protected function addToolbar() { $state = $this->get('State'); JToolBarHelper::title(JText::_('COM_XMAP_SITEMAPS_TITLE'), 'list'); $canDo = JHelperContent::getActions('com_xmap', 'sitemap'); JToolBarHelper::addNew('sitemap.add'); JToolbarHelper::editList('sitemap.edit'); if ($canDo->get('core.edit.state')) { JToolbarHelper::publish('sitemaps.publish', 'JTOOLBAR_PUBLISH', true); JToolbarHelper::unpublish('sitemaps.unpublish', 'JTOOLBAR_UNPUBLISH', true); } if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolbarHelper::deleteList('', 'sitemaps.delete', 'JTOOLBAR_EMPTY_TRASH'); } elseif ($canDo->get('core.edit.state')) { JToolbarHelper::trash('sitemaps.trash'); } if ($canDo->get('core.manage')) { JToolbarHelper::custom('sitemaps.ping', 'heart', 'heart', JText::_('COM_XMAP_TOOLBAR_PING')); } if (JFactory::getUser()->authorise('core.admin')) { JToolbarHelper::preferences('com_xmap'); } if (JHelperContent::getActions('com_plugins')->get('core.edit.state')) { JToolbarHelper::custom('sitemaps.plugins', 'power-cord', 'power-cord', JText::_('COM_XMAP_TOOLBAR_PLUGINS'), false); } JHtmlSidebar::setAction('index.php?option=com_xmap&view=sitemaps'); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_state', JHtml::_('select.options', XmapHelper::getStateOptions(), 'value', 'text', $this->state->get('filter.state'))); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_ACCESS'), 'filter_access', JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))); $this->sidebar = JHtmlSidebar::render(); }
/** * Display the view */ public function display($tpl = null) { if ($this->getLayout() !== 'modal') { XmapHelper::addSubmenu('sitemaps'); } $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $version = new JVersion(); $message = $this->get('ExtensionsMessage'); if ($message) { JFactory::getApplication()->enqueueMessage($message); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // We don't need toolbar in the modal window. if ($this->getLayout() !== 'modal') { if (version_compare($version->getShortVersion(), '3.0.0', '<')) { $tpl = 'legacy'; } $this->addToolbar(); } parent::display($tpl); }
/** * @param stdClass $sitemap * @param array $items * @param array $extensions */ public function __construct(stdClass $sitemap, array &$items, array &$extensions) { parent::__construct($sitemap, $items, $extensions); $languageTag = JFactory::getLanguage()->getTag(); $this->base = JUri::getInstance()->toString(array('scheme', 'user', 'pass', 'host', 'port')); if (in_array($languageTag, array('zh-cn', 'zh-tw'))) { $this->defaultLanguage = $languageTag; } else { $this->defaultLanguage = XmapHelper::getLanguageCode(); } }
/** * Display the view */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'xmap.php'; // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getWord('view', 'sitemaps'); $vFormat = $document->getType(); $lName = JRequest::getWord('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { // Get the model for the view. $model = $this->getModel($vName); // Push the model into the view (as default). $view->setModel($model, true); $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); // Load the submenu. XmapHelper::addSubmenu($vName); } }
function getExtensions() { return XmapHelper::getExtensions(); }
function &expandLink(&$parent) { $items =& JSite::getMenu(); $extensions =& $this->_extensions; $rows = null; if (strpos($parent->link, '-menu-') === 0) { $menutype = str_replace('-menu-', '', $parent->link); // Get Menu Items $rows = $items->getItems('menutype', $menutype); } elseif ($parent->id) { $rows = $items->getItems('parent_id', $parent->id); } if ($rows) { foreach ($rows as $item) { if ($item->parent_id == $parent->id) { $node = new stdclass(); $node->name = $item->title; $node->id = $item->id; $node->uid = 'itemid' . $item->id; $node->link = $item->link; $node->expandible = true; $node->selectable = true; // Prepare the node link XmapHelper::prepareMenuItem($node); if ($item->home) { $node->link = JURI::root(); } elseif (substr($item->link, 0, 9) == 'index.php' && $item->type != 'url') { if ($item->type == 'menulink') { // For Joomla 1.5 SEF compatibility $params = new JParameter($item->params); $node->link = 'index.php?Itemid=' . $params->get('menu_item'); } elseif (strpos($item->link, 'Itemid=') === FALSE) { $node->link = 'index.php?Itemid=' . $node->id; } } elseif ($item->type == 'separator') { $node->selectable = false; } $this->printNode($node); // Add to the internal list } } } if ($parent->id) { $option = null; if (preg_match('#^/?index.php.*option=(com_[^&]+)#', $parent->link, $matches)) { $option = $matches[1]; } $Itemid = JRequest::getInt('Itemid'); if (!$option && $Itemid) { $item = $items->getItem($Itemid); $link_query = parse_url($item->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $option = JArrayHelper::getValue($link_vars, 'option', ''); if ($option) { $parent->link = $item->link; } } if ($option) { if (!empty($extensions[$option])) { $parent->uid = $option; $className = 'xmap_' . $option; $result = call_user_func_array(array($className, 'getTree'), array(&$this, &$parent, $extensions[$option]->params)); } } } return $this->_list; }
/** * Get all content items within a content category. * Returns an array of all contained content items. * * @since 2.0 */ static function includeCategoryContent($xmap, $parent, $catid, &$params, $Itemid) { $db = JFactory::getDBO(); // We do not do ordering for XML sitemap. if ($xmap->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'] || $xmap->isNews) { $days = $xmap->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' . ',a.language' . ($params['add_images'] || $params['add_pagebreaks'] ? ',a.introtext, a.fulltext ' : ' ') . 'FROM #__content AS a ' . ($catid == 'featured' ? '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'] . ') ' . ($xmap->view != 'xml' ? "\n ORDER BY {$orderby} " : '') . ($params['max_art'] ? "\n LIMIT {$params['max_art']}" : ''); $db->setQuery($query); //echo nl2br(str_replace('#__','mgbj2_',$db->getQuery())); $items = $db->loadObjectList(); if (count($items) > 0) { $xmap->changeLevel(1); foreach ($items as $item) { $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 ($xmap->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']) { $node->images = XmapHelper::getImages($text, $params['max_images']); } if ($params['add_pagebreaks']) { $subnodes = XmapHelper::getPagebreaks($text, $node->link); $node->expandible = count($subnodes) > 0; // This article has children } if ($xmap->printNode($node) && $node->expandible) { self::printNodes($xmap, $parent, $params, $subnodes); } } $xmap->changeLevel(-1); } return true; }
function navigatorLinks($tpl = null) { require_once JPATH_COMPONENT_SITE . '/helpers/xmap.php'; $link = urldecode(JRequest::getVar('link', '')); $name = JRequest::getCmd('e_name', ''); $Itemid = JRequest::getInt('Itemid'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $menuItems = XmapHelper::getMenuItems($item->selections); $extensions = XmapHelper::getExtensions(); $this->loadTemplate('class'); $nav = new XmapNavigatorDisplayer($state->params, $item); $nav->setExtensions($extensions); $this->list = array(); // Show the menu list if (!$link && !$Itemid) { foreach ($menuItems as $menutype => &$menu) { $menu = new stdclass(); #$menu->id = 0; #$menu->menutype = $menutype; $node = new stdClass(); $node->uid = "menu-" . $menutype; $node->menutype = $menutype; $node->ordering = $item->selections->{$menutype}->ordering; $node->priority = $item->selections->{$menutype}->priority; $node->changefreq = $item->selections->{$menutype}->changefreq; $node->browserNav = 3; $node->type = 'separator'; if (!($node->name = $nav->getMenuTitle($menutype, @$menu->module))) { $node->name = $menutype; } $node->link = '-menu-' . $menutype; $node->expandible = true; $node->selectable = false; //$node->name = $this->getMenuTitle($menutype,@$menu->module); // get the mod_mainmenu title from modules table $this->list[] = $node; } } else { $parent = new stdClass(); if ($Itemid) { // Expand a menu Item $items =& JSite::getMenu(); $node =& $items->getItem($Itemid); if (isset($menuItems[$node->menutype])) { $parent->name = $node->title; $parent->id = $node->id; $parent->uid = 'itemid' . $node->id; $parent->link = $link; $parent->type = $node->type; $parent->browserNav = $node->browserNav; $parent->priority = $item->selections->{$node->menutype}->priority; $parent->changefreq = $item->selections->{$node->menutype}->changefreq; $parent->menutype = $node->menutype; $parent->selectable = false; $parent->expandible = true; } } else { $parent->id = 1; $parent->link = $link; } $this->list = $nav->expandLink($parent); } parent::display('links'); exit; }
/** * Call the function prepareMenuItem of the extension for the item (if any) * * @param object Menu item object * * @return void */ public static function prepareMenuItem($item) { $extensions = XmapHelper::getExtensions(); if (!empty($extensions[$item->option])) { $className = 'xmap_' . $item->option; $obj = new $className(); if (method_exists($obj, 'prepareMenuItem')) { $obj->prepareMenuItem($item, $extensions[$item->option]->params); } } }
/** * @return array|null */ public static function getExtensions() { if (is_null(self::$extensions)) { $db = JFactory::getDbo(); // init as array so this method called be only once self::$extensions = array(); $query = $db->getQuery(true)->select('e.element')->select('e.folder')->select('e.params')->from('#__extensions AS e')->where('e.folder = ' . $db->quote('xmap'))->where('e.enabled = ' . $db->quote(1)); $db->setQuery($query); try { $extensions = $db->loadObjectList('element'); } catch (RuntimeException $e) { return self::$extensions; } if (empty($extensions)) { return self::$extensions; } foreach ($extensions as $element => $extension) { // file_exists should be not required if extension marked as enabled?! if (JFile::exists(JPATH_PLUGINS . '/' . $extension->folder . '/' . $element . '/' . $element . '.php')) { require_once JPATH_PLUGINS . '/' . $extension->folder . '/' . $element . '/' . $element . '.php'; $params = new Registry($extension->params); $extension->params = $params->toArray(); } } self::$extensions = $extensions; } return self::$extensions; }
<?php echo $item->count_html . ' / ' . $item->views_html; ?> <div class="small"><?php echo XmapHelper::getLastVisitDate($item->lastvisit_html); ?> </div> </td> <td class="center hidden-phone"> <?php echo $item->count_xml . ' / ' . $item->views_xml; ?> <div class="small"><?php echo XmapHelper::getLastVisitDate($item->lastvisit_xml); ?> </div> </td> <td class="center hidden-phone"> <?php echo (int) $item->id; ?> </td> </tr> <?php } ?> </tbody> </table> <?php
url: '<?php echo JUri::root(); ?> index.php', dataType: 'json', type: 'POST', data: { option: 'com_xmap', format: 'json', task: 'sitemap.editElement', action: 'toggleElement', id: $this.data('id'), uid: $this.data('uid'), itemid: $this.data('itemid'), lang: '<?php echo XmapHelper::getLanguageCode(); ?> ', '<?php echo JSession::getFormToken(); ?> ': 1 }, success: function (response) { $this.removeClass('icon-remove-sign icon-ok-sign'); $this.attr('title', response.message).tooltip('fixTitle').tooltip('show'); if (response.success) { $this.addClass(response.data.state ? 'icon-ok-sign' : 'icon-remove-sign'); } else { $this.addClass('icon-circle-question-mark');