Fixes and simplifies counter template plugin
authorMatthias Schmidt <gravatronics@live.com>
Mon, 26 Dec 2011 22:08:15 +0000 (23:08 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 26 Dec 2011 22:08:15 +0000 (23:08 +0100)
Doesn't work at the moment as you can see in the acp of a standalone application in the cache list ({$cacheIndex} is always 0).

wcfsetup/install/files/lib/system/template/plugin/CounterFunctionTemplatePlugin.class.php

index fba1166534cdebea48c8d683fcea323736ad1143..f99488c38bf8c8f763aadfb6dadcd6667aeb3cfc 100644 (file)
@@ -29,42 +29,26 @@ class CounterFunctionTemplatePlugin implements IFunctionTemplatePlugin {
 
                if (!isset($this->counters[$tagArgs['name']])) {
                        $this->counters[$tagArgs['name']] = array(
-                               'start' => 1,
-                               'skip' => 1,
-                               'direction' => 'up',
-                               'count' => 1
+                               'skip' => isset($tagArgs['skip']) ? $tagArgs['skip'] : 1,
+                               'direction' => isset($tagArgs['direction']) ? $tagArgs['direction'] : 'up',
+                               'assign' => (isset($tagArgs['assign']) && !empty($tagArgs['assign'])) ? $tagArgs['assign'] : null,
+                               'print' => isset($tagArgs['print']) ? $tagArgs['print'] : false,
+                               'count' => isset($tagArgs['start']) ? $tagArgs['start'] : 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'])) {
+               if ($counter['assign'] != null) {
                        $tplObj->assign($counter['assign'], $counter['count']);
                }
 
-               $result = null;
-               if (!isset($tagArgs['print']) || $tagArgs['print']) {
+               $result = '';
+               if ($counter['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') {
+               if ($counter['direction'] == 'down') {
                        $counter['count'] -= $counter['skip'];
                }
                else {