update Smarty to 3.1.29
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1841 a1433add-5e2c-0410-b055-b7f2511e0802pull/19/head
parent
54603b0968
commit
2bed4110a5
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Autoloader
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Autoloader
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @author Uwe Tews
|
||||||
|
* Usage:
|
||||||
|
* require_once '...path/Autoloader.php';
|
||||||
|
* Smarty_Autoloader::register();
|
||||||
|
* $smarty = new Smarty();
|
||||||
|
* Note: This autoloader is not needed if you use Composer.
|
||||||
|
* Composer will automatically add the classes of the Smarty package to it common autoloader.
|
||||||
|
*/
|
||||||
|
class Smarty_Autoloader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Filepath to Smarty root
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $SMARTY_DIR = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath to Smarty internal plugins
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $SMARTY_SYSPLUGINS_DIR = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array with Smarty core classes and their filename
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||||
|
*/
|
||||||
|
public static function registerBC($prepend = false)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* register the class autoloader
|
||||||
|
*/
|
||||||
|
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||||
|
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||||
|
}
|
||||||
|
if (SMARTY_SPL_AUTOLOAD &&
|
||||||
|
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||||
|
) {
|
||||||
|
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||||
|
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
|
||||||
|
spl_autoload_register();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self::register($prepend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers Smarty_Autoloader as an SPL autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||||
|
*/
|
||||||
|
public static function register($prepend = false)
|
||||||
|
{
|
||||||
|
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||||
|
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||||
|
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||||
|
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
||||||
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
|
} else {
|
||||||
|
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles auto loading of classes.
|
||||||
|
*
|
||||||
|
* @param string $class A class name.
|
||||||
|
*/
|
||||||
|
public static function autoload($class)
|
||||||
|
{
|
||||||
|
$_class = strtolower($class);
|
||||||
|
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||||
|
if (strpos($_class, 'smarty_internal_') === 0) {
|
||||||
|
if (strpos($_class, 'smarty_internal_compile_') === 0) {
|
||||||
|
if (is_file($file)) {
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@include $file;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/',
|
||||||
|
$_class, $match)) {
|
||||||
|
if (!empty($match[3])) {
|
||||||
|
@include $file;
|
||||||
|
return;
|
||||||
|
} elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
|
||||||
|
$file = self::$rootClasses[$_class];
|
||||||
|
require $file;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 !== strpos($_class, 'smarty')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (is_file($file)) {
|
||||||
|
require $file;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Resource Data Object
|
|
||||||
* Meta Data Container for Config Files
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
* @author Rodney Rehm
|
|
||||||
* @property string $content
|
|
||||||
* @property int $timestamp
|
|
||||||
* @property bool $exists
|
|
||||||
*/
|
|
||||||
class Smarty_Config_Source extends Smarty_Template_Source
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* create Config Object container
|
|
||||||
*
|
|
||||||
* @param Smarty_Resource $handler Resource Handler this source object communicates with
|
|
||||||
* @param Smarty $smarty Smarty instance this source object belongs to
|
|
||||||
* @param string $resource full config_resource
|
|
||||||
* @param string $type type of resource
|
|
||||||
* @param string $name resource name
|
|
||||||
* @param string $unique_resource unqiue resource name
|
|
||||||
*/
|
|
||||||
public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
|
|
||||||
{
|
|
||||||
$this->handler = $handler; // Note: prone to circular references
|
|
||||||
|
|
||||||
// Note: these may be ->config_compiler_class etc in the future
|
|
||||||
//$this->config_compiler_class = $handler->config_compiler_class;
|
|
||||||
//$this->config_lexer_class = $handler->config_lexer_class;
|
|
||||||
//$this->config_parser_class = $handler->config_parser_class;
|
|
||||||
|
|
||||||
$this->smarty = $smarty;
|
|
||||||
$this->resource = $resource;
|
|
||||||
$this->type = $type;
|
|
||||||
$this->name = $name;
|
|
||||||
$this->unique_resource = $unique_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <<magic>> Generic setter.
|
|
||||||
*
|
|
||||||
* @param string $property_name valid: content, timestamp, exists
|
|
||||||
* @param mixed $value newly assigned value (not check for correct type)
|
|
||||||
*
|
|
||||||
* @throws SmartyException when the given property name is not valid
|
|
||||||
*/
|
|
||||||
public function __set($property_name, $value)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'content':
|
|
||||||
case 'timestamp':
|
|
||||||
case 'exists':
|
|
||||||
$this->$property_name = $value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new SmartyException("invalid config property '$property_name'.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <<magic>> Generic getter.
|
|
||||||
*
|
|
||||||
* @param string $property_name valid: content, timestamp, exists
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
* @throws SmartyException when the given property name is not valid
|
|
||||||
*/
|
|
||||||
public function __get($property_name)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'timestamp':
|
|
||||||
case 'exists':
|
|
||||||
$this->handler->populateTimestamp($this);
|
|
||||||
|
|
||||||
return $this->$property_name;
|
|
||||||
|
|
||||||
case 'content':
|
|
||||||
return $this->content = $this->handler->getContent($this);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new SmartyException("config property '$property_name' does not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Plugin Data
|
||||||
|
* This file contains the data object
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Template
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class for the Smarty data object
|
||||||
|
* The Smarty data object will hold Smarty variables in the current scope
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Template
|
||||||
|
*/
|
||||||
|
class Smarty_Data extends Smarty_Internal_Data
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Counter
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
static $count = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data block name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dataObjectName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty object
|
||||||
|
*
|
||||||
|
* @var Smarty
|
||||||
|
*/
|
||||||
|
public $smarty = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create Smarty data object
|
||||||
|
*
|
||||||
|
* @param Smarty|array $_parent parent template
|
||||||
|
* @param Smarty|Smarty_Internal_Template $smarty global smarty instance
|
||||||
|
* @param string $name optional data block name
|
||||||
|
*
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function __construct($_parent = null, $smarty = null, $name = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
self::$count ++;
|
||||||
|
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
||||||
|
$this->smarty = $smarty;
|
||||||
|
if (is_object($_parent)) {
|
||||||
|
// when object set up back pointer
|
||||||
|
$this->parent = $_parent;
|
||||||
|
} elseif (is_array($_parent)) {
|
||||||
|
// set up variable values
|
||||||
|
foreach ($_parent as $_key => $_val) {
|
||||||
|
$this->tpl_vars[$_key] = new Smarty_Variable($_val);
|
||||||
|
}
|
||||||
|
} elseif ($_parent != null) {
|
||||||
|
throw new SmartyException("Wrong type for template variables");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,220 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile ForeachSection
|
||||||
|
* Shared methods for {foreach} {section} tags
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile ForeachSection Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preg search pattern
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $propertyPreg = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offsets in preg match result
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $resultOffsets = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start offset
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $startOffset = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of this tag
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tagName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid properties of $smarty.xxx variable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $nameProperties = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {section} tag has no item properties
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $itemProperties = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {section} tag has always name attribute
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $isNamed = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $matchResults = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan sources for used tag attributes
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function scanForProperties($attributes, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
$this->propertyPreg = '~(';
|
||||||
|
$this->startOffset = 0;
|
||||||
|
$this->resultOffsets = array();
|
||||||
|
$this->matchResults = array('named' => array(), 'item' => array());
|
||||||
|
if ($this->isNamed) {
|
||||||
|
$this->buildPropertyPreg(true, $attributes);
|
||||||
|
}
|
||||||
|
if (isset($this->itemProperties)) {
|
||||||
|
if ($this->isNamed) {
|
||||||
|
$this->propertyPreg .= '|';
|
||||||
|
}
|
||||||
|
$this->buildPropertyPreg(false, $attributes);
|
||||||
|
}
|
||||||
|
$this->propertyPreg .= ')\W~i';
|
||||||
|
// Template source
|
||||||
|
$this->matchTemplateSource($compiler);
|
||||||
|
// Parent template source
|
||||||
|
$this->matchParentTemplateSource($compiler);
|
||||||
|
// {block} source
|
||||||
|
$this->matchBlockSource($compiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build property preg string
|
||||||
|
*
|
||||||
|
* @param bool $named
|
||||||
|
* @param array $attributes
|
||||||
|
*/
|
||||||
|
public function buildPropertyPreg($named, $attributes)
|
||||||
|
{
|
||||||
|
if ($named) {
|
||||||
|
$this->resultOffsets['named'] = $this->startOffset + 3;
|
||||||
|
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
|
||||||
|
$properties = $this->nameProperties;
|
||||||
|
} else {
|
||||||
|
$this->resultOffsets['item'] = $this->startOffset + 3;
|
||||||
|
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
|
||||||
|
$properties = $this->itemProperties;
|
||||||
|
}
|
||||||
|
$this->startOffset += count($properties) + 2;
|
||||||
|
$propName = reset($properties);
|
||||||
|
while ($propName) {
|
||||||
|
$this->propertyPreg .= "({$propName})";
|
||||||
|
$propName = next($properties);
|
||||||
|
if ($propName) {
|
||||||
|
$this->propertyPreg .= '|';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->propertyPreg .= '))';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in source string
|
||||||
|
*
|
||||||
|
* @param string $source
|
||||||
|
*/
|
||||||
|
public function matchProperty($source)
|
||||||
|
{
|
||||||
|
preg_match_all($this->propertyPreg, $source, $match, PREG_SET_ORDER);
|
||||||
|
foreach ($this->resultOffsets as $key => $offset) {
|
||||||
|
foreach ($match as $m) {
|
||||||
|
if (isset($m[$offset]) && !empty($m[$offset])) {
|
||||||
|
$this->matchResults[$key][strtolower($m[$offset])] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in template source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function matchTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
$this->matchProperty($compiler->parser->lex->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in all parent template source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
// search parent compiler template source
|
||||||
|
$nextCompiler = $compiler;
|
||||||
|
while ($nextCompiler !== $nextCompiler->parent_compiler) {
|
||||||
|
$nextCompiler = $nextCompiler->parent_compiler;
|
||||||
|
if ($compiler !== $nextCompiler) {
|
||||||
|
// get template source
|
||||||
|
$_content = $nextCompiler->template->source->getContent();
|
||||||
|
if ($_content != '') {
|
||||||
|
// run pre filter if required
|
||||||
|
if ((isset($nextCompiler->smarty->autoload_filters['pre']) ||
|
||||||
|
isset($nextCompiler->smarty->registered_filters['pre']))) {
|
||||||
|
$_content = $nextCompiler->smarty->ext->_filter_Handler->runFilter('pre', $_content, $nextCompiler->template);
|
||||||
|
}
|
||||||
|
$this->matchProperty($_content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in {block} tag source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function matchBlockSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for the {$smarty.foreach.xxx} or {$smarty.section.xxx}tag
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
|
* @param array $parameter array with compilation parameter
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
* @throws \SmartyCompilerException
|
||||||
|
*/
|
||||||
|
public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
|
{
|
||||||
|
$tag = strtolower(trim($parameter[ 0 ], '"\''));
|
||||||
|
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
|
||||||
|
if (!$name) {
|
||||||
|
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
|
||||||
|
}
|
||||||
|
$property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
|
||||||
|
if (!$property || !in_array($property, $this->nameProperties)) {
|
||||||
|
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
|
||||||
|
}
|
||||||
|
$tagVar = "'__smarty_{$tag}_{$name}'";
|
||||||
|
return "(isset(\$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}']) ? \$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}'] : null)";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,209 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile PHP Expression
|
||||||
|
* Compiles any tag which will output an expression or variable
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile PHP Expression Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $required_attributes = array('code', 'type');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for generating output from any expression
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
|
* @param array $parameter array with compilation parameter
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
|
{
|
||||||
|
// check and get attributes
|
||||||
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
$compiler->has_code = false;
|
||||||
|
if ($_attr['type'] == 'xml') {
|
||||||
|
$compiler->tag_nocache = true;
|
||||||
|
$save = $compiler->template->compiled->has_nocache_code;
|
||||||
|
$output = addcslashes($_attr['code'], "'\\");
|
||||||
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
|
||||||
|
$output .
|
||||||
|
"';?>", $compiler, true)));
|
||||||
|
$compiler->template->compiled->has_nocache_code = $save;
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if ($_attr['type'] != 'tag') {
|
||||||
|
if ($compiler->php_handling == Smarty::PHP_REMOVE) {
|
||||||
|
return '';
|
||||||
|
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
|
||||||
|
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
|
||||||
|
'quote'), $_attr['code']);
|
||||||
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Text($output));
|
||||||
|
return '';
|
||||||
|
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
|
||||||
|
$compiler->tag_nocache = true;
|
||||||
|
$save = $compiler->template->compiled->has_nocache_code;
|
||||||
|
$output = addcslashes($_attr['code'], "'\\");
|
||||||
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
|
||||||
|
$output .
|
||||||
|
"';?>", $compiler, true)));
|
||||||
|
$compiler->template->compiled->has_nocache_code = $save;
|
||||||
|
return '';
|
||||||
|
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
|
||||||
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
|
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', null, true);
|
||||||
|
}
|
||||||
|
$compiler->has_code = true;
|
||||||
|
return $_attr['code'];
|
||||||
|
} else {
|
||||||
|
$compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$compiler->has_code = true;
|
||||||
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
|
$compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null, true);
|
||||||
|
}
|
||||||
|
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
||||||
|
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
||||||
|
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match);
|
||||||
|
if (!empty($match[2])) {
|
||||||
|
if ('nocache' == trim($match[2])) {
|
||||||
|
$compiler->tag_nocache = true;
|
||||||
|
} else {
|
||||||
|
$compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#",
|
||||||
|
"#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lexer code for PHP tags
|
||||||
|
*
|
||||||
|
* This code has been moved from lexer here fo easier debugging and maintenance
|
||||||
|
*
|
||||||
|
* @param $lex
|
||||||
|
*/
|
||||||
|
public function parsePhp($lex)
|
||||||
|
{
|
||||||
|
$lex->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||||
|
$close = 0;
|
||||||
|
$lex->taglineno = $lex->line;
|
||||||
|
$closeTag = '?>';
|
||||||
|
if (strpos($lex->value, '<?xml') === 0) {
|
||||||
|
$lex->is_xml = true;
|
||||||
|
$lex->token = Smarty_Internal_Templateparser::TP_NOCACHE;
|
||||||
|
return;
|
||||||
|
} elseif (strpos($lex->value, '<?') === 0) {
|
||||||
|
$lex->phpType = 'php';
|
||||||
|
} elseif (strpos($lex->value, '<%') === 0) {
|
||||||
|
$lex->phpType = 'asp';
|
||||||
|
$closeTag = '%>';
|
||||||
|
} elseif (strpos($lex->value, '%>') === 0) {
|
||||||
|
$lex->phpType = 'unmatched';
|
||||||
|
} elseif (strpos($lex->value, '?>') === 0) {
|
||||||
|
if ($lex->is_xml) {
|
||||||
|
$lex->is_xml = false;
|
||||||
|
$lex->token = Smarty_Internal_Templateparser::TP_NOCACHE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$lex->phpType = 'unmatched';
|
||||||
|
} elseif (strpos($lex->value, '<s') === 0) {
|
||||||
|
$lex->phpType = 'script';
|
||||||
|
$closeTag = '</script>';
|
||||||
|
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
|
||||||
|
if ($lex->isAutoLiteral()) {
|
||||||
|
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
|
||||||
|
if ($lex->value == $closeTag) {
|
||||||
|
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
|
||||||
|
}
|
||||||
|
$lex->phpType = 'tag';
|
||||||
|
}
|
||||||
|
if ($lex->phpType == 'unmatched') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (($lex->phpType == 'php' || $lex->phpType == 'asp') &&
|
||||||
|
($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$start = $lex->counter + strlen($lex->value);
|
||||||
|
$body = true;
|
||||||
|
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||||
|
$close = $match[0][1];
|
||||||
|
} else {
|
||||||
|
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||||
|
}
|
||||||
|
while ($body) {
|
||||||
|
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||||
|
$value = $match[0][0];
|
||||||
|
$from = $pos = $match[0][1];
|
||||||
|
if ($pos > $close) {
|
||||||
|
$body = false;
|
||||||
|
} else {
|
||||||
|
$start = $pos + strlen($value);
|
||||||
|
$phpCommentStart = $value == '/*';
|
||||||
|
if ($phpCommentStart) {
|
||||||
|
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
|
||||||
|
if ($phpCommentEnd) {
|
||||||
|
$pos2 = $match[0][1];
|
||||||
|
$start = $pos2 + strlen($match[0][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ($close > $pos && $close < $start) {
|
||||||
|
if (preg_match('~' . preg_quote($closeTag, '~') .
|
||||||
|
'~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
|
||||||
|
$close = $match[0][1];
|
||||||
|
$from = $close + strlen($match[0][0]);
|
||||||
|
} else {
|
||||||
|
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
|
||||||
|
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
|
||||||
|
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$body = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call back function for $php_handling = PHP_QUOTE
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @param $match
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function quote($match)
|
||||||
|
{
|
||||||
|
return htmlspecialchars($match[0], ENT_QUOTES);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Shared Inheritance
|
||||||
|
* Shared methods for {extends} and {block} tags
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Shared Inheritance Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register post compile callback to compile inheritance initialization code
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
* @param bool|false $initChildSequence if true force child template
|
||||||
|
*/
|
||||||
|
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||||
|
{
|
||||||
|
if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
|
||||||
|
$compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
||||||
|
array($initChildSequence), 'inheritanceInit', $initChildSequence);
|
||||||
|
|
||||||
|
$compiler->_cache['inheritanceInit'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile inheritance initialization code as prefix
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
* @param bool|false $initChildSequence if true force child template
|
||||||
|
*/
|
||||||
|
static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||||
|
{
|
||||||
|
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->ext->_inheritance->init(\$_smarty_tpl, " .
|
||||||
|
var_export($initChildSequence, true) . ");\n?>\n";
|
||||||
|
}
|
||||||
|
}
|
@ -1,306 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Config
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Config
|
|
||||||
* @author Uwe Tews
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Config
|
|
||||||
* Main class for config variables
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Config
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Config
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Smarty instance
|
|
||||||
*
|
|
||||||
* @var Smarty object
|
|
||||||
*/
|
|
||||||
public $smarty = null;
|
|
||||||
/**
|
|
||||||
* Object of config var storage
|
|
||||||
*
|
|
||||||
* @var object
|
|
||||||
*/
|
|
||||||
public $data = null;
|
|
||||||
/**
|
|
||||||
* Config resource
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $config_resource = null;
|
|
||||||
/**
|
|
||||||
* Compiled config file
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $compiled_config = null;
|
|
||||||
/**
|
|
||||||
* filepath of compiled config file
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $compiled_filepath = null;
|
|
||||||
/**
|
|
||||||
* Filemtime of compiled config Filemtime
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $compiled_timestamp = null;
|
|
||||||
/**
|
|
||||||
* flag if compiled config file is invalid and must be (re)compiled
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $mustCompile = null;
|
|
||||||
/**
|
|
||||||
* Config file compiler object
|
|
||||||
*
|
|
||||||
* @var Smarty_Internal_Config_File_Compiler object
|
|
||||||
*/
|
|
||||||
public $compiler_object = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
public function __construct($config_resource, $smarty, $data = null)
|
|
||||||
{
|
|
||||||
$this->data = $data;
|
|
||||||
$this->smarty = $smarty;
|
|
||||||
$this->config_resource = $config_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the compiled filepath
|
|
||||||
*
|
|
||||||
* @return string the compiled filepath
|
|
||||||
*/
|
|
||||||
public function getCompiledFilepath()
|
|
||||||
{
|
|
||||||
return $this->compiled_filepath === null ?
|
|
||||||
($this->compiled_filepath = $this->buildCompiledFilepath()) :
|
|
||||||
$this->compiled_filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get file path.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
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(realpath($this->source->filepath) . $_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;
|
|
||||||
}
|
|
||||||
$_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
|
|
||||||
*
|
|
||||||
* @return integer the file timestamp
|
|
||||||
*/
|
|
||||||
public function getCompiledTimestamp()
|
|
||||||
{
|
|
||||||
return $this->compiled_timestamp === null
|
|
||||||
? ($this->compiled_timestamp = (file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false)
|
|
||||||
: $this->compiled_timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
public function getCompiledConfig()
|
|
||||||
{
|
|
||||||
if ($this->compiled_config === null) {
|
|
||||||
// see if template needs compiling.
|
|
||||||
if ($this->mustCompile()) {
|
|
||||||
$this->compileConfigSource();
|
|
||||||
} else {
|
|
||||||
$this->compiled_config = file_get_contents($this->getCompiledFilepath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->compiled_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compiles the config files
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function compileConfigSource()
|
|
||||||
{
|
|
||||||
// compile template
|
|
||||||
if (!is_object($this->compiler_object)) {
|
|
||||||
// load compiler
|
|
||||||
$this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty);
|
|
||||||
}
|
|
||||||
// compile locking
|
|
||||||
if ($this->smarty->compile_locking) {
|
|
||||||
if ($saved_timestamp = $this->getCompiledTimestamp()) {
|
|
||||||
touch($this->getCompiledFilepath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// call compiler
|
|
||||||
try {
|
|
||||||
$this->compiler_object->compileSource($this);
|
|
||||||
}
|
|
||||||
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
|
|
||||||
// write compiled template
|
|
||||||
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->getCompiledConfig(), $this->smarty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load config variables
|
|
||||||
*
|
|
||||||
* @param mixed $sections array of section names, single section or null
|
|
||||||
* @param string $scope global,parent or local
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function loadConfigVars($sections = null, $scope = 'local')
|
|
||||||
{
|
|
||||||
if ($this->data instanceof Smarty_Internal_Template) {
|
|
||||||
$this->data->properties['file_dependency'][sha1($this->source->filepath)] = array($this->source->filepath, $this->source->timestamp, '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_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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// scan sections
|
|
||||||
if (!empty($sections)) {
|
|
||||||
foreach ((array) $sections as $this_section) {
|
|
||||||
if (isset($_config_vars['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;
|
|
||||||
} else {
|
|
||||||
$scope_ptr->config_vars[$variable] = array_merge((array) $scope_ptr->config_vars[$variable], (array) $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set Smarty property in template context
|
|
||||||
*
|
|
||||||
* @param string $property_name property name
|
|
||||||
* @param mixed $value value
|
|
||||||
*
|
|
||||||
* @throws SmartyException if $property_name is not valid
|
|
||||||
*/
|
|
||||||
public function __set($property_name, $value)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'source':
|
|
||||||
case 'compiled':
|
|
||||||
$this->$property_name = $value;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new SmartyException("invalid config property '$property_name'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get Smarty property in template context
|
|
||||||
*
|
|
||||||
* @param string $property_name property name
|
|
||||||
*
|
|
||||||
* @return \Smarty_Config_Source|\Smarty_Template_Compiled
|
|
||||||
* @throws SmartyException if $property_name is not valid
|
|
||||||
*/
|
|
||||||
public function __get($property_name)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'source':
|
|
||||||
if (empty($this->config_resource)) {
|
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Extension Clear
|
||||||
|
*
|
||||||
|
* $smarty->clear() method file cache file resource
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Extension_Clear
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Empty cache for a specific template
|
||||||
|
*
|
||||||
|
* @param Smarty $smarty
|
||||||
|
* @param string $resource_name template name
|
||||||
|
* @param string $cache_id cache id
|
||||||
|
* @param string $compile_id compile id
|
||||||
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
|
*
|
||||||
|
* @return integer number of cache files deleted
|
||||||
|
*/
|
||||||
|
public static function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||||
|
{
|
||||||
|
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
||||||
|
$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
|
||||||
|
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
|
||||||
|
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
|
||||||
|
$_dir = $smarty->getCacheDir();
|
||||||
|
if ($_dir == '/') { //We should never want to delete this!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$_dir_length = strlen($_dir);
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
$_cache_id_parts = explode('|', $_cache_id);
|
||||||
|
$_cache_id_parts_count = count($_cache_id_parts);
|
||||||
|
if ($smarty->use_sub_dirs) {
|
||||||
|
foreach ($_cache_id_parts as $id_part) {
|
||||||
|
$_dir .= $id_part . DS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($resource_name)) {
|
||||||
|
$_save_stat = $smarty->caching;
|
||||||
|
$smarty->caching = true;
|
||||||
|
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||||
|
$smarty->caching = $_save_stat;
|
||||||
|
|
||||||
|
// remove from template cache
|
||||||
|
$tpl->source; // have the template registered before unset()
|
||||||
|
|
||||||
|
if ($tpl->source->exists) {
|
||||||
|
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_count = 0;
|
||||||
|
$_time = time();
|
||||||
|
if (file_exists($_dir)) {
|
||||||
|
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
||||||
|
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
|
foreach ($_cache as $_file) {
|
||||||
|
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// directory ?
|
||||||
|
if ($_file->isDir()) {
|
||||||
|
if (!$_cache->isDot()) {
|
||||||
|
// delete folder if empty
|
||||||
|
@rmdir($_file->getPathname());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
|
||||||
|
$_parts_count = count($_parts);
|
||||||
|
// check name
|
||||||
|
if (isset($resource_name)) {
|
||||||
|
if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check compile id
|
||||||
|
if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) ||
|
||||||
|
$_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// check cache id
|
||||||
|
if (isset($_cache_id)) {
|
||||||
|
// count of cache id parts
|
||||||
|
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset :
|
||||||
|
$_parts_count - 1 - $_compile_id_offset;
|
||||||
|
if ($_parts_count < $_cache_id_parts_count) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < $_cache_id_parts_count; $i ++) {
|
||||||
|
if ($_parts[$i] != $_cache_id_parts[$i]) {
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// expired ?
|
||||||
|
if (isset($exp_time)) {
|
||||||
|
if ($exp_time < 0) {
|
||||||
|
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
||||||
|
if ($_time < (@filemtime($_file) + $match[1])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($_time - @filemtime($_file) < $exp_time) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||||
|
if (function_exists('opcache_invalidate')) {
|
||||||
|
opcache_invalidate((string) $_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_count;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Extension handler
|
||||||
|
*
|
||||||
|
* Load extensions dynamically
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*
|
||||||
|
* @property Smarty_Internal_Runtime_Inheritance $_inheritance
|
||||||
|
* @property Smarty_Internal_Runtime_SubTemplate $_subTemplate
|
||||||
|
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
|
||||||
|
* @property Smarty_Internal_Runtime_Var $_var
|
||||||
|
* @property Smarty_Internal_Runtime_Config $_config
|
||||||
|
* @property Smarty_Internal_Runtime_Foreach $_foreach
|
||||||
|
* @property Smarty_Internal_Runtime_Hhvm $_hhvm
|
||||||
|
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
|
||||||
|
* @property Smarty_Internal_Runtime_ValidateCompiled $_validateCompiled
|
||||||
|
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
|
||||||
|
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler
|
||||||
|
* @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath
|
||||||
|
* @property Smarty_Internal_Runtime_UpdateScope $_updateScope
|
||||||
|
* @property Smarty_Internal_Runtime_IsCached $_isCached
|
||||||
|
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
|
||||||
|
* @property Smarty_Internal_Runtime_UpdateCache $_updateCache
|
||||||
|
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
|
||||||
|
* @property Smarty_Internal_Method_Append $append
|
||||||
|
* @property Smarty_Internal_Method_AppendByRef $appendByRef
|
||||||
|
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
|
||||||
|
* @property Smarty_Internal_Method_AssignByRef $assignByRef
|
||||||
|
* @property Smarty_Internal_Method_LoadFilter $loadFilter
|
||||||
|
* @property Smarty_Internal_Method_LoadPlugin $loadPlugin
|
||||||
|
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
|
||||||
|
* @property Smarty_Internal_Method_RegisterObject $registerObject
|
||||||
|
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Extension_Handler
|
||||||
|
{
|
||||||
|
|
||||||
|
public $objType = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache for property information from generic getter/setter
|
||||||
|
* Preloaded with names which should not use with generic getter/setter
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_property_info = array('AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
|
||||||
|
'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
|
||||||
|
'TemplateVars' => 0,);#
|
||||||
|
|
||||||
|
private $resolvedProperties = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call external Method
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data $data
|
||||||
|
* @param string $name external method names
|
||||||
|
* @param array $args argument array
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
|
||||||
|
{
|
||||||
|
/* @var Smarty $data ->smarty */
|
||||||
|
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||||
|
if (!isset($smarty->ext->$name)) {
|
||||||
|
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||||
|
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||||
|
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||||
|
// convert camel case to underscored name
|
||||||
|
$this->resolvedProperties[$prop] = $pn = strtolower(join('_',
|
||||||
|
preg_split('/([A-Z][^A-Z]*)/', $prop, - 1,
|
||||||
|
PREG_SPLIT_NO_EMPTY |
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE)));
|
||||||
|
$this->_property_info[$prop] = property_exists($data, $pn) ? 1 :
|
||||||
|
($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
|
||||||
|
}
|
||||||
|
if ($this->_property_info[$prop]) {
|
||||||
|
$pn = $this->resolvedProperties[$prop];
|
||||||
|
if ($match[1] == 'get') {
|
||||||
|
return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn;
|
||||||
|
} else {
|
||||||
|
return $this->_property_info[$prop] == 1 ? $data->$pn = $args[0] :
|
||||||
|
$data->smarty->$pn = $args[0];
|
||||||
|
}
|
||||||
|
} elseif (!class_exists($class)) {
|
||||||
|
throw new SmartyException("property '$pn' does not exist.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (class_exists($class)) {
|
||||||
|
$callback = array($smarty->ext->$name = new $class(), $name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$callback = array($smarty->ext->$name, $name);
|
||||||
|
}
|
||||||
|
array_unshift($args, $data);
|
||||||
|
if (isset($callback) && $callback[0]->objMap | $data->_objType) {
|
||||||
|
return call_user_func_array($callback, $args);
|
||||||
|
}
|
||||||
|
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set extension property
|
||||||
|
*
|
||||||
|
* @param string $property_name property name
|
||||||
|
* @param mixed $value value
|
||||||
|
*
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function __set($property_name, $value)
|
||||||
|
{
|
||||||
|
$this->$property_name = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get extension object
|
||||||
|
*
|
||||||
|
* @param string $property_name property name
|
||||||
|
*
|
||||||
|
* @return mixed|Smarty_Template_Cached
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function __get($property_name)
|
||||||
|
{
|
||||||
|
// object properties of runtime template extensions will start with '_'
|
||||||
|
if ($property_name[0] == '_') {
|
||||||
|
$class = 'Smarty_Internal_Runtime_' . ucfirst(substr($property_name, 1));
|
||||||
|
} else {
|
||||||
|
$class = 'Smarty_Internal_Method_' . ucfirst($property_name);
|
||||||
|
}
|
||||||
|
if (class_exists($class)) {
|
||||||
|
return $this->$property_name = new $class();
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call error handler for undefined method
|
||||||
|
*
|
||||||
|
* @param string $name unknown method-name
|
||||||
|
* @param array $args argument array
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function __call($name, $args)
|
||||||
|
{
|
||||||
|
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Function Call Handler
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsInternal
|
|
||||||
* @author Uwe Tews
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class does call function defined with the {function} tag
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsInternal
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Function_Call_Handler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This function handles calls to template functions defined by {function}
|
|
||||||
* It does create a PHP function at the first call
|
|
||||||
*
|
|
||||||
* @param string $_name template function name
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
* @param array $_params Smarty variables passed as call parameter
|
|
||||||
* @param string $_hash nocache hash value
|
|
||||||
* @param bool $_nocache nocache flag
|
|
||||||
*/
|
|
||||||
public static function call($_name, Smarty_Internal_Template $_template, $_params, $_hash, $_nocache)
|
|
||||||
{
|
|
||||||
if ($_nocache) {
|
|
||||||
$_function = "smarty_template_function_{$_name}_nocache";
|
|
||||||
} else {
|
|
||||||
$_function = "smarty_template_function_{$_hash}_{$_name}";
|
|
||||||
}
|
|
||||||
if (!is_callable($_function)) {
|
|
||||||
$_code = "function {$_function}(\$_smarty_tpl,\$params) {
|
|
||||||
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
|
|
||||||
foreach (\$_smarty_tpl->smarty->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};
|
|
||||||
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
|
|
||||||
if ($_nocache) {
|
|
||||||
$_code .= preg_replace(array("!<\?php echo \\'/\*%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/|/\*/%%SmartyNocache:{$_template->smarty->template_functions[$_name]['nocache_hash']}%%\*/\\';\?>!",
|
|
||||||
"!\\\'!"), array('', "'"), $_template->smarty->template_functions[$_name]['compiled']);
|
|
||||||
$_template->smarty->template_functions[$_name]['called_nocache'] = true;
|
|
||||||
} else {
|
|
||||||
$_code .= preg_replace("/{$_template->smarty->template_functions[$_name]['nocache_hash']}/", $_template->properties['nocache_hash'], $_template->smarty->template_functions[$_name]['compiled']);
|
|
||||||
}
|
|
||||||
$_code .= "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}";
|
|
||||||
eval($_code);
|
|
||||||
}
|
|
||||||
$_function($_template, $_params);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty read include path plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsInternal
|
|
||||||
* @author Monte Ohrt
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Read Include Path Class
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsInternal
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Get_Include_Path
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Return full file path from PHP include_path
|
|
||||||
*
|
|
||||||
* @param string $filepath filepath
|
|
||||||
*
|
|
||||||
* @return string|boolean full filepath or false
|
|
||||||
*/
|
|
||||||
public static function getIncludePath($filepath)
|
|
||||||
{
|
|
||||||
static $_include_path = null;
|
|
||||||
|
|
||||||
if (function_exists('stream_resolve_include_path')) {
|
|
||||||
// available since PHP 5.3.2
|
|
||||||
return stream_resolve_include_path($filepath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_include_path === null) {
|
|
||||||
$_include_path = explode(PATH_SEPARATOR, get_include_path());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($_include_path as $_path) {
|
|
||||||
if (file_exists($_path . DS . $filepath)) {
|
|
||||||
return $_path . DS . $filepath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method AddAutoloadFilters
|
||||||
|
*
|
||||||
|
* Smarty::addAutoloadFilters() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_SetAutoloadFilters
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add autoload filters
|
||||||
|
*
|
||||||
|
* @api Smarty::setAutoloadFilters()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param array $filters filters to load automatically
|
||||||
|
* @param string $type "pre", "output", … specify the
|
||||||
|
* filter type to set. Defaults to
|
||||||
|
* none treating $filters' keys as
|
||||||
|
* the appropriate types
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
*/
|
||||||
|
public function addAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if ($type !== null) {
|
||||||
|
$this->_checkFilterType($type);
|
||||||
|
if (!empty($smarty->autoload_filters[$type])) {
|
||||||
|
$smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $filters);
|
||||||
|
} else {
|
||||||
|
$smarty->autoload_filters[$type] = (array) $filters;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach ((array) $filters as $type => $value) {
|
||||||
|
$this->_checkFilterType($type);
|
||||||
|
if (!empty($smarty->autoload_filters[$type])) {
|
||||||
|
$smarty->autoload_filters[$type] = array_merge($smarty->autoload_filters[$type], (array) $value);
|
||||||
|
} else {
|
||||||
|
$smarty->autoload_filters[$type] = (array) $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method AddDefaultModifiers
|
||||||
|
*
|
||||||
|
* Smarty::addDefaultModifiers() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_AddDefaultModifiers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add default modifiers
|
||||||
|
*
|
||||||
|
* @api Smarty::addDefaultModifiers()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param array|string $modifiers modifier or list of modifiers
|
||||||
|
* to add
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
*/
|
||||||
|
public function addDefaultModifiers(Smarty_Internal_TemplateBase $obj, $modifiers)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (is_array($modifiers)) {
|
||||||
|
$this->default_modifiers = array_merge($smarty->default_modifiers, $modifiers);
|
||||||
|
} else {
|
||||||
|
$smarty->default_modifiers[] = $modifiers;
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method Append
|
||||||
|
*
|
||||||
|
* Smarty::append() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_Append
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* appends values to template variables
|
||||||
|
*
|
||||||
|
* @api Smarty::append()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.append.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
|
* @param mixed $value the value to append
|
||||||
|
* @param bool $merge flag if array elements shall be merged
|
||||||
|
* @param bool $nocache if true any output of this variable will
|
||||||
|
* be not cached
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function append(Smarty_Internal_Data $data, $tpl_var, $value = null, $merge = false, $nocache = false)
|
||||||
|
{
|
||||||
|
if (is_array($tpl_var)) {
|
||||||
|
// $tpl_var is an array, ignore $value
|
||||||
|
foreach ($tpl_var as $_key => $_val) {
|
||||||
|
if ($_key != '') {
|
||||||
|
$this->append($data, $_key, $_val, $merge, $nocache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($tpl_var != '' && isset($value)) {
|
||||||
|
if (!isset($data->tpl_vars[$tpl_var])) {
|
||||||
|
$tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false);
|
||||||
|
if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
|
||||||
|
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||||
|
} else {
|
||||||
|
$data->tpl_vars[$tpl_var] = clone $tpl_var_inst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(is_array($data->tpl_vars[$tpl_var]->value) ||
|
||||||
|
$data->tpl_vars[$tpl_var]->value instanceof ArrayAccess)
|
||||||
|
) {
|
||||||
|
settype($data->tpl_vars[$tpl_var]->value, 'array');
|
||||||
|
}
|
||||||
|
if ($merge && is_array($value)) {
|
||||||
|
foreach ($value as $_mkey => $_mval) {
|
||||||
|
$data->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data->tpl_vars[$tpl_var]->value[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($data->_objType == 2 && $data->scope) {
|
||||||
|
$data->ext->_updateScope->updateScope($data, $tpl_var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method AppendByRef
|
||||||
|
*
|
||||||
|
* Smarty::appendByRef() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_AppendByRef
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* appends values to template variables by reference
|
||||||
|
*
|
||||||
|
* @api Smarty::appendByRef()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.append.by.ref.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $tpl_var the template variable name
|
||||||
|
* @param mixed &$value the referenced value to append
|
||||||
|
* @param bool $merge flag if array elements shall be merged
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public static function appendByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $merge = false)
|
||||||
|
{
|
||||||
|
if ($tpl_var != '' && isset($value)) {
|
||||||
|
if (!isset($data->tpl_vars[$tpl_var])) {
|
||||||
|
$data->tpl_vars[$tpl_var] = new Smarty_Variable();
|
||||||
|
}
|
||||||
|
if (!is_array($data->tpl_vars[$tpl_var]->value)) {
|
||||||
|
settype($data->tpl_vars[$tpl_var]->value, 'array');
|
||||||
|
}
|
||||||
|
if ($merge && is_array($value)) {
|
||||||
|
foreach ($value as $_key => $_val) {
|
||||||
|
$data->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data->tpl_vars[$tpl_var]->value[] = &$value;
|
||||||
|
}
|
||||||
|
if ($data->_objType == 2 && $data->scope) {
|
||||||
|
$data->ext->_updateScope->updateScope($data, $tpl_var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method AssignByRef
|
||||||
|
*
|
||||||
|
* Smarty::assignByRef() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_AssignByRef
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assigns values to template variables by reference
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $tpl_var the template variable name
|
||||||
|
* @param $value
|
||||||
|
* @param boolean $nocache if true any output of this variable will be not cached
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache)
|
||||||
|
{
|
||||||
|
if ($tpl_var != '') {
|
||||||
|
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||||
|
$data->tpl_vars[$tpl_var]->value = &$value;
|
||||||
|
if ($data->_objType == 2 && $data->scope) {
|
||||||
|
$data->ext->_updateScope->updateScope($data, $tpl_var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method AssignGlobal
|
||||||
|
*
|
||||||
|
* Smarty::assignGlobal() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_AssignGlobal
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assigns a global Smarty variable
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $varName the global variable name
|
||||||
|
* @param mixed $value the value to assign
|
||||||
|
* @param boolean $nocache if true any output of this variable will be not cached
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
|
||||||
|
{
|
||||||
|
if ($varName != '') {
|
||||||
|
Smarty::$global_tpl_vars[$varName] = new Smarty_Variable($value, $nocache);
|
||||||
|
$ptr = $data;
|
||||||
|
while ($ptr->_objType == 2) {
|
||||||
|
$ptr->tpl_vars[$varName] = clone Smarty::$global_tpl_vars[$varName];
|
||||||
|
$ptr = $ptr->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearAllAssign
|
||||||
|
*
|
||||||
|
* Smarty::clearAllAssign() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearAllAssign
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clear all the assigned template variables.
|
||||||
|
*
|
||||||
|
* @api Smarty::clearAllAssign()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.all.assign.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function clearAllAssign(Smarty_Internal_Data $data)
|
||||||
|
{
|
||||||
|
$data->tpl_vars = array();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearAllCache
|
||||||
|
*
|
||||||
|
* Smarty::clearAllCache() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearAllCache
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty cache folder
|
||||||
|
*
|
||||||
|
* @api Smarty::clearAllCache()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param integer $exp_time expiration time
|
||||||
|
* @param string $type resource type
|
||||||
|
*
|
||||||
|
* @return integer number of cache files deleted
|
||||||
|
*/
|
||||||
|
public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null)
|
||||||
|
{
|
||||||
|
// load cache resource and call clearAll
|
||||||
|
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||||
|
$_cache_resource->invalidLoadedCache($smarty);
|
||||||
|
return $_cache_resource->clearAll($smarty, $exp_time);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearAssign
|
||||||
|
*
|
||||||
|
* Smarty::clearAssign() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearAssign
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clear the given assigned template variable(s).
|
||||||
|
*
|
||||||
|
* @api Smarty::clearAssign()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.assign.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string|array $tpl_var the template variable(s) to clear
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function clearAssign(Smarty_Internal_Data $data, $tpl_var)
|
||||||
|
{
|
||||||
|
if (is_array($tpl_var)) {
|
||||||
|
foreach ($tpl_var as $curr_var) {
|
||||||
|
unset($data->tpl_vars[$curr_var]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unset($data->tpl_vars[$tpl_var]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearCache
|
||||||
|
*
|
||||||
|
* Smarty::clearCache() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearCache
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty cache for a specific template
|
||||||
|
*
|
||||||
|
* @api Smarty::clearCache()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $template_name template name
|
||||||
|
* @param string $cache_id cache id
|
||||||
|
* @param string $compile_id compile id
|
||||||
|
* @param integer $exp_time expiration time
|
||||||
|
* @param string $type resource type
|
||||||
|
*
|
||||||
|
* @return integer number of cache files deleted
|
||||||
|
*/
|
||||||
|
public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
|
||||||
|
{
|
||||||
|
// load cache resource and call clear
|
||||||
|
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||||
|
$_cache_resource->invalidLoadedCache($smarty);
|
||||||
|
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearCompiledTemplate
|
||||||
|
*
|
||||||
|
* Smarty::clearCompiledTemplate() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearCompiledTemplate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete compiled template file
|
||||||
|
*
|
||||||
|
* @api Smarty::clearCompiledTemplate()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $resource_name template name
|
||||||
|
* @param string $compile_id compile id
|
||||||
|
* @param integer $exp_time expiration time
|
||||||
|
*
|
||||||
|
* @return integer number of template files deleted
|
||||||
|
*/
|
||||||
|
public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $compile_id = null, $exp_time = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$_compile_dir = $smarty->getCompileDir();
|
||||||
|
if ($_compile_dir == '/') { //We should never want to delete this!
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
|
||||||
|
$_dir_sep = $smarty->use_sub_dirs ? DS : '^';
|
||||||
|
if (isset($resource_name)) {
|
||||||
|
$_save_stat = $smarty->caching;
|
||||||
|
$smarty->caching = false;
|
||||||
|
/* @var Smarty_Internal_Template $tpl */
|
||||||
|
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||||
|
$smarty->caching = $_save_stat;
|
||||||
|
if ($tpl->source->exists) {
|
||||||
|
// remove from compileds cache
|
||||||
|
$tpl->source->compileds = array();
|
||||||
|
$_resource_part_1 = basename(str_replace('^', DS, $tpl->compiled->filepath));
|
||||||
|
$_resource_part_1_length = strlen($_resource_part_1);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
|
||||||
|
$_resource_part_2_length = strlen($_resource_part_2);
|
||||||
|
}
|
||||||
|
$_dir = $_compile_dir;
|
||||||
|
if ($smarty->use_sub_dirs && isset($_compile_id)) {
|
||||||
|
$_dir .= $_compile_id . $_dir_sep;
|
||||||
|
}
|
||||||
|
if (isset($_compile_id)) {
|
||||||
|
$_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep;
|
||||||
|
$_compile_id_part_length = strlen($_compile_id_part);
|
||||||
|
}
|
||||||
|
$_count = 0;
|
||||||
|
try {
|
||||||
|
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||||
|
// NOTE: UnexpectedValueException thrown for PHP >= 5.3
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
|
foreach ($_compile as $_file) {
|
||||||
|
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$_filepath = (string) $_file;
|
||||||
|
|
||||||
|
if ($_file->isDir()) {
|
||||||
|
if (!$_compile->isDot()) {
|
||||||
|
// delete folder if empty
|
||||||
|
@rmdir($_file->getPathname());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$unlink = false;
|
||||||
|
if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) &&
|
||||||
|
$a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
|
||||||
|
(!isset($resource_name) || (isset($_filepath[$_resource_part_1_length]) &&
|
||||||
|
substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length,
|
||||||
|
$_resource_part_1_length) == 0) ||
|
||||||
|
(isset($_filepath[$_resource_part_2_length]) &&
|
||||||
|
substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length,
|
||||||
|
$_resource_part_2_length) == 0))
|
||||||
|
) {
|
||||||
|
if (isset($exp_time)) {
|
||||||
|
if (time() - @filemtime($_filepath) >= $exp_time) {
|
||||||
|
$unlink = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$unlink = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($unlink && @unlink($_filepath)) {
|
||||||
|
$_count ++;
|
||||||
|
if (function_exists('opcache_invalidate')) {
|
||||||
|
opcache_invalidate($_filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// clear template objects cache
|
||||||
|
$smarty->_cache['isCached'] = array();
|
||||||
|
if (isset($smarty->ext->_subtemplate)) {
|
||||||
|
$smarty->ext->_subtemplate->tplObjects = array();
|
||||||
|
}
|
||||||
|
return $_count;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ClearConfig
|
||||||
|
*
|
||||||
|
* Smarty::clearConfig() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ClearConfig
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clear a single or all config variables
|
||||||
|
*
|
||||||
|
* @api Smarty::clearConfig()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.clear.config.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string|null $name variable name or null
|
||||||
|
*
|
||||||
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
|
*/
|
||||||
|
public function clearConfig(Smarty_Internal_Data $data, $name = null)
|
||||||
|
{
|
||||||
|
if (isset($name)) {
|
||||||
|
unset($data->config_vars[$name]);
|
||||||
|
} else {
|
||||||
|
$data->config_vars = array();
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method CompileAllConfig
|
||||||
|
*
|
||||||
|
* Smarty::compileAllConfig() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_CompileAllConfig extends Smarty_Internal_Method_CompileAllTemplates
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile all config files
|
||||||
|
*
|
||||||
|
* @api Smarty::compileAllConfig()
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $extension file extension
|
||||||
|
* @param bool $force_compile force all to recompile
|
||||||
|
* @param int $time_limit
|
||||||
|
* @param int $max_errors
|
||||||
|
*
|
||||||
|
* @return integer number of template files recompiled
|
||||||
|
*/
|
||||||
|
public function compileAllConfig(Smarty $smarty, $extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
|
{
|
||||||
|
return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method CompileAllTemplates
|
||||||
|
*
|
||||||
|
* Smarty::compileAllTemplates() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_CompileAllTemplates
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile all template files
|
||||||
|
*
|
||||||
|
* @api Smarty::compileAllTemplates()
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $extension file extension
|
||||||
|
* @param bool $force_compile force all to recompile
|
||||||
|
* @param int $time_limit
|
||||||
|
* @param int $max_errors
|
||||||
|
*
|
||||||
|
* @return integer number of template files recompiled
|
||||||
|
*/
|
||||||
|
public function compileAllTemplates(Smarty $smarty, $extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||||
|
{
|
||||||
|
return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile all template or config files
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $extension template file name extension
|
||||||
|
* @param bool $force_compile force all to recompile
|
||||||
|
* @param int $time_limit set maximum execution time
|
||||||
|
* @param int $max_errors set maximum allowed errors
|
||||||
|
* @param bool $isConfig flag true if called for config files
|
||||||
|
*
|
||||||
|
* @return int number of template files compiled
|
||||||
|
*/
|
||||||
|
protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors, $isConfig = false)
|
||||||
|
{
|
||||||
|
// switch off time limit
|
||||||
|
if (function_exists('set_time_limit')) {
|
||||||
|
@set_time_limit($time_limit);
|
||||||
|
}
|
||||||
|
$_count = 0;
|
||||||
|
$_error_count = 0;
|
||||||
|
$sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
|
||||||
|
// loop over array of source directories
|
||||||
|
foreach ($sourceDir as $_dir) {
|
||||||
|
$_dir_1 = new RecursiveDirectoryIterator($_dir);
|
||||||
|
$_dir_2 = new RecursiveIteratorIterator($_dir_1);
|
||||||
|
foreach ($_dir_2 as $_fileinfo) {
|
||||||
|
$_file = $_fileinfo->getFilename();
|
||||||
|
if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($_fileinfo->getPath() == !substr($_dir, 0, - 1)) {
|
||||||
|
$_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
|
||||||
|
}
|
||||||
|
echo "\n<br>", $_dir, '---', $_file;
|
||||||
|
flush();
|
||||||
|
$_start_time = microtime(true);
|
||||||
|
$_smarty = clone $smarty;
|
||||||
|
$_smarty->force_compile = $force_compile;
|
||||||
|
try {
|
||||||
|
/* @var Smarty_Internal_Template $_tpl */
|
||||||
|
$_tpl = new $smarty->template_class($_file, $_smarty);
|
||||||
|
$_tpl->caching = Smarty::CACHING_OFF;
|
||||||
|
$_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
|
||||||
|
if ($_tpl->mustCompile()) {
|
||||||
|
$_tpl->compileTemplateSource();
|
||||||
|
$_count ++;
|
||||||
|
echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
|
||||||
|
flush();
|
||||||
|
} else {
|
||||||
|
echo ' is up to date';
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
echo "\n<br> ------>Error: ", $e->getMessage(), "<br><br>\n";
|
||||||
|
$_error_count ++;
|
||||||
|
}
|
||||||
|
// free memory
|
||||||
|
unset($_tpl);
|
||||||
|
$_smarty->_cache['template_objects'] = array();
|
||||||
|
if ($max_errors !== null && $_error_count == $max_errors) {
|
||||||
|
echo "\n<br><br>too many errors\n";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "\n<br>";
|
||||||
|
return $_count;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method ConfigLoad
|
||||||
|
*
|
||||||
|
* Smarty::configLoad() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_ConfigLoad
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load a config file, optionally load just selected sections
|
||||||
|
*
|
||||||
|
* @api Smarty::configLoad()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $config_file filename
|
||||||
|
* @param mixed $sections array of section names, single
|
||||||
|
* section or null
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function configLoad(Smarty_Internal_Data $data, $config_file, $sections = null)
|
||||||
|
{
|
||||||
|
$this->_loadConfigFile($data, $config_file, $sections, 0);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load a config file, optionally load just selected sections
|
||||||
|
*
|
||||||
|
* @api Smarty::configLoad()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
||||||
|
* @param string $config_file filename
|
||||||
|
* @param mixed $sections array of section names, single
|
||||||
|
* section or null
|
||||||
|
* @param int $scope scope into which config variables
|
||||||
|
* shall be loaded
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0)
|
||||||
|
{
|
||||||
|
/* @var \Smarty $smarty */
|
||||||
|
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||||
|
/* @var \Smarty_Internal_Template $confObj */
|
||||||
|
$confObj = new Smarty_Internal_Template($config_file, $smarty, $data);
|
||||||
|
$confObj->caching = Smarty::CACHING_OFF;
|
||||||
|
$confObj->source = Smarty_Template_Config::load($confObj);
|
||||||
|
$confObj->source->config_sections = $sections;
|
||||||
|
$confObj->source->scope = $scope;
|
||||||
|
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
|
||||||
|
$confObj->compiled->render($confObj);
|
||||||
|
if ($data->_objType == 2) {
|
||||||
|
$data->compiled->file_dependency[$confObj->source->uid] =
|
||||||
|
array($confObj->source->filepath, $confObj->source->getTimeStamp(), $confObj->source->type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load config variables into template object
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Template $tpl
|
||||||
|
* @param array $_config_vars
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function _loadConfigVars(Smarty_Internal_Template $tpl, $_config_vars)
|
||||||
|
{
|
||||||
|
$this->_assignConfigVars($tpl->parent, $tpl, $_config_vars);
|
||||||
|
$scope = $tpl->source->scope;
|
||||||
|
if (!$scope && !$tpl->scope) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (array($scope, $tpl->scope) as $s) {
|
||||||
|
$s = ($bubble_up = $s >= Smarty::SCOPE_BUBBLE_UP) ? $s - Smarty::SCOPE_BUBBLE_UP : $s;
|
||||||
|
if ($bubble_up && $s) {
|
||||||
|
$ptr = $tpl->parent->parent;
|
||||||
|
if (isset($ptr)) {
|
||||||
|
$this->_assignConfigVars($ptr, $tpl, $_config_vars);
|
||||||
|
$ptr = $ptr->parent;
|
||||||
|
}
|
||||||
|
if ($s == Smarty::SCOPE_PARENT) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while (isset($ptr) && $ptr->_objType == 2) {
|
||||||
|
$this->_assignConfigVars($ptr, $tpl, $_config_vars);
|
||||||
|
$ptr = $ptr->parent;
|
||||||
|
}
|
||||||
|
if ($s == Smarty::SCOPE_TPL_ROOT) {
|
||||||
|
continue;
|
||||||
|
} elseif ($s == Smarty::SCOPE_SMARTY) {
|
||||||
|
$this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
|
||||||
|
} elseif ($s == Smarty::SCOPE_GLOBAL) {
|
||||||
|
$this->_assignConfigVars($tpl->smarty, $tpl, $_config_vars);
|
||||||
|
} elseif ($s == Smarty::SCOPE_ROOT) {
|
||||||
|
while (isset($ptr->parent)) {
|
||||||
|
$ptr = $ptr->parent;
|
||||||
|
}
|
||||||
|
$this->_assignConfigVars($ptr, $tpl, $_config_vars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign all config variables in given scope
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data $scope_ptr
|
||||||
|
* @param \Smarty_Internal_Template $tpl
|
||||||
|
* @param array $_config_vars
|
||||||
|
*/
|
||||||
|
public function _assignConfigVars(Smarty_Internal_Data $scope_ptr, Smarty_Internal_Template $tpl, $_config_vars)
|
||||||
|
{
|
||||||
|
// copy global config vars
|
||||||
|
foreach ($_config_vars['vars'] as $variable => $value) {
|
||||||
|
if ($tpl->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// scan sections
|
||||||
|
$sections = $tpl->source->config_sections;
|
||||||
|
if (!empty($sections)) {
|
||||||
|
foreach ((array) $sections as $tpl_section) {
|
||||||
|
if (isset($_config_vars['sections'][$tpl_section])) {
|
||||||
|
foreach ($_config_vars['sections'][$tpl_section]['vars'] as $variable => $value) {
|
||||||
|
if ($tpl->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a config variable value
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Template $tpl template object
|
||||||
|
* @param string $varName the name of the config variable
|
||||||
|
* @param bool $errorEnable
|
||||||
|
*
|
||||||
|
* @return mixed the value of the config variable
|
||||||
|
*/
|
||||||
|
public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $errorEnable = true)
|
||||||
|
{
|
||||||
|
$_ptr = $tpl;
|
||||||
|
while ($_ptr !== null) {
|
||||||
|
if (isset($_ptr->config_vars[$varName])) {
|
||||||
|
// found it, return it
|
||||||
|
return $_ptr->config_vars[$varName];
|
||||||
|
}
|
||||||
|
// not found, try at parent
|
||||||
|
$_ptr = $_ptr->parent;
|
||||||
|
}
|
||||||
|
if ($tpl->smarty->error_unassigned && $errorEnable) {
|
||||||
|
// force a notice
|
||||||
|
$x = $$varName;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method CreateData
|
||||||
|
*
|
||||||
|
* Smarty::createData() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_CreateData
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a data object
|
||||||
|
*
|
||||||
|
* @api Smarty::createData()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.create.data.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
|
||||||
|
* variables
|
||||||
|
* @param string $name optional data block name
|
||||||
|
*
|
||||||
|
* @returns Smarty_Data data object
|
||||||
|
*/
|
||||||
|
public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
|
||||||
|
{
|
||||||
|
/* @var Smarty $smarty */
|
||||||
|
$smarty = isset($this->smarty) ? $this->smarty : $obj;
|
||||||
|
$dataObj = new Smarty_Data($parent, $smarty, $name);
|
||||||
|
if ($smarty->debugging) {
|
||||||
|
Smarty_Internal_Debug::register_data($dataObj);
|
||||||
|
}
|
||||||
|
return $dataObj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetAutoloadFilters
|
||||||
|
*
|
||||||
|
* Smarty::getAutoloadFilters() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetAutoloadFilters extends Smarty_Internal_Method_SetAutoloadFilters
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get autoload filters
|
||||||
|
*
|
||||||
|
* @api Smarty::getAutoloadFilters()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $type type of filter to get auto loads
|
||||||
|
* for. Defaults to all autoload
|
||||||
|
* filters
|
||||||
|
*
|
||||||
|
* @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type
|
||||||
|
* was specified
|
||||||
|
*/
|
||||||
|
public function getAutoloadFilters(Smarty_Internal_TemplateBase $obj, $type = null)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if ($type !== null) {
|
||||||
|
$this->_checkFilterType($type);
|
||||||
|
return isset($smarty->autoload_filters[$type]) ? $smarty->autoload_filters[$type] : array();
|
||||||
|
}
|
||||||
|
return $smarty->autoload_filters;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetConfigVars
|
||||||
|
*
|
||||||
|
* Smarty::getConfigVars() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetConfigVars
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single or all config variables
|
||||||
|
*
|
||||||
|
* @api Smarty::getConfigVars()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $varname variable name or null
|
||||||
|
* @param bool $search_parents include parent templates?
|
||||||
|
*
|
||||||
|
* @return mixed variable value or or array of variables
|
||||||
|
*/
|
||||||
|
public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true)
|
||||||
|
{
|
||||||
|
$_ptr = $data;
|
||||||
|
$var_array = array();
|
||||||
|
while ($_ptr !== null) {
|
||||||
|
if (isset($varname)) {
|
||||||
|
if (isset($_ptr->config_vars[$varname])) {
|
||||||
|
return $_ptr->config_vars[$varname];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$var_array = array_merge($_ptr->config_vars, $var_array);
|
||||||
|
}
|
||||||
|
// not found, try at parent
|
||||||
|
if ($search_parents) {
|
||||||
|
$_ptr = $_ptr->parent;
|
||||||
|
} else {
|
||||||
|
$_ptr = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($varname)) {
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $var_array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetDebugTemplate
|
||||||
|
*
|
||||||
|
* Smarty::getDebugTemplate() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetDebugTemplate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return name of debugging template
|
||||||
|
*
|
||||||
|
* @api Smarty::getDebugTemplate()
|
||||||
|
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDebugTemplate(Smarty_Internal_TemplateBase $obj)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
return $smarty->debug_tpl;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetDefaultModifiers
|
||||||
|
*
|
||||||
|
* Smarty::getDefaultModifiers() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetDefaultModifiers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default modifiers
|
||||||
|
*
|
||||||
|
* @api Smarty::getDefaultModifiers()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
*
|
||||||
|
* @return array list of default modifiers
|
||||||
|
*/
|
||||||
|
public function getDefaultModifiers(Smarty_Internal_TemplateBase $obj)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
return $smarty->default_modifiers;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetRegisteredObject
|
||||||
|
*
|
||||||
|
* Smarty::getRegisteredObject() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetRegisteredObject
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return a reference to a registered object
|
||||||
|
*
|
||||||
|
* @api Smarty::getRegisteredObject()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $object_name object name
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
* @throws \SmartyException if no such object is found
|
||||||
|
*/
|
||||||
|
public function getRegisteredObject(Smarty_Internal_TemplateBase $obj, $object_name)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (!isset($smarty->registered_objects[$object_name])) {
|
||||||
|
throw new SmartyException("'$object_name' is not a registered object");
|
||||||
|
}
|
||||||
|
if (!is_object($smarty->registered_objects[$object_name][0])) {
|
||||||
|
throw new SmartyException("registered '$object_name' is not an object");
|
||||||
|
}
|
||||||
|
return $smarty->registered_objects[$object_name][0];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetStreamVariable
|
||||||
|
*
|
||||||
|
* Smarty::getStreamVariable() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetStreamVariable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a stream variable
|
||||||
|
*
|
||||||
|
* @api Smarty::getStreamVariable()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $variable the stream of the variable
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function getStreamVariable(Smarty_Internal_Data $data, $variable)
|
||||||
|
{
|
||||||
|
$_result = '';
|
||||||
|
$fp = fopen($variable, 'r+');
|
||||||
|
if ($fp) {
|
||||||
|
while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
|
||||||
|
$_result .= $current_line;
|
||||||
|
}
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
return $_result;
|
||||||
|
}
|
||||||
|
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||||
|
if ($smarty->error_unassigned) {
|
||||||
|
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetTags
|
||||||
|
*
|
||||||
|
* Smarty::getTags() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetTags
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return array of tag/attributes of all tags used by an template
|
||||||
|
*
|
||||||
|
* @api Smarty::getTags()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param null|string|Smarty_Internal_Template $template
|
||||||
|
*
|
||||||
|
* @return array of tag/attributes
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
|
||||||
|
{
|
||||||
|
/* @var Smarty $smarty */
|
||||||
|
$smarty = isset($this->smarty) ? $this->smarty : $obj;
|
||||||
|
if ($obj->_objType == 2 && !isset($template)) {
|
||||||
|
$tpl = clone $obj;
|
||||||
|
} elseif (isset($template) && $template->_objType == 2) {
|
||||||
|
$tpl = clone $template;
|
||||||
|
} elseif (isset($template) && is_string($template)) {
|
||||||
|
/* @var Smarty_Internal_Template $tpl */
|
||||||
|
$tpl = new $smarty->template_class($template, $smarty);
|
||||||
|
// checks if template exists
|
||||||
|
if (!$tpl->source->exists) {
|
||||||
|
throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($tpl)) {
|
||||||
|
$tpl->smarty = clone $tpl->smarty;
|
||||||
|
$tpl->smarty->_cache['get_used_tags'] = true;
|
||||||
|
$tpl->_cache['used_tags'] = array();
|
||||||
|
$tpl->smarty->merge_compiled_includes = false;
|
||||||
|
$tpl->smarty->disableSecurity();
|
||||||
|
$tpl->caching = false;
|
||||||
|
$tpl->loadCompiler();
|
||||||
|
$tpl->compiler->compileTemplate($tpl);
|
||||||
|
return $tpl->_cache['used_tags'];
|
||||||
|
}
|
||||||
|
throw new SmartyException("Missing template specification");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method GetTemplateVars
|
||||||
|
*
|
||||||
|
* Smarty::getTemplateVars() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_GetTemplateVars
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for all objects
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single or all template variables
|
||||||
|
*
|
||||||
|
* @api Smarty::getTemplateVars()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $varName variable name or null
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||||
|
* @param bool $searchParents include parent templates?
|
||||||
|
*
|
||||||
|
* @return mixed variable value or or array of variables
|
||||||
|
*/
|
||||||
|
public function getTemplateVars(Smarty_Internal_Data $data, $varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true)
|
||||||
|
{
|
||||||
|
if (isset($varName)) {
|
||||||
|
$_var = $this->_getVariable($data, $varName, $_ptr, $searchParents, false);
|
||||||
|
if (is_object($_var)) {
|
||||||
|
return $_var->value;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_result = array();
|
||||||
|
if ($_ptr === null) {
|
||||||
|
$_ptr = $data;
|
||||||
|
}
|
||||||
|
while ($_ptr !== null) {
|
||||||
|
foreach ($_ptr->tpl_vars AS $key => $var) {
|
||||||
|
if (!array_key_exists($key, $_result)) {
|
||||||
|
$_result[$key] = $var->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// not found, try at parent
|
||||||
|
if ($searchParents) {
|
||||||
|
$_ptr = $_ptr->parent;
|
||||||
|
} else {
|
||||||
|
$_ptr = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($searchParents && isset(Smarty::$global_tpl_vars)) {
|
||||||
|
foreach (Smarty::$global_tpl_vars AS $key => $var) {
|
||||||
|
if (!array_key_exists($key, $_result)) {
|
||||||
|
$_result[$key] = $var->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the object of a Smarty variable
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
|
* @param string $varName the name of the Smarty variable
|
||||||
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||||
|
* @param bool $searchParents search also in parent data
|
||||||
|
* @param bool $errorEnable
|
||||||
|
*
|
||||||
|
* @return \Smarty_Variable
|
||||||
|
*/
|
||||||
|
public function _getVariable(Smarty_Internal_Data $data, $varName, Smarty_Internal_Data $_ptr = null, $searchParents = true, $errorEnable = true)
|
||||||
|
{
|
||||||
|
if ($_ptr === null) {
|
||||||
|
$_ptr = $data;
|
||||||
|
}
|
||||||
|
while ($_ptr !== null) {
|
||||||
|
if (isset($_ptr->tpl_vars[$varName])) {
|
||||||
|
// found it, return it
|
||||||
|
return $_ptr->tpl_vars[$varName];
|
||||||
|
}
|
||||||
|
// not found, try at parent
|
||||||
|
if ($searchParents) {
|
||||||
|
$_ptr = $_ptr->parent;
|
||||||
|
} else {
|
||||||
|
$_ptr = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset(Smarty::$global_tpl_vars[$varName])) {
|
||||||
|
// found it, return it
|
||||||
|
return Smarty::$global_tpl_vars[$varName];
|
||||||
|
}
|
||||||
|
/* @var \Smarty $smarty */
|
||||||
|
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||||
|
if ($smarty->error_unassigned && $errorEnable) {
|
||||||
|
// force a notice
|
||||||
|
$x = $$varName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Smarty_Undefined_Variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method LoadFilter
|
||||||
|
*
|
||||||
|
* Smarty::loadFilter() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_LoadFilter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid filter types
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $filterTypes = array('pre' => true, 'post' => true, 'output' => true, 'variable' => true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load a filter of specified type and name
|
||||||
|
*
|
||||||
|
* @api Smarty::loadFilter()
|
||||||
|
*
|
||||||
|
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $type filter type
|
||||||
|
* @param string $name filter name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @throws SmartyException if filter could not be loaded
|
||||||
|
*/
|
||||||
|
public function loadFilter(Smarty_Internal_TemplateBase $obj, $type, $name)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
$this->_checkFilterType($type);
|
||||||
|
$_plugin = "smarty_{$type}filter_{$name}";
|
||||||
|
$_filter_name = $_plugin;
|
||||||
|
if (is_callable($_plugin)) {
|
||||||
|
$smarty->registered_filters[$type][$_filter_name] = $_plugin;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($smarty->loadPlugin($_plugin)) {
|
||||||
|
if (class_exists($_plugin, false)) {
|
||||||
|
$_plugin = array($_plugin, 'execute');
|
||||||
|
}
|
||||||
|
if (is_callable($_plugin)) {
|
||||||
|
$smarty->registered_filters[$type][$_filter_name] = $_plugin;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new SmartyException("{$type}filter \"{$name}\" not found or callable");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if filter type is valid
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function _checkFilterType($type)
|
||||||
|
{
|
||||||
|
if (!isset($this->filterTypes[$type])) {
|
||||||
|
throw new SmartyException("Illegal filter type \"{$type}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Extension Loadplugin
|
||||||
|
*
|
||||||
|
* $smarty->loadPlugin() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_LoadPlugin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cache of searched plugin files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $plugin_files = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes unknown classes and loads plugin files for them
|
||||||
|
* class name format: Smarty_PluginType_PluginName
|
||||||
|
* plugin filename format: plugintype.pluginname.php
|
||||||
|
*
|
||||||
|
* @param \Smarty $smarty
|
||||||
|
* @param string $plugin_name class plugin name to load
|
||||||
|
* @param bool $check check if already loaded
|
||||||
|
*
|
||||||
|
* @return bool|string
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function loadPlugin(Smarty $smarty, $plugin_name, $check)
|
||||||
|
{
|
||||||
|
// if function or class exists, exit silently (already loaded)
|
||||||
|
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) {
|
||||||
|
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||||
|
}
|
||||||
|
if (!empty($match[2])) {
|
||||||
|
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
|
||||||
|
if (isset($this->plugin_files[$file])) {
|
||||||
|
if ($this->plugin_files[$file] !== false) {
|
||||||
|
return $this->plugin_files[$file];
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (is_file($file)) {
|
||||||
|
$this->plugin_files[$file] = $file;
|
||||||
|
require_once($file);
|
||||||
|
return $file;
|
||||||
|
} else {
|
||||||
|
$this->plugin_files[$file] = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// plugin filename is expected to be: [type].[name].php
|
||||||
|
$_plugin_filename = "{$match[1]}.{$match[4]}.php";
|
||||||
|
$_lower_filename = strtolower($_plugin_filename);
|
||||||
|
if (isset($this->plugin_files)) {
|
||||||
|
if (isset($this->plugin_files['plugins_dir'][$_lower_filename])) {
|
||||||
|
if (!$smarty->use_include_path || $this->plugin_files['plugins_dir'][$_lower_filename] !== false) {
|
||||||
|
return $this->plugin_files['plugins_dir'][$_lower_filename];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$smarty->use_include_path || $smarty->ext->_getIncludePath->isNewIncludePath($smarty)) {
|
||||||
|
unset($this->plugin_files['include_path']);
|
||||||
|
} else {
|
||||||
|
if (isset($this->plugin_files['include_path'][$_lower_filename])) {
|
||||||
|
return $this->plugin_files['include_path'][$_lower_filename];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_file_names = array($_plugin_filename);
|
||||||
|
if ($_lower_filename != $_plugin_filename) {
|
||||||
|
$_file_names[] = $_lower_filename;
|
||||||
|
}
|
||||||
|
$_p_dirs = $smarty->getPluginsDir();
|
||||||
|
if (!isset($this->plugin_files['plugins_dir'][$_lower_filename])) {
|
||||||
|
// loop through plugin dirs and find the plugin
|
||||||
|
foreach ($_p_dirs as $_plugin_dir) {
|
||||||
|
foreach ($_file_names as $name) {
|
||||||
|
$file = $_plugin_dir . $name;
|
||||||
|
if (is_file($file)) {
|
||||||
|
$this->plugin_files['plugins_dir'][$_lower_filename] = $file;
|
||||||
|
require_once($file);
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
$this->plugin_files['plugins_dir'][$_lower_filename] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($smarty->use_include_path) {
|
||||||
|
foreach ($_file_names as $_file_name) {
|
||||||
|
// try PHP include_path
|
||||||
|
$file = $smarty->ext->_getIncludePath->getIncludePath($_p_dirs, $_file_name, $smarty);
|
||||||
|
$this->plugin_files['include_path'][$_lower_filename] = $file;
|
||||||
|
if ($file !== false) {
|
||||||
|
require_once($file);
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no plugin loaded
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method UnloadFilter
|
||||||
|
*
|
||||||
|
* Smarty_Internal_Template::mustCompile() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_MustCompile
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the current template must be compiled by the Smarty compiler
|
||||||
|
* It does compare the timestamps of template source and the compiled templates and checks the force compile
|
||||||
|
* configuration
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Template $_template
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function mustCompile(Smarty_Internal_Template $_template)
|
||||||
|
{
|
||||||
|
if (!$_template->source->exists) {
|
||||||
|
if (isset($_template->parent) && $_template->parent->_objType == 2) {
|
||||||
|
$parent_resource = " in '$_template->parent->template_resource}'";
|
||||||
|
} else {
|
||||||
|
$parent_resource = '';
|
||||||
|
}
|
||||||
|
throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
|
||||||
|
}
|
||||||
|
if ($_template->mustCompile === null) {
|
||||||
|
$_template->mustCompile = (!$_template->source->handler->uncompiled &&
|
||||||
|
($_template->smarty->force_compile || $_template->source->handler->recompiled || !$_template->compiled->exists ||
|
||||||
|
($_template->smarty->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_template->mustCompile;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterCacheResource
|
||||||
|
*
|
||||||
|
* Smarty::registerCacheResource() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterCacheResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a resource to fetch a template
|
||||||
|
*
|
||||||
|
* @api Smarty::registerCacheResource()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $name name of resource type
|
||||||
|
* @param \Smarty_CacheResource $resource_handler
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
*/
|
||||||
|
public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name, Smarty_CacheResource $resource_handler)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
$smarty->registered_cache_resources[$name] = $resource_handler;
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterClass
|
||||||
|
*
|
||||||
|
* Smarty::registerClass() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterClass
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers static classes to be used in templates
|
||||||
|
*
|
||||||
|
* @api Smarty::registerClass()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.class.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $class_name
|
||||||
|
* @param string $class_impl the referenced PHP class to
|
||||||
|
* register
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function registerClass(Smarty_Internal_TemplateBase $obj, $class_name, $class_impl)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
// test if exists
|
||||||
|
if (!class_exists($class_impl)) {
|
||||||
|
throw new SmartyException("Undefined class '$class_impl' in register template class");
|
||||||
|
}
|
||||||
|
// register the class
|
||||||
|
$smarty->registered_classes[$class_name] = $class_impl;
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterDefaultConfigHandler
|
||||||
|
*
|
||||||
|
* Smarty::registerDefaultConfigHandler() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterDefaultConfigHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config default handler
|
||||||
|
*
|
||||||
|
* @api Smarty::registerDefaultConfigHandler()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param callable $callback class/method name
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws SmartyException if $callback is not callable
|
||||||
|
*/
|
||||||
|
public function registerDefaultConfigHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (is_callable($callback)) {
|
||||||
|
$smarty->default_config_handler_func = $callback;
|
||||||
|
} else {
|
||||||
|
throw new SmartyException("Default config handler not callable");
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterDefaultPluginHandler
|
||||||
|
*
|
||||||
|
* Smarty::registerDefaultPluginHandler() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterDefaultPluginHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a default plugin handler
|
||||||
|
*
|
||||||
|
* @api Smarty::registerDefaultPluginHandler()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param callable $callback class/method name
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws SmartyException if $callback is not callable
|
||||||
|
*/
|
||||||
|
public function registerDefaultPluginHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (is_callable($callback)) {
|
||||||
|
$smarty->default_plugin_handler_func = $callback;
|
||||||
|
} else {
|
||||||
|
throw new SmartyException("Default plugin handler '$callback' not callable");
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterDefaultTemplateHandler
|
||||||
|
*
|
||||||
|
* Smarty::registerDefaultTemplateHandler() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterDefaultTemplateHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register template default handler
|
||||||
|
*
|
||||||
|
* @api Smarty::registerDefaultTemplateHandler()
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param callable $callback class/method name
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws SmartyException if $callback is not callable
|
||||||
|
*/
|
||||||
|
public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (is_callable($callback)) {
|
||||||
|
$smarty->default_template_handler_func = $callback;
|
||||||
|
} else {
|
||||||
|
throw new SmartyException("Default template handler not callable");
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get default content from template or config resource handler
|
||||||
|
*
|
||||||
|
* @param Smarty_Template_Source $source
|
||||||
|
*/
|
||||||
|
public static function _getDefaultTemplate(Smarty_Template_Source $source)
|
||||||
|
{
|
||||||
|
if ($source->isConfig) {
|
||||||
|
$default_handler = $source->smarty->default_config_handler_func;
|
||||||
|
} else {
|
||||||
|
$default_handler = $source->smarty->default_template_handler_func;
|
||||||
|
}
|
||||||
|
$_content = $_timestamp = null;
|
||||||
|
$_return = call_user_func_array($default_handler, array($source->type, $source->name, &$_content, &$_timestamp,
|
||||||
|
$source->smarty));
|
||||||
|
if (is_string($_return)) {
|
||||||
|
$source->exists = is_file($_return);
|
||||||
|
if ($source->exists) {
|
||||||
|
$source->timestamp = filemtime($_return);
|
||||||
|
}
|
||||||
|
$source->filepath = $_return;
|
||||||
|
} elseif ($_return === true) {
|
||||||
|
$source->content = $_content;
|
||||||
|
$source->timestamp = $_timestamp;
|
||||||
|
$source->exists = true;
|
||||||
|
$source->handler->recompiled = true;
|
||||||
|
$source->filepath = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterFilter
|
||||||
|
*
|
||||||
|
* Smarty::registerFilter() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterFilter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid filter types
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $filterTypes = array('pre' => true, 'post' => true, 'output' => true, 'variable' => true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a filter function
|
||||||
|
*
|
||||||
|
* @api Smarty::registerFilter()
|
||||||
|
*
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $type filter type
|
||||||
|
* @param callback $callback
|
||||||
|
* @param string|null $name optional filter name
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function registerFilter(Smarty_Internal_TemplateBase $obj, $type, $callback, $name = null)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
$this->_checkFilterType($type);
|
||||||
|
$name = isset($name) ? $name : $this->_getFilterName($callback);
|
||||||
|
if (!is_callable($callback)) {
|
||||||
|
throw new SmartyException("{$type}filter \"{$name}\" not callable");
|
||||||
|
}
|
||||||
|
$smarty->registered_filters[$type][$name] = $callback;
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return internal filter name
|
||||||
|
*
|
||||||
|
* @param callback $function_name
|
||||||
|
*
|
||||||
|
* @return string internal filter name
|
||||||
|
*/
|
||||||
|
public function _getFilterName($function_name)
|
||||||
|
{
|
||||||
|
if (is_array($function_name)) {
|
||||||
|
$_class_name = (is_object($function_name[0]) ? get_class($function_name[0]) : $function_name[0]);
|
||||||
|
|
||||||
|
return $_class_name . '_' . $function_name[1];
|
||||||
|
} elseif (is_string($function_name)) {
|
||||||
|
return $function_name;
|
||||||
|
} else {
|
||||||
|
return 'closure';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if filter type is valid
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function _checkFilterType($type)
|
||||||
|
{
|
||||||
|
if (!isset($this->filterTypes[$type])) {
|
||||||
|
throw new SmartyException("Illegal filter type \"{$type}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterObject
|
||||||
|
*
|
||||||
|
* Smarty::registerObject() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterObject
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers object to be used in templates
|
||||||
|
*
|
||||||
|
* @api Smarty::registerObject()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $object_name
|
||||||
|
* @param object $object the
|
||||||
|
* referenced
|
||||||
|
* PHP object to
|
||||||
|
* register
|
||||||
|
* @param array $allowed_methods_properties list of
|
||||||
|
* allowed
|
||||||
|
* methods
|
||||||
|
* (empty = all)
|
||||||
|
* @param bool $format smarty
|
||||||
|
* argument
|
||||||
|
* format, else
|
||||||
|
* traditional
|
||||||
|
* @param array $block_methods list of
|
||||||
|
* block-methods
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function registerObject(Smarty_Internal_TemplateBase $obj, $object_name, $object, $allowed_methods_properties = array(), $format = true, $block_methods = array())
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
// test if allowed methods callable
|
||||||
|
if (!empty($allowed_methods_properties)) {
|
||||||
|
foreach ((array) $allowed_methods_properties as $method) {
|
||||||
|
if (!is_callable(array($object, $method)) && !property_exists($object, $method)) {
|
||||||
|
throw new SmartyException("Undefined method or property '$method' in registered object");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// test if block methods callable
|
||||||
|
if (!empty($block_methods)) {
|
||||||
|
foreach ((array) $block_methods as $method) {
|
||||||
|
if (!is_callable(array($object, $method))) {
|
||||||
|
throw new SmartyException("Undefined method '$method' in registered object");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// register the object
|
||||||
|
$smarty->registered_objects[$object_name] = array($object, (array) $allowed_methods_properties,
|
||||||
|
(boolean) $format, (array) $block_methods);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Method RegisterPlugin
|
||||||
|
*
|
||||||
|
* Smarty::registerPlugin() method
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Method_RegisterPlugin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Valid for Smarty and template object
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $objMap = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers plugin to be used in templates
|
||||||
|
*
|
||||||
|
* @api Smarty::registerPlugin()
|
||||||
|
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
|
* @param string $type plugin type
|
||||||
|
* @param string $name name of template tag
|
||||||
|
* @param callback $callback PHP callback to register
|
||||||
|
* @param bool $cacheable if true (default) this
|
||||||
|
* function is cache able
|
||||||
|
* @param mixed $cache_attr caching attributes if any
|
||||||
|
*
|
||||||
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
|
* @throws SmartyException when the plugin tag is invalid
|
||||||
|
*/
|
||||||
|
public function registerPlugin(Smarty_Internal_TemplateBase $obj, $type, $name, $callback, $cacheable = true, $cache_attr = null)
|
||||||
|
{
|
||||||
|
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||||
|
if (isset($smarty->registered_plugins[$type][$name])) {
|
||||||
|
throw new SmartyException("Plugin tag \"{$name}\" already registered");
|
||||||
|
} elseif (!is_callable($callback)) {
|
||||||
|
throw new SmartyException("Plugin \"{$name}\" not callable");
|
||||||
|
} else {
|
||||||
|
$smarty->registered_plugins[$type][$name] = array($callback, (bool) $cacheable, (array) $cache_attr);
|
||||||
|
}
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue