Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class controller_Index extends _Controller
- {
- protected $layout;
- protected $model;
- protected $modelUser;
- function __construct()
- {
- $this->layout = new _View('layout/index.phtml');
- $this->model = new model_Article;
- $this->modelUser = new model_User;
- $this->modelNews = new model_News;
- $this->layout->user = $this->modelUser->getCurrentUser();
- $data = $this->model->getItems();
- $this->layout->menu = $data;
- }
- function login()
- {
- if (isset($_POST['login']) && isset($_POST['password']))
- {
- $user = $this->modelUser->login($_POST);
- if (isset($user[0])) return $this->index();
- }
- $this->layout->main = new _View('login.phtml');
- return $this->layout;
- }
- function logout()
- {
- $this->modelUser->logout();
- return $this->index();
- }
- function index()
- {
- $view = new _View('index.phtml');
- $view->data = $this->model->getItems();
- $news = $this->modelNews->getNews();
- $view ->news = $news;
- $this->layout->main = $view;
- return $this->layout;
- }
- function news()
- {
- if (empty($_GET['id'])) self::http404();
- $data = $this->modelNews->getOneNews(array('id' => $_GET['id']));
- if (empty($data[0])) self::http404();
- self::$config['title'][] = $data[0]->title;
- $view = new _View('news.phtml');
- $view->data = $data;
- $this->layout->main = $view;
- return $this->layout;
- }
- function article()
- {
- if (empty($_GET['id'])) self::http404();
- $data = $this->model->getItem(array('id' => $_GET['id']));
- $menu = $this->model->getItems();
- if (empty($data[0])) self::http404();
- self::$config['title'][] = $data[0]->title;
- $view = new _View('article.phtml');
- $view->data = $data;
- $view->menu = $menu;
- $this->layout->main = $view;
- return $this->layout;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement