/** * Get all content items within a content category. * Returns an array of all contained content items. * * @since 2.0 */ public static function includeCategoryContent($osmap, $parent, $catid, &$params, $Itemid) { $db = JFactory::getDBO(); // We do not do ordering for XML sitemap. if ($osmap->view != 'xml') { $orderby = self::buildContentOrderBy($parent->params, $parent->id, $Itemid); //$orderby = !empty($menuparams['orderby']) ? $menuparams['orderby'] : (!empty($menuparams['orderby_sec']) ? $menuparams['orderby_sec'] : 'rdate' ); //$orderby = self::orderby_sec($orderby); } if ($params['include_archived']) { $where = array('(a.state = 1 or a.state = 2)'); } else { $where = array('a.state = 1'); } if ($catid == 'featured') { $where[] = 'a.featured=1'; } elseif ($catid == 'archived') { $where = array('a.state=2'); } elseif (is_numeric($catid)) { $where[] = 'a.catid=' . (int) $catid; } if ($params['max_art_age'] || $osmap->isNews) { $days = $osmap->isNews && ($params['max_art_age'] > 3 || !$params['max_art_age']) ? 3 : $params['max_art_age']; $where[] = "( a.created >= '" . date('Y-m-d H:i:s', time() - $days * 86400) . "' ) "; } if ($params['language_filter']) { $where[] = 'a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'; } if (!$params['show_unauth']) { $where[] = 'a.access IN (' . $params['groups'] . ') '; } $query = 'SELECT a.id, a.title, a.alias, a.catid, ' . 'a.created created, a.modified modified, attribs as params, metadata' . ',a.language' . ($params['add_images'] || $params['add_pagebreaks'] ? ',a.introtext, a.fulltext ' : ' ') . 'FROM #__content AS a ' . 'LEFT JOIN #__content_frontpage AS fp ON a.id = fp.content_id ' . 'WHERE ' . implode(' AND ', $where) . ' AND ' . ' (a.publish_up = ' . $params['nullDate'] . ' OR a.publish_up <= ' . $params['nowDate'] . ') AND ' . ' (a.publish_down = ' . $params['nullDate'] . ' OR a.publish_down >= ' . $params['nowDate'] . ') ' . ($osmap->view != 'xml' ? "\n ORDER BY {$orderby} " : '') . ($params['max_art'] ? "\n LIMIT {$params['max_art']}" : ''); $db->setQuery($query); $items = $db->loadObjectList(); if (count($items) > 0) { $osmap->changeLevel(1); foreach ($items as $item) { if (OSMAP_LICENSE === 'pro') { $content = new Alledia\OSMap\Pro\Joomla\Item($item); if (!$content->isVisibleForRobots()) { continue; } } $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'a' . $item->id; $node->browserNav = $parent->browserNav; $node->priority = $params['art_priority']; $node->changefreq = $params['art_changefreq']; $node->name = $item->title; $node->modified = $item->modified; $node->expandible = false; $node->secure = $parent->secure; // TODO: Should we include category name or metakey here? // $node->keywords = $item->metakey; $node->newsItem = 1; $node->language = $item->language; // For the google news we should use te publication date instead // the last modification date. See if ($osmap->isNews || !$node->modified) { $node->modified = $item->created; } $node->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; //$node->catslug = $item->category_route ? ($catid . ':' . $item->category_route) : $catid; $node->catslug = $item->catid; $node->link = ContentHelperRoute::getArticleRoute($node->slug, $node->catslug); // Add images to the article $text = @$item->introtext . @$item->fulltext; if ($params['add_images']) { if (OSMAP_LICENSE === 'pro') { $node->images = Alledia\OSMap\Pro\Joomla\Helper::getImages($text, JArrayHelper::getValue($params, 'max_images', 1000)); } else { $node->images = OSMapHelper::getImages($text, JArrayHelper::getValue($params, 'max_images', 1000)); } } if ($params['add_pagebreaks']) { $subnodes = OSMapHelper::getPagebreaks($text, $node->link); $node->expandible = count($subnodes) > 0; // This article has children } if ($osmap->printNode($node) && $node->expandible) { self::printNodes($osmap, $parent, $params, $subnodes); } } $osmap->changeLevel(-1); } return true; }