Fixed icon prefilter
authorMarcel Werk <burntime@woltlab.com>
Thu, 27 Oct 2011 15:49:19 +0000 (17:49 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 27 Oct 2011 15:49:19 +0000 (17:49 +0200)
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/template/plugin/IconPrefilterTemplatePlugin.class.php

index c754e06534fa1257a1c33e77c49229d265546d90..5b5df17a3d250ab8c03679b35a517445f595e4b6 100644 (file)
@@ -467,7 +467,7 @@ class WCF {
         * Assigns some default variables to the template engine.
         */
        protected function assignDefaultTemplateVariables() {
-               self::getTPL()->registerPrefilter(array('event', 'hascontent', 'lang'));
+               self::getTPL()->registerPrefilter(array('event', 'hascontent', 'lang', 'icon'));
                self::getTPL()->assign(array('__wcf' => $this));
        }
        
index 6d290afc96b2468295a1b035a1e4d6ff2f68f648..fbfb7f5d3c2ab4693c247f5b177b99279565269d 100644 (file)
@@ -6,7 +6,7 @@ use wcf\system\template\TemplateScriptingCompiler;
  * The 'icon' prefilter compiles static icon paths.
  * 
  * Usage:
- * {icon}iconS.png{/icon}
+ * {icon size='L'}iconS.png{/icon}
  *
  * @author     Marcel Werk
  * @copyright  2001-2011 WoltLab GmbH
@@ -19,10 +19,10 @@ class IconPrefilterTemplatePlugin implements IPrefilterTemplatePlugin {
        /**
         * @see wcf\system\template\ITemplatePluginPrefilter::execute()
         */
-       public function execute($sourceContent, TemplateScriptingCompiler $compiler) {
+       public function execute($templateName, $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);
+               $sourceContent = preg_replace("~{$ldq}icon size='?(S|M|L)'?{$rdq}([\w\.]+){$ldq}/icon{$rdq}~", '{literal}<?php echo \wcf\system\style\StyleHandler::getInstance()->getStyle()->getIconPath(\'$2\', \'$1\'); ?>{/literal}', $sourceContent);
 
                return $sourceContent;
        }