update to smarty v3.1.24
[GitHub/Stricted/Domain-Control-Panel.git] / lib / api / smarty / plugins / block.lang.php
1 <?php
2 /**
3 * Smarty plugin to format text blocks
4 *
5 * @author Jan Altensen (Stricted)
6 * @copyright 2013-2015 Jan Altensen (Stricted)
7 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
8 * @package Smarty
9 * @subpackage PluginsBlock
10 */
11
12 /**
13 * Smarty {lang}{/lang} block plugin
14 */
15 function smarty_block_lang($params, $content, $template, &$repeat) {
16 if (is_null($content) || empty($content)) {
17 return;
18 }
19
20 $lang = $template->smarty->getTemplateVars('language');
21
22 if (is_null($lang)) {
23 return $content;
24 }
25
26 $content = str_replace(array("'", '"'), "", $content);
27
28 if (isset($lang[$content])) {
29 if (strpos($lang[$content], $template->smarty->left_delimiter) !== false && strpos($lang[$content], $template->smarty->right_delimiter) !== false) {
30 $data = str_replace("\$", '$', $lang[$content]);
31 $_template = new $template->smarty->template_class('eval:'.$data, $template->smarty, $template);
32 return $_template->fetch();
33 }
34
35 return $lang[$content];
36 }
37
38 return $content;
39 }