fix not working load_via parameter

This commit is contained in:
Ralf Becker 2021-04-18 21:07:26 +02:00
parent 80ae34158d
commit fb30713cbb
3 changed files with 20 additions and 16 deletions

View File

@ -164,7 +164,7 @@ class Etemplate extends Etemplate\Widget\Template
if (empty($this->name)) throw new Exception\AssertionFailed("Template name is not set '$this->name' !");
// instanciate template to fill self::$request->sel_options for select-* widgets
// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
$template = self::instance($this->name, $this->template_set, $this->version, $this->laod_via);
$template = self::instance($this->name, $this->template_set, $this->version, $this->load_via);
if (!$template) throw new Exception\AssertionFailed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
$this->children = array($template);
$template->run('beforeSendToClient', array('', array('cont'=>$content)));
@ -504,7 +504,7 @@ class Etemplate extends Etemplate\Widget\Template
public $name;
public $template_set;
public $version;
public $laod_via;
public $load_via;
/**
*
@ -536,7 +536,7 @@ class Etemplate extends Etemplate\Widget\Template
unset($lang); unset($group); // not used, but in old signature
$this->rel_path = self::relPath($this->name=$name, $this->template_set=$template_set,
$this->version=$version, $this->laod_via = $load_via);
$this->version=$version, $this->load_via = $load_via);
//error_log(__METHOD__."('$name', '$template_set', '$lang', $group, '$version', '$load_via') rel_path=".array2string($this->rel_path));
$this->dom_id = isset($_GET['fw_target']) ? $name.'-'.$_GET['fw_target'] : $name;

View File

@ -729,19 +729,22 @@ class Select extends Etemplate\Widget
MCAL_M_WEEKEND => 'weekend',
);
}
$value_in = $value;
$value = array();
foreach(array_keys($options) as $val)
if (!is_array($value))
{
if (($value_in & $val) == $val)
$value_in = $value;
$value = array();
foreach (array_keys($options) as $val)
{
$value[] = $val;
if ($val == MCAL_M_ALLDAYS ||
$val == MCAL_M_WEEKDAYS && $value_in == MCAL_M_WEEKDAYS ||
$val == MCAL_M_WEEKEND && $value_in == MCAL_M_WEEKEND)
if (($value_in & $val) == $val)
{
break; // dont set the others
$value[] = $val;
if ($val == MCAL_M_ALLDAYS ||
$val == MCAL_M_WEEKDAYS && $value_in == MCAL_M_WEEKDAYS ||
$val == MCAL_M_WEEKEND && $value_in == MCAL_M_WEEKEND)
{
break; // dont set the others
}
}
}
}

View File

@ -66,7 +66,7 @@ class Template extends Etemplate\Widget
//$start = microtime(true);
list($name) = explode('?', $_name); // remove optional cache-buster
if (isset(self::$cache[$name]) || !($path = self::relPath($name, $template_set, $version)))
if (isset(self::$cache[$name]) || !($path = self::relPath($name, $template_set, $version, $load_via)))
{
if ((!$path || self::read($load_via, $template_set)) && isset(self::$cache[$name]))
{
@ -139,13 +139,14 @@ class Template extends Etemplate\Widget
* @param string $name
* @param string $template_set =null default try template-set from user and if not found "default"
* @param string $version =''
* @param string $load_via =''
* @return string path of template xml file or null if not found
*/
public static function relPath($name, $template_set=null, $version='')
public static function relPath($name, $template_set=null, $version='', $load_via='')
{
static $prefixes = null;
unset($version); // not used currently
list($app, $rest) = explode('.', $name, 2);
list($app, $rest) = explode('.', $load_via ?: $name, 2);
if (empty($template_set))
{