s; } /** * Method to get archived article data for the current section * * @param int $state The content state to pull from for the current section * @since 1.5 */ function getArchives($state = -1) { return $this->getData(-1); } /** * Method to get archived article data for the current section * * @param int $state The content state to pull from for the current section * @since 1.5 */ function getTree() { return $this->_loadTree(); } /** * Method to load section data if it doesn't exist. * * @access private * @return boolean True on success */ function _loadSection() { if (empty($this->_section)) { // Lets get the information for the current section if ($this->_id) { $where = ' WHERE id = '. (int) $this->_id; } else { $where = null; } $query = 'SELECT *' . ' FROM #__sections' . $where; $this->_db->setQuery($query, 0, 1); $this->_section = $this->_db->loadObject(); } return true; } /** * Method to load sibling category data if it doesn't exist. * * @access private * @return boolean True on success */ function _loadCategories() { global $mainframe; // Lets load the siblings if they don't already exist if (empty($this->_categories)) { $user =& JFactory::getUser(); // Get the page/component configuration $params = &$mainframe->getParams(); $noauth = !$params->get('show_noauth'); $gid = $user->get('aid', 0); $now = $mainframe->get('requestTime'); $nullDate = $this->_db->getNullDate(); // Ordering control $orderby = $params->get('orderby', ''); $orderby = ContentHelperQuery::orderbySecondary($orderby); // Handle the access permissions part of the main database query if ($user->authorize('com_content', 'edit', 'content', 'all')) { $xwhere = ''; $xwhere2 = ' AND b.state >= 0'; } else { $xwhere = ' AND a.published = 1'; $xwhere2 = ' AND b.state = 1' . ' AND ( b.publish_up = '.$this->_db->Quote($nullDate).' OR b.publish_up <= '.$this->_db->Quote($now).' )' . ' AND ( b.publish_down = '.$this->_db->Quote($nullDate).' OR b.publish_down >= '.$this->_db->Quote($now).' )'; if ($noauth) { $xwhere2 .= ' AND b.access <= '.(int) $gid; } } // Determine whether to show/hide the empty categories and sections $empty = null; $empty_sec = null; // show/hide empty categories in section if (!$params->get('show_empty_categories')) { $empty_sec = ' HAVING numitems > 0'; } // Handle the access permissions $access_check = null; if ($noauth) { $access_check = ' AND a.access <= '.(int) $gid; //$access_check .= ' AND b.access <= '.(int) $gid; } // Query of categories within section $query = 'SELECT a.*, COUNT( b.id ) AS numitems,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'. ' FROM #__categories AS a' . ' LEFT JOIN #__content AS b ON b.catid = a.id'. $xwhere2 . ' WHERE a.section = '.(int) $this->_id. $xwhere. $access_check . ' GROUP BY a.id'.$empty.$empty_sec . ' ORDER BY '. $orderby; $this->_db->setQuery($query); $this->_categories = $this->_db->loadObjectList(); } return true; } /** * Method to load content item data for items in the category if they don't * exist. * * @access private * @return boolean True on success */ function _loadData($state = 1) { if (empty($this->_section)) { return false; // TODO: set error -- can't get siblings when we don't know the category } // Lets load the content if it doesn't already exist if (empty($this->_data[$state])) { // Get the pagination request variables $limit = JRequest::getVar('limit', 0, '', 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $query = $this->_buildQuery(); $Arows = $this->_getList($query, $limitstart, $limit); // special handling required as Uncategorized content does not have a section / category id linkage $i = $limitstart; $rows = array(); foreach ($Arows as $row) { // check to determine if section or category has proper access rights $rows[$i] = $row; $i ++; } $this->_data[$state] = $rows; } return true; } /** * Method to load content item data for items in the category if they don't * exist. * * @access private * @return boolean True on success */ function _loadTree() { global $mainframe; // Lets load the content if it doesn't already exist if (empty($this->_tree)) { $user =& JFactory::getUser(); $aid = $user->get('aid', 0); $now = $mainframe->get('requestTime'); $nullDate = $this->_db->getNullDate(); // Get the information for the current section if ($this->_id) { $and = ' AND a.section = '.(int) $this->_id; } else { $and = null; } // Query of categories within section $query = 'SELECT a.name AS catname, a.title AS cattitle, b.* ' . ' FROM #__categories AS a' . ' INNER JOIN #__content AS b ON b.catid = a.id' . ' AND b.state = 1' . ' AND ( b.publish_up = '.$this->_db->Quote($nullDate).' OR b.publish_up <= '.$this->_db->Quote($now).' )' . ' AND ( b.publish_down = '.$this->_db->Quote($nullDate).' OR b.publish_down >= '.$this->_db->Quote($now).' )'; ' WHERE a.published = 1' . $and . ' AND a.access <= '.(int) $aid . ' ORDER BY a.catid, a.ordering, b.ordering'; $this->_db->setQuery($query); $this->_tree = $this->_db->loadObjectList(); } return true; } function _buildQuery($state = 1) { global $mainframe; // Get the page/component configuration $params = &$mainframe->getParams(); // If voting is turned on, get voting data as well for the content items $voting = ContentHelperQuery::buildVotingQuery($params); // Get the WHERE and ORDER BY clauses for the query $where = $this->_buildContentWhere($stat