From: Matthias Schmidt Date: Wed, 10 Aug 2011 16:42:06 +0000 (+0200) Subject: Updated documentation of template classes X-Git-Tag: 2.0.0_Beta_1~1885^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1b73b8b4bfe6bdc93a405f6b6cb0a51991018c25;p=GitHub%2FWoltLab%2FWCF.git Updated documentation of template classes SetupTemplate has been replaced by SetupTemplateEngine and isn't needed anymore. --- diff --git a/wcfsetup/install/files/lib/system/template/SetupTemplate.class.php b/wcfsetup/install/files/lib/system/template/SetupTemplate.class.php deleted file mode 100644 index 5dab590449..0000000000 --- a/wcfsetup/install/files/lib/system/template/SetupTemplate.class.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @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); - } -} diff --git a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php index bf5ed4c674..3f55efde4e 100644 --- a/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateEngine.class.php @@ -20,92 +20,79 @@ use wcf\util\DirectoryUtil; */ 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 */ 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 */ 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 */ 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 */ protected $templateListeners = array(); /** - * Current environment - * + * current environment * @var string */ protected $environment = 'user'; @@ -169,8 +156,8 @@ class TemplateEngine extends SingletonFactory { /** * 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)) { @@ -465,7 +452,7 @@ class TemplateEngine extends SingletonFactory { /** * Returns a new template compiler object. * - * @return TemplateCompiler + * @return wcf\system\template\TemplateCompiler */ protected function getCompiler() { return new TemplateCompiler($this); @@ -605,7 +592,7 @@ class TemplateEngine extends SingletonFactory { /** * Returns an array with all prefilters. * - * @return array + * @return array */ public function getPrefilters() { return $this->prefilters; @@ -644,7 +631,7 @@ class TemplateEngine extends SingletonFactory { /** * Registers prefilters. * - * @param array $prefilters + * @param array $prefilters */ public function registerPrefilter(array $prefilters) { foreach ($prefilters as $name) { diff --git a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php index fa6b4949b8..402ac610f5 100644 --- a/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php +++ b/wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php @@ -16,46 +16,160 @@ use wcf\util\StringUtil; */ 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 + */ + protected $unknownPHPFunctions = array('isset', 'unset', 'empty'); + + /** + * PHP functions that can not be used in the modifier syntax + * @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 + ); + + /** + * 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 + */ + 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 + */ + 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; @@ -1173,57 +1287,25 @@ class TemplateScriptingCompiler { * Generates the regexp pattern. */ protected function buildPattern() { - // operator pattern $this->variableOperatorPattern = '\-\>|\.|\(|\)|\[|\]|\||\:|\+|\-|\*|\/|\%|\^|\,'; $this->conditionOperatorPattern = '===|!==|==|!=|<=|<|>=|(?|\|\||&&|!|='; - - // negative lookbehind for a backslash $this->escapedPattern = '(?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; @@ -1232,7 +1314,7 @@ class TemplateScriptingCompiler { /** * Returns the left delimiter for template tags. * - * @return string + * @return string */ public function getLeftDelimiter() { return $this->leftDelimiter; @@ -1250,7 +1332,7 @@ class TemplateScriptingCompiler { /** * Returns the name of the current template. * - * @return string + * @return string */ public function getCurrentIdentifier() { return $this->currentIdentifier; @@ -1259,7 +1341,7 @@ class TemplateScriptingCompiler { /** * Returns the current line number. * - * @return integer + * @return integer */ public function getCurrentLineNo() { return $this->currentLineNo;