gehe zur Dokumentation dieser Datei
27 static $_allowed_funcs = array(
28 'int' =>
true,
'abs' =>
true,
'ceil' =>
true,
'cos' =>
true,
'exp' =>
true,
'floor' =>
true,
29 'log' =>
true,
'log10' =>
true,
'max' =>
true,
'min' =>
true,
'pi' =>
true,
'pow' =>
true,
30 'rand' =>
true,
'round' =>
true,
'sin' =>
true,
'sqrt' =>
true,
'srand' =>
true,
'tan' =>
true
33 if (empty($params[
'equation'])) {
34 trigger_error(
"math: missing equation parameter", E_USER_WARNING);
39 $equation = $params[
'equation'];
42 if (substr_count($equation,
"(") != substr_count($equation,
")")) {
43 trigger_error(
"math: unbalanced parenthesis", E_USER_WARNING);
49 preg_match_all(
"!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
51 foreach ($match[1] as $curr_var) {
52 if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
53 trigger_error(
"math: function call $curr_var not allowed", E_USER_WARNING);
59 foreach ($params as $key => $val) {
60 if ($key !=
"equation" && $key !=
"format" && $key !=
"assign") {
62 if (strlen($val) == 0) {
63 trigger_error(
"math: parameter $key is empty", E_USER_WARNING);
67 if (!is_numeric($val)) {
68 trigger_error(
"math: parameter $key: is not numeric", E_USER_WARNING);
72 $equation = preg_replace(
"/\b$key\b/",
" \$params['$key'] ", $equation);
75 $smarty_math_result = null;
76 eval(
"\$smarty_math_result = " . $equation .
";");
78 if (empty($params[
'format'])) {
79 if (empty($params[
'assign'])) {
80 return $smarty_math_result;
82 $template->assign($params[
'assign'], $smarty_math_result);
85 if (empty($params[
'assign'])) {
86 printf($params[
'format'], $smarty_math_result);
88 $template->assign($params[
'assign'], sprintf($params[
'format'], $smarty_math_result));
Sie sind hier: Home » MyOOS Benutzerhandbuch » Smarty
Korrekturen, Hinweise und Ergänzungen
Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag
Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.