Blame view

plugins/function.url.php 911 Bytes
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  <?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_url($params, &$smarty)
  {       //  print_r($_SERVER);
      $url = preg_replace('/'.$params['var'].'=([0-9]+)/i',null,$_SERVER['REQUEST_URI']);
     // $url = (substr($url,-1,1)=='/')?$url:$url.'/';
     // return (substr($url,-1,1)=='&' or substr($url,-1,1)=='?')?$url:$url.'?';
     return (strpos($url,'?'))?((substr($url,-1,1)=='?')?$url:((substr($url,-1,1)=='&')?$url:$url.'&')):((substr($url,-1,1)=='/')?$url.'?':$url.'/?');
  }
  
  /* vim: set expandtab: */
  
  ?>