public function onJSolrSearchURIGet($document) { if ($this->get('context') == $document->context) { require_once JPATH_ROOT . "/components/com_newsfeeds/helpers/route.php"; return NewsfeedsHelperRoute::getNewsfeedRoute($document->id, $document->parent_id); } return null; }
function getNewsfeedsRoute($id, $catid) { $needles = array('category' => (int) $catid, 'categories' => null); //Find the itemid $itemid = NewsfeedsHelperRoute::_findItem($needles); $itemid = $itemid ? '&Itemid=' . $itemid : ''; //Create the link $link = 'index.php?option=com_newsfeeds&view=newsfeed&id=' . $id . '&catid=' . $catid . $itemid; return $link; }
/** * Prepares the document * * @return void */ protected function prepareDocument() { parent::prepareDocument(); $menu = $this->menu; $id = (int) @$menu->query['id']; if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $this->category->id)) { $path = array(array('title' => $this->category->title, 'link' => '')); $category = $this->category->getParent(); while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $this->pathway->addItem($item['title'], $item['link']); } } }
/** * Method to get the associations for a given item * * @param integer $id Id of the item * @param string $view Name of the view * * @return array Array of associations for the item * * @since 3.0 */ public static function getAssociations($id = 0, $view = null) { $jinput = JFactory::getApplication()->input; $view = is_null($view) ? $jinput->get('view') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; if ($view == 'newsfeed') { if ($id) { $associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $id); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = NewsfeedsHelperRoute::getNewsfeedRoute($item->id, (int) $item->catid, $item->language); } return $return; } } if ($view == 'category' || $view == 'categories') { return self::getCategoryAssociations($id, 'com_newsfeeds'); } return array(); }
protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component = JComponentHelper::getComponent('com_newsfeeds'); $items = $menus->getItems('component_id', $component->id); foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup[$view])) { foreach ($ids as $id) { if (isset(self::$lookup[$view][(int) $id])) { return self::$lookup[$view][(int) $id]; } } } } } else { $active = $menus->getActive(); if ($active) { return $active->id; } } return null; }
/** * Method to get the associations for a given item * * @param integer $id Id of the item * @param string $view Name of the view * * @return array Array of associations for the item * * @since 3.0 */ public static function getAssociations($id = 0, $view = null) { jimport('helper.route', JPATH_COMPONENT_SITE); $app = JFactory::getApplication(); $jinput = $app->input; $view = is_null($view) ? $jinput->get('view') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; if ($view == 'newsfeed') { if ($id) { $associations = NewsfeedsHelper::getAssociations($id); $return = array(); foreach ($associations as $tag => $item) { $return[$tag] = NewsfeedsHelperRoute::getNewsfeedRoute($item->id, $item->catid, $item->language); } return $return; } } if ($view == 'category' || $view == 'categories') { return self::getCategoryAssociations($id, 'com_newsfeeds'); } return array(); }
defined('_JEXEC') or die; ?> <?php if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) { ?> <ul> <?php foreach ($this->children[$this->category->id] as $id => $child) { ?> <?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) { ?> <li> <a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($child->id)); ?> "><?php echo $this->escape($child->title); ?> </a> <?php if ($this->params->get('show_cat_items') == 1) { ?> <small>(<?php echo $child->numitems; ?> )</small> <?php }
?> <?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) { if (!isset($this->items[$this->parent->id][$id + 1])) { $class = ' class="last"'; } ?> <li<?php echo $class; ?> > <?php $class = ''; ?> <span class="item-title"><a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($item->id)); ?> "> <?php echo $this->escape($item->title); ?> </a> </span> <?php if ($this->params->get('show_subcat_desc_cat') == 1) { ?> <?php if ($item->description) { ?> <div class="category-desc"> <?php
/** * Prepares the document * * @return void * * @since 1.6 */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // 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)); } else { $this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); $id = (int) @$menu->query['id']; // If the menu item does not concern this newsfeed if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] != 'newsfeed' || $id != $this->item->id)) { // If this is not a single newsfeed menu item, set the page title to the newsfeed title if ($this->item->name) { $title = $this->item->name; } $path = array(array('title' => $this->item->name, 'link' => '')); $category = JCategories::getInstance('Newsfeeds')->get($this->item->catid); while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } 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->item->name; } $this->document->setTitle($title); if ($this->item->metadesc) { $this->document->setDescription($this->item->metadesc); } elseif ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->item->metakey) { $this->document->setMetadata('keywords', $this->item->metakey); } elseif ($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 ($app->get('MetaTitle') == '1') { $this->document->setMetaData('title', $this->item->name); } if ($app->get('MetaAuthor') == '1') { $this->document->setMetaData('author', $this->item->author); } $mdata = $this->item->metadata->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } }
</td> <td> <a href="javascript:void(0)" onclick="if (window.parent) window.parent.<?php echo $this->escape($function); ?> ('<?php echo $item->id; ?> ', '<?php echo $this->escape(addslashes($item->name)); ?> ', '<?php echo $this->escape($item->catid); ?> ', null, '<?php echo $this->escape(NewsfeedsHelperRoute::getNewsfeedRoute($item->id, $item->catid, $item->language)); ?> ', '<?php echo $this->escape($lang); ?> ', null);"> <?php echo $this->escape($item->name); ?> </a> <div class="small"> <?php echo JText::_('JCATEGORY') . ": " . $this->escape($item->category_title); ?> </div> </td>
/** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format. Not used. * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled. if (JComponentHelper::isEnabled($this->extension) == false) { return; } $item->setLanguage(); // Initialize the item parameters. $registry = new Registry(); $registry->loadString($item->params); $item->params = $registry; $registry = new Registry(); $registry->loadString($item->metadata); $item->metadata = $registry; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = NewsfeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catslug, $item->language); $item->path = FinderIndexerHelper::getContentPath($item->route); /* * Add the meta-data processing instructions based on the newsfeeds * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'News Feed'); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. $this->indexer->index($item); }
?> <?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) { if (!isset($this->children[$this->category->id][$id + 1])) { $class = ' class="last"'; } ?> <li<?php echo $class; ?> > <?php $class = ''; ?> <span class="item-title"><a href="<?php echo Route::url(NewsfeedsHelperRoute::getCategoryRoute($child->id)); ?> "> <?php echo $this->escape($child->title); ?> </a> </span> <?php if ($this->params->get('show_subcat_desc') == 1) { ?> <?php if ($child->description) { ?> <div class="category-desc">
<?php defined('_JEXEC') or die; ?> <?php if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) : ?> <ul> <?php foreach($this->items[$this->parent->id] as $id => $item) : ?> <?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) : ?> <li> <a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($item->id));?>"><?php echo $this->escape($item->title); ?></a> <?php if ($this->params->get('show_cat_items_cat') == 1) : ?> <small>(<?php echo $item->numitems; ?>)</small> <?php endif; ?> <?php if (($this->params->get('show_subcat_desc_cat') == 1) && $item->description) : ?> <div><?php echo JHtml::_('content.prepare', $item->description, '', 'com_newsfeeds.categories'); ?></div> <?php endif; ?> <?php if (count($item->getChildren()) > 0) { $this->items[$item->id] = $item->getChildren(); $this->parent = $item; $this->maxLevelcat--; echo $this->loadTemplate('items'); $this->parent = $item->getParent(); $this->maxLevelcat++; } ?> </li>
<?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) { if (!isset($this->items[$this->parent->id][$id + 1])) { $class = ' class="last"'; } ?> <div <?php echo $class; ?> > <?php $class = ''; ?> <h3 class="page-header item-title"> <a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($item->id, $item->language)); ?> "> <?php echo $this->escape($item->title); ?> </a> <?php if ($this->params->get('show_cat_items_cat') == 1) { ?> <span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_NEWSFEEDS_NUM_ITEMS'); ?> "> <?php echo JText::_('COM_NEWSFEEDS_NUM_ITEMS');
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = \App::get('menu'); $title = null; // 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)); } else { $this->params->def('page_heading', Lang::txt('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE')); } $id = (int) @$menu->query['id']; if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $this->category->id)) { $path = array(array('title' => $this->category->title, 'link' => '')); $category = $this->category->getParent(); while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { Pathway::append($item['title'], $item['link']); } } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = Lang::txt('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = Lang::txt('JPAGETITLE', $title, $app->getCfg('sitename')); } $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 ($app->getCfg('MetaAuthor') == '1') { $this->document->setMetaData('author', $this->category->getMetadata()->get('author')); } $mdata = $this->category->getMetadata()->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } }
?> <?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) { if (!isset($this->items[$this->parent->id][$id + 1])) { $class = ' class="last"'; } ?> <li<?php echo $class; ?> > <?php $class = ''; ?> <span class="item-title"><a href="<?php echo Route::url(NewsfeedsHelperRoute::getCategoryRoute($item->id)); ?> "> <?php echo $this->escape($item->title); ?> </a> </span> <?php if ($this->params->get('show_subcat_desc_cat') == 1) { ?> <?php if ($item->description) { ?> <div class="category-desc"> <?php