[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_content/helpers/ -> route.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: route.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Content
   6   * @copyright    Copyright (C) 2005 - 2010 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
  12   * details.
  13   */
  14  
  15  // no direct access
  16  defined('_JEXEC') or die('Restricted access');
  17  
  18  // Component Helper
  19  jimport('joomla.application.component.helper');
  20  
  21  /**
  22   * Content Component Route Helper
  23   *
  24   * @static
  25   * @package        Joomla
  26   * @subpackage    Content
  27   * @since 1.5
  28   */
  29  class ContentHelperRoute
  30  {
  31      /**
  32       * @param    int    The route of the content item
  33       */
  34  	function getArticleRoute($id, $catid = 0, $sectionid = 0)
  35      {
  36          $needles = array(
  37              'article'  => (int) $id,
  38              'category' => (int) $catid,
  39              'section'  => (int) $sectionid,
  40          );
  41  
  42          //Create the link
  43          $link = 'index.php?option=com_content&view=article&id='. $id;
  44  
  45          if($catid) {
  46              $link .= '&catid='.$catid;
  47          }
  48  
  49          if($item = ContentHelperRoute::_findItem($needles)) {
  50              $link .= '&Itemid='.$item->id;
  51          };
  52  
  53          return $link;
  54      }
  55  
  56  	function getSectionRoute($sectionid)
  57      {
  58          $needles = array(
  59              'section' => (int) $sectionid
  60          );
  61  
  62          //Create the link
  63          $link = 'index.php?option=com_content&view=section&id='.$sectionid;
  64  
  65          if($item = ContentHelperRoute::_findItem($needles)) {
  66              if(isset($item->query['layout'])) {
  67                  $link .= '&layout='.$item->query['layout'];
  68              }
  69              $link .= '&Itemid='.$item->id;
  70          };
  71  
  72          return $link;
  73      }
  74  
  75  	function getCategoryRoute($catid, $sectionid)
  76      {
  77          $needles = array(
  78              'category' => (int) $catid,
  79              'section'  => (int) $sectionid
  80          );
  81  
  82          //Create the link
  83          $link = 'index.php?option=com_content&view=category&id='.$catid;
  84  
  85          if($item = ContentHelperRoute::_findItem($needles)) {
  86              if(isset($item->query['layout'])) {
  87                  $link .= '&layout='.$item->query['layout'];
  88              }
  89              $link .= '&Itemid='.$item->id;
  90          };
  91  
  92          return $link;
  93      }
  94  
  95  	function _findItem($needles)
  96      {
  97          $component =& JComponentHelper::getComponent('com_content');
  98  
  99          $menus    = &JApplication::getMenu('site', array());
 100          $items    = $menus->getItems('componentid', $component->id);
 101  
 102          $match = null;
 103  
 104          foreach($needles as $needle => $id)
 105          {
 106              foreach($items as $item)
 107              {
 108                  if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
 109                      $match = $item;
 110                      break;
 111                  }
 112              }
 113  
 114              if(isset($match)) {
 115                  break;
 116              }
 117          }
 118  
 119          return $match;
 120      }
 121  }
 122  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1