public function categoryAction() { $request = $this->getRequest(); $category = Modules_Category_Services_Category::factory(); if (null == $category) { Modules_Core_Services_Exception::error('ROUTE_NOT_FOUND'); } $this->view->category = $category; if ($category['meta']) { $this->view->headMeta($category['meta']); } $perPage = 30; $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(); $condition = array('status' => 'active', 'category_id' => $category['category_id']); $articles = Modules_News_Services_Article::find($start, $perPage, $condition); $numArticles = Modules_News_Services_Article::count($condition); $this->view->articles = $articles; $this->view->topArticle = $articles ? $articles[0] : null; // Pager require_once LIB_DIR . DS . 'PEAR' . DS . 'Pager' . DS . 'Sliding.php'; $pagerPath = $this->view->url('news_article_category', $category); $pagerOptions = array('mode' => 'Sliding', 'append' => false, 'perPage' => $perPage, 'delta' => 3, 'urlVar' => 'page', 'path' => $pagerPath, 'fileName' => 'page-%d', '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; $linkTagsRaw = $pager->linkTagsRaw; $this->view->linkTagsRaw = $linkTagsRaw; }
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; }
public function showAction() { $request = $this->getRequest(); $category = Modules_Category_Services_Category::factory(); if (null == $category) { return; } $categories = Modules_Category_Services_Category::getParents($category['category_id']); $this->view->categories = $categories; }
public function showAction() { $request = $this->getRequest(); $lang = $request->getParam('lang'); $category = Modules_Category_Services_Category::factory(); $categories = Modules_Category_Services_Category::getTree($lang, 'news'); $this->view->categories = $categories; $this->view->uuid = uniqid(); $this->view->currentCategory = $category; }
public function configAction() { $limit = $this->getParam('limit', 5); $this->view->limit = $limit; $categoryId = $this->getParam('category_id'); $categories = Modules_Category_Services_Category::getTree(null, 'news'); $this->view->categories = $categories; $this->view->categoryId = $categoryId; $style = $this->getParam('style'); $this->view->style = $style; $this->view->moduleName = Gio_Core_Widget::getIntance()->getModuleName(); $this->view->widgetName = Gio_Core_Widget::getIntance()->getWidgetName(); $this->view->widgetIndex = $this->getParam('widget_index'); }
public static function factory() { $request = Gio_Core_Request::getInstance(); $config = Gio_Core_Module::getConfig('category'); $param = isset($config['url']['param']) ? $config['url']['param'] : 'category_id'; $category = null; switch ($param) { case 'category_path': $category = Modules_Category_Services_Category::getByPath($request->getParam($param)); break; } if (null == $category) { $category = Modules_Category_Services_Category::getById($request->getParam('category_id')); } return $category; }
/** * @param array $links * @param string $lang * @return array */ public static function filter($links, $lang) { /** * Get the view instance */ $view = Gio_Core_View::getInstance(); /** * Get most recently activated articles * TODO: Make this variable configurable */ $limit = 10; // $articles = Modules_News_Services_Article::find(0, $limit, array('status' => 'active')); // // if (count($articles) > 0) { // foreach ($articles as $article) { // $links['news_article_details'][] = array( // 'title' => $article['title'], // 'text' => $article['title'], // 'href' => $view->url('news_article_details', $article), // ); // } // } /** * Get categories links */ $categories = Modules_Category_Services_Category::getTree($lang, 'news'); if (count($categories) > 0) { foreach ($categories as $category) { $links['news_article_category'][] = array('title' => $category['name'], 'text' => str_repeat('---', $category['depth']) . ' ' . $category['name'], 'href' => $view->url('news_article_category', $category)); $links['news_rss_category'][] = array('title' => $category['name'], 'text' => str_repeat('---', $category['depth']) . ' ' . $category['name'], 'href' => $view->url('news_rss_category', $category)); } } /** * RSS links for latest articles */ $links['news_rss_index'][] = array('href' => $view->url('news_rss_index', array('language' => $lang))); return $links; }
public function orderAction() { $this->setNoRender(); $this->disableLayout(); $request = $this->getRequest(); if (!$request->isPost()) { $this->getResponse()->setBody('RESULT_NOT_OK'); return; } $response = 'RESULT_NOT_OK'; $data = $request->getPost('data'); $json = new Services_JSON(); $data = $json->decode($data); foreach ($data as $category) { Modules_Category_Services_Category::updateOrder(array('category_id' => $category->id, 'parent_id' => $category->parent_id, 'left_id' => $category->left_id, 'right_id' => $category->right_id)); } $this->getResponse()->setBody('RESULT_OK'); }