Changed names of the template plugin classes
authorMatthias Schmidt <gravatronics@live.com>
Fri, 12 Aug 2011 19:51:11 +0000 (21:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 12 Aug 2011 19:51:11 +0000 (21:51 +0200)
During my tests, I found out that some template plugins don't work
anymore. I added a todo each time so you can fix that and replaced the
return value with an empty string so that at least no exception is
thrown anymore. I myself fixed a bug in the staticlang compiler (caused:
"Class 'WCF' not found in …").

59 files changed:
wcfsetup/install/files/lib/system/template/IBlockTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/ICompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/IFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/IModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/IPrefilterTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/ITemplatePluginBlock.class.php [deleted file]
wcfsetup/install/files/lib/system/template/ITemplatePluginCompiler.class.php [deleted file]
wcfsetup/install/files/lib/system/template/ITemplatePluginFunction.class.php [deleted file]
wcfsetup/install/files/lib/system/template/ITemplatePluginModifier.class.php [deleted file]
wcfsetup/install/files/lib/system/template/ITemplatePluginPrefilter.class.php [deleted file]
wcfsetup/install/files/lib/system/template/TemplateEngine.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/files/lib/system/template/plugin/AppendCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/ArrayfromlistModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/AssignCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/ConcatModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/EventPrefilterTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/FetchCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/FilesizeBinaryModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/FilesizeModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/IconCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/IconPrefilterTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/ImplodeCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/LangCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/LangPrefilterTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/PrependCompilerTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/SmallpagesFunctionTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/StaticlangTemplatePluginCompiler.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginBlockLink.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAppend.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAssign.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerFetch.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerIcon.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerImplode.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerLang.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerPrepend.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerStaticlang.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCounter.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCycle.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmlcheckboxes.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmloptions.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionPages.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionSmallpages.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierArrayfromlist.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierConcat.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierDate.class.php [deleted file]
wcfsetup/install/files/lib/system/template/plugin/TimeModifierTemplatePlugin.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/template/plugin/TruncateModifierTemplatePlugin.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/template/IBlockTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/IBlockTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..2abe514
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+namespace wcf\system\template;
+
+/**
+ * Block functions encloses a template block and operate on the contents of this block.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 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
+ */
+interface IBlockTemplatePlugin {
+       /**
+        * Executes this template block.
+        * 
+        * @param       array                   $tagArgs
+        * @param       string                  $blockContent
+        * @param       wcf\system\template\TemplateEngine      $tplObj
+        * @return      string                  output
+        */
+       public function execute($tagArgs, $blockContent, TemplateEngine $tplObj);
+       
+       /**
+        * Initialises this template block.
+        * 
+        * @param       array                   $tagArgs
+        * @param       wcf\system\template\TemplateEngine      $tplObj
+        */
+       public function init($tagArgs, TemplateEngine $tplObj);
+       
+       /**
+        * This function is called before every execution of this block function.
+        * 
+        * @param       wcf\system\template\TemplateEngine      $tplObj
+        * @return      boolean
+        */
+       public function next(TemplateEngine $tplObj);
+}
diff --git a/wcfsetup/install/files/lib/system/template/ICompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/ICompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..0b37d89
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace wcf\system\template;
+
+/**
+ * Compiler functions are called during the compilation of a template.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 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
+ */
+interface ICompilerTemplatePlugin {
+       /**
+        * Executes the start tag of this compiler function.
+        * 
+        * @param       array           $tagArgs                
+        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
+        * @return      string          php code        
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler);
+       
+       /**
+        * Executes the end tag of this compiler function.
+        * 
+        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
+        * @return      string          php code        
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler);
+}
diff --git a/wcfsetup/install/files/lib/system/template/IFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/IFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..862c793
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+namespace wcf\system\template;
+
+/**
+ * Template functions are identical to template blocks, but they have no closing tag.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 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
+ */
+interface IFunctionTemplatePlugin {
+       /**
+        * Executes this template function.
+        * 
+        * @param       array           $tagArgs
+        * @param       wcf\system\template\TemplateEngine      $tplObj
+        * @return      string          output
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj);
+}
diff --git a/wcfsetup/install/files/lib/system/template/IModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/IModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..2c240f2
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+namespace wcf\system\template;
+
+/**
+ * Modifiers are functions that are applied to a variable in the template 
+ * before it is displayed or used in some other context.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 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
+ */
+interface IModifierTemplatePlugin {
+       /**
+        * Executes this modifier.
+        * 
+        * @param       array           $tagArgs                
+        * @param       wcf\system\template\TemplateEngine      $tplObj
+        * @return      string          output          
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj);
+}
diff --git a/wcfsetup/install/files/lib/system/template/IPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/IPrefilterTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..455a03b
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+namespace wcf\system\template;
+
+/**
+ * Prefilters are used to process the source of the template immediately before compilation.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 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
+ */
+interface IPrefilterTemplatePlugin {
+       /**
+        * Executes this prefilter.
+        * 
+        * @param       string          $templateName
+        * @param       string          $sourceContent  
+        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
+        * @return      string
+        */
+       public function execute($templateName, $sourceContent, TemplateScriptingCompiler $compiler);
+}
diff --git a/wcfsetup/install/files/lib/system/template/ITemplatePluginBlock.class.php b/wcfsetup/install/files/lib/system/template/ITemplatePluginBlock.class.php
deleted file mode 100644 (file)
index 9c6487e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-namespace wcf\system\template;
-
-/**
- * Block functions encloses a template block and operate on the contents of this block.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 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
- */
-interface ITemplatePluginBlock {
-       /**
-        * Executes this template block.
-        * 
-        * @param       array                   $tagArgs
-        * @param       string                  $blockContent
-        * @param       wcf\system\template\TemplateEngine      $tplObj
-        * @return      string                  output
-        */
-       public function execute($tagArgs, $blockContent, TemplateEngine $tplObj);
-       
-       /**
-        * Initialises this template block.
-        * 
-        * @param       array                   $tagArgs
-        * @param       wcf\system\template\TemplateEngine      $tplObj
-        */
-       public function init($tagArgs, TemplateEngine $tplObj);
-       
-       /**
-        * This function is called before every execution of this block function.
-        * 
-        * @param       wcf\system\template\TemplateEngine      $tplObj
-        * @return      boolean
-        */
-       public function next(TemplateEngine $tplObj);
-}
diff --git a/wcfsetup/install/files/lib/system/template/ITemplatePluginCompiler.class.php b/wcfsetup/install/files/lib/system/template/ITemplatePluginCompiler.class.php
deleted file mode 100644 (file)
index ab579e9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-namespace wcf\system\template;
-
-/**
- * Compiler functions are called during the compilation of a template.
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 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
- */
-interface ITemplatePluginCompiler {
-       /**
-        * Executes the start tag of this compiler function.
-        * 
-        * @param       array           $tagArgs                
-        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
-        * @return      string          php code        
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler);
-       
-       /**
-        * Executes the end tag of this compiler function.
-        * 
-        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
-        * @return      string          php code        
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler);
-}
diff --git a/wcfsetup/install/files/lib/system/template/ITemplatePluginFunction.class.php b/wcfsetup/install/files/lib/system/template/ITemplatePluginFunction.class.php
deleted file mode 100644 (file)
index ac0b7d2..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-namespace wcf\system\template;
-
-/**
- * Template functions are identical to template blocks, but they have no closing tag.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 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
- */
-interface ITemplatePluginFunction {
-       /**
-        * Executes this template function.
-        * 
-        * @param       array           $tagArgs
-        * @param       wcf\system\template\TemplateEngine      $tplObj
-        * @return      string          output
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj);
-}
diff --git a/wcfsetup/install/files/lib/system/template/ITemplatePluginModifier.class.php b/wcfsetup/install/files/lib/system/template/ITemplatePluginModifier.class.php
deleted file mode 100644 (file)
index 478ebfd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-namespace wcf\system\template;
-
-/**
- * Modifiers are functions that are applied to a variable in the template 
- * before it is displayed or used in some other context.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 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
- */
-interface ITemplatePluginModifier {
-       /**
-        * Executes this modifier.
-        * 
-        * @param       array           $tagArgs                
-        * @param       wcf\system\template\TemplateEngine      $tplObj
-        * @return      string          output          
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj);
-}
diff --git a/wcfsetup/install/files/lib/system/template/ITemplatePluginPrefilter.class.php b/wcfsetup/install/files/lib/system/template/ITemplatePluginPrefilter.class.php
deleted file mode 100644 (file)
index 4701713..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-namespace wcf\system\template;
-
-/**
- * Prefilters are used to process the source of the template immediately before compilation.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 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
- */
-interface ITemplatePluginPrefilter {
-       /**
-        * Executes this prefilter.
-        * 
-        * @param       string          $templateName
-        * @param       string          $sourceContent  
-        * @param       wcf\system\template\TemplateScriptingCompiler   $compiler
-        * @return      string
-        */
-       public function execute($templateName, $sourceContent, TemplateScriptingCompiler $compiler);
-}
index 3f55efde4eaab7d9fd74af9cfb3be28de5a4976a..0a1335c42d1ee2ba61f5f6cd5fbd5ecf1753b0ae 100644 (file)
@@ -482,7 +482,7 @@ class TemplateEngine extends SingletonFactory {
         * @return      string                          class name
         */
        public function getPluginClassName($type, $tag) {
-               return $this->pluginNamespace.'TemplatePlugin'.StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)).StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($tag));
+               return $this->pluginNamespace.StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($tag)).StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)).'TemplatePlugin';
        }
        
        /**
index 402ac610f555350ab0939d4f1b1abe16a1d0f984..6604c11f2bc8e662ed6ad8a15167e9aef8069a13 100644 (file)
@@ -132,7 +132,7 @@ class TemplateScriptingCompiler {
        
        /**
         * list of loaded compiler plugin objects
-        * @var array<wcf\system\template\ITemplatePluginCompiler>
+        * @var array<wcf\system\template\ICompilerTemplatePlugin>
         */
        protected $compilerPlugins = array();
        
@@ -494,8 +494,8 @@ class TemplateScriptingCompiler {
                        
                        $this->compilerPlugins[$className] = new $className();
                        
-                       if (!($this->compilerPlugins[$className] instanceof ITemplatePluginCompiler)) {
-                               throw new SystemException($this->formatSyntaxError("Compiler plugin '".$tagCommand."' does not implement the interface 'ITemplatePluginCompiler'", $this->currentIdentifier));
+                       if (!($this->compilerPlugins[$className] instanceof ICompilerTemplatePlugin)) {
+                               throw new SystemException($this->formatSyntaxError("Compiler plugin '".$tagCommand."' does not implement the interface 'ICompilerTemplatePlugin'", $this->currentIdentifier));
                        }
                }
                
@@ -1364,11 +1364,11 @@ class TemplateScriptingCompiler {
                                $prefilter = new $className();
                        }
                        
-                       if ($prefilter instanceof ITemplatePluginPrefilter) {
+                       if ($prefilter instanceof IPrefilterTemplatePlugin) {
                                $string = $prefilter->execute($templateName, $string, $this);
                        }
                        else {
-                               throw new SystemException($this->formatSyntaxError("Prefilter '".$prefilter."' does not implement the interface 'ITemplatePluginPrefilter'", $this->currentIdentifier));
+                               throw new SystemException($this->formatSyntaxError("Prefilter '".$prefilter."' does not implement the interface 'IPrefilterTemplatePlugin'", $this->currentIdentifier));
                        }
                }
                
diff --git a/wcfsetup/install/files/lib/system/template/plugin/AppendCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/AppendCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..c443f25
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\system\exception\SystemException;
+
+/**
+ * The 'append' compiler function calls the append function on the template object.
+ * 
+ * Usage:
+ * {append var=name value="foo"}
+ *
+ * @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.plugin
+ * @category   Community Framework
+ */
+class AppendCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               if (!isset($tagArgs['var'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in append tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               if (!isset($tagArgs['value'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in append tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+                               
+               return "<?php \$this->append(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               throw new SystemException($compiler->formatSyntaxError("unknown tag {/append}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/ArrayfromlistModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ArrayfromlistModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..209f07f
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\data\option\Option;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+
+/**
+ * The 'arrayfromlist' modifier generates an associative array out of a key-value list.
+ * The list has key-value pairs separated by : with each pair on an own line:
+ * 
+ * Example list:
+ * key1:value1
+ * key2:value2
+ * ...
+ * 
+ * Usage:
+ * {$list|arrayfromlist}
+ *
+ * @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.plugin
+ * @category   Community Framework
+ */
+class ArrayfromlistModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // TODO: doesn't work
+               // return Option::parseSelectOptions($tagArgs[0]);
+               return '';
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/AssignCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/AssignCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..965da43
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\system\exception\SystemException;
+
+/**
+ * The 'assign' compiler function calls the assign function on the template object.
+ * 
+ * Usage:
+ * {assign var=name value="foo"}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class AssignCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               if (!isset($tagArgs['var'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in assign tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               if (!isset($tagArgs['value'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in assign tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+                               
+               return "<?php \$this->assign(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               throw new SystemException($compiler->formatSyntaxError("unknown tag {/assign}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/ConcatModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ConcatModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..31f3dde
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+
+/**
+ * The 'concat' modifier returns the string that results from concatenating the arguments.
+ * May have two or more arguments.
+ * 
+ * Usage:
+ * {"left"|concat:$right}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class ConcatModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\ITemplatePluginModifier::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               if (count($tagArgs) < 2) {
+                       throw new SystemException("concat modifier needs two or more arguments");
+               }
+               
+               $result = '';
+               foreach ($tagArgs as $arg) {
+                       $result .= $arg;
+               }
+       
+               return $result; 
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..0dd3c09
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\IFunctionTemplatePlugin;
+use wcf\system\template\TemplateEngine;
+
+/**
+ * The 'counter' template function is used to print out a count.
+ * 
+ * Usage:
+ * {counter assign=i}
+ * {counter start=10 skip=2}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class CounterFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       protected $counters = array();
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               if (!isset($tagArgs['name'])) {
+                       $tagArgs['name'] = 'default';
+               }
+
+               if (!isset($this->counters[$tagArgs['name']])) {
+                       $this->counters[$tagArgs['name']] = array(
+                               'start' => 1,
+                               'skip' => 1,
+                               'direction' => 'up',
+                               'count' => 1
+                       );
+               }
+
+               $counter =& $this->counters[$tagArgs['name']];
+
+               if (isset($tagArgs['start'])) {
+                       $counter['start'] = $counter['count'] = intval($tagArgs['start']);
+               }
+
+               if (isset($tagArgs['assign']) && !empty($tagArgs['assign'])) {
+                       $counter['assign'] = $tagArgs['assign'];
+               }
+
+               if (isset($counter['assign'])) {
+                       $tplObj->assign($counter['assign'], $counter['count']);
+               }
+
+               $result = null;
+               if (!isset($tagArgs['print']) || $tagArgs['print']) {
+                       $result = $counter['count'];
+               } 
+               
+               if (isset($tagArgs['skip'])) {
+                       $counter['skip'] = intval($tagArgs['skip']);
+               }
+
+               // get direction
+               if (isset($tagArgs['direction'])) {
+                       $counter['direction'] = $tagArgs['direction'];
+               }
+
+               if ($counter['direction'] == 'down') {
+                       $counter['count'] -= $counter['skip'];
+               }
+               else {
+                       $counter['count'] += $counter['skip'];
+               }
+
+               return $result;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/CycleFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..c427079
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\IFunctionTemplatePlugin;
+use wcf\system\template\TemplateEngine;
+
+/**
+ * The 'cycle' template function cycles through given values.
+ * 
+ * Usage:
+ * {cycle values="#eee,#fff"}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class CycleFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       protected $cycles = array();
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // get params
+               $name = isset($tagArgs['name']) ? $tagArgs['name'] : 'default';
+               $print = isset($tagArgs['print']) ? $tagArgs['print'] : 1;
+               $advance = isset($tagArgs['advance']) ? $tagArgs['advance'] : 1;
+               $reset = isset($tagArgs['reset']) ? $tagArgs['reset'] : 0;
+               
+               // get values
+               if (!isset($tagArgs['values']) ) {
+                       if (!isset($this->cycles[$name]['values'])) {
+                               throw new SystemException("missing 'values' argument in cycle tag");
+                       }
+               }
+               else {
+                       if (isset($this->cycles[$name]['values']) && $this->cycles[$name]['values'] != $tagArgs['values'] ) {
+                               $this->cycles[$name]['index'] = 0;
+                       }
+                       $this->cycles[$name]['values'] = $tagArgs['values'];
+               }
+               
+               // get delimiter
+               if (!isset($this->cycles[$name]['delimiter'])) {
+                       // set default delimiter
+                       $this->cycles[$name]['delimiter'] = ',';
+               }
+               if (isset($tagArgs['delimiter'])) {
+                       $this->cycles[$name]['delimiter'] = $tagArgs['delimiter'];
+               }
+               
+               // split values
+               if (is_array($this->cycles[$name]['values'])) {
+                       $cycleArray = $this->cycles[$name]['values'];
+               }
+               else {
+                       $cycleArray = explode($this->cycles[$name]['delimiter'], $this->cycles[$name]['values']);
+               }
+               
+               // set index
+               if (!isset($this->cycles[$name]['index']) || $reset) {
+                       $this->cycles[$name]['index'] = 0;
+               }
+               
+               // get result
+               $result = $cycleArray[$this->cycles[$name]['index']];
+               
+               // assign result to template var
+               if (isset($tagArgs['assign'])) {
+                       $print = false;
+                       $tplObj->assign($tagArgs['assign'], $result);
+               }
+               
+               // update index
+               if ($advance) {
+                       if ($this->cycles[$name]['index'] >= count($cycleArray) - 1) {
+                               $this->cycles[$name]['index'] = 0;
+                       }
+                       else {
+                               $this->cycles[$name]['index']++;
+                       }
+               }
+               
+               // print var
+               if ($print) {
+                       return $result;
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..ba81a4a
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\DateUtil;
+
+/**
+ * The 'date' modifier formats a unix timestamp.
+ * Default date format contains year, month and day.
+ * 
+ * Usage:
+ * {$timestamp|date}
+ * {"132845333"|date:"Y-m-d"}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class DateModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               return DateUtil::format(DateUtil::getDateTimeByTimestamp($tagArgs[0]), (!empty($tagArgs[2]) ? $tagArgs[2] : DateUtil::DATE_FORMAT));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/DatediffModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..2025c7f
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\DateUtil;
+
+/**
+ * The 'datediff' modifier calculates the difference between two unix timestamps.
+ * 
+ * Usage:
+ * {$timestamp|datediff}
+ * {"123456789"|datediff:$timestamp}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class DatediffModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // get timestamps
+               if (!isset($tagArgs[1])) $tagArgs[1] = TIME_NOW;
+               $start = min($tagArgs[0], $tagArgs[1]);
+               $end = max($tagArgs[0], $tagArgs[1]);
+               
+               // TODO: method doesn't exists anymore
+               // return DateUtil::diff($start, $end, 'string');
+               return '';
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/EncodejsModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..0935ec6
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\StringUtil;
+
+/**
+ * The 'encodejs' modifier formats a string for usage in a single quoted javascript string. 
+ * Escapes single quotes and new lines.
+ * 
+ * Usage:
+ * {$string|encodejs}
+ * {"bl''ah"|encodejs}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class EncodejsModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // escape backslash
+               $tagArgs[0] = StringUtil::replace("\\", "\\\\", $tagArgs[0]);
+               
+               // escape singe quote
+               $tagArgs[0] = StringUtil::replace("'", "\'", $tagArgs[0]);
+               
+               // escape new lines
+               $tagArgs[0] = StringUtil::replace("\n", '\n', $tagArgs[0]);
+               
+               // escape slashes
+               $tagArgs[0] = StringUtil::replace("/", '\/', $tagArgs[0]);
+               
+               return $tagArgs[0];
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/EventPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/EventPrefilterTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..1d25690
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\IPrefilterTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+
+/**
+ * The 'event' prefilter inserts template listener's code before compilation.
+ * 
+ * Usage:
+ * {event name='foo'}
+ *
+ * @author     Alexander Ebert
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class EventPrefilterTemplatePlugin implements IPrefilterTemplatePlugin {
+       /**
+        * @see wcf\system\template\IPrefilterTemplatePlugin::execute()
+        */
+       public function execute($templateName, $sourceContent, TemplateScriptingCompiler $compiler) {
+               $ldq = preg_quote($compiler->getLeftDelimiter(), '~');
+               $rdq = preg_quote($compiler->getRightDelimiter(), '~');
+               $sourceContent = preg_replace("~{$ldq}event\ name\=\'([\w]+)\'{$rdq}~e", 'wcf\system\WCF::getTPL()->getTemplateListenerCode(\''.$templateName.'\', \'$1\')', $sourceContent);
+               
+               return $sourceContent;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/FetchCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/FetchCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..106fd61
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\system\exception\SystemException;
+
+/**
+ * The 'fetch' compiler function fetches files from the local file system, http, or ftp and displays the content.
+ * 
+ * Usage:
+ * {fetch file='x.html'}
+ * {fetch file='x.html' assign=var}
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class FetchCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               if (!isset($tagArgs['file'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'file' argument in fetch tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               
+               if (isset($tagArgs['assign'])) {
+                       return "<?php \$this->assign(".$tagArgs['assign'].", @file_get_contents(".$tagArgs['file'].")); ?>";
+               }
+               else {
+                       return "<?php echo @file_get_contents(".$tagArgs['file']."); ?>";
+               }
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               throw new SystemException($compiler->formatSyntaxError("unknown tag {/fetch}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/FilesizeBinaryModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/FilesizeBinaryModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..27aacf0
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\FileUtil;
+
+/**
+ * The 'filesize' modifier formats a filesize (binary) (given in bytes).
+ * 
+ * Usage:
+ * {$string|filesizeBinary}
+ * {123456789|filesizeBinary}
+ *
+ * @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.plugin
+ * @category   Community Framework
+ */
+class FilesizeBinaryModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               return FileUtil::formatFilesizeBinary($tagArgs[0]);
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/FilesizeModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/FilesizeModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..1cbfcf8
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\FileUtil;
+
+/**
+ * The 'filesize' modifier formats a filesize (given in bytes).
+ * 
+ * Usage:
+ * {$string|filesize}
+ * {123456789|filesize}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class FilesizeModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               return FileUtil::formatFilesize($tagArgs[0]);
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HascontentPrefilterTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..12d3fb6
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\IPrefilterTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\util\StringUtil;
+
+/**
+ * The 'hascontent' prefilter inserts ability to insert code dynamically upon the contents of 'content'.
+ * 
+ * Usage:
+ * {hascontent}
+ * <ul>
+ *     {content}
+ *             {if $foo}<li>bar</li>{/if}
+ *     {/content}
+ * </ul>
+ * {hascontentelse}
+ *     <p>baz</p>
+ * {/hascontent}
+ *
+ * @author     Alexander Ebert
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class HascontentPrefilterTemplatePlugin implements IPrefilterTemplatePlugin {
+       /**
+        * @see wcf\system\template\IPrefilterTemplatePlugin::execute()
+        */
+       public function execute($templateName, $sourceContent, TemplateScriptingCompiler $compiler) {
+               $ldq = preg_quote($compiler->getLeftDelimiter(), '~');
+               $rdq = preg_quote($compiler->getRightDelimiter(), '~');
+               
+               $sourceContent = preg_replace_callback("~{$ldq}hascontent{$rdq}(.*){$ldq}content{$rdq}(.*){$ldq}\/content{$rdq}(.*)({$ldq}hascontentelse{$rdq}(.*))?{$ldq}\/hascontent{$rdq}~sU", array('self', 'replaceContentCallback'), $sourceContent);
+               
+               return $sourceContent;
+       }
+       
+       /**
+        * Reorders content to provide a logical order. In fact the content of
+        * '{content}' is moved outside the if-condition in order to capture
+        * the content during runtime, safely determining wether content is empty
+        * or not.
+        * 
+        * @param       array           $matches
+        * @return      string
+        */
+       protected static function replaceContentCallback(array $matches) {
+               $beforeContent = $matches[1];
+               $content = $matches[2];
+               $afterContent = $matches[3];
+               $elseContent = (isset($matches[5])) ? $matches[5] : '';
+               
+               $variable = 'hascontent_' . StringUtil::getRandomID();
+               
+               $newContent = '{capture assign='.$variable.'}'.$content.'{/capture}'."\n";
+               $newContent .= '{assign var='.$variable.' value=$'.$variable.'|trim}'."\n";
+               $newContent .= '{if $'.$variable.'}'.$beforeContent.'{@$'.$variable.'}'."\n".$afterContent;
+               
+               if (!empty($elseContent)) {
+                       $newContent .= '{else}'.$elseContent."\n";
+               }
+               
+               $newContent .= '{/if}'."\n";
+               
+               return $newContent;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmlcheckboxesFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..68cbb28
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\IFunctionTemplatePlugin;
+use wcf\system\template\TemplateEngine;
+use wcf\util\StringUtil;
+
+/**
+ * The 'htmlcheckboxes' template function generates a list of html checkboxes.
+ * 
+ * Usage:
+ * {htmlcheckboxes name="x" options=$array}
+ * {htmlcheckboxes name="x" options=$array selected=$foo}
+ * {htmlcheckboxes name="x" output=$outputArray}
+ * {htmlcheckboxes name="x" output=$outputArray values=$valueArray}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class HtmlcheckboxesFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       protected $disableEncoding = false;
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // get options
+               if (isset($tagArgs['output']) && is_array($tagArgs['output'])) {
+                       if (isset($tagArgs['values']) && is_array($tagArgs['values'])) {
+                               $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']);
+                       }
+                       else {
+                               $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']);
+                       }
+               }
+
+               if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) {
+                       throw new SystemException("missing 'options' argument in htmlCheckboxes tag");
+               }
+               
+               if (!isset($tagArgs['name'])) {
+                       throw new SystemException("missing 'name' argument in htmlCheckboxes tag");
+               }
+               
+               if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) {
+                       $this->disableEncoding = true;
+               }
+               else {
+                       $this->disableEncoding = false;
+               }
+               
+               // get selected values
+               if (isset($tagArgs['selected'])) {
+                       if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = array($tagArgs['selected']);        
+               }
+               else {
+                       $tagArgs['selected'] = array();
+               }
+               if (!isset($tagArgs['separator'])) {
+                       $tagArgs['separator'] = '';
+               }
+               
+               // build html
+               $html = '';
+               foreach ($tagArgs['options'] as $key => $value) {
+                       if (!empty($html)) $html .= $tagArgs['separator'];
+                       $html .= '<label><input type="checkbox" name="'.$this->encodeHTML($tagArgs['name']).'[]" value="'.$this->encodeHTML($key).'"'.(in_array($key, $tagArgs['selected']) ? ' checked="checked"' : '').' /> '.$this->encodeHTML($value).'</label>';                   
+               }
+               
+               return $html;
+       }
+       
+       /**
+        * Executes StringUtil::encodeHTML on the given text if disableEncoding is false.
+        * @see wcf\util\StringUtil::encodeHTML()
+        */
+       protected function encodeHTML($text) {
+               if (!$this->disableEncoding) {
+                       $text = StringUtil::encodeHTML($text);
+               }
+               
+               return $text;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/HtmloptionsFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..e474cc0
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\TemplateEngine;
+use wcf\util\StringUtil;
+
+/**
+ * The 'htmloptions' template function generates the options of an html select list.
+ * 
+ * Usage:
+ * {htmloptions options=$array}
+ * {htmloptions options=$array selected=$foo}
+ * {htmloptions options=$array name="x"}
+ * {htmloptions output=$outputArray}
+ * {htmloptions output=$outputArray values=$valueArray}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class HtmloptionsFunctionTemplatePlugin extends HtmlcheckboxesFunctionTemplatePlugin {
+       protected $selected = array();
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               if (isset($tagArgs['output']) && is_array($tagArgs['output'])) {
+                       if (count($tagArgs['output'])) {
+                               if (isset($tagArgs['values']) && is_array($tagArgs['values'])) {
+                                       if (count($tagArgs['output']) == count($tagArgs['values'])) {
+                                               $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']);
+                                       }
+                                       else {
+                                               $tagArgs['options'] = array();
+                                       }
+                               }
+                               else {
+                                       $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']);
+                               }
+                       }
+                       else {
+                               $tagArgs['options'] = array();
+                       }
+               }
+
+               if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) {
+                       throw new SystemException("missing 'options' argument in htmloptions tag");
+               }
+               
+               if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) {
+                       $this->disableEncoding = true;
+               }
+               else {
+                       $this->disableEncoding = false;
+               }
+               
+               // get selected values
+               $this->selected = array();
+               if (isset($tagArgs['selected'])) {
+                       $this->selected = $tagArgs['selected'];
+                       if (!is_array($this->selected)) $this->selected = array($this->selected);       
+               }
+               
+               // create option list
+               $htmloptions = $this->makeOptionGroup(null, $tagArgs['options']);
+               
+               // create also a 'select' tag
+               if (isset($tagArgs['name'])) {
+                       // unset all system vars
+                       unset($tagArgs['options'], $tagArgs['selected'], $tagArgs['output'], $tagArgs['values'], $tagArgs['disableEncoding']);
+                       
+                       // generate 'select' parameters
+                       $params = '';
+                       foreach ($tagArgs as $key => $value) {
+                               $params .= ' '.$key.'="'.$this->encodeHTML($value).'"';
+                       }
+                       
+                       $htmloptions = '<select'.$params.'>'."\n".$htmloptions."</select>\n";
+               }
+               
+               return $htmloptions;
+       }
+       
+       /**
+        * Makes the html for an option group.
+        * 
+        * @param       string          $key
+        * @param       array           $values
+        * @return      string                          html code of an option group
+        */
+       protected function makeOptionGroup($key, $values) {
+               $html = '';
+               if ($key !== null) {
+                       $html = '<optgroup label="'.$this->encodeHTML($key).'">'."\n";
+               }
+               
+               foreach ($values as $childKey => $value) {
+                       if (is_array($value)) {
+                               $html .= $this->makeOptionGroup($childKey, $value);
+                       }
+                       else {
+                               $html .= $this->makeOption($childKey, $value);
+                       }
+               }
+               
+               if ($key !== null) {
+                       $html .= "</optgroup>\n";
+               }
+               
+               return $html;
+       }
+       
+       /**
+        * Makes the html for an option.
+        * 
+        * @param       string          $key
+        * @param       string          $value
+        * @return      string                          html code of an option tag
+        */
+       protected function makeOption($key, $value) {
+               $value = $this->encodeHTML($value);
+               return '<option label="'.$value.'" value="'.$this->encodeHTML($key).'"'.(in_array($key, $this->selected) ? ' selected="selected"' : '').'>'.$value."</option>\n";
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/IconCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/IconCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..192c73f
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\util\StringUtil;
+
+/**
+ * The 'icon' compiler function compiles dynamic icon paths.
+ *
+ * Usage:
+ * {icon}{$foo}{/icon}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class IconCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               $compiler->pushTag('icon');
+               return "<?php ob_start(); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               $compiler->popTag('icon');
+               $hash = StringUtil::getRandomID();
+               return "<?php \$_icon".$hash." = ob_get_contents(); ob_end_clean(); echo wcf\system\style\StyleHandler::getInstance()->getStyle()->getIconPath(\$_icon".$hash."); ?>";
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/IconPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/IconPrefilterTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..b05bc4d
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\IPrefilterTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+
+/**
+ * The 'icon' prefilter compiles static icon paths.
+ * 
+ * Usage:
+ * {icon}iconS.png{/icon}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class IconPrefilterTemplatePlugin implements IPrefilterTemplatePlugin {
+       /**
+        * @see wcf\system\template\ITemplatePluginPrefilter::execute()
+        */
+       public function execute($sourceContent, TemplateScriptingCompiler $compiler) {
+               $ldq = preg_quote($compiler->getLeftDelimiter(), '~');
+               $rdq = preg_quote($compiler->getRightDelimiter(), '~');
+               $sourceContent = preg_replace("~{$ldq}icon{$rdq}([\w\.]+){$ldq}/icon{$rdq}~", '{literal}<?php echo wcf\system\style\StyleHandler::getInstance()->getStyle()->getIconPath(\'$1\'); ?>{/literal}', $sourceContent);
+
+               return $sourceContent;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/ImplodeCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/ImplodeCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..b99a6e6
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\system\exception\SystemException;
+use wcf\util\StringUtil;
+
+/**
+ * The 'implode' compiler function joins array elements with a string.
+ * 
+ * Usage:
+ * {implode from=$array key=bar item=foo glue=";"}{$foo}{/implode}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class ImplodeCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       protected $tagStack = array();
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               $compiler->pushTag('implode');
+               
+               if (!isset($tagArgs['from'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'from' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               if (!isset($tagArgs['item'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'item' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               
+               $hash = StringUtil::getRandomID();
+               $glue = isset($tagArgs['glue']) ? $tagArgs['glue'] : "', '";
+               $this->tagStack[] = array('hash' => $hash, 'glue' => $glue);
+               
+               $phpCode = "<?php\n";
+               $phpCode .= "\$_length".$hash." = count(".$tagArgs['from'].");\n";
+               $phpCode .= "\$_i".$hash." = 0;\n";
+               $phpCode .= "foreach (".$tagArgs['from']." as ".(isset($tagArgs['key']) ? (StringUtil::substring($tagArgs['key'], 0, 1) != '$' ? "\$this->v[".$tagArgs['key']."]" : $tagArgs['key'])." => " : '').(StringUtil::substring($tagArgs['item'], 0, 1) != '$' ? "\$this->v[".$tagArgs['item']."]" : $tagArgs['item']).") { ?>";
+               return $phpCode;
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               $compiler->popTag('implode');
+               $tagArgs = array_pop($this->tagStack);
+               
+               $phpCode = "<?php\n";
+               $phpCode .= "if (++\$_i".$tagArgs['hash']." < \$_length".$tagArgs['hash'].") { echo ".$tagArgs['glue']."; }\n";
+               $phpCode .= "} ?>";
+               
+               return $phpCode;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/LangCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/LangCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..baa1696
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\util\StringUtil;
+
+/**
+ * The 'lang' compiler function compiles dynamic language variables.
+ * 
+ * Usage:
+ * {lang}$blah{/lang}
+ * {lang var=$x}foo{/lang}
+ *
+ * @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.plugin
+ * @category   Community Framework
+ */
+class LangCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               $compiler->pushTag('lang');
+               
+               $newTagArgs = array();
+               foreach ($tagArgs as $key => $arg) {
+                       $newTagArgs[$key] = 'wcf\util\StringUtil::encodeHTML('.$arg.')';
+               }
+               
+               $tagArgs = $compiler->makeArgString($newTagArgs);
+               return "<?php \$this->tagStack[] = array('lang', array($tagArgs)); ob_start(); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               $compiler->popTag('lang');
+               $hash = StringUtil::getRandomID();
+               return "<?php \$_lang".$hash." = ob_get_contents(); ob_end_clean(); echo wcf\system\WCF::getLanguage()->getDynamicVariable(\$_lang".$hash.", \$this->tagStack[count(\$this->tagStack) - 1][1]); array_pop(\$this->tagStack); ?>";
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/LangPrefilterTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/LangPrefilterTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..03cbdd0
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\IPrefilterTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\system\WCF;
+
+/**
+ * The 'lang' prefilter compiles static language variables.
+ * Dynamic language variables will catched by the 'lang' compiler function.
+ * It is recommended to use static language variables.
+ * 
+ * Usage:
+ * {lang}foo{/lang}
+ * {lang}lang.foo.bar{/lang}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class LangPrefilterTemplatePlugin implements IPrefilterTemplatePlugin {
+       /**
+        * @see wcf\system\template\IPrefilterTemplatePlugin::execute()
+        */
+       public function execute($templateName, $sourceContent, TemplateScriptingCompiler $compiler) {
+               $ldq = preg_quote($compiler->getLeftDelimiter(), '~');
+               $rdq = preg_quote($compiler->getRightDelimiter(), '~');
+               $sourceContent = preg_replace("~{$ldq}lang{$rdq}([\w\.]+){$ldq}/lang{$rdq}~e", 'wcf\system\WCF::getLanguage()->get(\'$1\')', $sourceContent);
+
+               return $sourceContent;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..33b496c
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\request\LinkHandler;
+use wcf\system\template\IBlockTemplatePlugin;
+use wcf\system\template\TemplateEngine;
+
+/**
+ * Shortcut for usage of LinkHandler::getInstance()->getLink() in template scripting.
+ * 
+ * Usage:
+ * {link application='wcf'}index.php{/link}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class LinkBlockTemplatePlugin implements IBlockTemplatePlugin {
+       /**
+        * internal loop counter
+        * @var integer
+        */
+       protected $counter = 0;
+       
+       /**
+        * @see wcf\system\template\IBlockTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, $blockContent, TemplateEngine $tplObj) {
+               $application = 'wcf';
+               if (!empty($tagArgs['application'])) {
+                       $application = $tagArgs['application'];
+               }
+               
+               return LinkHandler::getInstance()->getLink($blockContent, $application);
+       }
+       
+       /**
+        * @see wcf\system\template\IBlockTemplatePlugin::init()
+        */
+       public function init($tagArgs, TemplateEngine $tplObj) {
+               $this->counter = 0;
+       }
+       
+       /**
+        * @see wcf\system\template\IBlockTemplatePlugin::next()
+        */
+       public function next(TemplateEngine $tplObj) {
+               if ($this->counter == 0) {
+                       $this->counter++;
+                       return true;
+               }
+               
+               return false;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..72495b4
--- /dev/null
@@ -0,0 +1,220 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IFunctionTemplatePlugin;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * The 'pages' template function is used to generate sliding pagers.
+ * 
+ * Usage:
+ * {pages pages=10 link='page-%d.html'}
+ * {pages page=8 pages=10 link='page-%d.html'}
+ * 
+ * assign to variable 'output'; do not print: 
+ * {pages page=8 pages=10 link='page-%d.html' assign='output'}
+ * 
+ * assign to variable 'output' and do print also:
+ * {pages page=8 pages=10 link='page-%d.html' assign='output' print=true}
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class PagesFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       const SHOW_LINKS = 11;
+       const SHOW_SUB_LINKS = 20;
+       
+       /**
+        * Inserts the page number into the link.
+        * 
+        * @param       string          $link
+        * @param       integer         $pageNo
+        * @return      string          final link
+        */
+       protected static function insertPageNumber($link, $pageNo) {
+               $startPos = StringUtil::indexOf($link, '%d');
+               if ($startPos !== null) $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
+               return $link;
+       }
+       
+       /**
+        * Generates html code of a link.
+        * 
+        * @param       string          $link
+        * @param       integer         $pageNo
+        * @param       integer         $activePage
+        * @param       boolean         $break
+        * @return      string
+        */
+       protected function makeLink($link, $pageNo, $activePage, $break = false) {
+               // first page
+               if ($activePage != $pageNo) {
+                       return '<li'.($break ? ' class="break"' : '').'><a href="'.$this->insertPageNumber($link, $pageNo).'">'.StringUtil::formatInteger($pageNo).'</a></li>'."\n";
+               }
+               else {
+                       return '<li class="'.($break ? 'break ' : '').'active"><span>'.StringUtil::formatInteger($pageNo).'</span></li>'."\n";
+               }
+       }
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // needed params: link, page, pages
+               if (!isset($tagArgs['link'])) throw new SystemException("missing 'link' argument in pages tag");
+               if (!isset($tagArgs['pages'])) {
+                       if (($tagArgs['pages'] = $tplObj->get('pages')) === null) {
+                               throw new SystemException("missing 'pages' argument in pages tag");
+                       }
+               }
+               
+               $html = '';
+               
+               if ($tagArgs['pages'] > 1) {
+                       // define page link for js function
+                       $html .= "<script type=\"text/javascript\">\n//<![CDATA[\nmultiPagesLinks.setPageLink('".StringUtil::replace("'", "\'", $tagArgs['link'])."');\n//]]>\n</script>";
+                       
+                       // encode link
+                       $tagArgs['link'] = StringUtil::encodeHTML($tagArgs['link']);
+               
+                       if (!isset($tagArgs['page'])) {
+                               if (($tagArgs['page'] = $tplObj->get('pageNo')) === null) {
+                                       $tagArgs['page'] = 0;
+                               }
+                       }
+                       
+                       // open div and ul
+                       $html .= "<div class=\"pageNavigation\">\n<ul>\n";
+                       
+                       // previous page
+                       $previousTitle = WCF::getLanguage()->getDynamicVariable('wcf.global.page.previous');
+                       if ($tagArgs['page'] > 1) {
+                               $html .= '<li class="skip"><a href="'.$this->insertPageNumber($tagArgs['link'], $tagArgs['page'] - 1).'" title="'.$previousTitle.'"><img src="'.self::getIconPath('previousS.png').'" alt="" /></a></li>'."\n";
+                       }
+                       else {
+                               $html .= '<li class="skip"><img src="'.self::getIconPath('previousDisabledS.png').'" alt="" /></li>'."\n";
+                       }
+                       
+                       // first page
+                       $html .= $this->makeLink($tagArgs['link'], 1, $tagArgs['page']);
+                       
+                       // calculate page links
+                       $maxLinks = self::SHOW_LINKS - 4;
+                       $linksBeforePage = $tagArgs['page'] - 2;
+                       if ($linksBeforePage < 0) $linksBeforePage = 0; 
+                       $linksAfterPage = $tagArgs['pages'] - ($tagArgs['page'] + 1);
+                       if ($linksAfterPage < 0) $linksAfterPage = 0; 
+                       if ($tagArgs['page'] > 1 && $tagArgs['page'] < $tagArgs['pages']) {
+                               $maxLinks--;
+                       }
+                       
+                       $half = $maxLinks / 2;
+                       $left = $right = $tagArgs['page'];
+                       if ($left < 1) $left = 1;
+                       if ($right < 1) $right = 1;
+                       if ($right > $tagArgs['pages'] - 1) $right = $tagArgs['pages'] - 1;
+                       
+                       if ($linksBeforePage >= $half) {
+                               $left -= $half;
+                       }
+                       else {
+                               $left -= $linksBeforePage;
+                               $right += $half - $linksBeforePage;
+                       }
+                       
+                       if ($linksAfterPage >= $half) {
+                               $right += $half;
+                       }
+                       else {
+                               $right += $linksAfterPage;
+                               $left -= $half - $linksAfterPage;
+                       }
+                       
+                       $right = intval(ceil($right));
+                       $left = intval(ceil($left));
+                       if ($left < 1) $left = 1;
+                       if ($right > $tagArgs['pages']) $right = $tagArgs['pages'];
+                       
+                       // left ... links
+                       if ($left > 1) {
+                               if ($left - 1 < 2) {
+                                       $html .= $this->makeLink($tagArgs['link'], 2, $tagArgs['page']);
+                               }
+                               else {
+                                       $html .= '<li class="children"><a onclick="multiPagesLinks.startPageNumberInput(this)">&hellip;<img src="'.self::getIconPath('arrowDown.png').'" alt="" /></a><input type="text" class="inputText" name="pageNo" /><div><ul>'."\n";
+                                       
+                                       $k = 0;
+                                       $step = intval(ceil(($left - 2) / self::SHOW_SUB_LINKS));
+                                       for ($i = 2; $i <= $left; $i += $step) {
+                                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page'], $k != 0 && $k % 4 == 0);
+                                               $k++;
+                                       }
+                                       
+                                       $html .= "</ul></div></li>\n";
+                               }
+                       }
+                       
+                       // visible links
+                       for ($i = $left + 1; $i < $right; $i++) {
+                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page']);
+                       }
+                       
+                       // right ... links
+                       if ($right < $tagArgs['pages']) {
+                               if ($tagArgs['pages'] - $right < 2) {
+                                       $html .= $this->makeLink($tagArgs['link'], $tagArgs['pages'] - 1, $tagArgs['page']);
+                               }
+                               else {
+                                       $html .= '<li class="children"><a onclick="multiPagesLinks.startPageNumberInput(this)">&hellip;<img src="'.self::getIconPath('arrowDown.png').'" alt="" /></a><input type="text" class="inputText" name="page" /><div><ul>'."\n";
+                                       
+                                       $k = 0;
+                                       $step = intval(ceil(($tagArgs['pages'] - $right) / self::SHOW_SUB_LINKS));
+                                       for ($i = $right; $i < $tagArgs['pages']; $i += $step) {
+                                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page'], $k != 0 && $k % 4 == 0);
+                                               $k++;
+                                       }
+                                       
+                                       $html .= "</ul></div></li>\n";
+                               }
+                       }
+                       
+                       // last page
+                       $html .= $this->makeLink($tagArgs['link'], $tagArgs['pages'], $tagArgs['page']);
+                       
+                       // next page
+                       $nextTitle = WCF::getLanguage()->getDynamicVariable('wcf.global.page.next');
+                       if ($tagArgs['page'] && $tagArgs['page'] < $tagArgs['pages']) {
+                               $html .= '<li class="skip"><a href="'.$this->insertPageNumber($tagArgs['link'], $tagArgs['page'] + 1).'" title="'.$nextTitle.'"><img src="'.self::getIconPath('nextS.png').'" alt="" /></a></li>'."\n";
+                       }
+                       else {
+                               $html .= '<li class="skip"><img src="'.self::getIconPath('nextDisabledS.png').'" alt="" /></li>'."\n";
+                       }
+                       
+                       // close div and ul
+                       $html .= "</ul></div>\n";
+               }
+               
+               // assign html output to template var
+               if (isset($tagArgs['assign'])) {
+                       $tplObj->assign($tagArgs['assign'], $html);
+                       if (!isset($tagArgs['print']) || !$tagArgs['print']) return '';
+               }
+               
+               return $html;
+       }
+       
+       private static function getIconPath($filename) {
+               if (class_exists('StyleManager')) {
+                       return StyleManager::getStyle()->getIconPath($filename);
+               }
+               else {
+                       return RELATIVE_WCF_DIR.'icon/'.$filename;
+               }
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..941153a
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\system\WCF;
+use wcf\util\DateUtil;
+
+/**
+ * The 'plainTime' modifier formats a unix timestamp.
+ * Default date format contains year, month, day, hour and minute.
+ * 
+ * Usage:
+ * {$timestamp|plainTime}
+ * {"132845333"|plainTime}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class PlainTimeModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               $dateTime = DateUtil::getDateTimeByTimestamp($tagArgs[0]);
+               return str_replace('%time%', DateUtil::format($dateTime, DateUtil::TIME_FORMAT), str_replace('%date%', DateUtil::format($dateTime, DateUtil::DATE_FORMAT), WCF::getLanguage()->get('wcf.global.date.dateTimeFormat')));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/PrependCompilerTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PrependCompilerTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..5400da7
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\exception\SystemException;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\util\StringUtil;
+
+/**
+ * The 'prepend' compiler function calls the prepend function on the template object.
+ * 
+ * Usage:
+ * {prepend var=name value="foo"}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class PrependCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               if (!isset($tagArgs['var'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in prepend tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+               if (!isset($tagArgs['value'])) {
+                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in prepend tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+               }
+                               
+               return "<?php \$this->prepend(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               throw new SystemException($compiler->formatSyntaxError("unknown tag {/prepend}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/SmallpagesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/SmallpagesFunctionTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..d0022e6
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\WCF;
+use wcf\system\exception\SystemException;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IFunctionTemplatePlugin;
+use wcf\util\StringUtil;
+
+/**
+ * The 'smallpages' template function is used to generate simple sliding pagers.
+ * 
+ * Usage:
+ * {smallpages pages=10 link='page-%d.html'}
+ * 
+ * assign to variable 'output'; do not print: 
+ * {smallpages pages=10 link='page-%d.html' assign='output'}
+ * 
+ * assign to variable 'output' and do print also:
+ * {smallpages pages=10 link='page-%d.html' assign='output' print=true}
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class SmallpagesFunctionTemplatePlugin implements IFunctionTemplatePlugin {
+       const SHOW_LINKS = 5;
+       
+       /**
+        * Inserts the page number into the link.
+        * 
+        * @param       string          $link
+        * @param       integer         $pageNo
+        * @return      string          final link
+        */
+       protected static function insertPageNumber($link, $pageNo) {
+               $startPos = StringUtil::indexOf($link, '%d');
+               if ($startPos !== null) $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
+               return $link;
+       }
+       
+       /**
+        * Generates html code of a link.
+        * 
+        * @param       string          $link
+        * @param       integer         $pageNo
+        * @return      string
+        */
+       protected function makeLink($link, $pageNo) {
+               return '<li><a href="'.$this->insertPageNumber($link, $pageNo).'" title="' . WCF::getLanguage()->getDynamicVariable('wcf.page.pageNo', array('pageNo' => $pageNo)) . '">'.StringUtil::formatInteger($pageNo).'</a></li>'."\n";
+       }
+       
+       /**
+        * @see wcf\system\template\IFunctionTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // needed params: link, pages
+               if (!isset($tagArgs['link'])) throw new SystemException("missing 'link' argument in pages tag");
+               if (!isset($tagArgs['pages'])) {
+                       if (($tagArgs['pages'] = $tplObj->get('pages')) === null) {
+                               throw new SystemException("missing 'pages' argument in pages tag");
+                       }
+               }
+               
+               $html = '';
+               if ($tagArgs['pages'] > 1) {
+                       // encode link
+                       $link = StringUtil::encodeHTML($tagArgs['link']);
+               
+                       // open div and ul
+                       $html .= "<div class=\"pageNavigation\">\n<ul>\n";
+                       
+                       // generate simple links
+                       $simpleLinks = $tagArgs['pages'];
+                       if ($simpleLinks > self::SHOW_LINKS) {
+                               $simpleLinks = self::SHOW_LINKS - 2;
+                       }
+                       
+                       for ($i = 1; $i <= $simpleLinks; $i++) {
+                               $html .= $this->makeLink($link, $i);
+                       }
+                       
+                       if ($tagArgs['pages'] > self::SHOW_LINKS) {
+                               // jumper
+                               $html .= '<li><a onclick="var result = prompt(\''.WCF::getLanguage()->get('wcf.global.page.input').'\', \''.$tagArgs['pages'].'\'); if (typeof(result) != \'object\' &amp;&amp; typeof(result) != \'undefined\') document.location.href = fixURL((\''.StringUtil::replace("'", "\'", $link).'\').replace(/%d/, result));">&hellip;</a></li>'."\n";
+
+                               // last page
+                               $html .= $this->makeLink($link, $tagArgs['pages']);
+                       }
+                       
+                       // close div and ul
+                       $html .= "</ul></div>\n";
+               }
+               
+               // assign html output to template var
+               if (isset($tagArgs['assign'])) {
+                       $tplObj->assign($tagArgs['assign'], $html);
+                       if (!isset($tagArgs['print']) || !$tagArgs['print']) return '';
+               }
+               
+               return $html;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/StaticlangTemplatePluginCompiler.class.php b/wcfsetup/install/files/lib/system/template/plugin/StaticlangTemplatePluginCompiler.class.php
new file mode 100644 (file)
index 0000000..0b76cd8
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\ICompilerTemplatePlugin;
+use wcf\system\template\TemplateScriptingCompiler;
+use wcf\util\StringUtil;
+
+/**
+ * The 'staticlang' compiler function gets the source of a language variables.
+ * 
+ * Usage:
+ * {staticlang}$blah{/staticlang}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class StaticlangCompilerTemplatePlugin implements ICompilerTemplatePlugin {
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeStart()
+        */
+       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
+               $compiler->pushTag('staticlang');
+               
+               return "<?php ob_start(); ?>";
+       }
+       
+       /**
+        * @see wcf\system\template\ICompilerTemplatePlugin::executeEnd()
+        */
+       public function executeEnd(TemplateScriptingCompiler $compiler) {
+               $compiler->popTag('staticlang');
+               $hash = StringUtil::getRandomID();
+               return "<?php \$_lang".$hash." = ob_get_contents(); ob_end_clean(); echo \wcf\system\WCF::getLanguage()->get(\$_lang".$hash."); ?>";
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginBlockLink.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginBlockLink.class.php
deleted file mode 100644 (file)
index 7861d47..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\request\LinkHandler;
-use wcf\system\template\ITemplatePluginBlock;
-use wcf\system\template\TemplateEngine;
-
-/**
- * Shortcut for usage of LinkHandler::getInstance()->getLink() in template scripting.
- * 
- * Usage:
- * {link application='wcf'}index.php{/link}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginBlockLink implements ITemplatePluginBlock {
-       /**
-        * internal loop counter
-        * @var integer
-        */
-       protected $counter = 0;
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginBlock::execute()
-        */
-       public function execute($tagArgs, $blockContent, TemplateEngine $tplObj) {
-               $application = 'wcf';
-               if (!empty($tagArgs['application'])) {
-                       $application = $tagArgs['application'];
-               }
-               
-               return LinkHandler::getInstance()->getLink($blockContent, $application);
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginBlock::init()
-        */
-       public function init($tagArgs, TemplateEngine $tplObj) {
-               $this->counter = 0;
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginBlock::next()
-        */
-       public function next(TemplateEngine $tplObj) {
-               if ($this->counter == 0) {
-                       $this->counter++;
-                       return true;
-               }
-               
-               return false;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAppend.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAppend.class.php
deleted file mode 100644 (file)
index cbb4808..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\system\exception\SystemException;
-
-/**
- * The 'append' compiler function calls the append function on the template object.
- * 
- * Usage:
- * {append var=name value="foo"}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerAppend implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               if (!isset($tagArgs['var'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in append tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               if (!isset($tagArgs['value'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in append tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-                               
-               return "<?php \$this->append(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               throw new SystemException($compiler->formatSyntaxError("unknown tag {/append}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAssign.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerAssign.class.php
deleted file mode 100644 (file)
index 9ae7d4d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\system\exception\SystemException;
-
-/**
- * The 'assign' compiler function calls the assign function on the template object.
- * 
- * Usage:
- * {assign var=name value="foo"}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerAssign implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               if (!isset($tagArgs['var'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in assign tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               if (!isset($tagArgs['value'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in assign tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-                               
-               return "<?php \$this->assign(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               throw new SystemException($compiler->formatSyntaxError("unknown tag {/assign}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerFetch.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerFetch.class.php
deleted file mode 100644 (file)
index 378b7be..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\system\exception\SystemException;
-
-/**
- * The 'fetch' compiler function fetches files from the local file system, http, or ftp and displays the content.
- * 
- * Usage:
- * {fetch file='x.html'}
- * {fetch file='x.html' assign=var}
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerFetch implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               if (!isset($tagArgs['file'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'file' argument in fetch tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               
-               if (isset($tagArgs['assign'])) {
-                       return "<?php \$this->assign(".$tagArgs['assign'].", @file_get_contents(".$tagArgs['file'].")); ?>";
-               }
-               else {
-                       return "<?php echo @file_get_contents(".$tagArgs['file']."); ?>";
-               }
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               throw new SystemException($compiler->formatSyntaxError("unknown tag {/fetch}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerIcon.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerIcon.class.php
deleted file mode 100644 (file)
index a4b0b10..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\util\StringUtil;
-
-/**
- * The 'icon' compiler function compiles dynamic icon paths.
- *
- * Usage:
- * {icon}{$foo}{/icon}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerIcon implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               $compiler->pushTag('icon');
-               return "<?php ob_start(); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               $compiler->popTag('icon');
-               $hash = StringUtil::getRandomID();
-               return "<?php \$_icon".$hash." = ob_get_contents(); ob_end_clean(); echo wcf\system\style\StyleHandler::getInstance()->getStyle()->getIconPath(\$_icon".$hash."); ?>";
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerImplode.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerImplode.class.php
deleted file mode 100644 (file)
index 25bb79a..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\system\exception\SystemException;
-use wcf\util\StringUtil;
-
-/**
- * The 'implode' compiler function joins array elements with a string.
- * 
- * Usage:
- * {implode from=$array key=bar item=foo glue=";"}{$foo}{/implode}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerImplode implements ITemplatePluginCompiler {
-       protected $tagStack = array();
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               $compiler->pushTag('implode');
-               
-               if (!isset($tagArgs['from'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'from' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               if (!isset($tagArgs['item'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'item' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               
-               $hash = StringUtil::getRandomID();
-               $glue = isset($tagArgs['glue']) ? $tagArgs['glue'] : "', '";
-               $this->tagStack[] = array('hash' => $hash, 'glue' => $glue);
-               
-               $phpCode = "<?php\n";
-               $phpCode .= "\$_length".$hash." = count(".$tagArgs['from'].");\n";
-               $phpCode .= "\$_i".$hash." = 0;\n";
-               $phpCode .= "foreach (".$tagArgs['from']." as ".(isset($tagArgs['key']) ? (StringUtil::substring($tagArgs['key'], 0, 1) != '$' ? "\$this->v[".$tagArgs['key']."]" : $tagArgs['key'])." => " : '').(StringUtil::substring($tagArgs['item'], 0, 1) != '$' ? "\$this->v[".$tagArgs['item']."]" : $tagArgs['item']).") { ?>";
-               return $phpCode;
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               $compiler->popTag('implode');
-               $tagArgs = array_pop($this->tagStack);
-               
-               $phpCode = "<?php\n";
-               $phpCode .= "if (++\$_i".$tagArgs['hash']." < \$_length".$tagArgs['hash'].") { echo ".$tagArgs['glue']."; }\n";
-               $phpCode .= "} ?>";
-               
-               return $phpCode;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerLang.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerLang.class.php
deleted file mode 100644 (file)
index a1a76c6..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\util\StringUtil;
-
-/**
- * The 'lang' compiler function compiles dynamic language variables.
- * 
- * Usage:
- * {lang}$blah{/lang}
- * {lang var=$x}foo{/lang}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerLang implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               $compiler->pushTag('lang');
-               
-               $newTagArgs = array();
-               foreach ($tagArgs as $key => $arg) {
-                       $newTagArgs[$key] = 'wcf\util\StringUtil::encodeHTML('.$arg.')';
-               }
-               
-               $tagArgs = $compiler->makeArgString($newTagArgs);
-               return "<?php \$this->tagStack[] = array('lang', array($tagArgs)); ob_start(); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               $compiler->popTag('lang');
-               $hash = StringUtil::getRandomID();
-               return "<?php \$_lang".$hash." = ob_get_contents(); ob_end_clean(); echo wcf\system\WCF::getLanguage()->getDynamicVariable(\$_lang".$hash.", \$this->tagStack[count(\$this->tagStack) - 1][1]); array_pop(\$this->tagStack); ?>";
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerPrepend.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerPrepend.class.php
deleted file mode 100644 (file)
index 4ac7471..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\util\StringUtil;
-
-/**
- * The 'prepend' compiler function calls the prepend function on the template object.
- * 
- * Usage:
- * {prepend var=name value="foo"}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerPrepend implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               if (!isset($tagArgs['var'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'var' argument in prepend tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-               if (!isset($tagArgs['value'])) {
-                       throw new SystemException($compiler->formatSyntaxError("missing 'value' argument in prepend tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-               }
-                               
-               return "<?php \$this->prepend(".$tagArgs['var'].", ".$tagArgs['value']."); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               throw new SystemException($compiler->formatSyntaxError("unknown tag {/prepend}", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerStaticlang.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginCompilerStaticlang.class.php
deleted file mode 100644 (file)
index f92a62b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginCompiler;
-use wcf\system\template\TemplateScriptingCompiler;
-use wcf\util\StringUtil;
-
-/**
- * The 'staticlang' compiler function gets the source of a language variables.
- * 
- * Usage:
- * {staticlang}$blah{/staticlang}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginCompilerStaticlang implements ITemplatePluginCompiler {
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeStart()
-        */
-       public function executeStart($tagArgs, TemplateScriptingCompiler $compiler) {
-               $compiler->pushTag('staticlang');
-               
-               return "<?php ob_start(); ?>";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginCompiler::executeEnd()
-        */
-       public function executeEnd(TemplateScriptingCompiler $compiler) {
-               $compiler->popTag('staticlang');
-               $hash = StringUtil::getRandomID();
-               return "<?php \$_lang".$hash." = ob_get_contents(); ob_end_clean(); echo WCF::getLanguage()->get(\$_lang".$hash."); ?>";
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCounter.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCounter.class.php
deleted file mode 100644 (file)
index ccc80f0..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\ITemplatePluginFunction;
-use wcf\system\template\TemplateEngine;
-
-/**
- * The 'counter' template function is used to print out a count.
- * 
- * Usage:
- * {counter assign=i}
- * {counter start=10 skip=2}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionCounter implements ITemplatePluginFunction {
-       protected $counters = array();
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               if (!isset($tagArgs['name'])) {
-                       $tagArgs['name'] = 'default';
-               }
-
-               if (!isset($this->counters[$tagArgs['name']])) {
-                       $this->counters[$tagArgs['name']] = array(
-                               'start' => 1,
-                               'skip' => 1,
-                               'direction' => 'up',
-                               'count' => 1
-                       );
-               }
-
-               $counter =& $this->counters[$tagArgs['name']];
-
-               if (isset($tagArgs['start'])) {
-                       $counter['start'] = $counter['count'] = intval($tagArgs['start']);
-               }
-
-               if (isset($tagArgs['assign']) && !empty($tagArgs['assign'])) {
-                       $counter['assign'] = $tagArgs['assign'];
-               }
-
-               if (isset($counter['assign'])) {
-                       $tplObj->assign($counter['assign'], $counter['count']);
-               }
-
-               $result = null;
-               if (!isset($tagArgs['print']) || $tagArgs['print']) {
-                       $result = $counter['count'];
-               } 
-               
-               if (isset($tagArgs['skip'])) {
-                       $counter['skip'] = intval($tagArgs['skip']);
-               }
-
-               // get direction
-               if (isset($tagArgs['direction'])) {
-                       $counter['direction'] = $tagArgs['direction'];
-               }
-
-               if ($counter['direction'] == 'down') {
-                       $counter['count'] -= $counter['skip'];
-               }
-               else {
-                       $counter['count'] += $counter['skip'];
-               }
-
-               return $result;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCycle.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionCycle.class.php
deleted file mode 100644 (file)
index b6e9750..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\template\ITemplatePluginFunction;
-use wcf\system\template\TemplateEngine;
-
-/**
- * The 'cycle' template function cycles through given values.
- * 
- * Usage:
- * {cycle values="#eee,#fff"}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionCycle implements ITemplatePluginFunction {
-       protected $cycles = array();
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               // get params
-               $name = isset($tagArgs['name']) ? $tagArgs['name'] : 'default';
-               $print = isset($tagArgs['print']) ? $tagArgs['print'] : 1;
-               $advance = isset($tagArgs['advance']) ? $tagArgs['advance'] : 1;
-               $reset = isset($tagArgs['reset']) ? $tagArgs['reset'] : 0;
-               
-               // get values
-               if (!isset($tagArgs['values']) ) {
-                       if (!isset($this->cycles[$name]['values'])) {
-                               throw new SystemException("missing 'values' argument in cycle tag");
-                       }
-               }
-               else {
-                       if (isset($this->cycles[$name]['values']) && $this->cycles[$name]['values'] != $tagArgs['values'] ) {
-                               $this->cycles[$name]['index'] = 0;
-                       }
-                       $this->cycles[$name]['values'] = $tagArgs['values'];
-               }
-               
-               // get delimiter
-               if (!isset($this->cycles[$name]['delimiter'])) {
-                       // set default delimiter
-                       $this->cycles[$name]['delimiter'] = ',';
-               }
-               if (isset($tagArgs['delimiter'])) {
-                       $this->cycles[$name]['delimiter'] = $tagArgs['delimiter'];
-               }
-               
-               // split values
-               if (is_array($this->cycles[$name]['values'])) {
-                       $cycleArray = $this->cycles[$name]['values'];
-               }
-               else {
-                       $cycleArray = explode($this->cycles[$name]['delimiter'], $this->cycles[$name]['values']);
-               }
-               
-               // set index
-               if (!isset($this->cycles[$name]['index']) || $reset) {
-                       $this->cycles[$name]['index'] = 0;
-               }
-               
-               // get result
-               $result = $cycleArray[$this->cycles[$name]['index']];
-               
-               // assign result to template var
-               if (isset($tagArgs['assign'])) {
-                       $print = false;
-                       $tplObj->assign($tagArgs['assign'], $result);
-               }
-               
-               // update index
-               if ($advance) {
-                       if ($this->cycles[$name]['index'] >= count($cycleArray) - 1) {
-                               $this->cycles[$name]['index'] = 0;
-                       }
-                       else {
-                               $this->cycles[$name]['index']++;
-                       }
-               }
-               
-               // print var
-               if ($print) {
-                       return $result;
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmlcheckboxes.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmlcheckboxes.class.php
deleted file mode 100644 (file)
index f80658a..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\template\ITemplatePluginFunction;
-use wcf\system\template\TemplateEngine;
-use wcf\util\StringUtil;
-
-/**
- * The 'htmlcheckboxes' template function generates a list of html checkboxes.
- * 
- * Usage:
- * {htmlcheckboxes name="x" options=$array}
- * {htmlcheckboxes name="x" options=$array selected=$foo}
- * {htmlcheckboxes name="x" output=$outputArray}
- * {htmlcheckboxes name="x" output=$outputArray values=$valueArray}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionHtmlcheckboxes implements ITemplatePluginFunction {
-       protected $disableEncoding = false;
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               // get options
-               if (isset($tagArgs['output']) && is_array($tagArgs['output'])) {
-                       if (isset($tagArgs['values']) && is_array($tagArgs['values'])) {
-                               $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']);
-                       }
-                       else {
-                               $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']);
-                       }
-               }
-
-               if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) {
-                       throw new SystemException("missing 'options' argument in htmlCheckboxes tag");
-               }
-               
-               if (!isset($tagArgs['name'])) {
-                       throw new SystemException("missing 'name' argument in htmlCheckboxes tag");
-               }
-               
-               if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) {
-                       $this->disableEncoding = true;
-               }
-               else {
-                       $this->disableEncoding = false;
-               }
-               
-               // get selected values
-               if (isset($tagArgs['selected'])) {
-                       if (!is_array($tagArgs['selected'])) $tagArgs['selected'] = array($tagArgs['selected']);        
-               }
-               else {
-                       $tagArgs['selected'] = array();
-               }
-               if (!isset($tagArgs['separator'])) {
-                       $tagArgs['separator'] = '';
-               }
-               
-               // build html
-               $html = '';
-               foreach ($tagArgs['options'] as $key => $value) {
-                       if (!empty($html)) $html .= $tagArgs['separator'];
-                       $html .= '<label><input type="checkbox" name="'.$this->encodeHTML($tagArgs['name']).'[]" value="'.$this->encodeHTML($key).'"'.(in_array($key, $tagArgs['selected']) ? ' checked="checked"' : '').' /> '.$this->encodeHTML($value).'</label>';                   
-               }
-               
-               return $html;
-       }
-       
-       /**
-        * Executes StringUtil::encodeHTML on the given text if disableEncoding is false.
-        * @see wcf\util\StringUtil::encodeHTML()
-        */
-       protected function encodeHTML($text) {
-               if (!$this->disableEncoding) {
-                       $text = StringUtil::encodeHTML($text);
-               }
-               
-               return $text;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmloptions.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionHtmloptions.class.php
deleted file mode 100644 (file)
index 7fa8c19..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\template\TemplateEngine;
-use wcf\util\StringUtil;
-
-/**
- * The 'htmloptions' template function generates the options of an html select list.
- * 
- * Usage:
- * {htmloptions options=$array}
- * {htmloptions options=$array selected=$foo}
- * {htmloptions options=$array name="x"}
- * {htmloptions output=$outputArray}
- * {htmloptions output=$outputArray values=$valueArray}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionHtmloptions extends TemplatePluginFunctionHtmlcheckboxes {
-       protected $selected = array();
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               if (isset($tagArgs['output']) && is_array($tagArgs['output'])) {
-                       if (count($tagArgs['output'])) {
-                               if (isset($tagArgs['values']) && is_array($tagArgs['values'])) {
-                                       if (count($tagArgs['output']) == count($tagArgs['values'])) {
-                                               $tagArgs['options'] = array_combine($tagArgs['values'], $tagArgs['output']);
-                                       }
-                                       else {
-                                               $tagArgs['options'] = array();
-                                       }
-                               }
-                               else {
-                                       $tagArgs['options'] = array_combine($tagArgs['output'], $tagArgs['output']);
-                               }
-                       }
-                       else {
-                               $tagArgs['options'] = array();
-                       }
-               }
-
-               if (!isset($tagArgs['options']) || !is_array($tagArgs['options'])) {
-                       throw new SystemException("missing 'options' argument in htmloptions tag");
-               }
-               
-               if (isset($tagArgs['disableEncoding']) && $tagArgs['disableEncoding']) {
-                       $this->disableEncoding = true;
-               }
-               else {
-                       $this->disableEncoding = false;
-               }
-               
-               // get selected values
-               $this->selected = array();
-               if (isset($tagArgs['selected'])) {
-                       $this->selected = $tagArgs['selected'];
-                       if (!is_array($this->selected)) $this->selected = array($this->selected);       
-               }
-               
-               // create option list
-               $htmloptions = $this->makeOptionGroup(null, $tagArgs['options']);
-               
-               // create also a 'select' tag
-               if (isset($tagArgs['name'])) {
-                       // unset all system vars
-                       unset($tagArgs['options'], $tagArgs['selected'], $tagArgs['output'], $tagArgs['values'], $tagArgs['disableEncoding']);
-                       
-                       // generate 'select' parameters
-                       $params = '';
-                       foreach ($tagArgs as $key => $value) {
-                               $params .= ' '.$key.'="'.$this->encodeHTML($value).'"';
-                       }
-                       
-                       $htmloptions = '<select'.$params.'>'."\n".$htmloptions."</select>\n";
-               }
-               
-               return $htmloptions;
-       }
-       
-       /**
-        * Makes the html for an option group.
-        * 
-        * @param       string          $key
-        * @param       array           $values
-        * @return      string                          html code of an option group
-        */
-       protected function makeOptionGroup($key, $values) {
-               $html = '';
-               if ($key !== null) {
-                       $html = '<optgroup label="'.$this->encodeHTML($key).'">'."\n";
-               }
-               
-               foreach ($values as $childKey => $value) {
-                       if (is_array($value)) {
-                               $html .= $this->makeOptionGroup($childKey, $value);
-                       }
-                       else {
-                               $html .= $this->makeOption($childKey, $value);
-                       }
-               }
-               
-               if ($key !== null) {
-                       $html .= "</optgroup>\n";
-               }
-               
-               return $html;
-       }
-       
-       /**
-        * Makes the html for an option.
-        * 
-        * @param       string          $key
-        * @param       string          $value
-        * @return      string                          html code of an option tag
-        */
-       protected function makeOption($key, $value) {
-               $value = $this->encodeHTML($value);
-               return '<option label="'.$value.'" value="'.$this->encodeHTML($key).'"'.(in_array($key, $this->selected) ? ' selected="selected"' : '').'>'.$value."</option>\n";
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionPages.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionPages.class.php
deleted file mode 100644 (file)
index 86f85c6..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\WCF;
-use wcf\system\exception\SystemException;
-use wcf\system\template\TemplateEngine;
-use wcf\system\template\ITemplatePluginFunction;
-use wcf\util\StringUtil;
-
-/**
- * The 'pages' template function is used to generate sliding pagers.
- * 
- * Usage:
- * {pages pages=10 link='page-%d.html'}
- * {pages page=8 pages=10 link='page-%d.html'}
- * 
- * assign to variable 'output'; do not print: 
- * {pages page=8 pages=10 link='page-%d.html' assign='output'}
- * 
- * assign to variable 'output' and do print also:
- * {pages page=8 pages=10 link='page-%d.html' assign='output' print=true}
- * 
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionPages implements ITemplatePluginFunction {
-       const SHOW_LINKS = 11;
-       const SHOW_SUB_LINKS = 20;
-       
-       /**
-        * Inserts the page number into the link.
-        * 
-        * @param       string          $link
-        * @param       integer         $pageNo
-        * @return      string          final link
-        */
-       protected static function insertPageNumber($link, $pageNo) {
-               $startPos = StringUtil::indexOf($link, '%d');
-               if ($startPos !== null) $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
-               return $link;
-       }
-       
-       /**
-        * Generates html code of a link.
-        * 
-        * @param       string          $link
-        * @param       integer         $pageNo
-        * @param       integer         $activePage
-        * @param       boolean         $break
-        * @return      string
-        */
-       protected function makeLink($link, $pageNo, $activePage, $break = false) {
-               // first page
-               if ($activePage != $pageNo) {
-                       return '<li'.($break ? ' class="break"' : '').'><a href="'.$this->insertPageNumber($link, $pageNo).'">'.StringUtil::formatInteger($pageNo).'</a></li>'."\n";
-               }
-               else {
-                       return '<li class="'.($break ? 'break ' : '').'active"><span>'.StringUtil::formatInteger($pageNo).'</span></li>'."\n";
-               }
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               // needed params: link, page, pages
-               if (!isset($tagArgs['link'])) throw new SystemException("missing 'link' argument in pages tag");
-               if (!isset($tagArgs['pages'])) {
-                       if (($tagArgs['pages'] = $tplObj->get('pages')) === null) {
-                               throw new SystemException("missing 'pages' argument in pages tag");
-                       }
-               }
-               
-               $html = '';
-               
-               if ($tagArgs['pages'] > 1) {
-                       // define page link for js function
-                       $html .= "<script type=\"text/javascript\">\n//<![CDATA[\nmultiPagesLinks.setPageLink('".StringUtil::replace("'", "\'", $tagArgs['link'])."');\n//]]>\n</script>";
-                       
-                       // encode link
-                       $tagArgs['link'] = StringUtil::encodeHTML($tagArgs['link']);
-               
-                       if (!isset($tagArgs['page'])) {
-                               if (($tagArgs['page'] = $tplObj->get('pageNo')) === null) {
-                                       $tagArgs['page'] = 0;
-                               }
-                       }
-                       
-                       // open div and ul
-                       $html .= "<div class=\"pageNavigation\">\n<ul>\n";
-                       
-                       // previous page
-                       $previousTitle = WCF::getLanguage()->getDynamicVariable('wcf.global.page.previous');
-                       if ($tagArgs['page'] > 1) {
-                               $html .= '<li class="skip"><a href="'.$this->insertPageNumber($tagArgs['link'], $tagArgs['page'] - 1).'" title="'.$previousTitle.'"><img src="'.self::getIconPath('previousS.png').'" alt="" /></a></li>'."\n";
-                       }
-                       else {
-                               $html .= '<li class="skip"><img src="'.self::getIconPath('previousDisabledS.png').'" alt="" /></li>'."\n";
-                       }
-                       
-                       // first page
-                       $html .= $this->makeLink($tagArgs['link'], 1, $tagArgs['page']);
-                       
-                       // calculate page links
-                       $maxLinks = self::SHOW_LINKS - 4;
-                       $linksBeforePage = $tagArgs['page'] - 2;
-                       if ($linksBeforePage < 0) $linksBeforePage = 0; 
-                       $linksAfterPage = $tagArgs['pages'] - ($tagArgs['page'] + 1);
-                       if ($linksAfterPage < 0) $linksAfterPage = 0; 
-                       if ($tagArgs['page'] > 1 && $tagArgs['page'] < $tagArgs['pages']) {
-                               $maxLinks--;
-                       }
-                       
-                       $half = $maxLinks / 2;
-                       $left = $right = $tagArgs['page'];
-                       if ($left < 1) $left = 1;
-                       if ($right < 1) $right = 1;
-                       if ($right > $tagArgs['pages'] - 1) $right = $tagArgs['pages'] - 1;
-                       
-                       if ($linksBeforePage >= $half) {
-                               $left -= $half;
-                       }
-                       else {
-                               $left -= $linksBeforePage;
-                               $right += $half - $linksBeforePage;
-                       }
-                       
-                       if ($linksAfterPage >= $half) {
-                               $right += $half;
-                       }
-                       else {
-                               $right += $linksAfterPage;
-                               $left -= $half - $linksAfterPage;
-                       }
-                       
-                       $right = intval(ceil($right));
-                       $left = intval(ceil($left));
-                       if ($left < 1) $left = 1;
-                       if ($right > $tagArgs['pages']) $right = $tagArgs['pages'];
-                       
-                       // left ... links
-                       if ($left > 1) {
-                               if ($left - 1 < 2) {
-                                       $html .= $this->makeLink($tagArgs['link'], 2, $tagArgs['page']);
-                               }
-                               else {
-                                       $html .= '<li class="children"><a onclick="multiPagesLinks.startPageNumberInput(this)">&hellip;<img src="'.self::getIconPath('arrowDown.png').'" alt="" /></a><input type="text" class="inputText" name="pageNo" /><div><ul>'."\n";
-                                       
-                                       $k = 0;
-                                       $step = intval(ceil(($left - 2) / self::SHOW_SUB_LINKS));
-                                       for ($i = 2; $i <= $left; $i += $step) {
-                                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page'], $k != 0 && $k % 4 == 0);
-                                               $k++;
-                                       }
-                                       
-                                       $html .= "</ul></div></li>\n";
-                               }
-                       }
-                       
-                       // visible links
-                       for ($i = $left + 1; $i < $right; $i++) {
-                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page']);
-                       }
-                       
-                       // right ... links
-                       if ($right < $tagArgs['pages']) {
-                               if ($tagArgs['pages'] - $right < 2) {
-                                       $html .= $this->makeLink($tagArgs['link'], $tagArgs['pages'] - 1, $tagArgs['page']);
-                               }
-                               else {
-                                       $html .= '<li class="children"><a onclick="multiPagesLinks.startPageNumberInput(this)">&hellip;<img src="'.self::getIconPath('arrowDown.png').'" alt="" /></a><input type="text" class="inputText" name="page" /><div><ul>'."\n";
-                                       
-                                       $k = 0;
-                                       $step = intval(ceil(($tagArgs['pages'] - $right) / self::SHOW_SUB_LINKS));
-                                       for ($i = $right; $i < $tagArgs['pages']; $i += $step) {
-                                               $html .= $this->makeLink($tagArgs['link'], $i, $tagArgs['page'], $k != 0 && $k % 4 == 0);
-                                               $k++;
-                                       }
-                                       
-                                       $html .= "</ul></div></li>\n";
-                               }
-                       }
-                       
-                       // last page
-                       $html .= $this->makeLink($tagArgs['link'], $tagArgs['pages'], $tagArgs['page']);
-                       
-                       // next page
-                       $nextTitle = WCF::getLanguage()->getDynamicVariable('wcf.global.page.next');
-                       if ($tagArgs['page'] && $tagArgs['page'] < $tagArgs['pages']) {
-                               $html .= '<li class="skip"><a href="'.$this->insertPageNumber($tagArgs['link'], $tagArgs['page'] + 1).'" title="'.$nextTitle.'"><img src="'.self::getIconPath('nextS.png').'" alt="" /></a></li>'."\n";
-                       }
-                       else {
-                               $html .= '<li class="skip"><img src="'.self::getIconPath('nextDisabledS.png').'" alt="" /></li>'."\n";
-                       }
-                       
-                       // close div and ul
-                       $html .= "</ul></div>\n";
-               }
-               
-               // assign html output to template var
-               if (isset($tagArgs['assign'])) {
-                       $tplObj->assign($tagArgs['assign'], $html);
-                       if (!isset($tagArgs['print']) || !$tagArgs['print']) return '';
-               }
-               
-               return $html;
-       }
-       
-       private static function getIconPath($filename) {
-               if (class_exists('StyleManager')) {
-                       return StyleManager::getStyle()->getIconPath($filename);
-               }
-               else {
-                       return RELATIVE_WCF_DIR.'icon/'.$filename;
-               }
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionSmallpages.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginFunctionSmallpages.class.php
deleted file mode 100644 (file)
index 2a6d12d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\WCF;
-use wcf\system\exception\SystemException;
-use wcf\system\template\TemplateEngine;
-use wcf\system\template\ITemplatePluginFunction;
-use wcf\util\StringUtil;
-
-/**
- * The 'smallpages' template function is used to generate simple sliding pagers.
- * 
- * Usage:
- * {smallpages pages=10 link='page-%d.html'}
- * 
- * assign to variable 'output'; do not print: 
- * {smallpages pages=10 link='page-%d.html' assign='output'}
- * 
- * assign to variable 'output' and do print also:
- * {smallpages pages=10 link='page-%d.html' assign='output' print=true}
- * 
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginFunctionSmallpages implements ITemplatePluginFunction {
-       const SHOW_LINKS = 5;
-       
-       /**
-        * Inserts the page number into the link.
-        * 
-        * @param       string          $link
-        * @param       integer         $pageNo
-        * @return      string          final link
-        */
-       protected static function insertPageNumber($link, $pageNo) {
-               $startPos = StringUtil::indexOf($link, '%d');
-               if ($startPos !== null) $link = StringUtil::substring($link, 0, $startPos) . $pageNo . StringUtil::substring($link, $startPos + 2);
-               return $link;
-       }
-       
-       /**
-        * Generates html code of a link.
-        * 
-        * @param       string          $link
-        * @param       integer         $pageNo
-        * @return      string
-        */
-       protected function makeLink($link, $pageNo) {
-               return '<li><a href="'.$this->insertPageNumber($link, $pageNo).'" title="' . WCF::getLanguage()->getDynamicVariable('wcf.page.pageNo', array('pageNo' => $pageNo)) . '">'.StringUtil::formatInteger($pageNo).'</a></li>'."\n";
-       }
-       
-       /**
-        * @see wcf\system\template\ITemplatePluginFunction::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               // needed params: link, pages
-               if (!isset($tagArgs['link'])) throw new SystemException("missing 'link' argument in pages tag");
-               if (!isset($tagArgs['pages'])) {
-                       if (($tagArgs['pages'] = $tplObj->get('pages')) === null) {
-                               throw new SystemException("missing 'pages' argument in pages tag");
-                       }
-               }
-               
-               $html = '';
-               if ($tagArgs['pages'] > 1) {
-                       // encode link
-                       $link = StringUtil::encodeHTML($tagArgs['link']);
-               
-                       // open div and ul
-                       $html .= "<div class=\"pageNavigation\">\n<ul>\n";
-                       
-                       // generate simple links
-                       $simpleLinks = $tagArgs['pages'];
-                       if ($simpleLinks > self::SHOW_LINKS) {
-                               $simpleLinks = self::SHOW_LINKS - 2;
-                       }
-                       
-                       for ($i = 1; $i <= $simpleLinks; $i++) {
-                               $html .= $this->makeLink($link, $i);
-                       }
-                       
-                       if ($tagArgs['pages'] > self::SHOW_LINKS) {
-                               // jumper
-                               $html .= '<li><a onclick="var result = prompt(\''.WCF::getLanguage()->get('wcf.global.page.input').'\', \''.$tagArgs['pages'].'\'); if (typeof(result) != \'object\' &amp;&amp; typeof(result) != \'undefined\') document.location.href = fixURL((\''.StringUtil::replace("'", "\'", $link).'\').replace(/%d/, result));">&hellip;</a></li>'."\n";
-
-                               // last page
-                               $html .= $this->makeLink($link, $tagArgs['pages']);
-                       }
-                       
-                       // close div and ul
-                       $html .= "</ul></div>\n";
-               }
-               
-               // assign html output to template var
-               if (isset($tagArgs['assign'])) {
-                       $tplObj->assign($tagArgs['assign'], $html);
-                       if (!isset($tagArgs['print']) || !$tagArgs['print']) return '';
-               }
-               
-               return $html;
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierArrayfromlist.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierArrayfromlist.class.php
deleted file mode 100644 (file)
index 49ae1c8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\data\option\Option;
-use wcf\system\template\TemplateEngine;
-use wcf\system\template\ITemplatePluginModifier;
-
-/**
- * The 'arrayfromlist' modifier generates an associative array out of a key-value list.
- * The list has key-value pairs separated by : with each pair on an own line:
- * 
- * Example list:
- * key1:value1
- * key2:value2
- * ...
- * 
- * Usage:
- * {$list|arrayfromlist}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginModifierArrayfromlist implements ITemplatePluginModifier {
-       /**
-        * @see wcf\system\template\ITemplatePluginModifier::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               return Option::parseSelectOptions($tagArgs[0]);
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierConcat.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierConcat.class.php
deleted file mode 100644 (file)
index f8cd763..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\exception\SystemException;
-use wcf\system\template\TemplateEngine;
-use wcf\system\template\ITemplatePluginModifier;
-
-/**
- * The 'concat' modifier returns the string that results from concatenating the arguments.
- * May have two or more arguments.
- * 
- * Usage:
- * {"left"|concat:$right}
- *
- * @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.plugin
- * @category   Community Framework
- */
-class TemplatePluginModifierConcat implements ITemplatePluginModifier {
-       /**
-        * @see wcf\system\template\ITemplatePluginModifier::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               if (count($tagArgs) < 2) {
-                       throw new SystemException("concat modifier needs two or more arguments");
-               }
-               
-               $result = '';
-               foreach ($tagArgs as $arg) {
-                       $result .= $arg;
-               }
-       
-               return $result; 
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierDate.class.php b/wcfsetup/install/files/lib/system/template/plugin/TemplatePluginModifierDate.class.php
deleted file mode 100644 (file)
index 6c5c373..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-namespace wcf\system\template\plugin;
-use wcf\system\template\TemplateEngine;
-use wcf\system\template\ITemplatePluginModifier;
-use wcf\util\DateUtil;
-
-/**
- * The 'date' modifier formats a unix timestamp.
- * Default date format contains year, month and day.
- * 
- * Usage:
- * {$timestamp|date}
- * {"132845333"|date:"Y-m-d"}
- *
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @subpackage system.template.plugin
- * @category   Community Framework
- */
-class TemplatePluginModifierDate implements ITemplatePluginModifier {
-       /**
-        * @see wcf\system\template\ITemplatePluginModifier::execute()
-        */
-       public function execute($tagArgs, TemplateEngine $tplObj) {
-               return DateUtil::format(DateUtil::getDateTimeByTimestamp($tagArgs[0]), (!empty($tagArgs[2]) ? $tagArgs[2] : DateUtil::DATE_FORMAT));
-       }
-}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TimeModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/TimeModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..57f6b5d
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\system\WCF;
+use wcf\util\DateUtil;
+
+/**
+ * The 'time' modifier formats a unix timestamp.
+ * Default date format contains year, month, day, hour and minute.
+ * 
+ * Usage:
+ * {$timestamp|time}
+ * {"132845333"|time}
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2011 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.template.plugin
+ * @category   Community Framework
+ */
+class TimeModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               $timestamp = intval($tagArgs[0]);
+               $dateTimeObject = DateUtil::getDateTimeByTimestamp($timestamp);
+               $date = DateUtil::format($dateTimeObject, DateUtil::DATE_FORMAT);
+               $time = DateUtil::format($dateTimeObject, DateUtil::TIME_FORMAT);
+               $dateTime = str_replace('%time%', $time, str_replace('%date%', $date, WCF::getLanguage()->get('wcf.global.date.dateTimeFormat')));
+               
+               return '<time datetime="'.DateUtil::format($dateTimeObject, 'c').'" class="datetime" data-timestamp="'.$timestamp.'" data-date="'.$date.'" data-time="'.$time.'" data-offset="'.$dateTimeObject->getOffset().'">'.$dateTime.'</time>';
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/template/plugin/TruncateModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/TruncateModifierTemplatePlugin.class.php
new file mode 100644 (file)
index 0000000..de59e25
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+namespace wcf\system\template\plugin;
+use wcf\system\template\TemplateEngine;
+use wcf\system\template\IModifierTemplatePlugin;
+use wcf\util\StringUtil;
+
+/**
+ * The 'truncate' modifier truncates a string.
+ * 
+ * Usage:
+ * {$foo|truncate:35:'...'}
+ *
+ * @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.plugin
+ * @category   Community Framework
+ */
+class TruncateModifierTemplatePlugin implements IModifierTemplatePlugin {
+       /**
+        * @see wcf\system\template\IModifierTemplatePlugin::execute()
+        */
+       public function execute($tagArgs, TemplateEngine $tplObj) {
+               // default values
+               $length = 80;
+               $etc = '...';
+               $breakWords = false;
+               
+               // get values
+               $string = $tagArgs[0];
+               if (isset($tagArgs[1])) $length = intval($tagArgs[1]);
+               if (isset($tagArgs[2])) $etc = $tagArgs[2];
+               if (isset($tagArgs[3])) $breakWords = $tagArgs[3];
+               
+               // execute plugin
+               if ($length == 0) {
+                       return '';
+               }
+
+               if (StringUtil::length($string) > $length) {
+                       $length -= StringUtil::length($etc);
+                       
+                       if (!$breakWords) {
+                               $string = preg_replace('/\s+?(\S+)?$/', '', StringUtil::substring($string, 0, $length + 1));
+                       }
+  
+                       return StringUtil::substring($string, 0, $length).$etc;
+               }
+               else {
+                       return $string;
+               }
+       }
+}