Dotclear

Changeset 306:dbcdebc54a75


Ignore:
Timestamp:
05/23/11 13:21:08 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
default
Message:

Added pre-contextual behaviors in urlhandlers, enables plugins to add their own context parameters for default urlhandlers.

New behaviors introduced (syntax : "public".<urlhandler>."before".<function_called>)

  • publicLangBeforeGetLangs
  • publicCategoryBeforeGetCategories
  • publicArchiveBeforeGetDates
  • publicPostBeforeGetPosts
  • publicFeedBeforeGetLangs
  • publicFeedBeforeGetCategories
  • publicFeedBeforeGetPosts

Closes #1090.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/public/lib.urlhandlers.php

    r303 r306  
    204204           
    205205          $n = self::getPageNumber($args); 
    206            
    207           $params['lang'] = $args; 
     206          $params = new ArrayObject(array( 
     207               'lang' => $args)); 
     208           
     209          $core->callBehavior('publicLangBeforeGetLangs',$params,$args); 
     210           
    208211          $_ctx->langs = $core->blog->getLangs($params); 
    209212           
     
    235238          else 
    236239          { 
    237                $params['cat_url'] = $args; 
    238                $params['post_type'] = 'post'; 
     240               $params = new ArrayObject(array( 
     241                    'cat_url' => $args, 
     242                    'post_type' => 'post')); 
     243                
     244               $core->callBehavior('publicCategoryBeforeGetCategories',$params,$args); 
    239245                
    240246               $_ctx->categories = $core->blog->getCategories($params); 
     
    267273          elseif (preg_match('|^/([0-9]{4})/([0-9]{2})$|',$args,$m)) 
    268274          { 
    269                $params['year'] = $m[1]; 
    270                $params['month'] = $m[2]; 
    271                $params['type'] = 'month'; 
     275               $params = new ArrayObject(array( 
     276                    'year' => $m[1], 
     277                    'month' => $m[2], 
     278                    'type' => 'month')); 
     279                
     280               $core->callBehavior('publicArchiveBeforeGetDates',$params,$args); 
     281                
    272282               $_ctx->archives = $core->blog->getDates($params); 
    273283                
     
    300310               $core->blog->withoutPassword(false); 
    301311                
    302                $params = new ArrayObject(); 
    303                $params['post_url'] = $args; 
    304                 
     312               $params = new ArrayObject(array( 
     313                    'post_url' => $args)); 
     314                
     315               $core->callBehavior('publicPostBeforeGetPosts',$params,$args); 
     316 
    305317               $_ctx->posts = $core->blog->getPosts($params); 
    306318                
     
    481493          $cat_url = false; 
    482494          $post_id = null; 
    483           $params = array(); 
    484495          $subtitle = ''; 
    485496           
     
    490501           
    491502          if (preg_match('!^([a-z]{2}(-[a-z]{2})?)/(.*)$!',$args,$m)) { 
    492                $params['lang'] = $m[1]; 
     503               $params = new ArrayObject(array('lang' => $m[1])); 
     504                
    493505               $args = $m[3]; 
     506                
     507               $core->callBehavior('publicFeedBeforeGetLangs',$params,$args); 
    494508                
    495509               $_ctx->langs = $core->blog->getLangs($params); 
     
    535549          if ($cat_url) 
    536550          { 
    537                $params['cat_url'] = $cat_url; 
    538                $params['post_type'] = 'post'; 
     551               $params = new ArrayObject(array( 
     552                    'cat_url' => $cat_url, 
     553                    'post_type' => 'post')); 
     554                
     555               $core->callBehavior('publicFeedBeforeGetCategories',$params,$args); 
     556                
    539557               $_ctx->categories = $core->blog->getCategories($params); 
    540558                
     
    549567          elseif ($post_id) 
    550568          { 
    551                $params['post_id'] = $post_id; 
    552                $params['post_type'] = ''; 
     569               $params = new ArrayObject(array( 
     570                    'post_id' => $post_id, 
     571                    'post_type' => '')); 
     572                     
     573               $core->callBehavior('publicFeedBeforeGetPosts',$params,$args); 
     574                
    553575               $_ctx->posts = $core->blog->getPosts($params); 
    554576                
  • plugins/pages/_public.php

    r270 r306  
    3333               $core->blog->withoutPassword(false); 
    3434                
    35                $params = new ArrayObject(); 
    36                $params['post_type'] = 'page'; 
    37                $params['post_url'] = $args; 
     35               $params = new ArrayObject(array( 
     36                    'post_type' => 'page', 
     37                    'post_url' => $args)); 
     38                
     39               $core->callBehavior('publicPagesBeforeGetPosts',$params,$args); 
    3840                
    3941               $_ctx->posts = $core->blog->getPosts($params); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map