mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Use a static variable to handle expansion when initializing with content set (validation)
This commit is contained in:
parent
a9aeabeeb1
commit
b7f83ef31f
@ -75,6 +75,17 @@ class etemplate_widget
|
||||
*/
|
||||
static protected $response;
|
||||
|
||||
/**
|
||||
* Namespaced content array, used when trying to initialize
|
||||
*
|
||||
* This is pretty much a global static variable, used when reading
|
||||
* a template with the content set. This allows variable expansion
|
||||
* in the constructor.
|
||||
*
|
||||
* @protected $cont
|
||||
*/
|
||||
static protected $cont = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -89,6 +100,15 @@ class etemplate_widget
|
||||
|
||||
$this->id = $reader->getAttribute('id');
|
||||
|
||||
// Update content?
|
||||
if(self::$cont == null)
|
||||
self::$cont = is_array(self::$request->content) ? self::$request->content : array();
|
||||
if($this->id && is_array(self::$cont[$this->id]))
|
||||
{
|
||||
$old_cont = self::$cont;
|
||||
self::$cont = self::$cont[$this->id];
|
||||
}
|
||||
|
||||
// read all attributes
|
||||
$this->set_attrs($reader);
|
||||
|
||||
@ -99,6 +119,11 @@ class etemplate_widget
|
||||
$this->children[] = self::factory($reader->name, $reader, $reader->getAttribute('id'));
|
||||
}
|
||||
}
|
||||
|
||||
// Reset content as we leave
|
||||
if($old_cont) {
|
||||
self::$cont = $old_cont;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,6 +64,12 @@ class etemplate_widget_template extends etemplate_widget
|
||||
if($name == $c_sub) return $c_template;
|
||||
}
|
||||
}
|
||||
// Template not found, try again with content expansion
|
||||
if (is_array(self::$request->content))
|
||||
{
|
||||
$expand_name = self::expand_name($name, '','','','',self::$cont);
|
||||
if($expand_name && $expand_name != $name) return self::instance($expand_name, $template_set, $version, $load_via);
|
||||
}
|
||||
|
||||
error_log(__METHOD__."('$name', '$template_set', '$version', '$load_via') template NOT found!");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user