From: Stricted Date: Thu, 18 Jun 2015 17:52:43 +0000 (+0200) Subject: update smarty to version 3.1.27 X-Git-Url: https://git.stricted.de/?p=GitHub%2FStricted%2FDomain-Control-Panel.git;a=commitdiff_plain;h=64ff9617e9008c62c55cf4306dd1b836d80157e3 update smarty to version 3.1.27 --- diff --git a/lib/system/DNS.class.php b/lib/system/DNS.class.php index 1ca2bb2..87edc9d 100644 --- a/lib/system/DNS.class.php +++ b/lib/system/DNS.class.php @@ -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'); diff --git a/lib/system/api/smarty b/lib/system/api/smarty index 58616d6..4537d8a 160000 --- a/lib/system/api/smarty +++ b/lib/system/api/smarty @@ -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 index 0000000..ed89977 --- /dev/null +++ b/lib/system/template/plugins/block.lang.php @@ -0,0 +1,39 @@ + + * @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 index 0000000..7408973 --- /dev/null +++ b/lib/system/template/plugins/function.pages.php @@ -0,0 +1,150 @@ +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 .= "\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 '
  • '.intval($pageNo).'
  • '."\n"; + } + else { + return '
  • '.intval($pageNo).'
  • '."\n"; + } +} + +function makePreviousLink($link, $pageNo) { + if ($pageNo > 1) { + return ''."\n"; + } + else { + return ''."\n"; + } +} + + +function makeNextLink($link, $pageNo, $pages) { + if ($pageNo && $pageNo < $pages) { + return ''."\n"; + } + else { + return ''."\n"; + } +} diff --git a/lib/system/template/plugins/prefilter.hascontent.php b/lib/system/template/plugins/prefilter.hascontent.php new file mode 100644 index 0000000..3049954 --- /dev/null +++ b/lib/system/template/plugins/prefilter.hascontent.php @@ -0,0 +1,55 @@ + + * {content} + * {if $foo}
  • bar
  • {/if} + * {/content} + * + * {hascontentelse} + *

    baz

    + * {/hascontent} + * + * @author Alexander Ebert + * @copyright 2001-2014 WoltLab GmbH + * @license GNU Lesser General Public License + * @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.*)')?{$rdq}(?P.*){$ldq}content{$rdq}(?P.*){$ldq}\/content{$rdq}(?P.*)({$ldq}hascontentelse{$rdq}(?P.*))?{$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 index ed89977..0000000 --- a/lib/template/plugins/block.lang.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @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 index 7408973..0000000 --- a/lib/template/plugins/function.pages.php +++ /dev/null @@ -1,150 +0,0 @@ -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 .= "\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 '
  • '.intval($pageNo).'
  • '."\n"; - } - else { - return '
  • '.intval($pageNo).'
  • '."\n"; - } -} - -function makePreviousLink($link, $pageNo) { - if ($pageNo > 1) { - return ''."\n"; - } - else { - return ''."\n"; - } -} - - -function makeNextLink($link, $pageNo, $pages) { - if ($pageNo && $pageNo < $pages) { - return ''."\n"; - } - else { - return ''."\n"; - } -} diff --git a/lib/template/plugins/prefilter.hascontent.php b/lib/template/plugins/prefilter.hascontent.php deleted file mode 100644 index 3049954..0000000 --- a/lib/template/plugins/prefilter.hascontent.php +++ /dev/null @@ -1,55 +0,0 @@ - - * {content} - * {if $foo}
  • bar
  • {/if} - * {/content} - * - * {hascontentelse} - *

    baz

    - * {/hascontent} - * - * @author Alexander Ebert - * @copyright 2001-2014 WoltLab GmbH - * @license GNU Lesser General Public License - * @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.*)')?{$rdq}(?P.*){$ldq}content{$rdq}(?P.*){$ldq}\/content{$rdq}(?P.*)({$ldq}hascontentelse{$rdq}(?P.*))?{$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; -}