| 1 | <?php |
| 2 | /** |
| 3 | * Smarty plugin to format text blocks |
| 4 | * |
| 5 | * @author Jan Altensen (Stricted) |
| 6 | * @copyright 2013-2016 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 ($content === null || empty($content)) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | $lang = $template->smarty->getTemplateVars('language'); |
| 21 | |
| 22 | if ($lang === null) { |
| 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 | } |