/** * @return JDatabaseQuery */ function getListQuery() { // Set the archive ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $categoryOrderby = ''; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive $query->select(' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'); $query->select(' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug'); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where('MONTH(' . $queryDate . ') = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where('YEAR(' . $queryDate . ') = ' . $year); } //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering The field to order on. * @param string $direction The direction to order on. * * @return void. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { parent::populateState($ordering, $direction); $input = JFactory::getApplication()->input; $user = JFactory::getUser(); // List state information $limitstart = $input->getUInt('limitstart', 0); $this->setState('list.start', $limitstart); $params = $this->state->params; $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links'); $this->setState('list.limit', $limit); $this->setState('list.links', $params->get('num_links')); $this->setState('filter.frontpage', true); if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { // Filter on published for those who do not have edit or edit.state rights. $this->setState('filter.published', 1); } else { $this->setState('filter.published', array(0, 1, 2)); } // Check for category selection if ($params->get('featured_categories') && implode(',', $params->get('featured_categories')) == true) { $featuredCategories = $params->get('featured_categories'); $this->setState('filter.frontpage.categories', $featuredCategories); } $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate); $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $this->setState('list.ordering', $primary . $secondary . ', a.created DESC'); $this->setState('list.direction', ''); }
function _buildContentOrderBy($state = 1) { $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } // Get the page/component configuration $app =& JFactory::getApplication(); $params =& $app->getParams(); switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= "{$primary} {$secondary}"; return $orderby; }
/** * Build the orderby for the query * * @return string $orderby portion of query */ protected function _buildContentOrderBy() { $app =& JFactory::getApplication('site'); $params = $this->_state->params; $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0); $filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } $articleOrderby = $params->get('article_orderby', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('category_orderby', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby .= $primary . ' ' . $secondary . ' a.created DESC '; return $orderby; }
/** * Display the view * * @return mixed False on error, null otherwise. */ public function display($tpl = null) { $user = JFactory::getUser(); $app = JFactory::getApplication(); $state = $this->get('State'); $items = $this->get('Items'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $params =& $state->params; // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). foreach ($items as $i => &$item) { $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->event = new stdClass(); $dispatcher = JEventDispatcher::getInstance(); $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'com_content.featured'); $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } // Preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interogate the arrays. $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->lead_items[$i] =& $items[$i]; } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->intro_items[$i] =& $items[$i]; } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns); } // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $max; $i++) { $this->link_items[$i] =& $items[$i]; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->params =& $params; $this->items =& $items; $this->pagination =& $pagination; $this->user =& $user; $this->_prepareDocument(); parent::display($tpl); }
/** * Get the master query for retrieving a list of articles subject to the model state. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // Set the archive ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $categoryOrderby = ''; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive // Sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id . ' END as catslug'; $query->select($case_when); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where($query->month($queryDate) . ' = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where($query->year($queryDate) . ' = ' . $year); } return $query; }
public function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); // Get some data from the models $state = $this->get('State'); $params = $state->params; $items = $this->get('Items'); $category = $this->get('Category'); $children = $this->get('Children'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if ($category == false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } if ($parent == false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } // Setup the category parameters. $cparams = $category->getParams(); $category->params = clone $params; $category->params->merge($cparams); // Check whether category access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if (!in_array($category->access, $groups)) { return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); } // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->event = new stdClass(); $dispatcher = JEventDispatcher::getInstance(); $item->introtext = JHtml::_('content.prepare', $item->introtext, '', 'com_content.category'); $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } // Check for layout override only if this is not the active menu item // If it is the active menu item, then the view and category id will match $active = $app->getMenu()->getActive(); if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $category->id) === false)) { // Get the layout from the merged category params if ($layout = $category->params->get('category_layout')) { $this->setLayout($layout); } } elseif (isset($active->query['layout'])) { // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout) $this->setLayout($active->query['layout']); } // For blog layouts, preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interrogate the arrays. if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') { $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->lead_items[$i] =& $items[$i]; } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->intro_items[$i] =& $items[$i]; } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns); } $limit = $numLeading + $numIntro + $numLinks; // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $limit && $i < $max; $i++) { $this->link_items[$i] =& $items[$i]; } } $children = array($category->id => $children); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevel = $params->get('maxLevel', -1); $this->state =& $state; $this->items =& $items; $this->category =& $category; $this->children =& $children; $this->params =& $params; $this->parent =& $parent; $this->pagination =& $pagination; $this->user =& $user; // Increment the category hit counter $model = $this->getModel(); $model->hit(); $this->_prepareDocument(); parent::display($tpl); }
function _buildContentOrderBy() { $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } // Get the page/component configuration $params = $this->getState('parameters.menu'); if (!is_object($params)) { $params =& JComponentHelper::getParams('com_content'); } // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $primary = ContentHelperQuery::orderbySecondary($orderby_sec); $orderby .= $primary; return $orderby; }
function _buildContentOrderBy($state = 1) { $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } // Get the parameters of the active menu item $menu =& JSite::getMenu(); $item = $menu->getActive(); $params =& $menu->getParams($item->id); switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= "{$primary} {$secondary}"; return $orderby; }
/** * * Get data * * @param Array $pk */ public function getData($pk) { $this->_data = new stdClass(); $this->_data->items = array(); $this->_data->children = null; $this->_data->category = null; jimport('joomla.application.categories'); $this->setState('category.id', $pk['id']); $this->_data->items = $this->getItems(); // Get some data from the models if (isset($this->state->params)) { $this->_data->params = $this->state->params; $options = array(); $options['countItems'] = $this->_data->params->get('show_cat_num_articles', 1) || !$this->_data->params->get('show_empty_categories_cat', 0); } else { $options['countItems'] = 0; } $categories = JCategories::getInstance('Content', $options); $this->_data->category = $categories->get($this->getState('category.id', 'root')); // Compute selected asset permissions. if (is_object($this->_data->category)) { // TODO: Why aren't we lazy loading the children and siblings? $this->_data->children = $this->_data->category->getChildren(); $this->_data->parent = false; if ($this->_data->category->getParent()) { $this->_data->parent = $this->_data->category->getParent(); } // Setup the category parameters. $cparams = $this->_data->category->getParams(); $this->_data->category->params = clone $this->_data->params; $this->_data->category->params->merge($cparams); } else { $this->_data->children = false; $this->_data->parent = false; } // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $this->_data->params->def('num_leading_articles', 1); $numIntro = $this->_data->params->def('num_intro_articles', 4); $numLinks = $this->_data->params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). for ($i = 0, $n = count($this->_data->items); $i < $n; $i++) { $item =& $this->_data->items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } // Ignore content plugins on links. if ($i < $numLeading + $numIntro) { $item->introtext = JHtml::_('content.prepare', $item->introtext); } } // For blog layouts, preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interrogate the arrays. if ($this->_data->params->get('layout_type') == 'blog' || @$pk['layout'] == 'blog') { $max = count($this->_data->items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->_data->lead_items[$i] =& $this->_data->items[$i]; // Add router helpers. $item =& $this->_data->lead_items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->_data->intro_items[$i] =& $this->_data->items[$i]; // Add router helpers. $item =& $this->_data->intro_items[$i]; $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; } $this->_data->columns = max(1, $this->_data->params->def('num_columns', 1)); $order = $this->_data->params->def('multi_column_order', 1); if ($order == 0 && $this->_data->columns > 1) { // call order down helper $this->_data->intro_items = ContentHelperQuery::orderDownColumns($this->_data->intro_items, $this->_data->columns); } $limit = $numLeading + $numIntro + $numLinks; // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $limit && $i < $max; $i++) { $this->_data->link_items[$i] =& $this->_data->items[$i]; } } // Order subcategories if (sizeof($this->_data->children)) { if ($this->_data->params->get('orderby_pri') == 'alpha' || $this->_data->params->get('orderby_pri') == 'ralpha') { jimport('joomla.utilities.arrayhelper'); JArrayHelper::sortObjects($this->_data->children, 'title', $this->_data->params->get('orderby_pri') == 'alpha' ? 1 : -1); } } if (isset($this->_data->category->id)) { $this->_data->children = array($this->_data->category->id => $this->_data->children); } //Escape strings for HTML output $this->_data->pageclass_sfx = htmlspecialchars($this->_data->params->get('pageclass_sfx')); $this->_data->maxLevel = $this->_data->params->get('maxLevel', -1); $this->_data->state = $this->state; return $this->_data; }
function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $uri = JFactory::getURI(); $document = JFactory::getDocument(); $dispatcher = JDispatcher::getInstance(); $pathway = $app->getPathway(); // Get the menu item object $menus = $app->getMenu(); $menu = $menus->getActive(); $params = $app->getParams(); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // Initialize variables $article = $this->get('Article'); $state = $this->get('State'); // Request variables $layout = $params->get('layout_type'); $task = JRequest::getCmd('task'); $numIntro = $params->get('num_intro_articles', 4); $numLeading = $params->get('num_leading_articles', 1); $numLinks = $params->get('num_links', 4); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $itemid = JRequest::getInt('Itemid', 0); $params->def('display_num', $app->getCfg('list_limit')); $default_limit = $params->get('display_num'); if ($layout == 'blog') { $limit = $numIntro + $numLeading + $numLinks; } else { $params->def('display_num', $app->getCfg('list_limit')); $default_limit = $params->get('display_num'); $limit = $app->getUserStateFromRequest('com_fjrelated.list.:' . $itemid . '.limit', 'limit', $default_limit, 'int'); } JRequest::setVar('limit', (int) $limit); $contentConfig = JComponentHelper::getParams('com_content'); $params->def('show_page_title', $contentConfig->get('show_title')); $menu_params = new JParameter($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', $article->title ? $article->title : $menu->title); } $document->setTitle($params->get('page_title')); if ($article->metadesc) { $document->setDescription($article->metadesc); } if ($article->metakey) { $document->setMetadata('keywords', $article->metakey); } // Get some data from the model $items = $this->get('Data'); if ($items) { $total = $this->get('Total'); // only do count if there are items to count } else { $total = 0; } //add alternate feed link if ($params->get('show_feed_link', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } // Create a user access object for the user $access = new stdClass(); $access->canEdit = $user->authorize('core.edit', 'com_content'); $access->canEditOwn = $user->authorize('core.edit.own', 'com_content'); $access->canPublish = $user->authorize('core.edit.state', 'com_content'); jimport('joomla.html.pagination'); //In case we are in a blog view set the limit if ($layout == 'blog') { $pagination = new JPagination($total, $limitstart, $limit - $numLinks); } else { $pagination = new JPagination($total, $limitstart, $limit); } // Compute the article slugs and prepare introtext (runs content plugins). foreach ($items as $i => &$item) { $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->event = new stdClass(); $dispatcher = JDispatcher::getInstance(); // Ignore content plugins on links. if ($i < $numLeading + $numIntro) { $item->introtext = JHtml::_('content.prepare', $item->introtext); $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } } // Preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interogate the arrays. $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->lead_items[$i] =& $items[$i]; } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->intro_items[$i] =& $items[$i]; } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns); } // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $max; $i++) { $this->link_items[$i] =& $items[$i]; } $this->assignRef('article', $article); $this->assignRef('params', $params); $this->assignRef('user', $user); $this->assignRef('access', $access); $this->assignRef('items', $items); $this->assign('total', $total); $this->assign('action', $uri->toString()); $this->assignRef('pagination', $pagination); $this->assignRef('state', $state); parent::display($tpl); }
function _buildQuery($state = 1) { $app = JFactory::getApplication(); $params = $app->getParams(); $user = JFactory::getUser(); $userGroups = implode(',', $user->getAuthorisedViewLevels()); // If voting is turned on, get voting data as well for the content items $voting = ContentHelperQuery::buildVotingQuery($params); $metakey = trim($this->_article->metakey); $thisAlias = trim($this->_article->created_by_alias); $thisAuthor = $this->_article->created_by; $matchAuthor = trim($params->get('matchAuthor', 0)); $matchAuthorAlias = trim($params->get('matchAuthorAlias', 0)); $noauth = !$params->get('show_noauth'); $anyOrAll = $params->get('anyOrAll', 'any'); $publishedState = $params->get('fjArticleState', 1); if ($metakey || $matchAuthor || $matchAuthorAlias && $thisAlias) { $db = $this->getDBO(); $user = JFactory::getUser(); $date = JFactory::getDate(); $now = $date->toMySQL(); $nullDate = $db->getNullDate(); // explode the meta keys on a comma $keys = explode(',', $metakey); $likes = array(); // assemble any non-blank word(s) foreach ($keys as $key) { $key = trim($key); if ($key) { // surround with commas so first and last items have surrounding commas $likes[] = ',' . $this->_db->getEscaped($key) . ','; } } $ordering = $params->get('ordering', 'alpha'); $sqlSort = $this->_buildContentOrderBy($ordering); // set connector to OR or AND based on parameter $sqlConnector = $anyOrAll == 'any' ? ' OR ' : ' AND '; if ($likes && $anyOrAll != 'exact') { $keywordSelection = ' CONCAT(",", REPLACE(a.metakey,", ",","),",") LIKE "%' . implode('%"' . $sqlConnector . 'CONCAT(",", REPLACE(a.metakey,", ",","),",") LIKE "%', $likes) . '%"'; } else { if ($likes && $anyOrAll == 'exact') { $keywordSelection = ' UPPER(a.metakey) = "' . strtoupper($metakey) . '" '; } else { // in this case we are only going to match on author or alias, so we put a harmless false selection here $keywordSelection = ' 1 = 2 '; // just as a placeholder (so our AND's and OR's still work) } } // get published state select if (is_array($publishedState)) { $publishedStateCondition = implode(',', $publishedState); } else { $publishedStateCondition = $publishedState; } // get category selections // process either as comma-delimited list or as array (for backward compatibility) $catid = is_array($params->get('catid')) ? implode(',', $params->get('catid')) : trim($params->get('catid')); $catCondition = ''; if ($catid || $catid == '0') { $ids = str_replace('C', $this->_article->catid, strtoupper($catid)); $ids = explode(',', $ids); JArrayHelper::toInteger($ids); $catCondition = ' AND a.catid IN (' . implode(',', $ids) . ')'; } if ($matchAuthor) { $matchAuthorCondition = $sqlConnector . 'a.created_by = ' . $db->Quote($thisAuthor) . ' '; } if ($matchAuthorAlias && $thisAlias) { $matchAuthorAliasCondition = $sqlConnector . 'UPPER(a.created_by_alias) = ' . $db->Quote(strtoupper($thisAlias)) . ' '; } else { $matchAuthorAliasCondition = ' '; } if ($noauth) { $noauthCondition = ' AND a.access IN (' . $userGroups . ')' . ' AND cc.access IN (' . $userGroups . ')' . ' AND cc.published = 1 '; } if ($params->get('filter_type') != 'none') { $filterWhere = $this->_getFilterWhere($params->get('filter_type')); } else { $filterWhere = ''; } // select other items based on the metakey field 'like' the keys found $query = 'SELECT a.id, a.title, a.alias, a.introtext, a.fulltext, DATE_FORMAT(a.created, "%Y-%m-%d") AS created, a.state, a.catid, a.hits,' . ' a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' . ' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.attribs, a.hits, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,' . ' cc.access AS cat_access, cc.published AS cat_state, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,' . ' CHAR_LENGTH( a.`fulltext` ) AS readmore, u.name AS author ' . $voting['select'] . ', ' . ' a.metakey, "0" as match_count, "" as match_list, "" as main_article_keywords, ' . ' cc.title as category, "article" as link_type, cc.alias as category_alias, parent.id as parent_id, parent.alias as parent_alias' . ' FROM #__content AS a' . ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid' . ' LEFT JOIN #__users AS u ON u.id = a.created_by' . ' LEFT JOIN #__categories AS parent on parent.id = cc.parent_id' . $voting['join'] . ' WHERE a.id != ' . (int) $this->_id . ' AND a.state IN (' . $publishedStateCondition . ') ' . ($noauth ? $noauthCondition : '') . ' AND ( ' . $keywordSelection . ($matchAuthor ? $matchAuthorCondition : '') . ($matchAuthorAlias ? $matchAuthorAliasCondition : '') . ' )' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' ) ' . ($catCondition ? $catCondition : '') . $filterWhere . $sqlSort; // sort the query } else { $query = ''; } return $query; }
public static function _buildContentOrderBy($atribmenu) { $app = JFactory::getApplication('site'); $db = JFactory::getDbo(); $params = $atribmenu; $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; /*if (!in_array($orderCol, $this->filter_fields)) { $orderCol = null; }*/ if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) { $orderDirn = 'ASC'; } if ($orderCol && $orderDirn) { $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', '; } $articleOrderby = $atribmenu['orderby_sec'] ? $atribmenu['orderby_sec'] : 'rdate'; $articleOrderDate = $atribmenu['order_date']; $categoryOrderby = $atribmenu['orderby_pri']; require_once JPATH_SITE . '/components/com_content/helpers/query.php'; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby .= $primary . ' ' . $secondary . ' a.created '; return $orderby; }
/** * Get the list of items. * * @return JDatabaseQuery */ protected function getListQuery() { // Set the blog ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Filter by frontpage. if ($this->getState('filter.frontpage')) { $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id'); } // Filter by categories $featuredCategories = $this->getState('filter.frontpage.categories'); if (is_array($featuredCategories) && !in_array('', $featuredCategories)) { $query->where('a.catid IN (' . implode(',', $featuredCategories) . ')'); } return $query; }
/** * Get featured items * */ public function getData($pk) { JSNFactory::localimport('libraries.joomlashine.config'); $params = JSNConfig::getMenuParams($pk['Itemid']); JSNConfig::megreGlobalParams('com_content', $params); $this->setState('params', $params); $data = new stdClass(); $data->params = $params; $activeAllParams = new JRegistry(); if ($params instanceof JRegistry) { foreach ($params->toArray() as $key => $val) { if (strpos($key, 'show_') !== false && (int) $params->get($key) == 0) { $activeAllParams->set($key, 1); } else { $activeAllParams->set($key, $val); } } } $limit = (int) $params->def('num_leading_articles', 1) + (int) $params->get('num_intro_articles', 4) + (int) $params->def('num_links', 4); $this->setState('params', $activeAllParams); $this->setState('filter.published', 1); $this->setState('filter.access', ''); $this->setState('list.start', 0); $this->setState('list.limit', $limit); $this->setState('list.direction', ''); $this->setState('list.filter', ''); // filter.subcategories indicates whether to include articles from subcategories in the list or blog $this->setState('list.links', $activeAllParams->get('num_links')); if ($activeAllParams->get('featured_categories') && implode(',', $activeAllParams->get('featured_categories')) == true) { $this->setState('filter.frontpage.categories', $activeAllParams->get('featured_categories')); } $this->setState('filter.frontpage', 1); $items = parent::getItems(); // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). foreach ($items as $i => &$item) { $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } // Ignore content plugins on links. if ($i < $numLeading + $numIntro) { $item->introtext = JHtml::_('content.prepare', $item->introtext); } } // Preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interogate the arrays. $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $data->lead_items[$i] =& $items[$i]; } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $data->intro_items[$i] =& $items[$i]; } $data->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $data->columns > 1) { // call order down helper $data->intro_items = ContentHelperQuery::orderDownColumns($data->intro_items, $data->columns); } // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $max; $i++) { $data->link_items[$i] =& $items[$i]; } $data->pagination = $this->getPagination(); //Escape strings for HTML output $data->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); return $data; }
/** * Generates the order by part of the query according to the * menu/component/user settings. It checks if the current user * has already changed the article's ordering column in the frontend * * @param JRegistry $params * @param int $parentId * @param int $itemid * @return string */ static function buildContentOrderBy(&$params, $parentId, $itemid) { $app = JFactory::getApplication('site'); // Case when the child gets a different menu itemid than it's parent if ($parentId != $itemid) { $menu = $app->getMenu(); $item = $menu->getItem($itemid); $menuParams = clone $params; $itemParams = new JRegistry($item->params); $menuParams->merge($itemParams); } else { $menuParams =& $params; } $filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } $articleOrderby = $menuParams->get('orderby_sec', 'rdate'); $articleOrderDate = $menuParams->get('order_date'); //$categoryOrderby = $menuParams->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; //$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); //$orderby .= $primary . ' ' . $secondary . ' a.created '; $orderby .= $secondary . ' a.created '; return $orderby; }
function _buildContentOrderBy() { $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); if (!in_array($filter_order, array('a.id', 'a.title', 'a.alias', 'a.title_alias', 'a.introtext', 'a.sectionid', 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias', 'a.modified', 'a.modified_by', 'a.hits', 'a.ordering', 'cc.title', 's.title'))) { $filter_order = ''; } if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { $filter_order_Dir = ''; } $orderby = ' ORDER BY '; if ($filter_order) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } // Get the page/component configuration $params = $this->getState('parameters.menu'); if (!is_object($params)) { $params =& JComponentHelper::getParams('com_content'); } // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $primary = ContentHelperQuery::orderbySecondary($orderby_sec); $orderby .= $primary; return $orderby; }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a Error object. */ public function display($tpl = null) { parent::commonCategoryDisplay(); // Prepare the data // Get the metrics for the structural page layout. $params = $this->params; $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). foreach ($this->items as $item) { $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->event = new stdClass(); $dispatcher = JEventDispatcher::getInstance(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0)); // Old plugins: Use processed text as introtext $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } // Check for layout override only if this is not the active menu item // If it is the active menu item, then the view and category id will match $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $this->category->id) === false)) { // Get the layout from the merged category params if ($layout = $this->category->params->get('category_layout')) { $this->setLayout($layout); } } elseif (isset($active->query['layout'])) { // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout) $this->setLayout($active->query['layout']); } // For blog layouts, preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interrogate the arrays. if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') { foreach ($this->items as $i => $item) { if ($i < $numLeading) { $this->lead_items[] = $item; } elseif ($i >= $numLeading && $i < $numLeading + $numIntro) { $this->intro_items[] = $item; } elseif ($i < $numLeading + $numIntro + $numLinks) { $this->link_items[] = $item; } else { continue; } } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // Call order down helper $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns); } } // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); $id = (int) @$menu->query['id']; // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->get('sitename'); } elseif ($app->get('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); } if (empty($title)) { $title = $this->category->title; } $this->document->setTitle($title); if ($this->category->metadesc) { $this->document->setDescription($this->category->metadesc); } elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->category->metakey) { $this->document->setMetadata('keywords', $this->category->metakey); } elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } if (!is_object($this->category->metadata)) { $this->category->metadata = new Registry($this->category->metadata); } if ($app->get('MetaAuthor') == '1' && $this->category->get('author', '')) { $this->document->setMetaData('author', $this->category->get('author', '')); } $mdata = $this->category->metadata->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } return parent::display($tpl); }
function _buildContentOrderBy($state = 1) { global $mainframe; // Get the page/component configuration $params =& $mainframe->getParams(); $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } if ($filter_order == 'author') { $orderby .= 'created_by_alias ' . $filter_order_Dir . ', '; } switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', '; $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', '; $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= $primary . ' ' . $secondary . ' a.created DESC'; return $orderby; }
function _buildContentOrderBy($state = 1) { global $mainframe; // Get the page/component configuration $params =& $mainframe->getParams(); $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0); $filter_order = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); if (!in_array($filter_order, array('a.title', 'author', 'a.hits', 'a.created', 'a.publish_up', 'a.publish_down', 'a.modified'))) { $filter_order = ''; } if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) { $filter_order_Dir = 'ASC'; } $orderby = ' ORDER BY '; if ($filter_order && $filter_order_Dir) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } if ($filter_order == 'author') { $orderby .= 'created_by_alias ' . $filter_order_Dir . ', '; } switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', '; $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', '; $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= $primary . ' ' . $secondary . ' a.created DESC'; return $orderby; }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a Error object. */ public function display($tpl = null) { parent::commonCategoryDisplay(); // Prepare the data // Get the metrics for the structural page layout. $params = $this->params; $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); // Compute the article slugs and prepare introtext (runs content plugins). foreach ($this->items as $item) { $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->event = new stdClass(); $dispatcher = JEventDispatcher::getInstance(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentPrepare', array('com_content.category', &$item, &$item->params, 0)); // Old plugins: Use processed text as introtext $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.category', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.category', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.category', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } // Check for layout override only if this is not the active menu item // If it is the active menu item, then the view and category id will match $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&id=' . (string) $this->category->id) === false)) { // Get the layout from the merged category params if ($layout = $this->category->params->get('category_layout')) { $this->setLayout($layout); } } elseif (isset($active->query['layout'])) { // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout) $this->setLayout($active->query['layout']); } // For blog layouts, preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interrogate the arrays. if ($params->get('layout_type') == 'blog' || $this->getLayout() == 'blog') { //$max = count($this->items); foreach ($this->items as $i => $item) { if ($i < $numLeading) { $this->lead_items[] = $item; } elseif ($i >= $numLeading && $i < $numLeading + $numIntro) { $this->intro_items[] = $item; } elseif ($i < $numLeading + $numIntro + $numLinks) { $this->link_items[] = $item; } else { continue; } } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns); } } return parent::display($tpl); }
/** * Build the orderby for the query * * @return string $orderby portion of query * @since 1.5 */ protected function _buildContentOrderBy() { $app = JFactory::getApplication('site'); $db = $this->getDbo(); $params = $this->state->params; $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; if (!in_array($orderCol, $this->filter_fields)) { $orderCol = null; } if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) { $orderDirn = 'ASC'; } if ($orderCol && $orderDirn) { $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', '; } $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby .= $primary . ' ' . $secondary . ' a.created '; return $orderby; }
function buildContentOrderBy() { $orderby = array(); $orderby_sec = $this->params->def('orderby_sec', 'rdate'); if ($orderby_sec == 'random') { return ' ORDER BY RAND() '; } else { $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $this->params->def('orderby_pri', ''); $orderby[] = ContentHelperQuery::orderbySecondary($orderby_sec); $orderby[] = ContentHelperQuery::orderbyPrimary($orderby_pri); $orderby = array_filter($orderby); if (!count($orderby)) { $orderby[] = 'a.created DESC'; } return ' ORDER BY ' . implode(',', $orderby); } }
/** * Method to load content article data * * @access private * @return boolean True on success * @since 1.5 */ function _loadArticle() { global $mainframe; if ($this->_id == '0') { return false; } // Load the content if it doesn't already exist if (empty($this->_article)) { // Get the page/component configuration $params =& $mainframe->getParams(); // If voting is turned on, get voting data as well for the article $voting = ContentHelperQuery::buildVotingQuery($params); // Get the WHERE clause $where = $this->_buildContentWhere(); $query = 'SELECT a.*, u.name AS author, u.usertype, cc.title AS category, s.title AS section,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,' . ' g.name AS groups, s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access ' . $voting['select'] . ' FROM #__content AS a' . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid' . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"' . ' LEFT JOIN #__users AS u ON u.id = a.created_by' . ' LEFT JOIN #__groups AS g ON a.access = g.id' . $voting['join'] . $where; $this->_db->setQuery($query); $this->_article = $this->_db->loadObject(); if (!$this->_article) { return false; } if ($this->_article->publish_down == $this->_db->getNullDate()) { $this->_article->publish_down = JText::_('Never'); } // These attributes need to be defined in order for the voting plugin to work if (count($voting) && !isset($this->_article->rating_count)) { $this->_article->rating_count = 0; $this->_article->rating = 0; } return true; } return true; }
function _buildContentOrderBy($state = 1) { $filter_order = JRequest::getCmd('filter_order'); $filter_order_Dir = JRequest::getWord('filter_order_Dir'); if (!in_array($filter_order, array('a.id', 'a.title', 'a.alias', 'a.title_alias', 'a.introtext', 'a.fulltext', 'a.sectionid', 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias', 'a.modified', 'a.modified_by', 'a.checked_out', 'a.checked_out_time', 'a.hits', 'a.ordering', 'a.metakey', 'a.access'))) { $filter_order = 'a.ordering'; } if (!in_array(trim(strtoupper($filter_order_Dir)), array('ASC', 'DESC'))) { $filter_order_Dir = 'ASC'; } $orderby = ' ORDER BY '; if ($filter_order) { $orderby .= $filter_order . ' ' . $filter_order_Dir . ', '; } // Get the page/component configuration $app =& JFactory::getApplication(); $params =& $app->getParams(); switch ($state) { case -1: // Special ordering for archive articles $orderby_sec = $params->def('orderby', 'rdate'); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ''; break; case 1: default: $orderby_sec = $params->def('orderby_sec', 'rdate'); $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec; $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); break; } $orderby .= "{$primary} {$secondary}"; return $orderby; }
function _buildContentOrderBy() { global $mainframe; // Get the page/component configuration $params =& $mainframe->getParams(); if (!is_object($params)) { $params =& JComponentHelper::getParams('com_content'); } $orderby_sec = $params->def('orderby_sec', ''); $orderby_pri = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($orderby_sec); $primary = ContentHelperQuery::orderbyPrimary($orderby_pri); $orderby = ' ORDER BY ' . $primary . ' ' . $secondary; return $orderby; }
protected function _buildContentOrderBy() { $app = JFactory::getApplication(); $db = JFactory::getDbo(); $params = JComponentHelper::getParams('com_content'); $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; $_filter_fields = array('id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'modified', 'a.modified', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'author', 'a.author'); if (!in_array($orderCol, $_filter_fields)) { $orderCol = null; } if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) { $orderDirn = 'ASC'; } if ($orderCol && $orderDirn) { $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', '; } $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby .= $primary . ' ' . $secondary . ' a.created '; return $orderby; }