コード例 #1
0
ファイル: view.html.php プロジェクト: bellodox/CrowdFunding
 public function display($tpl = null)
 {
     $this->option = JFactory::getApplication()->input->get('option');
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get('params');
     $this->displayProjectsNumber = $this->params->get('categories_display_projects_number', 0);
     $this->numberInRow = $this->params->get('categories_categories_row', 3);
     // Get description length
     $this->descriptionLength = $this->params->get('categories_description_length', 128);
     // Load projects number.
     if ($this->displayProjectsNumber) {
         $ids = array();
         foreach ($this->items as $item) {
             $ids[] = $item->id;
         }
         $categories = new Crowdfunding\Categories();
         $categories->setDb(JFactory::getDbo());
         $this->projectsNumber = $categories->getProjectsNumber($ids, array('state' => Prism\Constants::PUBLISHED, 'approved' => Prism\Constants::APPROVED));
     }
     // Prepare items parameters.
     if (is_array($this->items)) {
         $this->items = CrowdfundingHelper::prepareCategories($this->items, $this->numberInRow);
     }
     // Get layout
     $layout = $this->params->get('categories_layout', 'grid');
     $this->templateView = in_array($layout, $this->allowedLayouts, true) ? $layout : 'grid';
     // Get params
     /** @var  $params Joomla\Registry\Registry */
     $params = $this->state->get('params');
     $this->params = $params;
     // Prepare filters
     $this->listOrder = $this->escape($this->state->get('list.ordering'));
     $this->listDirn = $this->escape($this->state->get('list.direction'));
     $this->saveOrder = strcmp($this->listOrder, 'a.ordering') === 0;
     $this->prepareDocument();
     parent::display($tpl);
 }
コード例 #2
0
ファイル: route.php プロジェクト: pashakiz/crowdf
 /**
  *
  * Prepare categories path to the segments.
  * We use this method in the router "CrowdfundingParseRoute".
  *
  * @param integer $categoryId Category Id
  * @param array   $segments
  * @param object $menuItem
  * @param bool $menuItemGiven
  *
  * @return array
  */
 public static function prepareCategoriesSegments($categoryId, $segments, $menuItem, $menuItemGiven)
 {
     if ($menuItemGiven and isset($menuItem->query['id'])) {
         $menuCategoryId = $menuItem->query['id'];
     } else {
         $menuCategoryId = 0;
     }
     $categories = Crowdfunding\Categories::getInstance('Crowdfunding');
     $category = $categories->get($categoryId);
     if (!$category) {
         // We couldn't find the category we were given.
         return $segments;
     }
     $path = array_reverse($category->getPath());
     $array = array();
     // If a category ID match with an ID in a menu item,
     // we cannot generate an array with subcategories (aliases).
     foreach ($path as $id) {
         // Is an ID match with an ID in a menu item?
         if ((int) $id == (int) $menuCategoryId) {
             break;
         }
         // Add the item to the array with category aliases.
         /*list($tmp, $id) = explode(':', $id, 2);
           $array[] = $id;*/
         $array[] = str_replace(":", "-", $id);
     }
     $array = array_reverse($array);
     $segments = array_merge($segments, $array);
     return $segments;
 }
コード例 #3
0
ファイル: route.php プロジェクト: bellodox/CrowdFunding
 /**
  * Prepare categories path to the segments.
  * We use this method in the router "CrowdfundingParseRoute".
  *
  * @param integer $categoryId Category Id
  * @param array   $segments
  * @param object $menuItem
  * @param bool $menuItemGiven
  *
  * @return array
  */
 public static function prepareCategoriesSegments($categoryId, $segments, $menuItem, $menuItemGiven)
 {
     $menuCategoryId = 0;
     if ($menuItemGiven and (isset($menuItem->query) and !empty($menuItem->query['id']))) {
         $menuCategoryId = (int) $menuItem->query['id'];
     }
     $categories = Crowdfunding\Categories::getInstance('Crowdfunding');
     $category = $categories->get($categoryId);
     if (!$category) {
         // We couldn't find the category we were given.
         return $segments;
     }
     $path = array_reverse($category->getPath());
     $array = array();
     // If a category ID match with an ID in a menu item,
     // we cannot generate an array with subcategories (aliases).
     foreach ($path as $id) {
         // Is an ID match with an ID in a menu item?
         if ($menuCategoryId === (int) $id) {
             break;
         }
         $array[] = str_replace(':', '-', $id);
     }
     $array = array_reverse($array);
     $segments = array_merge($segments, $array);
     return $segments;
 }
コード例 #4
0
ファイル: view.html.php プロジェクト: pashakiz/crowdf
 private function prepareSubcategories()
 {
     $app = JFactory::getApplication();
     $categoryId = $app->input->getInt("id");
     $categories = new Crowdfunding\Categories();
     $category = $categories->get($categoryId);
     $this->categories = $category->getChildren();
     $this->subcategoriesPerRow = $this->params->get("categories_items_row", 3);
     $this->displayProjectsNumber = $this->params->get("categories_display_projects_number", 0);
     // Load projects number.
     if ($this->displayProjectsNumber) {
         $ids = array();
         foreach ($this->items as $item) {
             $ids[] = $item->id;
         }
         $categories->setDb(JFactory::getDbo());
         $this->projectsNumber = $categories->getProjectsNumber($ids, array("state" => 1));
     }
     $this->categories = CrowdfundingHelper::prepareCategories($this->categories);
 }