コード例 #1
0
 public function indexAction()
 {
     /**
      * Display article or category
      */
     $objContent = new Models_Scontent();
     $objContentLang = new Models_ScontentLang();
     $objCategory = new Models_ScontentCategory();
     /**
      * Get param
      */
     $this->url = $this->_getParam('url', '');
     $this->url = trim($this->url, '/');
     $this->url = substr($this->url, 0, -5);
     //Remove .html
     //	    echo $this->url;die;
     if ('' == $this->url) {
         $this->_redirect('');
     }
     /**
      * Load content
      */
     $this->content = $objContent->getContentByUrl($this->url, $this->langId);
     //	    echo '<pre>';print_r($this->content);die;
     /**
      * Not found?
      */
     if (null == @$this->content['scontent_lang_id']) {
         $this->_redirectToNotFoundPage();
     }
     /**
      * Set params
      */
     $this->view->headTitle($this->content['title']);
     $this->view->menuId = $this->content['scontent_id'];
     if (null != @$this->content['layout']) {
         $this->setLayout($this->content['layout']);
     }
     /**
      * Prepare for view
      */
     $this->view->content = $this->content;
     $this->view->layout = @$this->content['layout'];
 }
コード例 #2
0
 public function deleteGeneralContentAction()
 {
     /**
      * Check permission
      */
     if (false == $this->checkPermission('delete_scontent')) {
         $this->_forwardToNoPermissionPage();
         return;
     }
     $id = $this->_getParam('id', false);
     if (false == $id) {
         $this->_redirect('scontent/admin/manager');
     }
     $ids = explode('_', trim($id, '_'));
     $objScontent = new Models_Scontent();
     try {
         foreach ($ids as $id) {
             $objScontent->delete(array('scontent_id=?' => $id));
         }
         $this->session->scontentMessage = array('success' => true, 'message' => Vi_Language::translate('Delete content successfully'));
     } catch (Exception $e) {
         $this->session->scontentMessage = array('success' => false, 'message' => Vi_Language::translate('Can NOT delete this content. Please try again'));
     }
     $this->_redirect('scontent/admin/manager');
 }