public static function Instance() { if (self::$instance == null) { self::$instance = new M_Pages(); } return self::$instance; }
public function action_index() { $mArticles = M_Articles::Instance(); $mComments = M_Comments::Instance(); $mUsers = M_Users::Instance(); //$action = isset($params[0]) ? array_shift($params) : 'index'; $this->id = isset($this->params[0]) ? (int) $this->params[0] : 1; //array_shift($params); $User = $mUsers->Get(); $nick = $User["name"]; if ($User["name"] == '') { $nick = 'Гость'; } $mPages = M_Pages::Instance(); $act = '/page/index/'; $this->title .= ':: Главная'; $this->articles_on_page = 4; $this->pages = (int) $mArticles->number_of_pages($this->articles_on_page); $this->start_page = $mArticles->get_start_page($this->id, $this->pages); //Получение массива статей $this->articles = $mArticles->All($this->start_page * $this->articles_on_page, $this->articles_on_page); if ($mUsers->Can('EDIT_USERS')) { $layout = 'admin'; } else { $layout = $layout; } $vars = array('layout' => $layout, 'username' => $nick); $this->menu = $this->Template('./v/elements/menu.php', $vars); $vars = array('pages' => $this->pages, 'start_page' => $this->start_page, 'act' => $act); $this->pager = $this->Template('./v/elements/pager.php', $vars); $this->left_block = $mComments->latest_comments(); $vars = array('left_block' => $this->left_block); $this->left_block = $this->Template('./v/elements/new_comments.php', $vars); $vars = array('articles' => $this->articles, 'menu' => $this->menu, 'pager' => $this->pager, 'left_block' => $this->left_block); $this->content = $this->Template('./v/v_index.php', $vars); }