mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 09:13:02 +02:00
template improvement: added merge_block_vars method (instead of creating a
new block iteration, it merges given variables with the last block). This is a trick available to plugins (it will avoid calling trigger_event every 2 lines). git-svn-id: http://piwigo.org/svn/trunk@1587 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -243,6 +243,30 @@ class Template {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Block-level variable merge. Merge given variables to the last block
|
||||
* iteration. This can be called several times per block iteration.
|
||||
*/
|
||||
function merge_block_vars($blockname, $vararray)
|
||||
{
|
||||
$blocks = explode('.', $blockname);
|
||||
$blockcount = count($blocks);
|
||||
$str = '$this->_tpldata';
|
||||
for ($i = 0; $i < $blockcount; $i++)
|
||||
{
|
||||
$str .= '[\'' . $blocks[$i] . '.\']';
|
||||
eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;');
|
||||
if ($lastiteration==-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$str .= '[' . $lastiteration . ']';
|
||||
}
|
||||
$str = $str.'=array_merge('.$str.', $vararray);';
|
||||
eval($str);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root-level variable assignment. Adds to current assignments, overriding
|
||||
* any existing variable assignment with the same name.
|
||||
|
||||
Reference in New Issue
Block a user