summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Widgets/smarty/libs/sysplugins/smarty_internal_config.php')
-rw-r--r--Widgets/smarty/libs/sysplugins/smarty_internal_config.php75
1 files changed, 36 insertions, 39 deletions
diff --git a/Widgets/smarty/libs/sysplugins/smarty_internal_config.php b/Widgets/smarty/libs/sysplugins/smarty_internal_config.php
index 25694d5a..a309ec9f 100644
--- a/Widgets/smarty/libs/sysplugins/smarty_internal_config.php
+++ b/Widgets/smarty/libs/sysplugins/smarty_internal_config.php
@@ -2,23 +2,27 @@
/**
* Smarty Internal Plugin Config
*
- * @package Smarty
+ * @package Smarty
* @subpackage Config
- * @author Uwe Tews
+ * @author Uwe Tews
*/
/**
* Smarty Internal Plugin Config
+ *
* Main class for config variables
*
- * @package Smarty
+ * @package Smarty
* @subpackage Config
+ *
+ * @property Smarty_Config_Source $source
+ * @property Smarty_Config_Compiled $compiled
* @ignore
*/
-class Smarty_Internal_Config
-{
+class Smarty_Internal_Config {
+
/**
- * Smarty instance
+ * Samrty instance
*
* @var Smarty object
*/
@@ -31,7 +35,6 @@ class Smarty_Internal_Config
public $data = null;
/**
* Config resource
- *
* @var string
*/
public $config_resource = null;
@@ -55,7 +58,6 @@ class Smarty_Internal_Config
public $compiled_timestamp = null;
/**
* flag if compiled config file is invalid and must be (re)compiled
- *
* @var bool
*/
public $mustCompile = null;
@@ -70,8 +72,8 @@ class Smarty_Internal_Config
* Constructor of config file object
*
* @param string $config_resource config file resource name
- * @param Smarty $smarty Smarty instance
- * @param object $data object for config vars storage
+ * @param Smarty $smarty Smarty instance
+ * @param object $data object for config vars storage
*/
public function __construct($config_resource, $smarty, $data = null)
{
@@ -88,8 +90,8 @@ class Smarty_Internal_Config
public function getCompiledFilepath()
{
return $this->compiled_filepath === null ?
- ($this->compiled_filepath = $this->buildCompiledFilepath()) :
- $this->compiled_filepath;
+ ($this->compiled_filepath = $this->buildCompiledFilepath()) :
+ $this->compiled_filepath;
}
/**
@@ -101,26 +103,25 @@ class Smarty_Internal_Config
{
$_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(realpath($this->source->filepath) . $_flag);
+ + (int) $this->smarty->config_overwrite * 4;
+ $_filepath = sha1($this->source->name . $_flag);
// if use_sub_dirs, break file into directories
if ($this->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS
- . substr($_filepath, 2, 2) . DS
- . substr($_filepath, 4, 2) . DS
- . $_filepath;
+ . substr($_filepath, 2, 2) . DS
+ . 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->getCompileDir();
-
return $_compile_dir . $_filepath . '.' . basename($this->source->name) . '.config' . '.php';
}
/**
- * Returns the timestamp of the compiled file
+ * Returns the timpestamp of the compiled file
*
* @return integer the file timestamp
*/
@@ -133,6 +134,7 @@ class Smarty_Internal_Config
/**
* Returns if the current config file must be compiled
+ *
* It does compare the timestamps of config source and the compiled config and checks the force compile configuration
*
* @return boolean true if the file must be compiled
@@ -140,12 +142,13 @@ class Smarty_Internal_Config
public function mustCompile()
{
return $this->mustCompile === null ?
- $this->mustCompile = ($this->smarty->force_compile || $this->getCompiledTimestamp() === false || $this->smarty->compile_check && $this->getCompiledTimestamp() < $this->source->timestamp) :
+ $this->mustCompile = ($this->smarty->force_compile || $this->getCompiledTimestamp () === false || $this->smarty->compile_check && $this->getCompiledTimestamp () < $this->source->timestamp):
$this->mustCompile;
}
/**
* Returns the compiled config file
+ *
* It checks if the config file must be compiled or just read the compiled version
*
* @return string the compiled config file
@@ -160,7 +163,6 @@ class Smarty_Internal_Config
$this->compiled_config = file_get_contents($this->getCompiledFilepath());
}
}
-
return $this->compiled_config;
}
@@ -185,15 +187,14 @@ class Smarty_Internal_Config
// call compiler
try {
$this->compiler_object->compileSource($this);
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
// restore old timestamp in case of error
if ($this->smarty->compile_locking && $saved_timestamp) {
touch($this->getCompiledFilepath(), $saved_timestamp);
}
throw $e;
}
- // compiling succeeded
+ // compiling succeded
// write compiled template
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty);
}
@@ -201,10 +202,8 @@ class Smarty_Internal_Config
/**
* load config variables
*
- * @param mixed $sections array of section names, single section or null
- * @param string $scope global,parent or local
- *
- * @throws Exception
+ * @param mixed $sections array of section names, single section or null
+ * @param object $scope global,parent or local
*/
public function loadConfigVars($sections = null, $scope = 'local')
{
@@ -241,8 +240,9 @@ class Smarty_Internal_Config
}
// scan sections
if (!empty($sections)) {
- foreach ((array) $sections as $this_section) {
- if (isset($_config_vars['sections'][$this_section])) {
+ $sections = array_flip((array) $sections);
+ foreach ($_config_vars['sections'] as $this_section => $dummy) {
+ if (isset($sections[$this_section])) {
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;
@@ -258,9 +258,8 @@ class Smarty_Internal_Config
/**
* set Smarty property in template context
*
- * @param string $property_name property name
- * @param mixed $value value
- *
+ * @param string $property_name property name
+ * @param mixed $value value
* @throws SmartyException if $property_name is not valid
*/
public function __set($property_name, $value)
@@ -269,7 +268,6 @@ class Smarty_Internal_Config
case 'source':
case 'compiled':
$this->$property_name = $value;
-
return;
}
@@ -279,9 +277,7 @@ class Smarty_Internal_Config
/**
* get Smarty property in template context
*
- * @param string $property_name property name
- *
- * @return \Smarty_Config_Source|\Smarty_Template_Compiled
+ * @param string $property_name property name
* @throws SmartyException if $property_name is not valid
*/
public function __get($property_name)
@@ -292,15 +288,16 @@ class Smarty_Internal_Config
throw new SmartyException("Unable to parse resource name \"{$this->config_resource}\"");
}
$this->source = Smarty_Resource::config($this);
-
return $this->source;
case 'compiled':
$this->compiled = $this->source->getCompiled($this);
-
return $this->compiled;
}
throw new SmartyException("config attribute '$property_name' does not exist.");
}
+
}
+
+?> \ No newline at end of file