diff --git a/gosa-core/include/smarty/sysplugins/smarty_internal_config.php b/gosa-core/include/smarty/sysplugins/smarty_internal_config.php
index 3141e79319e4e7482faac788d76590b4df8d3aa2..5355512338c3f4a259927125f22bbf0a4585291b 100644 (file)
class Smarty_Internal_Config {
static $config_objects = array();
- public function __construct($config_resource, $smarty, $template = null)
+ public function __construct($config_resource, $smarty, $data = null)
{
- $this->template = $template;
+ $this->data = $data;
$this->smarty = $smarty;
$this->config_resource = $config_resource;
$this->config_resource_type = null;
$this->compiler_object = null;
// parse config resource name
if (!$this->parseConfigResourceName ($config_resource)) {
- throw new Exception ("Unable to parse config resource '{$config_resource}'");
+ throw new SmartyException ("Unable to parse config resource '{$config_resource}'");
}
}
if (file_exists($this->config_resource_name))
return $this->config_resource_name;
// no tpl file found
- throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
+ throw new SmartyException("Unable to load config file \"{$this->config_resource_name}\"");
return false;
}
/**
{
if ($this->config_source === null) {
if ($this->readConfigSource($this) === false) {
- throw new Exception("Unable to load config file \"{$this->config_resource_name}\"");
+ throw new SmartyException("Unable to load config file \"{$this->config_resource_name}\"");
}
}
return $this->config_source;
}
public function buildCompiledFilepath()
{
+ $_compile_id = isset($this->smarty->compile_id) ? preg_replace('![^\w\|]+!', '_', $this->smarty->compile_id) : null;
$_flag = (int)$this->smarty->config_read_hidden + (int)$this->smarty->config_booleanize * 2 +
(int)$this->smarty->config_overwrite * 4;
$_filepath = sha1($this->config_resource_name . $_flag);
. substr($_filepath, 4, 2) . DS
. $_filepath;
}
+ $_compile_dir_sep = $this->smarty->use_sub_dirs ? DS : '^';
+ if (isset($_compile_id)) {
+ $_filepath = $_compile_id . $_compile_dir_sep . $_filepath;
+ }
$_compile_dir = $this->smarty->compile_dir;
if (substr($_compile_dir, -1) != DS) {
$_compile_dir .= DS;
public function mustCompile ()
{
return $this->mustCompile === null ?
- $this->mustCompile = ($this->smarty->force_compile || $this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTimestamp ()):
+ $this->mustCompile = ($this->smarty->force_compile || $this->getCompiledTimestamp () === false || $this->smarty->compile_check && $this->getCompiledTimestamp () < $this->getTimestamp ()):
$this->mustCompile;
}
/**
* @param mixed $sections array of section names, single section or null
* @param object $scope global,parent or local
*/
- public function loadConfigVars ($sections = null, $scope)
+ public function loadConfigVars ($sections = null, $scope = 'local')
{
- if (isset($this->template)) {
- $this->template->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
- } else {
- $this->smarty->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp());
+ if ($this->data instanceof Smarty_Internal_Template) {
+ $this->data->properties['file_dependency'][sha1($this->getConfigFilepath())] = array($this->getConfigFilepath(), $this->getTimestamp(),'file');
}
if ($this->mustCompile()) {
$this->compileConfigSource();
- }
+ }
+ // pointer to scope
+ if ($scope == 'local') {
+ $scope_ptr = $this->data;
+ } elseif ($scope == 'parent') {
+ if (isset($this->data->parent)) {
+ $scope_ptr = $this->data->parent;
+ } else {
+ $scope_ptr = $this->data;
+ }
+ } elseif ($scope == 'root' || $scope == 'global') {
+ $scope_ptr = $this->data;
+ while (isset($scope_ptr->parent)) {
+ $scope_ptr = $scope_ptr->parent;
+ }
+ }
+ $_config_vars = array();
include($this->getCompiledFilepath ());
// copy global config vars
foreach ($_config_vars['vars'] as $variable => $value) {
- if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
- $scope->config_vars[$variable] = $value;
+ if ($this->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
+ $scope_ptr->config_vars[$variable] = $value;
} else {
- $scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
+ $scope_ptr->config_vars[$variable] = array_merge((array)$scope_ptr->config_vars[$variable], (array)$value);
}
}
// scan sections
- foreach ($_config_vars['sections'] as $this_section => $dummy) {
- if ($sections == null || in_array($this_section, (array)$sections)) {
- foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
- if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
- $scope->config_vars[$variable] = $value;
- } else {
- $scope->config_vars[$variable] = array_merge((array)$scope->config_vars[$variable], (array)$value);
- }
- }
- }
- }
+ if(!empty($sections)) {
+ foreach ($_config_vars['sections'] as $this_section => $dummy) {
+ if (in_array($this_section, (array)$sections)) {
+ foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
+ if ($this->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
+ $scope_ptr->config_vars[$variable] = $value;
+ } else {
+ $scope_ptr->config_vars[$variable] = array_merge((array)$scope_ptr->config_vars[$variable], (array)$value);
+ }
+ }
+ }
+ }
+ }
}
}
-
?>
\ No newline at end of file