+++ /dev/null
-<?php
-namespace wcf\system\template;
-
-/**
- * SetupTemplate loads and displays template in the setup process.
- *
- * @author Marcel Werk
- * @copyright 2001-2009 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package com.woltlab.wcf
- * @subpackage system.template
- * @category Community Framework
- */
-class SetupTemplate extends Template {
- protected $templatePath = '';
-
- /**
- * @see wcf\system\template\Template::setTemplatePaths()
- */
- public function setTemplatePaths($templatePaths) {
- if (is_array($templatePaths)) $this->templatePath = array_shift($templatePaths);
- else $this->templatePath = $templatePaths;
- }
-
- /**
- * @see wcf\system\template\Template::loadTemplateStructure()
- */
- protected function loadTemplateStructure() {}
-
- /**
- * @see wcf\system\template\Template::getSourceFilename()
- */
- public function getSourceFilename($templateName, $packageID = 0) {
- return $this->templatePath.TMP_FILE_PREFIX.$templateName.'.tpl';
- }
-
- /**
- * @see wcf\system\template\Template::getCompiledFilename()
- */
- public function getCompiledFilename($templateName, $packageID = 0) {
- return $this->compileDir.TMP_FILE_PREFIX.$this->languageID.'_'.$templateName.'.php';
- }
-
- /**
- * @see wcf\system\template\Template::getPluginFilename()
- */
- public function getPluginFilename($type, $tag) {
- return $this->pluginDir.TMP_FILE_PREFIX.'TemplatePlugin'.StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)).StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($tag)).'.class.php';
- }
-
- /**
- * @see wcf\system\template\Template::getCompiler()
- */
- protected function getCompiler() {
- return new TemplateCompiler($this);
- }
-}
*/
class TemplateEngine extends SingletonFactory {
/**
- * Directory used to cache previously compiled templates
- *
+ * directory used to cache previously compiled templates
* @var string
*/
public $compileDir = '';
/**
- * Active language id used to identify specific language versions of compiled templates
- *
+ * active language id used to identify specific language versions of compiled templates
* @var integer
*/
public $languageID = 0;
/**
- * Directories used as template source
- *
- * @var array
+ * directories used as template source
+ * @var array<string>
*/
public $templatePaths = array();
/**
- * Namespace containing template modifiers and plugins
- *
+ * namespace containing template modifiers and plugins
* @var string
*/
public $pluginNamespace = '';
/**
- * Active template compiler.
- *
- * @var TemplateCompiler
+ * active template compiler
+ * @var wcf\system\template\TemplateCompiler
*/
protected $compilerObj = null;
/**
* forces the template engine to recompile all included templates
- *
* @var boolean
*/
protected $forceCompile = false;
/**
* list of registered prefilters
- *
- * @var array
+ * @var array<string>
*/
protected $prefilters = array();
/**
- * Cached list of known template groups.
- *
+ * cached list of known template groups
* @var array
*/
protected $templateGroupCache = array();
/**
- * Active template group id.
- *
+ * active template group id
* @var integer
*/
protected $templateGroupID = 0;
/**
- * Contains all available template variables and those assigned during runtime.
- *
+ * all available template variables and those assigned during runtime
* @var array<array>
*/
protected $v = array();
/**
- * Contains all cached vars for usage after execution in sandbox.
- *
+ * all cached variables for usage after execution in sandbox
* @var array
*/
protected $sandboxVars = null;
/**
- * Contains all templates with assigned template listeners.
- *
+ * contains all templates with assigned template listeners.
* @var array<array>
*/
protected $templateListeners = array();
/**
- * Current environment
- *
+ * current environment
* @var string
*/
protected $environment = 'user';
/**
* Assigns a template variable.
*
- * @param mixed $variable
- * @param mixed $value
+ * @param mixed $variable
+ * @param mixed $value
*/
public function assign($variable, $value = '') {
if (is_array($variable)) {
/**
* Returns a new template compiler object.
*
- * @return TemplateCompiler
+ * @return wcf\system\template\TemplateCompiler
*/
protected function getCompiler() {
return new TemplateCompiler($this);
/**
* Returns an array with all prefilters.
*
- * @return array
+ * @return array<string>
*/
public function getPrefilters() {
return $this->prefilters;
/**
* Registers prefilters.
*
- * @param array $prefilters
+ * @param array<string> $prefilters
*/
public function registerPrefilter(array $prefilters) {
foreach ($prefilters as $name) {
*/
class TemplateScriptingCompiler {
/**
- * template object
- *
- * @var TemplateEngine
+ * template engine object
+ * @var wcf\system\templateTemplateEngine
*/
- protected $template;
+ protected $template;
/**
- * PHP functions that can be used in the modifier syntax and are unknown to the function_exists PHP method.
- *
+ * PHP functions that can be used in the modifier syntax and are unknown
+ * to the function_exists PHP method
+ * @var array<string>
+ */
+ protected $unknownPHPFunctions = array('isset', 'unset', 'empty');
+
+ /**
+ * PHP functions that can not be used in the modifier syntax
+ * @var array<string>
+ */
+ protected $disabledPHPFunctions = array(
+ 'system', 'exec', 'passthru', 'shell_exec', // command line execution
+ 'include', 'require', 'include_once', 'require_once', // includes
+ 'eval', 'virtual', 'call_user_func_array', 'call_user_func', 'assert' // code execution
+ );
+
+ /**
+ * pattern to match variable operators like -> or .
+ * @var string
+ */
+ protected $variableOperatorPattern;
+
+ /**
+ * pattern to match condition operators like == or <
+ * @var string
+ */
+ protected $conditionOperatorPattern;
+
+ /**
+ * negative lookbehind for a backslash
+ * @var string
+ */
+ protected $escapedPattern;
+
+ /**
+ * pattern to match valid variable names
+ * @var string
+ */
+ protected $validVarnamePattern;
+
+ /**
+ * pattern to match constants like CONSTANT or __CONSTANT
+ * @var string
+ */
+ protected $constantPattern;
+
+ /**
+ * pattern to match double quoted strings like "blah" or "quote: \"blah\""
+ * @var string
+ */
+ protected $doubleQuotePattern;
+
+ /**
+ * pattern to match single quoted strings like 'blah' or 'don\'t'
+ * @var string
+ */
+ protected $singleQuotePattern;
+
+ /**
+ * pattern to match single or double quoted strings
+ * @var string
+ */
+ protected $quotePattern;
+
+ /**
+ * pattern to match numbers, true, false and null
+ * @var string
+ */
+ protected $numericPattern;
+
+ /**
+ * pattern to match simple variables like $foo
+ * @var string
+ */
+ protected $simpleVarPattern;
+
+ /**
+ * pattern to match outputs like @$foo or #CONST
+ * @var string
+ */
+ protected $outputPattern;
+
+ /**
+ * identifier of currently compiled template
+ * @var string
+ */
+ protected $currentIdentifier;
+
+ /**
+ * current line number during template compilation
+ * @var string
+ */
+ protected $currentLineNo;
+
+ protected $modifiers = array();
+
+ /**
+ * list of automatically loaded tenplate plugins
+ * @var array<string>
+ */
+ protected $autoloadPlugins = array();
+
+ /**
+ * stack with template tags data
* @var array
*/
- protected $unknownPHPFunctions = array('isset', 'unset', 'empty');
+ protected $tagStack = array();
/**
- * PHP functions that can not be used in the modifier syntax.
- *
+ * list of loaded compiler plugin objects
+ * @var array<wcf\system\template\ITemplatePluginCompiler>
+ */
+ protected $compilerPlugins = array();
+
+ /**
+ * stack used to compile the capture tag
* @var array
*/
- protected $disabledPHPFunctions = array(
- 'system', 'exec', 'passthru', 'shell_exec', // command line execution
- 'include', 'require', 'include_once', 'require_once', // includes
- 'eval', 'virtual', 'call_user_func_array', 'call_user_func', 'assert' // code execution
- );
+ protected $captureStack = array();
- protected $variableOperatorPattern, $conditionOperatorPattern, $escapedPattern, $validVarnamePattern,
- $constantPattern, $doubleQuotePattern, $singleQuotePattern, $quotePattern, $numericPattern,
- $simpleVarPattern, $outputPattern;
+ /**
+ * left delimiter of template syntax
+ * @var string
+ */
+ protected $leftDelimiter = '{';
- protected $currentIdentifier, $currentLineNo;
+ /**
+ * right delimiter of template syntax
+ * @var string
+ */
+ protected $rightDelimiter = '}';
- protected $modifiers = array(), $autoloadPlugins = array(), $tagStack = array(),
- $compilerPlugins = array(), $captureStack = array();
+ /**
+ * left delimiter of template syntax used in regular expressions
+ * @var string
+ */
+ protected $ldq;
- protected $leftDelimiter = '{', $rightDelimiter = '}';
- protected $ldq, $rdq;
+ /**
+ * right delimiter of template syntax used in regular expressions
+ * @var string
+ */
+ protected $rdq;
/**
- * Creates a new TemplateScriptingCompiler.
+ * Creates a new TemplateScriptingCompiler object.
*
- * @param TemplateEngine $template
+ * @param wcf\system\templateTemplateEngine $template
*/
public function __construct(TemplateEngine $template) {
$this->template = $template;
* Generates the regexp pattern.
*/
protected function buildPattern() {
- // operator pattern
$this->variableOperatorPattern = '\-\>|\.|\(|\)|\[|\]|\||\:|\+|\-|\*|\/|\%|\^|\,';
$this->conditionOperatorPattern = '===|!==|==|!=|<=|<|>=|(?<!-)>|\|\||&&|!|=';
-
- // negative lookbehind for a backslash
$this->escapedPattern = '(?<!\\\\)';
-
- // valid variable name pattern
$this->validVarnamePattern = '(?:[a-zA-Z_][a-zA-Z_0-9]*)';
-
- // matches constants
- // CONSTANT
- // __CONSTANT2
$this->constantPattern = '(?:[A-Z_][A-Z_0-9]*)';
-
- // matches double quoted strings
- // "blah"
- // "quote: \"blah\""
//$this->doubleQuotePattern = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
$this->doubleQuotePattern = '"(?:[^"\\\\]+|\\\\.)*"';
-
- // matches single quoted strings
- // 'blah'
- // 'don\'t'
//$this->singleQuotePattern = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
$this->singleQuotePattern = '\'(?:[^\'\\\\]+|\\\\.)*\'';
-
- // matches single or double quoted strings
$this->quotePattern = '(?:' . $this->doubleQuotePattern . '|' . $this->singleQuotePattern . ')';
-
- // matches numericals and boolean constants
- // 234
- // -12
- // 23.92
- // true
- // false
$this->numericPattern = '(?i)(?:(?:\-?\d+(?:\.\d+)?)|true|false|null)';
-
- // matches simple variables
- // $foo
$this->simpleVarPattern = '(?:\$('.$this->validVarnamePattern.'))';
-
- // matches variable outputs
- // @$oo
$this->outputPattern = '(?:(?:@|#)?(?:'.$this->constantPattern.'|'.$this->quotePattern.'|'.$this->numericPattern.'|'.$this->simpleVarPattern.'|\())';
}
/**
* Returns the instance of the template engine class.
*
- * @return TemplateEngine
+ * @return wcf\system\templateTemplateEngine
*/
public function getTemplate() {
return $this->template;
/**
* Returns the left delimiter for template tags.
*
- * @return string
+ * @return string
*/
public function getLeftDelimiter() {
return $this->leftDelimiter;
/**
* Returns the name of the current template.
*
- * @return string
+ * @return string
*/
public function getCurrentIdentifier() {
return $this->currentIdentifier;
/**
* Returns the current line number.
*
- * @return integer
+ * @return integer
*/
public function getCurrentLineNo() {
return $this->currentLineNo;