Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_banners
  5.  * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  6.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8.  
  9. defined('_JEXEC') or die;
  10.  
  11. /**
  12.  * @param   array   A named array
  13.  * @return  array
  14.  */
  15. function BannersBuildRoute(&$query)
  16. {
  17.     $segments = array();
  18.  
  19.     if (isset($query['task'])) {
  20.         $segments[] = $query['task'];
  21.         unset($query['task']);
  22.     }
  23.     if (isset($query['id'])) {
  24.         $segments[] = $query['id'];
  25.         unset($query['id']);
  26.     }
  27.  
  28.     return $segments;
  29. }
  30.  
  31. /**
  32.  * @param   array   A named array
  33.  * @param   array
  34.  *
  35.  * Formats:
  36.  *
  37.  * index.php?/banners/task/id/Itemid
  38.  *
  39.  * index.php?/banners/id/Itemid
  40.  */
  41. function BannersParseRoute($segments)
  42. {
  43.     $vars = array();
  44.  
  45.     // view is always the first element of the array
  46.     $count = count($segments);
  47.  
  48.     if ($count)
  49.     {
  50.         $count--;
  51.         $segment = array_shift($segments);
  52.         if (is_numeric($segment)) {
  53.             $vars['id'] = $segment;
  54.         } else {
  55.             $vars['task'] = $segment;
  56.         }
  57.     }
  58.  
  59.     if ($count)
  60.     {
  61.         $count--;
  62.         $segment = array_shift($segments) ;
  63.         if (is_numeric($segment)) {
  64.             $vars['id'] = $segment;
  65.         }
  66.     }
  67.  
  68.     return $vars;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement