public static function &getMenuItems($selections) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $list = array(); foreach ($selections as $menutype => $menuOptions) { // Initialize variables. // Get the menu items as a tree. $query = $db->getQuery(true); $query->select('n.id, n.title, n.alias, n.path, n.level, n.link, ' . 'n.type, n.params, n.home, n.parent_id' . ',n.' . $db->quoteName('browserNav')); $query->from('#__menu AS n'); $query->join('INNER', ' #__menu AS p ON p.lft = 0'); $query->where('n.lft > p.lft'); $query->where('n.lft < p.rgt'); $query->order('n.lft'); // Filter over the appropriate menu. $query->where('n.menutype = ' . $db->quote($menutype)); // Filter over authorized access levels and publishing state. $query->where('n.published = 1'); $query->where('n.access IN (' . implode(',', (array) $user->getAuthorisedViewLevels()) . ')'); // Filter by language if ($app->getLanguageFilter()) { $query->where('n.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } // Get the list of menu items. $db->setQuery($query); $tmpList = $db->loadObjectList('id'); $list[$menutype] = array(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(021, $db->getErrorMsg()); return array(); } // Set some values to make nested HTML rendering easier. foreach ($tmpList as $id => $item) { $item->items = array(); $params = new JRegistry($item->params); if (OSMAP_LICENSE === 'pro') { $menuItem = new Alledia\OSMap\Pro\Joomla\Item($item); if (!$menuItem->isVisibleForRobots()) { continue; } } $item->uid = 'itemid' . $item->id; if (preg_match('#^/?index.php.*option=(com_[^&]+)#', $item->link, $matches)) { $item->option = $matches[1]; $componentParams = clone JComponentHelper::getParams($item->option); $componentParams->merge($params); //$params->merge($componentParams); $params = $componentParams; } else { $item->option = null; } $item->params = $params; if ($item->type != 'separator') { $item->priority = $menuOptions['priority']; $item->changefreq = $menuOptions['changefreq']; if (false === OSMapHelper::prepareMenuItem($item)) { continue; } } else { $item->priority = null; $item->changefreq = null; } if ($item->parent_id > 1) { $tmpList[$item->parent_id]->items[$item->id] = $item; } else { $list[$menutype][$item->id] = $item; } } } return $list; }
private static function getlinks(&$osmap, &$parent, &$params, $catid) { static::getCategoryTree($osmap, $parent, $params, $catid); if (!$params['include_links']) { return; } $db = JFactory::getDbo(); $now = JFactory::getDate('now', 'UTC')->toSql(); $query = $db->getQuery(true)->select(array('w.id', 'w.alias', 'w.title', 'params', 'metadata'))->from('#__weblinks AS w')->where('w.catid = ' . $db->Quote($catid))->where('w.state = 1')->where('(w.publish_up = ' . $db->quote($db->getNullDate()) . ' OR w.publish_up <= ' . $db->quote($now) . ')')->where('(w.publish_down = ' . $db->quote($db->getNullDate()) . ' OR w.publish_down >= ' . $db->quote($now) . ')')->order('w.ordering'); if (!$params['show_unauth']) { $query->where('w.access IN(' . $params['groups'] . ')'); } if ($params['language_filter']) { $query->where('w.language IN(' . $db->quote(JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } $db->setQuery($query); $rows = $db->loadObjectList(); if (empty($rows)) { return; } $osmap->changeLevel(1); foreach ($rows as $row) { if (OSMAP_LICENSE === 'pro') { $content = new Alledia\OSMap\Pro\Joomla\Item($row); if (!$content->isVisibleForRobots()) { continue; } } $node = new stdclass(); $node->id = $parent->id; $node->name = $row->title; $node->uid = $parent->uid . '_' . $row->id; $node->browserNav = $parent->browserNav; $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->link = WeblinksHelperRoute::getWeblinkRoute($row->id . ':' . $row->alias, $catid); $osmap->printNode($node); } $osmap->changeLevel(-1); }
/** * 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; }