Files
admin
system
autoload
controllers
install
lan
uploads
vendors
mpdf
smarty
libs
plugins
block.textformat.php
function.counter.php
function.cycle.php
function.fetch.php
function.html_checkboxes.php
function.html_image.php
function.html_options.php
function.html_radios.php
function.html_select_date.php
function.html_select_time.php
function.html_table.php
function.mailto.php
function.math.php
index.html
modifier.capitalize.php
modifier.date_format.php
modifier.debug_print_var.php
modifier.escape.php
modifier.regex_replace.php
modifier.replace.php
modifier.spacify.php
modifier.truncate.php
modifiercompiler.cat.php
modifiercompiler.count_characters.php
modifiercompiler.count_paragraphs.php
modifiercompiler.count_sentences.php
modifiercompiler.count_words.php
modifiercompiler.default.php
modifiercompiler.escape.php
modifiercompiler.from_charset.php
modifiercompiler.indent.php
modifiercompiler.lower.php
modifiercompiler.noprint.php
modifiercompiler.string_format.php
modifiercompiler.strip.php
modifiercompiler.strip_tags.php
modifiercompiler.to_charset.php
modifiercompiler.unescape.php
modifiercompiler.upper.php
modifiercompiler.wordwrap.php
outputfilter.trimwhitespace.php
shared.escape_special_chars.php
shared.literal_compiler_param.php
shared.make_timestamp.php
shared.mb_str_replace.php
shared.mb_unicode.php
shared.mb_wordwrap.php
variablefilter.htmlspecialchars.php
sysplugins
.DS_Store
Smarty.class.php
SmartyBC.class.php
debug.tpl
index.html
COPYING.lib
index.html
.DS_Store
index.html
.DS_Store
boot.php
config.sample.php
cron.php
index.html
orm.php
ui
.DS_Store
.gitignore
LICENSE
README.md
index.php
mitrobill/system/vendors/smarty/libs/plugins/shared.literal_compiler_param.php

34 lines
1.0 KiB
PHP
Raw Normal View History

2017-03-11 02:51:06 +07:00
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsShared
*/
/**
* evaluate compiler parameter
*
* @param array $params parameter array as given to the compiler function
* @param integer $index array index of the parameter to convert
* @param mixed $default value to be returned if the parameter is not present
* @return mixed evaluated value of parameter or $default
* @throws SmartyException if parameter is not a literal (but an expression, variable, )
* @author Rodney Rehm
*/
function smarty_literal_compiler_param($params, $index, $default=null)
{
// not set, go default
if (!isset($params[$index])) {
return $default;
}
// test if param is a literal
if (!preg_match('/^([\'"]?)[a-zA-Z0-9]+(\\1)$/', $params[$index])) {
throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time');
}
$t = null;
eval("\$t = " . $params[$index] . ";");
return $t;
}