コード例 #1
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function getAction()
 {
     $categoryId = $this->getParam('category_id');
     $category = Modules_Category_Services_Category::getById($categoryId);
     $this->view->category = $category;
     $limit = $this->getParam('limit', 5);
     $latestArticles = Modules_News_Services_Article::getLatestArticle($categoryId, $limit);
     $this->view->articles = $latestArticles;
 }
コード例 #2
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function showAction()
 {
     $limit = $this->getParam('limit', 5);
     $articles = Modules_News_Services_Article::getPhotoArticles($limit);
     if (count($articles) > 0) {
         $this->view->topArticle = $articles[0];
     }
     $this->view->articles = $articles;
 }
コード例 #3
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function showAction()
 {
     $request = $this->getRequest();
     $limit = $this->getParam('limit', 5);
     $categoryId = $this->getParam('category_id');
     $articleId = $this->getParam('article_id');
     $article = Modules_News_Services_Article::getById($articleId, true);
     $articles = Modules_News_Services_Article::getOlderArticles($article, $limit, $categoryId);
     $this->view->articles = $articles;
 }
コード例 #4
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function showAction()
 {
     $categoryId = $this->getParam('category_id');
     $this->view->categoryId = $categoryId;
     $style = $this->getParam('style');
     $this->view->style = $style;
     $limit = $this->getParam('limit', 10);
     $articles = Modules_News_Services_Article::getMostViewedArticle($categoryId, $limit);
     $this->view->articles = $articles;
 }
コード例 #5
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function showAction()
 {
     $categoryId = (int) $this->getParam('category_id');
     $category = Modules_Category_Services_Category::getById($categoryId);
     $this->view->category = $category;
     $limit = $this->getParam('limit', 5);
     $articles = Modules_News_Services_Article::getLatestArticle($categoryId, $limit);
     $this->view->articles = $articles;
     $style = $this->getParam('style');
     $this->view->style = $style;
 }
コード例 #6
0
ファイル: Widget.php プロジェクト: piratevn/cms-gio
 public function showAction()
 {
     $request = $this->getRequest();
     $limit = $this->getParam('limit', 20);
     $categoryId = $request->getParam('category_id');
     $articles = Modules_News_Services_Article::getHotArticle($limit, $categoryId);
     if (count($articles) > 0) {
         $this->view->articles = $articles;
         $this->view->topArticle = $articles[0];
     }
 }
コード例 #7
0
ファイル: Rss.php プロジェクト: piratevn/cms-gio
 public function indexAction()
 {
     $this->disableLayout();
     $start = 0;
     $perPage = 20;
     $condition = array('status' => 'active');
     $articles = Modules_News_Services_Article::find($start, $perPage, $condition);
     $this->view->articles = $articles;
     $buildDate = date('D, d M Y h:i:s');
     $this->view->buildDate = $buildDate;
     header('Content-Type: application/rss+xml; charset=utf-8');
 }
