aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-06-16 17:15:24 +0000
committermistic100 <mistic@piwigo.org>2013-06-16 17:15:24 +0000
commit2b8ea75b1d7adfbabe0f0a7303f7d0b272da3cd3 (patch)
tree87e1b88ec3bc9ecda2ed74a4beee0190c4510a7a
parent0a98109a9eb6baa735fe9df2c48dc25e3390e969 (diff)
feature:2785 Improve template method to sort actions buttons
+ add default rank = 50 git-svn-id: http://piwigo.org/svn/trunk@23263 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/template.class.php23
-rw-r--r--themes/default/template/index.tpl1
-rw-r--r--themes/default/template/picture.tpl1
3 files changed, 17 insertions, 8 deletions
diff --git a/include/template.class.php b/include/template.class.php
index 7ee5c0457..368b297e2 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -21,6 +21,7 @@
// | USA. |
// +-----------------------------------------------------------------------+
+define('BUTTONS_RANK_NEUTRAL', 50);
class Template {
@@ -861,12 +862,12 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
return $themeconfs[$dir];
}
- function add_picture_button($content, $rank)
+ function add_picture_button($content, $rank=BUTTONS_RANK_NEUTRAL)
{
$this->picture_buttons[$rank][] = $content;
}
- function add_index_button($content, $rank)
+ function add_index_button($content, $rank=BUTTONS_RANK_NEUTRAL)
{
$this->index_buttons[$rank][] = $content;
}
@@ -876,9 +877,12 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
if (!empty($this->picture_buttons))
{
ksort($this->picture_buttons);
- foreach ($this->picture_buttons as $ranked)
- foreach ($ranked as $content)
- $this->concat('PLUGIN_PICTURE_ACTIONS', $content);
+ $this->assign('PLUGIN_PICTURE_BUTTONS',
+ array_reduce(
+ $this->picture_buttons,
+ create_function('$v,$w', 'return array_merge($v, $w);'),
+ array()
+ ));
}
}
@@ -887,9 +891,12 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
if (!empty($this->index_buttons))
{
ksort($this->index_buttons);
- foreach ($this->index_buttons as $ranked)
- foreach ($ranked as $content)
- $this->concat('PLUGIN_INDEX_ACTIONS', $content);
+ $this->assign('PLUGIN_INDEX_BUTTONS',
+ array_reduce(
+ $this->index_buttons,
+ create_function('$v,$w', 'return array_merge($v, $w);'),
+ array()
+ ));
}
}
diff --git a/themes/default/template/index.tpl b/themes/default/template/index.tpl
index 3ed52498c..71e8d8ba4 100644
--- a/themes/default/template/index.tpl
+++ b/themes/default/template/index.tpl
@@ -111,6 +111,7 @@ jQuery("#derivativeSwitchBox").on("mouseleave", function() {
<span class="pwg-icon pwg-icon-camera-calendar">&nbsp;</span><span class="pwg-button-text">{'Calendar'|@translate}</span>
</a>{/strip}</li>
{/if}
+{foreach from=$PLUGIN_INDEX_BUTTONS item=button}<li>{$button}</li>{/foreach}
{if !empty($PLUGIN_INDEX_ACTIONS)}{$PLUGIN_INDEX_ACTIONS}{/if}
</ul>
diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl
index eacb81beb..d86434c88 100644
--- a/themes/default/template/picture.tpl
+++ b/themes/default/template/picture.tpl
@@ -76,6 +76,7 @@ jQuery("#derivativeSwitchBox").on("mouseleave click", function() {
<span class="pwg-icon pwg-icon-save"> </span><span class="pwg-button-text">{'Download'|@translate}</span>
</a>
{/if}{/strip}
+{foreach from=$PLUGIN_PICTURE_BUTTONS item=button}{$button}{/foreach}
{if isset($PLUGIN_PICTURE_ACTIONS)}{$PLUGIN_PICTURE_ACTIONS}{/if}
{strip}{if isset($favorite)}
<a href="{$favorite.U_FAVORITE}" title="{if $favorite.IS_FAVORITE}{'delete this photo from your favorites'|@translate}{else}{'add this photo to your favorites'|@translate}{/if}" class="pwg-state-default pwg-button" rel="nofollow">