Source for file function.url.php

Documentation is available at function.url.php

  1. <?php
  2. /**
  3.  *  smarty function:url生成
  4.  */
  5. function smarty_function_url($params&$smarty)
  6. {
  7.     $action $path $path_key null;
  8.     $query $params;
  9.  
  10.     foreach (array('action''anchor''scheme'as $key{
  11.         if (isset($params[$key])) {
  12.             ${$key$params[$key];
  13.         else {
  14.             ${$keynull;
  15.         }
  16.         unset($query[$key]);
  17.     }
  18.  
  19.     $c Ethna_Controller::getInstance();
  20.     $config $c->getConfig();
  21.     $url_handler $c->getUrlHandler();
  22.     list($path$path_key$url_handler->actionToRequest($action$query);
  23.  
  24.     if ($path != ""{
  25.         if (is_array($path_key)) {
  26.             foreach ($path_key as $key{
  27.                 unset($query[$key]);
  28.             }
  29.         }
  30.     else {
  31.         $query $url_handler->buildActionParameter($query$action);
  32.     }
  33.     $query $url_handler->buildQueryParameter($query);
  34.  
  35.     $url sprintf('%s%s'$c->getUrl()$path);
  36.  
  37.     if (preg_match('|^(\w+)://(.*)$|'$url$match)) {
  38.         if ($scheme{
  39.             $match[1$scheme;
  40.         }
  41.         $match[2preg_replace('|/+|''/'$match[2]);
  42.         $url $match[1'://' $match[2];
  43.     }
  44.  
  45.     $url .= $query "?$query"";
  46.     $url .= $anchor "#$anchor"";
  47.  
  48.     return $url;
  49. }

Documentation generated on Fri, 11 Nov 2011 03:58:10 +0900 by phpDocumentor 1.4.3