Ignore:
Timestamp:
06/16/13 19:15:24 (7 years ago)
Author:
mistic100
Message:

feature:2785 Improve template method to sort actions buttons
+ add default rank = 50

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r23184 r23263  
    2222// +-----------------------------------------------------------------------+ 
    2323 
     24define('BUTTONS_RANK_NEUTRAL', 50); 
    2425 
    2526class Template { 
     
    862863  } 
    863864 
    864   function add_picture_button($content, $rank) 
     865  function add_picture_button($content, $rank=BUTTONS_RANK_NEUTRAL) 
    865866  { 
    866867    $this->picture_buttons[$rank][] = $content; 
    867868  } 
    868869 
    869   function add_index_button($content, $rank) 
     870  function add_index_button($content, $rank=BUTTONS_RANK_NEUTRAL) 
    870871  { 
    871872    $this->index_buttons[$rank][] = $content; 
     
    877878    { 
    878879      ksort($this->picture_buttons); 
    879       foreach ($this->picture_buttons as $ranked) 
    880         foreach ($ranked as $content) 
    881           $this->concat('PLUGIN_PICTURE_ACTIONS', $content); 
     880      $this->assign('PLUGIN_PICTURE_BUTTONS',  
     881          array_reduce( 
     882            $this->picture_buttons,  
     883            create_function('$v,$w', 'return array_merge($v, $w);'),  
     884            array() 
     885          )); 
    882886    } 
    883887  } 
     
    888892    { 
    889893      ksort($this->index_buttons); 
    890       foreach ($this->index_buttons as $ranked) 
    891         foreach ($ranked as $content) 
    892           $this->concat('PLUGIN_INDEX_ACTIONS', $content); 
     894      $this->assign('PLUGIN_INDEX_BUTTONS',  
     895          array_reduce( 
     896            $this->index_buttons,  
     897            create_function('$v,$w', 'return array_merge($v, $w);'),  
     898            array() 
     899          )); 
    893900    } 
    894901  } 
Note: See TracChangeset for help on using the changeset viewer.