Dotclear

Changeset 2852:86651202b279 for inc


Ignore:
Timestamp:
12/16/14 21:59:13 (11 years ago)
Author:
Dsls
Branch:
2.7
Message:

Tuned redirections and admin urls management, should work with media & attachments now
Added adminurl->redirect to avoid confusion in "when to use & and when not to"

Location:
inc/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.dc.adminurl.php

    r2849 r2852  
    7575      * @return string            the forged url 
    7676      */ 
    77      public function get($name,$params=array(),$urlencode=true,$separator='&') 
     77     public function get($name,$params=array(),$separator='&') 
    7878     { 
    7979          if (!isset($this->urls[$name])) { 
    8080               throw new exception ('Unknown URL handler for '.$name); 
    81           } 
    82           // compatibility check for old behavior 
    83           if (!is_bool($urlencode)) { 
    84                $separator=$urlencode; 
    85                $urlencode = true; 
    8681          } 
    8782          $url = $this->urls[$name]; 
     
    9186               $u .= '?'.http_build_query($p,'',$separator); 
    9287          } 
    93           return $urlencode?$u:urldecode($u); 
     88          return $u; 
    9489     } 
     90 
     91 
     92     /** 
     93      * retrieves a URL given its name, and optional parameters 
     94      * 
     95      * @param  string $name      URL Name 
     96      * @param  array  $params    query string parameters, given as an associative array 
     97      * @param  boolean $urlencode set to true if url may not be encoded 
     98      * @param  string $separator separator to use between QS parameters 
     99      * @return string            the forged url 
     100      */ 
     101     public function redirect($name,$params=array(),$suffix="") 
     102     { 
     103          if (!isset($this->urls[$name])) { 
     104               throw new exception ('Unknown URL handler for '.$name); 
     105          } 
     106          http::redirect($this->get($name,$params,'&').$suffix); 
     107     } 
     108 
     109 
     110     /** 
     111      * retrieves a php page given its name, and optional parameters 
     112      * acts like get, but without the query string, should be used within forms actions 
     113      * 
     114      * @param  string $name      URL Name 
     115      * @return string            the forged url 
     116      */ 
     117     public function getBase($name) 
     118     { 
     119          if (!isset($this->urls[$name])) { 
     120               throw new exception ('Unknown URL handler for '.$name); 
     121          } 
     122          return $this->urls[$name]['url']; 
     123     } 
     124 
     125     /** 
     126      * forges form hidden fields to pass to a generated <form>. Should be used in combination with 
     127      * form action retrieved from getBase() 
     128      * 
     129      * @param  string $name      URL Name 
     130      * @param  array  $params    query string parameters, given as an associative array 
     131      * @return string            the forged form data 
     132      */ 
     133     public function getHiddenFormFields($name,$params=array()) 
     134     { 
     135          if (!isset($this->urls[$name])) { 
     136               throw new exception ('Unknown URL handler for '.$name); 
     137          } 
     138          $url = $this->urls[$name]; 
     139          $p = array_merge($url['qs'],$params); 
     140          $str = ''; 
     141          foreach ((array)$p as $k => $v) { 
     142               $str .= form::hidden(array($k),$v); 
     143          } 
     144          return $str; 
     145     } 
     146 
     147 
    95148 
    96149     /** 
    97150      * retrieves a URL (decoded — useful for echoing) given its name, and optional parameters 
    98151      * 
    99       * @deprecated should use get(...,true,...) instead 
     152      * should be used carefully, parameters are no more escaped 
    100153      * 
    101154      * @param  string $name      URL Name 
  • inc/admin/lib.dc.page.php

    r2849 r2852  
    927927 
    928928     public static function getPF($file) { 
    929           return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file),false); 
     929          return $GLOBALS['core']->adminurl->get('load.plugin.file',array('pf' => $file)); 
    930930     } 
    931931} 
  • inc/admin/lib.pager.php

    r2849 r2852  
    214214     { 
    215215          if ($this->core->auth->check('categories',$this->core->blog->id)) { 
    216                $cat_link = '<a href="'.$this->core->adminurl->get('admin.category',array('id' => '%s'),false).'">%s</a>'; 
     216               $cat_link = '<a href="'.$this->core->adminurl->get('admin.category',array('id' => '%s')).'">%s</a>'; 
     217               $cat_link = str_replace('%25s','%s',$cat_link); 
    217218          } else { 
    218219               $cat_link = '%2$s'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map