Skip to content

Commit

Permalink
Resolved issue 0000718: Add method "concat_var_from_handle" in templa…
Browse files Browse the repository at this point in the history
…te class

Rename trigger name loc_before_* by loc_begin_*

Merge branch-1_7 2048:2050 into BSF

git-svn-id: http://piwigo.org/svn/trunk@2058 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Jul 10, 2007
1 parent f3b1fed commit 7183b5d
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions include/template.php
Expand Up @@ -155,7 +155,7 @@ function pparse($handle)
// actually compile the template now.
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
{
trigger_action('loc_before_tpl_pparse', $handle, array(&$this));
trigger_action('loc_begin_tpl_pparse', $handle, array(&$this));
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
}
Expand All @@ -179,7 +179,7 @@ function parse($handle, $return=false)
// actually compile the template now.
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
{
trigger_action('loc_before_tpl_parse', $handle, array(&$this));
trigger_action('loc_begin_tpl_parse', $handle, array(&$this));
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str');
}
Expand Down Expand Up @@ -214,21 +214,23 @@ function p()
*/
function assign_var_from_handle($varname, $handle)
{
if (!$this->loadfile($handle))
{
die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle");
}

trigger_action('loc_before_tpl_assign_var_from_handle', $handle, array(&$this));
// Compile it, with the "no echo statements" option on.
$_str = "";
$code = $this->compile($this->uncompiled_code[$handle], true, '_str');

// evaluate the variable assignment.
eval($code);
// assign the value of the generated variable to the given varname.
$this->assign_var($varname, $_str);
trigger_action('loc_begin_tpl_assign_var_from_handle', $varname, $handle, array(&$this));
$this->assign_var($varname, $this->parse($handle, true));
return true;
}

/**
* Concat the uncompiled code for $handle as the value of $varname in the
* root-level. This can be used to effectively include a template in the
* middle of another template.
*
* Note that all desired assignments to the variables in $handle should be
* done BEFORE calling this function.
*/
function concat_var_from_handle($varname, $handle)
{
trigger_action('loc_begin_tpl_concat_var_from_handle', $varname, $handle, array(&$this));
$this->concat_var($varname, $this->parse($handle, true));
return true;
}

Expand Down

0 comments on commit 7183b5d

Please sign in to comment.