ea-Geiercode-base-smarty
[ class tree: ea-Geier ] [ index: ea-Geier ] [ all elements ]

Source for file function.eaURL.php

Documentation is available at function.eaURL.php

  1. <?php
  2. /**
  3.  * smarty function plugin to produce beautyfied URLs
  4.  *
  5.  * LICENSE:
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
  13.  * GNU General Public License for more details.
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program; if not, write to the Free Software Foundation, Inc.,
  16.  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17.  *
  18.  * @package       ea-Geier
  19.  * @subpackage code/base/smarty
  20.  * @author       m2mtech <tech@m2m.at>
  21.  * @copyright  2007 m2m server software gmbh
  22.  * @license       http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
  23.  * @version       $Id: function.eaURL.php 139 2007-08-29 20:49:58Z m2mtech $
  24.  * @link       http://www.ea-geier.at/
  25.  */
  26.  
  27. /**
  28.  * prevent multiple inclusion of this file
  29.  */
  30. if (defined('eaSMARTYeaURL')) return true;
  31. define('eaSMARTYeaURL'true);
  32.  
  33. /**
  34.  * Smarty {eaURL} plugin
  35.  *
  36.  * creates beautyfied links
  37.  *
  38.  * - {eaURL state=STATE [type=TYPE]}
  39.  * @param    array    function parameters
  40.  *                     - STATE -> link/STATE or PHP_SELF?state=STATE
  41.  *                     - TYPE = short -> link/STATE
  42.  *                     - TYPE = long  -> PHP_SELF?state=STATE
  43.  *                     - WHERE = #WHERE
  44.  *                     - ASSIGN -> ouput is assigned to given variable
  45.  *                     - LIMITER -> limiter is assigned to given variable
  46.  * @param    Smarty 
  47.  * @return    string 
  48.  */
  49. function smarty_function_eaURL($params&$smarty{
  50.     // escape parameter
  51.     require_once $smarty->_get_plugin_filepath('shared''escape_special_chars');
  52.     
  53.     $vars array('state''type''where''assign''limiter');
  54.     foreach ($vars as $varif (isset($params[$var]))
  55.         $$var smarty_function_escape_special_chars($params[$var]);
  56.  
  57.     if (!isset($type)) $type '';
  58.  
  59.     if (!isset($where)) $where '';
  60.     else $where '#' $where;
  61.  
  62.     $return '';
  63.  
  64.     // if apache is installed with mod_rewrite active
  65.     if (($type == 'short'|| (($type != 'long'&& (isset($_SERVER['REDIRECT_URL']|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])))) {
  66.         $path dirname($_SERVER['PHP_SELF']);
  67.         if (substr($path-11!= '/'$path .= '/';        
  68.         $lim '/';
  69.         $return $path $state $where;
  70.     }
  71.  
  72.     // no apache available
  73.     if (!$return{
  74.         if ($state$state 'state=' $state;
  75.         $return $_SERVER['PHP_SELF''?' $state $where;
  76.         $lim '&amp;';
  77.     }
  78.         
  79.     // assign limiter to variable
  80.     if (isset($limiter)) {
  81.         $smarty->assign($limiter$lim);
  82.     }
  83.  
  84.     // assign output to variable
  85.     if (isset($assign)) {
  86.         $smarty->assign($assign$return);
  87.         return;
  88.     }
  89.  
  90.     return $return;
  91. }
  92.  
  93. ?>

Documentation generated on Sun, 09 Sep 2007 17:08:47 +0200 by phpDocumentor 1.3.1