Changeset 23263


Ignore:
Timestamp:
Jun 16, 2013, 7:15:24 PM (11 years ago)
Author:
mistic100
Message:

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

Location:
trunk
Files:
3 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  }
  • trunk/themes/default/template/index.tpl

    r20982 r23263  
    112112                </a>{/strip}</li>
    113113{/if}
     114{foreach from=$PLUGIN_INDEX_BUTTONS item=button}<li>{$button}</li>{/foreach}
    114115{if !empty($PLUGIN_INDEX_ACTIONS)}{$PLUGIN_INDEX_ACTIONS}{/if}
    115116        </ul>
  • trunk/themes/default/template/picture.tpl

    r21176 r23263  
    7777        </a>
    7878{/if}{/strip}
     79{foreach from=$PLUGIN_PICTURE_BUTTONS item=button}{$button}{/foreach}
    7980{if isset($PLUGIN_PICTURE_ACTIONS)}{$PLUGIN_PICTURE_ACTIONS}{/if}
    8081{strip}{if isset($favorite)}
Note: See TracChangeset for help on using the changeset viewer.