function.url4.php 1.25 KB
<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {math} function plugin
 *
 * Type:     function<br>
 * Name:     math<br>
 * Purpose:  handle math computations in template<br>
 * @link http://smarty.php.net/manual/en/language.function.math.php {math}
 *          (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array
 * @param Smarty
 * @return string
 */
function smarty_function_url4($params, &$smarty)
{

$str = (isset($_GET['filter']) && strlen($_GET['filter'])>0) ? $_GET['filter'] : '';

if(strlen($str)>0)$l = explode(';',$str);
else $l = array();

$f=0;
foreach($l as $key=>$q){
 if($params['prefix'].$params['n'].'_'.$params['s']==$q){$f++;unset($l[$key]);}
}

if($f==0)$l[] = $params['prefix'].$params['n'].'_'.$params['s'];

sort($l);

$param = (count($l)) ? ("filter=".implode(",",$l)) : null;
$h = array();
if(trim($_GET['search_str'])!='') $h[] = "search_str=".trim($_GET['search_str']);
if(trim($_GET['brend'])!='') $h[] = "brend=".trim($_GET['brend']);
if(trim($_GET['sex'])!='') $h[] = "sex=".trim($_GET['sex']);
if(count($h)>0) $g = ";";
else $g = "";


return str_replace("/","",'/'.$_REQUEST['rubID']."-catalogs/filter;" . implode(";",$h) . $g . $param);
}

/* vim: set expandtab: */

?>