コード例 #8
0
ファイル: Article.php プロジェクト: piratevn/cms-gio
 /**
  * List news articles
  */
 public function listAction()
 {
     $request = $this->getRequest();
     $lang = $request->getParam('lang');
     $this->view->lang = $lang;
     $paramLang = $lang ? '/' . $lang : null;
     $perPage = 20;
     $pageIndex = (int) $request->getParam('page_index');
     if (null == $pageIndex || '' == $pageIndex || $pageIndex < 0) {
         $pageIndex = 1;
     }
     $start = ($pageIndex - 1) * $perPage;
     $this->view->pageIndex = $pageIndex;
     $this->view->articleDao = new Modules_News_Models_Mysql_Article();
     $user = Gio_Core_Session::getUser();
     $condition = array('status' => 'active', 'created_date_from' => date('Y-m-d 00:00:00'), 'created_date_to' => date('Y-m-d H:i:s'), 'search_form' => false, 'user_id' => $user['user_id'], 'search_my_articles' => true);
     $json = new Services_JSON();
     if ($request->isPost()) {
         $condition = $request->getPost('condition');
         $createdDateFrom = $request->getPost('created_date_from');
         $fromHour = isset($createdDateFrom['hour']) && $createdDateFrom['hour'] ? $createdDateFrom['hour'] : date('H');
         $fromMinute = isset($createdDateFrom['minute']) && $createdDateFrom['minute'] ? $createdDateFrom['minute'] : date('i');
         $fromSecond = isset($createdDateFrom['second']) && $createdDateFrom['second'] ? $createdDateFrom['second'] : date('s');
         $fromDay = isset($createdDateFrom['day']) && $createdDateFrom['day'] ? $createdDateFrom['day'] : date('d');
         $fromMonth = isset($createdDateFrom['month']) && $createdDateFrom['month'] ? $createdDateFrom['month'] : date('m');
         $fromYear = isset($createdDateFrom['year']) && $createdDateFrom['year'] ? $createdDateFrom['year'] : date('Y');
         $condition['created_date_from'] = date('Y-m-d H:i:s', strtotime("{$fromYear}-{$fromMonth}-{$fromDay} {$fromHour}:{$fromMinute}:{$fromSecond}"));
         $createdDateTo = $request->getPost('created_date_to');
         $toHour = isset($createdDateTo['hour']) && $createdDateTo['hour'] ? $createdDateTo['hour'] : date('H');
         $toMinute = isset($createdDateTo['minute']) && $createdDateTo['minute'] ? $createdDateTo['minute'] : date('i');
         $toSecond = isset($createdDateTo['second']) && $createdDateTo['second'] ? $createdDateTo['second'] : date('s');
         $toDay = isset($createdDateTo['day']) && $createdDateTo['day'] ? $createdDateTo['day'] : date('d');
         $toMonth = isset($createdDateTo['month']) && $createdDateTo['month'] ? $createdDateTo['month'] : date('m');
         $toYear = isset($createdDateTo['year']) && $createdDateTo['year'] ? $createdDateTo['year'] : date('Y');
         $condition['created_date_to'] = date('Y-m-d H:i:s', strtotime("{$toYear}-{$toMonth}-{$toDay} {$toHour}:{$toMinute}:{$toSecond}"));
         $condition['search_form'] = true;
         /**
          * Search in my articles 
          */
         $searchMyArticles = isset($condition['search_my_articles']) && $condition['search_my_articles'] == 1 ? true : false;
         $condition['user_id'] = $searchMyArticles ? $user['user_id'] : null;
         $params = rawurlencode(base64_encode($json->encodeUnsafe($condition)));
     } else {
         $params = $request->getParam('q');
         $params != null ? $condition = (array) $json->decode(rawurldecode(base64_decode($params))) : ($params = rawurlencode(base64_encode($json->encodeUnsafe($condition))));
     }
     $params = empty($condition) ? null : $params;
     $this->view->condition = $condition;
     $articles = Modules_News_Services_Article::find($start, $perPage, $condition);
     $numArticles = Modules_News_Services_Article::count($condition);
     $this->view->articles = $articles;
     // Pager
     require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php';
     $pagerPath = $this->view->url('news_article_list');
     $pagerOptions = array('mode' => 'Sliding', 'append' => false, 'perPage' => $perPage, 'delta' => 3, 'urlVar' => 'page', 'path' => $pagerPath, 'fileName' => null == $params ? 'page-%d' . $paramLang : 'page-%d' . $paramLang . '/?q=' . $params, 'separator' => '', 'nextImg' => '<small class="icon arrow_right"></small>', 'prevImg' => '<small class="icon arrow_left"></small>', 'altNext' => '', 'altPrev' => '', 'altPage' => '', 'totalItems' => $numArticles, 'currentPage' => $pageIndex, 'urlSeparator' => '/', 'spacesBeforeSeparator' => 0, 'spacesAfterSeparator' => 0, 'curPageSpanPre' => '<a href="javascript: void();" class="current">', 'curPageSpanPost' => '</a>');
     $pager = new Pager_Sliding($pagerOptions);
     $this->view->pager = $pager;
 }