/components/com_newsfeeds/helpers/route.php
PHP | 78 lines | 46 code | 13 blank | 19 comment | 7 complexity | c70edcc9ae91b318afc39a8490cd7556 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
- <?php
- /**
- * @version $Id: route.php 13088 2009-10-07 13:10:56Z mcsmom $
- * @package Joomla
- * @subpackage com_newsfeeds
- * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE.txt
- */
-
- // no direct access
- defined('_JEXEC') or die;
-
- // Component Helper
- jimport('joomla.application.component.helper');
- jimport('joomla.application.categorytree');
-
- /**
- * Newsfeed Component Route Helper
- *
- * @static
- * @package Joomla
- * @subpackage com_newsfeeds
- * @since 1.6
- */
-
- class NewsfeedsHelperRoute
- {
- 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;
- }
-
- function _findItem($needles)
- {
- static $items;
-
- if (!$items)
- {
- $component = &JComponentHelper::getComponent('com_newsfeeds');
- $menu = &JSite::getMenu();
- $items = $menu->getItems('component_id', $component->id);
- }
-
- if (!is_array($items)) {
- return null;
- }
-
- $match = null;
- foreach($needles as $needle => $id)
- {
- foreach($items as $item)
- {
- if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
- $match = $item->id;
- break;
- }
- }
-
- if (isset($match)) {
- break;
- }
- }
-
- return $match;
- }
- }
- ?>