Esempio n. 1
0
 /**
  * (non-PHPdoc)
  * @see \tfc\mvc\interfaces\Action::run()
  */
 public function run()
 {
     $req = Ap::getRequest();
     $catId = $req->getInteger('catid');
     if ($catId <= 0) {
         $this->err404();
     }
     $order = $req->getTrim('order', '');
     $paged = PageHelper::getCurrPage();
     $category = Model::getInstance('Categories', 'posts')->findByPk($catId);
     if (!$category || !is_array($category)) {
         $this->err404();
     }
     $tplName = isset($category['tpl_list']) ? Mvc::$module . DS . $category['tpl_list'] : null;
     $this->assign('category', $category);
     $this->assign('meta_title', isset($category['meta_title']) ? $category['meta_title'] : '');
     $this->assign('meta_keywords', isset($category['meta_keywords']) ? $category['meta_keywords'] : '');
     $this->assign('meta_description', isset($category['meta_description']) ? $category['meta_description'] : '');
     $this->assign('url', UrlHelper::getInstance()->getPostIndex($category));
     $mod = Model::getInstance('Posts', 'posts');
     $ret = $mod->findRows(array('category_id' => $catId), $order, $paged);
     $this->render($ret, $tplName);
 }
Esempio n. 2
0
 /**
  * (non-PHPdoc)
  * @see \tfc\mvc\Widget::run()
  */
 public function run()
 {
     $findType = isset($this->find_type) ? trim($this->find_type) : '';
     if ($findType === '') {
         return;
     }
     $limit = isset($this->limit) ? (int) $this->limit : 0;
     $offset = isset($this->offset) ? (int) $this->offset : 0;
     $title = isset($this->title) ? trim($this->title) : '';
     $catId = 0;
     if (($p = strpos($findType, '-')) !== false) {
         $catId = (int) substr($findType, $p + 1);
         $findType = substr($findType, 0, $p);
     }
     $findType = strtolower($findType);
     if (!in_array($findType, Helper::$findTypes)) {
         return;
     }
     $title = '';
     $url = '';
     if ($findType === Helper::FIND_TYPE_CATID) {
         if ($catId <= 0) {
             return;
         }
         $row = Categories::findByPk($catId);
         if (!$row || !is_array($row) || !isset($row['category_name'])) {
             return;
         }
         $title = $row['category_name'];
         $url = UrlHelper::getInstance()->getPostIndex($row);
     } else {
         switch (true) {
             case $findType === Helper::FIND_TYPE_HEAD:
                 $title = Text::_('MOD_POSTS_POSTS_HEAD');
                 break;
             case $findType === Helper::FIND_TYPE_RECOMMEND:
                 $title = Text::_('MOD_POSTS_POSTS_RECOMMEND');
                 break;
             default:
                 break;
         }
     }
     $rows = array();
     switch (true) {
         case $findType === Helper::FIND_TYPE_CATID:
             $rows = Helper::getRowsByCatId($catId, '', $limit, $offset);
             break;
         case $findType === Helper::FIND_TYPE_HEAD:
             $rows = Helper::getHeads($limit, $offset);
             break;
         case $findType === Helper::FIND_TYPE_RECOMMEND:
             $rows = Helper::getRecommends($limit, $offset);
             break;
         default:
             break;
     }
     $isShow = false;
     if ($title !== '' && $rows && is_array($rows)) {
         $isShow = true;
     }
     $this->assign('is_show', $isShow);
     $this->assign('title', $title);
     $this->assign('url', $url);
     $this->assign('rows', $rows);
     $this->display();
 }
Esempio n. 3
0
 /**
  * 将常用数据设置到模板变量中
  * @return void
  */
 public function assignSystem()
 {
     $viw = Mvc::getView();
     $viw->assign('app', APP_NAME);
     $viw->assign('module', Mvc::$module);
     $viw->assign('controller', Mvc::$controller);
     $viw->assign('action', Mvc::$action);
     $viw->assign('sidebar', Mvc::$module . '/' . Mvc::$action . '_sidebar');
     $viw->assign('log_id', Log::getId());
     $viw->assign('language', Ap::getLanguageType());
     $viw->assign('urlHelper', UrlHelper::getInstance());
     $viw->assign('site_name', Options::getSiteName());
     if (!isset($viw->meta_title)) {
         $viw->assign('meta_title', Options::getMetaTitle());
     }
     if (!isset($viw->meta_keywords)) {
         $viw->assign('meta_keywords', Options::getMetaKeywords());
     }
     if (!isset($viw->meta_description)) {
         $viw->assign('meta_description', Options::getMetaDescription());
     }
     $viw->assign('powerby', Options::getPowerby());
     $viw->assign('stat_code', Options::getStatCode());
     if (($wfBackTrace = Registry::get('warning_backtrace')) !== null) {
         $viw->assign('warning_backtrace', $wfBackTrace);
     }
 }