Dotclear

Changeset 772:2465bf307591


Ignore:
Timestamp:
11/28/11 10:26:03 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
default
Message:

Added new method getURLFor in urlhandler
2 new behaviors :

  • publicGetURLFor
  • publicRegisterURL

All changes are backward compatibles, news plugins will be encouraged
to use new urlhandler method for public URLs generation

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r747 r772  
    387387     if ($post_id) { 
    388388          $preview_url = 
    389           $core->blog->url.$core->url->getBase('preview').'/'. 
    390           $core->auth->userID().'/'. 
     389          $core->url->getURLFor('preview',$core->auth->userID().'/'. 
    391390          http::browserUID(DC_MASTER_KEY.$core->auth->userID().$core->auth->getInfo('user_pwd')). 
    392           '/'.$post->post_url; 
     391          '/'.$post->post_url); 
    393392          echo '<a id="post-preview" href="'.$preview_url.'" class="button">'.__('Preview').'</a> '; 
    394393     } 
  • inc/core/class.dc.rs.extensions.php

    r270 r772  
    188188     public static function getCategoryURL($rs) 
    189189     { 
    190           return $rs->core->blog->url.$rs->core->url->getBase('category').'/'. 
    191           html::sanitizeURL($rs->cat_url); 
     190          return $rs->core->url->getURLFor('category',html::sanitizeURL($rs->cat_url)); 
    192191     } 
    193192      
     
    395394     public static function getTrackbackLink($rs) 
    396395     { 
    397           return $rs->core->blog->url.$rs->core->url->getBase('trackback').'/'.$rs->post_id; 
     396          return $rs->core->url->getURLFor('trackback',$rs->post_id); 
    398397     } 
    399398      
     
    778777          $url = date('Y/m',strtotime($rs->dt)); 
    779778           
    780           return $core->blog->url.$core->url->getBase('archive').'/'.$url; 
     779          return $core->url->getURLFor('archive',$url); 
    781780     } 
    782781      
  • inc/core/class.dc.xmlrpc.php

    r696 r772  
    694694                    'description' => $rs->cat_title, 
    695695                    'categoryName' => $rs->cat_url, 
    696                     'htmlUrl' => $this->core->blog->url.$this->core->url->getBase('category').'/'.$rs->cat_url, 
    697                     'rssUrl' => $this->core->blog->url.$this->core->url->getBase('feed').'/category/'.$rs->cat_url.'/rss2' 
     696                    'htmlUrl' => $this->core->url->getURLFor('category',$rs->cat_url), 
     697                    'rssUrl' => $this->core->url->getURLFor('feed','category/'.$rs->cat_url.'/rss2') 
    698698               ); 
    699699                
     
    10721072           
    10731073          $res = array(); 
    1074           $url   = $this->core->blog->url.$this->core->url->getBase('tag').'/%s'; 
    1075           $f_url = $this->core->blog->url.$this->core->url->getBase('tag_feed').'/%s'; 
     1074          $url   = $this->core->url->getURLFor('tag','%s'); 
     1075          $f_url = $this->core->url->getURLFor('tag_feed','%s'); 
    10761076          while ($tags->fetch()) 
    10771077          { 
  • inc/public/class.dc.template.php

    r570 r772  
    742742     { 
    743743          $f = $this->getFilters($attr); 
    744           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("archive")').'; ?>'; 
     744          return '<?php echo '.sprintf($f,'$core->url->getURLFor("archive")').'; ?>'; 
    745745     } 
    746746      
     
    796796           
    797797          $f = $this->getFilters($attr); 
    798           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("feed")."/'.$type.'"').'; ?>'; 
     798          return '<?php echo '.sprintf($f,'$core->url->getURLFor("feed","'.$type.'")').'; ?>'; 
    799799     } 
    800800      
     
    881881     { 
    882882          $f = $this->getFilters($attr); 
    883           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase(\'rsd\')').'; ?>'; 
     883          return '<?php echo '.sprintf($f,'$core->url->getURLFor(\'rsd\')').'; ?>'; 
    884884     } 
    885885      
     
    10451045           
    10461046          $f = $this->getFilters($attr); 
    1047           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("feed")."/category/".'. 
    1048           '$_ctx->categories->cat_url."/'.$type.'"').'; ?>'; 
     1047          return '<?php echo '.sprintf($f,'$core->url->getURLFor("feed","category/".'. 
     1048          '$_ctx->categories->cat_url."/'.$type.'")').'; ?>'; 
    10491049     } 
    10501050      
     
    10551055     { 
    10561056          $f = $this->getFilters($attr); 
    1057           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("category")."/".$_ctx->categories->cat_url').'; ?>'; 
     1057          return '<?php echo '.sprintf($f,'$core->url->getURLFor("category",$_ctx->categories->cat_url)').'; ?>'; 
    10581058     } 
    10591059      
     
    19341934     { 
    19351935          $f = $this->getFilters($attr); 
    1936           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("lang").$_ctx->langs->post_lang').'; ?>'; 
     1936          return '<?php echo '.sprintf($f,'$core->url->getURLFor("lang",$_ctx->langs->post_lang)').'; ?>'; 
    19371937     } 
    19381938      
  • inc/public/lib.tpl.context.php

    r687 r772  
    9999     } 
    100100      
     101      
    101102     # Static methods 
    102103     public static function global_filter($str, 
  • inc/public/lib.urlhandlers.php

    r306 r772  
    1515{ 
    1616     public $args; 
     17      
     18     public function getURLFor($type,$value='') { 
     19          $core =& $GLOBALS['core']; 
     20          $url = $core->callBehavior("publicGetURLFor",$type,$value); 
     21          if ($url !== '') { 
     22               $url = $core->blog->url.$this->getBase($type); 
     23               if ($value !== '') { 
     24                    $url .= '/'.$value; 
     25               } 
     26          } 
     27          return $url; 
     28     } 
     29      
     30     public function register($type,$url,$representation,$handler) 
     31     { 
     32          $core =& $GLOBALS['core']; 
     33          $t = new ArrayObject(array($type,$url,$representation,$handler)); 
     34          $core->callBehavior("publicRegisterURL",$t); 
     35          parent::register($t[0],$t[1],$t[2],$t[3]); 
     36     } 
    1737      
    1838     public static function p404() 
Note: See TracChangeset for help on using the changeset viewer.

Sites map