Example #1
0
 public function delete($post_id)
 {
     if ($post_id <= 0) {
         return false;
     }
     $mComments = new M_Comments();
     $sql = "SELECT mlid FROM posts WHERE post_id =" . (int) $post_id;
     $result = $this->db->Select($sql);
     $mlid = isset($result[0]['mlid']) ? $result[0]['mlid'] : 0;
     if ($mComments->deleteEntriesSubject($post_id) !== false && parent::delete($post_id) > 0) {
         unset($mComments);
         if ($mlid > 0) {
             M_MenuLink::Instance()->delete($mlid);
         }
         $path = $this->ckupload_dir . 'post_' . $post_id;
         if (is_dir($path)) {
             $this->removeDirectory($path);
         }
         return true;
     }
     return false;
 }
Example #2
0
 public function action_page()
 {
     $mPosts = M_Posts::Instance();
     $post_id = isset($_GET['param']) ? $_GET['param'] : 0;
     $this->page = $mPosts->get($post_id);
     if (empty($this->page)) {
         $this->p404();
     }
     $this->title = $this->page['post_title'];
     $this->breadCrambsActive = $this->title;
     $this->menuLinkId = $this->page['mlid'];
     $this->page['children'] = array();
     //$mPosts->upPostViews($post_id);
     if ($this->page['mlid'] > 0 && $this->page['post_type'] == 'parent') {
         $this->page['children'] = M_MenuLink::Instance()->getTopChildren($this->page['mlid']);
     }
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/page/v_page.php');
     // Формирование контента страницы
     $this->blocks['_content_page'] = $this->Template($templateName, $this);
 }
Example #3
0
 public function getBreadCrumbs($mlid)
 {
     $breadCrambs = M_MenuLink::Instance()->getItemsBreadCrumbs($mlid);
     if (!empty($this->breadCrambsActive)) {
         $max = 20;
         $link_title = trim(strip_tags($this->breadCrambsActive));
         $link_title = mb_strlen($link_title) > $max ? mb_substr($link_title, 0, $max - 3) . '...' : $link_title;
         $breadCrambs[] = array('link_title' => $link_title, 'active' => true);
     }
     // Получение пути к шаблону
     $templateName = $this->getTemplate('v_bread_crambs.php');
     return $this->Template($templateName, array('breadCrambs' => $breadCrambs, 'mlid' => $mlid));
 }
Example #4
0
 public function getMenuWithChildren($menu_id = null)
 {
     $query = "SELECT menu_id, menu_title, menu_description\n\t\t\t\t\t\t\tFROM menu";
     if ($menu_id !== null) {
         $query .= " WHERE menu_id =" . (int) $menu_id;
     }
     $menu = $this->db->Select($query);
     foreach ($menu as $key => $item) {
         $menu[$key]['children'] = M_MenuLink::Instance()->getItemsByMenu($item['menu_id']);
     }
     return $menu;
 }
Example #5
0
 public function action_itemslist()
 {
     $mMenu = M_Menu::Instance();
     $menu_id = isset($_GET['param']) ? (int) $_GET['param'] : 0;
     if ($this->isPost()) {
         M_MenuLink::Instance()->editItemList($_POST);
         $this->redirect(M_Link::ToAdminMenu('itemslist', $menu_id));
     }
     $menu = $mMenu->getMenuWithChildren($menu_id);
     if (empty($menu)) {
         $this->p404();
     }
     $this->fields = $menu[0];
     // Получение пути к шаблону
     $templateName = $this->getTemplate('components/menu/v_itemslist.php');
     $this->content = $this->Template($templateName, $this);
 }