summaryrefslogtreecommitdiff
path: root/lib/smarty3/sysplugins/smarty_template_config.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-12-27 14:47:01 +0100
committeremkael <emkael@tlen.pl>2016-12-27 14:47:01 +0100
commit7085a0c2f7104a56a7e946c43ba0b5736be5f4e7 (patch)
tree5518c72e3486f41c559be30e514be1917bf5724f /lib/smarty3/sysplugins/smarty_template_config.php
parent1a3d783d8957a6adbe49b1765b326805477e7856 (diff)
* smarty bundled
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_template_config.php')
-rw-r--r--lib/smarty3/sysplugins/smarty_template_config.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/smarty3/sysplugins/smarty_template_config.php b/lib/smarty3/sysplugins/smarty_template_config.php
new file mode 100644
index 0000000..44cdba6
--- /dev/null
+++ b/lib/smarty3/sysplugins/smarty_template_config.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * Smarty Config Source Plugin
+ *
+ * @package Smarty
+ * @subpackage TemplateResources
+ * @author Uwe Tews
+ */
+
+/**
+ * Smarty Config Resource Data Object
+ * Meta Data Container for Template Files
+ *
+ * @package Smarty
+ * @subpackage TemplateResources
+ * @author Uwe Tews
+ *
+ */
+class Smarty_Template_Config extends Smarty_Template_Source
+{
+ /**
+ * array of section names, single section or null
+ *
+ * @var null|string|array
+ */
+ public $config_sections = null;
+
+ /**
+ * scope into which the config variables shall be loaded
+ *
+ * @var int
+ */
+ public $scope = 0;
+
+ /**
+ * Flag that source is a config file
+ *
+ * @var bool
+ */
+ public $isConfig = true;
+
+ /**
+ * Name of the Class to compile this resource's contents with
+ *
+ * @var string
+ */
+ public $compiler_class = 'Smarty_Internal_Config_File_Compiler';
+
+ /**
+ * Name of the Class to tokenize this resource's contents with
+ *
+ * @var string
+ */
+ public $template_lexer_class = 'Smarty_Internal_Configfilelexer';
+
+ /**
+ * Name of the Class to parse this resource's contents with
+ *
+ * @var string
+ */
+ public $template_parser_class = 'Smarty_Internal_Configfileparser';
+
+ /**
+ * initialize Source Object for given resource
+ * Either [$_template] or [$smarty, $template_resource] must be specified
+ *
+ * @param Smarty_Internal_Template $_template template object
+ * @param Smarty $smarty smarty object
+ * @param string $template_resource resource identifier
+ *
+ * @return Smarty_Template_Config Source Object
+ * @throws SmartyException
+ */
+ public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null,
+ $template_resource = null)
+ {
+ static $_incompatible_resources = array('extends' => true, 'php' => true);
+ if ($_template) {
+ $smarty = $_template->smarty;
+ $template_resource = $_template->template_resource;
+ }
+ if (empty($template_resource)) {
+ throw new SmartyException('Source: Missing name');
+ }
+ // parse resource_name, load resource handler
+ list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type);
+ // make sure configs are not loaded via anything smarty can't handle
+ if (isset($_incompatible_resources[ $type ])) {
+ throw new SmartyException ("Unable to use resource '{$type}' for config");
+ }
+ $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name);
+ $source->handler->populate($source, $_template);
+ if (!$source->exists && isset($smarty->default_config_handler_func)) {
+ Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source);
+ $source->handler->populate($source, $_template);
+ }
+ return $source;
+ }
+}