/** * Method to get category data for the current category * * @param int An optional ID */ public function getCategory() { if (!is_object($this->_item)) { if (isset($this->state->params)) { $params = $this->state->params; $options = array(); $options['countItems'] = $params->get('show_cat_num_articles', 1) || !$params->get('show_empty_categories_cat', 0); } else { $options['countItems'] = 0; } $categories = new JEMCategories($this->getState('category.id', 'root')); $this->_item = $categories->get($this->getState('category.id', 'root')); // Compute selected asset permissions. if (is_object($this->_item)) { $user = JFactory::getUser(); $userId = $user->get('id'); $asset = 'com_jem.category.' . $this->_item->id; // Check general create permission. if ($user->authorise('core.create', $asset)) { $this->_item->getParams()->set('access-create', true); } $this->_children = $this->_item->getChildren(); $this->_parent = false; if ($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; }
/** * Method to get category data for the current category * * @param int An optional ID */ public function getCategory() { if (!is_object($this->_item)) { $options = array(); if (isset($this->state->params)) { $params = $this->state->params; $options['countItems'] = ($params->get('show_cat_num_articles', 1) || !$params->get('show_empty_categories_cat', 0)) ? 1 : 0; } else { $options['countItems'] = 0; } $where_pub = $this->_getPublishWhere('i'); if (!empty($where_pub)) { $options['published_where'] = '(' . implode(' OR ', $where_pub) . ')'; } else { // something wrong - fallback to published events $options['published_where'] = 'i.published = 1'; } $catId = $this->getState('category.id', 'root'); $categories = new JEMCategories($catId, $options); $this->_item = $categories->get($catId); // Compute selected asset permissions. if (is_object($this->_item)) { // a JEMCategoryNode object $user = JemFactory::getUser(); $userId = $user->get('id'); // Check general or category specific create permission. $this->_item->getParams()->set('access-create', $user->can('add', 'event', false, false, $this->_item->id)); $this->_children = $this->_item->getChildren(); $this->_parent = $this->_item->getParent(); if (empty($this->_parent)) { $this->_parent = false; } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; }