Source for file function.eaURL.php
Documentation is available at function.eaURL.php
* smarty function plugin to produce beautyfied URLs
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @subpackage code/base/smarty
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: function.eaURL.php 139 2007-08-29 20:49:58Z m2mtech $
* @link http://www.ea-geier.at/
* prevent multiple inclusion of this file
if (defined('eaSMARTYeaURL')) return true;
define('eaSMARTYeaURL', true);
* creates beautyfied links
* - {eaURL state=STATE [type=TYPE]}
* @param array function parameters
* - STATE -> link/STATE or PHP_SELF?state=STATE
* - TYPE = short -> link/STATE
* - TYPE = long -> PHP_SELF?state=STATE
* - ASSIGN -> ouput is assigned to given variable
* - LIMITER -> limiter is assigned to given variable
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
$vars = array('state', 'type', 'where', 'assign', 'limiter');
foreach ($vars as $var) if (isset ($params[$var]))
$ $var = smarty_function_escape_special_chars($params[$var]);
if (!isset ($type)) $type = '';
if (!isset ($where)) $where = '';
else $where = '#' . $where;
// if apache is installed with mod_rewrite active
if (($type == 'short') || (($type != 'long') && (isset ($_SERVER['REDIRECT_URL']) || isset ($_SERVER['HTTP_X_FORWARDED_FOR'])))) {
$path = dirname($_SERVER['PHP_SELF']);
if (substr($path, - 1, 1) != '/') $path .= '/';
$return = $path . $state . $where;
if ($state) $state = 'state=' . $state;
$return = $_SERVER['PHP_SELF'] . '?' . $state . $where;
// assign limiter to variable
$smarty->assign($limiter, $lim);
// assign output to variable
$smarty->assign($assign, $return);
|