Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public function editAction()
 {
     $request = $this->getRequest();
     $this->view->defaultModule = $this->_defaultModule;
     $categoryId = $request->getParam('category_id');
     $category = Modules_Category_Services_Category::getById($categoryId);
     if (null == $category) {
         throw new Exception('Data not found');
     }
     $oldCategory = $category;
     $this->view->categoryData = $category;
     $sourceCategory = Modules_Category_Services_Category::getSource($category);
     $this->view->sourceCategory = $sourceCategory;
     if ($request->isPost()) {
         $categoryData = $request->getPost('category');
         $categoryData['language'] = $category['language'];
         $categoryData['module_id'] = $category['module_id'];
         $categoryData['language'] = $category['language'];
         $categoryData = Modules_Category_Services_Category::validate($categoryData);
         if (isset($categoryData['messages_error']) && $categoryData['messages_error']) {
             $this->view->errorMessages = $categoryData['messages'];
             $categoryData['category_id'] = $categoryId;
             $this->view->categoryData = $categoryData;
             return;
         }
         $parentId = $category['parent_id'];
         $parentCategory = null;
         if ($parentId) {
             $parentCategory = Modules_Category_Services_Category::getById($parentId);
         }
         $path = $parentCategory && $parentCategory['category_path'] ? $parentCategory['category_path'] . '/' . $categoryData['slug'] : $categoryData['slug'];
         $category = array('category_id' => $categoryId, 'name' => $this->view->STRING->escape($categoryData['name']), 'slug' => $this->view->STRING->escape($categoryData['slug']), 'category_path' => $this->view->STRING->escape($path), 'meta' => $this->view->STRING->escape($categoryData['meta']), 'module_id' => $this->view->STRING->escape($categoryData['module_id']), 'parent_id' => $this->view->STRING->escape($categoryData['parent_id']), 'language' => $this->view->STRING->escape($categoryData['language']), 'created_date' => $this->view->STRING->escape($oldCategory['created_date']), 'modified_date' => date('Y-m-d H:i:s'), 'status' => $this->view->STRING->escape($categoryData['status']), 'user_id' => $oldCategory['user_id']);
         $sourceItem = isset($categoryData['source_item']) ? $categoryData['source_item'] : null;
         /**
          * Get parent category
          */
         if ($category['parent_id'] == $parentId) {
             /**
              * User do NOT change the parent category value
              */
             Modules_Category_Services_Category::update($category, $sourceItem);
         } else {
             /**
              * User changed parent category
              */
             Modules_Category_Services_Category::delete($oldCategory);
             Modules_Category_Services_Category::add($category, $sourceItem);
             Modules_Category_Services_Category::updateParents($category['language'], $category['module_id']);
         }
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('category_actions_edit_success'));
         $this->redirect($this->view->url('category_category_edit', $category));
     }
 }