3 * @version $Id: route.php 1795 2009-04-24 09:29:31Z fishbone $
6 * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
7 * @license GNU/GPL, see LICENSE.php
8 * Joomla! is free software. This version may have been modified pursuant to the
9 * GNU General Public License, and as distributed it includes or is derivative
10 * of works licensed under the GNU General Public License or other free or open
11 * source software licenses. See COPYRIGHT.php for copyright notices and
16 defined('_JEXEC') or die('Restricted access');
19 jimport('joomla.application.component.helper');
22 * Content Component Route Helper
29 class ContentHelperRoute
32 * @param int The route of the content item
34 function getArticleRoute($id, $catid = 0, $sectionid = 0)
37 'article' => (int) $id,
38 'category' => (int) $catid,
39 'section' => (int) $sectionid,
43 $link = 'index.php?option=com_content&view=article&id='. $id;
46 $link .= '&catid='.$catid;
49 if($item = ContentHelperRoute::_findItem($needles)) {
50 $link .= '&Itemid='.$item->id;
56 function getSectionRoute($sectionid)
59 'section' => (int) $sectionid
63 $link = 'index.php?option=com_content&view=section&id='.$sectionid;
65 if($item = ContentHelperRoute::_findItem($needles)) {
66 if(isset($item->query['layout'])) {
67 $link .= '&layout='.$item->query['layout'];
69 $link .= '&Itemid='.$item->id;
75 function getCategoryRoute($catid, $sectionid)
78 'category' => (int) $catid,
79 'section' => (int) $sectionid
83 $link = 'index.php?option=com_content&view=category&id='.$catid;
85 if($item = ContentHelperRoute::_findItem($needles)) {
86 if(isset($item->query['layout'])) {
87 $link .= '&layout='.$item->query['layout'];
89 $link .= '&Itemid='.$item->id;
95 function _findItem($needles)
97 $component =& JComponentHelper::getComponent('com_content');
99 $menus = &JApplication::getMenu('site', array());
100 $items = $menus->getItems('componentid', $component->id);
104 foreach($needles as $needle => $id)
106 foreach($items as $item)
108 if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {