update smarty to version 3.1.27
authorStricted <info@stricted.de>
Thu, 18 Jun 2015 17:52:43 +0000 (19:52 +0200)
committerStricted <info@stricted.de>
Thu, 18 Jun 2015 17:52:43 +0000 (19:52 +0200)
lib/system/DNS.class.php
lib/system/api/smarty
lib/system/template/plugins/block.lang.php [new file with mode: 0644]
lib/system/template/plugins/function.pages.php [new file with mode: 0644]
lib/system/template/plugins/prefilter.hascontent.php [new file with mode: 0644]
lib/template/plugins/block.lang.php [deleted file]
lib/template/plugins/function.pages.php [deleted file]
lib/template/plugins/prefilter.hascontent.php [deleted file]

index 1ca2bb26ca4bbec68622c78ff5863b73d579e6bd..87edc9d57fd09338dd272caa1a371c6fbebed508 100644 (file)
@@ -289,7 +289,7 @@ class DNS {
                self::getTPL()->setCompileDir(DNS_DIR.(empty(self::$module) ? '' : '/'.self::$module)."/templates/compiled/".$tpl);
                self::getTPL()->setPluginsDir(array(
                        DNS_DIR."/lib/system/api/smarty/libs/plugins",
-                       DNS_DIR."/lib/template/plugins"
+                       DNS_DIR."/lib/system/template/plugins"
                ));
                self::getTPL()->loadFilter('pre', 'hascontent');
                
index 58616d6ee598674b682f8a2b81352ec4da7100c7..4537d8aae6c4a26f5439bc3a05d3437d25c2c4d2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 58616d6ee598674b682f8a2b81352ec4da7100c7
+Subproject commit 4537d8aae6c4a26f5439bc3a05d3437d25c2c4d2
diff --git a/lib/system/template/plugins/block.lang.php b/lib/system/template/plugins/block.lang.php
new file mode 100644 (file)
index 0000000..ed89977
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty plugin to format text blocks
+ *
+ * @author      Jan Altensen (Stricted)
+ * @copyright   2013-2015 Jan Altensen (Stricted)
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     Smarty
+ * @subpackage  PluginsBlock
+ */
+
+/**
+ * Smarty {lang}{/lang} block plugin
+ */
+function smarty_block_lang($params, $content, $template, &$repeat) {
+       if ($content === null || empty($content)) {
+               return;
+       }
+       
+       $lang = $template->smarty->getTemplateVars('language');
+       
+       if ($lang === null) {
+               return $content;
+       }
+       
+       $content = str_replace(array("'", '"'), "", $content);
+       
+       if (isset($lang[$content])) {
+               if (strpos($lang[$content], $template->smarty->left_delimiter) !== false && strpos($lang[$content], $template->smarty->right_delimiter) !== false) {
+                       $data = str_replace("\$", '$', $lang[$content]);
+                       $_template = new $template->smarty->template_class('eval:'.$data, $template->smarty, $template);
+                       return $_template->fetch();
+               }
+               
+               return $lang[$content];
+       }
+       
+       return $content;
+}
diff --git a/lib/system/template/plugins/function.pages.php b/lib/system/template/plugins/function.pages.php
new file mode 100644 (file)
index 0000000..7408973
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+use dns\system\DNS;
+
+function smarty_function_pages($tagArgs, $tplObj) {
+       // needed params: controller, pageNo, pages
+       if (!isset($tagArgs['controller'])) throw new Exception("missing 'controller' argument in pages tag");
+       if (!isset($tagArgs['pageNo'])) {
+               if (($tagArgs['pageNo'] = $tplObj->smarty->getTemplateVars('pageNo')) === null) {
+                       throw new Exception("missing 'pageNo' argument in pages tag");
+               }
+       }
+       if (!isset($tagArgs['pages'])) {
+               if (($tagArgs['pages'] = $tplObj->smarty->getTemplateVars('pages')) === null) {
+                       throw new Exception("missing 'pages' argument in pages tag");
+               }
+       }
+       
+       $html = '';
+       
+       if ($tagArgs['pages'] > 1) {
+               $link = "index.php?page=".$tagArgs['controller'].(isset($tagArgs['id']) ? "&id=".$tagArgs['id'] : "");
+               
+               if (!isset($tagArgs['pageNo'])) {
+                       if (($tagArgs['pageNo'] = $tplObj->smarty->getTemplateVars('pageNo')) === null) {
+                               $tagArgs['pageNo'] = 0;
+                       }
+               }
+               
+               // open div and ul
+               $html .= "<nav>\n<ul class='pagination'>\n";
+               
+               // previous page
+               $html .= makePreviousLink($link, $tagArgs['pageNo']);
+               
+               // first page
+               $html .= makeLink($link, 1, $tagArgs['pageNo'], $tagArgs['pages']);
+               
+               // calculate page links
+               $maxLinks = 7;
+               $linksBeforePage = $tagArgs['pageNo'] - 2;
+               if ($linksBeforePage < 0) $linksBeforePage = 0;
+               $linksAfterPage = $tagArgs['pages'] - ($tagArgs['pageNo'] + 1);
+               if ($linksAfterPage < 0) $linksAfterPage = 0;
+               if ($tagArgs['pageNo'] > 1 && $tagArgs['pageNo'] < $tagArgs['pages']) {
+                       $maxLinks--;
+               }
+               
+               $half = $maxLinks / 2;
+               $left = $right = $tagArgs['pageNo'];
+               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 .= makeLink($link, 2, $tagArgs['pageNo'], $tagArgs['pages']);
+                       }
+                       else {
+                               $html .= '<li class="button jumpTo"><a>&hellip;</a></li>'."\n";
+                       }
+               }
+               
+               // visible links
+               for ($i = $left + 1; $i < $right; $i++) {
+                       $html .= makeLink($link, $i, $tagArgs['pageNo'], $tagArgs['pages']);
+               }
+               
+               // right ... links
+               if ($right < $tagArgs['pages']) {
+                       if ($tagArgs['pages'] - $right < 2) {
+                               $html .= makeLink($link, $tagArgs['pages'] - 1, $tagArgs['pageNo'], $tagArgs['pages']);
+                       }
+                       else {
+                               $html .= '<li class="button jumpTo"><a>&hellip;</a></li>'."\n";
+                       }
+               }
+               
+               // last page
+               $html .= makeLink($link, $tagArgs['pages'], $tagArgs['pageNo'], $tagArgs['pages']);
+               
+               // next page
+               $html .= makeNextLink($link, $tagArgs['pageNo'], $tagArgs['pages']);
+               
+               // close div and ul
+               $html .= "</ul></nav>\n";
+       }
+       
+       // assign html output to template var
+       if (isset($tagArgs['assign'])) {
+               $tplObj->assign($tagArgs['assign'], $html);
+       }
+       
+       return $html;
+}
+
+function insertPageNumber($link, $pageNo) {
+       $link = $link ."&pageNo=".$pageNo;
+       return $link;
+}
+
+function makeLink($link, $pageNo, $activePage, $pages) {
+       // first page
+       if ($activePage != $pageNo) {
+               return '<li><a href="'.insertPageNumber($link, $pageNo).'" class="ttips" title="'.DNS::getLanguageVariable('pagination.page', array('page' => $pageNo)).'">'.intval($pageNo).'</a></li>'."\n";
+       }
+       else {
+               return '<li class="active"><a>'.intval($pageNo).'</a></li>'."\n";
+       }
+}
+
+function makePreviousLink($link, $pageNo) {
+       if ($pageNo > 1) {
+               return '<li class="skip"><a href="'.insertPageNumber($link, $pageNo - 1).'" title="'.DNS::getLanguageVariable('pagination.previous').'" class="ttips"><span class="fa fa-angle-double-left"></span></a></li>'."\n";
+       }
+       else {
+               return '<li class="skip disabled"><span class="fa fa-angle-double-left disabled"></span></li>'."\n";
+       }
+}
+
+
+function makeNextLink($link, $pageNo, $pages) {
+       if ($pageNo && $pageNo < $pages) {
+               return '<li class="skip"><a href="'.insertPageNumber($link, $pageNo + 1).'" title="'.DNS::getLanguageVariable('pagination.next').'" class="ttips"><span class="fa fa-angle-double-right"></span></a></li>'."\n";
+       }
+       else {
+               return '<li class="skip disabled"><span class="fa fa-angle-double-right disabled"></span></li>'."\n";
+       }
+}
diff --git a/lib/system/template/plugins/prefilter.hascontent.php b/lib/system/template/plugins/prefilter.hascontent.php
new file mode 100644 (file)
index 0000000..3049954
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Template prefiler plugin which allows inserting 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-2014 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
+ */
+
+function smarty_prefilter_hascontent($source, &$smarty) {
+       $ldq = preg_quote($smarty->left_delimiter, '~');
+       $rdq = preg_quote($smarty->right_delimiter, '~');
+       
+       $source = preg_replace_callback("~{$ldq}hascontent( assign='(?P<assign>.*)')?{$rdq}(?P<before>.*){$ldq}content{$rdq}(?P<content>.*){$ldq}\/content{$rdq}(?P<after>.*)({$ldq}hascontentelse{$rdq}(?P<else>.*))?{$ldq}\/hascontent{$rdq}~sU", function ($matches) {
+               $beforeContent = $matches['before'];
+               $content = $matches['content'];
+               $afterContent = $matches['after'];
+               $elseContent = (isset($matches['else'])) ? $matches['else'] : '';
+               $assignContent = (isset($matches['assign']) && !empty($matches['assign'])) ? $matches['assign'] : '';
+               $variable = 'hascontent_' . sha1(time());
+               
+               $newContent = '{capture assign='.$variable.'}'.$content.'{/capture}'."\n";
+               $newContent .= '{assign var='.$variable.' value=$'.$variable.'|trim}'."\n";
+               
+               if ($assignContent) $newContent .= '{capture assign='.$assignContent.'}'."\n";
+               $newContent .= '{if $'.$variable.'}'.$beforeContent.'{$'.$variable.'}'."\n".$afterContent;
+               
+               if (!empty($elseContent)) {
+                       $newContent .= '{else}'.$elseContent."\n";
+               }
+               
+               $newContent .= '{/if}'."\n";
+               
+               if ($assignContent) $newContent .= "{/capture}\n{\$".$assignContent."}\n";
+               
+               return $newContent;
+       }, $source);
+       
+       return $source;
+}
diff --git a/lib/template/plugins/block.lang.php b/lib/template/plugins/block.lang.php
deleted file mode 100644 (file)
index ed89977..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Smarty plugin to format text blocks
- *
- * @author      Jan Altensen (Stricted)
- * @copyright   2013-2015 Jan Altensen (Stricted)
- * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package     Smarty
- * @subpackage  PluginsBlock
- */
-
-/**
- * Smarty {lang}{/lang} block plugin
- */
-function smarty_block_lang($params, $content, $template, &$repeat) {
-       if ($content === null || empty($content)) {
-               return;
-       }
-       
-       $lang = $template->smarty->getTemplateVars('language');
-       
-       if ($lang === null) {
-               return $content;
-       }
-       
-       $content = str_replace(array("'", '"'), "", $content);
-       
-       if (isset($lang[$content])) {
-               if (strpos($lang[$content], $template->smarty->left_delimiter) !== false && strpos($lang[$content], $template->smarty->right_delimiter) !== false) {
-                       $data = str_replace("\$", '$', $lang[$content]);
-                       $_template = new $template->smarty->template_class('eval:'.$data, $template->smarty, $template);
-                       return $_template->fetch();
-               }
-               
-               return $lang[$content];
-       }
-       
-       return $content;
-}
diff --git a/lib/template/plugins/function.pages.php b/lib/template/plugins/function.pages.php
deleted file mode 100644 (file)
index 7408973..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-use dns\system\DNS;
-
-function smarty_function_pages($tagArgs, $tplObj) {
-       // needed params: controller, pageNo, pages
-       if (!isset($tagArgs['controller'])) throw new Exception("missing 'controller' argument in pages tag");
-       if (!isset($tagArgs['pageNo'])) {
-               if (($tagArgs['pageNo'] = $tplObj->smarty->getTemplateVars('pageNo')) === null) {
-                       throw new Exception("missing 'pageNo' argument in pages tag");
-               }
-       }
-       if (!isset($tagArgs['pages'])) {
-               if (($tagArgs['pages'] = $tplObj->smarty->getTemplateVars('pages')) === null) {
-                       throw new Exception("missing 'pages' argument in pages tag");
-               }
-       }
-       
-       $html = '';
-       
-       if ($tagArgs['pages'] > 1) {
-               $link = "index.php?page=".$tagArgs['controller'].(isset($tagArgs['id']) ? "&id=".$tagArgs['id'] : "");
-               
-               if (!isset($tagArgs['pageNo'])) {
-                       if (($tagArgs['pageNo'] = $tplObj->smarty->getTemplateVars('pageNo')) === null) {
-                               $tagArgs['pageNo'] = 0;
-                       }
-               }
-               
-               // open div and ul
-               $html .= "<nav>\n<ul class='pagination'>\n";
-               
-               // previous page
-               $html .= makePreviousLink($link, $tagArgs['pageNo']);
-               
-               // first page
-               $html .= makeLink($link, 1, $tagArgs['pageNo'], $tagArgs['pages']);
-               
-               // calculate page links
-               $maxLinks = 7;
-               $linksBeforePage = $tagArgs['pageNo'] - 2;
-               if ($linksBeforePage < 0) $linksBeforePage = 0;
-               $linksAfterPage = $tagArgs['pages'] - ($tagArgs['pageNo'] + 1);
-               if ($linksAfterPage < 0) $linksAfterPage = 0;
-               if ($tagArgs['pageNo'] > 1 && $tagArgs['pageNo'] < $tagArgs['pages']) {
-                       $maxLinks--;
-               }
-               
-               $half = $maxLinks / 2;
-               $left = $right = $tagArgs['pageNo'];
-               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 .= makeLink($link, 2, $tagArgs['pageNo'], $tagArgs['pages']);
-                       }
-                       else {
-                               $html .= '<li class="button jumpTo"><a>&hellip;</a></li>'."\n";
-                       }
-               }
-               
-               // visible links
-               for ($i = $left + 1; $i < $right; $i++) {
-                       $html .= makeLink($link, $i, $tagArgs['pageNo'], $tagArgs['pages']);
-               }
-               
-               // right ... links
-               if ($right < $tagArgs['pages']) {
-                       if ($tagArgs['pages'] - $right < 2) {
-                               $html .= makeLink($link, $tagArgs['pages'] - 1, $tagArgs['pageNo'], $tagArgs['pages']);
-                       }
-                       else {
-                               $html .= '<li class="button jumpTo"><a>&hellip;</a></li>'."\n";
-                       }
-               }
-               
-               // last page
-               $html .= makeLink($link, $tagArgs['pages'], $tagArgs['pageNo'], $tagArgs['pages']);
-               
-               // next page
-               $html .= makeNextLink($link, $tagArgs['pageNo'], $tagArgs['pages']);
-               
-               // close div and ul
-               $html .= "</ul></nav>\n";
-       }
-       
-       // assign html output to template var
-       if (isset($tagArgs['assign'])) {
-               $tplObj->assign($tagArgs['assign'], $html);
-       }
-       
-       return $html;
-}
-
-function insertPageNumber($link, $pageNo) {
-       $link = $link ."&pageNo=".$pageNo;
-       return $link;
-}
-
-function makeLink($link, $pageNo, $activePage, $pages) {
-       // first page
-       if ($activePage != $pageNo) {
-               return '<li><a href="'.insertPageNumber($link, $pageNo).'" class="ttips" title="'.DNS::getLanguageVariable('pagination.page', array('page' => $pageNo)).'">'.intval($pageNo).'</a></li>'."\n";
-       }
-       else {
-               return '<li class="active"><a>'.intval($pageNo).'</a></li>'."\n";
-       }
-}
-
-function makePreviousLink($link, $pageNo) {
-       if ($pageNo > 1) {
-               return '<li class="skip"><a href="'.insertPageNumber($link, $pageNo - 1).'" title="'.DNS::getLanguageVariable('pagination.previous').'" class="ttips"><span class="fa fa-angle-double-left"></span></a></li>'."\n";
-       }
-       else {
-               return '<li class="skip disabled"><span class="fa fa-angle-double-left disabled"></span></li>'."\n";
-       }
-}
-
-
-function makeNextLink($link, $pageNo, $pages) {
-       if ($pageNo && $pageNo < $pages) {
-               return '<li class="skip"><a href="'.insertPageNumber($link, $pageNo + 1).'" title="'.DNS::getLanguageVariable('pagination.next').'" class="ttips"><span class="fa fa-angle-double-right"></span></a></li>'."\n";
-       }
-       else {
-               return '<li class="skip disabled"><span class="fa fa-angle-double-right disabled"></span></li>'."\n";
-       }
-}
diff --git a/lib/template/plugins/prefilter.hascontent.php b/lib/template/plugins/prefilter.hascontent.php
deleted file mode 100644 (file)
index 3049954..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Template prefiler plugin which allows inserting 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-2014 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
- */
-
-function smarty_prefilter_hascontent($source, &$smarty) {
-       $ldq = preg_quote($smarty->left_delimiter, '~');
-       $rdq = preg_quote($smarty->right_delimiter, '~');
-       
-       $source = preg_replace_callback("~{$ldq}hascontent( assign='(?P<assign>.*)')?{$rdq}(?P<before>.*){$ldq}content{$rdq}(?P<content>.*){$ldq}\/content{$rdq}(?P<after>.*)({$ldq}hascontentelse{$rdq}(?P<else>.*))?{$ldq}\/hascontent{$rdq}~sU", function ($matches) {
-               $beforeContent = $matches['before'];
-               $content = $matches['content'];
-               $afterContent = $matches['after'];
-               $elseContent = (isset($matches['else'])) ? $matches['else'] : '';
-               $assignContent = (isset($matches['assign']) && !empty($matches['assign'])) ? $matches['assign'] : '';
-               $variable = 'hascontent_' . sha1(time());
-               
-               $newContent = '{capture assign='.$variable.'}'.$content.'{/capture}'."\n";
-               $newContent .= '{assign var='.$variable.' value=$'.$variable.'|trim}'."\n";
-               
-               if ($assignContent) $newContent .= '{capture assign='.$assignContent.'}'."\n";
-               $newContent .= '{if $'.$variable.'}'.$beforeContent.'{$'.$variable.'}'."\n".$afterContent;
-               
-               if (!empty($elseContent)) {
-                       $newContent .= '{else}'.$elseContent."\n";
-               }
-               
-               $newContent .= '{/if}'."\n";
-               
-               if ($assignContent) $newContent .= "{/capture}\n{\$".$assignContent."}\n";
-               
-               return $newContent;
-       }, $source);
-       
-       return $source;
-}