[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/components/com_finder/ -> router.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Site
   4   * @subpackage  com_finder
   5   *
   6   * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   7   * @license     GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  defined('_JEXEC') or die;
  11  
  12  // Register dependent classes.
  13  
  14  /**
  15   * Method to build a SEF route.
  16   *
  17   * @param   array  &$query  An array of route variables.
  18   *
  19   * @return  array  An array of route segments.
  20   *
  21   * @since   2.5
  22   */
  23  function FinderBuildRoute(&$query)
  24  {
  25      static $menu;
  26      $segments = array();
  27  
  28      // Load the menu if necessary.
  29      if (!$menu)
  30      {
  31          $menu = JFactory::getApplication('site')->getMenu();
  32      }
  33  
  34      /*
  35       * First, handle menu item routes first. When the menu system builds a
  36       * route, it only provides the option and the menu item id. We don't have
  37       * to do anything to these routes.
  38       */
  39      if (count($query) === 2 && isset($query['Itemid']) && isset($query['option']))
  40      {
  41          return $segments;
  42      }
  43  
  44      /*
  45       * Next, handle a route with a supplied menu item id. All system generated
  46       * routes should fall into this group. We can assume that the menu item id
  47       * is the best possible match for the query but we need to go through and
  48       * see which variables we can eliminate from the route query string because
  49       * they are present in the menu item route already.
  50       */
  51      if (!empty($query['Itemid']))
  52      {
  53          // Get the menu item.
  54          $item = $menu->getItem($query['Itemid']);
  55  
  56          // Check if the view matches.
  57          if ($item && @$item->query['view'] === @$query['view'])
  58          {
  59              unset($query['view']);
  60          }
  61  
  62          // Check if the search query filter matches.
  63          if ($item && @$item->query['f'] === @$query['f'])
  64          {
  65              unset($query['f']);
  66          }
  67  
  68          // Check if the search query string matches.
  69          if ($item && @$item->query['q'] === @$query['q'])
  70          {
  71              unset($query['q']);
  72          }
  73  
  74          return $segments;
  75      }
  76  
  77      /*
  78       * Lastly, handle a route with no menu item id. Fortunately, we only need
  79       * to deal with the view as the other route variables are supposed to stay
  80       * in the query string.
  81       */
  82      if (isset($query['view']))
  83      {
  84          // Add the view to the segments.
  85          $segments[] = $query['view'];
  86          unset($query['view']);
  87      }
  88  
  89      return $segments;
  90  }
  91  
  92  /**
  93   * Method to parse a SEF route.
  94   *
  95   * @param   array  $segments  An array of route segments.
  96   *
  97   * @return  array  An array of route variables.
  98   *
  99   * @since   2.5
 100   */
 101  function FinderParseRoute($segments)
 102  {
 103      $vars = array();
 104  
 105      // Check if the view segment is set and it equals search or advanced.
 106      if (@$segments[0] === 'search' || @$segments[0] === 'advanced')
 107      {
 108          $vars['view'] = $segments[0];
 109      }
 110  
 111      return $vars;
 112  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1