/branches/ant-ng/lib/init.php |
---|
Файл удален |
/branches/ant-ng/lib/Security.class.php |
---|
Новый файл |
0,0 → 1,84 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage Security |
* @author Uwe Tews |
*/ |
/** |
* This class does contain the security settings |
*/ |
class Smarty_Security_Policy { |
/** |
* This determines how Smarty handles "<?php ... ?>" tags in templates. |
* possible values: |
* <ul> |
* <li>SMARTY_PHP_PASSTHRU -> echo PHP tags as they are</li> |
* <li>SMARTY_PHP_QUOTE -> escape tags as entities</li> |
* <li>SMARTY_PHP_REMOVE -> remove php tags</li> |
* <li>SMARTY_PHP_ALLOW -> execute php tags</li> |
* </ul> |
* |
* @var integer |
*/ |
public $php_handling = SMARTY_PHP_PASSTHRU; |
/** |
* This is the list of template directories that are considered secure. |
* One directory per array element. |
* $template_dir is in this list implicitly. |
* |
* @var array |
*/ |
public $secure_dir = array(); |
/** |
* This is an array of directories where trusted php scripts reside. |
* {@link $security} is disabled during their inclusion/execution. |
* |
* @var array |
*/ |
public $trusted_dir = array(); |
/** |
* This is an array of trusted PHP functions. |
* |
* If empty all functions are allowed. |
* If set to 'none' none is allowed. |
* @var array |
*/ |
public $php_functions = array('isset', 'empty', |
'count', 'sizeof','in_array', 'is_array','time','nl2br'); |
/** |
* This is an array of trusted modifers. |
* |
* If empty all modifiers are allowed. |
* If set to 'none' none is allowed. |
* @var array |
*/ |
public $modifiers = array('escape','count'); |
/** |
* This is an array of trusted streams. |
* |
* If empty all streams are allowed. |
* If set to 'none' none is allowed. |
* @var array |
*/ |
public $streams = array('file'); |
/** |
+ flag if constants can be accessed from template |
*/ |
public $allow_constants = true; |
/** |
+ flag if {php} tag can be executed |
*/ |
public $allow_php_tag = false; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.lower.php |
---|
Новый файл |
0,0 → 1,30 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty lower modifier plugin |
* |
* Type: modifier<br> |
* Name: lower<br> |
* Purpose: convert string to lowercase |
* |
* @link http://smarty.php.net/manual/en/language.modifier.lower.php lower (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $ |
* @return string |
*/ |
function smarty_modifier_lower($string) |
{ |
if (function_exists('mb_strtolower')) { |
return mb_strtolower($string); |
} else { |
return strtolower($string); |
} |
} |
?> |
/branches/ant-ng/lib/plugins/block.textformat.php |
---|
Новый файл |
0,0 → 1,103 |
<?php |
/** |
* Smarty plugin to format text blocks |
* |
* @package Smarty |
* @subpackage PluginsBlock |
*/ |
/** |
* Smarty {textformat}{/textformat} block plugin |
* |
* Type: block function<br> |
* Name: textformat<br> |
* Purpose: format text a certain way with preset styles |
* or custom wrap/indent settings<br> |
* |
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} |
(Smarty online manual) |
* @param array $params parameters |
* <pre> |
* Params: style: string (email) |
* indent: integer (0) |
* wrap: integer (80) |
* wrap_char string ("\n") |
* indent_char: string (" ") |
* wrap_boundary: boolean (true) |
* </pre> |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $content contents of the block |
* @param object $smarty Smarty object |
* @param boolean &$repeat repeat flag |
* @param object $template template object |
* @return string content re-formatted |
*/ |
function smarty_block_textformat($params, $content, $smarty, &$repeat, $template) |
{ |
if (is_null($content)) { |
return; |
} |
$style = null; |
$indent = 0; |
$indent_first = 0; |
$indent_char = ' '; |
$wrap = 80; |
$wrap_char = "\n"; |
$wrap_cut = false; |
$assign = null; |
foreach ($params as $_key => $_val) { |
switch ($_key) { |
case 'style': |
case 'indent_char': |
case 'wrap_char': |
case 'assign': |
$$_key = (string)$_val; |
break; |
case 'indent': |
case 'indent_first': |
case 'wrap': |
$$_key = (int)$_val; |
break; |
case 'wrap_cut': |
$$_key = (bool)$_val; |
break; |
default: |
$smarty->trigger_error("textformat: unknown attribute '$_key'"); |
} |
} |
if ($style == 'email') { |
$wrap = 72; |
} |
// split into paragraphs |
$_paragraphs = preg_split('![\r\n][\r\n]!', $content); |
$_output = ''; |
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { |
if ($_paragraphs[$_x] == '') { |
continue; |
} |
// convert mult. spaces & special chars to single space |
$_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]); |
// indent first line |
if ($indent_first > 0) { |
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; |
} |
// wordwrap sentences |
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); |
// indent lines |
if ($indent > 0) { |
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); |
} |
} |
$_output = implode($wrap_char . $wrap_char, $_paragraphs); |
return $assign ? $template->assign($assign, $_output) : $_output; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.noprint.php |
---|
Новый файл |
0,0 → 1,24 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty noprint modifier plugin |
* |
* Type: modifier<br> |
* Name: noprint<br> |
* Purpose: return an empty string |
* @author Uwe Tews |
* @param string |
* @return string |
*/ |
function smarty_modifier_noprint($string) |
{ |
return ''; |
} |
?> |
/branches/ant-ng/lib/plugins/function.popup.php |
---|
Новый файл |
0,0 → 1,118 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {popup} function plugin |
* |
* Type: function<br> |
* Name: popup<br> |
* Purpose: make text pop up in windows via overlib |
* @link http://smarty.php.net/manual/en/language.function.popup.php {popup} |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
*/ |
function smarty_function_popup($params, $smarty, $template) |
{ |
$append = ''; |
foreach ($params as $_key=>$_value) { |
switch ($_key) { |
case 'text': |
case 'trigger': |
case 'function': |
case 'inarray': |
$$_key = (string)$_value; |
if ($_key == 'function' || $_key == 'inarray') |
$append .= ',' . strtoupper($_key) . ",'$_value'"; |
break; |
case 'caption': |
case 'closetext': |
case 'status': |
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'"; |
break; |
case 'fgcolor': |
case 'bgcolor': |
case 'textcolor': |
case 'capcolor': |
case 'closecolor': |
case 'textfont': |
case 'captionfont': |
case 'closefont': |
case 'fgbackground': |
case 'bgbackground': |
case 'caparray': |
case 'capicon': |
case 'background': |
case 'frame': |
$append .= ',' . strtoupper($_key) . ",'$_value'"; |
break; |
case 'textsize': |
case 'captionsize': |
case 'closesize': |
case 'width': |
case 'height': |
case 'border': |
case 'offsetx': |
case 'offsety': |
case 'snapx': |
case 'snapy': |
case 'fixx': |
case 'fixy': |
case 'padx': |
case 'pady': |
case 'timeout': |
case 'delay': |
$append .= ',' . strtoupper($_key) . ",$_value"; |
break; |
case 'sticky': |
case 'left': |
case 'right': |
case 'center': |
case 'above': |
case 'below': |
case 'noclose': |
case 'autostatus': |
case 'autostatuscap': |
case 'fullhtml': |
case 'hauto': |
case 'vauto': |
case 'mouseoff': |
case 'followmouse': |
case 'closeclick': |
case 'wrap': |
if ($_value) $append .= ',' . strtoupper($_key); |
break; |
default: |
throw new Exception ("[popup] unknown parameter $_key", E_USER_WARNING); |
} |
} |
if (empty($text) && !isset($inarray) && empty($function)) { |
throw new Exception ("overlib: attribute 'text' or 'inarray' or 'function' required"); |
return false; |
} |
if (empty($trigger)) { $trigger = "onmouseover"; } |
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\''; |
$retval .= $append . ');"'; |
if ($trigger == 'onmouseover') |
$retval .= ' onmouseout="nd();"'; |
return $retval; |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_radios.php |
---|
Новый файл |
0,0 → 1,156 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_radios} function plugin |
* |
* File: function.html_radios.php<br> |
* Type: function<br> |
* Name: html_radios<br> |
* Date: 24.Feb.2003<br> |
* Purpose: Prints out a list of radio input types<br> |
* Examples: |
* <pre> |
* {html_radios values=$ids output=$names} |
* {html_radios values=$ids name='box' separator='<br>' output=$names} |
* {html_radios values=$ids checked=$checked separator='<br>' output=$names} |
* </pre> |
* |
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} |
(Smarty online manual) |
* @author Christopher Kvarme <christopher.kvarme@flashjab.com> |
* @author credits to Monte Ohrt <monte at ohrt dot com> |
* @version 1.0 |
* @param array $params parameters |
* Input:<br> |
* - name (optional) - string default "radio" |
* - values (required) - array |
* - options (optional) - associative array |
* - checked (optional) - array default not set |
* - separator (optional) - ie <br> or |
* - output (optional) - the output next to each radio button |
* - assign (optional) - assign the output as an array to this variable |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
* @uses smarty_function_escape_special_chars() |
*/ |
function smarty_function_html_radios($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
//$smarty->loadPlugin('Smarty_shared_escape_special_chars'); |
$name = 'radio'; |
$values = null; |
$options = null; |
$selected = null; |
$separator = ''; |
$labels = true; |
$label_ids = false; |
$output = null; |
$extra = ''; |
foreach($params as $_key => $_val) { |
switch ($_key) { |
case 'name': |
case 'separator': |
$$_key = (string)$_val; |
break; |
case 'checked': |
case 'selected': |
if (is_array($_val)) { |
throw new Exception ('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); |
} else { |
$selected = (string)$_val; |
} |
break; |
case 'labels': |
case 'label_ids': |
$$_key = (bool)$_val; |
break; |
case 'options': |
$$_key = (array)$_val; |
break; |
case 'values': |
case 'output': |
$$_key = array_values((array)$_val); |
break; |
case 'radios': |
throw new Exception ('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING); |
$options = (array)$_val; |
break; |
case 'assign': |
break; |
default: |
if (!is_array($_val)) { |
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
} else { |
throw new Exception ("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
} |
} |
if (!isset($options) && !isset($values)) |
return ''; |
/* raise error here? */ |
$_html_result = array(); |
if (isset($options)) { |
foreach ($options as $_key => $_val) |
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); |
} else { |
foreach ($values as $_i => $_key) { |
$_val = isset($output[$_i]) ? $output[$_i] : ''; |
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); |
} |
} |
if (!empty($params['assign'])) { |
$template->assign($params['assign'], $_html_result); |
} else { |
return implode("\n", $_html_result); |
} |
} |
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) |
{ |
$_output = ''; |
if ($labels) { |
if ($label_ids) { |
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value)); |
$_output .= '<label for="' . $_id . '">'; |
} else { |
$_output .= '<label>'; |
} |
} |
$_output .= '<input type="radio" name="' |
. smarty_function_escape_special_chars($name) . '" value="' |
. smarty_function_escape_special_chars($value) . '"'; |
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"'; |
if ((string)$value == $selected) { |
$_output .= ' checked="checked"'; |
} |
$_output .= $extra . ' />' . $output; |
if ($labels) $_output .= '</label>'; |
$_output .= $separator; |
return $_output; |
} |
?> |
/branches/ant-ng/lib/plugins/outputfilter.trimwhitespace.php |
---|
Новый файл |
0,0 → 1,76 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFilter |
*/ |
/** |
* Smarty trimwhitespace outputfilter plugin |
* |
* File: outputfilter.trimwhitespace.php<br> |
* Type: outputfilter<br> |
* Name: trimwhitespace<br> |
* Date: Jan 25, 2003<br> |
* Purpose: trim leading white space and blank lines from |
* template source after it gets interpreted, cleaning |
* up code and saving bandwidth. Does not affect |
* <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br> |
* Install: Drop into the plugin directory, call |
* <code>$smarty->load_filter('output','trimwhitespace');</code> |
* from application. |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author Contributions from Lars Noschinski <lars@usenet.noschinski.de> |
* @version 1.3 |
* @param string $source input string |
* @param object &$smarty Smarty object |
* @return string filtered output |
*/ |
function smarty_outputfilter_trimwhitespace($source, &$smarty) |
{ |
// Pull out the script blocks |
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match); |
$_script_blocks = $match[0]; |
$source = preg_replace("!<script[^>]*?>.*?</script>!is", |
'@@@SMARTY:TRIM:SCRIPT@@@', $source); |
// Pull out the pre blocks |
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match); |
$_pre_blocks = $match[0]; |
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is", |
'@@@SMARTY:TRIM:PRE@@@', $source); |
// Pull out the textarea blocks |
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match); |
$_textarea_blocks = $match[0]; |
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is", |
'@@@SMARTY:TRIM:TEXTAREA@@@', $source); |
// remove all leading spaces, tabs and carriage returns NOT |
// preceeded by a php close tag. |
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source)); |
// replace textarea blocks |
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); |
// replace pre blocks |
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); |
// replace script blocks |
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); |
return $source; |
} |
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { |
$_len = strlen($search_str); |
$_pos = 0; |
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) |
if (($_pos=strpos($subject, $search_str, $_pos))!==false) |
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len); |
else |
break; |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_table.php |
---|
Новый файл |
0,0 → 1,176 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_table} function plugin |
* |
* Type: function<br> |
* Name: html_table<br> |
* Date: Feb 17, 2003<br> |
* Purpose: make an html table from an array of data<br> |
* |
* |
* Examples: |
* <pre> |
* {table loop=$data} |
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'} |
* {table loop=$data cols="first,second,third" tr_attr=$colors} |
* </pre> |
* |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author credit to Messju Mohr <messju at lammfellpuschen dot de> |
* @author credit to boots <boots dot smarty at yahoo dot com> |
* @version 1.1 |
* @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table} |
(Smarty online manual) |
* @param array $params parameters |
* Input:<br> |
* - loop = array to loop through |
* - cols = number of columns, comma separated list of column names |
* or array of column names |
* - rows = number of rows |
* - table_attr = table attributes |
* - th_attr = table heading attributes (arrays are cycled) |
* - tr_attr = table row attributes (arrays are cycled) |
* - td_attr = table cell attributes (arrays are cycled) |
* - trailpad = value to pad trailing cells with |
* - caption = text for caption element |
* - vdir = vertical direction (default: "down", means top-to-bottom) |
* - hdir = horizontal direction (default: "right", means left-to-right) |
* - inner = inner loop (default "cols": print $loop line by line, |
* $loop will be printed column by column otherwise) |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
*/ |
function smarty_function_html_table($params, $smarty, $template) |
{ |
$table_attr = 'border="1"'; |
$tr_attr = ''; |
$th_attr = ''; |
$td_attr = ''; |
$cols = $cols_count = 3; |
$rows = 3; |
$trailpad = ' '; |
$vdir = 'down'; |
$hdir = 'right'; |
$inner = 'cols'; |
$caption = ''; |
if (!isset($params['loop'])) { |
throw new Exception ("html_table: missing 'loop' parameter"); |
return; |
} |
foreach ($params as $_key => $_value) { |
switch ($_key) { |
case 'loop': |
$$_key = (array)$_value; |
break; |
case 'cols': |
if (is_array($_value) && !empty($_value)) { |
$cols = $_value; |
$cols_count = count($_value); |
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) { |
$cols = explode(',', $_value); |
$cols_count = count($cols); |
} elseif (!empty($_value)) { |
$cols_count = (int)$_value; |
} else { |
$cols_count = $cols; |
} |
break; |
case 'rows': |
$$_key = (int)$_value; |
break; |
case 'table_attr': |
case 'trailpad': |
case 'hdir': |
case 'vdir': |
case 'inner': |
case 'caption': |
$$_key = (string)$_value; |
break; |
case 'tr_attr': |
case 'td_attr': |
case 'th_attr': |
$$_key = $_value; |
break; |
} |
} |
$loop_count = count($loop); |
if (empty($params['rows'])) { |
/* no rows specified */ |
$rows = ceil($loop_count / $cols_count); |
} elseif (empty($params['cols'])) { |
if (!empty($params['rows'])) { |
/* no cols specified, but rows */ |
$cols_count = ceil($loop_count / $rows); |
} |
} |
$output = "<table $table_attr>\n"; |
if (!empty($caption)) { |
$output .= '<caption>' . $caption . "</caption>\n"; |
} |
if (is_array($cols)) { |
$cols = ($hdir == 'right') ? $cols : array_reverse($cols); |
$output .= "<thead><tr>\n"; |
for ($r = 0; $r < $cols_count; $r++) { |
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; |
$output .= $cols[$r]; |
$output .= "</th>\n"; |
} |
$output .= "</tr></thead>\n"; |
} |
$output .= "<tbody>\n"; |
for ($r = 0; $r < $rows; $r++) { |
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; |
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count; |
for ($c = 0; $c < $cols_count; $c++) { |
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c; |
if ($inner != 'cols') { |
/* shuffle x to loop over rows*/ |
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows; |
} |
if ($x < $loop_count) { |
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n"; |
} else { |
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n"; |
} |
} |
$output .= "</tr>\n"; |
} |
$output .= "</tbody>\n"; |
$output .= "</table>\n"; |
return $output; |
} |
function smarty_function_html_table_cycle($name, $var, $no) |
{ |
if (!is_array($var)) { |
$ret = $var; |
} else { |
$ret = $var[$no % count($var)]; |
} |
return ($ret) ? ' ' . $ret : ''; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.regex_replace.php |
---|
Новый файл |
0,0 → 1,48 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage plugins |
*/ |
/** |
* Smarty regex_replace modifier plugin |
* |
* Type: modifier<br> |
* Name: regex_replace<br> |
* Purpose: regular expression search/replace |
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php |
* regex_replace (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @param string|array |
* @param string|array |
* @return string |
*/ |
function smarty_modifier_regex_replace($string, $search, $replace) |
{ |
if(is_array($search)) { |
foreach($search as $idx => $s) |
$search[$idx] = _smarty_regex_replace_check($s); |
} else { |
$search = _smarty_regex_replace_check($search); |
} |
return preg_replace($search, $replace, $string); |
} |
function _smarty_regex_replace_check($search) |
{ |
if (($pos = strpos($search,"\0")) !== false) |
$search = substr($search,0,$pos); |
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { |
/* remove eval-modifier from $search */ |
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); |
} |
return $search; |
} |
/* vim: set expandtab: */ |
?> |
/branches/ant-ng/lib/plugins/modifier.wordwrap.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty wordwrap modifier plugin |
* |
* Type: modifier<br> |
* Name: wordwrap<br> |
* Purpose: wrap a string of text at a given length |
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php |
* wordwrap (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @param integer |
* @param string |
* @param boolean |
* @return string |
*/ |
function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false) |
{ |
return wordwrap($string,$length,$break,$cut); |
} |
?> |
/branches/ant-ng/lib/plugins/function.counter.php |
---|
Новый файл |
0,0 → 1,78 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {counter} function plugin |
* |
* Type: function<br> |
* Name: counter<br> |
* Purpose: print out a counter value |
* @author Monte Ohrt <monte at ohrt dot com> |
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter} |
* (Smarty online manual) |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string|null |
*/ |
function smarty_function_counter($params, $smarty, $template) |
{ |
$name = (isset($params['name'])) ? $params['name'] : 'default'; |
if (!isset($template->plugin_data['counter'][$name])) { |
$template->plugin_data['counter'][$name] = array( |
'start'=>1, |
'skip'=>1, |
'direction'=>'up', |
'count'=>1 |
); |
} |
$counter = &$template->plugin_data['counter'][$name]; |
if (isset($params['start'])) { |
$counter['start'] = $counter['count'] = (int)$params['start']; |
} |
if (!empty($params['assign'])) { |
$counter['assign'] = $params['assign']; |
} |
if (isset($counter['assign'])) { |
$template->assign($counter['assign'], $counter['count']); |
} |
if (isset($params['print'])) { |
$print = (bool)$params['print']; |
} else { |
$print = empty($counter['assign']); |
} |
if ($print) { |
$retval = $counter['count']; |
} else { |
$retval = null; |
} |
if (isset($params['skip'])) { |
$counter['skip'] = $params['skip']; |
} |
if (isset($params['direction'])) { |
$counter['direction'] = $params['direction']; |
} |
if ($counter['direction'] == "down") |
$counter['count'] -= $counter['skip']; |
else |
$counter['count'] += $counter['skip']; |
return $retval; |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_options.php |
---|
Новый файл |
0,0 → 1,122 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_options} function plugin |
* |
* Type: function<br> |
* Name: html_options<br> |
* Purpose: Prints the list of <option> tags generated from |
* the passed parameters |
* |
* @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image} |
(Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* Input:<br> |
* - name (optional) - string default "select" |
* - values (required if no options supplied) - array |
* - options (required if no values supplied) - associative array |
* - selected (optional) - string default not set |
* - output (required if not options supplied) - array |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
* @uses smarty_function_escape_special_chars() |
*/ |
function smarty_function_html_options($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
//$smarty->loadPlugin('Smarty_shared_escape_special_chars'); |
$name = null; |
$values = null; |
$options = null; |
$selected = array(); |
$output = null; |
$extra = ''; |
foreach($params as $_key => $_val) { |
switch ($_key) { |
case 'name': |
$$_key = (string)$_val; |
break; |
case 'options': |
$$_key = (array)$_val; |
break; |
case 'values': |
case 'output': |
$$_key = array_values((array)$_val); |
break; |
case 'selected': |
$$_key = array_map('strval', array_values((array)$_val)); |
break; |
default: |
if (!is_array($_val)) { |
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
} else { |
throw new Exception ("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
} |
} |
if (!isset($options) && !isset($values)) |
return ''; |
/* raise error here? */ |
$_html_result = ''; |
if (isset($options)) { |
foreach ($options as $_key => $_val) |
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); |
} else { |
foreach ($values as $_i => $_key) { |
$_val = isset($output[$_i]) ? $output[$_i] : ''; |
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); |
} |
} |
if (!empty($name)) { |
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n"; |
} |
return $_html_result; |
} |
function smarty_function_html_options_optoutput($key, $value, $selected) |
{ |
if (!is_array($value)) { |
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' . |
smarty_function_escape_special_chars($key) . '"'; |
if (in_array((string)$key, $selected)) |
$_html_result .= ' selected="selected"'; |
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n"; |
} else { |
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected); |
} |
return $_html_result; |
} |
function smarty_function_html_options_optgroup($key, $values, $selected) |
{ |
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; |
foreach ($values as $key => $value) { |
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected); |
} |
$optgroup_html .= "</optgroup>\n"; |
return $optgroup_html; |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_select_time.php |
---|
Новый файл |
0,0 → 1,197 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_select_time} function plugin |
* |
* Type: function<br> |
* Name: html_select_time<br> |
* Purpose: Prints the dropdowns for time selection |
* |
* @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time} |
(Smarty online manual) |
* @author Roberto Berto <roberto@berto.net> |
* @credits Monte Ohrt <monte AT ohrt DOT com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
* @uses smarty_make_timestamp() |
*/ |
function smarty_function_html_select_time($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); |
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php'); |
//$smarty->loadPlugin('Smarty_shared_make_timestamp'); |
//$smarty->loadPlugin('Smarty_function_html_options'); |
/* Default values. */ |
$prefix = "Time_"; |
$time = time(); |
$display_hours = true; |
$display_minutes = true; |
$display_seconds = true; |
$display_meridian = true; |
$use_24_hours = true; |
$minute_interval = 1; |
$second_interval = 1; |
/* Should the select boxes be part of an array when returned from PHP? |
e.g. setting it to "birthday", would create "birthday[Hour]", |
"birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]". |
Can be combined with prefix. */ |
$field_array = null; |
$all_extra = null; |
$hour_extra = null; |
$minute_extra = null; |
$second_extra = null; |
$meridian_extra = null; |
foreach ($params as $_key => $_value) { |
switch ($_key) { |
case 'prefix': |
case 'time': |
case 'field_array': |
case 'all_extra': |
case 'hour_extra': |
case 'minute_extra': |
case 'second_extra': |
case 'meridian_extra': |
$$_key = (string)$_value; |
break; |
case 'display_hours': |
case 'display_minutes': |
case 'display_seconds': |
case 'display_meridian': |
case 'use_24_hours': |
$$_key = (bool)$_value; |
break; |
case 'minute_interval': |
case 'second_interval': |
$$_key = (int)$_value; |
break; |
default: |
throw new Exception ("[html_select_time] unknown parameter $_key", E_USER_WARNING); |
} |
} |
$time = smarty_make_timestamp($time); |
$html_result = ''; |
if ($display_hours) { |
$hours = $use_24_hours ? range(0, 23) : range(1, 12); |
$hour_fmt = $use_24_hours ? '%H' : '%I'; |
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) |
$hours[$i] = sprintf('%02d', $hours[$i]); |
$html_result .= '<select name='; |
if (null !== $field_array) { |
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"'; |
} else { |
$html_result .= '"' . $prefix . 'Hour"'; |
} |
if (null !== $hour_extra) { |
$html_result .= ' ' . $hour_extra; |
} |
if (null !== $all_extra) { |
$html_result .= ' ' . $all_extra; |
} |
$html_result .= '>' . "\n"; |
$html_result .= smarty_function_html_options(array('output' => $hours, |
'values' => $hours, |
'selected' => strftime($hour_fmt, $time), |
'print_result' => false), |
$smarty, $template); |
$html_result .= "</select>\n"; |
} |
if ($display_minutes) { |
$all_minutes = range(0, 59); |
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i += $minute_interval) |
$minutes[] = sprintf('%02d', $all_minutes[$i]); |
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval); |
$html_result .= '<select name='; |
if (null !== $field_array) { |
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"'; |
} else { |
$html_result .= '"' . $prefix . 'Minute"'; |
} |
if (null !== $minute_extra) { |
$html_result .= ' ' . $minute_extra; |
} |
if (null !== $all_extra) { |
$html_result .= ' ' . $all_extra; |
} |
$html_result .= '>' . "\n"; |
$html_result .= smarty_function_html_options(array('output' => $minutes, |
'values' => $minutes, |
'selected' => $selected, |
'print_result' => false), |
$smarty, $template); |
$html_result .= "</select>\n"; |
} |
if ($display_seconds) { |
$all_seconds = range(0, 59); |
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i += $second_interval) |
$seconds[] = sprintf('%02d', $all_seconds[$i]); |
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval); |
$html_result .= '<select name='; |
if (null !== $field_array) { |
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]"'; |
} else { |
$html_result .= '"' . $prefix . 'Second"'; |
} |
if (null !== $second_extra) { |
$html_result .= ' ' . $second_extra; |
} |
if (null !== $all_extra) { |
$html_result .= ' ' . $all_extra; |
} |
$html_result .= '>' . "\n"; |
$html_result .= smarty_function_html_options(array('output' => $seconds, |
'values' => $seconds, |
'selected' => $selected, |
'print_result' => false), |
$smarty, $template); |
$html_result .= "</select>\n"; |
} |
if ($display_meridian && !$use_24_hours) { |
$html_result .= '<select name='; |
if (null !== $field_array) { |
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"'; |
} else { |
$html_result .= '"' . $prefix . 'Meridian"'; |
} |
if (null !== $meridian_extra) { |
$html_result .= ' ' . $meridian_extra; |
} |
if (null !== $all_extra) { |
$html_result .= ' ' . $all_extra; |
} |
$html_result .= '>' . "\n"; |
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'), |
'values' => array('am', 'pm'), |
'selected' => strtolower(strftime('%p', $time)), |
'print_result' => false), |
$smarty, $template); |
$html_result .= "</select>\n"; |
} |
return $html_result; |
} |
?> |
/branches/ant-ng/lib/plugins/shared.make_timestamp.php |
---|
Новый файл |
0,0 → 1,43 |
<?php |
/** |
* Smarty shared plugin |
* @package Smarty |
* @subpackage PluginsShared |
*/ |
/** |
* Function: smarty_make_timestamp<br> |
* Purpose: used by other smarty functions to make a timestamp |
* from a string. |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $string |
* @return string |
*/ |
function smarty_make_timestamp($string) |
{ |
if(empty($string)) { |
// use "now": |
$time = time(); |
} elseif (preg_match('/^\d{14}$/', $string)) { |
// it is mysql timestamp format of YYYYMMDDHHMMSS? |
$time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), |
substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); |
} elseif (is_numeric($string)) { |
// it is a numeric string, we handle it as timestamp |
$time = (int)$string; |
} else { |
// strtotime should handle it |
$time = strtotime($string); |
if ($time == -1 || $time === false) { |
// strtotime() was not able to parse $string, use "now": |
$time = time(); |
} |
} |
return $time; |
} |
?> |
/branches/ant-ng/lib/plugins/function.mailto.php |
---|
Новый файл |
0,0 → 1,157 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {mailto} function plugin |
* |
* Type: function<br> |
* Name: mailto<br> |
* Date: May 21, 2002 |
* Purpose: automate mailto address link creation, and optionally |
* encode them.<br> |
* |
* Examples: |
* <pre> |
* {mailto address="me@domain.com"} |
* {mailto address="me@domain.com" encode="javascript"} |
* {mailto address="me@domain.com" encode="hex"} |
* {mailto address="me@domain.com" subject="Hello to you!"} |
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"} |
* {mailto address="me@domain.com" extra='class="mailto"'} |
* </pre> |
* |
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto} |
(Smarty online manual) |
* @version 1.2 |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author credits to Jason Sweat (added cc, bcc and subject functionality) |
* @param array $params parameters |
* Input:<br> |
* - address = e-mail address |
* - text = (optional) text to display, default is address |
* - encode = (optional) can be one of: |
* * none : no encoding (default) |
* * javascript : encode with javascript |
* * javascript_charcode : encode with javascript charcode |
* * hex : encode with hexidecimal (no javascript) |
* - cc = (optional) address(es) to carbon copy |
* - bcc = (optional) address(es) to blind carbon copy |
* - subject = (optional) e-mail subject |
* - newsgroups = (optional) newsgroup(s) to post to |
* - followupto = (optional) address(es) to follow up to |
* - extra = (optional) extra tags for the href link |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
*/ |
function smarty_function_mailto($params, $smarty, $template) |
{ |
$extra = ''; |
if (empty($params['address'])) { |
throw new Exception ("mailto: missing 'address' parameter"); |
return; |
} else { |
$address = $params['address']; |
} |
$text = $address; |
// netscape and mozilla do not decode %40 (@) in BCC field (bug?) |
// so, don't encode it. |
$search = array('%40', '%2C'); |
$replace = array('@', ','); |
$mail_parms = array(); |
foreach ($params as $var => $value) { |
switch ($var) { |
case 'cc': |
case 'bcc': |
case 'followupto': |
if (!empty($value)) |
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); |
break; |
case 'subject': |
case 'newsgroups': |
$mail_parms[] = $var . '=' . rawurlencode($value); |
break; |
case 'extra': |
case 'text': |
$$var = $value; |
default: |
} |
} |
$mail_parm_vals = ''; |
for ($i = 0; $i < count($mail_parms); $i++) { |
$mail_parm_vals .= (0 == $i) ? '?' : '&'; |
$mail_parm_vals .= $mail_parms[$i]; |
} |
$address .= $mail_parm_vals; |
$encode = (empty($params['encode'])) ? 'none' : $params['encode']; |
if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) { |
throw new Exception ("mailto: 'encode' parameter must be none, javascript or hex"); |
return; |
} |
if ($encode == 'javascript') { |
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; |
$js_encode = ''; |
for ($x = 0; $x < strlen($string); $x++) { |
$js_encode .= '%' . bin2hex($string[$x]); |
} |
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>'; |
} elseif ($encode == 'javascript_charcode') { |
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
for($x = 0, $y = strlen($string); $x < $y; $x++) { |
$ord[] = ord($string[$x]); |
} |
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n"; |
$_ret .= "<!--\n"; |
$_ret .= "{document.write(String.fromCharCode("; |
$_ret .= implode(',', $ord); |
$_ret .= "))"; |
$_ret .= "}\n"; |
$_ret .= "//-->\n"; |
$_ret .= "</script>\n"; |
return $_ret; |
} elseif ($encode == 'hex') { |
preg_match('!^(.*)(\?.*)$!', $address, $match); |
if (!empty($match[2])) { |
throw new Exception ("mailto: hex encoding does not work with extra attributes. Try javascript."); |
return; |
} |
$address_encode = ''; |
for ($x = 0; $x < strlen($address); $x++) { |
if (preg_match('!\w!', $address[$x])) { |
$address_encode .= '%' . bin2hex($address[$x]); |
} else { |
$address_encode .= $address[$x]; |
} |
} |
$text_encode = ''; |
for ($x = 0; $x < strlen($text); $x++) { |
$text_encode .= '&#x' . bin2hex($text[$x]) . ';'; |
} |
$mailto = "mailto:"; |
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>'; |
} else { |
// no encoding |
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; |
} |
} |
?> |
/branches/ant-ng/lib/plugins/function.popup_init.php |
---|
Новый файл |
0,0 → 1,41 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {popup_init} function plugin |
* |
* Type: function<br> |
* Name: popup_init<br> |
* Purpose: initialize overlib |
* @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init} |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
*/ |
function smarty_function_popup_init($params, $smarty, $template) |
{ |
$zindex = 1000; |
if (!empty($params['zindex'])) { |
$zindex = $params['zindex']; |
} |
if (!empty($params['src'])) { |
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n" |
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n"; |
} else { |
throw new Exception ("popup_init: missing src parameter"); |
} |
} |
/* vim: set expandtab: */ |
?> |
/branches/ant-ng/lib/plugins/function.fetch.php |
---|
Новый файл |
0,0 → 1,217 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {fetch} plugin |
* |
* Type: function<br> |
* Name: fetch<br> |
* Purpose: fetch file, web or ftp data and display results |
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch} |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string|null if the assign parameter is passed, Smarty assigns the |
* result to a template variable |
*/ |
function smarty_function_fetch($params, $smarty, $template) |
{ |
if (empty($params['file'])) { |
throw new Exception ("[plugin] fetch parameter 'file' cannot be empty"); |
return; |
} |
$content = ''; |
if ($template->security && !preg_match('!^(http|ftp)://!i', $params['file'])) { |
if(!$smarty->security_handler->isTrustedResourceDir($params['file'])) { |
return; |
} |
// fetch the file |
if($fp = @fopen($params['file'],'r')) { |
while(!feof($fp)) { |
$content .= fgets ($fp,4096); |
} |
fclose($fp); |
} else { |
throw new Exception ('[plugin] fetch cannot read file \'' . $params['file'] . '\''); |
return; |
} |
} else { |
// not a local file |
if(preg_match('!^http://!i',$params['file'])) { |
// http fetch |
if($uri_parts = parse_url($params['file'])) { |
// set defaults |
$host = $server_name = $uri_parts['host']; |
$timeout = 30; |
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
$agent = "Smarty Template Engine ".$smarty->_version; |
$referer = ""; |
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; |
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; |
$_is_proxy = false; |
if(empty($uri_parts['port'])) { |
$port = 80; |
} else { |
$port = $uri_parts['port']; |
} |
if(!empty($uri_parts['user'])) { |
$user = $uri_parts['user']; |
} |
if(!empty($uri_parts['pass'])) { |
$pass = $uri_parts['pass']; |
} |
// loop through parameters, setup headers |
foreach($params as $param_key => $param_value) { |
switch($param_key) { |
case "file": |
case "assign": |
case "assign_headers": |
break; |
case "user": |
if(!empty($param_value)) { |
$user = $param_value; |
} |
break; |
case "pass": |
if(!empty($param_value)) { |
$pass = $param_value; |
} |
break; |
case "accept": |
if(!empty($param_value)) { |
$accept = $param_value; |
} |
break; |
case "header": |
if(!empty($param_value)) { |
if(!preg_match('![\w\d-]+: .+!',$param_value)) { |
throw new Exception ("[plugin] invalid header format '".$param_value."'"); |
return; |
} else { |
$extra_headers[] = $param_value; |
} |
} |
break; |
case "proxy_host": |
if(!empty($param_value)) { |
$proxy_host = $param_value; |
} |
break; |
case "proxy_port": |
if(!preg_match('!\D!', $param_value)) { |
$proxy_port = (int) $param_value; |
} else { |
throw new Exception ("[plugin] invalid value for attribute '".$param_key."'"); |
return; |
} |
break; |
case "agent": |
if(!empty($param_value)) { |
$agent = $param_value; |
} |
break; |
case "referer": |
if(!empty($param_value)) { |
$referer = $param_value; |
} |
break; |
case "timeout": |
if(!preg_match('!\D!', $param_value)) { |
$timeout = (int) $param_value; |
} else { |
throw new Exception ("[plugin] invalid value for attribute '".$param_key."'"); |
return; |
} |
break; |
default: |
throw new Exception ("[plugin] unrecognized attribute '".$param_key."'"); |
return; |
} |
} |
if(!empty($proxy_host) && !empty($proxy_port)) { |
$_is_proxy = true; |
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); |
} else { |
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); |
} |
if(!$fp) { |
throw new Exception ("[plugin] unable to fetch: $errstr ($errno)"); |
return; |
} else { |
if($_is_proxy) { |
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); |
} else { |
fputs($fp, "GET $uri HTTP/1.0\r\n"); |
} |
if(!empty($host)) { |
fputs($fp, "Host: $host\r\n"); |
} |
if(!empty($accept)) { |
fputs($fp, "Accept: $accept\r\n"); |
} |
if(!empty($agent)) { |
fputs($fp, "User-Agent: $agent\r\n"); |
} |
if(!empty($referer)) { |
fputs($fp, "Referer: $referer\r\n"); |
} |
if(isset($extra_headers) && is_array($extra_headers)) { |
foreach($extra_headers as $curr_header) { |
fputs($fp, $curr_header."\r\n"); |
} |
} |
if(!empty($user) && !empty($pass)) { |
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); |
} |
fputs($fp, "\r\n"); |
while(!feof($fp)) { |
$content .= fgets($fp,4096); |
} |
fclose($fp); |
$csplit = preg_split("!\r\n\r\n!",$content,2); |
$content = $csplit[1]; |
if(!empty($params['assign_headers'])) { |
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); |
} |
} |
} else { |
throw new Exception ("[plugin] unable to parse URL, check syntax"); |
return; |
} |
} else { |
// ftp fetch |
if($fp = @fopen($params['file'],'r')) { |
while(!feof($fp)) { |
$content .= fgets ($fp,4096); |
} |
fclose($fp); |
} else { |
throw new Exception ('[plugin] fetch cannot read file \'' . $params['file'] .'\''); |
return; |
} |
} |
} |
if (!empty($params['assign'])) { |
$template->assign($params['assign'],$content); |
} else { |
return $content; |
} |
} |
?> |
/branches/ant-ng/lib/plugins/function.math.php |
---|
Новый файл |
0,0 → 1,84 |
<?php |
/** |
* Smarty plugin |
* |
* This plugin is only for Smarty2 BC |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {math} function plugin |
* |
* Type: function<br> |
* Name: math<br> |
* Purpose: handle math computations in template<br> |
* @link http://smarty.php.net/manual/en/language.function.math.php {math} |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string|null |
*/ |
function smarty_function_math($params, $smarty, $template) |
{ |
// be sure equation parameter is present |
if (empty($params['equation'])) { |
throw new Exception ("math: missing equation parameter"); |
return; |
} |
$equation = $params['equation']; |
// make sure parenthesis are balanced |
if (substr_count($equation,"(") != substr_count($equation,")")) { |
throw new Exception ("math: unbalanced parenthesis"); |
return; |
} |
// match all vars in equation, make sure all are passed |
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]+)!",$equation, $match); |
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', |
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); |
foreach($match[1] as $curr_var) { |
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { |
throw new Exception ("math: function call $curr_var not allowed"); |
return; |
} |
} |
foreach($params as $key => $val) { |
if ($key != "equation" && $key != "format" && $key != "assign") { |
// make sure value is not empty |
if (strlen($val)==0) { |
throw new Exception ("math: parameter $key is empty"); |
return; |
} |
if (!is_numeric($val)) { |
throw new Exception ("math: parameter $key: is not numeric"); |
return; |
} |
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); |
} |
} |
eval("\$smarty_math_result = ".$equation.";"); |
if (empty($params['format'])) { |
if (empty($params['assign'])) { |
return $smarty_math_result; |
} else { |
$template->assign($params['assign'],$smarty_math_result); |
} |
} else { |
if (empty($params['assign'])){ |
printf($params['format'],$smarty_math_result); |
} else { |
$template->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); |
} |
} |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.indent.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty indent modifier plugin |
* |
* Type: modifier<br> |
* Name: indent<br> |
* Purpose: indent lines of text |
* @link http://smarty.php.net/manual/en/language.modifier.indent.php |
* indent (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @param integer |
* @param string |
* @return string |
*/ |
function smarty_modifier_indent($string,$chars=4,$char=" ") |
{ |
return preg_replace('!^!m',str_repeat($char,$chars),$string); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.truncate.php |
---|
Новый файл |
0,0 → 1,64 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty truncate modifier plugin |
* |
* Type: modifier<br> |
* Name: truncate<br> |
* Purpose: Truncate a string to a certain length if necessary, |
* optionally splitting in the middle of a word, and |
* appending the $etc string or inserting $etc into the middle. |
* |
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $string input string |
* @param integer $length lenght of truncated text |
* @param string $etc end string |
* @param boolean $break_words truncate at word boundary |
* @param boolean $middle truncate in the middle of text |
* @return string truncated string |
*/ |
function smarty_modifier_truncate($string, $length = 80, $etc = '...', |
$break_words = false, $middle = false) |
{ |
if ($length == 0) |
return ''; |
if (is_callable('mb_strlen')) { |
if (mb_strlen($string) > $length) { |
$length -= min($length, mb_strlen($etc)); |
if (!$break_words && !$middle) { |
$string = mb_ereg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length + 1), 'p'); |
} |
if (!$middle) { |
return mb_substr($string, 0, $length) . $etc; |
} else { |
return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2); |
} |
} else { |
return $string; |
} |
} else { |
if (strlen($string) > $length) { |
$length -= min($length, strlen($etc)); |
if (!$break_words && !$middle) { |
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); |
} |
if (!$middle) { |
return substr($string, 0, $length) . $etc; |
} else { |
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); |
} |
} else { |
return $string; |
} |
} |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_select_date.php |
---|
Новый файл |
0,0 → 1,333 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_select_date} plugin |
* |
* Type: function<br> |
* Name: html_select_date<br> |
* Purpose: Prints the dropdowns for date selection. |
* |
* ChangeLog:<br> |
* - 1.0 initial release |
* - 1.1 added support for +/- N syntax for begin |
* and end year values. (Monte) |
* - 1.2 added support for yyyy-mm-dd syntax for |
* time value. (Jan Rosier) |
* - 1.3 added support for choosing format for |
* month values (Gary Loescher) |
* - 1.3.1 added support for choosing format for |
* day values (Marcus Bointon) |
* - 1.3.2 support negative timestamps, force year |
* dropdown to include given date unless explicitly set (Monte) |
* - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that |
* of 0000-00-00 dates (cybot, boots) |
* |
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date} |
(Smarty online manual) |
* @version 1.3.4 |
* @author Andrei Zmievski |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $params parameters |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
*/ |
function smarty_function_html_select_date($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); |
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php'); |
//$smarty->loadPlugin('Smarty_shared_escape_special_chars'); |
//$smarty->loadPlugin('Smarty_shared_make_timestamp'); |
//$smarty->loadPlugin('Smarty_function_html_options'); |
/* Default values. */ |
$prefix = "Date_"; |
$start_year = strftime("%Y"); |
$end_year = $start_year; |
$display_days = true; |
$display_months = true; |
$display_years = true; |
$month_format = "%B"; |
/* Write months as numbers by default GL */ |
$month_value_format = "%m"; |
$day_format = "%02d"; |
/* Write day values using this format MB */ |
$day_value_format = "%d"; |
$year_as_text = false; |
/* Display years in reverse order? Ie. 2000,1999,.... */ |
$reverse_years = false; |
/* Should the select boxes be part of an array when returned from PHP? |
e.g. setting it to "birthday", would create "birthday[Day]", |
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */ |
$field_array = null; |
/* <select size>'s of the different <select> tags. |
If not set, uses default dropdown. */ |
$day_size = null; |
$month_size = null; |
$year_size = null; |
/* Unparsed attributes common to *ALL* the <select>/<input> tags. |
An example might be in the template: all_extra ='class ="foo"'. */ |
$all_extra = null; |
/* Separate attributes for the tags. */ |
$day_extra = null; |
$month_extra = null; |
$year_extra = null; |
/* Order in which to display the fields. |
"D" -> day, "M" -> month, "Y" -> year. */ |
$field_order = 'MDY'; |
/* String printed between the different fields. */ |
$field_separator = "\n"; |
$time = time(); |
$all_empty = null; |
$day_empty = null; |
$month_empty = null; |
$year_empty = null; |
$extra_attrs = ''; |
foreach ($params as $_key => $_value) { |
switch ($_key) { |
case 'prefix': |
case 'time': |
case 'start_year': |
case 'end_year': |
case 'month_format': |
case 'day_format': |
case 'day_value_format': |
case 'field_array': |
case 'day_size': |
case 'month_size': |
case 'year_size': |
case 'all_extra': |
case 'day_extra': |
case 'month_extra': |
case 'year_extra': |
case 'field_order': |
case 'field_separator': |
case 'month_value_format': |
case 'month_empty': |
case 'day_empty': |
case 'year_empty': |
$$_key = (string)$_value; |
break; |
case 'all_empty': |
$$_key = (string)$_value; |
$day_empty = $month_empty = $year_empty = $all_empty; |
break; |
case 'display_days': |
case 'display_months': |
case 'display_years': |
case 'year_as_text': |
case 'reverse_years': |
$$_key = (bool)$_value; |
break; |
default: |
if (!is_array($_value)) { |
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"'; |
} else { |
throw new Exception ("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
} |
} |
if (preg_match('!^-\d+$!', $time)) { |
// negative timestamp, use date() |
$time = date('Y-m-d', $time); |
} |
// If $time is not in format yyyy-mm-dd |
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) { |
$time = $found[1]; |
} else { |
// use smarty_make_timestamp to get an unix timestamp and |
// strftime to make yyyy-mm-dd |
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time)); |
} |
// Now split this in pieces, which later can be used to set the select |
$time = explode("-", $time); |
// make syntax "+N" or "-N" work with start_year and end_year |
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) { |
if ($match[1] == '+') { |
$end_year = strftime('%Y') + $match[2]; |
} else { |
$end_year = strftime('%Y') - $match[2]; |
} |
} |
if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) { |
if ($match[1] == '+') { |
$start_year = strftime('%Y') + $match[2]; |
} else { |
$start_year = strftime('%Y') - $match[2]; |
} |
} |
if (strlen($time[0]) > 0) { |
if ($start_year > $time[0] && !isset($params['start_year'])) { |
// force start year to include given date if not explicitly set |
$start_year = $time[0]; |
} |
if ($end_year < $time[0] && !isset($params['end_year'])) { |
// force end year to include given date if not explicitly set |
$end_year = $time[0]; |
} |
} |
$field_order = strtoupper($field_order); |
$html_result = $month_result = $day_result = $year_result = ""; |
$field_separator_count = -1; |
if ($display_months) { |
$field_separator_count++; |
$month_names = array(); |
$month_values = array(); |
if (isset($month_empty)) { |
$month_names[''] = $month_empty; |
$month_values[''] = ''; |
} |
for ($i = 1; $i <= 12; $i++) { |
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000)); |
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000)); |
} |
$month_result .= '<select name='; |
if (null !== $field_array) { |
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"'; |
} else { |
$month_result .= '"' . $prefix . 'Month"'; |
} |
if (null !== $month_size) { |
$month_result .= ' size="' . $month_size . '"'; |
} |
if (null !== $month_extra) { |
$month_result .= ' ' . $month_extra; |
} |
if (null !== $all_extra) { |
$month_result .= ' ' . $all_extra; |
} |
$month_result .= $extra_attrs . '>' . "\n"; |
$month_result .= smarty_function_html_options(array('output' => $month_names, |
'values' => $month_values, |
'selected' => (int)$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '', |
'print_result' => false), |
$smarty, $template); |
$month_result .= '</select>'; |
} |
if ($display_days) { |
$field_separator_count++; |
$days = array(); |
if (isset($day_empty)) { |
$days[''] = $day_empty; |
$day_values[''] = ''; |
} |
for ($i = 1; $i <= 31; $i++) { |
$days[] = sprintf($day_format, $i); |
$day_values[] = sprintf($day_value_format, $i); |
} |
$day_result .= '<select name='; |
if (null !== $field_array) { |
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"'; |
} else { |
$day_result .= '"' . $prefix . 'Day"'; |
} |
if (null !== $day_size) { |
$day_result .= ' size="' . $day_size . '"'; |
} |
if (null !== $all_extra) { |
$day_result .= ' ' . $all_extra; |
} |
if (null !== $day_extra) { |
$day_result .= ' ' . $day_extra; |
} |
$day_result .= $extra_attrs . '>' . "\n"; |
$day_result .= smarty_function_html_options(array('output' => $days, |
'values' => $day_values, |
'selected' => $time[2], |
'print_result' => false), |
$smarty, $template); |
$day_result .= '</select>'; |
} |
if ($display_years) { |
$field_separator_count++; |
if (null !== $field_array) { |
$year_name = $field_array . '[' . $prefix . 'Year]'; |
} else { |
$year_name = $prefix . 'Year'; |
} |
if ($year_as_text) { |
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"'; |
if (null !== $all_extra) { |
$year_result .= ' ' . $all_extra; |
} |
if (null !== $year_extra) { |
$year_result .= ' ' . $year_extra; |
} |
$year_result .= ' />'; |
} else { |
$years = range((int)$start_year, (int)$end_year); |
if ($reverse_years) { |
rsort($years, SORT_NUMERIC); |
} else { |
sort($years, SORT_NUMERIC); |
} |
$yearvals = $years; |
if (isset($year_empty)) { |
array_unshift($years, $year_empty); |
array_unshift($yearvals, ''); |
} |
$year_result .= '<select name="' . $year_name . '"'; |
if (null !== $year_size) { |
$year_result .= ' size="' . $year_size . '"'; |
} |
if (null !== $all_extra) { |
$year_result .= ' ' . $all_extra; |
} |
if (null !== $year_extra) { |
$year_result .= ' ' . $year_extra; |
} |
$year_result .= $extra_attrs . '>' . "\n"; |
$year_result .= smarty_function_html_options(array('output' => $years, |
'values' => $yearvals, |
'selected' => $time[0], |
'print_result' => false), |
$smarty, $template); |
$year_result .= '</select>'; |
} |
} |
// Loop thru the field_order field |
for ($i = 0; $i <= 2; $i++) { |
$c = substr($field_order, $i, 1); |
switch ($c) { |
case 'D': |
$html_result .= $day_result; |
break; |
case 'M': |
$html_result .= $month_result; |
break; |
case 'Y': |
$html_result .= $year_result; |
break; |
} |
// Add the field seperator |
if ($i < $field_separator_count) { |
$html_result .= $field_separator; |
} |
} |
return $html_result; |
} |
?> |
/branches/ant-ng/lib/plugins/shared.escape_special_chars.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty shared plugin |
* @package Smarty |
* @subpackage PluginsShared |
*/ |
/** |
* escape_special_chars common function |
* |
* Function: smarty_function_escape_special_chars<br> |
* Purpose: used by other smarty functions to escape |
* special chars except for already escaped ones |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @return string |
*/ |
function smarty_function_escape_special_chars($string) |
{ |
if(!is_array($string)) { |
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
$string = htmlspecialchars($string); |
$string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); |
} |
return $string; |
} |
/* vim: set expandtab: */ |
?> |
/branches/ant-ng/lib/plugins/function.html_checkboxes.php |
---|
Новый файл |
0,0 → 1,145 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_checkboxes} function plugin |
* |
* File: function.html_checkboxes.php<br> |
* Type: function<br> |
* Name: html_checkboxes<br> |
* Date: 24.Feb.2003<br> |
* Purpose: Prints out a list of checkbox input types<br> |
* Examples: |
* <pre> |
* {html_checkboxes values=$ids output=$names} |
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names} |
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names} |
* </pre> |
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} |
* (Smarty online manual) |
* @author Christopher Kvarme <christopher.kvarme@flashjab.com> |
* @author credits to Monte Ohrt <monte at ohrt dot com> |
* @version 1.0 |
* @param array $params parameters |
* Input:<br> |
* - name (optional) - string default "checkbox" |
* - values (required) - array |
* - options (optional) - associative array |
* - checked (optional) - array default not set |
* - separator (optional) - ie <br> or |
* - output (optional) - the output next to each checkbox |
* - assign (optional) - assign the output as an array to this variable |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
* @uses smarty_function_escape_special_chars() |
*/ |
function smarty_function_html_checkboxes($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
//$smarty->loadPlugin('Smarty_shared_escape_special_chars'); |
$name = 'checkbox'; |
$values = null; |
$options = null; |
$selected = null; |
$separator = ''; |
$labels = true; |
$output = null; |
$extra = ''; |
foreach($params as $_key => $_val) { |
switch($_key) { |
case 'name': |
case 'separator': |
$$_key = $_val; |
break; |
case 'labels': |
$$_key = (bool)$_val; |
break; |
case 'options': |
$$_key = (array)$_val; |
break; |
case 'values': |
case 'output': |
$$_key = array_values((array)$_val); |
break; |
case 'checked': |
case 'selected': |
$selected = array_map('strval', array_values((array)$_val)); |
break; |
case 'checkboxes': |
throw new Exception ('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING); |
$options = (array)$_val; |
break; |
case 'assign': |
break; |
default: |
if(!is_array($_val)) { |
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; |
} else { |
throw new Exception ("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
} |
} |
if (!isset($options) && !isset($values)) |
return ''; /* raise error here? */ |
settype($selected, 'array'); |
$_html_result = array(); |
if (isset($options)) { |
foreach ($options as $_key=>$_val) |
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); |
} else { |
foreach ($values as $_i=>$_key) { |
$_val = isset($output[$_i]) ? $output[$_i] : ''; |
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); |
} |
} |
if(!empty($params['assign'])) { |
$template->assign($params['assign'], $_html_result); |
} else { |
return implode("\n",$_html_result); |
} |
} |
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) { |
$_output = ''; |
if ($labels) $_output .= '<label>'; |
$_output .= '<input type="checkbox" name="' |
. smarty_function_escape_special_chars($name) . '[]" value="' |
. smarty_function_escape_special_chars($value) . '"'; |
if (in_array((string)$value, $selected)) { |
$_output .= ' checked="checked"'; |
} |
$_output .= $extra . ' />' . $output; |
if ($labels) $_output .= '</label>'; |
$_output .= $separator; |
return $_output; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.upper.php |
---|
Новый файл |
0,0 → 1,30 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty upper modifier plugin |
* |
* Type: modifier<br> |
* Name: upper<br> |
* Purpose: convert string to uppercase |
* |
* @link http://smarty.php.net/manual/en/language.modifier.upper.php upper (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $ |
* @return string |
*/ |
function smarty_modifier_upper($string) |
{ |
if (function_exists('mb_strtoupper')) { |
return mb_strtoupper($string); |
} else { |
return strtoupper($string); |
} |
} |
?> |
/branches/ant-ng/lib/plugins/function.html_image.php |
---|
Новый файл |
0,0 → 1,139 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {html_image} function plugin |
* |
* Type: function<br> |
* Name: html_image<br> |
* Date: Feb 24, 2003<br> |
* Purpose: format HTML tags for the image<br> |
* Examples: {html_image file="/images/masthead.gif"} |
* Output: <img src="/images/masthead.gif" width=400 height=23> |
* |
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} |
(Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author credits to Duda <duda@big.hu> |
* @version 1.0 |
* @param array $params parameters |
* Input:<br> |
* - file = file (and path) of image (required) |
* - height = image height (optional, default actual height) |
* - width = image width (optional, default actual width) |
* - basedir = base directory for absolute paths, default |
* is environment variable DOCUMENT_ROOT |
* - path_prefix = prefix for path output (optional, default empty) |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string |
* @uses smarty_function_escape_special_chars() |
*/ |
function smarty_function_html_image($params, $smarty, $template) |
{ |
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
//$smarty->loadPlugin('Smarty_shared_escape_special_chars'); |
$alt = ''; |
$file = ''; |
$height = ''; |
$width = ''; |
$extra = ''; |
$prefix = ''; |
$suffix = ''; |
$path_prefix = ''; |
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; |
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; |
foreach($params as $_key => $_val) { |
switch ($_key) { |
case 'file': |
case 'height': |
case 'width': |
case 'dpi': |
case 'path_prefix': |
case 'basedir': |
$$_key = $_val; |
break; |
case 'alt': |
if (!is_array($_val)) { |
$$_key = smarty_function_escape_special_chars($_val); |
} else { |
throw new Exception ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
case 'link': |
case 'href': |
$prefix = '<a href="' . $_val . '">'; |
$suffix = '</a>'; |
break; |
default: |
if (!is_array($_val)) { |
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
} else { |
throw new Exception ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
} |
break; |
} |
} |
if (empty($file)) { |
throw new Exception ("html_image: missing 'file' parameter", E_USER_NOTICE); |
return; |
} |
if (substr($file, 0, 1) == '/') { |
$_image_path = $basedir . $file; |
} else { |
$_image_path = $file; |
} |
if (!isset($params['width']) || !isset($params['height'])) { |
if (!$_image_data = @getimagesize($_image_path)) { |
if (!file_exists($_image_path)) { |
throw new Exception ("html_image: unable to find '$_image_path'", E_USER_NOTICE); |
return; |
} else if (!is_readable($_image_path)) { |
throw new Exception ("html_image: unable to read '$_image_path'", E_USER_NOTICE); |
return; |
} else { |
throw new Exception ("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); |
return; |
} |
} |
if ($template->security) { |
if (!$smarty->security_handler->isTrustedResourceDir($_image_path)) { |
return; |
} |
} |
if (!isset($params['width'])) { |
$width = $_image_data[0]; |
} |
if (!isset($params['height'])) { |
$height = $_image_data[1]; |
} |
} |
if (isset($params['dpi'])) { |
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) { |
$dpi_default = 72; |
} else { |
$dpi_default = 96; |
} |
$_resize = $dpi_default / $params['dpi']; |
$width = round($width * $_resize); |
$height = round($height * $_resize); |
} |
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.spacify.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty spacify modifier plugin |
* |
* Type: modifier<br> |
* Name: spacify<br> |
* Purpose: add spaces between characters in a string |
* |
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $ |
* @param string $ |
* @return string |
*/ |
function smarty_modifier_spacify($string, $spacify_char = ' ') |
{ |
return implode($spacify_char, preg_split('//', $string, -1)); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.count_sentences.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty count_sentences modifier plugin |
* |
* Type: modifier<br> |
* Name: count_sentences |
* Purpose: count the number of sentences in a text |
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php |
* count_sentences (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @return integer |
*/ |
function smarty_modifier_count_sentences($string) |
{ |
// find periods with a word before but not after. |
return preg_match_all('/[^\s]\.(?!\w)/', $string, $match); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.count_paragraphs.php |
---|
Новый файл |
0,0 → 1,26 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty count_paragraphs modifier plugin |
* |
* Type: modifier<br> |
* Name: count_paragraphs<br> |
* Purpose: count the number of paragraphs in a text |
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php |
* count_paragraphs (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @return integer |
*/ |
function smarty_modifier_count_paragraphs($string) |
{ |
// count \r or \n characters |
return count(preg_split('/[\r\n]+/', $string)); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.escape.php |
---|
Новый файл |
0,0 → 1,111 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty escape modifier plugin |
* |
* Type: modifier<br> |
* Name: escape<br> |
* Purpose: escape string for output |
* |
* @link http://smarty.php.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $string input string |
* @param string $esc_type escape type |
* @param string $char_set character set |
* @return string escaped input string |
*/ |
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_RESOURCE_CHAR_SET) |
{ |
switch ($esc_type) { |
case 'html': |
return htmlspecialchars($string, ENT_QUOTES, $char_set); |
case 'htmlall': |
return htmlentities($string, ENT_QUOTES, $char_set); |
case 'url': |
return rawurlencode($string); |
case 'urlpathinfo': |
return str_replace('%2F', '/', rawurlencode($string)); |
case 'quotes': |
// escape unescaped single quotes |
return preg_replace("%(?<!\\\\)'%", "\\'", $string); |
case 'hex': |
// escape every character into hex |
$return = ''; |
for ($x = 0; $x < strlen($string); $x++) { |
$return .= '%' . bin2hex($string[$x]); |
} |
return $return; |
case 'hexentity': |
$return = ''; |
for ($x = 0; $x < strlen($string); $x++) { |
$return .= '&#x' . bin2hex($string[$x]) . ';'; |
} |
return $return; |
case 'decentity': |
$return = ''; |
for ($x = 0; $x < strlen($string); $x++) { |
$return .= '&#' . ord($string[$x]) . ';'; |
} |
return $return; |
case 'javascript': |
// escape quotes and backslashes, newlines, etc. |
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/')); |
case 'mail': |
// safe way to display e-mail address on a web page |
if ($smarty->has_mb) { |
return mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
} else { |
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
} |
case 'nonstd': |
// escape non-standard chars, such as ms document quotes |
$_res = ''; |
for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { |
$_ord = ord(substr($string, $_i, 1)); |
// non-standard char, escape it |
if ($_ord >= 126) { |
$_res .= '&#' . $_ord . ';'; |
} else { |
$_res .= substr($string, $_i, 1); |
} |
} |
return $_res; |
default: |
return $string; |
} |
if (!function_exists("mb_str_replace")) { |
// simulate the missing PHP mb_str_replace function |
function mb_str_replace($needle, $replacement, $haystack) |
{ |
$needle_len = mb_strlen($needle); |
$replacement_len = mb_strlen($replacement); |
$pos = mb_strpos($haystack, $needle, 0); |
while ($pos !== false) { |
$haystack = mb_substr($haystack, 0, $pos) . $replacement |
. mb_substr($haystack, $pos + $needle_len); |
$pos = mb_strpos($haystack, $needle, $pos + $replacement_len); |
} |
return $haystack; |
} |
} |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.strip.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty strip modifier plugin |
* |
* Type: modifier<br> |
* Name: strip<br> |
* Purpose: Replace all repeated spaces, newlines, tabs |
* with a single space or supplied replacement string.<br> |
* Example: {$var|strip} {$var|strip:" "} |
* Date: September 25th, 2002 |
* |
* @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @version 1.0 |
* @param string $ |
* @param string $ |
* @return string |
*/ |
function smarty_modifier_strip($text, $replace = ' ') |
{ |
return preg_replace('!\s+!', $replace, $text); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.count_words.php |
---|
Новый файл |
0,0 → 1,25 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty count_words modifier plugin |
* |
* Type: modifier<br> |
* Name: count_words<br> |
* Purpose: count the number of words in a text |
* @link http://smarty.php.net/manual/en/language.modifier.count.words.php |
* count_words (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @return integer |
*/ |
function smarty_modifier_count_words($string) |
{ |
return str_word_count($string); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.cat.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty cat modifier plugin |
* |
* Type: modifier<br> |
* Name: cat<br> |
* Date: Feb 24, 2003 |
* Purpose: catenate a value to a variable |
* Input: string to catenate |
* Example: {$var|cat:"foo"} |
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @version 1.0 |
* @param string |
* @param string |
* @return string |
*/ |
function smarty_modifier_cat($string, $cat) |
{ |
return $string . $cat; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.debug_print_var.php |
---|
Новый файл |
0,0 → 1,89 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage Debug |
*/ |
/** |
* Smarty debug_print_var modifier plugin |
* |
* Type: modifier<br> |
* Name: debug_print_var<br> |
* Purpose: formats variable contents for display in the console |
* |
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param array $ |object |
* @param integer $ |
* @param integer $ |
* @return string |
*/ |
class Smarty_Modifier_Debug_Print_Var { |
static function execute ($var, $depth = 0, $length = 40) |
{ |
$_replace = array("\n" => '<i>\n</i>', |
"\r" => '<i>\r</i>', |
"\t" => '<i>\t</i>' |
); |
switch (gettype($var)) { |
case 'array' : |
$results = '<b>Array (' . count($var) . ')</b>'; |
foreach ($var as $curr_key => $curr_val) { |
$results .= '<br>' . str_repeat(' ', $depth * 2) |
. '<b>' . strtr($curr_key, $_replace) . '</b> => ' |
. self::execute($curr_val, ++$depth, $length); |
$depth--; |
} |
break; |
case 'object' : |
$object_vars = get_object_vars($var); |
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; |
foreach ($object_vars as $curr_key => $curr_val) { |
$results .= '<br>' . str_repeat(' ', $depth * 2) |
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = ' |
. self::execute($curr_val, ++$depth, $length); |
$depth--; |
} |
break; |
case 'boolean' : |
case 'NULL' : |
case 'resource' : |
if (true === $var) { |
$results = 'true'; |
} elseif (false === $var) { |
$results = 'false'; |
} elseif (null === $var) { |
$results = 'null'; |
} else { |
$results = htmlspecialchars((string) $var); |
} |
$results = '<i>' . $results . '</i>'; |
break; |
case 'integer' : |
case 'float' : |
$results = htmlspecialchars((string) $var); |
break; |
case 'string' : |
$results = strtr($var, $_replace); |
if (strlen($var) > $length) { |
$results = substr($var, 0, $length - 3) . '...'; |
} |
$results = htmlspecialchars('"' . $results . '"'); |
break; |
case 'unknown type' : |
default : |
$results = strtr((string) $var, $_replace); |
if (strlen($results) > $length) { |
$results = substr($results, 0, $length - 3) . '...'; |
} |
$results = htmlspecialchars($results); |
} |
return $results; |
} |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.replace.php |
---|
Новый файл |
0,0 → 1,48 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty replace modifier plugin |
* |
* Type: modifier<br> |
* Name: replace<br> |
* Purpose: simple search/replace |
* |
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author Uwe Tews |
* @param string $ |
* @param string $ |
* @param string $ |
* @return string |
*/ |
function smarty_modifier_replace($string, $search, $replace) |
{ |
if (!function_exists("mb_str_replace")) { |
// simulate the missing PHP mb_str_replace function |
function mb_str_replace($needle, $replacement, $haystack) |
{ |
$needle_len = mb_strlen($needle); |
$replacement_len = mb_strlen($replacement); |
$pos = mb_strpos($haystack, $needle, 0); |
while ($pos !== false) { |
$haystack = mb_substr($haystack, 0, $pos) . $replacement |
. mb_substr($haystack, $pos + $needle_len); |
$pos = mb_strpos($haystack, $needle, $pos + $replacement_len); |
} |
return $haystack; |
} |
} |
if (function_exists('mb_substr')) { |
return mb_str_replace($search, $replace, $string); |
} else { |
return str_replace($search, $replace, $string); |
} |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.string_format.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty string_format modifier plugin |
* |
* Type: modifier<br> |
* Name: string_format<br> |
* Purpose: format strings via sprintf |
* |
* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $string input string |
* @param string $format format string |
* @return string formatted string |
*/ |
function smarty_modifier_string_format($string, $format) |
{ |
return sprintf($format, $string); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.strip_tags.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty strip_tags modifier plugin |
* |
* Type: modifier<br> |
* Name: strip_tags<br> |
* Purpose: strip html tags from text |
* |
* @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $ |
* @param boolean $ |
* @return string |
*/ |
function smarty_modifier_strip_tags($string, $replace_with_space = true) |
{ |
if ($replace_with_space) { |
return preg_replace('!<[^>]*?>!', ' ', $string); |
} else { |
return strip_tags($string); |
} |
} |
?> |
/branches/ant-ng/lib/plugins/block.php.php |
---|
Новый файл |
0,0 → 1,39 |
<?php |
/** |
* Smarty plugin to execute PHP code |
* |
* @package Smarty |
* @subpackage PluginsBlock |
* @author Uwe Tews |
*/ |
/** |
* Smarty {php}{/php} block plugin |
* |
* @param string $content contents of the block |
* @param object $smarty Smarty object |
* @param boolean $ &$repeat repeat flag |
* @param object $template template object |
* @return string content re-formatted |
*/ |
function smarty_block_php($params, $content, $smarty, &$repeat, $template) |
{ |
// get security settings |
if ($template->security && isset($smarty->security_handler)) { |
$sec_obj = $smarty->security_policy; |
} else { |
$sec_obj = $smarty; |
} |
if (is_null($content)) { |
if (!$smarty->allow_php_tag) { |
trigger_error("{php} is deprecated, set allow_php_tag = true to enable", E_USER_WARNING); |
} |
return; |
} |
eval($content); |
return ''; |
} |
?> |
/branches/ant-ng/lib/plugins/variablefilter.htmlspecialchars.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsFilter |
*/ |
/** |
* Smarty htmlspecialchars variablefilter plugin |
* |
* @param string $source input string |
* @param object $ &$smarty Smarty object |
* @return string filtered output |
*/ |
function smarty_variablefilter_htmlspecialchars($source, &$smarty) |
{ |
return htmlspecialchars($source, ENT_QUOTES); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.default.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty default modifier plugin |
* |
* Type: modifier<br> |
* Name: default<br> |
* Purpose: designate default value for empty variables |
* @link http://smarty.php.net/manual/en/language.modifier.default.php |
* default (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @param string |
* @return string |
*/ |
function smarty_modifier_default($string, $default = '') |
{ |
if (!isset($string) || $string === '') |
return $default; |
else |
return $string; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.date_format.php |
---|
Новый файл |
0,0 → 1,57 |
<?php |
/** |
* Smarty plugin |
* |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty date_format modifier plugin |
* |
* Type: modifier<br> |
* Name: date_format<br> |
* Purpose: format datestamps via strftime<br> |
* Input:<br> |
* - string: input date string |
* - format: strftime format for output |
* - default_date: default date if $string is empty |
* |
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $ |
* @param string $ |
* @param string $ |
* @return string |void |
* @uses smarty_make_timestamp() |
*/ |
function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '') |
{ |
/** |
* Include the {@link shared.make_timestamp.php} plugin |
*/ |
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); |
if ($string != '') { |
$timestamp = smarty_make_timestamp($string); |
} elseif ($default_date != '') { |
$timestamp = smarty_make_timestamp($default_date); |
} else { |
return; |
} |
if (DS == '\\') { |
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
if (strpos($format, '%e') !== false) { |
$_win_from[] = '%e'; |
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); |
} |
if (strpos($format, '%l') !== false) { |
$_win_from[] = '%l'; |
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); |
} |
$format = str_replace($_win_from, $_win_to, $format); |
} |
return strftime($format, $timestamp); |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.capitalize.php |
---|
Новый файл |
0,0 → 1,41 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty capitalize modifier plugin |
* |
* Type: modifier<br> |
* Name: capitalize<br> |
* Purpose: capitalize words in the string |
* @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE |
* capitalize (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string |
* @return string |
*/ |
function smarty_modifier_capitalize($string, $uc_digits = false) |
{ |
smarty_modifier_capitalize_ucfirst(null, $uc_digits); |
return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string); |
} |
function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null) |
{ |
static $_uc_digits = false; |
if(isset($uc_digits)) { |
$_uc_digits = $uc_digits; |
return; |
} |
if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits) |
return ucfirst($string[0]); |
else |
return $string[0]; |
} |
?> |
/branches/ant-ng/lib/plugins/function.cycle.php |
---|
Новый файл |
0,0 → 1,97 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsFunction |
*/ |
/** |
* Smarty {cycle} function plugin |
* |
* Type: function<br> |
* Name: cycle<br> |
* Date: May 3, 2002<br> |
* Purpose: cycle through given values<br> |
* |
* Examples:<br> |
* <pre> |
* {cycle values="#eeeeee,#d0d0d0d"} |
* {cycle name=row values="one,two,three" reset=true} |
* {cycle name=row} |
* </pre> |
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} |
* (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author credit to Mark Priatel <mpriatel@rogers.com> |
* @author credit to Gerard <gerard@interfold.com> |
* @author credit to Jason Sweat <jsweat_php@yahoo.com> |
* @param array $params parameters |
* Input: |
* - name = name of cycle (optional) |
* - values = comma separated list of values to cycle, |
* or an array of values to cycle |
* (this can be left out for subsequent calls) |
* - reset = boolean - resets given var to true |
* - print = boolean - print var or not. default is true |
* - advance = boolean - whether or not to advance the cycle |
* - delimiter = the value delimiter, default is "," |
* - assign = boolean, assigns to template var instead of |
* printed. |
* @param object $smarty Smarty object |
* @param object $template template object |
* @return string|null |
*/ |
function smarty_function_cycle($params, $smarty, $template) |
{ |
$name = (empty($params['name'])) ? 'default' : $params['name']; |
$print = (isset($params['print'])) ? (bool)$params['print'] : true; |
$advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; |
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; |
if (!in_array('values', array_keys($params))) { |
if(!isset($template->plugin_data['cycle'][$name]['values'])) { |
throw new Exception ("cycle: missing 'values' parameter"); |
return; |
} |
} else { |
if(isset($template->plugin_data['cycle'][$name]['values']) |
&& $template->plugin_data['cycle'][$name]['values'] != $params['values'] ) { |
$template->plugin_data['cycle'][$name]['index'] = 0; |
} |
$template->plugin_data['cycle'][$name]['values'] = $params['values']; |
} |
$template->plugin_data['cycle'][$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ','; |
if(is_array($template->plugin_data['cycle'][$name]['values'])) { |
$cycle_array = $template->plugin_data['cycle'][$name]['values']; |
} else { |
$cycle_array = explode($template->plugin_data['cycle'][$name]['delimiter'],$template->plugin_data['cycle'][$name]['values']); |
} |
if(!isset($template->plugin_data['cycle'][$name]['index']) || $reset ) { |
$template->plugin_data['cycle'][$name]['index'] = 0; |
} |
if (isset($params['assign'])) { |
$print = false; |
$template->assign($params['assign'], $cycle_array[$template->plugin_data['cycle'][$name]['index']]); |
} |
if($print) { |
$retval = $cycle_array[$template->plugin_data['cycle'][$name]['index']]; |
} else { |
$retval = null; |
} |
if($advance) { |
if ( $template->plugin_data['cycle'][$name]['index'] >= count($cycle_array) -1 ) { |
$template->plugin_data['cycle'][$name]['index'] = 0; |
} else { |
$template->plugin_data['cycle'][$name]['index']++; |
} |
} |
return $retval; |
} |
?> |
/branches/ant-ng/lib/plugins/modifier.count_characters.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty plugin |
* @package Smarty |
* @subpackage PluginsModifier |
*/ |
/** |
* Smarty count_characters modifier plugin |
* |
* Type: modifier<br> |
* Name: count_characteres<br> |
* Purpose: count the number of characters in a text |
* @link http://smarty.php.net/manual/en/language.modifier.count.characters.php |
* count_characters (Smarty online manual) |
* @author Monte Ohrt <monte at ohrt dot com> |
* @param string $string input string |
* @param boolean $include_spaces include whitespace in the character count |
* @return integer number of characters |
*/ |
function smarty_modifier_count_characters($string, $include_spaces = false) |
{ |
if ($include_spaces) |
return(strlen($string)); |
return preg_match_all("/[^\s]/",$string, $match); |
} |
?> |
/branches/ant-ng/lib/DB/storage.php |
---|
Новый файл |
0,0 → 1,506 |
<?php |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
/** |
* Provides an object interface to a table row |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <stig@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: storage.php,v 1.24 2007/08/12 05:27:25 aharvey Exp $ |
* @link http://pear.php.net/package/DB |
*/ |
/** |
* Obtain the DB class so it can be extended from |
*/ |
require_once 'DB.php'; |
/** |
* Provides an object interface to a table row |
* |
* It lets you add, delete and change rows using objects rather than SQL |
* statements. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <stig@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB_storage extends PEAR |
{ |
// {{{ properties |
/** the name of the table (or view, if the backend database supports |
updates in views) we hold data from */ |
var $_table = null; |
/** which column(s) in the table contains primary keys, can be a |
string for single-column primary keys, or an array of strings |
for multiple-column primary keys */ |
var $_keycolumn = null; |
/** DB connection handle used for all transactions */ |
var $_dbh = null; |
/** an assoc with the names of database fields stored as properties |
in this object */ |
var $_properties = array(); |
/** an assoc with the names of the properties in this object that |
have been changed since they were fetched from the database */ |
var $_changes = array(); |
/** flag that decides if data in this object can be changed. |
objects that don't have their table's key column in their |
property lists will be flagged as read-only. */ |
var $_readonly = false; |
/** function or method that implements a validator for fields that |
are set, this validator function returns true if the field is |
valid, false if not */ |
var $_validator = null; |
// }}} |
// {{{ constructor |
/** |
* Constructor |
* |
* @param $table string the name of the database table |
* |
* @param $keycolumn mixed string with name of key column, or array of |
* strings if the table has a primary key of more than one column |
* |
* @param $dbh object database connection object |
* |
* @param $validator mixed function or method used to validate |
* each new value, called with three parameters: the name of the |
* field/column that is changing, a reference to the new value and |
* a reference to this object |
* |
*/ |
function DB_storage($table, $keycolumn, &$dbh, $validator = null) |
{ |
$this->PEAR('DB_Error'); |
$this->_table = $table; |
$this->_keycolumn = $keycolumn; |
$this->_dbh = $dbh; |
$this->_readonly = false; |
$this->_validator = $validator; |
} |
// }}} |
// {{{ _makeWhere() |
/** |
* Utility method to build a "WHERE" clause to locate ourselves in |
* the table. |
* |
* XXX future improvement: use rowids? |
* |
* @access private |
*/ |
function _makeWhere($keyval = null) |
{ |
if (is_array($this->_keycolumn)) { |
if ($keyval === null) { |
for ($i = 0; $i < sizeof($this->_keycolumn); $i++) { |
$keyval[] = $this->{$this->_keycolumn[$i]}; |
} |
} |
$whereclause = ''; |
for ($i = 0; $i < sizeof($this->_keycolumn); $i++) { |
if ($i > 0) { |
$whereclause .= ' AND '; |
} |
$whereclause .= $this->_keycolumn[$i]; |
if (is_null($keyval[$i])) { |
// there's not much point in having a NULL key, |
// but we support it anyway |
$whereclause .= ' IS NULL'; |
} else { |
$whereclause .= ' = ' . $this->_dbh->quote($keyval[$i]); |
} |
} |
} else { |
if ($keyval === null) { |
$keyval = @$this->{$this->_keycolumn}; |
} |
$whereclause = $this->_keycolumn; |
if (is_null($keyval)) { |
// there's not much point in having a NULL key, |
// but we support it anyway |
$whereclause .= ' IS NULL'; |
} else { |
$whereclause .= ' = ' . $this->_dbh->quote($keyval); |
} |
} |
return $whereclause; |
} |
// }}} |
// {{{ setup() |
/** |
* Method used to initialize a DB_storage object from the |
* configured table. |
* |
* @param $keyval mixed the key[s] of the row to fetch (string or array) |
* |
* @return int DB_OK on success, a DB error if not |
*/ |
function setup($keyval) |
{ |
$whereclause = $this->_makeWhere($keyval); |
$query = 'SELECT * FROM ' . $this->_table . ' WHERE ' . $whereclause; |
$sth = $this->_dbh->query($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$row = $sth->fetchRow(DB_FETCHMODE_ASSOC); |
if (DB::isError($row)) { |
return $row; |
} |
if (!$row) { |
return $this->raiseError(null, DB_ERROR_NOT_FOUND, null, null, |
$query, null, true); |
} |
foreach ($row as $key => $value) { |
$this->_properties[$key] = true; |
$this->$key = $value; |
} |
return DB_OK; |
} |
// }}} |
// {{{ insert() |
/** |
* Create a new (empty) row in the configured table for this |
* object. |
*/ |
function insert($newpk) |
{ |
if (is_array($this->_keycolumn)) { |
$primarykey = $this->_keycolumn; |
} else { |
$primarykey = array($this->_keycolumn); |
} |
settype($newpk, "array"); |
for ($i = 0; $i < sizeof($primarykey); $i++) { |
$pkvals[] = $this->_dbh->quote($newpk[$i]); |
} |
$sth = $this->_dbh->query("INSERT INTO $this->_table (" . |
implode(",", $primarykey) . ") VALUES(" . |
implode(",", $pkvals) . ")"); |
if (DB::isError($sth)) { |
return $sth; |
} |
if (sizeof($newpk) == 1) { |
$newpk = $newpk[0]; |
} |
$this->setup($newpk); |
} |
// }}} |
// {{{ toString() |
/** |
* Output a simple description of this DB_storage object. |
* @return string object description |
*/ |
function toString() |
{ |
$info = strtolower(get_class($this)); |
$info .= " (table="; |
$info .= $this->_table; |
$info .= ", keycolumn="; |
if (is_array($this->_keycolumn)) { |
$info .= "(" . implode(",", $this->_keycolumn) . ")"; |
} else { |
$info .= $this->_keycolumn; |
} |
$info .= ", dbh="; |
if (is_object($this->_dbh)) { |
$info .= $this->_dbh->toString(); |
} else { |
$info .= "null"; |
} |
$info .= ")"; |
if (sizeof($this->_properties)) { |
$info .= " [loaded, key="; |
$keyname = $this->_keycolumn; |
if (is_array($keyname)) { |
$info .= "("; |
for ($i = 0; $i < sizeof($keyname); $i++) { |
if ($i > 0) { |
$info .= ","; |
} |
$info .= $this->$keyname[$i]; |
} |
$info .= ")"; |
} else { |
$info .= $this->$keyname; |
} |
$info .= "]"; |
} |
if (sizeof($this->_changes)) { |
$info .= " [modified]"; |
} |
return $info; |
} |
// }}} |
// {{{ dump() |
/** |
* Dump the contents of this object to "standard output". |
*/ |
function dump() |
{ |
foreach ($this->_properties as $prop => $foo) { |
print "$prop = "; |
print htmlentities($this->$prop); |
print "<br />\n"; |
} |
} |
// }}} |
// {{{ &create() |
/** |
* Static method used to create new DB storage objects. |
* @param $data assoc. array where the keys are the names |
* of properties/columns |
* @return object a new instance of DB_storage or a subclass of it |
*/ |
function &create($table, &$data) |
{ |
$classname = strtolower(get_class($this)); |
$obj = new $classname($table); |
foreach ($data as $name => $value) { |
$obj->_properties[$name] = true; |
$obj->$name = &$value; |
} |
return $obj; |
} |
// }}} |
// {{{ loadFromQuery() |
/** |
* Loads data into this object from the given query. If this |
* object already contains table data, changes will be saved and |
* the object re-initialized first. |
* |
* @param $query SQL query |
* |
* @param $params parameter list in case you want to use |
* prepare/execute mode |
* |
* @return int DB_OK on success, DB_WARNING_READ_ONLY if the |
* returned object is read-only (because the object's specified |
* key column was not found among the columns returned by $query), |
* or another DB error code in case of errors. |
*/ |
// XXX commented out for now |
/* |
function loadFromQuery($query, $params = null) |
{ |
if (sizeof($this->_properties)) { |
if (sizeof($this->_changes)) { |
$this->store(); |
$this->_changes = array(); |
} |
$this->_properties = array(); |
} |
$rowdata = $this->_dbh->getRow($query, DB_FETCHMODE_ASSOC, $params); |
if (DB::isError($rowdata)) { |
return $rowdata; |
} |
reset($rowdata); |
$found_keycolumn = false; |
while (list($key, $value) = each($rowdata)) { |
if ($key == $this->_keycolumn) { |
$found_keycolumn = true; |
} |
$this->_properties[$key] = true; |
$this->$key = &$value; |
unset($value); // have to unset, or all properties will |
// refer to the same value |
} |
if (!$found_keycolumn) { |
$this->_readonly = true; |
return DB_WARNING_READ_ONLY; |
} |
return DB_OK; |
} |
*/ |
// }}} |
// {{{ set() |
/** |
* Modify an attriute value. |
*/ |
function set($property, $newvalue) |
{ |
// only change if $property is known and object is not |
// read-only |
if ($this->_readonly) { |
return $this->raiseError(null, DB_WARNING_READ_ONLY, null, |
null, null, null, true); |
} |
if (@isset($this->_properties[$property])) { |
if (empty($this->_validator)) { |
$valid = true; |
} else { |
$valid = @call_user_func($this->_validator, |
$this->_table, |
$property, |
$newvalue, |
$this->$property, |
$this); |
} |
if ($valid) { |
$this->$property = $newvalue; |
if (empty($this->_changes[$property])) { |
$this->_changes[$property] = 0; |
} else { |
$this->_changes[$property]++; |
} |
} else { |
return $this->raiseError(null, DB_ERROR_INVALID, null, |
null, "invalid field: $property", |
null, true); |
} |
return true; |
} |
return $this->raiseError(null, DB_ERROR_NOSUCHFIELD, null, |
null, "unknown field: $property", |
null, true); |
} |
// }}} |
// {{{ &get() |
/** |
* Fetch an attribute value. |
* |
* @param string attribute name |
* |
* @return attribute contents, or null if the attribute name is |
* unknown |
*/ |
function &get($property) |
{ |
// only return if $property is known |
if (isset($this->_properties[$property])) { |
return $this->$property; |
} |
$tmp = null; |
return $tmp; |
} |
// }}} |
// {{{ _DB_storage() |
/** |
* Destructor, calls DB_storage::store() if there are changes |
* that are to be kept. |
*/ |
function _DB_storage() |
{ |
if (sizeof($this->_changes)) { |
$this->store(); |
} |
$this->_properties = array(); |
$this->_changes = array(); |
$this->_table = null; |
} |
// }}} |
// {{{ store() |
/** |
* Stores changes to this object in the database. |
* |
* @return DB_OK or a DB error |
*/ |
function store() |
{ |
$params = array(); |
$vars = array(); |
foreach ($this->_changes as $name => $foo) { |
$params[] = &$this->$name; |
$vars[] = $name . ' = ?'; |
} |
if ($vars) { |
$query = 'UPDATE ' . $this->_table . ' SET ' . |
implode(', ', $vars) . ' WHERE ' . |
$this->_makeWhere(); |
$stmt = $this->_dbh->prepare($query); |
$res = $this->_dbh->execute($stmt, $params); |
if (DB::isError($res)) { |
return $res; |
} |
$this->_changes = array(); |
} |
return DB_OK; |
} |
// }}} |
// {{{ remove() |
/** |
* Remove the row represented by this object from the database. |
* |
* @return mixed DB_OK or a DB error |
*/ |
function remove() |
{ |
if ($this->_readonly) { |
return $this->raiseError(null, DB_WARNING_READ_ONLY, null, |
null, null, null, true); |
} |
$query = 'DELETE FROM ' . $this->_table .' WHERE '. |
$this->_makeWhere(); |
$res = $this->_dbh->query($query); |
if (DB::isError($res)) { |
return $res; |
} |
foreach ($this->_properties as $prop => $foo) { |
unset($this->$prop); |
} |
$this->_properties = array(); |
$this->_changes = array(); |
return DB_OK; |
} |
// }}} |
} |
/* |
* Local variables: |
* tab-width: 4 |
* c-basic-offset: 4 |
* End: |
*/ |
?> |
/branches/ant-ng/lib/DB/mysql.php |
---|
Новый файл |
0,0 → 1,1045 |
<?php |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
/** |
* The PEAR DB driver for PHP's mysql extension |
* for interacting with MySQL databases |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: mysql.php,v 1.126 2007/09/21 13:32:52 aharvey Exp $ |
* @link http://pear.php.net/package/DB |
*/ |
/** |
* Obtain the DB_common class so it can be extended from |
*/ |
require_once 'lib/DB/common.php'; |
/** |
* The methods PEAR DB uses to interact with PHP's mysql extension |
* for interacting with MySQL databases |
* |
* These methods overload the ones declared in DB_common. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB_mysql extends DB_common |
{ |
// {{{ properties |
/** |
* The DB driver type (mysql, oci8, odbc, etc.) |
* @var string |
*/ |
var $phptype = 'mysql'; |
/** |
* The database syntax variant to be used (db2, access, etc.), if any |
* @var string |
*/ |
var $dbsyntax = 'mysql'; |
/** |
* The capabilities of this DB implementation |
* |
* The 'new_link' element contains the PHP version that first provided |
* new_link support for this DBMS. Contains false if it's unsupported. |
* |
* Meaning of the 'limit' element: |
* + 'emulate' = emulate with fetch row by number |
* + 'alter' = alter the query |
* + false = skip rows |
* |
* @var array |
*/ |
var $features = array( |
'limit' => 'alter', |
'new_link' => '4.2.0', |
'numrows' => true, |
'pconnect' => true, |
'prepare' => false, |
'ssl' => false, |
'transactions' => true, |
); |
/** |
* A mapping of native error codes to DB error codes |
* @var array |
*/ |
var $errorcode_map = array( |
1004 => DB_ERROR_CANNOT_CREATE, |
1005 => DB_ERROR_CANNOT_CREATE, |
1006 => DB_ERROR_CANNOT_CREATE, |
1007 => DB_ERROR_ALREADY_EXISTS, |
1008 => DB_ERROR_CANNOT_DROP, |
1022 => DB_ERROR_ALREADY_EXISTS, |
1044 => DB_ERROR_ACCESS_VIOLATION, |
1046 => DB_ERROR_NODBSELECTED, |
1048 => DB_ERROR_CONSTRAINT, |
1049 => DB_ERROR_NOSUCHDB, |
1050 => DB_ERROR_ALREADY_EXISTS, |
1051 => DB_ERROR_NOSUCHTABLE, |
1054 => DB_ERROR_NOSUCHFIELD, |
1061 => DB_ERROR_ALREADY_EXISTS, |
1062 => DB_ERROR_ALREADY_EXISTS, |
1064 => DB_ERROR_SYNTAX, |
1091 => DB_ERROR_NOT_FOUND, |
1100 => DB_ERROR_NOT_LOCKED, |
1136 => DB_ERROR_VALUE_COUNT_ON_ROW, |
1142 => DB_ERROR_ACCESS_VIOLATION, |
1146 => DB_ERROR_NOSUCHTABLE, |
1216 => DB_ERROR_CONSTRAINT, |
1217 => DB_ERROR_CONSTRAINT, |
1356 => DB_ERROR_DIVZERO, |
1451 => DB_ERROR_CONSTRAINT, |
1452 => DB_ERROR_CONSTRAINT, |
); |
/** |
* The raw database connection created by PHP |
* @var resource |
*/ |
var $connection; |
/** |
* The DSN information for connecting to a database |
* @var array |
*/ |
var $dsn = array(); |
/** |
* Should data manipulation queries be committed automatically? |
* @var bool |
* @access private |
*/ |
var $autocommit = true; |
/** |
* The quantity of transactions begun |
* |
* {@internal While this is private, it can't actually be designated |
* private in PHP 5 because it is directly accessed in the test suite.}} |
* |
* @var integer |
* @access private |
*/ |
var $transaction_opcount = 0; |
/** |
* The database specified in the DSN |
* |
* It's a fix to allow calls to different databases in the same script. |
* |
* @var string |
* @access private |
*/ |
var $_db = ''; |
// }}} |
// {{{ constructor |
/** |
* This constructor calls <kbd>$this->DB_common()</kbd> |
* |
* @return void |
*/ |
function DB_mysql() |
{ |
$this->DB_common(); |
} |
// }}} |
// {{{ connect() |
/** |
* Connect to the database server, log in and open the database |
* |
* Don't call this method directly. Use DB::connect() instead. |
* |
* PEAR DB's mysql driver supports the following extra DSN options: |
* + new_link If set to true, causes subsequent calls to connect() |
* to return a new connection link instead of the |
* existing one. WARNING: this is not portable to |
* other DBMS's. Available since PEAR DB 1.7.0. |
* + client_flags Any combination of MYSQL_CLIENT_* constants. |
* Only used if PHP is at version 4.3.0 or greater. |
* Available since PEAR DB 1.7.0. |
* |
* @param array $dsn the data source name |
* @param bool $persistent should the connection be persistent? |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
*/ |
function connect($dsn, $persistent = false) |
{ |
if (!PEAR::loadExtension('mysql')) { |
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); |
} |
$this->dsn = $dsn; |
if ($dsn['dbsyntax']) { |
$this->dbsyntax = $dsn['dbsyntax']; |
} |
$params = array(); |
if ($dsn['protocol'] && $dsn['protocol'] == 'unix') { |
$params[0] = ':' . $dsn['socket']; |
} else { |
$params[0] = $dsn['hostspec'] ? $dsn['hostspec'] |
: 'localhost'; |
if ($dsn['port']) { |
$params[0] .= ':' . $dsn['port']; |
} |
} |
$params[] = $dsn['username'] ? $dsn['username'] : null; |
$params[] = $dsn['password'] ? $dsn['password'] : null; |
if (!$persistent) { |
if (isset($dsn['new_link']) |
&& ($dsn['new_link'] == 'true' || $dsn['new_link'] === true)) |
{ |
$params[] = true; |
} else { |
$params[] = false; |
} |
} |
if (version_compare(phpversion(), '4.3.0', '>=')) { |
$params[] = isset($dsn['client_flags']) |
? $dsn['client_flags'] : null; |
} |
$connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect'; |
$ini = ini_get('track_errors'); |
$php_errormsg = ''; |
if ($ini) { |
$this->connection = @call_user_func_array($connect_function, |
$params); |
} else { |
@ini_set('track_errors', 1); |
$this->connection = @call_user_func_array($connect_function, |
$params); |
@ini_set('track_errors', $ini); |
} |
if (!$this->connection) { |
if (($err = @mysql_error()) != '') { |
return $this->raiseError(DB_ERROR_CONNECT_FAILED, |
null, null, null, |
$err); |
} else { |
return $this->raiseError(DB_ERROR_CONNECT_FAILED, |
null, null, null, |
$php_errormsg); |
} |
} |
if ($dsn['database']) { |
if (!@mysql_select_db($dsn['database'], $this->connection)) { |
return $this->mysqlRaiseError(); |
} |
$this->_db = $dsn['database']; |
} |
return DB_OK; |
} |
// }}} |
// {{{ disconnect() |
/** |
* Disconnects from the database server |
* |
* @return bool TRUE on success, FALSE on failure |
*/ |
function disconnect() |
{ |
$ret = @mysql_close($this->connection); |
$this->connection = null; |
return $ret; |
} |
// }}} |
// {{{ simpleQuery() |
/** |
* Sends a query to the database server |
* |
* Generally uses mysql_query(). If you want to use |
* mysql_unbuffered_query() set the "result_buffering" option to 0 using |
* setOptions(). This option was added in Release 1.7.0. |
* |
* @param string the SQL query string |
* |
* @return mixed + a PHP result resrouce for successful SELECT queries |
* + the DB_OK constant for other successful queries |
* + a DB_Error object on failure |
*/ |
function simpleQuery($query) |
{ |
$ismanip = $this->_checkManip($query); |
$this->last_query = $query; |
$query = $this->modifyQuery($query); |
if ($this->_db) { |
if (!@mysql_select_db($this->_db, $this->connection)) { |
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); |
} |
} |
if (!$this->autocommit && $ismanip) { |
if ($this->transaction_opcount == 0) { |
$result = @mysql_query('SET AUTOCOMMIT=0', $this->connection); |
$result = @mysql_query('BEGIN', $this->connection); |
if (!$result) { |
return $this->mysqlRaiseError(); |
} |
} |
$this->transaction_opcount++; |
} |
if (!$this->options['result_buffering']) { |
$result = @mysql_unbuffered_query($query, $this->connection); |
} else { |
$result = @mysql_query($query, $this->connection); |
} |
if (!$result) { |
return $this->mysqlRaiseError(); |
} |
if (is_resource($result)) { |
return $result; |
} |
return DB_OK; |
} |
// }}} |
// {{{ nextResult() |
/** |
* Move the internal mysql result pointer to the next available result |
* |
* This method has not been implemented yet. |
* |
* @param a valid sql result resource |
* |
* @return false |
*/ |
function nextResult($result) |
{ |
return false; |
} |
// }}} |
// {{{ fetchInto() |
/** |
* Places a row from the result set into the given array |
* |
* Formating of the array and the data therein are configurable. |
* See DB_result::fetchInto() for more information. |
* |
* This method is not meant to be called directly. Use |
* DB_result::fetchInto() instead. It can't be declared "protected" |
* because DB_result is a separate object. |
* |
* @param resource $result the query result resource |
* @param array $arr the referenced array to put the data in |
* @param int $fetchmode how the resulting array should be indexed |
* @param int $rownum the row number to fetch (0 = first row) |
* |
* @return mixed DB_OK on success, NULL when the end of a result set is |
* reached or on failure |
* |
* @see DB_result::fetchInto() |
*/ |
function fetchInto($result, &$arr, $fetchmode, $rownum = null) |
{ |
if ($rownum !== null) { |
if (!@mysql_data_seek($result, $rownum)) { |
return null; |
} |
} |
if ($fetchmode & DB_FETCHMODE_ASSOC) { |
$arr = @mysql_fetch_array($result, MYSQL_ASSOC); |
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) { |
$arr = array_change_key_case($arr, CASE_LOWER); |
} |
} else { |
$arr = @mysql_fetch_row($result); |
} |
if (!$arr) { |
return null; |
} |
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { |
/* |
* Even though this DBMS already trims output, we do this because |
* a field might have intentional whitespace at the end that |
* gets removed by DB_PORTABILITY_RTRIM under another driver. |
*/ |
$this->_rtrimArrayValues($arr); |
} |
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { |
$this->_convertNullArrayValuesToEmpty($arr); |
} |
return DB_OK; |
} |
// }}} |
// {{{ freeResult() |
/** |
* Deletes the result set and frees the memory occupied by the result set |
* |
* This method is not meant to be called directly. Use |
* DB_result::free() instead. It can't be declared "protected" |
* because DB_result is a separate object. |
* |
* @param resource $result PHP's query result resource |
* |
* @return bool TRUE on success, FALSE if $result is invalid |
* |
* @see DB_result::free() |
*/ |
function freeResult($result) |
{ |
return is_resource($result) ? mysql_free_result($result) : false; |
} |
// }}} |
// {{{ numCols() |
/** |
* Gets the number of columns in a result set |
* |
* This method is not meant to be called directly. Use |
* DB_result::numCols() instead. It can't be declared "protected" |
* because DB_result is a separate object. |
* |
* @param resource $result PHP's query result resource |
* |
* @return int the number of columns. A DB_Error object on failure. |
* |
* @see DB_result::numCols() |
*/ |
function numCols($result) |
{ |
$cols = @mysql_num_fields($result); |
if (!$cols) { |
return $this->mysqlRaiseError(); |
} |
return $cols; |
} |
// }}} |
// {{{ numRows() |
/** |
* Gets the number of rows in a result set |
* |
* This method is not meant to be called directly. Use |
* DB_result::numRows() instead. It can't be declared "protected" |
* because DB_result is a separate object. |
* |
* @param resource $result PHP's query result resource |
* |
* @return int the number of rows. A DB_Error object on failure. |
* |
* @see DB_result::numRows() |
*/ |
function numRows($result) |
{ |
$rows = @mysql_num_rows($result); |
if ($rows === null) { |
return $this->mysqlRaiseError(); |
} |
return $rows; |
} |
// }}} |
// {{{ autoCommit() |
/** |
* Enables or disables automatic commits |
* |
* @param bool $onoff true turns it on, false turns it off |
* |
* @return int DB_OK on success. A DB_Error object if the driver |
* doesn't support auto-committing transactions. |
*/ |
function autoCommit($onoff = false) |
{ |
// XXX if $this->transaction_opcount > 0, we should probably |
// issue a warning here. |
$this->autocommit = $onoff ? true : false; |
return DB_OK; |
} |
// }}} |
// {{{ commit() |
/** |
* Commits the current transaction |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
*/ |
function commit() |
{ |
if ($this->transaction_opcount > 0) { |
if ($this->_db) { |
if (!@mysql_select_db($this->_db, $this->connection)) { |
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); |
} |
} |
$result = @mysql_query('COMMIT', $this->connection); |
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); |
$this->transaction_opcount = 0; |
if (!$result) { |
return $this->mysqlRaiseError(); |
} |
} |
return DB_OK; |
} |
// }}} |
// {{{ rollback() |
/** |
* Reverts the current transaction |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
*/ |
function rollback() |
{ |
if ($this->transaction_opcount > 0) { |
if ($this->_db) { |
if (!@mysql_select_db($this->_db, $this->connection)) { |
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); |
} |
} |
$result = @mysql_query('ROLLBACK', $this->connection); |
$result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); |
$this->transaction_opcount = 0; |
if (!$result) { |
return $this->mysqlRaiseError(); |
} |
} |
return DB_OK; |
} |
// }}} |
// {{{ affectedRows() |
/** |
* Determines the number of rows affected by a data maniuplation query |
* |
* 0 is returned for queries that don't manipulate data. |
* |
* @return int the number of rows. A DB_Error object on failure. |
*/ |
function affectedRows() |
{ |
if ($this->_last_query_manip) { |
return @mysql_affected_rows($this->connection); |
} else { |
return 0; |
} |
} |
// }}} |
// {{{ nextId() |
/** |
* Returns the next free id in a sequence |
* |
* @param string $seq_name name of the sequence |
* @param boolean $ondemand when true, the seqence is automatically |
* created if it does not exist |
* |
* @return int the next id number in the sequence. |
* A DB_Error object on failure. |
* |
* @see DB_common::nextID(), DB_common::getSequenceName(), |
* DB_mysql::createSequence(), DB_mysql::dropSequence() |
*/ |
function nextId($seq_name, $ondemand = true) |
{ |
$seqname = $this->getSequenceName($seq_name); |
do { |
$repeat = 0; |
$this->pushErrorHandling(PEAR_ERROR_RETURN); |
$result = $this->query("UPDATE ${seqname} ". |
'SET id=LAST_INSERT_ID(id+1)'); |
$this->popErrorHandling(); |
if ($result === DB_OK) { |
// COMMON CASE |
$id = @mysql_insert_id($this->connection); |
if ($id != 0) { |
return $id; |
} |
// EMPTY SEQ TABLE |
// Sequence table must be empty for some reason, so fill |
// it and return 1 and obtain a user-level lock |
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); |
if (DB::isError($result)) { |
return $this->raiseError($result); |
} |
if ($result == 0) { |
// Failed to get the lock |
return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED); |
} |
// add the default value |
$result = $this->query("REPLACE INTO ${seqname} (id) VALUES (0)"); |
if (DB::isError($result)) { |
return $this->raiseError($result); |
} |
// Release the lock |
$result = $this->getOne('SELECT RELEASE_LOCK(' |
. "'${seqname}_lock')"); |
if (DB::isError($result)) { |
return $this->raiseError($result); |
} |
// We know what the result will be, so no need to try again |
return 1; |
} elseif ($ondemand && DB::isError($result) && |
$result->getCode() == DB_ERROR_NOSUCHTABLE) |
{ |
// ONDEMAND TABLE CREATION |
$result = $this->createSequence($seq_name); |
if (DB::isError($result)) { |
return $this->raiseError($result); |
} else { |
$repeat = 1; |
} |
} elseif (DB::isError($result) && |
$result->getCode() == DB_ERROR_ALREADY_EXISTS) |
{ |
// BACKWARDS COMPAT |
// see _BCsequence() comment |
$result = $this->_BCsequence($seqname); |
if (DB::isError($result)) { |
return $this->raiseError($result); |
} |
$repeat = 1; |
} |
} while ($repeat); |
return $this->raiseError($result); |
} |
// }}} |
// {{{ createSequence() |
/** |
* Creates a new sequence |
* |
* @param string $seq_name name of the new sequence |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::createSequence(), DB_common::getSequenceName(), |
* DB_mysql::nextID(), DB_mysql::dropSequence() |
*/ |
function createSequence($seq_name) |
{ |
$seqname = $this->getSequenceName($seq_name); |
$res = $this->query('CREATE TABLE ' . $seqname |
. ' (id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,' |
. ' PRIMARY KEY(id))'); |
if (DB::isError($res)) { |
return $res; |
} |
// insert yields value 1, nextId call will generate ID 2 |
$res = $this->query("INSERT INTO ${seqname} (id) VALUES (0)"); |
if (DB::isError($res)) { |
return $res; |
} |
// so reset to zero |
return $this->query("UPDATE ${seqname} SET id = 0"); |
} |
// }}} |
// {{{ dropSequence() |
/** |
* Deletes a sequence |
* |
* @param string $seq_name name of the sequence to be deleted |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::dropSequence(), DB_common::getSequenceName(), |
* DB_mysql::nextID(), DB_mysql::createSequence() |
*/ |
function dropSequence($seq_name) |
{ |
return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name)); |
} |
// }}} |
// {{{ _BCsequence() |
/** |
* Backwards compatibility with old sequence emulation implementation |
* (clean up the dupes) |
* |
* @param string $seqname the sequence name to clean up |
* |
* @return bool true on success. A DB_Error object on failure. |
* |
* @access private |
*/ |
function _BCsequence($seqname) |
{ |
// Obtain a user-level lock... this will release any previous |
// application locks, but unlike LOCK TABLES, it does not abort |
// the current transaction and is much less frequently used. |
$result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); |
if (DB::isError($result)) { |
return $result; |
} |
if ($result == 0) { |
// Failed to get the lock, can't do the conversion, bail |
// with a DB_ERROR_NOT_LOCKED error |
return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED); |
} |
$highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}"); |
if (DB::isError($highest_id)) { |
return $highest_id; |
} |
// This should kill all rows except the highest |
// We should probably do something if $highest_id isn't |
// numeric, but I'm at a loss as how to handle that... |
$result = $this->query('DELETE FROM ' . $seqname |
. " WHERE id <> $highest_id"); |
if (DB::isError($result)) { |
return $result; |
} |
// If another thread has been waiting for this lock, |
// it will go thru the above procedure, but will have no |
// real effect |
$result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')"); |
if (DB::isError($result)) { |
return $result; |
} |
return true; |
} |
// }}} |
// {{{ quoteIdentifier() |
/** |
* Quotes a string so it can be safely used as a table or column name |
* (WARNING: using names that require this is a REALLY BAD IDEA) |
* |
* WARNING: Older versions of MySQL can't handle the backtick |
* character (<kbd>`</kbd>) in table or column names. |
* |
* @param string $str identifier name to be quoted |
* |
* @return string quoted identifier string |
* |
* @see DB_common::quoteIdentifier() |
* @since Method available since Release 1.6.0 |
*/ |
function quoteIdentifier($str) |
{ |
return '`' . str_replace('`', '``', $str) . '`'; |
} |
// }}} |
// {{{ quote() |
/** |
* @deprecated Deprecated in release 1.6.0 |
*/ |
function quote($str) |
{ |
return $this->quoteSmart($str); |
} |
// }}} |
// {{{ escapeSimple() |
/** |
* Escapes a string according to the current DBMS's standards |
* |
* @param string $str the string to be escaped |
* |
* @return string the escaped string |
* |
* @see DB_common::quoteSmart() |
* @since Method available since Release 1.6.0 |
*/ |
function escapeSimple($str) |
{ |
if (function_exists('mysql_real_escape_string')) { |
return @mysql_real_escape_string($str, $this->connection); |
} else { |
return @mysql_escape_string($str); |
} |
} |
// }}} |
// {{{ modifyQuery() |
/** |
* Changes a query string for various DBMS specific reasons |
* |
* This little hack lets you know how many rows were deleted |
* when running a "DELETE FROM table" query. Only implemented |
* if the DB_PORTABILITY_DELETE_COUNT portability option is on. |
* |
* @param string $query the query string to modify |
* |
* @return string the modified query string |
* |
* @access protected |
* @see DB_common::setOption() |
*/ |
function modifyQuery($query) |
{ |
if ($this->options['portability'] & DB_PORTABILITY_DELETE_COUNT) { |
// "DELETE FROM table" gives 0 affected rows in MySQL. |
// This little hack lets you know how many rows were deleted. |
if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) { |
$query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', |
'DELETE FROM \1 WHERE 1=1', $query); |
} |
} |
return $query; |
} |
// }}} |
// {{{ modifyLimitQuery() |
/** |
* Adds LIMIT clauses to a query string according to current DBMS standards |
* |
* @param string $query the query to modify |
* @param int $from the row to start to fetching (0 = the first row) |
* @param int $count the numbers of rows to fetch |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return string the query string with LIMIT clauses added |
* |
* @access protected |
*/ |
function modifyLimitQuery($query, $from, $count, $params = array()) |
{ |
if (DB::isManip($query) || $this->_next_query_manip) { |
return $query . " LIMIT $count"; |
} else { |
return $query . " LIMIT $from, $count"; |
} |
} |
// }}} |
// {{{ mysqlRaiseError() |
/** |
* Produces a DB_Error object regarding the current problem |
* |
* @param int $errno if the error is being manually raised pass a |
* DB_ERROR* constant here. If this isn't passed |
* the error information gathered from the DBMS. |
* |
* @return object the DB_Error object |
* |
* @see DB_common::raiseError(), |
* DB_mysql::errorNative(), DB_common::errorCode() |
*/ |
function mysqlRaiseError($errno = null) |
{ |
if ($errno === null) { |
if ($this->options['portability'] & DB_PORTABILITY_ERRORS) { |
$this->errorcode_map[1022] = DB_ERROR_CONSTRAINT; |
$this->errorcode_map[1048] = DB_ERROR_CONSTRAINT_NOT_NULL; |
$this->errorcode_map[1062] = DB_ERROR_CONSTRAINT; |
} else { |
// Doing this in case mode changes during runtime. |
$this->errorcode_map[1022] = DB_ERROR_ALREADY_EXISTS; |
$this->errorcode_map[1048] = DB_ERROR_CONSTRAINT; |
$this->errorcode_map[1062] = DB_ERROR_ALREADY_EXISTS; |
} |
$errno = $this->errorCode(mysql_errno($this->connection)); |
} |
return $this->raiseError($errno, null, null, null, |
@mysql_errno($this->connection) . ' ** ' . |
@mysql_error($this->connection)); |
} |
// }}} |
// {{{ errorNative() |
/** |
* Gets the DBMS' native error code produced by the last query |
* |
* @return int the DBMS' error code |
*/ |
function errorNative() |
{ |
return @mysql_errno($this->connection); |
} |
// }}} |
// {{{ tableInfo() |
/** |
* Returns information about a table or a result set |
* |
* @param object|string $result DB_result object from a query or a |
* string containing the name of a table. |
* While this also accepts a query result |
* resource identifier, this behavior is |
* deprecated. |
* @param int $mode a valid tableInfo mode |
* |
* @return array an associative array with the information requested. |
* A DB_Error object on failure. |
* |
* @see DB_common::tableInfo() |
*/ |
function tableInfo($result, $mode = null) |
{ |
if (is_string($result)) { |
// Fix for bug #11580. |
if ($this->_db) { |
if (!@mysql_select_db($this->_db, $this->connection)) { |
return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); |
} |
} |
/* |
* Probably received a table name. |
* Create a result resource identifier. |
*/ |
$id = @mysql_query("SELECT * FROM $result LIMIT 0", |
$this->connection); |
$got_string = true; |
} elseif (isset($result->result)) { |
/* |
* Probably received a result object. |
* Extract the result resource identifier. |
*/ |
$id = $result->result; |
$got_string = false; |
} else { |
/* |
* Probably received a result resource identifier. |
* Copy it. |
* Deprecated. Here for compatibility only. |
*/ |
$id = $result; |
$got_string = false; |
} |
if (!is_resource($id)) { |
return $this->mysqlRaiseError(DB_ERROR_NEED_MORE_DATA); |
} |
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) { |
$case_func = 'strtolower'; |
} else { |
$case_func = 'strval'; |
} |
$count = @mysql_num_fields($id); |
$res = array(); |
if ($mode) { |
$res['num_fields'] = $count; |
} |
for ($i = 0; $i < $count; $i++) { |
$res[$i] = array( |
'table' => $case_func(@mysql_field_table($id, $i)), |
'name' => $case_func(@mysql_field_name($id, $i)), |
'type' => @mysql_field_type($id, $i), |
'len' => @mysql_field_len($id, $i), |
'flags' => @mysql_field_flags($id, $i), |
); |
if ($mode & DB_TABLEINFO_ORDER) { |
$res['order'][$res[$i]['name']] = $i; |
} |
if ($mode & DB_TABLEINFO_ORDERTABLE) { |
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; |
} |
} |
// free the result only if we were called on a table |
if ($got_string) { |
@mysql_free_result($id); |
} |
return $res; |
} |
// }}} |
// {{{ getSpecialQuery() |
/** |
* Obtains the query string needed for listing a given type of objects |
* |
* @param string $type the kind of objects you want to retrieve |
* |
* @return string the SQL query string or null if the driver doesn't |
* support the object type requested |
* |
* @access protected |
* @see DB_common::getListOf() |
*/ |
function getSpecialQuery($type) |
{ |
switch ($type) { |
case 'tables': |
return 'SHOW TABLES'; |
case 'users': |
return 'SELECT DISTINCT User FROM mysql.user'; |
case 'databases': |
return 'SHOW DATABASES'; |
default: |
return null; |
} |
} |
// }}} |
} |
/* |
* Local variables: |
* tab-width: 4 |
* c-basic-offset: 4 |
* End: |
*/ |
?> |
/branches/ant-ng/lib/DB/common.php |
---|
Новый файл |
0,0 → 1,2257 |
<?php |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
/** |
* Contains the DB_common base class |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V. Cox <cox@idecnet.com> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: common.php,v 1.143 2007/09/21 13:40:41 aharvey Exp $ |
* @link http://pear.php.net/package/DB |
*/ |
/** |
* Obtain the PEAR class so it can be extended from |
*/ |
require_once 'lib/PEAR.php'; |
/** |
* DB_common is the base class from which each database driver class extends |
* |
* All common methods are declared here. If a given DBMS driver contains |
* a particular method, that method will overload the one here. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V. Cox <cox@idecnet.com> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB_common extends PEAR |
{ |
// {{{ properties |
/** |
* The current default fetch mode |
* @var integer |
*/ |
var $fetchmode = DB_FETCHMODE_ORDERED; |
/** |
* The name of the class into which results should be fetched when |
* DB_FETCHMODE_OBJECT is in effect |
* |
* @var string |
*/ |
var $fetchmode_object_class = 'stdClass'; |
/** |
* Was a connection present when the object was serialized()? |
* @var bool |
* @see DB_common::__sleep(), DB_common::__wake() |
*/ |
var $was_connected = null; |
/** |
* The most recently executed query |
* @var string |
*/ |
var $last_query = ''; |
/** |
* Run-time configuration options |
* |
* The 'optimize' option has been deprecated. Use the 'portability' |
* option instead. |
* |
* @var array |
* @see DB_common::setOption() |
*/ |
var $options = array( |
'result_buffering' => 500, |
'persistent' => false, |
'ssl' => false, |
'debug' => 0, |
'seqname_format' => '%s_seq', |
'autofree' => false, |
'portability' => DB_PORTABILITY_NONE, |
'optimize' => 'performance', // Deprecated. Use 'portability'. |
); |
/** |
* The parameters from the most recently executed query |
* @var array |
* @since Property available since Release 1.7.0 |
*/ |
var $last_parameters = array(); |
/** |
* The elements from each prepared statement |
* @var array |
*/ |
var $prepare_tokens = array(); |
/** |
* The data types of the various elements in each prepared statement |
* @var array |
*/ |
var $prepare_types = array(); |
/** |
* The prepared queries |
* @var array |
*/ |
var $prepared_queries = array(); |
/** |
* Flag indicating that the last query was a manipulation query. |
* @access protected |
* @var boolean |
*/ |
var $_last_query_manip = false; |
/** |
* Flag indicating that the next query <em>must</em> be a manipulation |
* query. |
* @access protected |
* @var boolean |
*/ |
var $_next_query_manip = false; |
// }}} |
// {{{ DB_common |
/** |
* This constructor calls <kbd>$this->PEAR('DB_Error')</kbd> |
* |
* @return void |
*/ |
function DB_common() |
{ |
$this->PEAR('DB_Error'); |
} |
// }}} |
// {{{ __sleep() |
/** |
* Automatically indicates which properties should be saved |
* when PHP's serialize() function is called |
* |
* @return array the array of properties names that should be saved |
*/ |
function __sleep() |
{ |
if ($this->connection) { |
// Don't disconnect(), people use serialize() for many reasons |
$this->was_connected = true; |
} else { |
$this->was_connected = false; |
} |
if (isset($this->autocommit)) { |
return array('autocommit', |
'dbsyntax', |
'dsn', |
'features', |
'fetchmode', |
'fetchmode_object_class', |
'options', |
'was_connected', |
); |
} else { |
return array('dbsyntax', |
'dsn', |
'features', |
'fetchmode', |
'fetchmode_object_class', |
'options', |
'was_connected', |
); |
} |
} |
// }}} |
// {{{ __wakeup() |
/** |
* Automatically reconnects to the database when PHP's unserialize() |
* function is called |
* |
* The reconnection attempt is only performed if the object was connected |
* at the time PHP's serialize() function was run. |
* |
* @return void |
*/ |
function __wakeup() |
{ |
if ($this->was_connected) { |
$this->connect($this->dsn, $this->options); |
} |
} |
// }}} |
// {{{ __toString() |
/** |
* Automatic string conversion for PHP 5 |
* |
* @return string a string describing the current PEAR DB object |
* |
* @since Method available since Release 1.7.0 |
*/ |
function __toString() |
{ |
$info = strtolower(get_class($this)); |
$info .= ': (phptype=' . $this->phptype . |
', dbsyntax=' . $this->dbsyntax . |
')'; |
if ($this->connection) { |
$info .= ' [connected]'; |
} |
return $info; |
} |
// }}} |
// {{{ toString() |
/** |
* DEPRECATED: String conversion method |
* |
* @return string a string describing the current PEAR DB object |
* |
* @deprecated Method deprecated in Release 1.7.0 |
*/ |
function toString() |
{ |
return $this->__toString(); |
} |
// }}} |
// {{{ quoteString() |
/** |
* DEPRECATED: Quotes a string so it can be safely used within string |
* delimiters in a query |
* |
* @param string $string the string to be quoted |
* |
* @return string the quoted string |
* |
* @see DB_common::quoteSmart(), DB_common::escapeSimple() |
* @deprecated Method deprecated some time before Release 1.2 |
*/ |
function quoteString($string) |
{ |
$string = $this->quote($string); |
if ($string{0} == "'") { |
return substr($string, 1, -1); |
} |
return $string; |
} |
// }}} |
// {{{ quote() |
/** |
* DEPRECATED: Quotes a string so it can be safely used in a query |
* |
* @param string $string the string to quote |
* |
* @return string the quoted string or the string <samp>NULL</samp> |
* if the value submitted is <kbd>null</kbd>. |
* |
* @see DB_common::quoteSmart(), DB_common::escapeSimple() |
* @deprecated Deprecated in release 1.6.0 |
*/ |
function quote($string = null) |
{ |
return ($string === null) ? 'NULL' |
: "'" . str_replace("'", "''", $string) . "'"; |
} |
// }}} |
// {{{ quoteIdentifier() |
/** |
* Quotes a string so it can be safely used as a table or column name |
* |
* Delimiting style depends on which database driver is being used. |
* |
* NOTE: just because you CAN use delimited identifiers doesn't mean |
* you SHOULD use them. In general, they end up causing way more |
* problems than they solve. |
* |
* Portability is broken by using the following characters inside |
* delimited identifiers: |
* + backtick (<kbd>`</kbd>) -- due to MySQL |
* + double quote (<kbd>"</kbd>) -- due to Oracle |
* + brackets (<kbd>[</kbd> or <kbd>]</kbd>) -- due to Access |
* |
* Delimited identifiers are known to generally work correctly under |
* the following drivers: |
* + mssql |
* + mysql |
* + mysqli |
* + oci8 |
* + odbc(access) |
* + odbc(db2) |
* + pgsql |
* + sqlite |
* + sybase (must execute <kbd>set quoted_identifier on</kbd> sometime |
* prior to use) |
* |
* InterBase doesn't seem to be able to use delimited identifiers |
* via PHP 4. They work fine under PHP 5. |
* |
* @param string $str the identifier name to be quoted |
* |
* @return string the quoted identifier |
* |
* @since Method available since Release 1.6.0 |
*/ |
function quoteIdentifier($str) |
{ |
return '"' . str_replace('"', '""', $str) . '"'; |
} |
// }}} |
// {{{ quoteSmart() |
/** |
* Formats input so it can be safely used in a query |
* |
* The output depends on the PHP data type of input and the database |
* type being used. |
* |
* @param mixed $in the data to be formatted |
* |
* @return mixed the formatted data. The format depends on the input's |
* PHP type: |
* <ul> |
* <li> |
* <kbd>input</kbd> -> <samp>returns</samp> |
* </li> |
* <li> |
* <kbd>null</kbd> -> the string <samp>NULL</samp> |
* </li> |
* <li> |
* <kbd>integer</kbd> or <kbd>double</kbd> -> the unquoted number |
* </li> |
* <li> |
* <kbd>bool</kbd> -> output depends on the driver in use |
* Most drivers return integers: <samp>1</samp> if |
* <kbd>true</kbd> or <samp>0</samp> if |
* <kbd>false</kbd>. |
* Some return strings: <samp>TRUE</samp> if |
* <kbd>true</kbd> or <samp>FALSE</samp> if |
* <kbd>false</kbd>. |
* Finally one returns strings: <samp>T</samp> if |
* <kbd>true</kbd> or <samp>F</samp> if |
* <kbd>false</kbd>. Here is a list of each DBMS, |
* the values returned and the suggested column type: |
* <ul> |
* <li> |
* <kbd>dbase</kbd> -> <samp>T/F</samp> |
* (<kbd>Logical</kbd>) |
* </li> |
* <li> |
* <kbd>fbase</kbd> -> <samp>TRUE/FALSE</samp> |
* (<kbd>BOOLEAN</kbd>) |
* </li> |
* <li> |
* <kbd>ibase</kbd> -> <samp>1/0</samp> |
* (<kbd>SMALLINT</kbd>) [1] |
* </li> |
* <li> |
* <kbd>ifx</kbd> -> <samp>1/0</samp> |
* (<kbd>SMALLINT</kbd>) [1] |
* </li> |
* <li> |
* <kbd>msql</kbd> -> <samp>1/0</samp> |
* (<kbd>INTEGER</kbd>) |
* </li> |
* <li> |
* <kbd>mssql</kbd> -> <samp>1/0</samp> |
* (<kbd>BIT</kbd>) |
* </li> |
* <li> |
* <kbd>mysql</kbd> -> <samp>1/0</samp> |
* (<kbd>TINYINT(1)</kbd>) |
* </li> |
* <li> |
* <kbd>mysqli</kbd> -> <samp>1/0</samp> |
* (<kbd>TINYINT(1)</kbd>) |
* </li> |
* <li> |
* <kbd>oci8</kbd> -> <samp>1/0</samp> |
* (<kbd>NUMBER(1)</kbd>) |
* </li> |
* <li> |
* <kbd>odbc</kbd> -> <samp>1/0</samp> |
* (<kbd>SMALLINT</kbd>) [1] |
* </li> |
* <li> |
* <kbd>pgsql</kbd> -> <samp>TRUE/FALSE</samp> |
* (<kbd>BOOLEAN</kbd>) |
* </li> |
* <li> |
* <kbd>sqlite</kbd> -> <samp>1/0</samp> |
* (<kbd>INTEGER</kbd>) |
* </li> |
* <li> |
* <kbd>sybase</kbd> -> <samp>1/0</samp> |
* (<kbd>TINYINT(1)</kbd>) |
* </li> |
* </ul> |
* [1] Accommodate the lowest common denominator because not all |
* versions of have <kbd>BOOLEAN</kbd>. |
* </li> |
* <li> |
* other (including strings and numeric strings) -> |
* the data with single quotes escaped by preceeding |
* single quotes, backslashes are escaped by preceeding |
* backslashes, then the whole string is encapsulated |
* between single quotes |
* </li> |
* </ul> |
* |
* @see DB_common::escapeSimple() |
* @since Method available since Release 1.6.0 |
*/ |
function quoteSmart($in) |
{ |
if (is_int($in)) { |
return $in; |
} elseif (is_float($in)) { |
return $this->quoteFloat($in); |
} elseif (is_bool($in)) { |
return $this->quoteBoolean($in); |
} elseif (is_null($in)) { |
return 'NULL'; |
} else { |
if ($this->dbsyntax == 'access' |
&& preg_match('/^#.+#$/', $in)) |
{ |
return $this->escapeSimple($in); |
} |
return "'" . $this->escapeSimple($in) . "'"; |
} |
} |
// }}} |
// {{{ quoteBoolean() |
/** |
* Formats a boolean value for use within a query in a locale-independent |
* manner. |
* |
* @param boolean the boolean value to be quoted. |
* @return string the quoted string. |
* @see DB_common::quoteSmart() |
* @since Method available since release 1.7.8. |
*/ |
function quoteBoolean($boolean) { |
return $boolean ? '1' : '0'; |
} |
// }}} |
// {{{ quoteFloat() |
/** |
* Formats a float value for use within a query in a locale-independent |
* manner. |
* |
* @param float the float value to be quoted. |
* @return string the quoted string. |
* @see DB_common::quoteSmart() |
* @since Method available since release 1.7.8. |
*/ |
function quoteFloat($float) { |
return "'".$this->escapeSimple(str_replace(',', '.', strval(floatval($float))))."'"; |
} |
// }}} |
// {{{ escapeSimple() |
/** |
* Escapes a string according to the current DBMS's standards |
* |
* In SQLite, this makes things safe for inserts/updates, but may |
* cause problems when performing text comparisons against columns |
* containing binary data. See the |
* {@link http://php.net/sqlite_escape_string PHP manual} for more info. |
* |
* @param string $str the string to be escaped |
* |
* @return string the escaped string |
* |
* @see DB_common::quoteSmart() |
* @since Method available since Release 1.6.0 |
*/ |
function escapeSimple($str) |
{ |
return str_replace("'", "''", $str); |
} |
// }}} |
// {{{ provides() |
/** |
* Tells whether the present driver supports a given feature |
* |
* @param string $feature the feature you're curious about |
* |
* @return bool whether this driver supports $feature |
*/ |
function provides($feature) |
{ |
return $this->features[$feature]; |
} |
// }}} |
// {{{ setFetchMode() |
/** |
* Sets the fetch mode that should be used by default for query results |
* |
* @param integer $fetchmode DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC |
* or DB_FETCHMODE_OBJECT |
* @param string $object_class the class name of the object to be returned |
* by the fetch methods when the |
* DB_FETCHMODE_OBJECT mode is selected. |
* If no class is specified by default a cast |
* to object from the assoc array row will be |
* done. There is also the posibility to use |
* and extend the 'DB_row' class. |
* |
* @see DB_FETCHMODE_ORDERED, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT |
*/ |
function setFetchMode($fetchmode, $object_class = 'stdClass') |
{ |
switch ($fetchmode) { |
case DB_FETCHMODE_OBJECT: |
$this->fetchmode_object_class = $object_class; |
case DB_FETCHMODE_ORDERED: |
case DB_FETCHMODE_ASSOC: |
$this->fetchmode = $fetchmode; |
break; |
default: |
return $this->raiseError('invalid fetchmode mode'); |
} |
} |
// }}} |
// {{{ setOption() |
/** |
* Sets run-time configuration options for PEAR DB |
* |
* Options, their data types, default values and description: |
* <ul> |
* <li> |
* <var>autofree</var> <kbd>boolean</kbd> = <samp>false</samp> |
* <br />should results be freed automatically when there are no |
* more rows? |
* </li><li> |
* <var>result_buffering</var> <kbd>integer</kbd> = <samp>500</samp> |
* <br />how many rows of the result set should be buffered? |
* <br />In mysql: mysql_unbuffered_query() is used instead of |
* mysql_query() if this value is 0. (Release 1.7.0) |
* <br />In oci8: this value is passed to ocisetprefetch(). |
* (Release 1.7.0) |
* </li><li> |
* <var>debug</var> <kbd>integer</kbd> = <samp>0</samp> |
* <br />debug level |
* </li><li> |
* <var>persistent</var> <kbd>boolean</kbd> = <samp>false</samp> |
* <br />should the connection be persistent? |
* </li><li> |
* <var>portability</var> <kbd>integer</kbd> = <samp>DB_PORTABILITY_NONE</samp> |
* <br />portability mode constant (see below) |
* </li><li> |
* <var>seqname_format</var> <kbd>string</kbd> = <samp>%s_seq</samp> |
* <br />the sprintf() format string used on sequence names. This |
* format is applied to sequence names passed to |
* createSequence(), nextID() and dropSequence(). |
* </li><li> |
* <var>ssl</var> <kbd>boolean</kbd> = <samp>false</samp> |
* <br />use ssl to connect? |
* </li> |
* </ul> |
* |
* ----------------------------------------- |
* |
* PORTABILITY MODES |
* |
* These modes are bitwised, so they can be combined using <kbd>|</kbd> |
* and removed using <kbd>^</kbd>. See the examples section below on how |
* to do this. |
* |
* <samp>DB_PORTABILITY_NONE</samp> |
* turn off all portability features |
* |
* This mode gets automatically turned on if the deprecated |
* <var>optimize</var> option gets set to <samp>performance</samp>. |
* |
* |
* <samp>DB_PORTABILITY_LOWERCASE</samp> |
* convert names of tables and fields to lower case when using |
* <kbd>get*()</kbd>, <kbd>fetch*()</kbd> and <kbd>tableInfo()</kbd> |
* |
* This mode gets automatically turned on in the following databases |
* if the deprecated option <var>optimize</var> gets set to |
* <samp>portability</samp>: |
* + oci8 |
* |
* |
* <samp>DB_PORTABILITY_RTRIM</samp> |
* right trim the data output by <kbd>get*()</kbd> <kbd>fetch*()</kbd> |
* |
* |
* <samp>DB_PORTABILITY_DELETE_COUNT</samp> |
* force reporting the number of rows deleted |
* |
* Some DBMS's don't count the number of rows deleted when performing |
* simple <kbd>DELETE FROM tablename</kbd> queries. This portability |
* mode tricks such DBMS's into telling the count by adding |
* <samp>WHERE 1=1</samp> to the end of <kbd>DELETE</kbd> queries. |
* |
* This mode gets automatically turned on in the following databases |
* if the deprecated option <var>optimize</var> gets set to |
* <samp>portability</samp>: |
* + fbsql |
* + mysql |
* + mysqli |
* + sqlite |
* |
* |
* <samp>DB_PORTABILITY_NUMROWS</samp> |
* enable hack that makes <kbd>numRows()</kbd> work in Oracle |
* |
* This mode gets automatically turned on in the following databases |
* if the deprecated option <var>optimize</var> gets set to |
* <samp>portability</samp>: |
* + oci8 |
* |
* |
* <samp>DB_PORTABILITY_ERRORS</samp> |
* makes certain error messages in certain drivers compatible |
* with those from other DBMS's |
* |
* + mysql, mysqli: change unique/primary key constraints |
* DB_ERROR_ALREADY_EXISTS -> DB_ERROR_CONSTRAINT |
* |
* + odbc(access): MS's ODBC driver reports 'no such field' as code |
* 07001, which means 'too few parameters.' When this option is on |
* that code gets mapped to DB_ERROR_NOSUCHFIELD. |
* DB_ERROR_MISMATCH -> DB_ERROR_NOSUCHFIELD |
* |
* <samp>DB_PORTABILITY_NULL_TO_EMPTY</samp> |
* convert null values to empty strings in data output by get*() and |
* fetch*(). Needed because Oracle considers empty strings to be null, |
* while most other DBMS's know the difference between empty and null. |
* |
* |
* <samp>DB_PORTABILITY_ALL</samp> |
* turn on all portability features |
* |
* ----------------------------------------- |
* |
* Example 1. Simple setOption() example |
* <code> |
* $db->setOption('autofree', true); |
* </code> |
* |
* Example 2. Portability for lowercasing and trimming |
* <code> |
* $db->setOption('portability', |
* DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_RTRIM); |
* </code> |
* |
* Example 3. All portability options except trimming |
* <code> |
* $db->setOption('portability', |
* DB_PORTABILITY_ALL ^ DB_PORTABILITY_RTRIM); |
* </code> |
* |
* @param string $option option name |
* @param mixed $value value for the option |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::$options |
*/ |
function setOption($option, $value) |
{ |
if (isset($this->options[$option])) { |
$this->options[$option] = $value; |
/* |
* Backwards compatibility check for the deprecated 'optimize' |
* option. Done here in case settings change after connecting. |
*/ |
if ($option == 'optimize') { |
if ($value == 'portability') { |
switch ($this->phptype) { |
case 'oci8': |
$this->options['portability'] = |
DB_PORTABILITY_LOWERCASE | |
DB_PORTABILITY_NUMROWS; |
break; |
case 'fbsql': |
case 'mysql': |
case 'mysqli': |
case 'sqlite': |
$this->options['portability'] = |
DB_PORTABILITY_DELETE_COUNT; |
break; |
} |
} else { |
$this->options['portability'] = DB_PORTABILITY_NONE; |
} |
} |
return DB_OK; |
} |
return $this->raiseError("unknown option $option"); |
} |
// }}} |
// {{{ getOption() |
/** |
* Returns the value of an option |
* |
* @param string $option the option name you're curious about |
* |
* @return mixed the option's value |
*/ |
function getOption($option) |
{ |
if (isset($this->options[$option])) { |
return $this->options[$option]; |
} |
return $this->raiseError("unknown option $option"); |
} |
// }}} |
// {{{ prepare() |
/** |
* Prepares a query for multiple execution with execute() |
* |
* Creates a query that can be run multiple times. Each time it is run, |
* the placeholders, if any, will be replaced by the contents of |
* execute()'s $data argument. |
* |
* Three types of placeholders can be used: |
* + <kbd>?</kbd> scalar value (i.e. strings, integers). The system |
* will automatically quote and escape the data. |
* + <kbd>!</kbd> value is inserted 'as is' |
* + <kbd>&</kbd> requires a file name. The file's contents get |
* inserted into the query (i.e. saving binary |
* data in a db) |
* |
* Example 1. |
* <code> |
* $sth = $db->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)'); |
* $data = array( |
* "John's text", |
* "'it''s good'", |
* 'filename.txt' |
* ); |
* $res = $db->execute($sth, $data); |
* </code> |
* |
* Use backslashes to escape placeholder characters if you don't want |
* them to be interpreted as placeholders: |
* <pre> |
* "UPDATE foo SET col=? WHERE col='over \& under'" |
* </pre> |
* |
* With some database backends, this is emulated. |
* |
* {@internal ibase and oci8 have their own prepare() methods.}} |
* |
* @param string $query the query to be prepared |
* |
* @return mixed DB statement resource on success. A DB_Error object |
* on failure. |
* |
* @see DB_common::execute() |
*/ |
function prepare($query) |
{ |
$tokens = preg_split('/((?<!\\\)[&?!])/', $query, -1, |
PREG_SPLIT_DELIM_CAPTURE); |
$token = 0; |
$types = array(); |
$newtokens = array(); |
foreach ($tokens as $val) { |
switch ($val) { |
case '?': |
$types[$token++] = DB_PARAM_SCALAR; |
break; |
case '&': |
$types[$token++] = DB_PARAM_OPAQUE; |
break; |
case '!': |
$types[$token++] = DB_PARAM_MISC; |
break; |
default: |
$newtokens[] = preg_replace('/\\\([&?!])/', "\\1", $val); |
} |
} |
$this->prepare_tokens[] = &$newtokens; |
end($this->prepare_tokens); |
$k = key($this->prepare_tokens); |
$this->prepare_types[$k] = $types; |
$this->prepared_queries[$k] = implode(' ', $newtokens); |
return $k; |
} |
// }}} |
// {{{ autoPrepare() |
/** |
* Automaticaly generates an insert or update query and pass it to prepare() |
* |
* @param string $table the table name |
* @param array $table_fields the array of field names |
* @param int $mode a type of query to make: |
* DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE |
* @param string $where for update queries: the WHERE clause to |
* append to the SQL statement. Don't |
* include the "WHERE" keyword. |
* |
* @return resource the query handle |
* |
* @uses DB_common::prepare(), DB_common::buildManipSQL() |
*/ |
function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT, |
$where = false) |
{ |
$query = $this->buildManipSQL($table, $table_fields, $mode, $where); |
if (DB::isError($query)) { |
return $query; |
} |
return $this->prepare($query); |
} |
// }}} |
// {{{ autoExecute() |
/** |
* Automaticaly generates an insert or update query and call prepare() |
* and execute() with it |
* |
* @param string $table the table name |
* @param array $fields_values the associative array where $key is a |
* field name and $value its value |
* @param int $mode a type of query to make: |
* DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE |
* @param string $where for update queries: the WHERE clause to |
* append to the SQL statement. Don't |
* include the "WHERE" keyword. |
* |
* @return mixed a new DB_result object for successful SELECT queries |
* or DB_OK for successul data manipulation queries. |
* A DB_Error object on failure. |
* |
* @uses DB_common::autoPrepare(), DB_common::execute() |
*/ |
function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, |
$where = false) |
{ |
$sth = $this->autoPrepare($table, array_keys($fields_values), $mode, |
$where); |
if (DB::isError($sth)) { |
return $sth; |
} |
$ret = $this->execute($sth, array_values($fields_values)); |
$this->freePrepared($sth); |
return $ret; |
} |
// }}} |
// {{{ buildManipSQL() |
/** |
* Produces an SQL query string for autoPrepare() |
* |
* Example: |
* <pre> |
* buildManipSQL('table_sql', array('field1', 'field2', 'field3'), |
* DB_AUTOQUERY_INSERT); |
* </pre> |
* |
* That returns |
* <samp> |
* INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) |
* </samp> |
* |
* NOTES: |
* - This belongs more to a SQL Builder class, but this is a simple |
* facility. |
* - Be carefull! If you don't give a $where param with an UPDATE |
* query, all the records of the table will be updated! |
* |
* @param string $table the table name |
* @param array $table_fields the array of field names |
* @param int $mode a type of query to make: |
* DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE |
* @param string $where for update queries: the WHERE clause to |
* append to the SQL statement. Don't |
* include the "WHERE" keyword. |
* |
* @return string the sql query for autoPrepare() |
*/ |
function buildManipSQL($table, $table_fields, $mode, $where = false) |
{ |
if (count($table_fields) == 0) { |
return $this->raiseError(DB_ERROR_NEED_MORE_DATA); |
} |
$first = true; |
switch ($mode) { |
case DB_AUTOQUERY_INSERT: |
$values = ''; |
$names = ''; |
foreach ($table_fields as $value) { |
if ($first) { |
$first = false; |
} else { |
$names .= ','; |
$values .= ','; |
} |
$names .= $value; |
$values .= '?'; |
} |
return "INSERT INTO $table ($names) VALUES ($values)"; |
case DB_AUTOQUERY_UPDATE: |
$set = ''; |
foreach ($table_fields as $value) { |
if ($first) { |
$first = false; |
} else { |
$set .= ','; |
} |
$set .= "$value = ?"; |
} |
$sql = "UPDATE $table SET $set"; |
if ($where) { |
$sql .= " WHERE $where"; |
} |
return $sql; |
default: |
return $this->raiseError(DB_ERROR_SYNTAX); |
} |
} |
// }}} |
// {{{ execute() |
/** |
* Executes a DB statement prepared with prepare() |
* |
* Example 1. |
* <code> |
* $sth = $db->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)'); |
* $data = array( |
* "John's text", |
* "'it''s good'", |
* 'filename.txt' |
* ); |
* $res = $db->execute($sth, $data); |
* </code> |
* |
* @param resource $stmt a DB statement resource returned from prepare() |
* @param mixed $data array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return mixed a new DB_result object for successful SELECT queries |
* or DB_OK for successul data manipulation queries. |
* A DB_Error object on failure. |
* |
* {@internal ibase and oci8 have their own execute() methods.}} |
* |
* @see DB_common::prepare() |
*/ |
function &execute($stmt, $data = array()) |
{ |
$realquery = $this->executeEmulateQuery($stmt, $data); |
if (DB::isError($realquery)) { |
return $realquery; |
} |
$result = $this->simpleQuery($realquery); |
if ($result === DB_OK || DB::isError($result)) { |
return $result; |
} else { |
$tmp = new DB_result($this, $result); |
return $tmp; |
} |
} |
// }}} |
// {{{ executeEmulateQuery() |
/** |
* Emulates executing prepared statements if the DBMS not support them |
* |
* @param resource $stmt a DB statement resource returned from execute() |
* @param mixed $data array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return mixed a string containing the real query run when emulating |
* prepare/execute. A DB_Error object on failure. |
* |
* @access protected |
* @see DB_common::execute() |
*/ |
function executeEmulateQuery($stmt, $data = array()) |
{ |
$stmt = (int)$stmt; |
$data = (array)$data; |
$this->last_parameters = $data; |
if (count($this->prepare_types[$stmt]) != count($data)) { |
$this->last_query = $this->prepared_queries[$stmt]; |
return $this->raiseError(DB_ERROR_MISMATCH); |
} |
$realquery = $this->prepare_tokens[$stmt][0]; |
$i = 0; |
foreach ($data as $value) { |
if ($this->prepare_types[$stmt][$i] == DB_PARAM_SCALAR) { |
$realquery .= $this->quoteSmart($value); |
} elseif ($this->prepare_types[$stmt][$i] == DB_PARAM_OPAQUE) { |
$fp = @fopen($value, 'rb'); |
if (!$fp) { |
return $this->raiseError(DB_ERROR_ACCESS_VIOLATION); |
} |
$realquery .= $this->quoteSmart(fread($fp, filesize($value))); |
fclose($fp); |
} else { |
$realquery .= $value; |
} |
$realquery .= $this->prepare_tokens[$stmt][++$i]; |
} |
return $realquery; |
} |
// }}} |
// {{{ executeMultiple() |
/** |
* Performs several execute() calls on the same statement handle |
* |
* $data must be an array indexed numerically |
* from 0, one execute call is done for every "row" in the array. |
* |
* If an error occurs during execute(), executeMultiple() does not |
* execute the unfinished rows, but rather returns that error. |
* |
* @param resource $stmt query handle from prepare() |
* @param array $data numeric array containing the |
* data to insert into the query |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::prepare(), DB_common::execute() |
*/ |
function executeMultiple($stmt, $data) |
{ |
foreach ($data as $value) { |
$res = $this->execute($stmt, $value); |
if (DB::isError($res)) { |
return $res; |
} |
} |
return DB_OK; |
} |
// }}} |
// {{{ freePrepared() |
/** |
* Frees the internal resources associated with a prepared query |
* |
* @param resource $stmt the prepared statement's PHP resource |
* @param bool $free_resource should the PHP resource be freed too? |
* Use false if you need to get data |
* from the result set later. |
* |
* @return bool TRUE on success, FALSE if $result is invalid |
* |
* @see DB_common::prepare() |
*/ |
function freePrepared($stmt, $free_resource = true) |
{ |
$stmt = (int)$stmt; |
if (isset($this->prepare_tokens[$stmt])) { |
unset($this->prepare_tokens[$stmt]); |
unset($this->prepare_types[$stmt]); |
unset($this->prepared_queries[$stmt]); |
return true; |
} |
return false; |
} |
// }}} |
// {{{ modifyQuery() |
/** |
* Changes a query string for various DBMS specific reasons |
* |
* It is defined here to ensure all drivers have this method available. |
* |
* @param string $query the query string to modify |
* |
* @return string the modified query string |
* |
* @access protected |
* @see DB_mysql::modifyQuery(), DB_oci8::modifyQuery(), |
* DB_sqlite::modifyQuery() |
*/ |
function modifyQuery($query) |
{ |
return $query; |
} |
// }}} |
// {{{ modifyLimitQuery() |
/** |
* Adds LIMIT clauses to a query string according to current DBMS standards |
* |
* It is defined here to assure that all implementations |
* have this method defined. |
* |
* @param string $query the query to modify |
* @param int $from the row to start to fetching (0 = the first row) |
* @param int $count the numbers of rows to fetch |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return string the query string with LIMIT clauses added |
* |
* @access protected |
*/ |
function modifyLimitQuery($query, $from, $count, $params = array()) |
{ |
return $query; |
} |
// }}} |
// {{{ query() |
/** |
* Sends a query to the database server |
* |
* The query string can be either a normal statement to be sent directly |
* to the server OR if <var>$params</var> are passed the query can have |
* placeholders and it will be passed through prepare() and execute(). |
* |
* @param string $query the SQL query or the statement to prepare |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return mixed a new DB_result object for successful SELECT queries |
* or DB_OK for successul data manipulation queries. |
* A DB_Error object on failure. |
* |
* @see DB_result, DB_common::prepare(), DB_common::execute() |
*/ |
function &query($query, $params = array()) |
{ |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$ret = $this->execute($sth, $params); |
$this->freePrepared($sth, false); |
return $ret; |
} else { |
$this->last_parameters = array(); |
$result = $this->simpleQuery($query); |
if ($result === DB_OK || DB::isError($result)) { |
return $result; |
} else { |
$tmp = new DB_result($this, $result); |
return $tmp; |
} |
} |
} |
// }}} |
// {{{ limitQuery() |
/** |
* Generates and executes a LIMIT query |
* |
* @param string $query the query |
* @param intr $from the row to start to fetching (0 = the first row) |
* @param int $count the numbers of rows to fetch |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return mixed a new DB_result object for successful SELECT queries |
* or DB_OK for successul data manipulation queries. |
* A DB_Error object on failure. |
*/ |
function &limitQuery($query, $from, $count, $params = array()) |
{ |
$query = $this->modifyLimitQuery($query, $from, $count, $params); |
if (DB::isError($query)){ |
return $query; |
} |
$result = $this->query($query, $params); |
if (is_a($result, 'DB_result')) { |
$result->setOption('limit_from', $from); |
$result->setOption('limit_count', $count); |
} |
return $result; |
} |
// }}} |
// {{{ getOne() |
/** |
* Fetches the first column of the first row from a query result |
* |
* Takes care of doing the query and freeing the results when finished. |
* |
* @param string $query the SQL query |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return mixed the returned value of the query. |
* A DB_Error object on failure. |
*/ |
function &getOne($query, $params = array()) |
{ |
$params = (array)$params; |
// modifyLimitQuery() would be nice here, but it causes BC issues |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$res = $this->execute($sth, $params); |
$this->freePrepared($sth); |
} else { |
$res = $this->query($query); |
} |
if (DB::isError($res)) { |
return $res; |
} |
$err = $res->fetchInto($row, DB_FETCHMODE_ORDERED); |
$res->free(); |
if ($err !== DB_OK) { |
return $err; |
} |
return $row[0]; |
} |
// }}} |
// {{{ getRow() |
/** |
* Fetches the first row of data returned from a query result |
* |
* Takes care of doing the query and freeing the results when finished. |
* |
* @param string $query the SQL query |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* @param int $fetchmode the fetch mode to use |
* |
* @return array the first row of results as an array. |
* A DB_Error object on failure. |
*/ |
function &getRow($query, $params = array(), |
$fetchmode = DB_FETCHMODE_DEFAULT) |
{ |
// compat check, the params and fetchmode parameters used to |
// have the opposite order |
if (!is_array($params)) { |
if (is_array($fetchmode)) { |
if ($params === null) { |
$tmp = DB_FETCHMODE_DEFAULT; |
} else { |
$tmp = $params; |
} |
$params = $fetchmode; |
$fetchmode = $tmp; |
} elseif ($params !== null) { |
$fetchmode = $params; |
$params = array(); |
} |
} |
// modifyLimitQuery() would be nice here, but it causes BC issues |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$res = $this->execute($sth, $params); |
$this->freePrepared($sth); |
} else { |
$res = $this->query($query); |
} |
if (DB::isError($res)) { |
return $res; |
} |
$err = $res->fetchInto($row, $fetchmode); |
$res->free(); |
if ($err !== DB_OK) { |
return $err; |
} |
return $row; |
} |
// }}} |
// {{{ getCol() |
/** |
* Fetches a single column from a query result and returns it as an |
* indexed array |
* |
* @param string $query the SQL query |
* @param mixed $col which column to return (integer [column number, |
* starting at 0] or string [column name]) |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of items |
* passed must match quantity of placeholders in |
* query: meaning 1 placeholder for non-array |
* parameters or 1 placeholder per array element. |
* |
* @return array the results as an array. A DB_Error object on failure. |
* |
* @see DB_common::query() |
*/ |
function &getCol($query, $col = 0, $params = array()) |
{ |
$params = (array)$params; |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$res = $this->execute($sth, $params); |
$this->freePrepared($sth); |
} else { |
$res = $this->query($query); |
} |
if (DB::isError($res)) { |
return $res; |
} |
$fetchmode = is_int($col) ? DB_FETCHMODE_ORDERED : DB_FETCHMODE_ASSOC; |
if (!is_array($row = $res->fetchRow($fetchmode))) { |
$ret = array(); |
} else { |
if (!array_key_exists($col, $row)) { |
$ret = $this->raiseError(DB_ERROR_NOSUCHFIELD); |
} else { |
$ret = array($row[$col]); |
while (is_array($row = $res->fetchRow($fetchmode))) { |
$ret[] = $row[$col]; |
} |
} |
} |
$res->free(); |
if (DB::isError($row)) { |
$ret = $row; |
} |
return $ret; |
} |
// }}} |
// {{{ getAssoc() |
/** |
* Fetches an entire query result and returns it as an |
* associative array using the first column as the key |
* |
* If the result set contains more than two columns, the value |
* will be an array of the values from column 2-n. If the result |
* set contains only two columns, the returned value will be a |
* scalar with the value of the second column (unless forced to an |
* array with the $force_array parameter). A DB error code is |
* returned on errors. If the result set contains fewer than two |
* columns, a DB_ERROR_TRUNCATED error is returned. |
* |
* For example, if the table "mytable" contains: |
* |
* <pre> |
* ID TEXT DATE |
* -------------------------------- |
* 1 'one' 944679408 |
* 2 'two' 944679408 |
* 3 'three' 944679408 |
* </pre> |
* |
* Then the call getAssoc('SELECT id,text FROM mytable') returns: |
* <pre> |
* array( |
* '1' => 'one', |
* '2' => 'two', |
* '3' => 'three', |
* ) |
* </pre> |
* |
* ...while the call getAssoc('SELECT id,text,date FROM mytable') returns: |
* <pre> |
* array( |
* '1' => array('one', '944679408'), |
* '2' => array('two', '944679408'), |
* '3' => array('three', '944679408') |
* ) |
* </pre> |
* |
* If the more than one row occurs with the same value in the |
* first column, the last row overwrites all previous ones by |
* default. Use the $group parameter if you don't want to |
* overwrite like this. Example: |
* |
* <pre> |
* getAssoc('SELECT category,id,name FROM mytable', false, null, |
* DB_FETCHMODE_ASSOC, true) returns: |
* |
* array( |
* '1' => array(array('id' => '4', 'name' => 'number four'), |
* array('id' => '6', 'name' => 'number six') |
* ), |
* '9' => array(array('id' => '4', 'name' => 'number four'), |
* array('id' => '6', 'name' => 'number six') |
* ) |
* ) |
* </pre> |
* |
* Keep in mind that database functions in PHP usually return string |
* values for results regardless of the database's internal type. |
* |
* @param string $query the SQL query |
* @param bool $force_array used only when the query returns |
* exactly two columns. If true, the values |
* of the returned array will be one-element |
* arrays instead of scalars. |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of |
* items passed must match quantity of |
* placeholders in query: meaning 1 |
* placeholder for non-array parameters or |
* 1 placeholder per array element. |
* @param int $fetchmode the fetch mode to use |
* @param bool $group if true, the values of the returned array |
* is wrapped in another array. If the same |
* key value (in the first column) repeats |
* itself, the values will be appended to |
* this array instead of overwriting the |
* existing values. |
* |
* @return array the associative array containing the query results. |
* A DB_Error object on failure. |
*/ |
function &getAssoc($query, $force_array = false, $params = array(), |
$fetchmode = DB_FETCHMODE_DEFAULT, $group = false) |
{ |
$params = (array)$params; |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$res = $this->execute($sth, $params); |
$this->freePrepared($sth); |
} else { |
$res = $this->query($query); |
} |
if (DB::isError($res)) { |
return $res; |
} |
if ($fetchmode == DB_FETCHMODE_DEFAULT) { |
$fetchmode = $this->fetchmode; |
} |
$cols = $res->numCols(); |
if ($cols < 2) { |
$tmp = $this->raiseError(DB_ERROR_TRUNCATED); |
return $tmp; |
} |
$results = array(); |
if ($cols > 2 || $force_array) { |
// return array values |
// XXX this part can be optimized |
if ($fetchmode == DB_FETCHMODE_ASSOC) { |
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ASSOC))) { |
reset($row); |
$key = current($row); |
unset($row[key($row)]); |
if ($group) { |
$results[$key][] = $row; |
} else { |
$results[$key] = $row; |
} |
} |
} elseif ($fetchmode == DB_FETCHMODE_OBJECT) { |
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { |
$arr = get_object_vars($row); |
$key = current($arr); |
if ($group) { |
$results[$key][] = $row; |
} else { |
$results[$key] = $row; |
} |
} |
} else { |
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) { |
// we shift away the first element to get |
// indices running from 0 again |
$key = array_shift($row); |
if ($group) { |
$results[$key][] = $row; |
} else { |
$results[$key] = $row; |
} |
} |
} |
if (DB::isError($row)) { |
$results = $row; |
} |
} else { |
// return scalar values |
while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) { |
if ($group) { |
$results[$row[0]][] = $row[1]; |
} else { |
$results[$row[0]] = $row[1]; |
} |
} |
if (DB::isError($row)) { |
$results = $row; |
} |
} |
$res->free(); |
return $results; |
} |
// }}} |
// {{{ getAll() |
/** |
* Fetches all of the rows from a query result |
* |
* @param string $query the SQL query |
* @param mixed $params array, string or numeric data to be used in |
* execution of the statement. Quantity of |
* items passed must match quantity of |
* placeholders in query: meaning 1 |
* placeholder for non-array parameters or |
* 1 placeholder per array element. |
* @param int $fetchmode the fetch mode to use: |
* + DB_FETCHMODE_ORDERED |
* + DB_FETCHMODE_ASSOC |
* + DB_FETCHMODE_ORDERED | DB_FETCHMODE_FLIPPED |
* + DB_FETCHMODE_ASSOC | DB_FETCHMODE_FLIPPED |
* |
* @return array the nested array. A DB_Error object on failure. |
*/ |
function &getAll($query, $params = array(), |
$fetchmode = DB_FETCHMODE_DEFAULT) |
{ |
// compat check, the params and fetchmode parameters used to |
// have the opposite order |
if (!is_array($params)) { |
if (is_array($fetchmode)) { |
if ($params === null) { |
$tmp = DB_FETCHMODE_DEFAULT; |
} else { |
$tmp = $params; |
} |
$params = $fetchmode; |
$fetchmode = $tmp; |
} elseif ($params !== null) { |
$fetchmode = $params; |
$params = array(); |
} |
} |
if (sizeof($params) > 0) { |
$sth = $this->prepare($query); |
if (DB::isError($sth)) { |
return $sth; |
} |
$res = $this->execute($sth, $params); |
$this->freePrepared($sth); |
} else { |
$res = $this->query($query); |
} |
if ($res === DB_OK || DB::isError($res)) { |
return $res; |
} |
$results = array(); |
while (DB_OK === $res->fetchInto($row, $fetchmode)) { |
if ($fetchmode & DB_FETCHMODE_FLIPPED) { |
foreach ($row as $key => $val) { |
$results[$key][] = $val; |
} |
} else { |
$results[] = $row; |
} |
} |
$res->free(); |
if (DB::isError($row)) { |
$tmp = $this->raiseError($row); |
return $tmp; |
} |
return $results; |
} |
// }}} |
// {{{ autoCommit() |
/** |
* Enables or disables automatic commits |
* |
* @param bool $onoff true turns it on, false turns it off |
* |
* @return int DB_OK on success. A DB_Error object if the driver |
* doesn't support auto-committing transactions. |
*/ |
function autoCommit($onoff = false) |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ commit() |
/** |
* Commits the current transaction |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
*/ |
function commit() |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ rollback() |
/** |
* Reverts the current transaction |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
*/ |
function rollback() |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ numRows() |
/** |
* Determines the number of rows in a query result |
* |
* @param resource $result the query result idenifier produced by PHP |
* |
* @return int the number of rows. A DB_Error object on failure. |
*/ |
function numRows($result) |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ affectedRows() |
/** |
* Determines the number of rows affected by a data maniuplation query |
* |
* 0 is returned for queries that don't manipulate data. |
* |
* @return int the number of rows. A DB_Error object on failure. |
*/ |
function affectedRows() |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ getSequenceName() |
/** |
* Generates the name used inside the database for a sequence |
* |
* The createSequence() docblock contains notes about storing sequence |
* names. |
* |
* @param string $sqn the sequence's public name |
* |
* @return string the sequence's name in the backend |
* |
* @access protected |
* @see DB_common::createSequence(), DB_common::dropSequence(), |
* DB_common::nextID(), DB_common::setOption() |
*/ |
function getSequenceName($sqn) |
{ |
return sprintf($this->getOption('seqname_format'), |
preg_replace('/[^a-z0-9_.]/i', '_', $sqn)); |
} |
// }}} |
// {{{ nextId() |
/** |
* Returns the next free id in a sequence |
* |
* @param string $seq_name name of the sequence |
* @param boolean $ondemand when true, the seqence is automatically |
* created if it does not exist |
* |
* @return int the next id number in the sequence. |
* A DB_Error object on failure. |
* |
* @see DB_common::createSequence(), DB_common::dropSequence(), |
* DB_common::getSequenceName() |
*/ |
function nextId($seq_name, $ondemand = true) |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ createSequence() |
/** |
* Creates a new sequence |
* |
* The name of a given sequence is determined by passing the string |
* provided in the <var>$seq_name</var> argument through PHP's sprintf() |
* function using the value from the <var>seqname_format</var> option as |
* the sprintf()'s format argument. |
* |
* <var>seqname_format</var> is set via setOption(). |
* |
* @param string $seq_name name of the new sequence |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::dropSequence(), DB_common::getSequenceName(), |
* DB_common::nextID() |
*/ |
function createSequence($seq_name) |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ dropSequence() |
/** |
* Deletes a sequence |
* |
* @param string $seq_name name of the sequence to be deleted |
* |
* @return int DB_OK on success. A DB_Error object on failure. |
* |
* @see DB_common::createSequence(), DB_common::getSequenceName(), |
* DB_common::nextID() |
*/ |
function dropSequence($seq_name) |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ raiseError() |
/** |
* Communicates an error and invoke error callbacks, etc |
* |
* Basically a wrapper for PEAR::raiseError without the message string. |
* |
* @param mixed integer error code, or a PEAR error object (all |
* other parameters are ignored if this parameter is |
* an object |
* @param int error mode, see PEAR_Error docs |
* @param mixed if error mode is PEAR_ERROR_TRIGGER, this is the |
* error level (E_USER_NOTICE etc). If error mode is |
* PEAR_ERROR_CALLBACK, this is the callback function, |
* either as a function name, or as an array of an |
* object and method name. For other error modes this |
* parameter is ignored. |
* @param string extra debug information. Defaults to the last |
* query and native error code. |
* @param mixed native error code, integer or string depending the |
* backend |
* |
* @return object the PEAR_Error object |
* |
* @see PEAR_Error |
*/ |
function &raiseError($code = DB_ERROR, $mode = null, $options = null, |
$userinfo = null, $nativecode = null) |
{ |
// The error is yet a DB error object |
if (is_object($code)) { |
// because we the static PEAR::raiseError, our global |
// handler should be used if it is set |
if ($mode === null && !empty($this->_default_error_mode)) { |
$mode = $this->_default_error_mode; |
$options = $this->_default_error_options; |
} |
$tmp = PEAR::raiseError($code, null, $mode, $options, |
null, null, true); |
return $tmp; |
} |
if ($userinfo === null) { |
$userinfo = $this->last_query; |
} |
if ($nativecode) { |
$userinfo .= ' [nativecode=' . trim($nativecode) . ']'; |
} else { |
$userinfo .= ' [DB Error: ' . DB::errorMessage($code) . ']'; |
} |
$tmp = PEAR::raiseError(null, $code, $mode, $options, $userinfo, |
'DB_Error', true); |
return $tmp; |
} |
// }}} |
// {{{ errorNative() |
/** |
* Gets the DBMS' native error code produced by the last query |
* |
* @return mixed the DBMS' error code. A DB_Error object on failure. |
*/ |
function errorNative() |
{ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ errorCode() |
/** |
* Maps native error codes to DB's portable ones |
* |
* Uses the <var>$errorcode_map</var> property defined in each driver. |
* |
* @param string|int $nativecode the error code returned by the DBMS |
* |
* @return int the portable DB error code. Return DB_ERROR if the |
* current driver doesn't have a mapping for the |
* $nativecode submitted. |
*/ |
function errorCode($nativecode) |
{ |
if (isset($this->errorcode_map[$nativecode])) { |
return $this->errorcode_map[$nativecode]; |
} |
// Fall back to DB_ERROR if there was no mapping. |
return DB_ERROR; |
} |
// }}} |
// {{{ errorMessage() |
/** |
* Maps a DB error code to a textual message |
* |
* @param integer $dbcode the DB error code |
* |
* @return string the error message corresponding to the error code |
* submitted. FALSE if the error code is unknown. |
* |
* @see DB::errorMessage() |
*/ |
function errorMessage($dbcode) |
{ |
return DB::errorMessage($this->errorcode_map[$dbcode]); |
} |
// }}} |
// {{{ tableInfo() |
/** |
* Returns information about a table or a result set |
* |
* The format of the resulting array depends on which <var>$mode</var> |
* you select. The sample output below is based on this query: |
* <pre> |
* SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId |
* FROM tblFoo |
* JOIN tblBar ON tblFoo.fldId = tblBar.fldId |
* </pre> |
* |
* <ul> |
* <li> |
* |
* <kbd>null</kbd> (default) |
* <pre> |
* [0] => Array ( |
* [table] => tblFoo |
* [name] => fldId |
* [type] => int |
* [len] => 11 |
* [flags] => primary_key not_null |
* ) |
* [1] => Array ( |
* [table] => tblFoo |
* [name] => fldPhone |
* [type] => string |
* [len] => 20 |
* [flags] => |
* ) |
* [2] => Array ( |
* [table] => tblBar |
* [name] => fldId |
* [type] => int |
* [len] => 11 |
* [flags] => primary_key not_null |
* ) |
* </pre> |
* |
* </li><li> |
* |
* <kbd>DB_TABLEINFO_ORDER</kbd> |
* |
* <p>In addition to the information found in the default output, |
* a notation of the number of columns is provided by the |
* <samp>num_fields</samp> element while the <samp>order</samp> |
* element provides an array with the column names as the keys and |
* their location index number (corresponding to the keys in the |
* the default output) as the values.</p> |
* |
* <p>If a result set has identical field names, the last one is |
* used.</p> |
* |
* <pre> |
* [num_fields] => 3 |
* [order] => Array ( |
* [fldId] => 2 |
* [fldTrans] => 1 |
* ) |
* </pre> |
* |
* </li><li> |
* |
* <kbd>DB_TABLEINFO_ORDERTABLE</kbd> |
* |
* <p>Similar to <kbd>DB_TABLEINFO_ORDER</kbd> but adds more |
* dimensions to the array in which the table names are keys and |
* the field names are sub-keys. This is helpful for queries that |
* join tables which have identical field names.</p> |
* |
* <pre> |
* [num_fields] => 3 |
* [ordertable] => Array ( |
* [tblFoo] => Array ( |
* [fldId] => 0 |
* [fldPhone] => 1 |
* ) |
* [tblBar] => Array ( |
* [fldId] => 2 |
* ) |
* ) |
* </pre> |
* |
* </li> |
* </ul> |
* |
* The <samp>flags</samp> element contains a space separated list |
* of extra information about the field. This data is inconsistent |
* between DBMS's due to the way each DBMS works. |
* + <samp>primary_key</samp> |
* + <samp>unique_key</samp> |
* + <samp>multiple_key</samp> |
* + <samp>not_null</samp> |
* |
* Most DBMS's only provide the <samp>table</samp> and <samp>flags</samp> |
* elements if <var>$result</var> is a table name. The following DBMS's |
* provide full information from queries: |
* + fbsql |
* + mysql |
* |
* If the 'portability' option has <samp>DB_PORTABILITY_LOWERCASE</samp> |
* turned on, the names of tables and fields will be lowercased. |
* |
* @param object|string $result DB_result object from a query or a |
* string containing the name of a table. |
* While this also accepts a query result |
* resource identifier, this behavior is |
* deprecated. |
* @param int $mode either unused or one of the tableInfo modes: |
* <kbd>DB_TABLEINFO_ORDERTABLE</kbd>, |
* <kbd>DB_TABLEINFO_ORDER</kbd> or |
* <kbd>DB_TABLEINFO_FULL</kbd> (which does both). |
* These are bitwise, so the first two can be |
* combined using <kbd>|</kbd>. |
* |
* @return array an associative array with the information requested. |
* A DB_Error object on failure. |
* |
* @see DB_common::setOption() |
*/ |
function tableInfo($result, $mode = null) |
{ |
/* |
* If the DB_<driver> class has a tableInfo() method, that one |
* overrides this one. But, if the driver doesn't have one, |
* this method runs and tells users about that fact. |
*/ |
return $this->raiseError(DB_ERROR_NOT_CAPABLE); |
} |
// }}} |
// {{{ getTables() |
/** |
* Lists the tables in the current database |
* |
* @return array the list of tables. A DB_Error object on failure. |
* |
* @deprecated Method deprecated some time before Release 1.2 |
*/ |
function getTables() |
{ |
return $this->getListOf('tables'); |
} |
// }}} |
// {{{ getListOf() |
/** |
* Lists internal database information |
* |
* @param string $type type of information being sought. |
* Common items being sought are: |
* tables, databases, users, views, functions |
* Each DBMS's has its own capabilities. |
* |
* @return array an array listing the items sought. |
* A DB DB_Error object on failure. |
*/ |
function getListOf($type) |
{ |
$sql = $this->getSpecialQuery($type); |
if ($sql === null) { |
$this->last_query = ''; |
return $this->raiseError(DB_ERROR_UNSUPPORTED); |
} elseif (is_int($sql) || DB::isError($sql)) { |
// Previous error |
return $this->raiseError($sql); |
} elseif (is_array($sql)) { |
// Already the result |
return $sql; |
} |
// Launch this query |
return $this->getCol($sql); |
} |
// }}} |
// {{{ getSpecialQuery() |
/** |
* Obtains the query string needed for listing a given type of objects |
* |
* @param string $type the kind of objects you want to retrieve |
* |
* @return string the SQL query string or null if the driver doesn't |
* support the object type requested |
* |
* @access protected |
* @see DB_common::getListOf() |
*/ |
function getSpecialQuery($type) |
{ |
return $this->raiseError(DB_ERROR_UNSUPPORTED); |
} |
// }}} |
// {{{ nextQueryIsManip() |
/** |
* Sets (or unsets) a flag indicating that the next query will be a |
* manipulation query, regardless of the usual DB::isManip() heuristics. |
* |
* @param boolean true to set the flag overriding the isManip() behaviour, |
* false to clear it and fall back onto isManip() |
* |
* @return void |
* |
* @access public |
*/ |
function nextQueryIsManip($manip) |
{ |
$this->_next_query_manip = $manip; |
} |
// }}} |
// {{{ _checkManip() |
/** |
* Checks if the given query is a manipulation query. This also takes into |
* account the _next_query_manip flag and sets the _last_query_manip flag |
* (and resets _next_query_manip) according to the result. |
* |
* @param string The query to check. |
* |
* @return boolean true if the query is a manipulation query, false |
* otherwise |
* |
* @access protected |
*/ |
function _checkManip($query) |
{ |
if ($this->_next_query_manip || DB::isManip($query)) { |
$this->_last_query_manip = true; |
} else { |
$this->_last_query_manip = false; |
} |
$this->_next_query_manip = false; |
return $this->_last_query_manip; |
$manip = $this->_next_query_manip; |
} |
// }}} |
// {{{ _rtrimArrayValues() |
/** |
* Right-trims all strings in an array |
* |
* @param array $array the array to be trimmed (passed by reference) |
* |
* @return void |
* |
* @access protected |
*/ |
function _rtrimArrayValues(&$array) |
{ |
foreach ($array as $key => $value) { |
if (is_string($value)) { |
$array[$key] = rtrim($value); |
} |
} |
} |
// }}} |
// {{{ _convertNullArrayValuesToEmpty() |
/** |
* Converts all null values in an array to empty strings |
* |
* @param array $array the array to be de-nullified (passed by reference) |
* |
* @return void |
* |
* @access protected |
*/ |
function _convertNullArrayValuesToEmpty(&$array) |
{ |
foreach ($array as $key => $value) { |
if (is_null($value)) { |
$array[$key] = ''; |
} |
} |
} |
// }}} |
} |
/* |
* Local variables: |
* tab-width: 4 |
* c-basic-offset: 4 |
* End: |
*/ |
?> |
/branches/ant-ng/lib/Smarty.class.php |
---|
Новый файл |
0,0 → 1,531 |
<?php |
/** |
* Project: Smarty: the PHP compiling template engine |
* File: Smarty.class.php |
* |
* This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Lesser General Public |
* License as published by the Free Software Foundation; either |
* version 2.1 of the License, or (at your option) any later version. |
* |
* This library is distributed in the hope that it will be useful, |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* Lesser General Public License for more details. |
* |
* You should have received a copy of the GNU Lesser General Public |
* License along with this library; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
* For questions, help, comments, discussion, etc., please join the |
* Smarty mailing list. Send a blank e-mail to |
* smarty-discussion-subscribe@googlegroups.com |
* |
* @link http://www.smarty.net/ |
* @copyright 2008 New Digital Group, Inc. |
* @author Monte Ohrt <monte at ohrt dot com> |
* @author Uwe Tews |
* @package Smarty |
* @version 3.0-beta |
*/ |
/** |
* define shorthand directory separator constant |
*/ |
if (!defined('DS')) { |
define('DS', DIRECTORY_SEPARATOR); |
} |
/** |
* set SMARTY_DIR to absolute path to Smarty library files. |
* Sets SMARTY_DIR only if user application has not already defined it. |
*/ |
if (!defined('SMARTY_DIR')) { |
define('SMARTY_DIR', dirname(__FILE__) . DS); |
} |
/** |
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. |
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. |
*/ |
if (!defined('SMARTY_SYSPLUGINS_DIR')) { |
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); |
} |
if (!defined('SMARTY_PLUGINS_DIR')) { |
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); |
} |
if (!defined('SMARTY_RESOURCE_CHAR_SET')) { |
define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8'); |
} |
/** |
* define variable scopes |
*/ |
define('SMARTY_LOCAL_SCOPE', 0); |
define('SMARTY_PARENT_SCOPE', 1); |
define('SMARTY_ROOT_SCOPE', 2); |
define('SMARTY_GLOBAL_SCOPE', 3); |
/** |
* define caching modes |
*/ |
define('SMARTY_CACHING_OFF', 0); |
define('SMARTY_CACHING_LIFETIME_CURRENT', 1); |
define('SMARTY_CACHING_LIVETIME_SAVED', 2); |
/** |
* This determines how Smarty handles "<?php ... ?>" tags in templates. |
* possible values: |
*/ |
define('SMARTY_PHP_PASSTHRU', 0); //-> print tags as plain text |
define('SMARTY_PHP_QUOTE', 1); //-> escape tags as entities |
define('SMARTY_PHP_REMOVE', 2); //-> escape tags as entities |
define('SMARTY_PHP_ALLOW', 3); //-> escape tags as entities |
/** |
* load required base class for creation of the smarty object |
*/ |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.templatebase.php'); |
/** |
* This is the main Smarty class |
*/ |
class Smarty extends Smarty_Internal_TemplateBase { |
// smarty version |
public static $_version = 'Smarty3Beta-dev'; |
// auto literal on delimiters with whitspace |
public $auto_literal = true; |
// display error on not assigned variabled |
static $error_unassigned = false; |
// template directory |
public $template_dir = null; |
// default template handler |
public $default_template_handler_func = null; |
// compile directory |
public $compile_dir = null; |
// plugins directory |
public $plugins_dir = null; |
// cache directory |
public $cache_dir = null; |
// config directory |
public $config_dir = null; |
// force template compiling? |
public $force_compile = false; |
// check template for modifications? |
public $compile_check = true; |
// use sub dirs for compiled/cached files? |
public $use_sub_dirs = false; |
// php file extention |
public $php_ext = '.php'; |
// compile_error? |
public $compile_error = false; |
// caching enabled |
public $caching = false; |
// cache lifetime |
public $cache_lifetime = 0; |
// force cache file creation |
public $force_cache = false; |
// cache_id |
public $cache_id = null; |
// compile_id |
public $compile_id = null; |
// template delimiters |
public $left_delimiter = "{"; |
public $right_delimiter = "}"; |
// security |
public $php_handling = SMARTY_PHP_PASSTHRU; |
public $allow_php_tag = false; |
public $allow_php_templates = false; |
public $security = false; |
public $security_policy = null; |
public $security_handler = null; |
public $direct_access_security = true; |
// debug mode |
public $debugging = false; |
public $debugging_ctrl = 'URL'; |
public $smarty_debug_id = 'SMARTY_DEBUG'; |
public $debug_tpl = null; |
// When set, smarty does uses this value as error_reporting-level. |
public $error_reporting = null; |
// config var settings |
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other. |
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean |
public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. |
// config vars |
public $config_vars = array(); |
// assigned tpl vars |
public $tpl_vars = array(); |
// assigned global tpl vars |
public $global_tpl_vars = array(); |
// dummy parent object |
public $parent = null; |
// global template functions |
public $template_functions = null; |
// resource type used if none given |
public $default_resource_type = 'file'; |
// caching type |
public $default_caching_type = 'file'; |
// internal cache resource types |
public $cache_resorce_types = array('file'); |
// config type |
public $default_config_type = 'file'; |
// class used for cacher |
public $cacher_class = 'Smarty_Internal_Cacher_InlineCode'; |
// exception handler: array('ExceptionClass','ExceptionMethod'); |
public $exception_handler = null; |
// cached template objects |
public $template_objects = null; |
// check If-Modified-Since headers |
public $cache_modified_check = false; |
// cached objects |
public $resource_objects = array(); |
// registered plugins |
public $registered_plugins = array(); |
// plugin search order |
public $plugin_search_order = array('function', 'block', 'compiler', 'class'); |
// plugin handler object |
public $plugin_handler = null; |
// default plugin handler |
public $default_plugin_handler_func = null; |
// registered objects |
public $registered_objects = array(); |
// registered filters |
public $registered_filters = array(); |
// filter handler |
public $filter_handler = null; |
// autoload filter |
public $autoload_filters = array(); |
// status of filter on variable output |
public $variable_filter = true; |
// cache resorce objects |
public $cache_resource_objects = array(); |
// write file object |
public $write_file_object = null; |
// global internal smarty vars |
public $_smarty_vars = array(); |
// start time for execution time calculation |
public $start_time = 0; |
/** |
* Class constructor, initializes basic smarty properties |
*/ |
public function __construct() |
{ |
// self reference needed by other classes methodes |
$this->smarty = $this; |
if (is_callable('mb_internal_encoding')) { |
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET); |
} |
$this->start_time = $this->_get_time(); |
// set exception handler |
if (!empty($this->exception_handler)) |
set_exception_handler($this->exception_handler); |
// set default dirs |
$this->template_dir = array('.' . DS . 'templates' . DS); |
$this->compile_dir = '.' . DS . 'templates_c' . DS; |
$this->plugins_dir = array(SMARTY_PLUGINS_DIR); |
$this->cache_dir = '.' . DS . 'cache' . DS; |
$this->config_dir = '.' . DS . 'configs' . DS; |
$this->debug_tpl = SMARTY_DIR . 'debug.tpl'; |
// load basic plugins |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.template.php'); |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.plugin_handler.php'); |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.run_filter.php'); |
// $this->loadPlugin($this->template_class); |
// $this->loadPlugin('Smarty_Internal_Plugin_Handler'); |
// $this->loadPlugin('Smarty_Internal_Run_Filter'); |
$this->plugin_handler = new Smarty_Internal_Plugin_Handler($this); |
$this->filter_handler = new Smarty_Internal_Run_Filter($this); |
if (!$this->debugging && $this->debugging_ctrl == 'URL') { |
if (isset($_SERVER['QUERY_STRING'])) { |
$_query_string = $_SERVER['QUERY_STRING']; |
} else { |
$_query_string = ''; |
} |
if (false !== strpos($_query_string, $this->smarty_debug_id)) { |
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) { |
// enable debugging for this browser session |
setcookie('SMARTY_DEBUG', true); |
$this->debugging = true; |
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) { |
// disable debugging for this browser session |
setcookie('SMARTY_DEBUG', false); |
$this->debugging = false; |
} else { |
// enable debugging for this page |
$this->debugging = true; |
} |
} else { |
if (isset($_COOKIE['SMARTY_DEBUG'])) { |
$this->debugging = true; |
} |
} |
} |
$this->assign_global('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); |
} |
/** |
* Class destructor |
*/ |
public function __destruct() |
{ |
// restore to previous exception handler, if any |
if (!empty($this->exception_handler)) |
restore_exception_handler(); |
} |
/** |
* fetches a rendered Smarty template |
* |
* @param string $template the resource handle of the template file or template object |
* @param mixed $cache_id cache id to be used with this template |
* @param mixed $compile_id compile id to be used with this template |
* @param object $ |null $parent next higher level of Smarty variables |
* @return string rendered template output |
*/ |
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null) |
{ |
if (is_object($cache_id)) { |
$parent = $cache_id; |
$cache_id = null; |
} |
if ($parent === null) { |
// get default Smarty data object |
$parent = $this; |
} |
// create template object if necessary |
($template instanceof $this->template_class)? $_template = $template : |
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); |
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) |
? $this->error_reporting : error_reporting() &~E_NOTICE); |
// return redered template |
$_output = $_template->getRenderedTemplate(); |
$_template->rendered_content = null; |
error_reporting($_smarty_old_error_level); |
return $_output; |
} |
/** |
* displays a Smarty template |
* |
* @param string $ |object $template the resource handle of the template file or template object |
* @param mixed $cache_id cache id to be used with this template |
* @param mixed $compile_id compile id to be used with this template |
* @param object $parent next higher level of Smarty variables |
*/ |
public function display($template, $cache_id = null, $compile_id = null, $parent = null) |
{ |
if (is_object($cache_id)) { |
$parent = $cache_id; |
$cache_id = null; |
} |
// display template |
echo $this->fetch ($template, $cache_id, $compile_id, $parent); |
// debug output? |
if ($this->debugging) { |
$this->loadPlugin('Smarty_Internal_Debug'); |
Smarty_Internal_Debug::display_debug($this); |
} |
return true; |
} |
/** |
* test if cache i valid |
* |
* @param string $ |object $template the resource handle of the template file or template object |
* @param mixed $cache_id cache id to be used with this template |
* @param mixed $compile_id compile id to be used with this template |
* @return boolean cache status |
*/ |
public function is_cached($template, $cache_id = null, $compile_id = null) |
{ |
if (!($template instanceof $this->template_class)) { |
$template = $this->createTemplate ($template, $cache_id, $compile_id, $this); |
} |
// return cache status of template |
return $template->isCached(); |
} |
/** |
* Load the plugin with security definition and enables security |
* |
* @param string $security_policy plugin to load |
*/ |
public function enableSecurity($security_policy_file = null) |
{ |
if (!isset($security_policy_file)) { |
$security_policy_file = SMARTY_DIR . 'Security.class.php'; |
} |
if (file_exists($security_policy_file)) { |
require_once($security_policy_file); |
if (!class_exists('Smarty_Security_Policy')) { |
throw new Exception("Security policy must define class 'Smarty_Security_Policy'"); |
} |
$this->security_policy = new Smarty_Security_Policy; |
$this->loadPlugin('Smarty_Internal_Security_Handler'); |
$this->security_handler = new Smarty_Internal_Security_Handler($this); |
$this->security = true; |
} else { |
throw new Exception("Security policy {$security_policy_file} not found"); |
} |
} |
/** |
* Set template directory |
* |
* @param string $ |array $template_dir folder(s) of template sorces |
*/ |
public function setTemplateDir($template_dir) |
{ |
$this->template_dir = (array)$template_dir; |
return; |
} |
/** |
* Adds template directory(s) to existing ones |
* |
* @param string $ |array $template_dir folder(s) of template sources |
*/ |
public function addTemplateDir($template_dir) |
{ |
$this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir); |
$this->template_dir = array_unique($this->template_dir); |
return; |
} |
/** |
* Set compile directory |
* |
* @param string $compile_dir folder of compiled template sources |
*/ |
public function setCompileDir($compile_dir) |
{ |
$this->compile_dir = $compile_dir; |
return; |
} |
/** |
* Set cache directory |
* |
* @param string $cache_dir folder of cache files |
*/ |
public function setCacheDir($cache_dir) |
{ |
$this->cache_dir = $cache_dir; |
return; |
} |
/** |
* Enable Caching |
*/ |
public function enableCaching() |
{ |
$this->caching = true; |
return; |
} |
/** |
* Set caching life time |
* |
* @param integer $lifetime lifetime of cached file in seconds |
*/ |
public function setCacheLifetime($lifetime) |
{ |
$this->cache_lifetime = $lifetime; |
return; |
} |
/** |
* Takes unknown classes and loads plugin files for them |
* class name format: Smarty_PluginType_PluginName |
* plugin filename format: plugintype.pluginname.php |
* |
* @param string $plugin_name class plugin name to load |
* @return boolean |
*/ |
public function loadPlugin($plugin_name) |
{ |
// if class exists, exit silently (already loaded) |
if (class_exists($plugin_name, false)) |
return true; |
// if callable as function, exit silently (already loaded) |
if (is_callable($plugin_name)) |
return true; |
// Plugin name is expected to be: Smarty_[Type]_[Name] |
$plugin_name = strtolower($plugin_name); |
$_name_parts = explode('_', $plugin_name, 3); |
// class name must have three parts to be valid plugin |
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') { |
throw new Exception("plugin {$plugin_name} is not a valid name format"); |
return false; |
} |
// plugin filename is expected to be: [type].[name].php |
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}{$this->php_ext}"; |
// if type is "internal", get plugin from sysplugins |
if ($_name_parts[1] == 'internal') { |
if (file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_filename)) { |
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_filename); |
return true; |
} else { |
return false; |
} |
} |
// loop through plugin dirs and find the plugin |
foreach((array)$this->plugins_dir as $_plugin_dir) { |
if (strpos('/\\', substr($_plugin_dir, -1)) === false) { |
$_plugin_dir .= DS; |
} |
if (file_exists($_plugin_dir . $_plugin_filename)) { |
require_once($_plugin_dir . $_plugin_filename); |
return true; |
} |
} |
// no plugin loaded |
return false; |
} |
/** |
* Sets the exception handler for Smarty. |
* |
* @param mixed $handler function name or array with object/method names |
* @return string previous exception handler |
*/ |
public function setExceptionHandler($handler) |
{ |
$this->exception_handler = $handler; |
return set_exception_handler($handler); |
} |
/** |
* trigger Smarty error |
* |
* @param string $error_msg |
* @param integer $error_type |
*/ |
public function trigger_error($error_msg, $error_type = E_USER_WARNING) |
{ |
// trigger_error("Smarty error: $error_msg", $error_type); |
throw new Exception("Smarty error: $error_msg"); |
} |
/** |
* Takes unknown class methods and lazy loads sysplugin files for them |
* class name format: Smarty_Method_MethodName |
* plugin filename format: method.methodname.php |
* |
* @param string $name unknown methode name |
* @param array $args aurgument array |
*/ |
public function __call($name, $args) |
{ |
if (!is_callable($name)) { |
$_plugin_filename = strtolower('method.' . $name . $this->php_ext); |
if (!file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_filename)) { |
throw new Exception("Sysplugin file " . $_plugin_filename . " does not exist"); |
} |
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_filename); |
if (!is_callable($name)) { |
throw new Exception ("Sysplugin file " . $_plugin_filename . " does not define function " . $name); |
} |
} |
return call_user_func_array($name, array_merge(array($this), $args)); |
} |
} |
?> |
/branches/ant-ng/lib/DB.php |
---|
Новый файл |
0,0 → 1,1489 |
<?php |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
/** |
* Database independent query interface |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V.Cox <cox@idecnet.com> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: DB.php,v 1.88 2007/08/12 05:27:25 aharvey Exp $ |
* @link http://pear.php.net/package/DB |
*/ |
/** |
* Obtain the PEAR class so it can be extended from |
*/ |
require_once 'PEAR.php'; |
// {{{ constants |
// {{{ error codes |
/**#@+ |
* One of PEAR DB's portable error codes. |
* @see DB_common::errorCode(), DB::errorMessage() |
* |
* {@internal If you add an error code here, make sure you also add a textual |
* version of it in DB::errorMessage().}} |
*/ |
/** |
* The code returned by many methods upon success |
*/ |
define('DB_OK', 1); |
/** |
* Unkown error |
*/ |
define('DB_ERROR', -1); |
/** |
* Syntax error |
*/ |
define('DB_ERROR_SYNTAX', -2); |
/** |
* Tried to insert a duplicate value into a primary or unique index |
*/ |
define('DB_ERROR_CONSTRAINT', -3); |
/** |
* An identifier in the query refers to a non-existant object |
*/ |
define('DB_ERROR_NOT_FOUND', -4); |
/** |
* Tried to create a duplicate object |
*/ |
define('DB_ERROR_ALREADY_EXISTS', -5); |
/** |
* The current driver does not support the action you attempted |
*/ |
define('DB_ERROR_UNSUPPORTED', -6); |
/** |
* The number of parameters does not match the number of placeholders |
*/ |
define('DB_ERROR_MISMATCH', -7); |
/** |
* A literal submitted did not match the data type expected |
*/ |
define('DB_ERROR_INVALID', -8); |
/** |
* The current DBMS does not support the action you attempted |
*/ |
define('DB_ERROR_NOT_CAPABLE', -9); |
/** |
* A literal submitted was too long so the end of it was removed |
*/ |
define('DB_ERROR_TRUNCATED', -10); |
/** |
* A literal number submitted did not match the data type expected |
*/ |
define('DB_ERROR_INVALID_NUMBER', -11); |
/** |
* A literal date submitted did not match the data type expected |
*/ |
define('DB_ERROR_INVALID_DATE', -12); |
/** |
* Attempt to divide something by zero |
*/ |
define('DB_ERROR_DIVZERO', -13); |
/** |
* A database needs to be selected |
*/ |
define('DB_ERROR_NODBSELECTED', -14); |
/** |
* Could not create the object requested |
*/ |
define('DB_ERROR_CANNOT_CREATE', -15); |
/** |
* Could not drop the database requested because it does not exist |
*/ |
define('DB_ERROR_CANNOT_DROP', -17); |
/** |
* An identifier in the query refers to a non-existant table |
*/ |
define('DB_ERROR_NOSUCHTABLE', -18); |
/** |
* An identifier in the query refers to a non-existant column |
*/ |
define('DB_ERROR_NOSUCHFIELD', -19); |
/** |
* The data submitted to the method was inappropriate |
*/ |
define('DB_ERROR_NEED_MORE_DATA', -20); |
/** |
* The attempt to lock the table failed |
*/ |
define('DB_ERROR_NOT_LOCKED', -21); |
/** |
* The number of columns doesn't match the number of values |
*/ |
define('DB_ERROR_VALUE_COUNT_ON_ROW', -22); |
/** |
* The DSN submitted has problems |
*/ |
define('DB_ERROR_INVALID_DSN', -23); |
/** |
* Could not connect to the database |
*/ |
define('DB_ERROR_CONNECT_FAILED', -24); |
/** |
* The PHP extension needed for this DBMS could not be found |
*/ |
define('DB_ERROR_EXTENSION_NOT_FOUND',-25); |
/** |
* The present user has inadequate permissions to perform the task requestd |
*/ |
define('DB_ERROR_ACCESS_VIOLATION', -26); |
/** |
* The database requested does not exist |
*/ |
define('DB_ERROR_NOSUCHDB', -27); |
/** |
* Tried to insert a null value into a column that doesn't allow nulls |
*/ |
define('DB_ERROR_CONSTRAINT_NOT_NULL',-29); |
/**#@-*/ |
// }}} |
// {{{ prepared statement-related |
/**#@+ |
* Identifiers for the placeholders used in prepared statements. |
* @see DB_common::prepare() |
*/ |
/** |
* Indicates a scalar (<kbd>?</kbd>) placeholder was used |
* |
* Quote and escape the value as necessary. |
*/ |
define('DB_PARAM_SCALAR', 1); |
/** |
* Indicates an opaque (<kbd>&</kbd>) placeholder was used |
* |
* The value presented is a file name. Extract the contents of that file |
* and place them in this column. |
*/ |
define('DB_PARAM_OPAQUE', 2); |
/** |
* Indicates a misc (<kbd>!</kbd>) placeholder was used |
* |
* The value should not be quoted or escaped. |
*/ |
define('DB_PARAM_MISC', 3); |
/**#@-*/ |
// }}} |
// {{{ binary data-related |
/**#@+ |
* The different ways of returning binary data from queries. |
*/ |
/** |
* Sends the fetched data straight through to output |
*/ |
define('DB_BINMODE_PASSTHRU', 1); |
/** |
* Lets you return data as usual |
*/ |
define('DB_BINMODE_RETURN', 2); |
/** |
* Converts the data to hex format before returning it |
* |
* For example the string "123" would become "313233". |
*/ |
define('DB_BINMODE_CONVERT', 3); |
/**#@-*/ |
// }}} |
// {{{ fetch modes |
/**#@+ |
* Fetch Modes. |
* @see DB_common::setFetchMode() |
*/ |
/** |
* Indicates the current default fetch mode should be used |
* @see DB_common::$fetchmode |
*/ |
define('DB_FETCHMODE_DEFAULT', 0); |
/** |
* Column data indexed by numbers, ordered from 0 and up |
*/ |
define('DB_FETCHMODE_ORDERED', 1); |
/** |
* Column data indexed by column names |
*/ |
define('DB_FETCHMODE_ASSOC', 2); |
/** |
* Column data as object properties |
*/ |
define('DB_FETCHMODE_OBJECT', 3); |
/** |
* For multi-dimensional results, make the column name the first level |
* of the array and put the row number in the second level of the array |
* |
* This is flipped from the normal behavior, which puts the row numbers |
* in the first level of the array and the column names in the second level. |
*/ |
define('DB_FETCHMODE_FLIPPED', 4); |
/**#@-*/ |
/**#@+ |
* Old fetch modes. Left here for compatibility. |
*/ |
define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); |
define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); |
define('DB_GETMODE_FLIPPED', DB_FETCHMODE_FLIPPED); |
/**#@-*/ |
// }}} |
// {{{ tableInfo() && autoPrepare()-related |
/**#@+ |
* The type of information to return from the tableInfo() method. |
* |
* Bitwised constants, so they can be combined using <kbd>|</kbd> |
* and removed using <kbd>^</kbd>. |
* |
* @see DB_common::tableInfo() |
* |
* {@internal Since the TABLEINFO constants are bitwised, if more of them are |
* added in the future, make sure to adjust DB_TABLEINFO_FULL accordingly.}} |
*/ |
define('DB_TABLEINFO_ORDER', 1); |
define('DB_TABLEINFO_ORDERTABLE', 2); |
define('DB_TABLEINFO_FULL', 3); |
/**#@-*/ |
/**#@+ |
* The type of query to create with the automatic query building methods. |
* @see DB_common::autoPrepare(), DB_common::autoExecute() |
*/ |
define('DB_AUTOQUERY_INSERT', 1); |
define('DB_AUTOQUERY_UPDATE', 2); |
/**#@-*/ |
// }}} |
// {{{ portability modes |
/**#@+ |
* Portability Modes. |
* |
* Bitwised constants, so they can be combined using <kbd>|</kbd> |
* and removed using <kbd>^</kbd>. |
* |
* @see DB_common::setOption() |
* |
* {@internal Since the PORTABILITY constants are bitwised, if more of them are |
* added in the future, make sure to adjust DB_PORTABILITY_ALL accordingly.}} |
*/ |
/** |
* Turn off all portability features |
*/ |
define('DB_PORTABILITY_NONE', 0); |
/** |
* Convert names of tables and fields to lower case |
* when using the get*(), fetch*() and tableInfo() methods |
*/ |
define('DB_PORTABILITY_LOWERCASE', 1); |
/** |
* Right trim the data output by get*() and fetch*() |
*/ |
define('DB_PORTABILITY_RTRIM', 2); |
/** |
* Force reporting the number of rows deleted |
*/ |
define('DB_PORTABILITY_DELETE_COUNT', 4); |
/** |
* Enable hack that makes numRows() work in Oracle |
*/ |
define('DB_PORTABILITY_NUMROWS', 8); |
/** |
* Makes certain error messages in certain drivers compatible |
* with those from other DBMS's |
* |
* + mysql, mysqli: change unique/primary key constraints |
* DB_ERROR_ALREADY_EXISTS -> DB_ERROR_CONSTRAINT |
* |
* + odbc(access): MS's ODBC driver reports 'no such field' as code |
* 07001, which means 'too few parameters.' When this option is on |
* that code gets mapped to DB_ERROR_NOSUCHFIELD. |
*/ |
define('DB_PORTABILITY_ERRORS', 16); |
/** |
* Convert null values to empty strings in data output by |
* get*() and fetch*() |
*/ |
define('DB_PORTABILITY_NULL_TO_EMPTY', 32); |
/** |
* Turn on all portability features |
*/ |
define('DB_PORTABILITY_ALL', 63); |
/**#@-*/ |
// }}} |
// }}} |
// {{{ class DB |
/** |
* Database independent query interface |
* |
* The main "DB" class is simply a container class with some static |
* methods for creating DB objects as well as some utility functions |
* common to all parts of DB. |
* |
* The object model of DB is as follows (indentation means inheritance): |
* <pre> |
* DB The main DB class. This is simply a utility class |
* with some "static" methods for creating DB objects as |
* well as common utility functions for other DB classes. |
* |
* DB_common The base for each DB implementation. Provides default |
* | implementations (in OO lingo virtual methods) for |
* | the actual DB implementations as well as a bunch of |
* | query utility functions. |
* | |
* +-DB_mysql The DB implementation for MySQL. Inherits DB_common. |
* When calling DB::factory or DB::connect for MySQL |
* connections, the object returned is an instance of this |
* class. |
* </pre> |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V.Cox <cox@idecnet.com> |
* @author Daniel Convissor <danielc@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB |
{ |
// {{{ &factory() |
/** |
* Create a new DB object for the specified database type but don't |
* connect to the database |
* |
* @param string $type the database type (eg "mysql") |
* @param array $options an associative array of option names and values |
* |
* @return object a new DB object. A DB_Error object on failure. |
* |
* @see DB_common::setOption() |
*/ |
function &factory($type, $options = false) |
{ |
if (!is_array($options)) { |
$options = array('persistent' => $options); |
} |
if (isset($options['debug']) && $options['debug'] >= 2) { |
// expose php errors with sufficient debug level |
include_once "DB/{$type}.php"; |
} else { |
@include_once "DB/{$type}.php"; |
} |
$classname = "DB_${type}"; |
if (!class_exists($classname)) { |
$tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null, |
"Unable to include the DB/{$type}.php" |
. " file for '$dsn'", |
'DB_Error', true); |
return $tmp; |
} |
@$obj = new $classname; |
foreach ($options as $option => $value) { |
$test = $obj->setOption($option, $value); |
if (DB::isError($test)) { |
return $test; |
} |
} |
return $obj; |
} |
// }}} |
// {{{ &connect() |
/** |
* Create a new DB object including a connection to the specified database |
* |
* Example 1. |
* <code> |
* require_once 'DB.php'; |
* |
* $dsn = 'pgsql://user:password@host/database'; |
* $options = array( |
* 'debug' => 2, |
* 'portability' => DB_PORTABILITY_ALL, |
* ); |
* |
* $db =& DB::connect($dsn, $options); |
* if (PEAR::isError($db)) { |
* die($db->getMessage()); |
* } |
* </code> |
* |
* @param mixed $dsn the string "data source name" or array in the |
* format returned by DB::parseDSN() |
* @param array $options an associative array of option names and values |
* |
* @return object a new DB object. A DB_Error object on failure. |
* |
* @uses DB_dbase::connect(), DB_fbsql::connect(), DB_ibase::connect(), |
* DB_ifx::connect(), DB_msql::connect(), DB_mssql::connect(), |
* DB_mysql::connect(), DB_mysqli::connect(), DB_oci8::connect(), |
* DB_odbc::connect(), DB_pgsql::connect(), DB_sqlite::connect(), |
* DB_sybase::connect() |
* |
* @uses DB::parseDSN(), DB_common::setOption(), PEAR::isError() |
*/ |
function &connect($dsn, $options = array()) |
{ |
$dsninfo = DB::parseDSN($dsn); |
$type = $dsninfo['phptype']; |
if (!is_array($options)) { |
/* |
* For backwards compatibility. $options used to be boolean, |
* indicating whether the connection should be persistent. |
*/ |
$options = array('persistent' => $options); |
} |
if (isset($options['debug']) && $options['debug'] >= 2) { |
// expose php errors with sufficient debug level |
include_once "DB/${type}.php"; |
} else { |
@include_once "DB/${type}.php"; |
} |
$classname = "DB_${type}"; |
if (!class_exists($classname)) { |
$tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null, |
"Unable to include the DB/{$type}.php" |
. " file for '$dsn'", |
'DB_Error', true); |
return $tmp; |
} |
@$obj = new $classname; |
foreach ($options as $option => $value) { |
$test = $obj->setOption($option, $value); |
if (DB::isError($test)) { |
return $test; |
} |
} |
$err = $obj->connect($dsninfo, $obj->getOption('persistent')); |
if (DB::isError($err)) { |
if (is_array($dsn)) { |
$err->addUserInfo(DB::getDSNString($dsn, true)); |
} else { |
$err->addUserInfo($dsn); |
} |
return $err; |
} |
return $obj; |
} |
// }}} |
// {{{ apiVersion() |
/** |
* Return the DB API version |
* |
* @return string the DB API version number |
*/ |
function apiVersion() |
{ |
return '1.7.13'; |
} |
// }}} |
// {{{ isError() |
/** |
* Determines if a variable is a DB_Error object |
* |
* @param mixed $value the variable to check |
* |
* @return bool whether $value is DB_Error object |
*/ |
function isError($value) |
{ |
return is_a($value, 'DB_Error'); |
} |
// }}} |
// {{{ isConnection() |
/** |
* Determines if a value is a DB_<driver> object |
* |
* @param mixed $value the value to test |
* |
* @return bool whether $value is a DB_<driver> object |
*/ |
function isConnection($value) |
{ |
return (is_object($value) && |
is_subclass_of($value, 'db_common') && |
method_exists($value, 'simpleQuery')); |
} |
// }}} |
// {{{ isManip() |
/** |
* Tell whether a query is a data manipulation or data definition query |
* |
* Examples of data manipulation queries are INSERT, UPDATE and DELETE. |
* Examples of data definition queries are CREATE, DROP, ALTER, GRANT, |
* REVOKE. |
* |
* @param string $query the query |
* |
* @return boolean whether $query is a data manipulation query |
*/ |
function isManip($query) |
{ |
$manips = 'INSERT|UPDATE|DELETE|REPLACE|' |
. 'CREATE|DROP|' |
. 'LOAD DATA|SELECT .* INTO .* FROM|COPY|' |
. 'ALTER|GRANT|REVOKE|' |
. 'LOCK|UNLOCK'; |
if (preg_match('/^\s*"?(' . $manips . ')\s+/i', $query)) { |
return true; |
} |
return false; |
} |
// }}} |
// {{{ errorMessage() |
/** |
* Return a textual error message for a DB error code |
* |
* @param integer $value the DB error code |
* |
* @return string the error message or false if the error code was |
* not recognized |
*/ |
function errorMessage($value) |
{ |
static $errorMessages; |
if (!isset($errorMessages)) { |
$errorMessages = array( |
DB_ERROR => 'unknown error', |
DB_ERROR_ACCESS_VIOLATION => 'insufficient permissions', |
DB_ERROR_ALREADY_EXISTS => 'already exists', |
DB_ERROR_CANNOT_CREATE => 'can not create', |
DB_ERROR_CANNOT_DROP => 'can not drop', |
DB_ERROR_CONNECT_FAILED => 'connect failed', |
DB_ERROR_CONSTRAINT => 'constraint violation', |
DB_ERROR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint', |
DB_ERROR_DIVZERO => 'division by zero', |
DB_ERROR_EXTENSION_NOT_FOUND=> 'extension not found', |
DB_ERROR_INVALID => 'invalid', |
DB_ERROR_INVALID_DATE => 'invalid date or time', |
DB_ERROR_INVALID_DSN => 'invalid DSN', |
DB_ERROR_INVALID_NUMBER => 'invalid number', |
DB_ERROR_MISMATCH => 'mismatch', |
DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied', |
DB_ERROR_NODBSELECTED => 'no database selected', |
DB_ERROR_NOSUCHDB => 'no such database', |
DB_ERROR_NOSUCHFIELD => 'no such field', |
DB_ERROR_NOSUCHTABLE => 'no such table', |
DB_ERROR_NOT_CAPABLE => 'DB backend not capable', |
DB_ERROR_NOT_FOUND => 'not found', |
DB_ERROR_NOT_LOCKED => 'not locked', |
DB_ERROR_SYNTAX => 'syntax error', |
DB_ERROR_UNSUPPORTED => 'not supported', |
DB_ERROR_TRUNCATED => 'truncated', |
DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row', |
DB_OK => 'no error', |
); |
} |
if (DB::isError($value)) { |
$value = $value->getCode(); |
} |
return isset($errorMessages[$value]) ? $errorMessages[$value] |
: $errorMessages[DB_ERROR]; |
} |
// }}} |
// {{{ parseDSN() |
/** |
* Parse a data source name |
* |
* Additional keys can be added by appending a URI query string to the |
* end of the DSN. |
* |
* The format of the supplied DSN is in its fullest form: |
* <code> |
* phptype(dbsyntax)://username:password@protocol+hostspec/database?option=8&another=true |
* </code> |
* |
* Most variations are allowed: |
* <code> |
* phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644 |
* phptype://username:password@hostspec/database_name |
* phptype://username:password@hostspec |
* phptype://username@hostspec |
* phptype://hostspec/database |
* phptype://hostspec |
* phptype(dbsyntax) |
* phptype |
* </code> |
* |
* @param string $dsn Data Source Name to be parsed |
* |
* @return array an associative array with the following keys: |
* + phptype: Database backend used in PHP (mysql, odbc etc.) |
* + dbsyntax: Database used with regards to SQL syntax etc. |
* + protocol: Communication protocol to use (tcp, unix etc.) |
* + hostspec: Host specification (hostname[:port]) |
* + database: Database to use on the DBMS server |
* + username: User name for login |
* + password: Password for login |
*/ |
function parseDSN($dsn) |
{ |
$parsed = array( |
'phptype' => false, |
'dbsyntax' => false, |
'username' => false, |
'password' => false, |
'protocol' => false, |
'hostspec' => false, |
'port' => false, |
'socket' => false, |
'database' => false, |
); |
if (is_array($dsn)) { |
$dsn = array_merge($parsed, $dsn); |
if (!$dsn['dbsyntax']) { |
$dsn['dbsyntax'] = $dsn['phptype']; |
} |
return $dsn; |
} |
// Find phptype and dbsyntax |
if (($pos = strpos($dsn, '://')) !== false) { |
$str = substr($dsn, 0, $pos); |
$dsn = substr($dsn, $pos + 3); |
} else { |
$str = $dsn; |
$dsn = null; |
} |
// Get phptype and dbsyntax |
// $str => phptype(dbsyntax) |
if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
$parsed['phptype'] = $arr[1]; |
$parsed['dbsyntax'] = !$arr[2] ? $arr[1] : $arr[2]; |
} else { |
$parsed['phptype'] = $str; |
$parsed['dbsyntax'] = $str; |
} |
if (!count($dsn)) { |
return $parsed; |
} |
// Get (if found): username and password |
// $dsn => username:password@protocol+hostspec/database |
if (($at = strrpos($dsn,'@')) !== false) { |
$str = substr($dsn, 0, $at); |
$dsn = substr($dsn, $at + 1); |
if (($pos = strpos($str, ':')) !== false) { |
$parsed['username'] = rawurldecode(substr($str, 0, $pos)); |
$parsed['password'] = rawurldecode(substr($str, $pos + 1)); |
} else { |
$parsed['username'] = rawurldecode($str); |
} |
} |
// Find protocol and hostspec |
if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
// $dsn => proto(proto_opts)/database |
$proto = $match[1]; |
$proto_opts = $match[2] ? $match[2] : false; |
$dsn = $match[3]; |
} else { |
// $dsn => protocol+hostspec/database (old format) |
if (strpos($dsn, '+') !== false) { |
list($proto, $dsn) = explode('+', $dsn, 2); |
} |
if (strpos($dsn, '/') !== false) { |
list($proto_opts, $dsn) = explode('/', $dsn, 2); |
} else { |
$proto_opts = $dsn; |
$dsn = null; |
} |
} |
// process the different protocol options |
$parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
$proto_opts = rawurldecode($proto_opts); |
if (strpos($proto_opts, ':') !== false) { |
list($proto_opts, $parsed['port']) = explode(':', $proto_opts); |
} |
if ($parsed['protocol'] == 'tcp') { |
$parsed['hostspec'] = $proto_opts; |
} elseif ($parsed['protocol'] == 'unix') { |
$parsed['socket'] = $proto_opts; |
} |
// Get dabase if any |
// $dsn => database |
if ($dsn) { |
if (($pos = strpos($dsn, '?')) === false) { |
// /database |
$parsed['database'] = rawurldecode($dsn); |
} else { |
// /database?param1=value1¶m2=value2 |
$parsed['database'] = rawurldecode(substr($dsn, 0, $pos)); |
$dsn = substr($dsn, $pos + 1); |
if (strpos($dsn, '&') !== false) { |
$opts = explode('&', $dsn); |
} else { // database?param1=value1 |
$opts = array($dsn); |
} |
foreach ($opts as $opt) { |
list($key, $value) = explode('=', $opt); |
if (!isset($parsed[$key])) { |
// don't allow params overwrite |
$parsed[$key] = rawurldecode($value); |
} |
} |
} |
} |
return $parsed; |
} |
// }}} |
// {{{ getDSNString() |
/** |
* Returns the given DSN in a string format suitable for output. |
* |
* @param array|string the DSN to parse and format |
* @param boolean true to hide the password, false to include it |
* @return string |
*/ |
function getDSNString($dsn, $hidePassword) { |
/* Calling parseDSN will ensure that we have all the array elements |
* defined, and means that we deal with strings and array in the same |
* manner. */ |
$dsnArray = DB::parseDSN($dsn); |
if ($hidePassword) { |
$dsnArray['password'] = 'PASSWORD'; |
} |
/* Protocol is special-cased, as using the default "tcp" along with an |
* Oracle TNS connection string fails. */ |
if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') { |
$dsnArray['protocol'] = false; |
} |
// Now we just have to construct the actual string. This is ugly. |
$dsnString = $dsnArray['phptype']; |
if ($dsnArray['dbsyntax']) { |
$dsnString .= '('.$dsnArray['dbsyntax'].')'; |
} |
$dsnString .= '://' |
.$dsnArray['username'] |
.':' |
.$dsnArray['password'] |
.'@' |
.$dsnArray['protocol']; |
if ($dsnArray['socket']) { |
$dsnString .= '('.$dsnArray['socket'].')'; |
} |
if ($dsnArray['protocol'] && $dsnArray['hostspec']) { |
$dsnString .= '+'; |
} |
$dsnString .= $dsnArray['hostspec']; |
if ($dsnArray['port']) { |
$dsnString .= ':'.$dsnArray['port']; |
} |
$dsnString .= '/'.$dsnArray['database']; |
/* Option handling. Unfortunately, parseDSN simply places options into |
* the top-level array, so we'll first get rid of the fields defined by |
* DB and see what's left. */ |
unset($dsnArray['phptype'], |
$dsnArray['dbsyntax'], |
$dsnArray['username'], |
$dsnArray['password'], |
$dsnArray['protocol'], |
$dsnArray['socket'], |
$dsnArray['hostspec'], |
$dsnArray['port'], |
$dsnArray['database'] |
); |
if (count($dsnArray) > 0) { |
$dsnString .= '?'; |
$i = 0; |
foreach ($dsnArray as $key => $value) { |
if (++$i > 1) { |
$dsnString .= '&'; |
} |
$dsnString .= $key.'='.$value; |
} |
} |
return $dsnString; |
} |
// }}} |
} |
// }}} |
// {{{ class DB_Error |
/** |
* DB_Error implements a class for reporting portable database error |
* messages |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB_Error extends PEAR_Error |
{ |
// {{{ constructor |
/** |
* DB_Error constructor |
* |
* @param mixed $code DB error code, or string with error message |
* @param int $mode what "error mode" to operate in |
* @param int $level what error level to use for $mode & |
* PEAR_ERROR_TRIGGER |
* @param mixed $debuginfo additional debug info, such as the last query |
* |
* @see PEAR_Error |
*/ |
function DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN, |
$level = E_USER_NOTICE, $debuginfo = null) |
{ |
if (is_int($code)) { |
$this->PEAR_Error('DB Error: ' . DB::errorMessage($code), $code, |
$mode, $level, $debuginfo); |
} else { |
$this->PEAR_Error("DB Error: $code", DB_ERROR, |
$mode, $level, $debuginfo); |
} |
} |
// }}} |
} |
// }}} |
// {{{ class DB_result |
/** |
* This class implements a wrapper for a DB result set |
* |
* A new instance of this class will be returned by the DB implementation |
* after processing a query that returns data. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
*/ |
class DB_result |
{ |
// {{{ properties |
/** |
* Should results be freed automatically when there are no more rows? |
* @var boolean |
* @see DB_common::$options |
*/ |
var $autofree; |
/** |
* A reference to the DB_<driver> object |
* @var object |
*/ |
var $dbh; |
/** |
* The current default fetch mode |
* @var integer |
* @see DB_common::$fetchmode |
*/ |
var $fetchmode; |
/** |
* The name of the class into which results should be fetched when |
* DB_FETCHMODE_OBJECT is in effect |
* |
* @var string |
* @see DB_common::$fetchmode_object_class |
*/ |
var $fetchmode_object_class; |
/** |
* The number of rows to fetch from a limit query |
* @var integer |
*/ |
var $limit_count = null; |
/** |
* The row to start fetching from in limit queries |
* @var integer |
*/ |
var $limit_from = null; |
/** |
* The execute parameters that created this result |
* @var array |
* @since Property available since Release 1.7.0 |
*/ |
var $parameters; |
/** |
* The query string that created this result |
* |
* Copied here incase it changes in $dbh, which is referenced |
* |
* @var string |
* @since Property available since Release 1.7.0 |
*/ |
var $query; |
/** |
* The query result resource id created by PHP |
* @var resource |
*/ |
var $result; |
/** |
* The present row being dealt with |
* @var integer |
*/ |
var $row_counter = null; |
/** |
* The prepared statement resource id created by PHP in $dbh |
* |
* This resource is only available when the result set was created using |
* a driver's native execute() method, not PEAR DB's emulated one. |
* |
* Copied here incase it changes in $dbh, which is referenced |
* |
* {@internal Mainly here because the InterBase/Firebird API is only |
* able to retrieve data from result sets if the statemnt handle is |
* still in scope.}} |
* |
* @var resource |
* @since Property available since Release 1.7.0 |
*/ |
var $statement; |
// }}} |
// {{{ constructor |
/** |
* This constructor sets the object's properties |
* |
* @param object &$dbh the DB object reference |
* @param resource $result the result resource id |
* @param array $options an associative array with result options |
* |
* @return void |
*/ |
function DB_result(&$dbh, $result, $options = array()) |
{ |
$this->autofree = $dbh->options['autofree']; |
$this->dbh = &$dbh; |
$this->fetchmode = $dbh->fetchmode; |
$this->fetchmode_object_class = $dbh->fetchmode_object_class; |
$this->parameters = $dbh->last_parameters; |
$this->query = $dbh->last_query; |
$this->result = $result; |
$this->statement = empty($dbh->last_stmt) ? null : $dbh->last_stmt; |
foreach ($options as $key => $value) { |
$this->setOption($key, $value); |
} |
} |
/** |
* Set options for the DB_result object |
* |
* @param string $key the option to set |
* @param mixed $value the value to set the option to |
* |
* @return void |
*/ |
function setOption($key, $value = null) |
{ |
switch ($key) { |
case 'limit_from': |
$this->limit_from = $value; |
break; |
case 'limit_count': |
$this->limit_count = $value; |
} |
} |
// }}} |
// {{{ fetchRow() |
/** |
* Fetch a row of data and return it by reference into an array |
* |
* The type of array returned can be controlled either by setting this |
* method's <var>$fetchmode</var> parameter or by changing the default |
* fetch mode setFetchMode() before calling this method. |
* |
* There are two options for standardizing the information returned |
* from databases, ensuring their values are consistent when changing |
* DBMS's. These portability options can be turned on when creating a |
* new DB object or by using setOption(). |
* |
* + <var>DB_PORTABILITY_LOWERCASE</var> |
* convert names of fields to lower case |
* |
* + <var>DB_PORTABILITY_RTRIM</var> |
* right trim the data |
* |
* @param int $fetchmode the constant indicating how to format the data |
* @param int $rownum the row number to fetch (index starts at 0) |
* |
* @return mixed an array or object containing the row's data, |
* NULL when the end of the result set is reached |
* or a DB_Error object on failure. |
* |
* @see DB_common::setOption(), DB_common::setFetchMode() |
*/ |
function &fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) |
{ |
if ($fetchmode === DB_FETCHMODE_DEFAULT) { |
$fetchmode = $this->fetchmode; |
} |
if ($fetchmode === DB_FETCHMODE_OBJECT) { |
$fetchmode = DB_FETCHMODE_ASSOC; |
$object_class = $this->fetchmode_object_class; |
} |
if (is_null($rownum) && $this->limit_from !== null) { |
if ($this->row_counter === null) { |
$this->row_counter = $this->limit_from; |
// Skip rows |
if ($this->dbh->features['limit'] === false) { |
$i = 0; |
while ($i++ < $this->limit_from) { |
$this->dbh->fetchInto($this->result, $arr, $fetchmode); |
} |
} |
} |
if ($this->row_counter >= ($this->limit_from + $this->limit_count)) |
{ |
if ($this->autofree) { |
$this->free(); |
} |
$tmp = null; |
return $tmp; |
} |
if ($this->dbh->features['limit'] === 'emulate') { |
$rownum = $this->row_counter; |
} |
$this->row_counter++; |
} |
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); |
if ($res === DB_OK) { |
if (isset($object_class)) { |
// The default mode is specified in the |
// DB_common::fetchmode_object_class property |
if ($object_class == 'stdClass') { |
$arr = (object) $arr; |
} else { |
$arr = new $object_class($arr); |
} |
} |
return $arr; |
} |
if ($res == null && $this->autofree) { |
$this->free(); |
} |
return $res; |
} |
// }}} |
// {{{ fetchInto() |
/** |
* Fetch a row of data into an array which is passed by reference |
* |
* The type of array returned can be controlled either by setting this |
* method's <var>$fetchmode</var> parameter or by changing the default |
* fetch mode setFetchMode() before calling this method. |
* |
* There are two options for standardizing the information returned |
* from databases, ensuring their values are consistent when changing |
* DBMS's. These portability options can be turned on when creating a |
* new DB object or by using setOption(). |
* |
* + <var>DB_PORTABILITY_LOWERCASE</var> |
* convert names of fields to lower case |
* |
* + <var>DB_PORTABILITY_RTRIM</var> |
* right trim the data |
* |
* @param array &$arr the variable where the data should be placed |
* @param int $fetchmode the constant indicating how to format the data |
* @param int $rownum the row number to fetch (index starts at 0) |
* |
* @return mixed DB_OK if a row is processed, NULL when the end of the |
* result set is reached or a DB_Error object on failure |
* |
* @see DB_common::setOption(), DB_common::setFetchMode() |
*/ |
function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = null) |
{ |
if ($fetchmode === DB_FETCHMODE_DEFAULT) { |
$fetchmode = $this->fetchmode; |
} |
if ($fetchmode === DB_FETCHMODE_OBJECT) { |
$fetchmode = DB_FETCHMODE_ASSOC; |
$object_class = $this->fetchmode_object_class; |
} |
if (is_null($rownum) && $this->limit_from !== null) { |
if ($this->row_counter === null) { |
$this->row_counter = $this->limit_from; |
// Skip rows |
if ($this->dbh->features['limit'] === false) { |
$i = 0; |
while ($i++ < $this->limit_from) { |
$this->dbh->fetchInto($this->result, $arr, $fetchmode); |
} |
} |
} |
if ($this->row_counter >= ( |
$this->limit_from + $this->limit_count)) |
{ |
if ($this->autofree) { |
$this->free(); |
} |
return null; |
} |
if ($this->dbh->features['limit'] === 'emulate') { |
$rownum = $this->row_counter; |
} |
$this->row_counter++; |
} |
$res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); |
if ($res === DB_OK) { |
if (isset($object_class)) { |
// default mode specified in the |
// DB_common::fetchmode_object_class property |
if ($object_class == 'stdClass') { |
$arr = (object) $arr; |
} else { |
$arr = new $object_class($arr); |
} |
} |
return DB_OK; |
} |
if ($res == null && $this->autofree) { |
$this->free(); |
} |
return $res; |
} |
// }}} |
// {{{ numCols() |
/** |
* Get the the number of columns in a result set |
* |
* @return int the number of columns. A DB_Error object on failure. |
*/ |
function numCols() |
{ |
return $this->dbh->numCols($this->result); |
} |
// }}} |
// {{{ numRows() |
/** |
* Get the number of rows in a result set |
* |
* @return int the number of rows. A DB_Error object on failure. |
*/ |
function numRows() |
{ |
if ($this->dbh->features['numrows'] === 'emulate' |
&& $this->dbh->options['portability'] & DB_PORTABILITY_NUMROWS) |
{ |
if ($this->dbh->features['prepare']) { |
$res = $this->dbh->query($this->query, $this->parameters); |
} else { |
$res = $this->dbh->query($this->query); |
} |
if (DB::isError($res)) { |
return $res; |
} |
$i = 0; |
while ($res->fetchInto($tmp, DB_FETCHMODE_ORDERED)) { |
$i++; |
} |
$count = $i; |
} else { |
$count = $this->dbh->numRows($this->result); |
} |
/* fbsql is checked for here because limit queries are implemented |
* using a TOP() function, which results in fbsql_num_rows still |
* returning the total number of rows that would have been returned, |
* rather than the real number. As a result, we'll just do the limit |
* calculations for fbsql in the same way as a database with emulated |
* limits. Unfortunately, we can't just do this in DB_fbsql::numRows() |
* because that only gets the result resource, rather than the full |
* DB_Result object. */ |
if (($this->dbh->features['limit'] === 'emulate' |
&& $this->limit_from !== null) |
|| $this->dbh->phptype == 'fbsql') { |
$limit_count = is_null($this->limit_count) ? $count : $this->limit_count; |
if ($count < $this->limit_from) { |
$count = 0; |
} elseif ($count < ($this->limit_from + $limit_count)) { |
$count -= $this->limit_from; |
} else { |
$count = $limit_count; |
} |
} |
return $count; |
} |
// }}} |
// {{{ nextResult() |
/** |
* Get the next result if a batch of queries was executed |
* |
* @return bool true if a new result is available or false if not |
*/ |
function nextResult() |
{ |
return $this->dbh->nextResult($this->result); |
} |
// }}} |
// {{{ free() |
/** |
* Frees the resources allocated for this result set |
* |
* @return bool true on success. A DB_Error object on failure. |
*/ |
function free() |
{ |
$err = $this->dbh->freeResult($this->result); |
if (DB::isError($err)) { |
return $err; |
} |
$this->result = false; |
$this->statement = false; |
return true; |
} |
// }}} |
// {{{ tableInfo() |
/** |
* @see DB_common::tableInfo() |
* @deprecated Method deprecated some time before Release 1.2 |
*/ |
function tableInfo($mode = null) |
{ |
if (is_string($mode)) { |
return $this->dbh->raiseError(DB_ERROR_NEED_MORE_DATA); |
} |
return $this->dbh->tableInfo($this, $mode); |
} |
// }}} |
// {{{ getQuery() |
/** |
* Determine the query string that created this result |
* |
* @return string the query string |
* |
* @since Method available since Release 1.7.0 |
*/ |
function getQuery() |
{ |
return $this->query; |
} |
// }}} |
// {{{ getRowCounter() |
/** |
* Tells which row number is currently being processed |
* |
* @return integer the current row being looked at. Starts at 1. |
*/ |
function getRowCounter() |
{ |
return $this->row_counter; |
} |
// }}} |
} |
// }}} |
// {{{ class DB_row |
/** |
* PEAR DB Row Object |
* |
* The object contains a row of data from a result set. Each column's data |
* is placed in a property named for the column. |
* |
* @category Database |
* @package DB |
* @author Stig Bakken <ssb@php.net> |
* @copyright 1997-2007 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.13 |
* @link http://pear.php.net/package/DB |
* @see DB_common::setFetchMode() |
*/ |
class DB_row |
{ |
// {{{ constructor |
/** |
* The constructor places a row's data into properties of this object |
* |
* @param array the array containing the row's data |
* |
* @return void |
*/ |
function DB_row(&$arr) |
{ |
foreach ($arr as $key => $value) { |
$this->$key = &$arr[$key]; |
} |
} |
// }}} |
} |
// }}} |
/* |
* Local variables: |
* tab-width: 4 |
* c-basic-offset: 4 |
* End: |
*/ |
?> |
/branches/ant-ng/lib/config.php |
---|
12,7 → 12,11 |
* |
*/ |
require_once dirname(__FILE__)."/config.php"; |
# Define options for MySQL connection |
define('DBNAME', "generator"); // Database name |
define('DBUSER', "sqluser"); // Database user |
define('DBPASS', "sqlpass"); // Password |
define('DBHOST', "localhost"); // Database host |
define('PREFIX', "g_"); // Database tables prefix |
?> |
/branches/ant-ng/lib/PEAR.php |
---|
Новый файл |
0,0 → 1,1118 |
<?php |
/** |
* PEAR, the PHP Extension and Application Repository |
* |
* PEAR class and PEAR_Error class |
* |
* PHP versions 4 and 5 |
* |
* LICENSE: This source file is subject to version 3.0 of the PHP license |
* that is available through the world-wide-web at the following URI: |
* http://www.php.net/license/3_0.txt. If you did not receive a copy of |
* the PHP License and are unable to obtain it through the web, please |
* send a note to license@php.net so we can mail you a copy immediately. |
* |
* @category pear |
* @package PEAR |
* @author Sterling Hughes <sterling@php.net> |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V.Cox <cox@idecnet.com> |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2008 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version CVS: $Id: PEAR.php,v 1.104 2008/01/03 20:26:34 cellog Exp $ |
* @link http://pear.php.net/package/PEAR |
* @since File available since Release 0.1 |
*/ |
/**#@+ |
* ERROR constants |
*/ |
define('PEAR_ERROR_RETURN', 1); |
define('PEAR_ERROR_PRINT', 2); |
define('PEAR_ERROR_TRIGGER', 4); |
define('PEAR_ERROR_DIE', 8); |
define('PEAR_ERROR_CALLBACK', 16); |
/** |
* WARNING: obsolete |
* @deprecated |
*/ |
define('PEAR_ERROR_EXCEPTION', 32); |
/**#@-*/ |
define('PEAR_ZE2', (function_exists('version_compare') && |
version_compare(zend_version(), "2-dev", "ge"))); |
if (substr(PHP_OS, 0, 3) == 'WIN') { |
define('OS_WINDOWS', true); |
define('OS_UNIX', false); |
define('PEAR_OS', 'Windows'); |
} else { |
define('OS_WINDOWS', false); |
define('OS_UNIX', true); |
define('PEAR_OS', 'Unix'); // blatant assumption |
} |
// instant backwards compatibility |
if (!defined('PATH_SEPARATOR')) { |
if (OS_WINDOWS) { |
define('PATH_SEPARATOR', ';'); |
} else { |
define('PATH_SEPARATOR', ':'); |
} |
} |
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; |
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; |
$GLOBALS['_PEAR_destructor_object_list'] = array(); |
$GLOBALS['_PEAR_shutdown_funcs'] = array(); |
$GLOBALS['_PEAR_error_handler_stack'] = array(); |
@ini_set('track_errors', true); |
/** |
* Base class for other PEAR classes. Provides rudimentary |
* emulation of destructors. |
* |
* If you want a destructor in your class, inherit PEAR and make a |
* destructor method called _yourclassname (same name as the |
* constructor, but with a "_" prefix). Also, in your constructor you |
* have to call the PEAR constructor: $this->PEAR();. |
* The destructor method will be called without parameters. Note that |
* at in some SAPI implementations (such as Apache), any output during |
* the request shutdown (in which destructors are called) seems to be |
* discarded. If you need to get any debug information from your |
* destructor, use error_log(), syslog() or something similar. |
* |
* IMPORTANT! To use the emulated destructors you need to create the |
* objects by reference: $obj =& new PEAR_child; |
* |
* @category pear |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V. Cox <cox@idecnet.com> |
* @author Greg Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.2 |
* @link http://pear.php.net/package/PEAR |
* @see PEAR_Error |
* @since Class available since PHP 4.0.2 |
* @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear |
*/ |
class PEAR |
{ |
// {{{ properties |
/** |
* Whether to enable internal debug messages. |
* |
* @var bool |
* @access private |
*/ |
var $_debug = false; |
/** |
* Default error mode for this object. |
* |
* @var int |
* @access private |
*/ |
var $_default_error_mode = null; |
/** |
* Default error options used for this object when error mode |
* is PEAR_ERROR_TRIGGER. |
* |
* @var int |
* @access private |
*/ |
var $_default_error_options = null; |
/** |
* Default error handler (callback) for this object, if error mode is |
* PEAR_ERROR_CALLBACK. |
* |
* @var string |
* @access private |
*/ |
var $_default_error_handler = ''; |
/** |
* Which class to use for error objects. |
* |
* @var string |
* @access private |
*/ |
var $_error_class = 'PEAR_Error'; |
/** |
* An array of expected errors. |
* |
* @var array |
* @access private |
*/ |
var $_expected_errors = array(); |
// }}} |
// {{{ constructor |
/** |
* Constructor. Registers this object in |
* $_PEAR_destructor_object_list for destructor emulation if a |
* destructor object exists. |
* |
* @param string $error_class (optional) which class to use for |
* error objects, defaults to PEAR_Error. |
* @access public |
* @return void |
*/ |
function PEAR($error_class = null) |
{ |
$classname = strtolower(get_class($this)); |
if ($this->_debug) { |
print "PEAR constructor called, class=$classname\n"; |
} |
if ($error_class !== null) { |
$this->_error_class = $error_class; |
} |
while ($classname && strcasecmp($classname, "pear")) { |
$destructor = "_$classname"; |
if (method_exists($this, $destructor)) { |
global $_PEAR_destructor_object_list; |
$_PEAR_destructor_object_list[] = &$this; |
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { |
register_shutdown_function("_PEAR_call_destructors"); |
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; |
} |
break; |
} else { |
$classname = get_parent_class($classname); |
} |
} |
} |
// }}} |
// {{{ destructor |
/** |
* Destructor (the emulated type of...). Does nothing right now, |
* but is included for forward compatibility, so subclass |
* destructors should always call it. |
* |
* See the note in the class desciption about output from |
* destructors. |
* |
* @access public |
* @return void |
*/ |
function _PEAR() { |
if ($this->_debug) { |
printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); |
} |
} |
// }}} |
// {{{ getStaticProperty() |
/** |
* If you have a class that's mostly/entirely static, and you need static |
* properties, you can use this method to simulate them. Eg. in your method(s) |
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); |
* You MUST use a reference, or they will not persist! |
* |
* @access public |
* @param string $class The calling classname, to prevent clashes |
* @param string $var The variable to retrieve. |
* @return mixed A reference to the variable. If not set it will be |
* auto initialised to NULL. |
*/ |
function &getStaticProperty($class, $var) |
{ |
static $properties; |
if (!isset($properties[$class])) { |
$properties[$class] = array(); |
} |
if (!array_key_exists($var, $properties[$class])) { |
$properties[$class][$var] = null; |
} |
return $properties[$class][$var]; |
} |
// }}} |
// {{{ registerShutdownFunc() |
/** |
* Use this function to register a shutdown method for static |
* classes. |
* |
* @access public |
* @param mixed $func The function name (or array of class/method) to call |
* @param mixed $args The arguments to pass to the function |
* @return void |
*/ |
function registerShutdownFunc($func, $args = array()) |
{ |
// if we are called statically, there is a potential |
// that no shutdown func is registered. Bug #6445 |
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { |
register_shutdown_function("_PEAR_call_destructors"); |
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; |
} |
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); |
} |
// }}} |
// {{{ isError() |
/** |
* Tell whether a value is a PEAR error. |
* |
* @param mixed $data the value to test |
* @param int $code if $data is an error object, return true |
* only if $code is a string and |
* $obj->getMessage() == $code or |
* $code is an integer and $obj->getCode() == $code |
* @access public |
* @return bool true if parameter is an error |
*/ |
function isError($data, $code = null) |
{ |
if (is_a($data, 'PEAR_Error')) { |
if (is_null($code)) { |
return true; |
} elseif (is_string($code)) { |
return $data->getMessage() == $code; |
} else { |
return $data->getCode() == $code; |
} |
} |
return false; |
} |
// }}} |
// {{{ setErrorHandling() |
/** |
* Sets how errors generated by this object should be handled. |
* Can be invoked both in objects and statically. If called |
* statically, setErrorHandling sets the default behaviour for all |
* PEAR objects. If called in an object, setErrorHandling sets |
* the default behaviour for that object. |
* |
* @param int $mode |
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, |
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, |
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. |
* |
* @param mixed $options |
* When $mode is PEAR_ERROR_TRIGGER, this is the error level (one |
* of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). |
* |
* When $mode is PEAR_ERROR_CALLBACK, this parameter is expected |
* to be the callback function or method. A callback |
* function is a string with the name of the function, a |
* callback method is an array of two elements: the element |
* at index 0 is the object, and the element at index 1 is |
* the name of the method to call in the object. |
* |
* When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is |
* a printf format string used when printing the error |
* message. |
* |
* @access public |
* @return void |
* @see PEAR_ERROR_RETURN |
* @see PEAR_ERROR_PRINT |
* @see PEAR_ERROR_TRIGGER |
* @see PEAR_ERROR_DIE |
* @see PEAR_ERROR_CALLBACK |
* @see PEAR_ERROR_EXCEPTION |
* |
* @since PHP 4.0.5 |
*/ |
function setErrorHandling($mode = null, $options = null) |
{ |
if (isset($this) && is_a($this, 'PEAR')) { |
$setmode = &$this->_default_error_mode; |
$setoptions = &$this->_default_error_options; |
} else { |
$setmode = &$GLOBALS['_PEAR_default_error_mode']; |
$setoptions = &$GLOBALS['_PEAR_default_error_options']; |
} |
switch ($mode) { |
case PEAR_ERROR_EXCEPTION: |
case PEAR_ERROR_RETURN: |
case PEAR_ERROR_PRINT: |
case PEAR_ERROR_TRIGGER: |
case PEAR_ERROR_DIE: |
case null: |
$setmode = $mode; |
$setoptions = $options; |
break; |
case PEAR_ERROR_CALLBACK: |
$setmode = $mode; |
// class/object method callback |
if (is_callable($options)) { |
$setoptions = $options; |
} else { |
trigger_error("invalid error callback", E_USER_WARNING); |
} |
break; |
default: |
trigger_error("invalid error mode", E_USER_WARNING); |
break; |
} |
} |
// }}} |
// {{{ expectError() |
/** |
* This method is used to tell which errors you expect to get. |
* Expected errors are always returned with error mode |
* PEAR_ERROR_RETURN. Expected error codes are stored in a stack, |
* and this method pushes a new element onto it. The list of |
* expected errors are in effect until they are popped off the |
* stack with the popExpect() method. |
* |
* Note that this method can not be called statically |
* |
* @param mixed $code a single error code or an array of error codes to expect |
* |
* @return int the new depth of the "expected errors" stack |
* @access public |
*/ |
function expectError($code = '*') |
{ |
if (is_array($code)) { |
array_push($this->_expected_errors, $code); |
} else { |
array_push($this->_expected_errors, array($code)); |
} |
return sizeof($this->_expected_errors); |
} |
// }}} |
// {{{ popExpect() |
/** |
* This method pops one element off the expected error codes |
* stack. |
* |
* @return array the list of error codes that were popped |
*/ |
function popExpect() |
{ |
return array_pop($this->_expected_errors); |
} |
// }}} |
// {{{ _checkDelExpect() |
/** |
* This method checks unsets an error code if available |
* |
* @param mixed error code |
* @return bool true if the error code was unset, false otherwise |
* @access private |
* @since PHP 4.3.0 |
*/ |
function _checkDelExpect($error_code) |
{ |
$deleted = false; |
foreach ($this->_expected_errors AS $key => $error_array) { |
if (in_array($error_code, $error_array)) { |
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); |
$deleted = true; |
} |
// clean up empty arrays |
if (0 == count($this->_expected_errors[$key])) { |
unset($this->_expected_errors[$key]); |
} |
} |
return $deleted; |
} |
// }}} |
// {{{ delExpect() |
/** |
* This method deletes all occurences of the specified element from |
* the expected error codes stack. |
* |
* @param mixed $error_code error code that should be deleted |
* @return mixed list of error codes that were deleted or error |
* @access public |
* @since PHP 4.3.0 |
*/ |
function delExpect($error_code) |
{ |
$deleted = false; |
if ((is_array($error_code) && (0 != count($error_code)))) { |
// $error_code is a non-empty array here; |
// we walk through it trying to unset all |
// values |
foreach($error_code as $key => $error) { |
if ($this->_checkDelExpect($error)) { |
$deleted = true; |
} else { |
$deleted = false; |
} |
} |
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME |
} elseif (!empty($error_code)) { |
// $error_code comes alone, trying to unset it |
if ($this->_checkDelExpect($error_code)) { |
return true; |
} else { |
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME |
} |
} else { |
// $error_code is empty |
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME |
} |
} |
// }}} |
// {{{ raiseError() |
/** |
* This method is a wrapper that returns an instance of the |
* configured error class with this object's default error |
* handling applied. If the $mode and $options parameters are not |
* specified, the object's defaults are used. |
* |
* @param mixed $message a text error message or a PEAR error object |
* |
* @param int $code a numeric error code (it is up to your class |
* to define these if you want to use codes) |
* |
* @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, |
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, |
* PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. |
* |
* @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter |
* specifies the PHP-internal error level (one of |
* E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). |
* If $mode is PEAR_ERROR_CALLBACK, this |
* parameter specifies the callback function or |
* method. In other error modes this parameter |
* is ignored. |
* |
* @param string $userinfo If you need to pass along for example debug |
* information, this parameter is meant for that. |
* |
* @param string $error_class The returned error object will be |
* instantiated from this class, if specified. |
* |
* @param bool $skipmsg If true, raiseError will only pass error codes, |
* the error message parameter will be dropped. |
* |
* @access public |
* @return object a PEAR error object |
* @see PEAR::setErrorHandling |
* @since PHP 4.0.5 |
*/ |
function &raiseError($message = null, |
$code = null, |
$mode = null, |
$options = null, |
$userinfo = null, |
$error_class = null, |
$skipmsg = false) |
{ |
// The error is yet a PEAR error object |
if (is_object($message)) { |
$code = $message->getCode(); |
$userinfo = $message->getUserInfo(); |
$error_class = $message->getType(); |
$message->error_message_prefix = ''; |
$message = $message->getMessage(); |
} |
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { |
if ($exp[0] == "*" || |
(is_int(reset($exp)) && in_array($code, $exp)) || |
(is_string(reset($exp)) && in_array($message, $exp))) { |
$mode = PEAR_ERROR_RETURN; |
} |
} |
// No mode given, try global ones |
if ($mode === null) { |
// Class error handler |
if (isset($this) && isset($this->_default_error_mode)) { |
$mode = $this->_default_error_mode; |
$options = $this->_default_error_options; |
// Global error handler |
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { |
$mode = $GLOBALS['_PEAR_default_error_mode']; |
$options = $GLOBALS['_PEAR_default_error_options']; |
} |
} |
if ($error_class !== null) { |
$ec = $error_class; |
} elseif (isset($this) && isset($this->_error_class)) { |
$ec = $this->_error_class; |
} else { |
$ec = 'PEAR_Error'; |
} |
if (intval(PHP_VERSION) < 5) { |
// little non-eval hack to fix bug #12147 |
include 'PEAR/FixPHP5PEARWarnings.php'; |
return $a; |
} |
if ($skipmsg) { |
$a = new $ec($code, $mode, $options, $userinfo); |
} else { |
$a = new $ec($message, $code, $mode, $options, $userinfo); |
} |
return $a; |
} |
// }}} |
// {{{ throwError() |
/** |
* Simpler form of raiseError with fewer options. In most cases |
* message, code and userinfo are enough. |
* |
* @param string $message |
* |
*/ |
function &throwError($message = null, |
$code = null, |
$userinfo = null) |
{ |
if (isset($this) && is_a($this, 'PEAR')) { |
$a = &$this->raiseError($message, $code, null, null, $userinfo); |
return $a; |
} else { |
$a = &PEAR::raiseError($message, $code, null, null, $userinfo); |
return $a; |
} |
} |
// }}} |
function staticPushErrorHandling($mode, $options = null) |
{ |
$stack = &$GLOBALS['_PEAR_error_handler_stack']; |
$def_mode = &$GLOBALS['_PEAR_default_error_mode']; |
$def_options = &$GLOBALS['_PEAR_default_error_options']; |
$stack[] = array($def_mode, $def_options); |
switch ($mode) { |
case PEAR_ERROR_EXCEPTION: |
case PEAR_ERROR_RETURN: |
case PEAR_ERROR_PRINT: |
case PEAR_ERROR_TRIGGER: |
case PEAR_ERROR_DIE: |
case null: |
$def_mode = $mode; |
$def_options = $options; |
break; |
case PEAR_ERROR_CALLBACK: |
$def_mode = $mode; |
// class/object method callback |
if (is_callable($options)) { |
$def_options = $options; |
} else { |
trigger_error("invalid error callback", E_USER_WARNING); |
} |
break; |
default: |
trigger_error("invalid error mode", E_USER_WARNING); |
break; |
} |
$stack[] = array($mode, $options); |
return true; |
} |
function staticPopErrorHandling() |
{ |
$stack = &$GLOBALS['_PEAR_error_handler_stack']; |
$setmode = &$GLOBALS['_PEAR_default_error_mode']; |
$setoptions = &$GLOBALS['_PEAR_default_error_options']; |
array_pop($stack); |
list($mode, $options) = $stack[sizeof($stack) - 1]; |
array_pop($stack); |
switch ($mode) { |
case PEAR_ERROR_EXCEPTION: |
case PEAR_ERROR_RETURN: |
case PEAR_ERROR_PRINT: |
case PEAR_ERROR_TRIGGER: |
case PEAR_ERROR_DIE: |
case null: |
$setmode = $mode; |
$setoptions = $options; |
break; |
case PEAR_ERROR_CALLBACK: |
$setmode = $mode; |
// class/object method callback |
if (is_callable($options)) { |
$setoptions = $options; |
} else { |
trigger_error("invalid error callback", E_USER_WARNING); |
} |
break; |
default: |
trigger_error("invalid error mode", E_USER_WARNING); |
break; |
} |
return true; |
} |
// {{{ pushErrorHandling() |
/** |
* Push a new error handler on top of the error handler options stack. With this |
* you can easily override the actual error handler for some code and restore |
* it later with popErrorHandling. |
* |
* @param mixed $mode (same as setErrorHandling) |
* @param mixed $options (same as setErrorHandling) |
* |
* @return bool Always true |
* |
* @see PEAR::setErrorHandling |
*/ |
function pushErrorHandling($mode, $options = null) |
{ |
$stack = &$GLOBALS['_PEAR_error_handler_stack']; |
if (isset($this) && is_a($this, 'PEAR')) { |
$def_mode = &$this->_default_error_mode; |
$def_options = &$this->_default_error_options; |
} else { |
$def_mode = &$GLOBALS['_PEAR_default_error_mode']; |
$def_options = &$GLOBALS['_PEAR_default_error_options']; |
} |
$stack[] = array($def_mode, $def_options); |
if (isset($this) && is_a($this, 'PEAR')) { |
$this->setErrorHandling($mode, $options); |
} else { |
PEAR::setErrorHandling($mode, $options); |
} |
$stack[] = array($mode, $options); |
return true; |
} |
// }}} |
// {{{ popErrorHandling() |
/** |
* Pop the last error handler used |
* |
* @return bool Always true |
* |
* @see PEAR::pushErrorHandling |
*/ |
function popErrorHandling() |
{ |
$stack = &$GLOBALS['_PEAR_error_handler_stack']; |
array_pop($stack); |
list($mode, $options) = $stack[sizeof($stack) - 1]; |
array_pop($stack); |
if (isset($this) && is_a($this, 'PEAR')) { |
$this->setErrorHandling($mode, $options); |
} else { |
PEAR::setErrorHandling($mode, $options); |
} |
return true; |
} |
// }}} |
// {{{ loadExtension() |
/** |
* OS independant PHP extension load. Remember to take care |
* on the correct extension name for case sensitive OSes. |
* |
* @param string $ext The extension name |
* @return bool Success or not on the dl() call |
*/ |
function loadExtension($ext) |
{ |
if (!extension_loaded($ext)) { |
// if either returns true dl() will produce a FATAL error, stop that |
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { |
return false; |
} |
if (OS_WINDOWS) { |
$suffix = '.dll'; |
} elseif (PHP_OS == 'HP-UX') { |
$suffix = '.sl'; |
} elseif (PHP_OS == 'AIX') { |
$suffix = '.a'; |
} elseif (PHP_OS == 'OSX') { |
$suffix = '.bundle'; |
} else { |
$suffix = '.so'; |
} |
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); |
} |
return true; |
} |
// }}} |
} |
// {{{ _PEAR_call_destructors() |
function _PEAR_call_destructors() |
{ |
global $_PEAR_destructor_object_list; |
if (is_array($_PEAR_destructor_object_list) && |
sizeof($_PEAR_destructor_object_list)) |
{ |
reset($_PEAR_destructor_object_list); |
if (PEAR::getStaticProperty('PEAR', 'destructlifo')) { |
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); |
} |
while (list($k, $objref) = each($_PEAR_destructor_object_list)) { |
$classname = get_class($objref); |
while ($classname) { |
$destructor = "_$classname"; |
if (method_exists($objref, $destructor)) { |
$objref->$destructor(); |
break; |
} else { |
$classname = get_parent_class($classname); |
} |
} |
} |
// Empty the object list to ensure that destructors are |
// not called more than once. |
$_PEAR_destructor_object_list = array(); |
} |
// Now call the shutdown functions |
if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { |
foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { |
call_user_func_array($value[0], $value[1]); |
} |
} |
} |
// }}} |
/** |
* Standard PEAR error class for PHP 4 |
* |
* This class is supserseded by {@link PEAR_Exception} in PHP 5 |
* |
* @category pear |
* @package PEAR |
* @author Stig Bakken <ssb@php.net> |
* @author Tomas V.V. Cox <cox@idecnet.com> |
* @author Gregory Beaver <cellog@php.net> |
* @copyright 1997-2006 The PHP Group |
* @license http://www.php.net/license/3_0.txt PHP License 3.0 |
* @version Release: 1.7.2 |
* @link http://pear.php.net/manual/en/core.pear.pear-error.php |
* @see PEAR::raiseError(), PEAR::throwError() |
* @since Class available since PHP 4.0.2 |
*/ |
class PEAR_Error |
{ |
// {{{ properties |
var $error_message_prefix = ''; |
var $mode = PEAR_ERROR_RETURN; |
var $level = E_USER_NOTICE; |
var $code = -1; |
var $message = ''; |
var $userinfo = ''; |
var $backtrace = null; |
// }}} |
// {{{ constructor |
/** |
* PEAR_Error constructor |
* |
* @param string $message message |
* |
* @param int $code (optional) error code |
* |
* @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, |
* PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, |
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION |
* |
* @param mixed $options (optional) error level, _OR_ in the case of |
* PEAR_ERROR_CALLBACK, the callback function or object/method |
* tuple. |
* |
* @param string $userinfo (optional) additional user/debug info |
* |
* @access public |
* |
*/ |
function PEAR_Error($message = 'unknown error', $code = null, |
$mode = null, $options = null, $userinfo = null) |
{ |
if ($mode === null) { |
$mode = PEAR_ERROR_RETURN; |
} |
$this->message = $message; |
$this->code = $code; |
$this->mode = $mode; |
$this->userinfo = $userinfo; |
if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) { |
$this->backtrace = debug_backtrace(); |
if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { |
unset($this->backtrace[0]['object']); |
} |
} |
if ($mode & PEAR_ERROR_CALLBACK) { |
$this->level = E_USER_NOTICE; |
$this->callback = $options; |
} else { |
if ($options === null) { |
$options = E_USER_NOTICE; |
} |
$this->level = $options; |
$this->callback = null; |
} |
if ($this->mode & PEAR_ERROR_PRINT) { |
if (is_null($options) || is_int($options)) { |
$format = "%s"; |
} else { |
$format = $options; |
} |
printf($format, $this->getMessage()); |
} |
if ($this->mode & PEAR_ERROR_TRIGGER) { |
trigger_error($this->getMessage(), $this->level); |
} |
if ($this->mode & PEAR_ERROR_DIE) { |
$msg = $this->getMessage(); |
if (is_null($options) || is_int($options)) { |
$format = "%s"; |
if (substr($msg, -1) != "\n") { |
$msg .= "\n"; |
} |
} else { |
$format = $options; |
} |
die(sprintf($format, $msg)); |
} |
if ($this->mode & PEAR_ERROR_CALLBACK) { |
if (is_callable($this->callback)) { |
call_user_func($this->callback, $this); |
} |
} |
if ($this->mode & PEAR_ERROR_EXCEPTION) { |
trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); |
eval('$e = new Exception($this->message, $this->code);throw($e);'); |
} |
} |
// }}} |
// {{{ getMode() |
/** |
* Get the error mode from an error object. |
* |
* @return int error mode |
* @access public |
*/ |
function getMode() { |
return $this->mode; |
} |
// }}} |
// {{{ getCallback() |
/** |
* Get the callback function/method from an error object. |
* |
* @return mixed callback function or object/method array |
* @access public |
*/ |
function getCallback() { |
return $this->callback; |
} |
// }}} |
// {{{ getMessage() |
/** |
* Get the error message from an error object. |
* |
* @return string full error message |
* @access public |
*/ |
function getMessage() |
{ |
return ($this->error_message_prefix . $this->message); |
} |
// }}} |
// {{{ getCode() |
/** |
* Get error code from an error object |
* |
* @return int error code |
* @access public |
*/ |
function getCode() |
{ |
return $this->code; |
} |
// }}} |
// {{{ getType() |
/** |
* Get the name of this error/exception. |
* |
* @return string error/exception name (type) |
* @access public |
*/ |
function getType() |
{ |
return get_class($this); |
} |
// }}} |
// {{{ getUserInfo() |
/** |
* Get additional user-supplied information. |
* |
* @return string user-supplied information |
* @access public |
*/ |
function getUserInfo() |
{ |
return $this->userinfo; |
} |
// }}} |
// {{{ getDebugInfo() |
/** |
* Get additional debug information supplied by the application. |
* |
* @return string debug information |
* @access public |
*/ |
function getDebugInfo() |
{ |
return $this->getUserInfo(); |
} |
// }}} |
// {{{ getBacktrace() |
/** |
* Get the call backtrace from where the error was generated. |
* Supported with PHP 4.3.0 or newer. |
* |
* @param int $frame (optional) what frame to fetch |
* @return array Backtrace, or NULL if not available. |
* @access public |
*/ |
function getBacktrace($frame = null) |
{ |
if (defined('PEAR_IGNORE_BACKTRACE')) { |
return null; |
} |
if ($frame === null) { |
return $this->backtrace; |
} |
return $this->backtrace[$frame]; |
} |
// }}} |
// {{{ addUserInfo() |
function addUserInfo($info) |
{ |
if (empty($this->userinfo)) { |
$this->userinfo = $info; |
} else { |
$this->userinfo .= " ** $info"; |
} |
} |
// }}} |
// {{{ toString() |
function __toString() |
{ |
return $this->getMessage(); |
} |
// }}} |
// {{{ toString() |
/** |
* Make a string representation of this object. |
* |
* @return string a string with an object summary |
* @access public |
*/ |
function toString() { |
$modes = array(); |
$levels = array(E_USER_NOTICE => 'notice', |
E_USER_WARNING => 'warning', |
E_USER_ERROR => 'error'); |
if ($this->mode & PEAR_ERROR_CALLBACK) { |
if (is_array($this->callback)) { |
$callback = (is_object($this->callback[0]) ? |
strtolower(get_class($this->callback[0])) : |
$this->callback[0]) . '::' . |
$this->callback[1]; |
} else { |
$callback = $this->callback; |
} |
return sprintf('[%s: message="%s" code=%d mode=callback '. |
'callback=%s prefix="%s" info="%s"]', |
strtolower(get_class($this)), $this->message, $this->code, |
$callback, $this->error_message_prefix, |
$this->userinfo); |
} |
if ($this->mode & PEAR_ERROR_PRINT) { |
$modes[] = 'print'; |
} |
if ($this->mode & PEAR_ERROR_TRIGGER) { |
$modes[] = 'trigger'; |
} |
if ($this->mode & PEAR_ERROR_DIE) { |
$modes[] = 'die'; |
} |
if ($this->mode & PEAR_ERROR_RETURN) { |
$modes[] = 'return'; |
} |
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. |
'prefix="%s" info="%s"]', |
strtolower(get_class($this)), $this->message, $this->code, |
implode("|", $modes), $levels[$this->level], |
$this->error_message_prefix, |
$this->userinfo); |
} |
// }}} |
} |
/* |
* Local Variables: |
* mode: php |
* tab-width: 4 |
* c-basic-offset: 4 |
* End: |
*/ |
?> |
/branches/ant-ng/lib/core.php |
---|
Новый файл |
0,0 → 1,19 |
<?php |
/** |
* |
* Codename: ant-ng - generator of sources.list for Debian and |
* distributives, based on Debian |
* http://alex-w.org.ru/p/antng/ |
* |
* Copyright (c) 2009 Alexander Wolf |
* Dual licensed under the MIT and GNU LGPL licenses. |
* http://alex-w.org.ru/p/antng/license |
* |
*/ |
class Core { |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_file.php |
---|
Новый файл |
0,0 → 1,140 |
<?php |
/** |
* Smarty Internal Plugin Resource File |
* |
* Implements the file system as resource for Smarty templates |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource File |
*/ |
class Smarty_Internal_Resource_File { |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
// classes used for compiling Smarty templates from file resource |
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
public $template_parser_class = 'Smarty_Internal_Templateparser'; |
/** |
* Return flag if template source is existing |
* |
* @return boolean true |
*/ |
public function isExisting($template) |
{ |
if ($template->getTemplateFilepath() === false) { |
return false; |
} else { |
return true; |
} |
} |
/** |
* Get filepath to template source |
* |
* @param object $_template template object |
* @return string filepath to template source file |
*/ |
public function getTemplateFilepath($_template) |
{ |
$_filepath = $_template->buildTemplateFilepath (); |
if ($_filepath !== false) { |
if ($_template->security) { |
$_template->smarty->security_handler->isTrustedResourceDir($_filepath); |
} |
} |
return $_filepath; |
} |
/** |
* Get timestamp to template source |
* |
* @param object $_template template object |
* @return integer timestamp of template source file |
*/ |
public function getTemplateTimestamp($_template) |
{ |
return filemtime($_template->getTemplateFilepath()); |
} |
/** |
* Read template source from file |
* |
* @param object $_template template object |
* @return string content of template source file |
*/ |
public function getTemplateSource($_template) |
{ |
// read template file |
if (file_exists($_template->getTemplateFilepath())) { |
$_template->template_source = file_get_contents($_template->getTemplateFilepath()); |
return true; |
} else { |
return false; |
} |
} |
/** |
* Return flag that this resource uses the compiler |
* |
* @return boolean true |
*/ |
public function usesCompiler() |
{ |
// template has tags, uses compiler |
return true; |
} |
/** |
* Return flag that this is not evaluated |
* |
* @return boolean false |
*/ |
public function isEvaluated() |
{ |
// save the compiled file to disk, do not evaluate |
return false; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $_template template object |
* @return string return path to compiled template |
*/ |
public function getCompiledFilepath($_template) |
{ |
// $_filepath = md5($_template->resource_name); |
$_filepath = (string)abs(crc32($_template->resource_name)); |
// if use_sub_dirs, break file into directories |
if ($_template->smarty->use_sub_dirs) { |
$_filepath = substr($_filepath, 0, 3) . DS |
. substr($_filepath, 0, 2) . DS |
. substr($_filepath, 0, 1) . DS |
. $_filepath; |
} |
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; |
if (isset($_template->compile_id)) { |
$_filepath = $_template->compile_id . $_compile_dir_sep . $_filepath; |
} |
if ($_template->caching) { |
$_cache = '.cache'; |
} else { |
$_cache = ''; |
} |
$_compile_dir = $_template->smarty->compile_dir; |
if (strpos('/\\', substr($_compile_dir, -1)) === false) { |
$_compile_dir .= DS; |
} |
return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_template->resource_name). $_cache . $_template->smarty->php_ext; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getcachelifetime.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method getCacheLifetime |
* |
* Returns lifetime of cache files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Smarty class getCacheLifetime |
* |
* Returns lifetime of cache files |
*/ |
/** |
* Returns lifetime of cache files |
* |
* @return integer cache file lifetime |
*/ |
function getCacheLifetime($smarty) |
{ |
return $smarty->cache_lifetime; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.registerdefaulttemplatehandler.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method registerDefaultTemplateHandler |
* |
* Registers a default template handler |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers a default template handler |
* |
* @param object $smarty |
* @param string $ |array $function class/methode name |
*/ |
function registerDefaultTemplateHandler($smarty, $function) |
{ |
if (is_callable($function)) { |
$smarty->default_template_handler_func = $function; |
} else { |
throw new Exception('Default template handler "' . $function . '" not callable'); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_blockclose.php |
---|
Новый файл |
0,0 → 1,56 |
<?php |
/** |
* Smarty Internal Plugin Compile Block Close |
* |
* Compiles the {/block} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile BlockClose Class |
*/ |
class Smarty_Internal_Compile_BlockClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/block} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->compiler->has_code = true; |
// turn off block code extraction |
$compiler->template->extract_code = false; |
// check and get attributes |
$this->optional_attributes = array('name'); |
$_attr = $this->_get_attributes($args); |
$saved_data = $this->_close_tag(array('block')); |
// if name does match to opening tag |
if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { |
$this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); |
} |
$_name = trim($saved_data[0]['name'], "\"'"); |
if (isset($compiler->template->block_data[$_name])) { |
if (strpos($compiler->template->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { |
$_output = str_replace('%%%%SMARTY_PARENT%%%%', $_compiled_content, $compiler->template->block_data[$_name]['compiled']); |
} elseif ($compiler->template->block_data[$_name]['mode'] == 'prepend') { |
$_output = $compiler->template->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code; |
} elseif ($compiler->template->block_data[$_name]['mode'] == 'append') { |
$_output = $compiler->template->extracted_compiled_code . $compiler->template->block_data[$_name]['compiled']; |
} elseif (!empty($compiler->template->block_data[$_name])) { |
$_output = $compiler->template->block_data[$_name]['compiled']; |
} |
} else { |
$_output = $compiler->template->extracted_compiled_code; |
} |
$compiler->template->extracted_compiled_code = $saved_data[1]; |
$compiler->template->extract_code = $saved_data[2]; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.write_file.php |
---|
Новый файл |
0,0 → 1,47 |
<?php |
/** |
* Smarty write file plugin |
* |
* @package Smarty |
* @subpackage PluginsInternal |
* @author Monte Ohrt |
*/ |
/** |
* Smarty Internal Write File Class |
*/ |
class Smarty_Internal_Write_File { |
/** |
* Writes file in a save way to disk |
* |
* @param string $_filepath complete filepath |
* @param string $_contents file content |
* @return boolean true |
*/ |
public function writeFile($_filepath, $_contents) |
{ |
$_dirpath = dirname($_filepath); |
// if subdirs, create dir structure |
if ($_dirpath !== '.' && !file_exists($_dirpath)) { |
mkdir($_dirpath, 0755, true); |
} |
// write to tmp file, then move to overt file lock race condition |
$_tmp_file = tempnam($_dirpath, 'wrt'); |
if (!file_put_contents($_tmp_file, $_contents)) { |
throw new Exception("unable to write file {$_tmp_file}"); |
return false; |
} |
// remove original file |
if (file_exists($_filepath)) |
unlink($_filepath); |
// rename tmp file |
rename($_tmp_file, $_filepath); |
// set file permissions |
chmod($_filepath, 0644); |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_function.php |
---|
Новый файл |
0,0 → 1,44 |
<?php |
/** |
* Smarty Internal Plugin Compile Function |
* |
* Compiles the {function} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Function Class |
*/ |
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {function} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return boolean true |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('name'); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); |
$this->_open_tag('function', $save); |
$_name = trim($_attr['name'], "'"); |
foreach ($_attr as $_key => $_data) { |
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data; |
} |
// make function known for recursive calls |
$this->compiler->smarty->template_functions[$_name]['compiled'] = ''; |
$compiler->template->extract_code = true; |
$compiler->template->extracted_compiled_code = ''; |
$compiler->template->has_code = false; |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.addpluginsdir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method addPluginsDir |
* |
* Adds directory of plugin files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Adds directory of plugin files |
* |
* @param object $smarty |
* @param string $ |array $ plugins folder |
* @return |
*/ |
function AddPluginsDir($smarty, $plugins_dir) |
{ |
$smarty->plugins_dir = array_merge((array)$smarty->plugins_dir, (array)$plugins_dir); |
$smarty->plugins_dir = array_unique($smarty->plugins_dir); |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_stripclose.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty Internal Plugin Compile Strip Close |
* |
* Compiles the {/strip} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile StripClose Class |
*/ |
class Smarty_Internal_Compile_StripClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/strip} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$saved_attr = $this->_close_tag(array('strip')); |
$_output = "<?php echo preg_replace('![\t ]*[\r\n]+[\t ]*!', '', ob_get_clean()); ?>\n"; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.setpluginsdir.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method setPluginsDir |
* |
* Sets directory of plugin files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Sets directory of plugin files |
*/ |
/** |
* Sets directory of plugin files |
* |
* @param string $ plugins folder |
* @return |
*/ |
function SetPluginsDir($smarty, $plugins_dir) |
{ |
$smarty->plugins_dir = (array)$plugins_dir; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enablecompilecheck.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableCompileCheck |
* |
* Enable compile checking |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable compile checking |
*/ |
function enableCompileCheck($smarty) |
{ |
$smarty->compile_check = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_resource.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method Unregister_Resource |
* |
* Unregister a template resource |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a template resource |
*/ |
/** |
* Unregisters a resource |
* |
* @param string $type name of resource |
*/ |
function Unregister_Resource($smarty, $type) |
{ |
unset($smarty->plugins['resource'][$type]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_sectionclose.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty Internal Plugin Compile Section Close |
* |
* Compiles the {/section} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile SectionClose Class |
*/ |
class Smarty_Internal_Compile_SectionClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/section} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$_open_tag = $this->_close_tag(array('section', 'sectionelse')); |
if ($_open_tag == 'sectionelse') |
return "<?php endif; ?>"; |
else |
return "<?php endfor; endif; ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disableconfigoverwrite.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method disableConfigOverwrite |
* |
* Disable config overwrite mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable config overwrite mode |
*/ |
function disableConfigOverwrite($smarty) |
{ |
$smarty->config_overwrite = false; |
return ; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_variablefilter.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method Unregister_Variablefilter |
* |
* Unregister a variablefilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a variablefilter |
*/ |
/** |
* Unregisters a variablefilter function |
* |
* @param callback $function |
*/ |
function unregister_variablefilter($smarty, $function) |
{ |
unset($smarty->registered_filters['variable'][$smarty->_get_filter_name($function)]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_postfilter.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method Unregister_Postfilter |
* |
* Unregister a postfilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a postfilter |
*/ |
/** |
* Unregisters a postfilter function |
* |
* @param callback $function |
*/ |
function unregister_postfilter($smarty, $function) |
{ |
unset($smarty->registered_filters['post'][$smarty->_get_filter_name($function)]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_prefilter.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method Unregister_Prefilter |
* |
* Unregister a prefilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a prefilter |
*/ |
/** |
* Unregisters a prefilter function |
* |
* @param callback $function |
*/ |
function unregister_prefilter($smarty, $function) |
{ |
unset($smarty->registered_filters['pre'][$smarty->_get_filter_name($function)]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_nocache.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty Internal Plugin Compile Nocache |
* |
* Compiles the {nocache} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Nocache Class |
*/ |
class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {nocache} tag |
* |
* This tag does not generate compiled output. It only sets a compiler flag |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$_attr = $this->_get_attributes($args); |
// enter nocache mode |
$this->compiler->nocache = true; |
// this tag does not return compiled code |
$this->compiler->has_code = false; |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_strip.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty Internal Plugin Compile Strip |
* |
* Compiles the {strip} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Strip Class |
*/ |
class Smarty_Internal_Compile_Strip extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {strip} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('strip'); |
$_output = "<?php ob_start(); ?>"; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_capture.php |
---|
Новый файл |
0,0 → 1,46 |
<?php |
/** |
* Smarty Internal Plugin Compile Capture |
* |
* Compiles the {capture} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Capture Class |
*/ |
class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {capture} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->optional_attributes = array('name', 'assign'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
if (isset($_attr['name'])) |
$buffer = $_attr['name']; |
else |
$buffer = "'default'"; |
if (isset($_attr['assign'])) |
$assign = $_attr['assign']; |
else |
$assign = null; |
$this->_open_tag('capture',array($buffer, $assign)); |
$_output = "<?php ob_start(); ?>"; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.templatelexer.php |
---|
Новый файл |
0,0 → 1,742 |
<?php |
/** |
* Smarty Internal Plugin Templatelexer |
* |
* This is the lexer to break the template source into tokens |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Templatelexer |
*/ |
class Smarty_Internal_Templatelexer |
{ |
public $data; |
public $counter; |
public $token; |
public $value; |
public $node; |
public $line; |
private $state = 1; |
public $smarty_token_names = array ( // Text for parser error messages |
'IDENTITY' => '===', |
'NONEIDENTITY' => '!==', |
'EQUALS' => '==', |
'NOTEQUALS' => '!=', |
'GREATEREQUAL' => '(>=,GE)', |
'LESSEQUAL' => '(<=,LE)', |
'GREATERTHAN' => '(>,GT)', |
'LESSTHAN' => '(<,LT)', |
'NOT' => '(!,NOT)', |
'LAND' => '(&&,AND)', |
'LOR' => '(||,OR)', |
'LXOR' => 'XOR', |
'OPENP' => '(', |
'CLOSEP' => ')', |
'OPENB' => '[', |
'CLOSEB' => ']', |
'PTR' => '->', |
'APTR' => '=>', |
'EQUAL' => '=', |
'NUMBER' => 'number', |
'UNIMATH' => '+" , "-', |
'MATH' => '*" , "/" , "%', |
'INCDEC' => '++" , "--', |
'SPACE' => ' ', |
'DOLLAR' => '$', |
'SEMICOLON' => ';', |
'COLON' => ':', |
'DOUBLECOLON' => '::', |
'AT' => '@', |
'HATCH' => '#', |
'QUOTE' => '"', |
'SINGLEQUOTE' => "'", |
'BACKTICK' => '`', |
'VERT' => '|', |
'DOT' => '.', |
'COMMA' => '","', |
'ANDSYM' => '"&"', |
'ID' => 'identifier', |
'OTHER' => 'text', |
'PHP' => 'PHP code', |
'LDELSLASH' => 'closing tag', |
'COMMENTSTART' => '{*', |
'COMMENTEND' => '*}', |
'LITERALEND' => 'literal close', |
'AS' => 'as', |
'NULL' => 'null', |
'BOOLEAN' => 'boolean' |
); |
function __construct($data,$smarty) |
{ |
// set instance object |
self::instance($this); |
$this->data = $data; |
$this->counter = 0; |
$this->line = 1; |
$this->smarty = $smarty; |
$this->ldel = preg_quote($this->smarty->left_delimiter); |
$this->rdel = preg_quote($this->smarty->right_delimiter); |
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; |
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; |
} |
public static function &instance($new_instance = null) |
{ |
static $instance = null; |
if (isset($new_instance) && is_object($new_instance)) |
$instance = $new_instance; |
return $instance; |
} |
private $_yy_state = 1; |
private $_yy_stack = array(); |
function yylex() |
{ |
return $this->{'yylex' . $this->_yy_state}(); |
} |
function yypushstate($state) |
{ |
array_push($this->_yy_stack, $this->_yy_state); |
$this->_yy_state = $state; |
} |
function yypopstate() |
{ |
$this->_yy_state = array_pop($this->_yy_stack); |
} |
function yybegin($state) |
{ |
$this->_yy_state = $state; |
} |
function yylex1() |
{ |
$tokenMap = array ( |
1 => 0, |
2 => 0, |
3 => 0, |
4 => 0, |
5 => 0, |
6 => 0, |
7 => 1, |
9 => 0, |
10 => 0, |
11 => 0, |
12 => 0, |
13 => 0, |
14 => 0, |
15 => 0, |
16 => 0, |
17 => 0, |
18 => 0, |
19 => 0, |
20 => 0, |
21 => 1, |
23 => 0, |
24 => 0, |
25 => 0, |
26 => 0, |
27 => 0, |
28 => 1, |
30 => 1, |
32 => 1, |
34 => 1, |
36 => 1, |
38 => 1, |
40 => 1, |
42 => 1, |
44 => 1, |
46 => 1, |
48 => 0, |
49 => 0, |
50 => 0, |
51 => 0, |
52 => 0, |
53 => 0, |
54 => 0, |
55 => 0, |
56 => 0, |
57 => 0, |
58 => 0, |
59 => 0, |
60 => 0, |
61 => 0, |
62 => 0, |
63 => 0, |
64 => 0, |
65 => 0, |
66 => 1, |
68 => 1, |
70 => 1, |
72 => 0, |
73 => 0, |
74 => 0, |
75 => 0, |
76 => 0, |
77 => 0, |
78 => 0, |
79 => 0, |
80 => 0, |
81 => 0, |
82 => 0, |
83 => 0, |
84 => 1, |
86 => 0, |
87 => 0, |
88 => 0, |
); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
$yy_global_pattern = "/^(\\s*<\\?xml)|^(\\s*<\\?php)|^(\\s*<\\?=)|^(\\s*\\?>)|^(\\s*\\*".$this->rdel.")|^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)/"; |
do { |
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) { |
$yysubmatches = $yymatches; |
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
if (!count($yymatches)) { |
throw new Exception('Error: lexing failed because a rule matched' . |
'an empty string. Input "' . substr($this->data, |
$this->counter, 5) . '... state START'); |
} |
next($yymatches); // skip global match |
$this->token = key($yymatches); // token number |
if ($tokenMap[$this->token]) { |
// extract sub-patterns for passing to lex function |
$yysubmatches = array_slice($yysubmatches, $this->token + 1, |
$tokenMap[$this->token]); |
} else { |
$yysubmatches = array(); |
} |
$this->value = current($yymatches); // token value |
$r = $this->{'yy_r1_' . $this->token}($yysubmatches); |
if ($r === null) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
// accept this token |
return true; |
} elseif ($r === true) { |
// we have changed state |
// process this token in the new state |
return $this->yylex(); |
} elseif ($r === false) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
// skip this token |
continue; |
} else { $yy_yymore_patterns = array( |
1 => array(0, "^(\\s*<\\?php)|^(\\s*<\\?=)|^(\\s*\\?>)|^(\\s*\\*".$this->rdel.")|^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
2 => array(0, "^(\\s*<\\?=)|^(\\s*\\?>)|^(\\s*\\*".$this->rdel.")|^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
3 => array(0, "^(\\s*\\?>)|^(\\s*\\*".$this->rdel.")|^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
4 => array(0, "^(\\s*\\*".$this->rdel.")|^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
5 => array(0, "^(\\s*".$this->ldel."\\*)|^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
6 => array(0, "^((\\\\\"|\\\\'))|^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
7 => array(1, "^(')|^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
9 => array(1, "^(\\s*".$this->ldel."literal".$this->rdel.")|^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
10 => array(1, "^(\\s*".$this->ldel."\/literal".$this->rdel.")|^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
11 => array(1, "^(\\s*".$this->ldel."ldelim".$this->rdel.")|^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
12 => array(1, "^(\\s*".$this->ldel."rdelim".$this->rdel.")|^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
13 => array(1, "^(\\s*".$this->ldel."\\s{1,}\/)|^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
14 => array(1, "^(\\s*".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
15 => array(1, "^(\\s{1,}".$this->rdel.")|^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
16 => array(1, "^(\\s*".$this->ldel."\/)|^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
17 => array(1, "^(\\s*".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
18 => array(1, "^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
19 => array(1, "^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
20 => array(1, "^(\\s+(AS|as)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
21 => array(2, "^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
23 => array(2, "^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
24 => array(2, "^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
25 => array(2, "^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
26 => array(2, "^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
27 => array(2, "^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
28 => array(3, "^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|ne)\\s+)|^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
30 => array(4, "^(\\s*>=\\s*|\\s+(GE|ge)\\s+)|^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
32 => array(5, "^(\\s*<=\\s*|\\s+(LE|le)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
34 => array(6, "^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
36 => array(7, "^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
38 => array(8, "^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
40 => array(9, "^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
42 => array(10, "^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
44 => array(11, "^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
46 => array(12, "^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
48 => array(12, "^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
49 => array(12, "^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
50 => array(12, "^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
51 => array(12, "^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
52 => array(12, "^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
53 => array(12, "^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
54 => array(12, "^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
55 => array(12, "^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
56 => array(12, "^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
57 => array(12, "^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
58 => array(12, "^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
59 => array(12, "^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
60 => array(12, "^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
61 => array(12, "^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
62 => array(12, "^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
63 => array(12, "^(\\s*=\\s*)|^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
64 => array(12, "^(\\d+)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
65 => array(12, "^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
66 => array(13, "^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
68 => array(14, "^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
70 => array(15, "^(\\$)|^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
72 => array(15, "^(\\s*;\\s*)|^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
73 => array(15, "^(::)|^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
74 => array(15, "^(:)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
75 => array(15, "^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
76 => array(15, "^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
77 => array(15, "^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
78 => array(15, "^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
79 => array(15, "^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
80 => array(15, "^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
81 => array(15, "^(\\s*,\\s*)|^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
82 => array(15, "^(\\s*&\\s*)|^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
83 => array(15, "^(([A-Za-z]\\w*\\s+){5,})|^(\\w+)|^(\\s+)|^(.)"), |
84 => array(16, "^(\\w+)|^(\\s+)|^(.)"), |
86 => array(16, "^(\\s+)|^(.)"), |
87 => array(16, "^(.)"), |
88 => array(16, ""), |
); |
// yymore is needed |
do { |
if (!strlen($yy_yymore_patterns[$this->token][1])) { |
throw new Exception('cannot do yymore for the last token'); |
} |
$yysubmatches = array(); |
if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', |
substr($this->data, $this->counter), $yymatches)) { |
$yysubmatches = $yymatches; |
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
next($yymatches); // skip global match |
$this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number |
$this->value = current($yymatches); // token value |
$this->line = substr_count($this->value, "\n"); |
if ($tokenMap[$this->token]) { |
// extract sub-patterns for passing to lex function |
$yysubmatches = array_slice($yysubmatches, $this->token + 1, |
$tokenMap[$this->token]); |
} else { |
$yysubmatches = array(); |
} |
} |
$r = $this->{'yy_r1_' . $this->token}($yysubmatches); |
} while ($r !== null && !is_bool($r)); |
if ($r === true) { |
// we have changed state |
// process this token in the new state |
return $this->yylex(); |
} elseif ($r === false) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
// skip this token |
continue; |
} else { |
// accept |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
return true; |
} |
} |
} else { |
throw new Exception('Unexpected input at line' . $this->line . |
': ' . $this->data[$this->counter]); |
} |
break; |
} while (true); |
} // end function |
const START = 1; |
function yy_r1_1($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_XML; |
} |
function yy_r1_2($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_PHP; |
} |
function yy_r1_3($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_SHORTTAGSTART; |
} |
function yy_r1_4($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_SHORTTAGEND; |
} |
function yy_r1_5($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_COMMENTEND; |
} |
function yy_r1_6($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_COMMENTSTART; |
} |
function yy_r1_7($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} |
function yy_r1_9($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTE; |
} |
function yy_r1_10($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; |
} |
function yy_r1_11($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
} |
function yy_r1_12($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LDELIMTAG; |
} |
function yy_r1_13($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_RDELIMTAG; |
} |
function yy_r1_14($yy_subpatterns) |
{ |
if ($this->smarty->auto_literal) { |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} else { |
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; |
} |
} |
function yy_r1_15($yy_subpatterns) |
{ |
if ($this->smarty->auto_literal) { |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} else { |
$this->token = Smarty_Internal_Templateparser::TP_LDEL; |
} |
} |
function yy_r1_16($yy_subpatterns) |
{ |
if ($this->smarty->auto_literal) { |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} else { |
$this->token = Smarty_Internal_Templateparser::TP_RDEL; |
} |
} |
function yy_r1_17($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; |
} |
function yy_r1_18($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LDEL; |
} |
function yy_r1_19($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_RDEL; |
} |
function yy_r1_20($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISIN; |
} |
function yy_r1_21($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_AS; |
} |
function yy_r1_23($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; |
} |
function yy_r1_24($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_BOOLEAN; |
} |
function yy_r1_25($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_NULL; |
} |
function yy_r1_26($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_IDENTITY; |
} |
function yy_r1_27($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY; |
} |
function yy_r1_28($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_EQUALS; |
} |
function yy_r1_30($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS; |
} |
function yy_r1_32($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL; |
} |
function yy_r1_34($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL; |
} |
function yy_r1_36($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN; |
} |
function yy_r1_38($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LESSTHAN; |
} |
function yy_r1_40($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_NOT; |
} |
function yy_r1_42($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LAND; |
} |
function yy_r1_44($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LOR; |
} |
function yy_r1_46($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_LXOR; |
} |
function yy_r1_48($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISODDBY; |
} |
function yy_r1_49($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY; |
} |
function yy_r1_50($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISODD; |
} |
function yy_r1_51($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODD; |
} |
function yy_r1_52($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISEVENBY; |
} |
function yy_r1_53($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY; |
} |
function yy_r1_54($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISEVEN; |
} |
function yy_r1_55($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN; |
} |
function yy_r1_56($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISDIVBY; |
} |
function yy_r1_57($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY; |
} |
function yy_r1_58($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_OPENP; |
} |
function yy_r1_59($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP; |
} |
function yy_r1_60($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_OPENB; |
} |
function yy_r1_61($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB; |
} |
function yy_r1_62($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_PTR; |
} |
function yy_r1_63($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_APTR; |
} |
function yy_r1_64($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_EQUAL; |
} |
function yy_r1_65($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_INTEGER; |
} |
function yy_r1_66($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_INCDEC; |
} |
function yy_r1_68($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH; |
} |
function yy_r1_70($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_MATH; |
} |
function yy_r1_72($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR; |
} |
function yy_r1_73($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; |
} |
function yy_r1_74($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; |
} |
function yy_r1_75($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_COLON; |
} |
function yy_r1_76($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_AT; |
} |
function yy_r1_77($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_HATCH; |
} |
function yy_r1_78($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
} |
function yy_r1_79($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
} |
function yy_r1_80($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_VERT; |
} |
function yy_r1_81($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_DOT; |
} |
function yy_r1_82($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_COMMA; |
} |
function yy_r1_83($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ANDSYM; |
} |
function yy_r1_84($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} |
function yy_r1_86($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_ID; |
} |
function yy_r1_87($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_SPACE; |
} |
function yy_r1_88($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Templateparser::TP_OTHER; |
} |
} |
/branches/ant-ng/lib/sysplugins/internal.compile_config_load.php |
---|
Новый файл |
0,0 → 1,53 |
<?php |
/** |
* Smarty Internal Plugin Compile Config Load |
* |
* Compiles the {config load} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Config Load Class |
*/ |
class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {config_load} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('file'); |
$this->optional_attributes = array('section', 'scope'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// save posible attributes |
$conf_file = $_attr['file']; |
if (isset($_attr['section'])) { |
$section = $_attr['section']; |
} else { |
$section = 'null'; |
} |
$scope = '$_smarty_tpl->smarty'; |
if (isset($_attr['scope'])) { |
if ($_attr['scope'] == '\'local\'') { |
$scope = '$_smarty_tpl'; |
} elseif ($_attr['scope'] == '\'parent\'') { |
$scope = '$_smarty_tpl->parent'; |
} |
} |
// create config object |
$_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Config');"; |
$_output .= "\$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty);"; |
$_output .= "\$_config->loadConfigVars($section, $scope); ?>"; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_insert.php |
---|
Новый файл |
0,0 → 1,74 |
<?php |
/** |
* Smarty Internal Plugin Compile Insert |
* |
* Compiles the {insert} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Insert Class |
*/ |
class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {insert} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('name'); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// this tag must not be cached |
$this->compiler->tag_nocache = true; |
$_output = '<?php '; |
// save posible attributes |
$_name = 'insert_' . trim($_attr['name'], "'"); |
if (isset($_attr['assign'])) { |
// output will be stored in a smarty variable instead of beind displayed |
$_assign = $_attr['assign']; |
// create variable to make shure that the compiler knows about its nocache status |
$this->compiler->template->tpl_vars[trim($_attr['assign'],"'")] = new Smarty_Variable(null,true); |
} |
if (isset($_attr['script'])) { |
// script which must be included |
$_script = $_attr['script']; |
if (!file_exists($_script)) { |
$this->compiler->trigger_template_error('missing file "' . $_script . '"'); |
} |
// code for script file loading |
$_output .= 'require once ' . $_script . ';'; |
} else { |
if (!is_callable($_name)) { |
$this->compiler->trigger_template_error('function "' . $_name . '" is not callable'); |
} |
} |
// delete {insert} standard attributes |
unset($_attr['name'], $_attr['assign'], $_attr['script']); |
// convert attributes into parameter array string |
$_paramsArray = array(); |
foreach ($_attr as $_key => $_value) { |
$_paramsArray[] = "'$_key'=>$_value"; |
} |
$_params = 'array(' . implode(",", $_paramsArray) . ')'; |
// call insert |
if (isset($_assign)) { |
$_output .= '$_smarty_tpl->assign(' . $_assign . ',' . $_name . '(' . $_params . '),true); ?>'; |
} else { |
$this->compiler->has_output = true; |
$_output .= 'echo ' . $_name . '(' . $_params . '); ?>'; |
} |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_cache.php |
---|
Новый файл |
0,0 → 1,38 |
<?php |
/** |
* Smarty method Clear_Cache |
* |
* Empties the cache for a specific template |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Empty cache for a specific template |
* |
* @param object $smarty |
* @param string $template_name template name |
* @param string $cache_id cache id |
* @param string $compile_id compile id |
* @param integer $exp_time expiration time |
* @param string $type resource type |
* @return integer number of cache files deleted |
*/ |
function clear_cache($smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = 'file') |
{ |
// load cache resource |
if (!isset($smarty->cache_resource_objects[$type])) { |
$_cache_resource_class = 'Smarty_Internal_CacheResource_' . $type; |
if (!$smarty->loadPlugin($_cache_resource_class)) { |
throw new Exception("Undefined cache resource type {$type}"); |
} |
$smarty->cache_resource_objects[$type] = new $_cache_resource_class($smarty); |
} |
return $smarty->cache_resource_objects[$type]->clear($template_name, $cache_id, $compile_id, $exp_time); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isconfigreadhidden.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isConfigReadHidden |
* |
* is config read hidden mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* |
* is config read hidden mode |
*/ |
function isConfigReadHidden($smarty) |
{ |
return $smarty->config_read_hidden; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.gettemplatedir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getTemplateDir |
* |
* Returns template directory |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns template directory |
*/ |
/** |
* Returns template directory |
* |
* @return array template folders |
*/ |
function getTemplateDir($smarty) |
{ |
return $smarty->template_dir; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.template_exists.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty method Template_Exists |
* |
* Checks if a template resource exists |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Checks if a template resource exists |
*/ |
/** |
* Check if a template resource exists |
* |
* @param string $resource_name template name |
* @return boolean status |
*/ |
function template_exists($smarty, $resource_name) |
{ |
// create template object |
$tpl = new $smarty->template_class($resource_name, $smarty); |
// check if it does exists |
return $tpl->isExisting(); |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_while.php |
---|
Новый файл |
0,0 → 1,39 |
<?php |
/** |
* Smarty Internal Plugin Compile While |
* |
* Compiles the {while} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile While Class |
*/ |
class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {while} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('if condition'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('while'); |
if (is_array($args['if condition'])) { |
$_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n"; |
$_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>"; |
return $_output; |
} else { |
return '<?php while (' . $args['if condition'] . ') { ?>'; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.setconfigdir.php |
---|
Новый файл |
0,0 → 1,26 |
<?php |
/** |
* Smarty method setConfigDir |
* |
* Sets directory of config files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Sets directory of config files |
* |
* @param object $smarty |
* @param string $ config folder |
* @return |
*/ |
function SetConfigDir($smarty, $config_dir) |
{ |
$this->smarty->config_dir = $config_dir; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_sectionelse.php |
---|
Новый файл |
0,0 → 1,34 |
<?php |
/** |
* Smarty Internal Plugin Compile Section Else |
* |
* Compiles the {sectionelse} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Sectionelse Class |
*/ |
class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {sectionelse} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_close_tag('section'); |
$this->_open_tag('sectionelse'); |
return "<?php endfor; else: ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_all_assign.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method Clear_All_Assign |
* |
* Deletes all assigned Smarty variables at current level |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Delete Smarty variables |
* |
* @param object $smarty |
* @param object $data_object object which holds tpl_vars |
*/ |
function clear_all_assign($smarty, $data_object = null) |
{ |
if (isset($data_object)) { |
$ptr = $data_object; |
} else { |
$ptr = $smarty; |
} |
$ptr->tpl_vars = array(); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.iscompilecheck.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isCompileCheck |
* |
* is compile checking |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is compile checking |
*/ |
function isCompileCheck($smarty) |
{ |
return $smarty->compile_check; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.load_filter.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty method Load_Filter |
* |
* Loads a filter plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* load a filter of specified type and name |
* |
* @param string $type filter type |
* @param string $name filter name |
*/ |
function load_filter($smarty, $type, $name) |
{ |
$_plugin = "smarty_{$type}filter_{$name}"; |
$_filter_name = $_plugin; |
if ($smarty->loadPlugin($_plugin)) { |
if (class_exists($_plugin, false)) { |
$_plugin = array($_plugin, 'execute'); |
} |
if (is_callable($_plugin)) { |
$smarty->registered_filters[$type][$_filter_name] = $_plugin; |
return; |
} |
} |
throw new Exception("{$type}filter \"{$name}\" not callable"); |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.templateparser.php |
---|
Новый файл |
0,0 → 1,2644 |
<?php |
/** |
* Smarty Internal Plugin Templateparser |
* |
* This is the template parser. |
* It is generated from the internal.templateparser.y file |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* This can be used to store both the string representation of |
* a token, and any useful meta-data associated with the token. |
* |
* meta-data should be stored as an array |
*/ |
class TP_yyToken implements ArrayAccess |
{ |
public $string = ''; |
public $metadata = array(); |
function __construct($s, $m = array()) |
{ |
if ($s instanceof TP_yyToken) { |
$this->string = $s->string; |
$this->metadata = $s->metadata; |
} else { |
$this->string = (string) $s; |
if ($m instanceof TP_yyToken) { |
$this->metadata = $m->metadata; |
} elseif (is_array($m)) { |
$this->metadata = $m; |
} |
} |
} |
function __toString() |
{ |
return $this->_string; |
} |
function offsetExists($offset) |
{ |
return isset($this->metadata[$offset]); |
} |
function offsetGet($offset) |
{ |
return $this->metadata[$offset]; |
} |
function offsetSet($offset, $value) |
{ |
if ($offset === null) { |
if (isset($value[0])) { |
$x = ($value instanceof TP_yyToken) ? |
$value->metadata : $value; |
$this->metadata = array_merge($this->metadata, $x); |
return; |
} |
$offset = count($this->metadata); |
} |
if ($value === null) { |
return; |
} |
if ($value instanceof TP_yyToken) { |
if ($value->metadata) { |
$this->metadata[$offset] = $value->metadata; |
} |
} elseif ($value) { |
$this->metadata[$offset] = $value; |
} |
} |
function offsetUnset($offset) |
{ |
unset($this->metadata[$offset]); |
} |
} |
/** The following structure represents a single element of the |
* parser's stack. Information stored includes: |
* |
* + The state number for the parser at this level of the stack. |
* |
* + The value of the token stored at this level of the stack. |
* (In other words, the "major" token.) |
* |
* + The semantic value stored at this level of the stack. This is |
* the information used by the action routines in the grammar. |
* It is sometimes called the "minor" token. |
*/ |
class TP_yyStackEntry |
{ |
public $stateno; /* The state-number */ |
public $major; /* The major token value. This is the code |
** number for the token at this stack level */ |
public $minor; /* The user-supplied minor token value. This |
** is the value of the token */ |
}; |
// code external to the class is included here |
// declare_class is output here |
#line 12 "internal.templateparser.y" |
class Smarty_Internal_Templateparser#line 109 "internal.templateparser.php" |
{ |
/* First off, code is included which follows the "include_class" declaration |
** in the input file. */ |
#line 14 "internal.templateparser.y" |
// states whether the parse was successful or not |
public $successful = true; |
public $retvalue = 0; |
private $lex; |
private $internalError = false; |
function __construct($lex, $compiler) { |
// set instance object |
self::instance($this); |
$this->lex = $lex; |
$this->compiler = $compiler; |
$this->smarty = $this->compiler->smarty; |
$this->template = $this->compiler->template; |
if ($this->template->security && isset($this->smarty->security_handler)) { |
$this->sec_obj = $this->smarty->security_policy; |
} else { |
$this->sec_obj = $this->smarty; |
} |
$this->cacher = $this->template->cacher_object; |
$this->nocache = false; |
$this->prefix_code = array(); |
$this->prefix_number = 0; |
} |
public static function &instance($new_instance = null) |
{ |
static $instance = null; |
if (isset($new_instance) && is_object($new_instance)) |
$instance = $new_instance; |
return $instance; |
} |
#line 147 "internal.templateparser.php" |
/* Next is all token values, as class constants |
*/ |
/* |
** These constants (all generated automatically by the parser generator) |
** specify the various kinds of tokens (terminals) that the parser |
** understands. |
** |
** Each symbol here is a terminal symbol in the grammar. |
*/ |
const TP_OTHER = 1; |
const TP_XML = 2; |
const TP_PHP = 3; |
const TP_SHORTTAGSTART = 4; |
const TP_SHORTTAGEND = 5; |
const TP_PHPSTART = 6; |
const TP_PHPEND = 7; |
const TP_COMMENTEND = 8; |
const TP_COMMENTSTART = 9; |
const TP_SINGLEQUOTE = 10; |
const TP_LITERALSTART = 11; |
const TP_LITERALEND = 12; |
const TP_LDELIMTAG = 13; |
const TP_RDELIMTAG = 14; |
const TP_LDELSLASH = 15; |
const TP_LDEL = 16; |
const TP_RDEL = 17; |
const TP_ISIN = 18; |
const TP_AS = 19; |
const TP_BOOLEAN = 20; |
const TP_NULL = 21; |
const TP_IDENTITY = 22; |
const TP_NONEIDENTITY = 23; |
const TP_EQUALS = 24; |
const TP_NOTEQUALS = 25; |
const TP_GREATEREQUAL = 26; |
const TP_LESSEQUAL = 27; |
const TP_GREATERTHAN = 28; |
const TP_LESSTHAN = 29; |
const TP_NOT = 30; |
const TP_LAND = 31; |
const TP_LOR = 32; |
const TP_LXOR = 33; |
const TP_ISODDBY = 34; |
const TP_ISNOTODDBY = 35; |
const TP_ISODD = 36; |
const TP_ISNOTODD = 37; |
const TP_ISEVENBY = 38; |
const TP_ISNOTEVENBY = 39; |
const TP_ISEVEN = 40; |
const TP_ISNOTEVEN = 41; |
const TP_ISDIVBY = 42; |
const TP_ISNOTDIVBY = 43; |
const TP_OPENP = 44; |
const TP_CLOSEP = 45; |
const TP_OPENB = 46; |
const TP_CLOSEB = 47; |
const TP_PTR = 48; |
const TP_APTR = 49; |
const TP_EQUAL = 50; |
const TP_INTEGER = 51; |
const TP_INCDEC = 52; |
const TP_UNIMATH = 53; |
const TP_MATH = 54; |
const TP_DOLLAR = 55; |
const TP_COLON = 56; |
const TP_DOUBLECOLON = 57; |
const TP_SEMICOLON = 58; |
const TP_AT = 59; |
const TP_HATCH = 60; |
const TP_QUOTE = 61; |
const TP_BACKTICK = 62; |
const TP_VERT = 63; |
const TP_DOT = 64; |
const TP_COMMA = 65; |
const TP_ANDSYM = 66; |
const TP_ID = 67; |
const TP_SPACE = 68; |
const TP_INSTANCEOF = 69; |
const YY_NO_ACTION = 448; |
const YY_ACCEPT_ACTION = 447; |
const YY_ERROR_ACTION = 446; |
/* Next are that tables used to determine what action to take based on the |
** current state and lookahead token. These tables are used to implement |
** functions that take a state number and lookahead value and return an |
** action integer. |
** |
** Suppose the action integer is N. Then the action is determined as |
** follows |
** |
** 0 <= N < self::YYNSTATE Shift N. That is, |
** push the lookahead |
** token onto the stack |
** and goto state N. |
** |
** self::YYNSTATE <= N < self::YYNSTATE+self::YYNRULE Reduce by rule N-YYNSTATE. |
** |
** N == self::YYNSTATE+self::YYNRULE A syntax error has occurred. |
** |
** N == self::YYNSTATE+self::YYNRULE+1 The parser accepts its |
** input. (and concludes parsing) |
** |
** N == self::YYNSTATE+self::YYNRULE+2 No such action. Denotes unused |
** slots in the yy_action[] table. |
** |
** The action table is constructed as a single large static array $yy_action. |
** Given state S and lookahead X, the action is computed as |
** |
** self::$yy_action[self::$yy_shift_ofst[S] + X ] |
** |
** If the index value self::$yy_shift_ofst[S]+X is out of range or if the value |
** self::$yy_lookahead[self::$yy_shift_ofst[S]+X] is not equal to X or if |
** self::$yy_shift_ofst[S] is equal to self::YY_SHIFT_USE_DFLT, it means that |
** the action is not in the table and that self::$yy_default[S] should be used instead. |
** |
** The formula above is for computing the action when the lookahead is |
** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
** a reduce action) then the static $yy_reduce_ofst array is used in place of |
** the static $yy_shift_ofst array and self::YY_REDUCE_USE_DFLT is used in place of |
** self::YY_SHIFT_USE_DFLT. |
** |
** The following are the tables generated in this section: |
** |
** self::$yy_action A single table containing all actions. |
** self::$yy_lookahead A table containing the lookahead for each entry in |
** yy_action. Used to detect hash collisions. |
** self::$yy_shift_ofst For each state, the offset into self::$yy_action for |
** shifting terminals. |
** self::$yy_reduce_ofst For each state, the offset into self::$yy_action for |
** shifting non-terminals after a reduce. |
** self::$yy_default Default action for each state. |
*/ |
const YY_SZ_ACTTAB = 1162; |
static public $yy_action = array( |
/* 0 */ 56, 27, 193, 56, 281, 153, 25, 39, 153, 25, |
/* 10 */ 210, 206, 276, 210, 206, 242, 244, 60, 158, 245, |
/* 20 */ 4, 62, 72, 67, 165, 69, 46, 230, 236, 153, |
/* 30 */ 25, 19, 275, 167, 5, 130, 12, 23, 200, 12, |
/* 40 */ 192, 161, 222, 35, 161, 66, 35, 186, 62, 231, |
/* 50 */ 46, 40, 203, 46, 40, 157, 235, 137, 139, 14, |
/* 60 */ 134, 153, 18, 157, 227, 30, 262, 259, 260, 10, |
/* 70 */ 2, 266, 263, 11, 7, 264, 265, 3, 6, 139, |
/* 80 */ 196, 447, 51, 185, 234, 31, 56, 39, 57, 56, |
/* 90 */ 27, 153, 25, 148, 153, 25, 210, 206, 277, 210, |
/* 100 */ 206, 142, 93, 42, 269, 34, 4, 197, 43, 249, |
/* 110 */ 250, 254, 255, 252, 248, 256, 253, 108, 269, 129, |
/* 120 */ 5, 208, 12, 23, 29, 12, 204, 161, 226, 35, |
/* 130 */ 161, 58, 35, 231, 66, 91, 46, 40, 282, 46, |
/* 140 */ 40, 203, 270, 133, 229, 139, 41, 16, 227, 157, |
/* 150 */ 139, 269, 262, 259, 260, 10, 2, 266, 263, 11, |
/* 160 */ 7, 264, 265, 3, 6, 257, 262, 259, 260, 10, |
/* 170 */ 2, 266, 263, 11, 7, 264, 265, 3, 6, 56, |
/* 180 */ 261, 320, 184, 139, 153, 25, 27, 201, 139, 210, |
/* 190 */ 206, 262, 259, 260, 10, 2, 266, 263, 11, 7, |
/* 200 */ 264, 265, 3, 6, 110, 31, 56, 199, 13, 27, |
/* 210 */ 106, 153, 25, 23, 22, 12, 210, 206, 284, 283, |
/* 220 */ 161, 112, 35, 42, 66, 178, 205, 118, 56, 46, |
/* 230 */ 40, 36, 320, 153, 25, 231, 137, 203, 210, 206, |
/* 240 */ 23, 272, 12, 20, 219, 72, 48, 161, 114, 35, |
/* 250 */ 227, 62, 171, 267, 268, 27, 46, 40, 214, 207, |
/* 260 */ 203, 198, 23, 140, 12, 222, 231, 284, 283, 161, |
/* 270 */ 237, 35, 272, 62, 129, 14, 72, 157, 46, 40, |
/* 280 */ 36, 227, 56, 151, 274, 141, 183, 153, 25, 214, |
/* 290 */ 207, 195, 210, 206, 8, 272, 222, 123, 171, 72, |
/* 300 */ 216, 119, 209, 157, 56, 53, 203, 218, 278, 153, |
/* 310 */ 25, 129, 214, 207, 210, 206, 23, 272, 12, 222, |
/* 320 */ 179, 72, 139, 161, 13, 35, 15, 66, 177, 213, |
/* 330 */ 223, 27, 46, 40, 214, 207, 21, 112, 23, 41, |
/* 340 */ 12, 222, 186, 139, 180, 161, 128, 35, 1, 66, |
/* 350 */ 224, 182, 233, 234, 46, 40, 153, 18, 284, 283, |
/* 360 */ 272, 135, 52, 13, 72, 20, 189, 74, 145, 136, |
/* 370 */ 96, 36, 144, 175, 13, 89, 112, 214, 207, 28, |
/* 380 */ 56, 226, 203, 166, 222, 153, 25, 112, 56, 258, |
/* 390 */ 210, 206, 139, 153, 25, 225, 142, 32, 210, 206, |
/* 400 */ 162, 56, 181, 43, 132, 62, 153, 25, 33, 147, |
/* 410 */ 46, 210, 206, 100, 23, 131, 12, 168, 247, 231, |
/* 420 */ 157, 161, 23, 280, 226, 62, 187, 72, 246, 161, |
/* 430 */ 46, 40, 220, 62, 227, 23, 62, 140, 46, 40, |
/* 440 */ 217, 46, 161, 287, 27, 140, 62, 222, 221, 172, |
/* 450 */ 139, 46, 40, 215, 241, 24, 34, 239, 138, 38, |
/* 460 */ 249, 250, 254, 255, 252, 248, 256, 253, 152, 272, |
/* 470 */ 211, 52, 72, 72, 157, 27, 77, 102, 13, 129, |
/* 480 */ 149, 146, 271, 257, 89, 170, 214, 207, 226, 9, |
/* 490 */ 72, 112, 222, 222, 62, 203, 231, 94, 258, 46, |
/* 500 */ 272, 139, 52, 169, 72, 157, 103, 78, 157, 183, |
/* 510 */ 222, 227, 146, 271, 139, 89, 71, 214, 207, 157, |
/* 520 */ 92, 272, 174, 52, 222, 72, 164, 126, 76, 258, |
/* 530 */ 88, 228, 209, 146, 271, 64, 89, 107, 214, 207, |
/* 540 */ 272, 273, 52, 202, 72, 222, 269, 82, 226, 55, |
/* 550 */ 258, 95, 146, 271, 228, 89, 101, 214, 207, 272, |
/* 560 */ 39, 52, 26, 72, 222, 269, 83, 226, 125, 258, |
/* 570 */ 194, 146, 271, 209, 89, 90, 214, 207, 160, 190, |
/* 580 */ 54, 176, 272, 222, 50, 228, 72, 124, 258, 75, |
/* 590 */ 70, 155, 209, 199, 146, 271, 269, 89, 121, 214, |
/* 600 */ 207, 65, 38, 272, 68, 52, 222, 72, 59, 228, |
/* 610 */ 80, 258, 22, 188, 156, 146, 271, 154, 89, 159, |
/* 620 */ 214, 207, 272, 240, 52, 243, 72, 222, 37, 84, |
/* 630 */ 288, 109, 258, 105, 146, 271, 216, 89, 33, 214, |
/* 640 */ 207, 272, 238, 52, 232, 72, 222, 61, 79, 17, |
/* 650 */ 191, 258, 199, 146, 271, 225, 89, 44, 214, 207, |
/* 660 */ 73, 157, 269, 269, 272, 222, 52, 269, 72, 269, |
/* 670 */ 258, 81, 269, 269, 269, 269, 146, 271, 269, 89, |
/* 680 */ 269, 214, 207, 269, 269, 272, 269, 99, 222, 72, |
/* 690 */ 269, 269, 269, 258, 269, 269, 269, 212, 271, 269, |
/* 700 */ 89, 269, 214, 207, 269, 269, 269, 269, 269, 222, |
/* 710 */ 272, 269, 99, 269, 72, 269, 269, 143, 285, 269, |
/* 720 */ 269, 269, 212, 271, 269, 89, 269, 214, 207, 272, |
/* 730 */ 269, 98, 269, 72, 222, 269, 269, 269, 269, 269, |
/* 740 */ 269, 212, 271, 279, 89, 269, 214, 207, 269, 269, |
/* 750 */ 173, 269, 272, 222, 98, 269, 72, 269, 269, 269, |
/* 760 */ 269, 269, 269, 269, 212, 271, 269, 89, 269, 214, |
/* 770 */ 207, 269, 269, 150, 269, 272, 222, 98, 269, 72, |
/* 780 */ 269, 269, 269, 269, 269, 269, 269, 212, 271, 269, |
/* 790 */ 89, 269, 214, 207, 269, 269, 286, 269, 272, 222, |
/* 800 */ 98, 269, 72, 269, 269, 269, 269, 269, 269, 269, |
/* 810 */ 212, 271, 269, 89, 269, 214, 207, 269, 269, 163, |
/* 820 */ 269, 272, 222, 115, 269, 72, 269, 269, 269, 269, |
/* 830 */ 269, 269, 269, 212, 271, 269, 89, 269, 214, 207, |
/* 840 */ 272, 269, 47, 269, 63, 222, 269, 269, 269, 269, |
/* 850 */ 269, 269, 212, 271, 269, 89, 269, 214, 207, 269, |
/* 860 */ 269, 269, 269, 272, 222, 49, 269, 72, 269, 269, |
/* 870 */ 269, 269, 269, 269, 269, 212, 271, 269, 89, 269, |
/* 880 */ 214, 207, 269, 269, 269, 269, 272, 222, 111, 269, |
/* 890 */ 72, 269, 269, 269, 269, 269, 269, 269, 212, 271, |
/* 900 */ 269, 89, 269, 214, 207, 269, 269, 269, 269, 272, |
/* 910 */ 222, 104, 269, 72, 269, 269, 269, 269, 269, 269, |
/* 920 */ 269, 212, 271, 269, 89, 269, 214, 207, 272, 269, |
/* 930 */ 113, 269, 72, 222, 269, 269, 269, 269, 269, 269, |
/* 940 */ 212, 271, 269, 89, 269, 214, 207, 269, 269, 269, |
/* 950 */ 269, 272, 222, 117, 269, 72, 269, 269, 269, 269, |
/* 960 */ 269, 269, 269, 212, 271, 269, 89, 269, 214, 207, |
/* 970 */ 269, 269, 269, 269, 272, 222, 127, 269, 72, 269, |
/* 980 */ 269, 269, 269, 269, 269, 269, 212, 271, 269, 89, |
/* 990 */ 269, 214, 207, 269, 269, 269, 269, 272, 222, 116, |
/* 1000 */ 269, 72, 269, 269, 269, 269, 269, 269, 269, 212, |
/* 1010 */ 271, 269, 89, 269, 214, 207, 272, 269, 45, 269, |
/* 1020 */ 63, 222, 269, 269, 269, 269, 269, 269, 212, 271, |
/* 1030 */ 269, 89, 269, 214, 207, 269, 269, 269, 269, 272, |
/* 1040 */ 222, 97, 269, 72, 269, 269, 269, 269, 269, 269, |
/* 1050 */ 269, 212, 271, 269, 89, 269, 214, 207, 269, 269, |
/* 1060 */ 269, 269, 272, 222, 122, 269, 72, 269, 269, 269, |
/* 1070 */ 269, 269, 269, 269, 212, 271, 269, 89, 269, 214, |
/* 1080 */ 207, 269, 269, 269, 269, 272, 222, 120, 269, 72, |
/* 1090 */ 269, 269, 269, 269, 269, 272, 269, 212, 271, 72, |
/* 1100 */ 89, 269, 214, 207, 269, 269, 269, 212, 271, 222, |
/* 1110 */ 86, 269, 214, 207, 272, 269, 272, 269, 72, 222, |
/* 1120 */ 72, 269, 269, 269, 269, 269, 212, 271, 251, 85, |
/* 1130 */ 269, 214, 207, 214, 207, 269, 269, 272, 222, 269, |
/* 1140 */ 222, 72, 269, 269, 269, 269, 269, 269, 269, 212, |
/* 1150 */ 271, 269, 87, 269, 214, 207, 269, 269, 269, 269, |
/* 1160 */ 269, 222, |
); |
static public $yy_lookahead = array( |
/* 0 */ 10, 16, 17, 10, 17, 15, 16, 48, 15, 16, |
/* 10 */ 20, 21, 17, 20, 21, 1, 2, 3, 4, 5, |
/* 20 */ 30, 55, 78, 9, 59, 11, 60, 13, 14, 15, |
/* 30 */ 16, 16, 67, 67, 44, 91, 46, 44, 94, 46, |
/* 40 */ 47, 51, 98, 53, 51, 55, 53, 1, 55, 1, |
/* 50 */ 60, 61, 67, 60, 61, 68, 8, 67, 63, 44, |
/* 60 */ 67, 15, 16, 68, 16, 49, 31, 32, 33, 34, |
/* 70 */ 35, 36, 37, 38, 39, 40, 41, 42, 43, 63, |
/* 80 */ 1, 71, 72, 73, 74, 46, 10, 48, 84, 10, |
/* 90 */ 16, 15, 16, 58, 15, 16, 20, 21, 17, 20, |
/* 100 */ 21, 55, 84, 64, 100, 18, 30, 61, 62, 22, |
/* 110 */ 23, 24, 25, 26, 27, 28, 29, 77, 100, 79, |
/* 120 */ 44, 101, 46, 44, 50, 46, 52, 51, 88, 53, |
/* 130 */ 51, 55, 53, 1, 55, 84, 60, 61, 17, 60, |
/* 140 */ 61, 67, 17, 67, 12, 63, 67, 65, 16, 68, |
/* 150 */ 63, 100, 31, 32, 33, 34, 35, 36, 37, 38, |
/* 160 */ 39, 40, 41, 42, 43, 45, 31, 32, 33, 34, |
/* 170 */ 35, 36, 37, 38, 39, 40, 41, 42, 43, 10, |
/* 180 */ 45, 17, 17, 63, 15, 16, 16, 17, 63, 20, |
/* 190 */ 21, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
/* 200 */ 40, 41, 42, 43, 97, 46, 10, 100, 44, 16, |
/* 210 */ 97, 15, 16, 44, 50, 46, 20, 21, 53, 54, |
/* 220 */ 51, 57, 53, 64, 55, 1, 17, 80, 10, 60, |
/* 230 */ 61, 66, 68, 15, 16, 1, 67, 67, 20, 21, |
/* 240 */ 44, 74, 46, 50, 10, 78, 80, 51, 97, 53, |
/* 250 */ 16, 55, 59, 86, 87, 16, 60, 61, 91, 92, |
/* 260 */ 67, 47, 44, 67, 46, 98, 1, 53, 54, 51, |
/* 270 */ 5, 53, 74, 55, 79, 44, 78, 68, 60, 61, |
/* 280 */ 66, 16, 10, 48, 86, 67, 74, 15, 16, 91, |
/* 290 */ 92, 67, 20, 21, 58, 74, 98, 96, 59, 78, |
/* 300 */ 99, 65, 101, 68, 10, 93, 67, 86, 47, 15, |
/* 310 */ 16, 79, 91, 92, 20, 21, 44, 74, 46, 98, |
/* 320 */ 108, 78, 63, 51, 44, 53, 65, 55, 48, 86, |
/* 330 */ 60, 16, 60, 61, 91, 92, 104, 57, 44, 67, |
/* 340 */ 46, 98, 1, 63, 62, 51, 17, 53, 68, 55, |
/* 350 */ 60, 1, 73, 74, 60, 61, 15, 16, 53, 54, |
/* 360 */ 74, 67, 76, 44, 78, 50, 47, 81, 82, 83, |
/* 370 */ 77, 66, 86, 87, 44, 89, 57, 91, 92, 49, |
/* 380 */ 10, 88, 67, 64, 98, 15, 16, 57, 10, 103, |
/* 390 */ 20, 21, 63, 15, 16, 102, 55, 16, 20, 21, |
/* 400 */ 67, 10, 61, 62, 17, 55, 15, 16, 56, 19, |
/* 410 */ 60, 20, 21, 77, 44, 79, 46, 67, 67, 1, |
/* 420 */ 68, 51, 44, 17, 88, 55, 62, 78, 10, 51, |
/* 430 */ 60, 61, 51, 55, 16, 44, 55, 67, 60, 61, |
/* 440 */ 91, 60, 51, 45, 16, 67, 55, 98, 67, 56, |
/* 450 */ 63, 60, 61, 67, 17, 16, 18, 17, 67, 69, |
/* 460 */ 22, 23, 24, 25, 26, 27, 28, 29, 55, 74, |
/* 470 */ 51, 76, 78, 78, 68, 16, 81, 77, 44, 79, |
/* 480 */ 67, 86, 87, 45, 89, 91, 91, 92, 88, 105, |
/* 490 */ 78, 57, 98, 98, 55, 67, 1, 75, 103, 60, |
/* 500 */ 74, 63, 76, 91, 78, 68, 67, 81, 68, 74, |
/* 510 */ 98, 16, 86, 87, 63, 89, 67, 91, 92, 68, |
/* 520 */ 75, 74, 19, 76, 98, 78, 67, 96, 81, 103, |
/* 530 */ 84, 109, 101, 86, 87, 55, 89, 77, 91, 92, |
/* 540 */ 74, 67, 76, 108, 78, 98, 100, 81, 88, 84, |
/* 550 */ 103, 75, 86, 87, 109, 89, 77, 91, 92, 74, |
/* 560 */ 48, 76, 50, 78, 98, 100, 81, 88, 96, 103, |
/* 570 */ 45, 86, 87, 101, 89, 75, 91, 92, 85, 47, |
/* 580 */ 84, 64, 74, 98, 76, 109, 78, 96, 103, 81, |
/* 590 */ 45, 67, 101, 100, 86, 87, 100, 89, 67, 91, |
/* 600 */ 92, 55, 69, 74, 55, 76, 98, 78, 67, 109, |
/* 610 */ 81, 103, 50, 17, 67, 86, 87, 67, 89, 55, |
/* 620 */ 91, 92, 74, 17, 76, 5, 78, 98, 90, 81, |
/* 630 */ 17, 97, 103, 97, 86, 87, 99, 89, 56, 91, |
/* 640 */ 92, 74, 88, 76, 109, 78, 98, 55, 81, 44, |
/* 650 */ 82, 103, 100, 86, 87, 102, 89, 97, 91, 92, |
/* 660 */ 94, 68, 110, 110, 74, 98, 76, 110, 78, 110, |
/* 670 */ 103, 81, 110, 110, 110, 110, 86, 87, 110, 89, |
/* 680 */ 110, 91, 92, 110, 110, 74, 110, 76, 98, 78, |
/* 690 */ 110, 110, 110, 103, 110, 110, 110, 86, 87, 110, |
/* 700 */ 89, 110, 91, 92, 110, 110, 110, 110, 110, 98, |
/* 710 */ 74, 110, 76, 110, 78, 110, 110, 106, 107, 110, |
/* 720 */ 110, 110, 86, 87, 110, 89, 110, 91, 92, 74, |
/* 730 */ 110, 76, 110, 78, 98, 110, 110, 110, 110, 110, |
/* 740 */ 110, 86, 87, 107, 89, 110, 91, 92, 110, 110, |
/* 750 */ 95, 110, 74, 98, 76, 110, 78, 110, 110, 110, |
/* 760 */ 110, 110, 110, 110, 86, 87, 110, 89, 110, 91, |
/* 770 */ 92, 110, 110, 95, 110, 74, 98, 76, 110, 78, |
/* 780 */ 110, 110, 110, 110, 110, 110, 110, 86, 87, 110, |
/* 790 */ 89, 110, 91, 92, 110, 110, 95, 110, 74, 98, |
/* 800 */ 76, 110, 78, 110, 110, 110, 110, 110, 110, 110, |
/* 810 */ 86, 87, 110, 89, 110, 91, 92, 110, 110, 95, |
/* 820 */ 110, 74, 98, 76, 110, 78, 110, 110, 110, 110, |
/* 830 */ 110, 110, 110, 86, 87, 110, 89, 110, 91, 92, |
/* 840 */ 74, 110, 76, 110, 78, 98, 110, 110, 110, 110, |
/* 850 */ 110, 110, 86, 87, 110, 89, 110, 91, 92, 110, |
/* 860 */ 110, 110, 110, 74, 98, 76, 110, 78, 110, 110, |
/* 870 */ 110, 110, 110, 110, 110, 86, 87, 110, 89, 110, |
/* 880 */ 91, 92, 110, 110, 110, 110, 74, 98, 76, 110, |
/* 890 */ 78, 110, 110, 110, 110, 110, 110, 110, 86, 87, |
/* 900 */ 110, 89, 110, 91, 92, 110, 110, 110, 110, 74, |
/* 910 */ 98, 76, 110, 78, 110, 110, 110, 110, 110, 110, |
/* 920 */ 110, 86, 87, 110, 89, 110, 91, 92, 74, 110, |
/* 930 */ 76, 110, 78, 98, 110, 110, 110, 110, 110, 110, |
/* 940 */ 86, 87, 110, 89, 110, 91, 92, 110, 110, 110, |
/* 950 */ 110, 74, 98, 76, 110, 78, 110, 110, 110, 110, |
/* 960 */ 110, 110, 110, 86, 87, 110, 89, 110, 91, 92, |
/* 970 */ 110, 110, 110, 110, 74, 98, 76, 110, 78, 110, |
/* 980 */ 110, 110, 110, 110, 110, 110, 86, 87, 110, 89, |
/* 990 */ 110, 91, 92, 110, 110, 110, 110, 74, 98, 76, |
/* 1000 */ 110, 78, 110, 110, 110, 110, 110, 110, 110, 86, |
/* 1010 */ 87, 110, 89, 110, 91, 92, 74, 110, 76, 110, |
/* 1020 */ 78, 98, 110, 110, 110, 110, 110, 110, 86, 87, |
/* 1030 */ 110, 89, 110, 91, 92, 110, 110, 110, 110, 74, |
/* 1040 */ 98, 76, 110, 78, 110, 110, 110, 110, 110, 110, |
/* 1050 */ 110, 86, 87, 110, 89, 110, 91, 92, 110, 110, |
/* 1060 */ 110, 110, 74, 98, 76, 110, 78, 110, 110, 110, |
/* 1070 */ 110, 110, 110, 110, 86, 87, 110, 89, 110, 91, |
/* 1080 */ 92, 110, 110, 110, 110, 74, 98, 76, 110, 78, |
/* 1090 */ 110, 110, 110, 110, 110, 74, 110, 86, 87, 78, |
/* 1100 */ 89, 110, 91, 92, 110, 110, 110, 86, 87, 98, |
/* 1110 */ 89, 110, 91, 92, 74, 110, 74, 110, 78, 98, |
/* 1120 */ 78, 110, 110, 110, 110, 110, 86, 87, 86, 89, |
/* 1130 */ 110, 91, 92, 91, 92, 110, 110, 74, 98, 110, |
/* 1140 */ 98, 78, 110, 110, 110, 110, 110, 110, 110, 86, |
/* 1150 */ 87, 110, 89, 110, 91, 92, 110, 110, 110, 110, |
/* 1160 */ 110, 98, |
); |
const YY_SHIFT_USE_DFLT = -42; |
const YY_SHIFT_MAX = 177; |
static public $yy_shift_ofst = array( |
/* 0 */ 14, 76, -10, -10, -10, -10, -10, -10, -10, -10, |
/* 10 */ -10, -10, 294, 169, 169, 294, 169, 169, 79, 169, |
/* 20 */ 169, 169, 169, 169, 169, 272, 169, 169, 169, 169, |
/* 30 */ 169, -7, 196, 218, 370, 378, 378, 378, 391, 439, |
/* 40 */ 341, 280, 381, 350, 39, -5, -34, 451, 352, 451, |
/* 50 */ 438, 14, 87, 46, 193, 74, 418, 239, 459, 235, |
/* 60 */ 495, 428, 428, 512, 428, 428, 459, 495, 428, 495, |
/* 70 */ -41, 593, -41, -41, 121, 135, 35, 160, 160, 160, |
/* 80 */ 160, 160, 160, 160, 160, 165, 214, 305, 315, 305, |
/* 90 */ 234, -15, 265, 170, 48, 132, -13, 125, 82, 16, |
/* 100 */ 406, 209, 81, 15, 387, 159, 159, 440, 437, 159, |
/* 110 */ 159, 329, 413, 120, 159, 259, 259, 259, 582, 592, |
/* 120 */ 259, 605, 259, -41, -41, -41, -41, 259, -42, -42, |
/* 130 */ -42, -42, -42, 164, 319, 330, 236, 434, 434, -35, |
/* 140 */ 434, 434, 224, 261, 390, 613, 533, 549, 546, 231, |
/* 150 */ 545, 524, 531, 541, 562, 606, 620, 550, 564, 547, |
/* 160 */ 596, 517, 532, 398, 393, 351, 333, 270, 282, 290, |
/* 170 */ 364, 386, 474, 525, 480, 503, 419, 449, |
); |
const YY_REDUCE_USE_DFLT = -57; |
const YY_REDUCE_MAX = 132; |
static public $yy_reduce_ofst = array( |
/* 0 */ 10, 286, 395, 485, 466, 508, 529, 548, 447, 426, |
/* 10 */ 590, 567, 611, 724, 655, 636, 701, 678, 942, 812, |
/* 20 */ 1011, 923, 877, 854, 835, 766, 789, 965, 988, 900, |
/* 30 */ 747, 1021, 1040, 1063, 167, 243, 198, 221, 1042, -56, |
/* 40 */ 212, 336, 349, 394, 201, 40, 412, 40, 293, 400, |
/* 50 */ 232, 279, 232, 435, 107, 493, 500, 107, 496, 460, |
/* 60 */ 445, 446, 4, 431, 51, 465, 4, 422, 18, 476, |
/* 70 */ 491, 479, 431, 472, 384, 384, 384, 384, 384, 384, |
/* 80 */ 384, 384, 384, 384, 384, 538, 538, 538, 552, 538, |
/* 90 */ 535, 552, 535, 552, 535, 535, 554, 195, 195, 195, |
/* 100 */ 554, 554, 554, 536, 195, 537, 537, 554, 554, 537, |
/* 110 */ 537, 195, 566, 195, 537, 195, 195, 195, 553, 568, |
/* 120 */ 195, 560, 195, 20, 20, 20, 20, 195, 151, 147, |
/* 130 */ 113, 166, 534, |
); |
static public $yyExpectedTokens = array( |
/* 0 */ array(1, 2, 3, 4, 5, 9, 11, 13, 14, 15, 16, ), |
/* 1 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 2 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 3 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 4 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 5 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 6 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 7 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 8 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 9 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 10 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 11 */ array(10, 15, 16, 20, 21, 30, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 12 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 13 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 14 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 15 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 16 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 17 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 18 */ array(1, 10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 19 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 20 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 21 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 22 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 23 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 24 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 25 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 26 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 27 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 28 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 29 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 30 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 31 */ array(10, 15, 16, 20, 21, 44, 46, 47, 51, 53, 55, 60, 61, 67, ), |
/* 32 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 33 */ array(10, 15, 16, 20, 21, 44, 46, 51, 53, 55, 60, 61, 67, ), |
/* 34 */ array(10, 15, 16, 20, 21, 44, 46, 51, 55, 60, 61, 67, ), |
/* 35 */ array(10, 15, 16, 20, 21, 44, 51, 55, 60, 61, 67, ), |
/* 36 */ array(10, 15, 16, 20, 21, 44, 51, 55, 60, 61, 67, ), |
/* 37 */ array(10, 15, 16, 20, 21, 44, 51, 55, 60, 61, 67, ), |
/* 38 */ array(10, 15, 16, 20, 21, 44, 51, 55, 60, 61, 67, ), |
/* 39 */ array(16, 55, 60, 67, ), |
/* 40 */ array(1, 15, 16, 55, 61, 62, ), |
/* 41 */ array(44, 48, 57, 63, 68, ), |
/* 42 */ array(16, 51, 55, 60, 67, ), |
/* 43 */ array(1, 55, 60, 67, ), |
/* 44 */ array(46, 48, 64, ), |
/* 45 */ array(17, 63, 68, ), |
/* 46 */ array(55, 60, 67, ), |
/* 47 */ array(63, 68, ), |
/* 48 */ array(56, 68, ), |
/* 49 */ array(63, 68, ), |
/* 50 */ array(18, 22, 23, 24, 25, 26, 27, 28, 29, 45, 63, ), |
/* 51 */ array(1, 2, 3, 4, 5, 9, 11, 13, 14, 15, 16, ), |
/* 52 */ array(18, 22, 23, 24, 25, 26, 27, 28, 29, 63, ), |
/* 53 */ array(1, 15, 16, 55, 61, 62, ), |
/* 54 */ array(16, 50, 59, 67, ), |
/* 55 */ array(16, 50, 52, 67, ), |
/* 56 */ array(1, 10, 16, ), |
/* 57 */ array(16, 59, 67, ), |
/* 58 */ array(16, 67, ), |
/* 59 */ array(48, 68, ), |
/* 60 */ array(1, 16, ), |
/* 61 */ array(16, 67, ), |
/* 62 */ array(16, 67, ), |
/* 63 */ array(48, 50, ), |
/* 64 */ array(16, 67, ), |
/* 65 */ array(16, 67, ), |
/* 66 */ array(16, 67, ), |
/* 67 */ array(1, 16, ), |
/* 68 */ array(16, 67, ), |
/* 69 */ array(1, 16, ), |
/* 70 */ array(48, ), |
/* 71 */ array(68, ), |
/* 72 */ array(48, ), |
/* 73 */ array(48, ), |
/* 74 */ array(17, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 75 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, ), |
/* 76 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 58, ), |
/* 77 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 78 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 79 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 80 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 81 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 82 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 83 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 84 */ array(31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, ), |
/* 85 */ array(17, 53, 54, 66, ), |
/* 86 */ array(47, 53, 54, 66, ), |
/* 87 */ array(53, 54, 66, ), |
/* 88 */ array(16, 50, 67, ), |
/* 89 */ array(53, 54, 66, ), |
/* 90 */ array(1, 10, 16, ), |
/* 91 */ array(16, 17, 67, ), |
/* 92 */ array(1, 5, 16, ), |
/* 93 */ array(16, 17, 67, ), |
/* 94 */ array(1, 8, 16, ), |
/* 95 */ array(1, 12, 16, ), |
/* 96 */ array(17, 68, ), |
/* 97 */ array(17, 63, ), |
/* 98 */ array(63, 65, ), |
/* 99 */ array(49, 63, ), |
/* 100 */ array(17, 68, ), |
/* 101 */ array(17, 68, ), |
/* 102 */ array(17, 68, ), |
/* 103 */ array(16, 44, ), |
/* 104 */ array(17, 63, ), |
/* 105 */ array(46, 64, ), |
/* 106 */ array(46, 64, ), |
/* 107 */ array(17, 68, ), |
/* 108 */ array(17, 68, ), |
/* 109 */ array(46, 64, ), |
/* 110 */ array(46, 64, ), |
/* 111 */ array(17, 63, ), |
/* 112 */ array(55, 67, ), |
/* 113 */ array(45, 63, ), |
/* 114 */ array(46, 64, ), |
/* 115 */ array(63, ), |
/* 116 */ array(63, ), |
/* 117 */ array(63, ), |
/* 118 */ array(56, ), |
/* 119 */ array(55, ), |
/* 120 */ array(63, ), |
/* 121 */ array(44, ), |
/* 122 */ array(63, ), |
/* 123 */ array(48, ), |
/* 124 */ array(48, ), |
/* 125 */ array(48, ), |
/* 126 */ array(48, ), |
/* 127 */ array(63, ), |
/* 128 */ array(), |
/* 129 */ array(), |
/* 130 */ array(), |
/* 131 */ array(), |
/* 132 */ array(), |
/* 133 */ array(17, 44, 50, 57, 68, ), |
/* 134 */ array(44, 47, 57, 64, ), |
/* 135 */ array(44, 49, 57, ), |
/* 136 */ array(58, 65, ), |
/* 137 */ array(44, 57, ), |
/* 138 */ array(44, 57, ), |
/* 139 */ array(59, 67, ), |
/* 140 */ array(44, 57, ), |
/* 141 */ array(44, 57, ), |
/* 142 */ array(1, 67, ), |
/* 143 */ array(47, 65, ), |
/* 144 */ array(19, 69, ), |
/* 145 */ array(17, ), |
/* 146 */ array(69, ), |
/* 147 */ array(55, ), |
/* 148 */ array(55, ), |
/* 149 */ array(44, ), |
/* 150 */ array(45, ), |
/* 151 */ array(67, ), |
/* 152 */ array(67, ), |
/* 153 */ array(67, ), |
/* 154 */ array(50, ), |
/* 155 */ array(17, ), |
/* 156 */ array(5, ), |
/* 157 */ array(67, ), |
/* 158 */ array(55, ), |
/* 159 */ array(67, ), |
/* 160 */ array(17, ), |
/* 161 */ array(64, ), |
/* 162 */ array(47, ), |
/* 163 */ array(45, ), |
/* 164 */ array(56, ), |
/* 165 */ array(67, ), |
/* 166 */ array(67, ), |
/* 167 */ array(60, ), |
/* 168 */ array(62, ), |
/* 169 */ array(60, ), |
/* 170 */ array(62, ), |
/* 171 */ array(67, ), |
/* 172 */ array(67, ), |
/* 173 */ array(45, ), |
/* 174 */ array(55, ), |
/* 175 */ array(19, ), |
/* 176 */ array(51, ), |
/* 177 */ array(67, ), |
/* 178 */ array(), |
/* 179 */ array(), |
/* 180 */ array(), |
/* 181 */ array(), |
/* 182 */ array(), |
/* 183 */ array(), |
/* 184 */ array(), |
/* 185 */ array(), |
/* 186 */ array(), |
/* 187 */ array(), |
/* 188 */ array(), |
/* 189 */ array(), |
/* 190 */ array(), |
/* 191 */ array(), |
/* 192 */ array(), |
/* 193 */ array(), |
/* 194 */ array(), |
/* 195 */ array(), |
/* 196 */ array(), |
/* 197 */ array(), |
/* 198 */ array(), |
/* 199 */ array(), |
/* 200 */ array(), |
/* 201 */ array(), |
/* 202 */ array(), |
/* 203 */ array(), |
/* 204 */ array(), |
/* 205 */ array(), |
/* 206 */ array(), |
/* 207 */ array(), |
/* 208 */ array(), |
/* 209 */ array(), |
/* 210 */ array(), |
/* 211 */ array(), |
/* 212 */ array(), |
/* 213 */ array(), |
/* 214 */ array(), |
/* 215 */ array(), |
/* 216 */ array(), |
/* 217 */ array(), |
/* 218 */ array(), |
/* 219 */ array(), |
/* 220 */ array(), |
/* 221 */ array(), |
/* 222 */ array(), |
/* 223 */ array(), |
/* 224 */ array(), |
/* 225 */ array(), |
/* 226 */ array(), |
/* 227 */ array(), |
/* 228 */ array(), |
/* 229 */ array(), |
/* 230 */ array(), |
/* 231 */ array(), |
/* 232 */ array(), |
/* 233 */ array(), |
/* 234 */ array(), |
/* 235 */ array(), |
/* 236 */ array(), |
/* 237 */ array(), |
/* 238 */ array(), |
/* 239 */ array(), |
/* 240 */ array(), |
/* 241 */ array(), |
/* 242 */ array(), |
/* 243 */ array(), |
/* 244 */ array(), |
/* 245 */ array(), |
/* 246 */ array(), |
/* 247 */ array(), |
/* 248 */ array(), |
/* 249 */ array(), |
/* 250 */ array(), |
/* 251 */ array(), |
/* 252 */ array(), |
/* 253 */ array(), |
/* 254 */ array(), |
/* 255 */ array(), |
/* 256 */ array(), |
/* 257 */ array(), |
/* 258 */ array(), |
/* 259 */ array(), |
/* 260 */ array(), |
/* 261 */ array(), |
/* 262 */ array(), |
/* 263 */ array(), |
/* 264 */ array(), |
/* 265 */ array(), |
/* 266 */ array(), |
/* 267 */ array(), |
/* 268 */ array(), |
/* 269 */ array(), |
/* 270 */ array(), |
/* 271 */ array(), |
/* 272 */ array(), |
/* 273 */ array(), |
/* 274 */ array(), |
/* 275 */ array(), |
/* 276 */ array(), |
/* 277 */ array(), |
/* 278 */ array(), |
/* 279 */ array(), |
/* 280 */ array(), |
/* 281 */ array(), |
/* 282 */ array(), |
/* 283 */ array(), |
/* 284 */ array(), |
/* 285 */ array(), |
/* 286 */ array(), |
/* 287 */ array(), |
/* 288 */ array(), |
); |
static public $yy_default = array( |
/* 0 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, |
/* 10 */ 446, 446, 427, 386, 386, 446, 386, 386, 446, 446, |
/* 20 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, |
/* 30 */ 446, 446, 446, 446, 446, 446, 446, 446, 446, 446, |
/* 40 */ 446, 318, 446, 446, 351, 446, 446, 318, 318, 318, |
/* 50 */ 396, 289, 396, 446, 361, 446, 446, 361, 446, 318, |
/* 60 */ 446, 446, 446, 354, 446, 446, 446, 446, 446, 446, |
/* 70 */ 347, 318, 354, 346, 446, 446, 446, 410, 400, 405, |
/* 80 */ 402, 409, 394, 401, 406, 446, 446, 391, 446, 325, |
/* 90 */ 446, 446, 446, 446, 446, 446, 446, 446, 385, 430, |
/* 100 */ 446, 446, 446, 361, 446, 377, 378, 446, 446, 379, |
/* 110 */ 359, 446, 446, 446, 380, 428, 397, 319, 327, 446, |
/* 120 */ 323, 361, 429, 352, 349, 348, 374, 310, 361, 390, |
/* 130 */ 361, 390, 361, 324, 446, 324, 446, 324, 411, 446, |
/* 140 */ 446, 392, 446, 446, 328, 321, 328, 446, 446, 350, |
/* 150 */ 446, 446, 446, 446, 320, 446, 446, 446, 446, 446, |
/* 160 */ 446, 336, 446, 446, 372, 446, 446, 446, 446, 446, |
/* 170 */ 446, 446, 446, 446, 446, 332, 446, 446, 438, 432, |
/* 180 */ 433, 345, 440, 437, 365, 290, 441, 434, 309, 366, |
/* 190 */ 367, 322, 369, 313, 383, 435, 439, 344, 368, 371, |
/* 200 */ 381, 312, 431, 372, 311, 305, 339, 340, 376, 375, |
/* 210 */ 338, 337, 328, 329, 335, 355, 360, 364, 330, 342, |
/* 220 */ 363, 362, 356, 357, 358, 389, 317, 445, 443, 294, |
/* 230 */ 295, 444, 442, 291, 292, 293, 296, 297, 316, 314, |
/* 240 */ 315, 302, 301, 298, 299, 300, 343, 387, 418, 419, |
/* 250 */ 420, 412, 417, 416, 413, 414, 415, 341, 393, 422, |
/* 260 */ 423, 395, 421, 408, 403, 404, 407, 399, 398, 370, |
/* 270 */ 373, 332, 353, 326, 331, 388, 436, 303, 424, 426, |
/* 280 */ 304, 306, 307, 334, 333, 425, 384, 382, 308, |
); |
/* The next thing included is series of defines which control |
** various aspects of the generated parser. |
** self::YYNOCODE is a number which corresponds |
** to no legal terminal or nonterminal number. This |
** number is used to fill in empty slots of the hash |
** table. |
** self::YYFALLBACK If defined, this indicates that one or more tokens |
** have fall-back values which should be used if the |
** original value of the token will not parse. |
** self::YYSTACKDEPTH is the maximum depth of the parser's stack. |
** self::YYNSTATE the combined number of states. |
** self::YYNRULE the number of rules in the grammar |
** self::YYERRORSYMBOL is the code number of the error symbol. If not |
** defined, then do no error processing. |
*/ |
const YYNOCODE = 111; |
const YYSTACKDEPTH = 100; |
const YYNSTATE = 289; |
const YYNRULE = 157; |
const YYERRORSYMBOL = 70; |
const YYERRSYMDT = 'yy0'; |
const YYFALLBACK = 1; |
/** The next table maps tokens into fallback tokens. If a construct |
* like the following: |
* |
* %fallback ID X Y Z. |
* |
* appears in the grammer, then ID becomes a fallback token for X, Y, |
* and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
* but it does not parse, the type of the token is changed to ID and |
* the parse is retried before an error is thrown. |
*/ |
static public $yyFallback = array( |
0, /* $ => nothing */ |
0, /* OTHER => nothing */ |
1, /* XML => OTHER */ |
1, /* PHP => OTHER */ |
1, /* SHORTTAGSTART => OTHER */ |
1, /* SHORTTAGEND => OTHER */ |
1, /* PHPSTART => OTHER */ |
1, /* PHPEND => OTHER */ |
1, /* COMMENTEND => OTHER */ |
1, /* COMMENTSTART => OTHER */ |
1, /* SINGLEQUOTE => OTHER */ |
1, /* LITERALSTART => OTHER */ |
1, /* LITERALEND => OTHER */ |
1, /* LDELIMTAG => OTHER */ |
1, /* RDELIMTAG => OTHER */ |
1, /* LDELSLASH => OTHER */ |
1, /* LDEL => OTHER */ |
1, /* RDEL => OTHER */ |
1, /* ISIN => OTHER */ |
1, /* AS => OTHER */ |
1, /* BOOLEAN => OTHER */ |
1, /* NULL => OTHER */ |
1, /* IDENTITY => OTHER */ |
1, /* NONEIDENTITY => OTHER */ |
1, /* EQUALS => OTHER */ |
1, /* NOTEQUALS => OTHER */ |
1, /* GREATEREQUAL => OTHER */ |
1, /* LESSEQUAL => OTHER */ |
1, /* GREATERTHAN => OTHER */ |
1, /* LESSTHAN => OTHER */ |
1, /* NOT => OTHER */ |
1, /* LAND => OTHER */ |
1, /* LOR => OTHER */ |
1, /* LXOR => OTHER */ |
1, /* ISODDBY => OTHER */ |
1, /* ISNOTODDBY => OTHER */ |
1, /* ISODD => OTHER */ |
1, /* ISNOTODD => OTHER */ |
1, /* ISEVENBY => OTHER */ |
1, /* ISNOTEVENBY => OTHER */ |
1, /* ISEVEN => OTHER */ |
1, /* ISNOTEVEN => OTHER */ |
1, /* ISDIVBY => OTHER */ |
1, /* ISNOTDIVBY => OTHER */ |
1, /* OPENP => OTHER */ |
1, /* CLOSEP => OTHER */ |
1, /* OPENB => OTHER */ |
1, /* CLOSEB => OTHER */ |
1, /* PTR => OTHER */ |
1, /* APTR => OTHER */ |
1, /* EQUAL => OTHER */ |
1, /* INTEGER => OTHER */ |
1, /* INCDEC => OTHER */ |
1, /* UNIMATH => OTHER */ |
1, /* MATH => OTHER */ |
1, /* DOLLAR => OTHER */ |
1, /* COLON => OTHER */ |
1, /* DOUBLECOLON => OTHER */ |
1, /* SEMICOLON => OTHER */ |
1, /* AT => OTHER */ |
1, /* HATCH => OTHER */ |
1, /* QUOTE => OTHER */ |
1, /* BACKTICK => OTHER */ |
1, /* VERT => OTHER */ |
1, /* DOT => OTHER */ |
1, /* COMMA => OTHER */ |
1, /* ANDSYM => OTHER */ |
1, /* ID => OTHER */ |
1, /* SPACE => OTHER */ |
1, /* INSTANCEOF => OTHER */ |
); |
/** |
* Turn parser tracing on by giving a stream to which to write the trace |
* and a prompt to preface each trace message. Tracing is turned off |
* by making either argument NULL |
* |
* Inputs: |
* |
* - A stream resource to which trace output should be written. |
* If NULL, then tracing is turned off. |
* - A prefix string written at the beginning of every |
* line of trace output. If NULL, then tracing is |
* turned off. |
* |
* Outputs: |
* |
* - None. |
* @param resource |
* @param string |
*/ |
static function Trace($TraceFILE, $zTracePrompt) |
{ |
if (!$TraceFILE) { |
$zTracePrompt = 0; |
} elseif (!$zTracePrompt) { |
$TraceFILE = 0; |
} |
self::$yyTraceFILE = $TraceFILE; |
self::$yyTracePrompt = $zTracePrompt; |
} |
/** |
* Output debug information to output (php://output stream) |
*/ |
static function PrintTrace() |
{ |
self::$yyTraceFILE = fopen('php://output', 'w'); |
self::$yyTracePrompt = '<br>'; |
} |
/** |
* @var resource|0 |
*/ |
static public $yyTraceFILE; |
/** |
* String to prepend to debug output |
* @var string|0 |
*/ |
static public $yyTracePrompt; |
/** |
* @var int |
*/ |
public $yyidx; /* Index of top element in stack */ |
/** |
* @var int |
*/ |
public $yyerrcnt; /* Shifts left before out of the error */ |
/** |
* @var array |
*/ |
public $yystack = array(); /* The parser's stack */ |
/** |
* For tracing shifts, the names of all terminals and nonterminals |
* are required. The following table supplies these names |
* @var array |
*/ |
public $yyTokenName = array( |
'$', 'OTHER', 'XML', 'PHP', |
'SHORTTAGSTART', 'SHORTTAGEND', 'PHPSTART', 'PHPEND', |
'COMMENTEND', 'COMMENTSTART', 'SINGLEQUOTE', 'LITERALSTART', |
'LITERALEND', 'LDELIMTAG', 'RDELIMTAG', 'LDELSLASH', |
'LDEL', 'RDEL', 'ISIN', 'AS', |
'BOOLEAN', 'NULL', 'IDENTITY', 'NONEIDENTITY', |
'EQUALS', 'NOTEQUALS', 'GREATEREQUAL', 'LESSEQUAL', |
'GREATERTHAN', 'LESSTHAN', 'NOT', 'LAND', |
'LOR', 'LXOR', 'ISODDBY', 'ISNOTODDBY', |
'ISODD', 'ISNOTODD', 'ISEVENBY', 'ISNOTEVENBY', |
'ISEVEN', 'ISNOTEVEN', 'ISDIVBY', 'ISNOTDIVBY', |
'OPENP', 'CLOSEP', 'OPENB', 'CLOSEB', |
'PTR', 'APTR', 'EQUAL', 'INTEGER', |
'INCDEC', 'UNIMATH', 'MATH', 'DOLLAR', |
'COLON', 'DOUBLECOLON', 'SEMICOLON', 'AT', |
'HATCH', 'QUOTE', 'BACKTICK', 'VERT', |
'DOT', 'COMMA', 'ANDSYM', 'ID', |
'SPACE', 'INSTANCEOF', 'error', 'start', |
'template', 'template_element', 'smartytag', 'text', |
'expr', 'attributes', 'varindexed', 'modifier', |
'modparameters', 'ifexprs', 'statement', 'statements', |
'varvar', 'foraction', 'value', 'array', |
'attribute', 'exprs', 'math', 'variable', |
'function', 'doublequoted', 'method', 'params', |
'objectchain', 'arrayindex', 'object', 'indexdef', |
'varvarele', 'objectelement', 'modparameter', 'ifexpr', |
'ifcond', 'lop', 'arrayelements', 'arrayelement', |
'doublequotedcontent', 'textelement', |
); |
/** |
* For tracing reduce actions, the names of all rules are required. |
* @var array |
*/ |
static public $yyRuleName = array( |
/* 0 */ "start ::= template", |
/* 1 */ "template ::= template_element", |
/* 2 */ "template ::= template template_element", |
/* 3 */ "template_element ::= smartytag", |
/* 4 */ "template_element ::= COMMENTSTART text COMMENTEND", |
/* 5 */ "template_element ::= LITERALSTART text LITERALEND", |
/* 6 */ "template_element ::= LDELIMTAG", |
/* 7 */ "template_element ::= RDELIMTAG", |
/* 8 */ "template_element ::= PHP text SHORTTAGEND", |
/* 9 */ "template_element ::= SHORTTAGSTART DOLLAR ID SHORTTAGEND", |
/* 10 */ "template_element ::= XML", |
/* 11 */ "template_element ::= SHORTTAGEND", |
/* 12 */ "template_element ::= OTHER", |
/* 13 */ "smartytag ::= LDEL expr attributes RDEL", |
/* 14 */ "smartytag ::= LDEL varindexed EQUAL expr attributes RDEL", |
/* 15 */ "smartytag ::= LDEL ID attributes RDEL", |
/* 16 */ "smartytag ::= LDEL ID PTR ID attributes RDEL", |
/* 17 */ "smartytag ::= LDEL ID modifier modparameters attributes RDEL", |
/* 18 */ "smartytag ::= LDEL ID SPACE ifexprs RDEL", |
/* 19 */ "smartytag ::= LDEL ID SPACE statement RDEL", |
/* 20 */ "smartytag ::= LDEL ID SPACE statements SEMICOLON ifexprs SEMICOLON DOLLAR varvar foraction RDEL", |
/* 21 */ "foraction ::= EQUAL expr", |
/* 22 */ "foraction ::= INCDEC", |
/* 23 */ "smartytag ::= LDEL ID SPACE value AS DOLLAR varvar RDEL", |
/* 24 */ "smartytag ::= LDEL ID SPACE array AS DOLLAR varvar RDEL", |
/* 25 */ "smartytag ::= LDELSLASH ID attributes RDEL", |
/* 26 */ "smartytag ::= LDELSLASH ID PTR ID RDEL", |
/* 27 */ "attributes ::= attributes attribute", |
/* 28 */ "attributes ::= attribute", |
/* 29 */ "attributes ::=", |
/* 30 */ "attribute ::= SPACE ID EQUAL expr", |
/* 31 */ "attribute ::= SPACE ID", |
/* 32 */ "statements ::= statement", |
/* 33 */ "statements ::= statements COMMA statement", |
/* 34 */ "statement ::= DOLLAR varvar EQUAL expr", |
/* 35 */ "expr ::= ID", |
/* 36 */ "expr ::= exprs", |
/* 37 */ "expr ::= DOLLAR ID COLON ID", |
/* 38 */ "expr ::= expr modifier modparameters", |
/* 39 */ "exprs ::= value", |
/* 40 */ "exprs ::= UNIMATH value", |
/* 41 */ "exprs ::= exprs math value", |
/* 42 */ "exprs ::= exprs ANDSYM value", |
/* 43 */ "exprs ::= array", |
/* 44 */ "math ::= UNIMATH", |
/* 45 */ "math ::= MATH", |
/* 46 */ "value ::= variable", |
/* 47 */ "value ::= INTEGER", |
/* 48 */ "value ::= INTEGER DOT INTEGER", |
/* 49 */ "value ::= BOOLEAN", |
/* 50 */ "value ::= NULL", |
/* 51 */ "value ::= function", |
/* 52 */ "value ::= OPENP expr CLOSEP", |
/* 53 */ "value ::= SINGLEQUOTE text SINGLEQUOTE", |
/* 54 */ "value ::= SINGLEQUOTE SINGLEQUOTE", |
/* 55 */ "value ::= QUOTE doublequoted QUOTE", |
/* 56 */ "value ::= QUOTE QUOTE", |
/* 57 */ "value ::= ID DOUBLECOLON method", |
/* 58 */ "value ::= ID DOUBLECOLON DOLLAR ID OPENP params CLOSEP", |
/* 59 */ "value ::= ID DOUBLECOLON method objectchain", |
/* 60 */ "value ::= ID DOUBLECOLON DOLLAR ID OPENP params CLOSEP objectchain", |
/* 61 */ "value ::= ID DOUBLECOLON ID", |
/* 62 */ "value ::= ID DOUBLECOLON DOLLAR ID arrayindex", |
/* 63 */ "value ::= ID DOUBLECOLON DOLLAR ID arrayindex objectchain", |
/* 64 */ "value ::= smartytag", |
/* 65 */ "variable ::= varindexed", |
/* 66 */ "variable ::= DOLLAR varvar AT ID", |
/* 67 */ "variable ::= object", |
/* 68 */ "variable ::= HATCH ID HATCH", |
/* 69 */ "variable ::= HATCH variable HATCH", |
/* 70 */ "varindexed ::= DOLLAR varvar arrayindex", |
/* 71 */ "arrayindex ::= arrayindex indexdef", |
/* 72 */ "arrayindex ::=", |
/* 73 */ "indexdef ::= DOT ID", |
/* 74 */ "indexdef ::= DOT INTEGER", |
/* 75 */ "indexdef ::= DOT variable", |
/* 76 */ "indexdef ::= DOT LDEL exprs RDEL", |
/* 77 */ "indexdef ::= OPENB ID CLOSEB", |
/* 78 */ "indexdef ::= OPENB ID DOT ID CLOSEB", |
/* 79 */ "indexdef ::= OPENB exprs CLOSEB", |
/* 80 */ "indexdef ::= OPENB CLOSEB", |
/* 81 */ "varvar ::= varvarele", |
/* 82 */ "varvar ::= varvar varvarele", |
/* 83 */ "varvarele ::= ID", |
/* 84 */ "varvarele ::= LDEL expr RDEL", |
/* 85 */ "object ::= varindexed objectchain", |
/* 86 */ "objectchain ::= objectelement", |
/* 87 */ "objectchain ::= objectchain objectelement", |
/* 88 */ "objectelement ::= PTR ID arrayindex", |
/* 89 */ "objectelement ::= PTR variable arrayindex", |
/* 90 */ "objectelement ::= PTR LDEL expr RDEL arrayindex", |
/* 91 */ "objectelement ::= PTR ID LDEL expr RDEL arrayindex", |
/* 92 */ "objectelement ::= PTR method", |
/* 93 */ "function ::= ID OPENP params CLOSEP", |
/* 94 */ "method ::= ID OPENP params CLOSEP", |
/* 95 */ "params ::= expr COMMA params", |
/* 96 */ "params ::= expr", |
/* 97 */ "params ::=", |
/* 98 */ "modifier ::= VERT AT ID", |
/* 99 */ "modifier ::= VERT ID", |
/* 100 */ "modparameters ::= modparameters modparameter", |
/* 101 */ "modparameters ::=", |
/* 102 */ "modparameter ::= COLON exprs", |
/* 103 */ "modparameter ::= COLON ID", |
/* 104 */ "ifexprs ::= ifexpr", |
/* 105 */ "ifexprs ::= NOT ifexprs", |
/* 106 */ "ifexprs ::= OPENP ifexprs CLOSEP", |
/* 107 */ "ifexpr ::= expr", |
/* 108 */ "ifexpr ::= expr ifcond expr", |
/* 109 */ "ifexpr ::= expr ISIN array", |
/* 110 */ "ifexpr ::= expr ISIN value", |
/* 111 */ "ifexpr ::= ifexprs lop ifexprs", |
/* 112 */ "ifexpr ::= ifexprs ISDIVBY ifexprs", |
/* 113 */ "ifexpr ::= ifexprs ISNOTDIVBY ifexprs", |
/* 114 */ "ifexpr ::= ifexprs ISEVEN", |
/* 115 */ "ifexpr ::= ifexprs ISNOTEVEN", |
/* 116 */ "ifexpr ::= ifexprs ISEVENBY ifexprs", |
/* 117 */ "ifexpr ::= ifexprs ISNOTEVENBY ifexprs", |
/* 118 */ "ifexpr ::= ifexprs ISODD", |
/* 119 */ "ifexpr ::= ifexprs ISNOTODD", |
/* 120 */ "ifexpr ::= ifexprs ISODDBY ifexprs", |
/* 121 */ "ifexpr ::= ifexprs ISNOTODDBY ifexprs", |
/* 122 */ "ifexpr ::= value INSTANCEOF ID", |
/* 123 */ "ifexpr ::= value INSTANCEOF value", |
/* 124 */ "ifcond ::= EQUALS", |
/* 125 */ "ifcond ::= NOTEQUALS", |
/* 126 */ "ifcond ::= GREATERTHAN", |
/* 127 */ "ifcond ::= LESSTHAN", |
/* 128 */ "ifcond ::= GREATEREQUAL", |
/* 129 */ "ifcond ::= LESSEQUAL", |
/* 130 */ "ifcond ::= IDENTITY", |
/* 131 */ "ifcond ::= NONEIDENTITY", |
/* 132 */ "lop ::= LAND", |
/* 133 */ "lop ::= LOR", |
/* 134 */ "lop ::= LXOR", |
/* 135 */ "array ::= OPENB arrayelements CLOSEB", |
/* 136 */ "arrayelements ::= arrayelement", |
/* 137 */ "arrayelements ::= arrayelements COMMA arrayelement", |
/* 138 */ "arrayelements ::=", |
/* 139 */ "arrayelement ::= expr APTR expr", |
/* 140 */ "arrayelement ::= ID APTR expr", |
/* 141 */ "arrayelement ::= expr", |
/* 142 */ "doublequoted ::= doublequoted doublequotedcontent", |
/* 143 */ "doublequoted ::= doublequotedcontent", |
/* 144 */ "doublequotedcontent ::= BACKTICK ID BACKTICK", |
/* 145 */ "doublequotedcontent ::= BACKTICK variable BACKTICK", |
/* 146 */ "doublequotedcontent ::= DOLLAR ID", |
/* 147 */ "doublequotedcontent ::= LDEL expr RDEL", |
/* 148 */ "doublequotedcontent ::= smartytag", |
/* 149 */ "doublequotedcontent ::= DOLLAR OTHER", |
/* 150 */ "doublequotedcontent ::= LDEL OTHER", |
/* 151 */ "doublequotedcontent ::= BACKTICK OTHER", |
/* 152 */ "doublequotedcontent ::= OTHER", |
/* 153 */ "text ::= text textelement", |
/* 154 */ "text ::= textelement", |
/* 155 */ "textelement ::= OTHER", |
/* 156 */ "textelement ::= LDEL", |
); |
/** |
* This function returns the symbolic name associated with a token |
* value. |
* @param int |
* @return string |
*/ |
function tokenName($tokenType) |
{ |
if ($tokenType === 0) { |
return 'End of Input'; |
} |
if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { |
return $this->yyTokenName[$tokenType]; |
} else { |
return "Unknown"; |
} |
} |
/** |
* The following function deletes the value associated with a |
* symbol. The symbol can be either a terminal or nonterminal. |
* @param int the symbol code |
* @param mixed the symbol's value |
*/ |
static function yy_destructor($yymajor, $yypminor) |
{ |
switch ($yymajor) { |
/* Here is inserted the actions which take place when a |
** terminal or non-terminal is destroyed. This can happen |
** when the symbol is popped from the stack during a |
** reduce or during error processing or when a parser is |
** being destroyed before it is finished parsing. |
** |
** Note: during a reduce, the only symbols destroyed are those |
** which appear on the RHS of the rule, but which are not used |
** inside the C code. |
*/ |
default: break; /* If no destructor action specified: do nothing */ |
} |
} |
/** |
* Pop the parser's stack once. |
* |
* If there is a destructor routine associated with the token which |
* is popped from the stack, then call it. |
* |
* Return the major token number for the symbol popped. |
* @param TP_yyParser |
* @return int |
*/ |
function yy_pop_parser_stack() |
{ |
if (!count($this->yystack)) { |
return; |
} |
$yytos = array_pop($this->yystack); |
if (self::$yyTraceFILE && $this->yyidx >= 0) { |
fwrite(self::$yyTraceFILE, |
self::$yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . |
"\n"); |
} |
$yymajor = $yytos->major; |
self::yy_destructor($yymajor, $yytos->minor); |
$this->yyidx--; |
return $yymajor; |
} |
/** |
* Deallocate and destroy a parser. Destructors are all called for |
* all stack elements before shutting the parser down. |
*/ |
function __destruct() |
{ |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
if (is_resource(self::$yyTraceFILE)) { |
fclose(self::$yyTraceFILE); |
} |
} |
/** |
* Based on the current state and parser stack, get a list of all |
* possible lookahead tokens |
* @param int |
* @return array |
*/ |
function yy_get_expected_tokens($token) |
{ |
$state = $this->yystack[$this->yyidx]->stateno; |
$expected = self::$yyExpectedTokens[$state]; |
if (in_array($token, self::$yyExpectedTokens[$state], true)) { |
return $expected; |
} |
$stack = $this->yystack; |
$yyidx = $this->yyidx; |
do { |
$yyact = $this->yy_find_shift_action($token); |
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
// reduce action |
$done = 0; |
do { |
if ($done++ == 100) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// too much recursion prevents proper detection |
// so give up |
return array_unique($expected); |
} |
$yyruleno = $yyact - self::YYNSTATE; |
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs']; |
$nextstate = $this->yy_find_reduce_action( |
$this->yystack[$this->yyidx]->stateno, |
self::$yyRuleInfo[$yyruleno]['lhs']); |
if (isset(self::$yyExpectedTokens[$nextstate])) { |
$expected += self::$yyExpectedTokens[$nextstate]; |
if (in_array($token, |
self::$yyExpectedTokens[$nextstate], true)) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return array_unique($expected); |
} |
} |
if ($nextstate < self::YYNSTATE) { |
// we need to shift a non-terminal |
$this->yyidx++; |
$x = new TP_yyStackEntry; |
$x->stateno = $nextstate; |
$x->major = self::$yyRuleInfo[$yyruleno]['lhs']; |
$this->yystack[$this->yyidx] = $x; |
continue 2; |
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// the last token was just ignored, we can't accept |
// by ignoring input, this is in essence ignoring a |
// syntax error! |
return array_unique($expected); |
} elseif ($nextstate === self::YY_NO_ACTION) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// input accepted, but not shifted (I guess) |
return $expected; |
} else { |
$yyact = $nextstate; |
} |
} while (true); |
} |
break; |
} while (true); |
return array_unique($expected); |
} |
/** |
* Based on the parser state and current parser stack, determine whether |
* the lookahead token is possible. |
* |
* The parser will convert the token value to an error token if not. This |
* catches some unusual edge cases where the parser would fail. |
* @param int |
* @return bool |
*/ |
function yy_is_expected_token($token) |
{ |
if ($token === 0) { |
return true; // 0 is not part of this |
} |
$state = $this->yystack[$this->yyidx]->stateno; |
if (in_array($token, self::$yyExpectedTokens[$state], true)) { |
return true; |
} |
$stack = $this->yystack; |
$yyidx = $this->yyidx; |
do { |
$yyact = $this->yy_find_shift_action($token); |
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
// reduce action |
$done = 0; |
do { |
if ($done++ == 100) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// too much recursion prevents proper detection |
// so give up |
return true; |
} |
$yyruleno = $yyact - self::YYNSTATE; |
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs']; |
$nextstate = $this->yy_find_reduce_action( |
$this->yystack[$this->yyidx]->stateno, |
self::$yyRuleInfo[$yyruleno]['lhs']); |
if (isset(self::$yyExpectedTokens[$nextstate]) && |
in_array($token, self::$yyExpectedTokens[$nextstate], true)) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return true; |
} |
if ($nextstate < self::YYNSTATE) { |
// we need to shift a non-terminal |
$this->yyidx++; |
$x = new TP_yyStackEntry; |
$x->stateno = $nextstate; |
$x->major = self::$yyRuleInfo[$yyruleno]['lhs']; |
$this->yystack[$this->yyidx] = $x; |
continue 2; |
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
if (!$token) { |
// end of input: this is valid |
return true; |
} |
// the last token was just ignored, we can't accept |
// by ignoring input, this is in essence ignoring a |
// syntax error! |
return false; |
} elseif ($nextstate === self::YY_NO_ACTION) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// input accepted, but not shifted (I guess) |
return true; |
} else { |
$yyact = $nextstate; |
} |
} while (true); |
} |
break; |
} while (true); |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return true; |
} |
/** |
* Find the appropriate action for a parser given the terminal |
* look-ahead token iLookAhead. |
* |
* If the look-ahead token is YYNOCODE, then check to see if the action is |
* independent of the look-ahead. If it is, return the action, otherwise |
* return YY_NO_ACTION. |
* @param int The look-ahead token |
*/ |
function yy_find_shift_action($iLookAhead) |
{ |
$stateno = $this->yystack[$this->yyidx]->stateno; |
/* if ($this->yyidx < 0) return self::YY_NO_ACTION; */ |
if (!isset(self::$yy_shift_ofst[$stateno])) { |
// no shift actions |
return self::$yy_default[$stateno]; |
} |
$i = self::$yy_shift_ofst[$stateno]; |
if ($i === self::YY_SHIFT_USE_DFLT) { |
return self::$yy_default[$stateno]; |
} |
if ($iLookAhead == self::YYNOCODE) { |
return self::YY_NO_ACTION; |
} |
$i += $iLookAhead; |
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
self::$yy_lookahead[$i] != $iLookAhead) { |
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) |
&& ($iFallback = self::$yyFallback[$iLookAhead]) != 0) { |
if (self::$yyTraceFILE) { |
fwrite(self::$yyTraceFILE, self::$yyTracePrompt . "FALLBACK " . |
$this->yyTokenName[$iLookAhead] . " => " . |
$this->yyTokenName[$iFallback] . "\n"); |
} |
return $this->yy_find_shift_action($iFallback); |
} |
return self::$yy_default[$stateno]; |
} else { |
return self::$yy_action[$i]; |
} |
} |
/** |
* Find the appropriate action for a parser given the non-terminal |
* look-ahead token $iLookAhead. |
* |
* If the look-ahead token is self::YYNOCODE, then check to see if the action is |
* independent of the look-ahead. If it is, return the action, otherwise |
* return self::YY_NO_ACTION. |
* @param int Current state number |
* @param int The look-ahead token |
*/ |
function yy_find_reduce_action($stateno, $iLookAhead) |
{ |
/* $stateno = $this->yystack[$this->yyidx]->stateno; */ |
if (!isset(self::$yy_reduce_ofst[$stateno])) { |
return self::$yy_default[$stateno]; |
} |
$i = self::$yy_reduce_ofst[$stateno]; |
if ($i == self::YY_REDUCE_USE_DFLT) { |
return self::$yy_default[$stateno]; |
} |
if ($iLookAhead == self::YYNOCODE) { |
return self::YY_NO_ACTION; |
} |
$i += $iLookAhead; |
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
self::$yy_lookahead[$i] != $iLookAhead) { |
return self::$yy_default[$stateno]; |
} else { |
return self::$yy_action[$i]; |
} |
} |
/** |
* Perform a shift action. |
* @param int The new state to shift in |
* @param int The major token to shift in |
* @param mixed the minor token to shift in |
*/ |
function yy_shift($yyNewState, $yyMajor, $yypMinor) |
{ |
$this->yyidx++; |
if ($this->yyidx >= self::YYSTACKDEPTH) { |
$this->yyidx--; |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will execute if the parser |
** stack ever overflows */ |
return; |
} |
$yytos = new TP_yyStackEntry; |
$yytos->stateno = $yyNewState; |
$yytos->major = $yyMajor; |
$yytos->minor = $yypMinor; |
array_push($this->yystack, $yytos); |
if (self::$yyTraceFILE && $this->yyidx > 0) { |
fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt, |
$yyNewState); |
fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt); |
for($i = 1; $i <= $this->yyidx; $i++) { |
fprintf(self::$yyTraceFILE, " %s", |
$this->yyTokenName[$this->yystack[$i]->major]); |
} |
fwrite(self::$yyTraceFILE,"\n"); |
} |
} |
/** |
* The following table contains information about every rule that |
* is used during the reduce. |
* |
* <pre> |
* array( |
* array( |
* int $lhs; Symbol on the left-hand side of the rule |
* int $nrhs; Number of right-hand side symbols in the rule |
* ),... |
* ); |
* </pre> |
*/ |
static public $yyRuleInfo = array( |
array( 'lhs' => 71, 'rhs' => 1 ), |
array( 'lhs' => 72, 'rhs' => 1 ), |
array( 'lhs' => 72, 'rhs' => 2 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 73, 'rhs' => 3 ), |
array( 'lhs' => 73, 'rhs' => 3 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 73, 'rhs' => 3 ), |
array( 'lhs' => 73, 'rhs' => 4 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 73, 'rhs' => 1 ), |
array( 'lhs' => 74, 'rhs' => 4 ), |
array( 'lhs' => 74, 'rhs' => 6 ), |
array( 'lhs' => 74, 'rhs' => 4 ), |
array( 'lhs' => 74, 'rhs' => 6 ), |
array( 'lhs' => 74, 'rhs' => 6 ), |
array( 'lhs' => 74, 'rhs' => 5 ), |
array( 'lhs' => 74, 'rhs' => 5 ), |
array( 'lhs' => 74, 'rhs' => 11 ), |
array( 'lhs' => 85, 'rhs' => 2 ), |
array( 'lhs' => 85, 'rhs' => 1 ), |
array( 'lhs' => 74, 'rhs' => 8 ), |
array( 'lhs' => 74, 'rhs' => 8 ), |
array( 'lhs' => 74, 'rhs' => 4 ), |
array( 'lhs' => 74, 'rhs' => 5 ), |
array( 'lhs' => 77, 'rhs' => 2 ), |
array( 'lhs' => 77, 'rhs' => 1 ), |
array( 'lhs' => 77, 'rhs' => 0 ), |
array( 'lhs' => 88, 'rhs' => 4 ), |
array( 'lhs' => 88, 'rhs' => 2 ), |
array( 'lhs' => 83, 'rhs' => 1 ), |
array( 'lhs' => 83, 'rhs' => 3 ), |
array( 'lhs' => 82, 'rhs' => 4 ), |
array( 'lhs' => 76, 'rhs' => 1 ), |
array( 'lhs' => 76, 'rhs' => 1 ), |
array( 'lhs' => 76, 'rhs' => 4 ), |
array( 'lhs' => 76, 'rhs' => 3 ), |
array( 'lhs' => 89, 'rhs' => 1 ), |
array( 'lhs' => 89, 'rhs' => 2 ), |
array( 'lhs' => 89, 'rhs' => 3 ), |
array( 'lhs' => 89, 'rhs' => 3 ), |
array( 'lhs' => 89, 'rhs' => 1 ), |
array( 'lhs' => 90, 'rhs' => 1 ), |
array( 'lhs' => 90, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 2 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 2 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 7 ), |
array( 'lhs' => 86, 'rhs' => 4 ), |
array( 'lhs' => 86, 'rhs' => 8 ), |
array( 'lhs' => 86, 'rhs' => 3 ), |
array( 'lhs' => 86, 'rhs' => 5 ), |
array( 'lhs' => 86, 'rhs' => 6 ), |
array( 'lhs' => 86, 'rhs' => 1 ), |
array( 'lhs' => 91, 'rhs' => 1 ), |
array( 'lhs' => 91, 'rhs' => 4 ), |
array( 'lhs' => 91, 'rhs' => 1 ), |
array( 'lhs' => 91, 'rhs' => 3 ), |
array( 'lhs' => 91, 'rhs' => 3 ), |
array( 'lhs' => 78, 'rhs' => 3 ), |
array( 'lhs' => 97, 'rhs' => 2 ), |
array( 'lhs' => 97, 'rhs' => 0 ), |
array( 'lhs' => 99, 'rhs' => 2 ), |
array( 'lhs' => 99, 'rhs' => 2 ), |
array( 'lhs' => 99, 'rhs' => 2 ), |
array( 'lhs' => 99, 'rhs' => 4 ), |
array( 'lhs' => 99, 'rhs' => 3 ), |
array( 'lhs' => 99, 'rhs' => 5 ), |
array( 'lhs' => 99, 'rhs' => 3 ), |
array( 'lhs' => 99, 'rhs' => 2 ), |
array( 'lhs' => 84, 'rhs' => 1 ), |
array( 'lhs' => 84, 'rhs' => 2 ), |
array( 'lhs' => 100, 'rhs' => 1 ), |
array( 'lhs' => 100, 'rhs' => 3 ), |
array( 'lhs' => 98, 'rhs' => 2 ), |
array( 'lhs' => 96, 'rhs' => 1 ), |
array( 'lhs' => 96, 'rhs' => 2 ), |
array( 'lhs' => 101, 'rhs' => 3 ), |
array( 'lhs' => 101, 'rhs' => 3 ), |
array( 'lhs' => 101, 'rhs' => 5 ), |
array( 'lhs' => 101, 'rhs' => 6 ), |
array( 'lhs' => 101, 'rhs' => 2 ), |
array( 'lhs' => 92, 'rhs' => 4 ), |
array( 'lhs' => 94, 'rhs' => 4 ), |
array( 'lhs' => 95, 'rhs' => 3 ), |
array( 'lhs' => 95, 'rhs' => 1 ), |
array( 'lhs' => 95, 'rhs' => 0 ), |
array( 'lhs' => 79, 'rhs' => 3 ), |
array( 'lhs' => 79, 'rhs' => 2 ), |
array( 'lhs' => 80, 'rhs' => 2 ), |
array( 'lhs' => 80, 'rhs' => 0 ), |
array( 'lhs' => 102, 'rhs' => 2 ), |
array( 'lhs' => 102, 'rhs' => 2 ), |
array( 'lhs' => 81, 'rhs' => 1 ), |
array( 'lhs' => 81, 'rhs' => 2 ), |
array( 'lhs' => 81, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 1 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 2 ), |
array( 'lhs' => 103, 'rhs' => 2 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 2 ), |
array( 'lhs' => 103, 'rhs' => 2 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 103, 'rhs' => 3 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 104, 'rhs' => 1 ), |
array( 'lhs' => 105, 'rhs' => 1 ), |
array( 'lhs' => 105, 'rhs' => 1 ), |
array( 'lhs' => 105, 'rhs' => 1 ), |
array( 'lhs' => 87, 'rhs' => 3 ), |
array( 'lhs' => 106, 'rhs' => 1 ), |
array( 'lhs' => 106, 'rhs' => 3 ), |
array( 'lhs' => 106, 'rhs' => 0 ), |
array( 'lhs' => 107, 'rhs' => 3 ), |
array( 'lhs' => 107, 'rhs' => 3 ), |
array( 'lhs' => 107, 'rhs' => 1 ), |
array( 'lhs' => 93, 'rhs' => 2 ), |
array( 'lhs' => 93, 'rhs' => 1 ), |
array( 'lhs' => 108, 'rhs' => 3 ), |
array( 'lhs' => 108, 'rhs' => 3 ), |
array( 'lhs' => 108, 'rhs' => 2 ), |
array( 'lhs' => 108, 'rhs' => 3 ), |
array( 'lhs' => 108, 'rhs' => 1 ), |
array( 'lhs' => 108, 'rhs' => 2 ), |
array( 'lhs' => 108, 'rhs' => 2 ), |
array( 'lhs' => 108, 'rhs' => 2 ), |
array( 'lhs' => 108, 'rhs' => 1 ), |
array( 'lhs' => 75, 'rhs' => 2 ), |
array( 'lhs' => 75, 'rhs' => 1 ), |
array( 'lhs' => 109, 'rhs' => 1 ), |
array( 'lhs' => 109, 'rhs' => 1 ), |
); |
/** |
* The following table contains a mapping of reduce action to method name |
* that handles the reduction. |
* |
* If a rule is not set, it has no handler. |
*/ |
static public $yyReduceMap = array( |
0 => 0, |
39 => 0, |
46 => 0, |
47 => 0, |
49 => 0, |
50 => 0, |
51 => 0, |
67 => 0, |
136 => 0, |
1 => 1, |
36 => 1, |
43 => 1, |
44 => 1, |
45 => 1, |
81 => 1, |
104 => 1, |
143 => 1, |
152 => 1, |
154 => 1, |
155 => 1, |
156 => 1, |
2 => 2, |
71 => 2, |
142 => 2, |
150 => 2, |
153 => 2, |
3 => 3, |
4 => 4, |
5 => 5, |
6 => 6, |
7 => 7, |
8 => 8, |
9 => 9, |
10 => 10, |
11 => 11, |
12 => 12, |
13 => 13, |
14 => 14, |
15 => 15, |
16 => 16, |
17 => 17, |
18 => 18, |
19 => 19, |
20 => 20, |
21 => 21, |
22 => 22, |
28 => 22, |
96 => 22, |
141 => 22, |
23 => 23, |
24 => 24, |
25 => 25, |
26 => 26, |
27 => 27, |
29 => 29, |
30 => 30, |
31 => 31, |
32 => 32, |
33 => 33, |
34 => 34, |
35 => 35, |
37 => 37, |
38 => 38, |
40 => 40, |
41 => 41, |
42 => 42, |
48 => 48, |
52 => 52, |
53 => 53, |
54 => 54, |
56 => 54, |
55 => 55, |
57 => 57, |
58 => 58, |
59 => 59, |
60 => 60, |
61 => 61, |
62 => 62, |
63 => 63, |
64 => 64, |
65 => 65, |
66 => 66, |
68 => 68, |
69 => 69, |
70 => 70, |
72 => 72, |
101 => 72, |
73 => 73, |
74 => 74, |
75 => 75, |
76 => 76, |
79 => 76, |
77 => 77, |
78 => 78, |
80 => 80, |
82 => 82, |
83 => 83, |
84 => 84, |
106 => 84, |
85 => 85, |
86 => 86, |
87 => 87, |
88 => 88, |
89 => 89, |
90 => 90, |
91 => 91, |
92 => 92, |
93 => 93, |
94 => 94, |
95 => 95, |
97 => 97, |
98 => 98, |
99 => 99, |
100 => 100, |
102 => 102, |
103 => 103, |
105 => 105, |
107 => 107, |
108 => 108, |
111 => 108, |
122 => 108, |
109 => 109, |
110 => 110, |
112 => 112, |
113 => 113, |
114 => 114, |
119 => 114, |
115 => 115, |
118 => 115, |
116 => 116, |
121 => 116, |
117 => 117, |
120 => 117, |
123 => 123, |
124 => 124, |
125 => 125, |
126 => 126, |
127 => 127, |
128 => 128, |
129 => 129, |
130 => 130, |
131 => 131, |
132 => 132, |
133 => 133, |
134 => 134, |
135 => 135, |
137 => 137, |
138 => 138, |
139 => 139, |
140 => 140, |
144 => 144, |
145 => 145, |
146 => 146, |
147 => 147, |
148 => 148, |
149 => 149, |
151 => 151, |
); |
/* Beginning here are the reduction cases. A typical example |
** follows: |
** #line <lineno> <grammarfile> |
** function yy_r0($yymsp){ ... } // User supplied code |
** #line <lineno> <thisfile> |
*/ |
#line 79 "internal.templateparser.y" |
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 1943 "internal.templateparser.php" |
#line 85 "internal.templateparser.y" |
function yy_r1(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 1946 "internal.templateparser.php" |
#line 87 "internal.templateparser.y" |
function yy_r2(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 1949 "internal.templateparser.php" |
#line 93 "internal.templateparser.y" |
function yy_r3(){if ($this->compiler->has_code) { |
$tmp =''; foreach ($this->prefix_code as $code) {$tmp.=$code;} $this->prefix_code=array(); |
$this->_retvalue = $this->cacher->processNocacheCode($tmp.$this->yystack[$this->yyidx + 0]->minor, $this->compiler,$this->nocache,true); |
} else { $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;} $this->nocache=false; } |
#line 1955 "internal.templateparser.php" |
#line 98 "internal.templateparser.y" |
function yy_r4(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -2]->minor,$s); $this->_retvalue = $s[0]; } |
#line 1958 "internal.templateparser.php" |
#line 101 "internal.templateparser.y" |
function yy_r5(){preg_match('/\s*/',$this->yystack[$this->yyidx + -2]->minor,$s); preg_match('/\s*/',$this->yystack[$this->yyidx + 0]->minor,$s2); $this->_retvalue = $s[0].$this->cacher->processNocacheCode($this->yystack[$this->yyidx + -1]->minor.$s2[0], $this->compiler,false,false); } |
#line 1961 "internal.templateparser.php" |
#line 103 "internal.templateparser.y" |
function yy_r6(){preg_match('/\s*/',$this->yystack[$this->yyidx + 0]->minor,$s); $this->_retvalue = $s[0].$this->cacher->processNocacheCode($this->smarty->left_delimiter, $this->compiler,false,false); } |
#line 1964 "internal.templateparser.php" |
#line 105 "internal.templateparser.y" |
function yy_r7(){preg_match('/\s*/',$this->yystack[$this->yyidx + 0]->minor,$s); $this->_retvalue = $s[0].$this->cacher->processNocacheCode($this->smarty->right_delimiter, $this->compiler,false,false); } |
#line 1967 "internal.templateparser.php" |
#line 107 "internal.templateparser.y" |
function yy_r8(){if ($this->sec_obj->php_handling == SMARTY_PHP_PASSTHRU) { |
$this->_retvalue = $this->cacher->processNocacheCode("<?php echo '<?php".str_replace("'","\'",$this->yystack[$this->yyidx + -1]->minor)."?>';?>\n", $this->compiler, false, false); |
} elseif ($this->sec_obj->php_handling == SMARTY_PHP_QUOTE) { |
$this->_retvalue = $this->cacher->processNocacheCode(htmlspecialchars('<?php'.$this->yystack[$this->yyidx + -1]->minor.'?>', ENT_QUOTES), $this->compiler, false, false); |
}elseif ($this->sec_obj->php_handling == SMARTY_PHP_ALLOW) { |
$this->_retvalue = $this->cacher->processNocacheCode('<?php'.$this->yystack[$this->yyidx + -1]->minor.'?>', $this->compiler, false,true); |
}elseif ($this->sec_obj->php_handling == SMARTY_PHP_REMOVE) { |
$this->_retvalue = ''; |
} |
} |
#line 1979 "internal.templateparser.php" |
#line 118 "internal.templateparser.y" |
function yy_r9(){preg_match('/\s*/',$this->yystack[$this->yyidx + -3]->minor,$s); $this->_retvalue = $s[0]; |
if ($this->sec_obj->php_handling == SMARTY_PHP_PASSTHRU || $this->sec_obj->php_handling == SMARTY_PHP_ALLOW) { |
$this->_retvalue .= $this->cacher->processNocacheCode("<?php echo '<?=$".$this->yystack[$this->yyidx + -1]->minor."?>'?>\n", $this->compiler, false, false); |
} elseif ($this->sec_obj->php_handling == SMARTY_PHP_QUOTE) { |
$this->_retvalue .= $this->cacher->processNocacheCode(htmlspecialchars('<?=$'.$this->yystack[$this->yyidx + -1]->minor.'?>', ENT_QUOTES), $this->compiler, false, false); |
}elseif ($this->sec_obj == SMARTY_PHP_REMOVE) { |
$this->_retvalue .= ''; |
} |
} |
#line 1990 "internal.templateparser.php" |
#line 129 "internal.templateparser.y" |
function yy_r10(){preg_match('/\s*/',$this->yystack[$this->yyidx + 0]->minor,$s); $this->_retvalue = $s[0].$this->cacher->processNocacheCode("<?php echo '<?xml';?>", $this->compiler, true, true); } |
#line 1993 "internal.templateparser.php" |
#line 130 "internal.templateparser.y" |
function yy_r11(){$this->_retvalue = $this->cacher->processNocacheCode("<?php echo '?>';?>\n", $this->compiler, true, true); } |
#line 1996 "internal.templateparser.php" |
#line 132 "internal.templateparser.y" |
function yy_r12(){$this->_retvalue = $this->cacher->processNocacheCode($this->yystack[$this->yyidx + 0]->minor, $this->compiler,false,false); } |
#line 1999 "internal.templateparser.php" |
#line 139 "internal.templateparser.y" |
function yy_r13(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -3]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag('print_expression',array_merge(array('value'=>$this->yystack[$this->yyidx + -2]->minor),$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2002 "internal.templateparser.php" |
#line 141 "internal.templateparser.y" |
function yy_r14(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -5]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag('assign',array_merge(array('value'=>$this->yystack[$this->yyidx + -2]->minor),$this->yystack[$this->yyidx + -4]->minor,$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2005 "internal.templateparser.php" |
#line 143 "internal.templateparser.y" |
function yy_r15(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -3]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor,$this->yystack[$this->yyidx + -1]->minor); } |
#line 2008 "internal.templateparser.php" |
#line 145 "internal.templateparser.y" |
function yy_r16(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -5]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -4]->minor,array_merge(array('object_methode'=>$this->yystack[$this->yyidx + -2]->minor),$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2011 "internal.templateparser.php" |
#line 147 "internal.templateparser.y" |
function yy_r17(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -5]->minor,$s); $this->_retvalue = $s[0].'<?php ob_start();?>'.$this->compiler->compileTag($this->yystack[$this->yyidx + -4]->minor,$this->yystack[$this->yyidx + -1]->minor).'<?php echo '; |
if ($this->smarty->plugin_handler->loadSmartyPlugin($this->yystack[$this->yyidx + -3]->minor[0],'modifier')) { |
$this->_retvalue .= "\$_smarty_tpl->smarty->plugin_handler->executeModifier('".$this->yystack[$this->yyidx + -3]->minor[0] . "',array(ob_get_clean()" . $this->yystack[$this->yyidx + -2]->minor. "),".$this->yystack[$this->yyidx + -3]->minor[1].");?>"; |
} else { |
if (is_callable($this->yystack[$this->yyidx + -3]->minor[0])) { |
if (!$this->template->security || $this->smarty->security_handler->isTrustedModifier($this->yystack[$this->yyidx + -3]->minor[0], $this->compiler)) { |
$this->_retvalue .= "\$_smarty_tpl->smarty->plugin_handler->executeModifier('".$this->yystack[$this->yyidx + -3]->minor[0] . "',array(ob_get_clean()" . $this->yystack[$this->yyidx + -2]->minor. "),".$this->yystack[$this->yyidx + -3]->minor[1].");?>"; |
} |
} else { |
$this->compiler->trigger_template_error ("unknown modifier \"" . $this->yystack[$this->yyidx + -3]->minor[0] . "\""); |
} |
} |
} |
#line 2026 "internal.templateparser.php" |
#line 161 "internal.templateparser.y" |
function yy_r18(){if (!in_array($this->yystack[$this->yyidx + -3]->minor,array('if','elseif','while'))) { |
$this->compiler->trigger_template_error ("wrong syntax for tag \"" . $this->yystack[$this->yyidx + -3]->minor . "\""); |
} |
preg_match('/\s*/',$this->yystack[$this->yyidx + -4]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor,array('if condition'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2032 "internal.templateparser.php" |
#line 165 "internal.templateparser.y" |
function yy_r19(){ if (!in_array($this->yystack[$this->yyidx + -3]->minor,array('if','elseif','while'))) { |
$this->compiler->trigger_template_error ("wrong syntax for tag \"" . $this->yystack[$this->yyidx + -3]->minor . "\""); |
} |
preg_match('/\s*/',$this->yystack[$this->yyidx + -4]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor,array('if condition'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2038 "internal.templateparser.php" |
#line 170 "internal.templateparser.y" |
function yy_r20(){ |
if ($this->yystack[$this->yyidx + -9]->minor != 'for') { |
$this->compiler->trigger_template_error ("wrong syntax for tag \"" . $this->yystack[$this->yyidx + -9]->minor . "\""); |
} |
preg_match('/\s*/',$this->yystack[$this->yyidx + -10]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -9]->minor,array('start'=>$this->yystack[$this->yyidx + -7]->minor,'ifexp'=>$this->yystack[$this->yyidx + -5]->minor,'varloop'=>$this->yystack[$this->yyidx + -2]->minor,'loop'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2045 "internal.templateparser.php" |
#line 175 "internal.templateparser.y" |
function yy_r21(){ $this->_retvalue = '='.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2048 "internal.templateparser.php" |
#line 176 "internal.templateparser.y" |
function yy_r22(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 2051 "internal.templateparser.php" |
#line 178 "internal.templateparser.y" |
function yy_r23(){ |
if ($this->yystack[$this->yyidx + -6]->minor != 'foreach') { |
$this->compiler->trigger_template_error ("wrong syntax for tag \"" . $this->yystack[$this->yyidx + -6]->minor . "\""); |
} |
preg_match('/\s*/',$this->yystack[$this->yyidx + -7]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -6]->minor,array('from'=>$this->yystack[$this->yyidx + -4]->minor,'item'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2058 "internal.templateparser.php" |
#line 183 "internal.templateparser.y" |
function yy_r24(){ |
if ($this->yystack[$this->yyidx + -6]->minor != 'foreach') { |
$this->compiler->trigger_template_error ("wrong syntax for tag \"" . $this->yystack[$this->yyidx + -6]->minor . "\""); |
} |
preg_match('/\s*/',$this->yystack[$this->yyidx + -7]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -6]->minor,array('from'=>$this->yystack[$this->yyidx + -4]->minor,'item'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2065 "internal.templateparser.php" |
#line 190 "internal.templateparser.y" |
function yy_r25(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -3]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor.'close',$this->yystack[$this->yyidx + -1]->minor); } |
#line 2068 "internal.templateparser.php" |
#line 192 "internal.templateparser.y" |
function yy_r26(){ preg_match('/\s*/',$this->yystack[$this->yyidx + -4]->minor,$s); $this->_retvalue = $s[0].$this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor.'close',array('object_methode'=>$this->yystack[$this->yyidx + -1]->minor)); } |
#line 2071 "internal.templateparser.php" |
#line 199 "internal.templateparser.y" |
function yy_r27(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); } |
#line 2074 "internal.templateparser.php" |
#line 203 "internal.templateparser.y" |
function yy_r29(){ $this->_retvalue = array(); } |
#line 2077 "internal.templateparser.php" |
#line 206 "internal.templateparser.y" |
function yy_r30(){ $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>$this->yystack[$this->yyidx + 0]->minor); } |
#line 2080 "internal.templateparser.php" |
#line 207 "internal.templateparser.y" |
function yy_r31(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor=>'true'); } |
#line 2083 "internal.templateparser.php" |
#line 212 "internal.templateparser.y" |
function yy_r32(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } |
#line 2086 "internal.templateparser.php" |
#line 213 "internal.templateparser.y" |
function yy_r33(){ $this->yystack[$this->yyidx + -2]->minor[]=$this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor; } |
#line 2089 "internal.templateparser.php" |
#line 215 "internal.templateparser.y" |
function yy_r34(){ $this->_retvalue = array('var' => $this->yystack[$this->yyidx + -2]->minor, 'value'=>$this->yystack[$this->yyidx + 0]->minor); } |
#line 2092 "internal.templateparser.php" |
#line 221 "internal.templateparser.y" |
function yy_r35(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } |
#line 2095 "internal.templateparser.php" |
#line 225 "internal.templateparser.y" |
function yy_r37(){$this->_retvalue = '$_smarty_tpl->getStreamVariable(\''. $this->yystack[$this->yyidx + -2]->minor .'://'. $this->yystack[$this->yyidx + 0]->minor . '\')'; } |
#line 2098 "internal.templateparser.php" |
#line 226 "internal.templateparser.y" |
function yy_r38(){ |
if ($this->smarty->plugin_handler->loadSmartyPlugin($this->yystack[$this->yyidx + -1]->minor[0],'modifier')) { |
$this->_retvalue = "\$_smarty_tpl->smarty->plugin_handler->executeModifier('".$this->yystack[$this->yyidx + -1]->minor[0] . "',array(". $this->yystack[$this->yyidx + -2]->minor . $this->yystack[$this->yyidx + 0]->minor. "),".$this->yystack[$this->yyidx + -1]->minor[1].")"; |
} else { |
if (is_callable($this->yystack[$this->yyidx + -1]->minor[0])) { |
if (!$this->template->security || $this->smarty->security_handler->isTrustedModifier($this->yystack[$this->yyidx + -1]->minor[0], $this->compiler)) { |
$this->_retvalue = "\$_smarty_tpl->smarty->plugin_handler->executeModifier('".$this->yystack[$this->yyidx + -1]->minor[0] . "',array(". $this->yystack[$this->yyidx + -2]->minor . $this->yystack[$this->yyidx + 0]->minor. "),".$this->yystack[$this->yyidx + -1]->minor[1].")"; |
} |
} else { |
$this->compiler->trigger_template_error ("unknown modifier \"" . $this->yystack[$this->yyidx + -1]->minor[0] . "\""); |
} |
} |
} |
#line 2113 "internal.templateparser.php" |
#line 243 "internal.templateparser.y" |
function yy_r40(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2116 "internal.templateparser.php" |
#line 245 "internal.templateparser.y" |
function yy_r41(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor . $this->yystack[$this->yyidx + -1]->minor . $this->yystack[$this->yyidx + 0]->minor; } |
#line 2119 "internal.templateparser.php" |
#line 247 "internal.templateparser.y" |
function yy_r42(){ $this->_retvalue = '('. $this->yystack[$this->yyidx + -2]->minor . ').(' . $this->yystack[$this->yyidx + 0]->minor. ')'; } |
#line 2122 "internal.templateparser.php" |
#line 267 "internal.templateparser.y" |
function yy_r48(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2125 "internal.templateparser.php" |
#line 275 "internal.templateparser.y" |
function yy_r52(){ $this->_retvalue = "(". $this->yystack[$this->yyidx + -1]->minor .")"; } |
#line 2128 "internal.templateparser.php" |
#line 277 "internal.templateparser.y" |
function yy_r53(){ $this->_retvalue = "'".$this->yystack[$this->yyidx + -1]->minor."'"; } |
#line 2131 "internal.templateparser.php" |
#line 278 "internal.templateparser.y" |
function yy_r54(){ $this->_retvalue = "''"; } |
#line 2134 "internal.templateparser.php" |
#line 280 "internal.templateparser.y" |
function yy_r55(){ $this->_retvalue = '"'.$this->yystack[$this->yyidx + -1]->minor.'"'; } |
#line 2137 "internal.templateparser.php" |
#line 283 "internal.templateparser.y" |
function yy_r57(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'::'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2140 "internal.templateparser.php" |
#line 284 "internal.templateparser.y" |
function yy_r58(){ $this->prefix_number++; $this->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'=$_smarty_tpl->getVariable(\''. $this->yystack[$this->yyidx + -3]->minor .'\')->value;?>'; $this->_retvalue = $this->yystack[$this->yyidx + -6]->minor.'::$_tmp'.$this->prefix_number.'('. $this->yystack[$this->yyidx + -1]->minor .')'; } |
#line 2143 "internal.templateparser.php" |
#line 286 "internal.templateparser.y" |
function yy_r59(){ $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.'::'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2146 "internal.templateparser.php" |
#line 287 "internal.templateparser.y" |
function yy_r60(){ $this->prefix_number++; $this->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'=$_smarty_tpl->getVariable(\''. $this->yystack[$this->yyidx + -4]->minor .'\')->value;?>'; $this->_retvalue = $this->yystack[$this->yyidx + -7]->minor.'::$_tmp'.$this->prefix_number.'('. $this->yystack[$this->yyidx + -2]->minor .')'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2149 "internal.templateparser.php" |
#line 289 "internal.templateparser.y" |
function yy_r61(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'::'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2152 "internal.templateparser.php" |
#line 291 "internal.templateparser.y" |
function yy_r62(){ $this->_retvalue = $this->yystack[$this->yyidx + -4]->minor.'::$'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2155 "internal.templateparser.php" |
#line 293 "internal.templateparser.y" |
function yy_r63(){ $this->_retvalue = $this->yystack[$this->yyidx + -5]->minor.'::$'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2158 "internal.templateparser.php" |
#line 295 "internal.templateparser.y" |
function yy_r64(){ $this->prefix_number++; $this->prefix_code[] = '<?php ob_start();?>'.$this->yystack[$this->yyidx + 0]->minor.'<?php $_tmp'.$this->prefix_number.'=ob_get_clean();?>'; $this->_retvalue = '$_tmp'.$this->prefix_number; } |
#line 2161 "internal.templateparser.php" |
#line 301 "internal.templateparser.y" |
function yy_r65(){if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') { $this->_retvalue = $this->compiler->compileTag('internal_smarty_var',$this->yystack[$this->yyidx + 0]->minor['index']);} else { |
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + 0]->minor['var'] .')->value'.$this->yystack[$this->yyidx + 0]->minor['index']; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor['var'],"'"))->nocache;} } |
#line 2165 "internal.templateparser.php" |
#line 304 "internal.templateparser.y" |
function yy_r66(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + -2]->minor,"'"))->nocache; } |
#line 2168 "internal.templateparser.php" |
#line 308 "internal.templateparser.y" |
function yy_r68(){$this->_retvalue = '$_smarty_tpl->getConfigVariable(\''. $this->yystack[$this->yyidx + -1]->minor .'\')'; } |
#line 2171 "internal.templateparser.php" |
#line 309 "internal.templateparser.y" |
function yy_r69(){$this->_retvalue = '$_smarty_tpl->getConfigVariable('. $this->yystack[$this->yyidx + -1]->minor .')'; } |
#line 2174 "internal.templateparser.php" |
#line 312 "internal.templateparser.y" |
function yy_r70(){$this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'index'=>$this->yystack[$this->yyidx + 0]->minor); } |
#line 2177 "internal.templateparser.php" |
#line 320 "internal.templateparser.y" |
function yy_r72(){return; } |
#line 2180 "internal.templateparser.php" |
#line 324 "internal.templateparser.y" |
function yy_r73(){ $this->_retvalue = "['". $this->yystack[$this->yyidx + 0]->minor ."']"; } |
#line 2183 "internal.templateparser.php" |
#line 325 "internal.templateparser.y" |
function yy_r74(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + 0]->minor ."]"; } |
#line 2186 "internal.templateparser.php" |
#line 326 "internal.templateparser.y" |
function yy_r75(){ $this->_retvalue = "[".$this->yystack[$this->yyidx + 0]->minor."]"; } |
#line 2189 "internal.templateparser.php" |
#line 327 "internal.templateparser.y" |
function yy_r76(){ $this->_retvalue = "[". $this->yystack[$this->yyidx + -1]->minor ."]"; } |
#line 2192 "internal.templateparser.php" |
#line 329 "internal.templateparser.y" |
function yy_r77(){ $this->_retvalue = '['.$this->compiler->compileTag('internal_smarty_var','[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']'; } |
#line 2195 "internal.templateparser.php" |
#line 330 "internal.templateparser.y" |
function yy_r78(){ $this->_retvalue = '['.$this->compiler->compileTag('internal_smarty_var','[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; } |
#line 2198 "internal.templateparser.php" |
#line 334 "internal.templateparser.y" |
function yy_r80(){$this->_retvalue = ''; } |
#line 2201 "internal.templateparser.php" |
#line 342 "internal.templateparser.y" |
function yy_r82(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2204 "internal.templateparser.php" |
#line 344 "internal.templateparser.y" |
function yy_r83(){$this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } |
#line 2207 "internal.templateparser.php" |
#line 346 "internal.templateparser.y" |
function yy_r84(){$this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; } |
#line 2210 "internal.templateparser.php" |
#line 351 "internal.templateparser.y" |
function yy_r85(){ if ($this->yystack[$this->yyidx + -1]->minor['var'] == '\'smarty\'') { $this->_retvalue = $this->compiler->compileTag('internal_smarty_var',$this->yystack[$this->yyidx + -1]->minor['index']).$this->yystack[$this->yyidx + 0]->minor;} else { |
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -1]->minor['var'] .')->value'.$this->yystack[$this->yyidx + -1]->minor['index'].$this->yystack[$this->yyidx + 0]->minor; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + -1]->minor['var'],"'"))->nocache;} } |
#line 2214 "internal.templateparser.php" |
#line 354 "internal.templateparser.y" |
function yy_r86(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 2217 "internal.templateparser.php" |
#line 356 "internal.templateparser.y" |
function yy_r87(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2220 "internal.templateparser.php" |
#line 358 "internal.templateparser.y" |
function yy_r88(){ $this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2223 "internal.templateparser.php" |
#line 359 "internal.templateparser.y" |
function yy_r89(){ $this->_retvalue = '->{'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; } |
#line 2226 "internal.templateparser.php" |
#line 360 "internal.templateparser.y" |
function yy_r90(){ $this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; } |
#line 2229 "internal.templateparser.php" |
#line 361 "internal.templateparser.y" |
function yy_r91(){ $this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; } |
#line 2232 "internal.templateparser.php" |
#line 363 "internal.templateparser.y" |
function yy_r92(){ $this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2235 "internal.templateparser.php" |
#line 369 "internal.templateparser.y" |
function yy_r93(){if (!$this->template->security || $this->smarty->security_handler->isTrustedPhpFunction($this->yystack[$this->yyidx + -3]->minor, $this->compiler)) { |
if ($this->yystack[$this->yyidx + -3]->minor == 'isset' || $this->yystack[$this->yyidx + -3]->minor == 'empty' || $this->yystack[$this->yyidx + -3]->minor == 'array' || is_callable($this->yystack[$this->yyidx + -3]->minor)) { |
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". $this->yystack[$this->yyidx + -1]->minor .")"; |
} else { |
$this->compiler->trigger_template_error ("unknown function \"" . $this->yystack[$this->yyidx + -3]->minor . "\""); |
} |
} } |
#line 2244 "internal.templateparser.php" |
#line 380 "internal.templateparser.y" |
function yy_r94(){ $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . "(". $this->yystack[$this->yyidx + -1]->minor .")"; } |
#line 2247 "internal.templateparser.php" |
#line 384 "internal.templateparser.y" |
function yy_r95(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.",".$this->yystack[$this->yyidx + 0]->minor; } |
#line 2250 "internal.templateparser.php" |
#line 388 "internal.templateparser.y" |
function yy_r97(){ return; } |
#line 2253 "internal.templateparser.php" |
#line 393 "internal.templateparser.y" |
function yy_r98(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor,'false'); } |
#line 2256 "internal.templateparser.php" |
#line 394 "internal.templateparser.y" |
function yy_r99(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor,'true'); } |
#line 2259 "internal.templateparser.php" |
#line 401 "internal.templateparser.y" |
function yy_r100(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2262 "internal.templateparser.php" |
#line 405 "internal.templateparser.y" |
function yy_r102(){$this->_retvalue = ','.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2265 "internal.templateparser.php" |
#line 406 "internal.templateparser.y" |
function yy_r103(){$this->_retvalue = ',\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } |
#line 2268 "internal.templateparser.php" |
#line 413 "internal.templateparser.y" |
function yy_r105(){$this->_retvalue = '!'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2271 "internal.templateparser.php" |
#line 418 "internal.templateparser.y" |
function yy_r107(){$this->_retvalue =$this->yystack[$this->yyidx + 0]->minor; } |
#line 2274 "internal.templateparser.php" |
#line 419 "internal.templateparser.y" |
function yy_r108(){$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2277 "internal.templateparser.php" |
#line 420 "internal.templateparser.y" |
function yy_r109(){$this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2280 "internal.templateparser.php" |
#line 421 "internal.templateparser.y" |
function yy_r110(){$this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.',(array)'.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2283 "internal.templateparser.php" |
#line 423 "internal.templateparser.y" |
function yy_r112(){$this->_retvalue = '!('.$this->yystack[$this->yyidx + -2]->minor.' % '.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2286 "internal.templateparser.php" |
#line 424 "internal.templateparser.y" |
function yy_r113(){$this->_retvalue = '('.$this->yystack[$this->yyidx + -2]->minor.' % '.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2289 "internal.templateparser.php" |
#line 425 "internal.templateparser.y" |
function yy_r114(){$this->_retvalue = '!(1 & '.$this->yystack[$this->yyidx + -1]->minor.')'; } |
#line 2292 "internal.templateparser.php" |
#line 426 "internal.templateparser.y" |
function yy_r115(){$this->_retvalue = '(1 & '.$this->yystack[$this->yyidx + -1]->minor.')'; } |
#line 2295 "internal.templateparser.php" |
#line 427 "internal.templateparser.y" |
function yy_r116(){$this->_retvalue = '!(1 & '.$this->yystack[$this->yyidx + -2]->minor.' / '.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2298 "internal.templateparser.php" |
#line 428 "internal.templateparser.y" |
function yy_r117(){$this->_retvalue = '(1 & '.$this->yystack[$this->yyidx + -2]->minor.' / '.$this->yystack[$this->yyidx + 0]->minor.')'; } |
#line 2301 "internal.templateparser.php" |
#line 434 "internal.templateparser.y" |
function yy_r123(){$this->prefix_number++; $this->prefix_code[] = '<?php $_tmp'.$this->prefix_number.'='.$this->yystack[$this->yyidx + 0]->minor.';?>'; $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.'$_tmp'.$this->prefix_number; } |
#line 2304 "internal.templateparser.php" |
#line 436 "internal.templateparser.y" |
function yy_r124(){$this->_retvalue = '=='; } |
#line 2307 "internal.templateparser.php" |
#line 437 "internal.templateparser.y" |
function yy_r125(){$this->_retvalue = '!='; } |
#line 2310 "internal.templateparser.php" |
#line 438 "internal.templateparser.y" |
function yy_r126(){$this->_retvalue = '>'; } |
#line 2313 "internal.templateparser.php" |
#line 439 "internal.templateparser.y" |
function yy_r127(){$this->_retvalue = '<'; } |
#line 2316 "internal.templateparser.php" |
#line 440 "internal.templateparser.y" |
function yy_r128(){$this->_retvalue = '>='; } |
#line 2319 "internal.templateparser.php" |
#line 441 "internal.templateparser.y" |
function yy_r129(){$this->_retvalue = '<='; } |
#line 2322 "internal.templateparser.php" |
#line 442 "internal.templateparser.y" |
function yy_r130(){$this->_retvalue = '==='; } |
#line 2325 "internal.templateparser.php" |
#line 443 "internal.templateparser.y" |
function yy_r131(){$this->_retvalue = '!=='; } |
#line 2328 "internal.templateparser.php" |
#line 445 "internal.templateparser.y" |
function yy_r132(){$this->_retvalue = '&&'; } |
#line 2331 "internal.templateparser.php" |
#line 446 "internal.templateparser.y" |
function yy_r133(){$this->_retvalue = '||'; } |
#line 2334 "internal.templateparser.php" |
#line 447 "internal.templateparser.y" |
function yy_r134(){$this->_retvalue = ' XOR '; } |
#line 2337 "internal.templateparser.php" |
#line 452 "internal.templateparser.y" |
function yy_r135(){ $this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')'; } |
#line 2340 "internal.templateparser.php" |
#line 454 "internal.templateparser.y" |
function yy_r137(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2343 "internal.templateparser.php" |
#line 455 "internal.templateparser.y" |
function yy_r138(){ return; } |
#line 2346 "internal.templateparser.php" |
#line 456 "internal.templateparser.y" |
function yy_r139(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2349 "internal.templateparser.php" |
#line 457 "internal.templateparser.y" |
function yy_r140(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2352 "internal.templateparser.php" |
#line 465 "internal.templateparser.y" |
function yy_r144(){$this->_retvalue = "`".$this->yystack[$this->yyidx + -1]->minor."`"; } |
#line 2355 "internal.templateparser.php" |
#line 466 "internal.templateparser.y" |
function yy_r145(){$this->_retvalue = '".'.$this->yystack[$this->yyidx + -1]->minor.'."'; } |
#line 2358 "internal.templateparser.php" |
#line 467 "internal.templateparser.y" |
function yy_r146(){$this->_retvalue = '".'.'$_smarty_tpl->getVariable(\''. $this->yystack[$this->yyidx + 0]->minor .'\')->value'.'."'; $this->nocache=$this->template->getVariable(trim($this->yystack[$this->yyidx + 0]->minor,"'"))->nocache; } |
#line 2361 "internal.templateparser.php" |
#line 468 "internal.templateparser.y" |
function yy_r147(){preg_match('/\s*/',$this->yystack[$this->yyidx + -2]->minor,$s); $this->_retvalue = $s[0].'".('.$this->yystack[$this->yyidx + -1]->minor.')."'; } |
#line 2364 "internal.templateparser.php" |
#line 469 "internal.templateparser.y" |
function yy_r148(){ $this->prefix_number++; $this->prefix_code[] = '<?php ob_start();?>'.$this->yystack[$this->yyidx + 0]->minor.'<?php $_tmp'.$this->prefix_number.'=ob_get_clean();?>'; $this->_retvalue = '".$_tmp'.$this->prefix_number.'."'; } |
#line 2367 "internal.templateparser.php" |
#line 470 "internal.templateparser.y" |
function yy_r149(){$this->_retvalue = '$'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2370 "internal.templateparser.php" |
#line 472 "internal.templateparser.y" |
function yy_r151(){$this->_retvalue = '`'.$this->yystack[$this->yyidx + 0]->minor; } |
#line 2373 "internal.templateparser.php" |
/** |
* placeholder for the left hand side in a reduce operation. |
* |
* For a parser with a rule like this: |
* <pre> |
* rule(A) ::= B. { A = 1; } |
* </pre> |
* |
* The parser will translate to something like: |
* |
* <code> |
* function yy_r0(){$this->_retvalue = 1;} |
* </code> |
*/ |
private $_retvalue; |
/** |
* Perform a reduce action and the shift that must immediately |
* follow the reduce. |
* |
* For a rule such as: |
* |
* <pre> |
* A ::= B blah C. { dosomething(); } |
* </pre> |
* |
* This function will first call the action, if any, ("dosomething();" in our |
* example), and then it will pop three states from the stack, |
* one for each entry on the right-hand side of the expression |
* (B, blah, and C in our example rule), and then push the result of the action |
* back on to the stack with the resulting state reduced to (as described in the .out |
* file) |
* @param int Number of the rule by which to reduce |
*/ |
function yy_reduce($yyruleno) |
{ |
//int $yygoto; /* The next state */ |
//int $yyact; /* The next action */ |
//mixed $yygotominor; /* The LHS of the rule reduced */ |
//TP_yyStackEntry $yymsp; /* The top of the parser's stack */ |
//int $yysize; /* Amount to pop the stack */ |
$yymsp = $this->yystack[$this->yyidx]; |
if (self::$yyTraceFILE && $yyruleno >= 0 |
&& $yyruleno < count(self::$yyRuleName)) { |
fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n", |
self::$yyTracePrompt, $yyruleno, |
self::$yyRuleName[$yyruleno]); |
} |
$this->_retvalue = $yy_lefthand_side = null; |
if (array_key_exists($yyruleno, self::$yyReduceMap)) { |
// call the action |
$this->_retvalue = null; |
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}(); |
$yy_lefthand_side = $this->_retvalue; |
} |
$yygoto = self::$yyRuleInfo[$yyruleno]['lhs']; |
$yysize = self::$yyRuleInfo[$yyruleno]['rhs']; |
$this->yyidx -= $yysize; |
for($i = $yysize; $i; $i--) { |
// pop all of the right-hand side parameters |
array_pop($this->yystack); |
} |
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto); |
if ($yyact < self::YYNSTATE) { |
/* If we are not debugging and the reduce action popped at least |
** one element off the stack, then we can push the new element back |
** onto the stack here, and skip the stack overflow test in yy_shift(). |
** That gives a significant speed improvement. */ |
if (!self::$yyTraceFILE && $yysize) { |
$this->yyidx++; |
$x = new TP_yyStackEntry; |
$x->stateno = $yyact; |
$x->major = $yygoto; |
$x->minor = $yy_lefthand_side; |
$this->yystack[$this->yyidx] = $x; |
} else { |
$this->yy_shift($yyact, $yygoto, $yy_lefthand_side); |
} |
} elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yy_accept(); |
} |
} |
/** |
* The following code executes when the parse fails |
* |
* Code from %parse_fail is inserted here |
*/ |
function yy_parse_failed() |
{ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will be executed whenever the |
** parser fails */ |
} |
/** |
* The following code executes when a syntax error first occurs. |
* |
* %syntax_error code is inserted here |
* @param int The major type of the error token |
* @param mixed The minor type of the error token |
*/ |
function yy_syntax_error($yymajor, $TOKEN) |
{ |
#line 60 "internal.templateparser.y" |
$this->internalError = true; |
$this->yymajor = $yymajor; |
$this->compiler->trigger_template_error(); |
#line 2491 "internal.templateparser.php" |
} |
/** |
* The following is executed when the parser accepts |
* |
* %parse_accept code is inserted here |
*/ |
function yy_accept() |
{ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sAccept!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$stack = $this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will be executed whenever the |
** parser accepts */ |
#line 52 "internal.templateparser.y" |
$this->successful = !$this->internalError; |
$this->internalError = false; |
$this->retvalue = $this->_retvalue; |
//echo $this->retvalue."\n\n"; |
#line 2516 "internal.templateparser.php" |
} |
/** |
* The main parser program. |
* |
* The first argument is the major token number. The second is |
* the token value string as scanned from the input. |
* |
* @param int the token number |
* @param mixed the token value |
* @param mixed any extra arguments that should be passed to handlers |
*/ |
function doParse($yymajor, $yytokenvalue) |
{ |
// $yyact; /* The parser action. */ |
// $yyendofinput; /* True if we are at the end of input */ |
$yyerrorhit = 0; /* True if yymajor has invoked an error */ |
/* (re)initialize the parser, if necessary */ |
if ($this->yyidx === null || $this->yyidx < 0) { |
/* if ($yymajor == 0) return; // not sure why this was here... */ |
$this->yyidx = 0; |
$this->yyerrcnt = -1; |
$x = new TP_yyStackEntry; |
$x->stateno = 0; |
$x->major = 0; |
$this->yystack = array(); |
array_push($this->yystack, $x); |
} |
$yyendofinput = ($yymajor==0); |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sInput %s\n", |
self::$yyTracePrompt, $this->yyTokenName[$yymajor]); |
} |
do { |
$yyact = $this->yy_find_shift_action($yymajor); |
if ($yymajor < self::YYERRORSYMBOL && |
!$this->yy_is_expected_token($yymajor)) { |
// force a syntax error |
$yyact = self::YY_ERROR_ACTION; |
} |
if ($yyact < self::YYNSTATE) { |
$this->yy_shift($yyact, $yymajor, $yytokenvalue); |
$this->yyerrcnt--; |
if ($yyendofinput && $this->yyidx >= 0) { |
$yymajor = 0; |
} else { |
$yymajor = self::YYNOCODE; |
} |
} elseif ($yyact < self::YYNSTATE + self::YYNRULE) { |
$this->yy_reduce($yyact - self::YYNSTATE); |
} elseif ($yyact == self::YY_ERROR_ACTION) { |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sSyntax Error!\n", |
self::$yyTracePrompt); |
} |
if (self::YYERRORSYMBOL) { |
/* A syntax error has occurred. |
** The response to an error depends upon whether or not the |
** grammar defines an error token "ERROR". |
** |
** This is what we do if the grammar does define ERROR: |
** |
** * Call the %syntax_error function. |
** |
** * Begin popping the stack until we enter a state where |
** it is legal to shift the error symbol, then shift |
** the error symbol. |
** |
** * Set the error count to three. |
** |
** * Begin accepting and shifting new tokens. No new error |
** processing will occur until three tokens have been |
** shifted successfully. |
** |
*/ |
if ($this->yyerrcnt < 0) { |
$this->yy_syntax_error($yymajor, $yytokenvalue); |
} |
$yymx = $this->yystack[$this->yyidx]->major; |
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit ){ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sDiscard input token %s\n", |
self::$yyTracePrompt, $this->yyTokenName[$yymajor]); |
} |
$this->yy_destructor($yymajor, $yytokenvalue); |
$yymajor = self::YYNOCODE; |
} else { |
while ($this->yyidx >= 0 && |
$yymx != self::YYERRORSYMBOL && |
($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE |
){ |
$this->yy_pop_parser_stack(); |
} |
if ($this->yyidx < 0 || $yymajor==0) { |
$this->yy_destructor($yymajor, $yytokenvalue); |
$this->yy_parse_failed(); |
$yymajor = self::YYNOCODE; |
} elseif ($yymx != self::YYERRORSYMBOL) { |
$u2 = 0; |
$this->yy_shift($yyact, self::YYERRORSYMBOL, $u2); |
} |
} |
$this->yyerrcnt = 3; |
$yyerrorhit = 1; |
} else { |
/* YYERRORSYMBOL is not defined */ |
/* This is what we do if the grammar does not define ERROR: |
** |
** * Report an error message, and throw away the input token. |
** |
** * If the input token is $, then fail the parse. |
** |
** As before, subsequent error messages are suppressed until |
** three input tokens have been successfully shifted. |
*/ |
if ($this->yyerrcnt <= 0) { |
$this->yy_syntax_error($yymajor, $yytokenvalue); |
} |
$this->yyerrcnt = 3; |
$this->yy_destructor($yymajor, $yytokenvalue); |
if ($yyendofinput) { |
$this->yy_parse_failed(); |
} |
$yymajor = self::YYNOCODE; |
} |
} else { |
$this->yy_accept(); |
$yymajor = self::YYNOCODE; |
} |
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0); |
} |
} |
/branches/ant-ng/lib/sysplugins/method.disabledebuggingurlctrl.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableDebuggingUrlCtrl |
* |
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute |
*/ |
function disableDebuggingUrlCtrl($smarty) |
{ |
$smarty->debugging_ctrl = 'none'; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_assign.php |
---|
Новый файл |
0,0 → 1,69 |
<?php |
/** |
* Smarty Internal Plugin Compile Assign |
* |
* Compiles the {assign} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Assign Class |
*/ |
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {assign} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('var', 'value'); |
$this->optional_attributes = array('scope', 'nocache', 'index'); |
$_nocache = 'null'; |
$_scope = 'null'; |
// check for nocache attribute before _get_attributes because |
// it shall not controll caching of the compiled code, but is a parameter |
if (isset($args['nocache'])) { |
if ($args['nocache'] == 'true') { |
$_nocache = 'true'; |
$_nocache_boolean = true; |
} |
unset($args['nocache']); |
} |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
if (isset($_attr['scope'])) { |
if ($_attr['scope'] == '\'parent\'') { |
$_scope = SMARTY_PARENT_SCOPE; |
} elseif ($_attr['scope'] == '\'root\'') { |
$_scope = SMARTY_ROOT_SCOPE; |
} elseif ($_attr['scope'] == '\'global\'') { |
$_scope = SMARTY_GLOBAL_SCOPE; |
} |
} |
if (isset($_attr['index'])) { |
$_index = $_attr['index']; |
} |
// compiled output |
if (isset($_attr['index'])) { |
if ($_attr['index'] == '') { |
return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>"; |
} else { |
return "<?php \$_tmp$_attr[index] = $_attr[value]; \$_smarty_tpl->append($_attr[var],\$_tmp,true,$_nocache,$_scope);?>"; |
} |
} else { |
return "<?php \$_smarty_tpl->assign($_attr[var],$_attr[value],$_nocache,$_scope);?>"; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_else.php |
---|
Новый файл |
0,0 → 1,33 |
<?php |
/** |
* Smarty Internal Plugin Compile Else |
* |
* Compiles the {else} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Else Class |
*/ |
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {else} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->_close_tag(array('if', 'elseif')); |
$this->_open_tag('else'); |
return '<?php else: ?>'; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_include_php.php |
---|
Новый файл |
0,0 → 1,70 |
<?php |
/** |
* Smarty Internal Plugin Compile Include PHP |
* |
* Compiles the {include_php} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Insert Class |
*/ |
class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {include_php} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('file'); |
$this->optional_attributes = array('once', 'assign'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$_output = '<?php '; |
// save posible attributes |
$_file = $_attr['file']; |
$_file = realpath(trim($_file, "'")); |
if ($this->smarty->security) { |
$this->smarty->security_handler->isTrustedPHPDir($_file); |
} |
if ($_file === false) { |
$this->compiler->trigger_template_error('include_php: file "' . $_attr['file'] . '" is not readable'); |
} |
if ($this->smarty->security) { |
$this->smarty->security_handler->isTrustedPHPDir($_file); |
} |
if (isset($_attr['assign'])) { |
// output will be stored in a smarty variable instead of being displayed |
$_assign = $_attr['assign']; |
} |
$_once = '_once'; |
if (isset($_attr['once'])) { |
if ($_attr['once'] == 'false') { |
$_once = ''; |
} |
} |
$_output = '<?php '; |
if (isset($_assign)) { |
$_output .= 'ob_start(); include' . $_once . ' (\'' . $_file . '\'); $_smarty_tpl->assign(' . $_assign . ',ob_get_contents()); ob_end_clean();?>'; |
} else { |
$this->compiler->has_output = true; |
$_output .= 'include' . $once . ' (' . $_file . '); ?>'; |
} |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.config.php |
---|
Новый файл |
0,0 → 1,246 |
<?php |
/** |
* Smarty Internal Plugin Config |
* |
* Main class for config variables |
* |
* @ignore |
* @package Smarty |
* @subpackage Config |
* @author Uwe Tews |
*/ |
class Smarty_Internal_Config { |
static $config_objects = array(); |
public function __construct($config_resource, $smarty) |
{ |
$this->smarty = $smarty; |
$this->config_resource = $config_resource; |
$this->config_resource_type = null; |
$this->config_resource_name = null; |
$this->config_filepath = null; |
$this->config_timestamp = null; |
$this->config_source = null; |
$this->compiled_config = null; |
$this->compiled_filepath = null; |
$this->compiled_timestamp = null; |
$this->mustCompile = null; |
$this->compiler_object = null; |
// parse config resource name |
if (!$this->parseConfigResourceName ($config_resource)) { |
throw new Exception ("Unable to parse config resource '{$config_resource}'"); |
} |
} |
public function getConfigFilepath () |
{ |
return $this->config_filepath === null ? |
$this->config_filepath = $this->buildConfigFilepath() : |
$this->config_filepath; |
} |
public function getTimestamp () |
{ |
return $this->config_timestamp === null ? |
$this->config_timestamp = filemtime($this->getConfigFilepath()) : |
$this->config_timestamp; |
} |
private function parseConfigResourceName($config_resource) |
{ |
if (empty($config_resource)) |
return false; |
if (strpos($config_resource, ':') === false) { |
// no resource given, use default |
$this->config_resource_type = $this->smarty->default_config_type; |
$this->config_resource_name = $config_resource; |
} else { |
// get type and name from path |
list($this->config_resource_type, $this->config_resource_name) = explode(':', $config_resource, 2); |
if (strlen($this->config_resource_type) == 1) { |
// 1 char is not resource type, but part of filepath |
$this->config_resource_type = $this->smarty->default_config_type; |
$this->config_resource_name = $config_resource; |
} else { |
$this->config_resource_type = strtolower($this->config_resource_type); |
} |
} |
return true; |
} |
/* |
* get system filepath to config |
*/ |
public function buildConfigFilepath () |
{ |
foreach((array)$this->smarty->config_dir as $_config_dir) { |
if (strpos('/\\', substr($_config_dir, -1)) === false) { |
$_config_dir .= DS; |
} |
$_filepath = $_config_dir . $this->config_resource_name; |
if (file_exists($_filepath)) |
return $_filepath; |
} |
// no tpl file found |
throw new Exception("Unable to load config file \"{$this->config_resource_name}\""); |
return false; |
} |
/** |
* Read config file source |
* |
* @return string content of source file |
*/ |
/** |
* Returns the template source code |
* |
* The template source is being read by the actual resource handler |
* |
* @return string the template source |
*/ |
public function getConfigSource () |
{ |
if ($this->config_source === null) { |
if ($this->readConfigSource($this) === false) { |
throw new Exception("Unable to load config file \"{$this->config_resource_name}\""); |
} |
} |
return $this->config_source; |
} |
public function readConfigSource() |
{ |
// read source file |
if (file_exists($this->getConfigFilepath())) { |
$this->config_source = file_get_contents($this->getConfigFilepath()); |
return true; |
} else { |
return false; |
} |
} |
/** |
* Returns the compiled filepath |
* |
* @return string the compiled filepath |
*/ |
public function getCompiledFilepath () |
{ |
return $this->compiled_filepath === null ? |
($this->compiled_filepath = $this->buildCompiledFilepath()) : |
$this->compiled_filepath; |
} |
public function buildCompiledFilepath() |
{ |
$_filepath = (string)abs(crc32($this->config_resource_name)); |
// if use_sub_dirs, break file into directories |
if ($this->smarty->use_sub_dirs) { |
$_filepath = substr($_filepath, 0, 3) . DS |
. substr($_filepath, 0, 2) . DS |
. substr($_filepath, 0, 1) . DS |
. $_filepath; |
} |
$_compile_dir = $this->smarty->compile_dir; |
if (substr($_compile_dir, -1) != DS) { |
$_compile_dir .= DS; |
} |
return $_compile_dir . $_filepath . '.' . basename($this->config_resource_name) . '.config' . $this->smarty->php_ext; |
} |
/** |
* Returns the timpestamp of the compiled file |
* |
* @return integer the file timestamp |
*/ |
public function getCompiledTimestamp () |
{ |
return $this->compiled_timestamp === null ? |
($this->compiled_timestamp = (file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false) : |
$this->compiled_timestamp; |
} |
/** |
* Returns if the current config file must be compiled |
* |
* It does compare the timestamps of config source and the compiled config and checks the force compile configuration |
* |
* @return boolean true if the file must be compiled |
*/ |
public function mustCompile () |
{ |
return $this->mustCompile === null ? |
$this->mustCompile = ($this->smarty->force_compile || $this->getCompiledTimestamp () !== $this->getTimestamp ()): |
$this->mustCompile; |
} |
/** |
* Returns the compiled config file |
* |
* It checks if the config file must be compiled or just read the compiled version |
* |
* @return string the compiled config file |
*/ |
public function getCompiledConfig () |
{ |
if ($this->compiled_config === null) { |
// see if template needs compiling. |
if ($this->mustCompile()) { |
$this->compileConfigSource(); |
} else { |
$this->compiled_config = file_get_contents($this->getCompiledFilepath()); |
} |
} |
return $this->compiled_config; |
} |
/** |
* Compiles the config files |
*/ |
public function compileConfigSource () |
{ |
// compile template |
if (!is_object($this->compiler_object)) { |
// load compiler |
$this->smarty->loadPlugin('Smarty_Internal_Config_File_Compiler'); |
$this->compiler_object = new Smarty_Internal_Config_File_Compiler($this->smarty); |
} |
if (!is_object($this->smarty->write_file_object)) { |
$this->smarty->loadPlugin("Smarty_Internal_Write_File"); |
$this->smarty->write_file_object = new Smarty_Internal_Write_File; |
} |
// call compiler |
if ($this->compiler_object->compileSource($this)) { |
// compiling succeded |
// write compiled template |
$this->smarty->write_file_object->writeFile($this->getCompiledFilepath(), $this->getCompiledConfig()); |
// make template and compiled file timestamp match |
touch($this->getCompiledFilepath(), $this->getTimestamp()); |
} else { |
// error compiling template |
throw new Exception("Error compiling template {$this->getConfigFilepath ()}"); |
return false; |
} |
} |
/* |
* load config variables |
* |
* @param mixed $sections array of section names, single section or null |
* @param object $scope global,parent or local |
*/ |
public function loadConfigVars ($sections = null, $scope) |
{ |
$config_data = unserialize($this->getCompiledConfig()); |
// var_dump($config_data); |
// copy global config vars |
foreach ($config_data['vars'] as $variable => $value) { |
$scope->config_vars[$variable] = $value; |
} |
// scan sections |
foreach ($config_data['sections'] as $this_section => $dummy) { |
if ($sections == null || in_array($this_section, (array)$sections)) { |
foreach ($config_data['sections'][$this_section]['vars'] as $variable => $value) { |
$scope->config_vars[$variable] = $value; |
} |
} |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_foreachclose.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty Internal Plugin Compile Foreach Close |
* |
* Compiles the {/foreach} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile ForeachClose Class |
*/ |
class Smarty_Internal_Compile_ForeachClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/foreach} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$_open_tag = $this->_close_tag(array('foreach', 'foreachelse')); |
if ($_open_tag == 'foreachelse') |
return "<?php } ?>"; |
else |
return "<?php }} ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_modifier.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty method Register_Modifier |
* |
* Registers a PHP function as Smarty modifier plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers modifier to be used in templates |
* |
* @param object $smarty |
* @param string $modifier name of template modifier |
* @param string $modifier_impl name of PHP function to register |
*/ |
function register_modifier($smarty, $modifier, $modifier_impl) |
{ |
if (isset($smarty->registered_plugins[$modifier])) { |
throw new Exception("Plugin \"{$modifier}\" already registered"); |
} elseif (!is_callable($modifier_impl)) { |
throw new Exception("Plugin \"{$modifier}\" not callable"); |
} else { |
$smarty->registered_plugins[$modifier] = |
array('modifier', $modifier_impl); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_if.php |
---|
Новый файл |
0,0 → 1,40 |
<?php |
/** |
* Smarty Internal Plugin Compile If |
* |
* Compiles the {if} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile If Class |
*/ |
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {if} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('if condition'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('if'); |
if (is_array($args['if condition'])) { |
$_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n"; |
$_output .= " if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."): ?>"; |
return $_output; |
} else { |
return '<?php if (' . $args['if condition'] . '): ?>'; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enabledebugging.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableDebugging |
* |
* Enable debugging |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable debugging |
*/ |
public function enableDebugging($smarty) |
{ |
$this->smarty->debugging = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_section.php |
---|
Новый файл |
0,0 → 1,112 |
<?php |
/** |
* Smarty Internal Plugin Compile Section |
* |
* Compiles the {section} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Section Class |
*/ |
class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {section} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('name', 'loop'); |
$this->optional_attributes = array('start', 'step', 'max', 'show'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('section'); |
$output = "<?php "; |
$section_name = $_attr['name']; |
$output .= "unset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]);\n"; |
$section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]"; |
foreach ($_attr as $attr_name => $attr_value) { |
switch ($attr_name) { |
case 'loop': |
$output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n"; |
break; |
case 'show': |
if (is_bool($attr_value)) |
$show_attr_value = $attr_value ? 'true' : 'false'; |
else |
$show_attr_value = "(bool)$attr_value"; |
$output .= "{$section_props}['show'] = $show_attr_value;\n"; |
break; |
case 'name': |
$output .= "{$section_props}['$attr_name'] = $attr_value;\n"; |
break; |
case 'max': |
case 'start': |
$output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n"; |
break; |
case 'step': |
$output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n"; |
break; |
} |
} |
if (!isset($_attr['show'])) |
$output .= "{$section_props}['show'] = true;\n"; |
if (!isset($_attr['loop'])) |
$output .= "{$section_props}['loop'] = 1;\n"; |
if (!isset($_attr['max'])) |
$output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; |
else |
$output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n"; |
if (!isset($_attr['step'])) |
$output .= "{$section_props}['step'] = 1;\n"; |
if (!isset($_attr['start'])) |
$output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; |
else { |
$output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; |
} |
$output .= "if ({$section_props}['show']) {\n"; |
if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) { |
$output .= " {$section_props}['total'] = {$section_props}['loop'];\n"; |
} else { |
$output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; |
} |
$output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n"; |
$output .= "if ({$section_props}['show']):\n"; |
$output .= " |
for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1; |
{$section_props}['iteration'] <= {$section_props}['total']; |
{$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n"; |
$output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n"; |
$output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n"; |
$output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n"; |
$output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n"; |
$output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n"; |
$output .= "?>"; |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isconfigbooleanize.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isConfigBooleanize |
* |
* is config booleanize mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is config booleanize mode |
*/ |
public function isConfigBooleanize($smarty) |
{ |
return $smarty->config_booleanize; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enabledebuggingurlctrl.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableDebuggingUrlCtrl |
* |
* Enable possibility to enable debugging by SMARTY_DEBUG attribute |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable possibility to enable debugging by SMARTY_DEBUG attribute |
*/ |
function enableDebuggingUrlCtrl($smarty) |
{ |
$smarty->debugging_ctrl = 'URL'; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compilebase.php |
---|
Новый файл |
0,0 → 1,109 |
<?php |
/** |
* Smarty Internal Plugin CompileBase |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/* |
interface TagCompilerInterface { |
public function compile($args, $compiler); |
} |
*/ |
/** |
* This class does extend all internal compile plugins |
*/ |
//abstract class Smarty_Internal_CompileBase implements TagCompilerInterface |
abstract class Smarty_Internal_CompileBase |
{ |
function __construct() |
{ |
// initialize valid attributes |
$this->required_attributes = array(); |
$this->optional_attributes = array(); |
} |
/** |
* This function checks if the attributes passed are valid |
* |
* The attributes passed for the tag to compile are checked against the list of required and |
* optional attributes. Required attributes must be present. Optional attributes are check against |
* against the corresponding list. The keyword '_any' specifies that any attribute will be accepted |
* as valid |
* |
* @todo More generallized handling of the nocache attributes in compile plugins |
* @param array $args attributes applied to the tag |
* @return array attributes for further processing |
*/ |
function _get_attributes ($args) |
{ |
// check if all required attributes present |
foreach ($this->required_attributes as $attr) { |
if (!array_key_exists($attr, $args)) { |
$this->compiler->trigger_template_error("missing \"" . $attr . "\" attribute"); |
} |
} |
// check for unallowed attributes |
if ($this->optional_attributes != array('_any')) { |
$tmp_array = array_merge($this->required_attributes, $this->optional_attributes); |
foreach ($args as $key => $dummy) { |
if (!in_array($key, $tmp_array) && $key !== 0) { |
$this->compiler->trigger_template_error("unexspected \"" . $key . "\" attribute"); |
} |
} |
} |
return $args; |
} |
/** |
* Push opening tag name on stack |
* |
* Optionally additional data can be saved on stack |
* |
* @param string $open_tag the opening tag's name |
* @param anytype $data optional data which shall be saved on stack |
*/ |
function _open_tag($open_tag, $data = null) |
{ |
array_push($this->compiler->_tag_stack, array($open_tag, $data)); |
} |
/** |
* Pop closing tag |
* |
* Raise an error if this stack-top doesn't match with expected opening tags |
* |
* @param array $ |string $expected_tag the expected opening tag names |
* @return anytype the opening tag's name or saved data |
*/ |
function _close_tag($expected_tag) |
{ |
if (count($this->compiler->_tag_stack) > 0) { |
// get stacked info |
list($_open_tag, $_data) = array_pop($this->compiler->_tag_stack); |
// open tag must match with the expected ones |
if (in_array($_open_tag, (array)$expected_tag)) { |
if (is_null($_data)) { |
// return opening tag |
return $_open_tag; |
} else { |
// return restored data |
return $_data; |
} |
} |
// wrong nesting of tags |
$this->compiler->trigger_template_error("unclosed {" . $_open_tag . "} tag"); |
return; |
} |
// wrong nesting of tags |
$this->compiler->trigger_template_error("unexpected closing tag"); |
return; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disablevariablefilter.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableVariableFilter |
* |
* Disable filter on variable output |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable filter on variable output |
*/ |
function disableVariableFilter($smarty) |
{ |
$smarty->variable_filter = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_internal_function_call.php |
---|
Новый файл |
0,0 → 1,76 |
<?php |
/** |
* Smarty Internal Plugin Compile Internal_Function_Call |
* |
* Compiles the {internal_function_call} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Internal_Function_Call Class |
*/ |
class Smarty_Internal_Compile_Internal_Function_Call extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {internal_function_call} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('name'); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// save posible attributes |
if (isset($_attr['assign'])) { |
// output will be stored in a smarty variable instead of beind displayed |
$_assign = $_attr['assign']; |
} |
$_name = trim($_attr['name'], "'"); |
// create template object |
$_output = "<?php \$_template = new Smarty_Template ('string:', \$_smarty_tpl->smarty, \$_smarty_tpl);\n"; |
// assign default paramter |
if (isset($this->smarty->template_functions[$_name]['parameter'])) { |
// function is already compiled |
foreach ($this->smarty->template_functions[$_name]['parameter'] as $_key => $_value) { |
if (!isset($_attr[$_key])) { |
$_output .= "\$_template->assign('$_key',$_value);\n"; |
} |
} |
} |
if (isset($compiler->template->properties['function'][$_name]['parameter'])) { |
// for recursive call during function compilation |
foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) { |
if (!isset($_attr[$_key])) { |
$_output .= "\$_template->assign('$_key',$_value);\n"; |
} |
} |
} |
// delete {include} standard attributes |
unset($_attr['name'], $_attr['assign']); |
// remaining attributes must be assigned as smarty variable |
if (!empty($_attr)) { |
// create variables |
foreach ($_attr as $_key => $_value) { |
$_output .= "\$_template->assign('$_key',$_value);\n"; |
} |
} |
// load compiled function |
$_output .= "\$_template->compiled_template = \$this->smarty->template_functions['$_name']['compiled'];\n\$_template->mustCompile = false;\n"; |
// was there an assign attribute |
if (isset($_assign)) { |
$_output .= "\$_smarty_tpl->assign($_assign,\$_smarty_tpl->smarty->fetch(\$_template)); ?>"; |
} else { |
$_output .= "echo \$_smarty_tpl->smarty->fetch(\$_template); ?>"; |
} |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getdebugtemplate.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getDebugTemplate |
* |
* Returns debug template filepath |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns debug template filepath |
*/ |
/** |
* Returns directory of cache files |
* |
* @return string debug template filepath |
*/ |
function GetDebugTemplate($smarty) |
{ |
return $smarty->debug_tpl; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_compiler_function.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method Unregister_Compiler_Function |
* |
* Unregister a Smarty compiler function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a Smarty compiler function plugin |
*/ |
/** |
* Unregisters compiler function |
* |
* @param string $compiler_tag name of template function |
*/ |
function unregister_compiler_function($smarty, $compiler_tag) |
{ |
if (isset($smarty->registered_plugins[$compiler_tag]) && $smarty->registered_plugins[$compiler_tag][0] == 'compiler') { |
unset($smarty->registered_plugins[$compiler_tag]); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getcompiledir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getCompileDir |
* |
* Returns directory of compiled templates |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns directory of compiled templates |
*/ |
/** |
* Returns directory of compiled templates |
* |
* @return array compiled template folder |
*/ |
function GetCompileDir($smarty) |
{ |
return $this->smarty->compile_dir; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_ifclose.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty Internal Plugin Compile If Close |
* |
* Compiles the {/if} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile IfClose Class |
*/ |
class Smarty_Internal_Compile_IfClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/if} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->_close_tag(array('if', 'else', 'elseif')); |
return "<?php endif;?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.iscaching.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isCaching |
* |
* is caching |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is caching |
*/ |
function isCaching($smarty) |
{ |
return $smarty->caching; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_extend.php |
---|
Новый файл |
0,0 → 1,196 |
<?php |
/** |
* Smarty Internal Plugin Resource Extend |
* |
* Implements the file system as resource for Smarty which does extend a chain of template files templates |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource Extend |
*/ |
class Smarty_Internal_Resource_Extend { |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
// classes used for compiling Smarty templates from file resource |
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
public $template_parser_class = 'Smarty_Internal_Templateparser'; |
/** |
* Return flag if template source is existing |
* |
* @param object $template template object |
* @return boolean result |
*/ |
public function isExisting($template) |
{ |
if ($template->getTemplateFilepath() === false) { |
return false; |
} else { |
return true; |
} |
} |
/** |
* Get filepath to template source |
* |
* @param object $template template object |
* @return string filepath to template source file |
*/ |
public function getTemplateFilepath($template) |
{ |
$_files = explode('|', $template->resource_name); |
$_filepath = $template->buildTemplateFilepath ($_files[count($_files)-1]); |
if ($_filepath !== false) { |
if ($template->security) { |
$template->smarty->security_handler->isTrustedResourceDir($_filepath); |
} |
} |
return $_filepath; |
} |
/** |
* Get timestamp to template source |
* |
* @param object $template template object |
* @return integer timestamp of template source file |
*/ |
public function getTemplateTimestamp($template) |
{ |
return filemtime($template->getTemplateFilepath()); |
} |
/** |
* Read template source from file |
* |
* @param object $template template object |
* @return string content of template source file |
*/ |
public function getTemplateSource($template) |
{ |
$this->template = $template; |
$_files = explode('|', $template->resource_name); |
$_files = array_reverse($_files); |
foreach ($_files as $_file) { |
$_filepath = $template->buildTemplateFilepath ($_file); |
// read template file |
if ($_filepath === false) { |
throw new Exception("Unable to load template \"file : {$_file}\""); |
} |
if ($_file != $_files[0]) { |
$template->properties['file_dependency']['F' . abs(crc32($_filepath))] = array($_filepath, filemtime($_filepath)); |
} |
$_content = file_get_contents($_filepath); |
if ($_file != $_files[count($_files)-1]) { |
if (preg_match_all('/(' . $this->smarty->left_delimiter . 'block(.+?)' . $this->smarty->right_delimiter . ')/', $_content, $_open, PREG_OFFSET_CAPTURE) != |
preg_match_all('/(' . $this->smarty->left_delimiter . '\/block(.*?)' . $this->smarty->right_delimiter . ')/', $_content, $_close, PREG_OFFSET_CAPTURE)) { |
$this->smarty->trigger_error(" unmatched {block} {/block} pairs"); |
} |
$_block_count = count($_open[0]); |
for ($_i = 0; $_i < $_block_count; $_i++) { |
$_block_content = str_replace($this->smarty->left_delimiter . '$smarty.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', |
substr($_content, $_open[0][$_i][1] + strlen($_open[0][$_i][0]), $_close[0][$_i][1] - $_open[0][$_i][1] - strlen($_open[0][$_i][0]))); |
$this->saveBlockData($_block_content, $_open[0][$_i][0]); |
} |
} else { |
$template->template_source = $_content; |
return true; |
} |
} |
} |
protected function saveBlockData($block_content, $block_tag) |
{ |
if (0 == preg_match('/(.?)(name=)([^ ]*)/', $block_tag, $_match)) { |
$this->smarty->trigger_error("\"" . $block_tag . "\" missing name attribute"); |
} else { |
// compile block content |
$_tpl = $this->smarty->createTemplate('string:' . $block_content); |
$_tpl->template_filepath = $this->template->getTemplateFilepath(); |
$_tpl->suppressHeader = true; |
$_compiled_content = $_tpl->getCompiledTemplate(); |
unset($_tpl); |
$_name = trim($_match[3], "\"'}"); |
if (isset($this->template->block_data[$_name])) { |
if (strpos($this->template->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { |
$this->template->block_data[$_name]['compiled'] = |
str_replace('%%%%SMARTY_PARENT%%%%', $_compiled_content, $this->template->block_data[$_name]['compiled']); |
} elseif ($this->template->block_data[$_name]['mode'] == 'prepend') { |
$this->template->block_data[$_name]['compiled'] .= $_compiled_content; |
} elseif ($this->template->block_data[$_name]['mode'] == 'append') { |
$this->template->block_data[$_name]['compiled'] = $_compiled_content . $this->template->block_data[$_name]['compiled']; |
} |
} else { |
$this->template->block_data[$_name]['compiled'] = $_compiled_content; |
} |
if (preg_match('/(.?)(append=true)(.*)/', $block_tag, $_match) != 0) { |
$this->template->block_data[$_name]['mode'] = 'append'; |
} elseif (preg_match('/(.?)(prepend=true)(.*)/', $block_tag, $_match) != 0) { |
$this->template->block_data[$_name]['mode'] = 'prepend'; |
} else { |
$this->template->block_data[$_name]['mode'] = 'replace'; |
} |
} |
} |
/** |
* Return flag that this resource uses the compiler |
* |
* @return boolean true |
*/ |
public function usesCompiler() |
{ |
// template has tags, uses compiler |
return true; |
} |
/** |
* Return flag that this is not evaluated |
* |
* @return boolean false |
*/ |
public function isEvaluated() |
{ |
// save the compiled file to disk, do not evaluate |
return false; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $template template object |
* @return string return path to compiled template |
*/ |
public function getCompiledFilepath($template) |
{ |
$_files = explode('|', $template->resource_name); |
$_filepath = (string)abs(crc32($template->resource_name)); |
// if use_sub_dirs, break file into directories |
if ($template->smarty->use_sub_dirs) { |
$_filepath = substr($_filepath, 0, 3) . DS |
. substr($_filepath, 0, 2) . DS |
. substr($_filepath, 0, 1) . DS |
. $_filepath; |
} |
$_compile_dir_sep = $template->smarty->use_sub_dirs ? DS : '^'; |
if (isset($template->compile_id)) { |
$_filepath = $template->compile_id . $_compile_dir_sep . $_filepath; |
} |
if ($template->caching) { |
$_cache = '.cache'; |
} else { |
$_cache = ''; |
} |
$_compile_dir = $template->smarty->compile_dir; |
if (substr($_compile_dir, -1) != DS) { |
$_compile_dir .= DS; |
} |
return $_compile_dir . $_filepath . '.' . basename($_files[count($_files)-1]) . $_cache . $template->smarty->php_ext; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.config_file_compiler.php |
---|
Новый файл |
0,0 → 1,116 |
<?php |
/** |
* Smarty Internal Plugin Config File Compiler |
* |
* This is the config file compiler class. It calls the lexer and parser to |
* perform the compiling. |
* |
* @package Smarty |
* @subpackage Config |
* @author Uwe Tews |
*/ |
/** |
* Main config file compiler class |
*/ |
class Smarty_Internal_Config_File_Compiler { |
public $compile_error= false; |
/** |
* Initialize compiler |
*/ |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
// get required plugins |
$this->smarty->loadPlugin('Smarty_Internal_Configfilelexer'); |
$this->smarty->loadPlugin('Smarty_Internal_Configfileparser'); |
$this->config_data['sections'] = array(); |
$this->config_data['vars'] = array(); |
} |
/** |
* Methode to compile a Smarty template |
* |
* @param $template template object to compile |
* @return bool true if compiling succeeded, false if it failed |
*/ |
public function compileSource($config) |
{ |
/* here is where the compiling takes place. Smarty |
tags in the templates are replaces with PHP code, |
then written to compiled files. */ |
$this->config = $config; |
// get config file source |
$_content = $config->getConfigSource(); |
// on empty template just return |
if ($_content == '') { |
return true; |
} |
// init the lexer/parser to compile the config file |
$lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty); |
$parser = new Smarty_Internal_Configfileparser($lex, $this); |
// $parser->PrintTrace(); |
// get tokens from lexer and parse them |
while ($lex->yylex()) { |
// echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; |
$parser->doParse($lex->token, $lex->value); |
} |
// finish parsing process |
$parser->doParse(0, 0); |
$config->compiled_config = serialize($this->config_data); |
if (!$this->compile_error) { |
return true; |
} else { |
// compilation error |
return false; |
} |
} |
/** |
* display compiler error messages without dying |
* |
* If parameter $args is empty it is a parser detected syntax error. |
* In this case the parser is called to obtain information about exspected tokens. |
* |
* If parameter $args contains a string this is used as error message |
* |
* @todo output exact position of parse error in source line |
* @param $args string individual error message or null |
*/ |
public function trigger_config_file_error($args = null) |
{ |
$this->lex = Smarty_Internal_Configfilelexer::instance(); |
$this->parser = Smarty_Internal_Configfileparser::instance(); |
// get template source line which has error |
$line = $this->lex->line; |
if (isset($args)) { |
// $line--; |
} |
$match = preg_split("/\n/", $this->lex->data); |
$error_text = 'Syntax Error in config file "' . $this->config->getConfigFilepath() . '" on line ' . $line . ' "'. $match[$line-1].'" '; |
if (isset($args)) { |
// individual error message |
$error_text .= $args; |
} else { |
// exspected token from parser |
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { |
$exp_token = $this->parser->yyTokenName[$token]; |
if (isset($this->lex->smarty_token_names[$exp_token])) { |
// token type from lexer |
$expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; |
} else { |
// otherwise internal token name |
$expect[] = $this->parser->yyTokenName[$token]; |
} |
} |
// output parser error message |
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect); |
} |
throw new Exception($error_text); |
// set error flag |
$this->compile_error = true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_php.php |
---|
Новый файл |
0,0 → 1,145 |
<?php |
/** |
* Smarty Internal Plugin Resource PHP |
* |
* Implements the file system as resource for PHP templates |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource PHP |
*/ |
class Smarty_Internal_Resource_PHP { |
/** |
* Class constructor, enable short open tags |
*/ |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
ini_set('short_open_tag', '1'); |
} |
/** |
* Return flag if template source is existing |
* |
* @return boolean true |
*/ |
public function isExisting($template) |
{ |
if ($template->getTemplateFilepath() === false) { |
return false; |
} else { |
return true; |
} |
} |
/** |
* Get filepath to template source |
* |
* @param object $_template template object |
* @return string filepath to template source file |
*/ |
public function getTemplateFilepath($_template) |
{ |
$_filepath = $_template->buildTemplateFilepath (); |
if ($_template->security) { |
$_template->smarty->security_handler->isTrustedResourceDir($_filepath); |
} |
return $_filepath; |
} |
/** |
* Get timestamp to template source |
* |
* @param object $_template template object |
* @return integer timestamp of template source file |
*/ |
public function getTemplateTimestamp($_template) |
{ |
return filemtime($_template->getTemplateFilepath()); |
} |
/** |
* Read template source from file |
* |
* @param object $_template template object |
* @return string content of template source file |
*/ |
public function getTemplateSource($_template) |
{ |
if (file_exists($_template->getTemplateFilepath())) { |
$_template->template_source = file_get_contents($_template->getTemplateFilepath()); |
return true; |
} else { |
return false; |
} |
} |
/** |
* Return flag that this resource not use the compiler |
* |
* @return boolean false |
*/ |
public function usesCompiler() |
{ |
// does not use compiler, template is PHP |
return false; |
} |
/** |
* Return flag that this is not evaluated |
* |
* @return boolean false |
*/ |
public function isEvaluated() |
{ |
// does not use compiler, must be false |
return false; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $_template template object |
* @return boolean return false as compiled template is not stored |
*/ |
public function getCompiledFilepath($_template) |
{ |
// no filepath for PHP templates |
return false; |
} |
/** |
* renders the PHP template |
*/ |
public function renderUncompiled($_smarty_template) |
{ |
if (!$this->smarty->allow_php_templates) { |
throw new Exception("PHP templates are disabled"); |
} |
if ($this->getTemplateFilepath($_smarty_template) === false) { |
throw new Exception("Unable to load template \"{$_smarty_template->resource_type} : {$_smarty_template->resource_name}\""); |
} |
// prepare variables |
$_smarty_ptr = $_smarty_template; |
do { |
foreach ($_smarty_ptr->tpl_vars as $_smarty_var => $_smarty_var_object) { |
if (isset($_smarty_var_object->value)) { |
$$_smarty_var = $_smarty_var_object->value; |
} |
} |
$_smarty_ptr = $_smarty_ptr->parent; |
} while ($_smarty_ptr != null); |
unset ($_smarty_var, $_smarty_var_object, $_smarty_ptr); |
// include PHP template |
include($this->getTemplateFilepath($_smarty_template)); |
return; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isdefaulttimezone.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isDefaultTimezone |
* |
* is setting of default timezone |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is setting of default timezone |
*/ |
function isDefaultTimezone($smarty) |
{ |
return $smarty->set_timezone = false; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_function.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method Unregister_Function |
* |
* Unregister a Smarty function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a Smarty function plugin |
*/ |
/** |
* Unregisters custom function |
* |
* @param string $function_tag name of template function |
*/ |
function unregister_function($smarty, $function_tag) |
{ |
if (isset($smarty->registered_plugins[$function_tag]) && $smarty->registered_plugins[$function_tag][0] == 'function') { |
unset($smarty->registered_plugins[$function_tag]); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disablecachemodifycheck.php |
---|
Новый файл |
0,0 → 1,23 |
<?php |
/** |
* Smarty method disableCacheModifyCheck |
* |
* Disable cache modify check |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* |
* Disable cache modify check |
*/ |
function disableCacheModifyCheck($smarty) |
{ |
$smarty->cache_modified_check = false; |
return ; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_captureclose.php |
---|
Новый файл |
0,0 → 1,38 |
<?php |
/** |
* Smarty Internal Plugin Compile Capture Close |
* |
* Compiles the {/capture} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile CaptureClose Class |
*/ |
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/capture} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$saved_attr = $this->_close_tag(array('capture')); |
$_output = "<?php "; |
if (isset($saved_attr[1])) { |
$_output .= " \$_smarty_tpl->assign($saved_attr[1], ob_get_contents());"; |
} |
$_output .= " \$_smarty_tpl->smarty->_smarty_vars['capture'][$saved_attr[0]]=ob_get_clean(); ?>\n"; |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.templatecompilerbase.php |
---|
Новый файл |
0,0 → 1,259 |
<?php |
/** |
* Smarty Internal Plugin Smarty Template Compiler Base |
* |
* This file contains the basic classes and methodes for compiling Smarty templates with lexer/parser |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Main compiler class |
*/ |
class Smarty_Internal_TemplateCompilerBase { |
// compile tag objects |
static $_tag_objects = array(); |
// tag stack |
public $_tag_stack = array(); |
// current template |
public $template = null; |
/** |
* Initialize compiler |
*/ |
public function __construct() |
{ |
} |
// abstract function doCompile($_content); |
/** |
* Methode to compile a Smarty template |
* |
* @param $template template object to compile |
* @return bool true if compiling succeeded, false if it failed |
*/ |
public function compileTemplate($template) |
{ |
/* here is where the compiling takes place. Smarty |
tags in the templates are replaces with PHP code, |
then written to compiled files. */ |
if (!is_object($template->cacher_object)) { |
$this->smarty->loadPlugin($template->cacher_class); |
$template->cacher_object = new $template->cacher_class($this->smarty); |
} |
// flag for nochache sections |
$this->nocache = false; |
$this->tag_nocache = false; |
// assume successfull compiling |
$this->compile_error = false; |
// save template object in compiler class |
$this->template = $template; |
// template header code |
$template_header = ''; |
if (!$template->suppressHeader) { |
$template_header .= "<?php /* Smarty version " . Smarty::$_version . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n"; |
$template_header .= " compiled from \"" . $this->template->getTemplateFilepath() . "\" */ ?>\n"; |
} |
do { |
// flag for aborting current and start recompile |
$this->abort_and_recompile = false; |
// get template source |
$_content = $template->getTemplateSource(); |
// run prefilter if required |
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) { |
$_content = $this->smarty->filter_handler->execute('pre', $_content); |
} |
// on empty template just return header |
if ($_content == '') { |
$template->compiled_template = $template->createPropertyHeader() . $template_header; |
return true; |
} |
// init cacher plugin |
$template->cacher_object->initCacher($this); |
// call compiler |
$_compiled_code = $this->doCompile($_content); |
} while ($this->abort_and_recompile); |
if (!$this->compile_error) { |
// close cacher and return compiled template |
$template->compiled_template = $template->createPropertyHeader() . $template_header . $template->cacher_object->closeCacher($this, $_compiled_code); |
// run postfilter if required |
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) { |
$template->compiled_template = $this->smarty->filter_handler->execute('post', $template->compiled_template); |
} |
return true; |
} else { |
// compilation error |
return false; |
} |
} |
/** |
* Compile Tag |
* |
* This is a call back from the lexer/parser |
* It executes the required compile plugin for the Smarty tag |
* |
* @param string $tag tag name |
* @param array $args array with tag attributes |
* @return string compiled code |
*/ |
public function compileTag($tag, $args) |
{ |
// $args contains the attributes parsed and compiled by the lexer/parser |
// assume that tag does compile into code, but creates no HTML output |
$this->has_code = true; |
$this->has_output = false; |
// compile the smarty tag (required compile classes to compile the tag are autoloaded) |
if (($_output = $this->$tag($args, $this)) === false) { |
if (isset($this->smarty->template_functions[$tag])) { |
// template defined by {template} tag |
$args['name'] = $tag; |
$tag = 'internal_function_call'; |
$_output = $this->$tag($args, $this); |
} |
} |
if ($_output !== false) { |
if ($_output !== true) { |
// did we get compiled code |
if ($this->has_code) { |
// Does it create output? |
if ($this->has_output) { |
$_output .= "\n"; |
} |
// return compiled code |
return $_output; |
} |
} |
// tag did not produce compiled code |
return ''; |
} else { |
// not an internal compiler tag |
// check if tag is a registered object |
if (isset($this->smarty->registered_objects[$tag]) && isset($args['object_methode'])) { |
$methode = $args['object_methode']; |
unset ($args['object_methode']); |
if (!in_array($methode, $this->smarty->registered_objects[$tag][3]) && |
(empty($this->smarty->registered_objects[$tag][1]) || in_array($methode, $this->smarty->registered_objects[$tag][1]))) { |
return $this->object_function($args, $tag, $methode, $this); |
} elseif (in_array($methode, $this->smarty->registered_objects[$tag][3])) { |
return $this->object_block_function($args, $tag, $methode, $this); |
} else { |
return $this->trigger_template_error ('unallowed methode "' . $methode . '" in registered object "' . $tag . '"'); |
} |
} |
// check if tag is registered or is Smarty plugin |
$this->smarty->plugin_handler->loadSmartyPlugin($tag, $this->smarty->plugin_search_order); |
if (isset($this->smarty->registered_plugins[$tag])) { |
// if compiler function plugin call it now |
if ($this->smarty->registered_plugins[$tag][0] == 'compiler') { |
if (!$this->smarty->registered_plugins[$tag][2]) { |
$this->tag_nocache = true; |
} |
return call_user_func_array($this->smarty->registered_plugins[$tag][1], array($args, $this)); |
} |
// compile function or block plugin |
$plugin_type = $this->smarty->registered_plugins[$tag][0] . '_plugin'; |
return $this->$plugin_type($args, $tag, $this); |
} |
// compile closing tag of block function |
if (strlen($tag) > 5 && substr_compare($tag, 'close', -5, 5) == 0) { |
$base_tag = substr($tag, 0, -5); |
// check if closing tag is a registered object |
if (isset($this->smarty->registered_objects[$base_tag]) && isset($args['object_methode'])) { |
$methode = $args['object_methode']; |
unset ($args['object_methode']); |
if (in_array($methode, $this->smarty->registered_objects[$base_tag][3])) { |
return $this->object_block_function($args, $tag, $methode, $this); |
} else { |
return $this->trigger_template_error ('unallowed closing tag methode "' . $methode . '" in registered object "' . $base_tag . '"'); |
} |
} |
// plugin ? |
if (isset($this->smarty->registered_plugins[$base_tag]) && $this->smarty->registered_plugins[$base_tag][0] == 'block') { |
return $this->block_plugin($args, $tag, $this); |
} |
} |
$this->trigger_template_error ("unknown tag \"" . $tag . "\""); |
} |
} |
/** |
* lazy loads internal compile plugin for tag and calls the compile methode |
* |
* compile objects cached for reuse. |
* class name format: Smarty_Internal_Compile_TagName |
* plugin filename format: internal.compile_tagname.php |
* |
* @param $tag string tag name |
* @param $args array with tag attributes |
* @return string compiled code |
*/ |
public function __call($name, $args) |
{ |
// re-use object if already exists |
if (isset(self::$_tag_objects[$name])) { |
// compile this tag |
return call_user_func_array(array(self::$_tag_objects[$name], 'compile'), $args); |
} |
// lazy load internal compiler plugin |
$class_name = "Smarty_Internal_Compile_{$name}"; |
if ($this->smarty->loadPlugin($class_name)) { |
// use plugin if found |
self::$_tag_objects[$name] = new $class_name; |
// compile this tag |
return call_user_func_array(array(self::$_tag_objects[$name], 'compile'), $args); |
} |
// no internal compile plugin for this tag |
return false; |
} |
/** |
* display compiler error messages without dying |
* |
* If parameter $args is empty it is a parser detected syntax error. |
* In this case the parser is called to obtain information about expected tokens. |
* |
* If parameter $args contains a string this is used as error message |
* |
* @todo output exact position of parse error in source line |
* @param $args string individual error message or null |
*/ |
public function trigger_template_error($args = null) |
{ |
$this->lex = Smarty_Internal_Templatelexer::instance(); |
$this->parser = Smarty_Internal_Templateparser::instance(); |
// get template source line which has error |
$line = $this->lex->line; |
if (isset($args)) { |
// $line--; |
} |
$match = preg_split("/\n/", $this->lex->data); |
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . $match[$line-1] . '" '; |
if (isset($args)) { |
// individual error message |
$error_text .= $args; |
} else { |
// expected token from parser |
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { |
$exp_token = $this->parser->yyTokenName[$token]; |
if (isset($this->lex->smarty_token_names[$exp_token])) { |
// token type from lexer |
$expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; |
} else { |
// otherwise internal token name |
$expect[] = $this->parser->yyTokenName[$token]; |
} |
} |
// output parser error message |
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect); |
} |
throw new Exception($error_text); |
// set error flag |
$this->compile_error = true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_block.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty method Register_Block |
* |
* Registers a PHP function as Smarty block function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Register a PHP function as Smarty block function plugin |
*/ |
/** |
* Registers block function to be used in templates |
* |
* @param string $block_tag name of template block |
* @param string $block_impl PHP function to register |
* @param boolean $cacheable if true (default) this fuction is cachable |
*/ |
function register_block($smarty, $block_tag, $block_impl, $cacheable = true, $cache_attr = array()) |
{ |
if (isset($smarty->registered_plugins[$block_tag])) { |
throw new Exception("Plugin tag \"{$block_tag}\" already registered"); |
} elseif (!is_callable($block_impl)) { |
throw new Exception("Plugin \"{$block_tag}\" not callable"); |
} else { |
$smarty->registered_plugins[$block_tag] = |
array('block', $block_impl, $cacheable, $cache_attr); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_prefilter.php |
---|
Новый файл |
0,0 → 1,25 |
<?php |
/** |
* Smarty method Register_Prefilter |
* |
* Registers a PHP function as prefilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers a prefilter function to apply |
* to a template before compiling |
* |
* @param object $smarty |
* @param callback $function |
*/ |
function register_prefilter($smarty, $function) |
{ |
$smarty->registered_filters['pre'][$smarty->_get_filter_name($function)] = $function; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_forelse.php |
---|
Новый файл |
0,0 → 1,34 |
<?php |
/** |
* Smarty Internal Plugin Compile For Else |
* |
* Compiles the {forelse} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Forelse Class |
*/ |
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {forelse} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_close_tag(array('for')); |
$this->_open_tag('forelse'); |
return "<?php }} else { ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.get_template_vars.php |
---|
Новый файл |
0,0 → 1,56 |
<?php |
/** |
* Smarty method Get_Template_Vars |
* |
* Returns a single or all template variables |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns a single or all template variables |
*/ |
/** |
* Returns a single or all template variables |
* |
* @param string $varname variable name or null |
* @return string variable value or or array of variables |
*/ |
function get_template_vars($smarty, $varname = null, $_ptr = null, $search_parents = true) |
{ |
if (isset($varname)) { |
$_var = $smarty->getVariable($varname, $_ptr, $search_parents); |
if (is_object($_var)) { |
return $_var->value; |
} else { |
return null; |
} |
} else { |
$_result = array(); |
if ($_ptr === null) { |
$_ptr = $smarty; |
} while ($_ptr !== null) { |
foreach ($_ptr->tpl_vars AS $key => $var) { |
$_result[$key] = $var->value; |
} |
// not found, try at parent |
if ($search_parents) { |
$_ptr = $_ptr->parent; |
} else { |
$_ptr = null; |
} |
} |
if ($search_parents) { |
foreach ($smarty->global_tpl_vars AS $key => $var) { |
$_result[$key] = $var->value; |
} |
} |
return $_result; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enabledefaulttimezone.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableDefaultTimezone |
* |
* Enable setting of default timezone |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable setting of default timezone |
*/ |
function enableDefaultTimezone($smarty) |
{ |
$this->smarty->set_timezone = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_object.php |
---|
Новый файл |
0,0 → 1,46 |
<?php |
/** |
* Smarty method Register_Object |
* |
* Registers a PHP object |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers object to be used in templates |
* |
* @param object $smarty |
* @param string $object name of template object |
* @param object $ &$object_impl the referenced PHP object to register |
* @param null $ |array $allowed list of allowed methods (empty = all) |
* @param boolean $smarty_args smarty argument format, else traditional |
* @param null $ |array $block_functs list of methods that are block format |
*/ |
function register_object($smarty, $object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) |
{ |
// test if allowed methodes callable |
if (!empty($allowed)) { |
foreach ((array)$allowed as $methode) { |
if (!is_callable(array($object_impl, $methode))) { |
throw new Exception("Undefined methode '$methode' in registered object"); |
} |
} |
} |
// test if block methodes callable |
if (!empty($block_methods)) { |
foreach ((array)$block_methods as $methode) { |
if (!is_callable(array($object_impl, $methode))) { |
throw new Exception("Undefined methode '$methode' in registered object"); |
} |
} |
} |
// register the object |
$smarty->registered_objects[$object] = |
array($object_impl, (array)$allowed, (boolean)$smarty_args, (array)$block_methods); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_outputfilter.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method Unregister_Outputfilter |
* |
* Unregister a outputfilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a outputfilter |
*/ |
/** |
* Registers an output filter function to apply |
* to a template output |
* |
* @param callback $function |
*/ |
function unregister_outputfilter($smarty, $function) |
{ |
unset($smarty->registered_filters['output'][$smarty->_get_filter_name($function)]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enablecachemodifycheck.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableCacheModifyCheck |
* |
* Enable cache modify check |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable cache modify check |
*/ |
function enableCacheModifyCheck($smarty) |
{ |
$smarty->cache_modified_check = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isdebugging.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isDebugging |
* |
* is debugging |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is debugging |
*/ |
function isDebugging($smarty) |
{ |
return $smarty->debugging; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_include.php |
---|
Новый файл |
0,0 → 1,153 |
<?php |
/** |
* Smarty Internal Plugin Compile Include |
* |
* Compiles the {include} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Include Class |
*/ |
class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {include} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('file'); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// save posible attributes |
$include_file = $_attr['file']; |
$has_compiled_template = false; |
if (true) { |
// check if compiled code can be merged |
if (strpos($include_file, '$_smarty_tpl') === false) { |
$tpl = $compiler->smarty->createTemplate (trim($include_file, "'\""), $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); |
do { |
$must_compile = false; |
$prop = array(); |
$compiled_tpl = $tpl->getCompiledTemplate(); |
preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); |
$compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/','/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); |
//var_dump($matches, $compiled_tpl); |
if (isset($matches[2])) { |
$prop = unserialize($matches[2]); |
foreach ($prop['file_dependency'] as $_file_to_check) { |
If (is_file($_file_to_check[0])) { |
$mtime = filemtime($_file_to_check[0]); |
} else { |
$tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); |
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); |
} |
If ($mtime != $_file_to_check[1]) { |
$must_compile = true; |
break; |
} |
} |
if ($must_compile) { |
// recompile |
$tpl->compileTemplateSource(); |
} |
} |
} while ($must_compile); |
if (isset($prop['file_dependency'])) { |
$compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); |
} |
$has_compiled_template = true; |
} |
} |
if (isset($_attr['assign'])) { |
// output will be stored in a smarty variable instead of beind displayed |
$_assign = $_attr['assign']; |
} |
$_parent_scope = SMARTY_LOCAL_SCOPE; |
if (isset($_attr['scope'])) { |
if ($_attr['scope'] == '\'parent\'') { |
$_parent_scope = SMARTY_PARENT_SCOPE; |
} elseif ($_attr['scope'] == '\'root\'') { |
$_parent_scope = SMARTY_ROOT_SCOPE; |
} elseif ($_attr['scope'] == '\'global\'') { |
$_parent_scope = SMARTY_GLOBAL_SCOPE; |
} |
} |
// default for included templates |
if ($compiler->template->caching) { |
$_caching = SMARTY_CACHING_LIFETIME_CURRENT; |
} else { |
$_caching = SMARTY_CACHING_OFF; |
} |
/* |
* if the {include} tag provides individual parameter for caching |
* it will not be included into the common cache file and treated like |
* a nocache section |
*/ |
if (isset($_attr['cache_lifetime'])) { |
$_cache_lifetime = $_attr['cache_lifetime']; |
$this->compiler->tag_nocache = true; |
} |
if (isset($_attr['nocache'])) { |
if ($_attr['nocache'] == 'true') { |
$this->compiler->tag_nocache = true; |
} |
} |
if (isset($_attr['caching'])) { |
if ($_attr['caching'] == 'true') { |
$_caching = SMARTY_CACHING_LIFETIME_CURRENT; |
} else { |
$_caching = SMARTY_CACHING_OFF; |
} |
} |
// create template object |
$_output = "<?php \$_template = new Smarty_Template ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);"; |
// delete {include} standard attributes |
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']); |
// remaining attributes must be assigned as smarty variable |
if (!empty($_attr)) { |
if ($_parent_scope == SMARTY_LOCAL_SCOPE) { |
// create variables |
foreach ($_attr as $_key => $_value) { |
$_output .= "\$_template->assign('$_key',$_value);"; |
} |
} else { |
$this->compiler->trigger_template_error('variable passing not allowed in parent/global scope'); |
} |
} |
// add caching parameter if required |
if (isset($_cache_lifetime)) { |
$_output .= "\$_template->cache_lifetime = $_cache_lifetime;"; |
$_caching = SMARTY_CACHING_LIFETIME_CURRENT; |
} |
$_output .= "\$_template->caching = $_caching;"; |
// was there an assign attribute |
if (isset($_assign)) { |
$_output .= "\$_smarty_tpl->assign($_assign,\$_smarty_tpl->smarty->fetch(\$_template)); ?>"; |
} else { |
if ($has_compiled_template) { |
$_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n"; |
$_output .= $compiled_tpl . "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";; |
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>"; |
} else { |
$_output .= " echo \$_smarty_tpl->smarty->fetch(\$_template); ?>"; |
} |
} |
if ($_parent_scope != SMARTY_LOCAL_SCOPE) { |
$_output .= "<?php \$_template->updateParentVariables($_parent_scope); ?>"; |
} |
return $_output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_nocacheclose.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty Internal Plugin Compile Nocache Close |
* |
* Compiles the {/nocache} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile NocacheClose Class |
*/ |
class Smarty_Internal_Compile_NocacheClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/nocache} tag |
* |
* This tag does not generate compiled output. It only sets a compiler flag |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$_attr = $this->_get_attributes($args); |
// leave nocache mode |
$this->compiler->nocache = false; |
// this tag does not return compiled code |
$this->compiler->has_code = false; |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_for.php |
---|
Новый файл |
0,0 → 1,55 |
<?php |
/** |
* Smarty Internal Plugin Compile For |
* |
* Compiles the {for} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile For Class |
*/ |
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {for} tag |
* |
* Smarty 3 does implement two different sytaxes: |
* |
* - {for $var in $array} |
* For looping over arrays or iterators |
* |
* - {for $x=0; $x<$y; $x++} |
* For general loops |
* |
* The parser is gereration different sets of attribute by which this compiler can |
* determin which syntax is used. |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// {for $x=0; $x<$y; $x++} syntax |
$this->required_attributes = array('ifexp', 'start', 'loop', 'varloop'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('for'); |
$output = "<?php "; |
foreach ($_attr['start'] as $_statement) { |
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;"; |
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n"; |
} |
$output .= " if ($_attr[ifexp]){ for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[varloop]]->value$_attr[loop]){\n"; |
$output .= "?>"; |
// return compiled code |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_block.php |
---|
Новый файл |
0,0 → 1,38 |
<?php |
/** |
* Smarty Internal Plugin Compile Block |
* |
* Compiles the {block} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Block Class |
*/ |
class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {block} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return boolean true |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('name'); |
$this->optional_attributes = array('assign'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); |
$this->_open_tag('block', $save); |
$compiler->template->extract_code = true; |
$compiler->template->extracted_compiled_code = ''; |
$compiler->template->has_code = false; |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_variablefilter.php |
---|
Новый файл |
0,0 → 1,25 |
<?php |
/** |
* Smarty method Register_Variablefilter |
* |
* Registers a PHP function as an output filter for variables |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers an output filter function which |
* runs over any variable output |
* |
* @param object $smarty |
* @param callback $function |
*/ |
function register_variablefilter($smarty, $function) |
{ |
$smarty->registered_filters['variable'][$smarty->_get_filter_name($function)] = $function; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.get_global.php |
---|
Новый файл |
0,0 → 1,37 |
<?php |
/** |
* Smarty method Get_Global |
* |
* Returns a single or all global variables |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns a single or all global variables |
* |
* @param object $smarty |
* @param string $varname variable name or null |
* @return string variable value or or array of variables |
*/ |
function get_global($smarty, $varname = null) |
{ |
if (isset($varname)) { |
if (isset($smarty->global_tpl_vars[$varname])) { |
return $smarty->global_tpl_vars[$varname]->value; |
} else { |
return ''; |
} |
} else { |
$_result = array(); |
foreach ($smarty->global_tpl_vars AS $key => $var) { |
$_result[$key] = $var->value; |
} |
return $_result; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disableconfigreadhidden.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method disableConfigReadHidden |
* |
* Disable config read hidden mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable config read hidden mode |
*/ |
function disableConfigReadHidden ($smarty) |
{ |
$this->smarty->config_read_hidden = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_whileclose.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty Internal Plugin Compile While Close |
* |
* Compiles the {/while} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile WhileClose Class |
*/ |
class Smarty_Internal_Compile_WhileClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/while} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->_close_tag(array('while')); |
return "<?php }?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.template.php |
---|
Новый файл |
0,0 → 1,716 |
<?php |
/** |
* Smarty Internal Plugin Template |
* |
* This files contains the Smarty template engine |
* |
* @package Smarty |
* @subpackage Templates |
* @author Uwe Tews |
*/ |
/** |
* Main class with template data structures and methods |
*/ |
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { |
// object cache |
public $compiler_object = null; |
public $cacher_object = null; |
// Smarty parameter |
public $cache_id = null; |
public $compile_id = null; |
public $caching = null; |
public $cache_lifetime = null; |
public $cacher_class = null; |
public $caching_type = null; |
public $force_compile = null; |
// Template resource |
public $template_resource = null; |
public $resource_type = null; |
public $resource_name = null; |
private $usesCompiler = null; |
private $isEvaluated = null; |
private $isExisting = null; |
// Template source |
public $template_filepath = null; |
public $template_source = null; |
private $template_timestamp = null; |
// Compiled template |
private $compiled_filepath = null; |
public $compiled_template = null; |
private $compiled_timestamp = null; |
public $compile_time = 0; |
public $mustCompile = null; |
public $suppressHeader = false; |
public $extract_code = false; |
public $extracted_compiled_code = ''; |
// Rendered content |
public $rendered_content = null; |
// Cache file |
private $cached_filepath = null; |
private $cached_timestamp = null; |
private $isCached = null; |
public $cache_time = 0; |
// template variables |
public $tpl_vars = array(); |
public $parent = null; |
public $config_vars = array(); |
// storage for plugin |
public $plugin_data = array(); |
// special properties |
public $properties = array(); |
// storage for block data |
public $block_data = array(); |
public $render_time = 0; |
/** |
* Create template data object |
* |
* Some of the global Smarty settings copied to template scope |
* It load the required template resources and cacher plugins |
* |
* @param string $template_resource template resource string |
* @param object $_parent back pointer to parent object with variables or null |
* @param mixed $_cache_id cache id or null |
* @param mixed $_compile_id compile id or null |
*/ |
public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null) |
{ |
$this->smarty = $smarty; |
// Smarty parameter |
$this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id; |
$this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id; |
$this->force_compile = $this->smarty->force_compile; |
$this->caching = $this->smarty->caching; |
$this->cache_lifetime = $this->smarty->cache_lifetime; |
$this->force_cache = $this->smarty->force_cache; |
$this->cacher_class = $this->smarty->cacher_class; |
$this->caching_type = $this->smarty->default_caching_type; |
$this->security = $this->smarty->security; |
$this->cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($this->caching_type); |
$this->parent = $_parent; |
$this->properties['file_dependency'] = array(); |
// dummy local smarty variable |
$this->tpl_vars['smarty'] = new Smarty_Variable; |
// Template resource |
$this->template_resource = $template_resource; |
// parse resource name |
if (!$this->parseResourceName ($template_resource, $this->resource_type, $this->resource_name, $dummy)) { |
throw new Exception ("Unable to parse resource name \"{$template_resource}\""); |
} |
// load cache resource |
if (!$this->isEvaluated() && $this->caching && !isset($this->smarty->cache_resource_objects[$this->caching_type])) { |
$this->smarty->loadPlugin($this->cache_resource_class); |
$this->smarty->cache_resource_objects[$this->caching_type] = new $this->cache_resource_class($this->smarty); |
} |
} |
/** |
* Returns the template filepath |
* |
* The template filepath is determined by the actual resource handler |
* |
* @return string the template filepath |
*/ |
public function getTemplateFilepath () |
{ |
return $this->template_filepath === null ? |
$this->template_filepath = $this->smarty->resource_objects[$this->resource_type]->getTemplateFilepath($this) : |
$this->template_filepath; |
} |
/** |
* Returns the timpestamp of the template source |
* |
* The template timestamp is determined by the actual resource handler |
* |
* @return integer the template timestamp |
*/ |
public function getTemplateTimestamp () |
{ |
return $this->template_timestamp === null ? |
$this->template_timestamp = $this->smarty->resource_objects[$this->resource_type]->getTemplateTimestamp($this) : |
$this->template_timestamp; |
} |
/** |
* Returns the template source code |
* |
* The template source is being read by the actual resource handler |
* |
* @return string the template source |
*/ |
public function getTemplateSource () |
{ |
if ($this->template_source === null) { |
if (!$this->smarty->resource_objects[$this->resource_type]->getTemplateSource($this)) { |
throw new Exception("Unable to read template '{$this->resource_name}'"); |
} |
} |
return $this->template_source; |
} |
/** |
* Returns if the template is existing |
* |
* The status is determined by the actual resource handler |
* |
* @return boolean true if the template exists |
*/ |
public function isExisting ($error= false) |
{ |
if ($this->isExisting === null) { |
$this->isExisting = $this->smarty->resource_objects[$this->resource_type]->isExisting($this); |
} |
if (!$this->isExisting && $error) { |
throw new Exception("Unable to load template \"{$this->resource_type} : {$this->resource_name}\""); |
} |
return $this->isExisting; |
} |
/** |
* Returns if the template resource uses the Smarty compiler |
* |
* The status is determined by the actual resource handler |
* |
* @return boolean true if the template will use the compiler |
*/ |
public function usesCompiler () |
{ |
return $this->usesCompiler === null ? |
$this->usesCompiler = $this->smarty->resource_objects[$this->resource_type]->usesCompiler() : |
$this->usesCompiler; |
} |
/** |
* Returns if the compiled template is stored or just evaluated in memory |
* |
* The status is determined by the actual resource handler |
* |
* @return boolean true if the compiled template has to be evaluated |
*/ |
public function isEvaluated () |
{ |
return $this->isEvaluated === null ? |
$this->isEvaluated = $this->smarty->resource_objects[$this->resource_type]->isEvaluated() : |
$this->isEvaluated; |
} |
/** |
* Returns if the current template must be compiled by the Smarty compiler |
* |
* It does compare the timestamps of template source and the compiled templates and checks the force compile configuration |
* |
* @return boolean true if the template must be compiled |
*/ |
public function mustCompile () |
{ |
$this->isExisting(true); |
if ($this->mustCompile === null) { |
$this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ()))); |
} |
return $this->mustCompile; |
} |
/** |
* Returns the compiled template filepath |
* |
* @return string the template filepath |
*/ |
public function getCompiledFilepath () |
{ |
return $this->compiled_filepath === null ? |
($this->compiled_filepath = !$this->isEvaluated() ? $this->smarty->resource_objects[$this->resource_type]->getCompiledFilepath($this) : false) : |
$this->compiled_filepath; |
} |
/** |
* Returns the timpestamp of the compiled template |
* |
* @return integer the template timestamp |
*/ |
public function getCompiledTimestamp () |
{ |
return $this->compiled_timestamp === null ? |
($this->compiled_timestamp = (!$this->isEvaluated() && file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false) : |
$this->compiled_timestamp; |
} |
/** |
* Returns the compiled template |
* |
* It checks if the template must be compiled or just read from the template resource |
* |
* @return string the compiled template |
*/ |
public function getCompiledTemplate () |
{ |
if ($this->compiled_template === null) { |
// see if template needs compiling. |
if ($this->mustCompile()) { |
$this->compileTemplateSource(); |
} else { |
if ($this->compiled_template === null) { |
$this->compiled_template = !$this->isEvaluated() && $this->usesCompiler() ? file_get_contents($this->getCompiledFilepath()) : false; |
} |
} |
} |
return $this->compiled_template; |
} |
/** |
* Compiles the template |
* |
* If the template is not evaluated the compiled template is saved on disk |
*/ |
public function compileTemplateSource () |
{ |
$_start_time = $this->_get_time(); |
if (!$this->isEvaluated) { |
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); |
} |
// compile template |
if (!is_object($this->compiler_object)) { |
// load compiler |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.compilebase.php'); |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.templatecompilerbase.php'); |
// $this->smarty->loadPlugin('Smarty_Internal_CompileBase'); |
// $this->smarty->loadPlugin('Smarty_Internal_TemplateCompilerBase'); |
$this->smarty->loadPlugin($this->smarty->resource_objects[$this->resource_type]->compiler_class); |
$this->compiler_object = new $this->smarty->resource_objects[$this->resource_type]->compiler_class($this->smarty->resource_objects[$this->resource_type]->template_lexer_class, $this->smarty->resource_objects[$this->resource_type]->template_parser_class, $this->smarty); |
// load cacher |
if ($this->caching) { |
$this->smarty->loadPlugin($this->cacher_class); |
$this->cacher_object = new $this->cacher_class($this->smarty); |
} |
} |
if (!is_object($this->smarty->write_file_object)) { |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.write_file.php'); |
// $this->smarty->loadPlugin("Smarty_Internal_Write_File"); |
$this->smarty->write_file_object = new Smarty_Internal_Write_File; |
} |
// call compiler |
if ($this->compiler_object->compileTemplate($this)) { |
// compiling succeded |
if (!$this->isEvaluated()) { |
// write compiled template |
$this->smarty->write_file_object->writeFile($this->getCompiledFilepath(), $this->compiled_template); |
// make template and compiled file timestamp match |
touch($this->getCompiledFilepath(), $this->getTemplateTimestamp()); |
} |
} else { |
// error compiling template |
throw new Exception("Error compiling template {$this->getTemplateFilepath ()}"); |
return false; |
} |
$this->compile_time += $this->_get_time() - $_start_time; |
} |
/** |
* Returns the filepath of the cached template output |
* |
* The filepath is determined by the actual resource handler of the cacher |
* |
* @return string the cache filepath |
*/ |
public function getCachedFilepath () |
{ |
return $this->cached_filepath === null ? |
$this->cached_filepath = ($this->isEvaluated() || !$this->caching) ? false : $this->smarty->cache_resource_objects[$this->caching_type]->getCachedFilepath($this) : |
$this->cached_filepath; |
} |
/** |
* Returns the timpestamp of the cached template output |
* |
* The timestamp is determined by the actual resource handler of the cacher |
* |
* @return integer the template timestamp |
*/ |
public function getCachedTimestamp () |
{ |
return $this->cached_timestamp === null ? |
$this->cached_timestamp = ($this->isEvaluated() || !$this->caching) ? false : $this->smarty->cache_resource_objects[$this->caching_type]->getCachedTimestamp($this) : |
$this->cached_timestamp; |
} |
/** |
* Returns the cached template output |
* |
* @return string |booelan the template content or false if the file does not exist |
*/ |
public function getCachedContent () |
{ |
return $this->rendered_content === null ? |
$this->rendered_content = ($this->isEvaluated() || !$this->caching) ? false : $this->smarty->cache_resource_objects[$this->caching_type]->getCachedContents($this) : |
$this->rendered_content; |
} |
/** |
* Writes the cached template output |
*/ |
public function writeCachedContent () |
{ |
// build file dependency string |
$this->properties['cache_lifetime'] = $this->cache_lifetime; |
return ($this->isEvaluated() || !$this->caching) ? false : $this->smarty->cache_resource_objects[$this->caching_type]->writeCachedContent($this, $this->createPropertyHeader() . $this->rendered_content); |
} |
/** |
* Checks of a valid version redered HTML output is in the cache |
* |
* If the cache is valid the contents is stored in the template object |
* |
* @return boolean true if cache is valid |
*/ |
public function isCached () |
{ |
if ($this->isCached === null) { |
$this->isCached = false; |
if ($this->caching && !$this->isEvaluated() && !$this->force_compile && !$this->force_cache) { |
if ($this->getCachedTimestamp() === false) { |
return $this->isCached; |
} |
if (($this->caching == SMARTY_CACHING_LIVETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0)))) { |
$_start_time = $this->_get_time(); |
$this->rendered_content = $this->smarty->cache_resource_objects[$this->caching_type]->getCachedContents($this); |
$this->cache_time += $this->_get_time() - $_start_time; |
if ($this->caching == SMARTY_CACHING_LIVETIME_SAVED && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']) || $this->properties['cache_lifetime'] < 0)) { |
$this->rendered_content = null; |
return $this->isCached; |
} |
if (!empty($this->properties['file_dependency']) && $this->smarty->compile_check) { |
foreach ($this->properties['file_dependency'] as $_file_to_check) { |
If (is_file($_file_to_check[0])) { |
$mtime = filemtime($_file_to_check[0]); |
} else { |
$this->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); |
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); |
} |
// If ($mtime > $this->getCachedTimestamp()) { |
If ($mtime > $_file_to_check[1]) { |
$this->rendered_content = null; |
$this->properties['file_dependency'] = array(); |
return $this->isCached; |
} |
} |
} |
$this->isCached = true; |
} |
} |
} |
return $this->isCached; |
} |
/** |
* Render the output using the compiled template or the PHP template source |
* |
* The rendering process is accomplished by just including the PHP files. |
* The only exceptions are evaluated templates (string template). Their code has |
* to be evaluated |
*/ |
public function renderTemplate () |
{ |
if ($this->usesCompiler()) { |
if ($this->mustCompile()) { |
$this->compileTemplateSource(); |
} |
$_smarty_tpl = $this; |
$_start_time = $this->_get_time(); |
ob_start(); |
if ($this->isEvaluated()) { |
eval("?>" . $this->compiled_template); |
} else { |
include($this->getCompiledFilepath ()); |
// check file dependencies at compiled code |
if ($this->smarty->compile_check) { |
if (!empty($this->properties['file_dependency'])) { |
$this->mustCompile = false; |
foreach ($this->properties['file_dependency'] as $_file_to_check) { |
If (is_file($_file_to_check[0])) { |
$mtime = filemtime($_file_to_check[0]); |
} else { |
$this->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); |
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); |
} |
If ($mtime != $_file_to_check[1]) { |
$this->properties['file_dependency'] = array(); |
$this->mustCompile = true; |
} |
} |
if ($this->mustCompile) { |
// recompile and render again |
ob_get_clean(); |
$this->compileTemplateSource(); |
ob_start(); |
include($this->getCompiledFilepath ()); |
} |
} |
} |
} |
} else { |
if (is_callable(array($this->smarty->resource_objects[$this->resource_type], 'renderUncompiled'))) { |
$_start_time = $this->_get_time(); |
ob_start(); |
$this->smarty->resource_objects[$this->resource_type]->renderUncompiled($this); |
} else { |
throw new Exception("Resource '$this->resource_type' must have 'renderUncompiled' methode"); |
} |
} |
$this->rendered_content = ob_get_clean(); |
$this->render_time += $this->_get_time() - $_start_time; |
if (!$this->isEvaluated) { |
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp()); |
} |
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) { |
// var_dump('merge ', $this->parent->getTemplateFilepath(), $this->parent->properties['file_dependency'], $this->getTemplateFilepath(), $this->properties['file_dependency']); |
$this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']); |
} |
// write to cache when nessecary |
if (!$this->isEvaluated() && $this->caching) { |
// write rendered template |
$this->writeCachedContent($this); |
// cache file may contain nocache code. read it back for processing |
$this->rendered_content = $this->smarty->cache_resource_objects[$this->caching_type]->getCachedContents($this); |
} |
} |
/** |
* Returns the rendered HTML output |
* |
* If the cache is valid the cached content is used, otherwise |
* the output is rendered from the compiled template or PHP template source |
* |
* @return string rendered HTML output |
*/ |
public function getRenderedTemplate () |
{ |
// disable caching for evaluated code |
if ($this->isEvaluated()) { |
$this->caching = false; |
} |
// checks if template exists |
$this->isExisting(true); |
// read from cache or render |
if ($this->rendered_content === null && !$this->isCached()) { |
// render template (not loaded and not in cache) |
$this->renderTemplate(); |
} |
$this->updateParentVariables(); |
return (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))? |
$this->smarty->filter_handler->execute('output', $this->rendered_content) : $this->rendered_content; |
} |
/** |
* parse a template resource in its name and type |
* |
* @param string $template_resource template resource specification |
*/ |
public function parseResourceName($template_resource, &$resource_type, &$resource_name, &$resource_handler) |
{ |
if (empty($template_resource)) |
return false; |
if (strpos($template_resource, ':') === false) { |
// no resource given, use default |
$resource_type = $this->smarty->default_resource_type; |
$resource_name = $template_resource; |
} else { |
// get type and name from path |
list($resource_type, $resource_name) = explode(':', $template_resource, 2); |
if (strlen($resource_type) == 1) { |
// 1 char is not resource type, but part of filepath |
$resource_type = 'file'; |
$resource_name = $template_resource; |
} else { |
$resource_type = strtolower($resource_type); |
} |
} |
// load resource handler if required |
if (!isset($this->smarty->resource_objects[$resource_type])) { |
// try registered resource |
if (isset($this->smarty->_plugins['resource'][$resource_type])) { |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.resource_registered.php'); |
// $this->smarty->loadPlugin('Smarty_Internal_Resource_Registered'); |
$resource_handler = $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Registered($this->smarty); |
} else { |
// try sysplugins dir |
$_resource_class = "Smarty_Internal_Resource_{$resource_type}"; |
if ($this->smarty->loadPlugin($_resource_class)) { |
$resource_handler = $this->smarty->resource_objects[$resource_type] = new $_resource_class($this->smarty); |
} else { |
// try plugins dir |
$_resource_class = "Smarty_Resource_{$resource_type}"; |
if ($this->smarty->loadPlugin($_resource_class)) { |
$resource_handler = $this->smarty->resource_objects[$resource_type] = new $_resource_class($this->smarty); |
} else { |
// try streams |
$_known_stream = stream_get_wrappers(); |
if (in_array($resource_type, $_known_stream)) { |
// is known stream |
if ($this->smarty->security) { |
$this->smarty->security_handler->isTrustedStream($resource_type); |
} |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.resource_stream.php'); |
// $this->smarty->loadPlugin('Smarty_Internal_Resource_Stream'); |
$resource_handler = $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Stream($this->smarty); |
// $resource_name = str_replace(':', '://', $template_resource); |
} else { |
throw new Exception('Unkown resource type \'' . $resource_type . '\''); |
} |
} |
} |
} |
} else { |
$resource_handler = $this->smarty->resource_objects[$resource_type]; |
} |
// cache template object under a unique ID |
// do not cache string resources |
if ($resource_type != 'string') { |
$this->smarty->template_objects[$this->buildTemplateId ($this->template_resource, $this->cache_id, $this->compile_id)] = $this; |
} |
return true; |
} |
/** |
* get system filepath to template |
*/ |
public function buildTemplateFilepath ($file = null) |
{ |
if ($file == null) { |
$file = $this->resource_name; |
} |
foreach((array)$this->smarty->template_dir as $_template_dir) { |
if (strpos('/\\', substr($_template_dir, -1)) === false) { |
$_template_dir .= DS; |
} |
$_filepath = $_template_dir . $file; |
if (file_exists($_filepath)) |
return $_filepath; |
} |
if (file_exists($file)) return $file; |
// no tpl file found |
if (!empty($this->smarty->default_template_handler_func)) { |
if (!is_callable($this->smarty->default_template_handler_func)) { |
throw new Exception("Default template handler not callable"); |
} else { |
$_return = call_user_func_array($this->smarty->default_template_handler_func, |
array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, &$this)); |
if ($_return == true) { |
return $_filepath; |
} |
} |
} |
// throw new Exception("Unable to load template \"{$file}\""); |
return false; |
} |
/** |
* Decode saved properties from compiled template and cache files |
*/ |
public function decodeProperties ($properties) |
{ |
$prop = unserialize($properties); |
if (isset($prop['cache_lifetime'])) { |
$this->properties['cache_lifetime'] = $prop['cache_lifetime']; |
} |
if (isset($prop['file_dependency'])) { |
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $prop['file_dependency']); |
// $this->properties['file_dependency'] = array_unique($this->properties['file_dependency']); |
} |
if (!empty($prop['function'])) { |
foreach ($prop['function'] as $_name => $_data) { |
$this->smarty->template_functions[$_name]['compiled'] = str_replace('_%n', "\n", $_data['compiled']); |
$this->smarty->template_functions[$_name]['parameter'] = $_data['parameter']; |
} |
} |
} |
/** |
* Update Smarty variables in parent variable object |
*/ |
public function updateParentVariables ($scope = SMARTY_LOCAL_SCOPE) |
{ |
foreach ($this->tpl_vars as $_key => $_variable) { |
// copy global vars back to parent |
if (isset($this->parent) && ($scope == SMARTY_PARENT_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_PARENT_SCOPE)) { |
if (isset($this->parent->tpl_vars[$_key])) { |
// variable is already defined in parent, copy value |
$this->parent->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; |
} else { |
// create variable in parent |
$this->parent->tpl_vars[$_key] = clone $_variable; |
$this->parent->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; |
} |
} |
if ($scope == SMARTY_ROOT_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_ROOT_SCOPE) { |
$_ptr = $this; |
// find root |
while ($_ptr->parent != null) { |
$_ptr = $_ptr->parent; |
} |
if (isset($_ptr->tpl_vars[$_key])) { |
// variable is already defined in root, copy value |
$_ptr->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; |
} else { |
// create variable in root |
$_ptr->tpl_vars[$_key] = clone $_variable; |
$_ptr->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; |
} |
} |
if ($scope == SMARTY_GLOBAL_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_GLOBAL_SCOPE) { |
if (isset($this->smarty->global_tpl_vars[$_key])) { |
// variable is already defined in root, copy value |
$this->smarty->global_tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value; |
} else { |
// create variable in root |
$this->smarty->global_tpl_vars[$_key] = clone $_variable; |
} |
$this->smarty->global_tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE; |
} |
} |
} |
/** |
* Create property header |
*/ |
public function createPropertyHeader () |
{ |
$directory_security = $this->smarty->direct_access_security ? "<?php if(!defined('SMARTY_DIR')) exit('no direct access allowed'); ?>\n" : ''; |
$properties_string = "<?php \$_smarty_tpl->decodeProperties('" . str_replace("'", '"', (serialize($this->properties))) . "'); ?>\n"; |
return $directory_security . $properties_string; |
} |
/** |
* wrapper for display |
*/ |
public function display () |
{ |
return $this->smarty->display($this); |
} |
/** |
* wrapper for fetch |
*/ |
public function fetch () |
{ |
return $this->smarty->fetch($this); |
} |
/** |
* wrapper for is_cached |
*/ |
public function is_cached () |
{ |
return $this->iscached(); |
} |
} |
/** |
* wrapper for template class |
*/ |
class Smarty_Template extends Smarty_Internal_Template { |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_outputfilter.php |
---|
Новый файл |
0,0 → 1,25 |
<?php |
/** |
* Smarty method Register_Outputfilter |
* |
* Registers a PHP function as outputfilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers an output filter function to apply |
* to a template output |
* |
* @param object $smarty |
* @param callback $function |
*/ |
function register_outputfilter($smarty, $function) |
{ |
$smarty->registered_filters['output'][$smarty->_get_filter_name($function)] = $function; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.cacher_inlinecode.php |
---|
Новый файл |
0,0 → 1,93 |
<?php |
/** |
* Smarty Internal Plugin Cacher InlineCode |
* |
* Process nocached code. |
* Version to inject nocache code directly into cache file |
* if caching is disabled at render time the code is being evaluated |
* |
* @package Smarty |
* @subpackage Cacher |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Cacher InlineCode Class |
*/ |
class Smarty_Internal_Cacher_InlineCode { |
function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
/** |
* Inject inline code for nocache template sections |
* |
* This method gets the content of each template element from the parser. |
* If the content is compiled code and it should be not cached the code is injected |
* into the rendered output. |
* |
* @param string $content content of template element |
* @param object $compiler intance of compiler class |
* @param boolean $tag_nocache true if the parser detected a nocache situation |
* @param boolean $is_code true if content is compiled code |
* @return string content |
*/ |
public function processNocacheCode ($content, $compiler, $tag_nocache, $is_code) |
{ |
// If the template is not evaluated and we have a nocache section and or a nocache tag |
if ($is_code) { |
// generate replacement code |
if (!$compiler->template->isEvaluated() && $compiler->template->caching && |
($tag_nocache || $compiler->nocache || $compiler->tag_nocache)) { |
$compiler->tag_nocache = false; |
$_output = str_replace("'", "\'", $content); |
$_output = '<?php echo \'' . $_output . '\';?>'; |
} else { |
$_output = $content; |
} |
} else { |
$_output = $content; |
} |
// if compiled code shall be grabbed |
if ($compiler->template->extract_code == false) { |
// return output |
return $_output; |
} else { |
// store code in extract buffer |
$compiler->template->extracted_compiled_code .= $_output; |
return ''; |
} |
} |
/** |
* Initialize cacher |
* |
* Is a noop in current implementation |
* |
* @param object $compiler intance of compiler class |
*/ |
public function initCacher ($compiler) |
{ |
return; |
} |
/** |
* Close cacher |
* |
* Hook to perform any post processing on the final compiled template |
* Is a noop in current implementation |
* |
* @param object $compiler intance of compiler class |
* @param string $template_code complete compiled template |
* @return string compiled template output |
*/ |
public function closeCacher ($compiler, $template_code) |
{ |
return $template_code; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disablecompilecheck.php |
---|
Новый файл |
0,0 → 1,24 |
<?php |
/** |
* Smarty method disableCompileCheck |
* |
* Disable compile checking |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable compile checking |
* |
* @param object $smarty |
*/ |
function DisableCompileCheck($smarty) |
{ |
$smarty->compile_check = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_foreach.php |
---|
Новый файл |
0,0 → 1,135 |
<?php |
/** |
* Smarty Internal Plugin Compile Foreach |
* |
* Compiles the {foreach} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Foreach Class |
*/ |
class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {foreach} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('from', 'item'); |
$this->optional_attributes = array('name', 'key'); |
$tpl = $compiler->template; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_open_tag('foreach'); |
$from = $_attr['from']; |
$item = $_attr['item']; |
if (isset($_attr['key'])) { |
$key = $_attr['key']; |
} else { |
$key = null; |
} |
if (isset($_attr['name'])) { |
$name = $_attr['name']; |
$has_name = true; |
$SmartyVarName = '$smarty.foreach.' . trim($name,'\'"') . '.'; |
} else { |
$name = null; |
$has_name = false; |
} |
$ItemVarName = '$' . trim($item,'\'"') . '@'; |
// evaluates which Smarty variables and properties have to be computed |
if ($has_name) { |
$usesSmartyFirst = strpos($tpl->template_source, $SmartyVarName . 'first') !== false; |
$usesSmartyLast = strpos($tpl->template_source, $SmartyVarName . 'last') !== false; |
$usesSmartyIndex = strpos($tpl->template_source, $SmartyVarName . 'index') !== false; |
$usesSmartyIteration = strpos($tpl->template_source, $SmartyVarName . 'iteration') !== false; |
$usesSmartyShow = strpos($tpl->template_source, $SmartyVarName . 'show') !== false; |
$usesSmartyTotal = $usesSmartyLast || strpos($tpl->template_source, $SmartyVarName . 'total') !== false; |
} else { |
$usesSmartyFirst = false; |
$usesSmartyLast = false; |
$usesSmartyTotal = false; |
} |
$usesPropFirst = $usesSmartyFirst || strpos($tpl->template_source, $ItemVarName . 'first') !== false; |
$usesPropLast = $usesSmartyLast || strpos($tpl->template_source, $ItemVarName . 'last') !== false; |
$usesPropIndex = $usesPropFirst || strpos($tpl->template_source, $ItemVarName . 'index') !== false; |
$usesPropIteration = $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'iteration') !== false; |
$usesPropShow = strpos($tpl->template_source, $ItemVarName . 'show') !== false; |
$usesPropTotal = $usesSmartyTotal || $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'total') !== false; |
// generate output code |
$output = "<?php "; |
$output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable;\n"; |
if ($key != null) { |
$output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; |
} |
$output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; |
if ($usesPropTotal) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n"; |
} |
if ($usesPropIteration) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n"; |
} |
if ($usesPropIndex) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n"; |
} |
if ($has_name) { |
if ($usesSmartyTotal) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n"; |
} |
if ($usesSmartyIteration) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n"; |
} |
if ($usesSmartyIndex) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n"; |
} |
} |
$output .= "if (count(\$_from) > 0){\n"; |
$output .= " foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n"; |
if ($key != null) { |
$output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; |
} |
if ($usesPropIteration) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n"; |
} |
if ($usesPropIndex) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n"; |
} |
if ($usesPropFirst) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n"; |
} |
if ($usesPropLast) { |
$output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n"; |
} |
if ($has_name) { |
if ($usesSmartyFirst) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n"; |
} |
if ($usesSmartyIteration) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n"; |
} |
if ($usesSmartyIndex) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n"; |
} |
if ($usesSmartyLast) { |
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n"; |
} |
} |
$output .= "?>"; |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_block_plugin.php |
---|
Новый файл |
0,0 → 1,61 |
<?php |
/** |
* Smarty Internal Plugin Compile Block Plugin |
* |
* Compiles code for the execution of block plugin |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Block Plugin Class |
*/ |
class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the execution of block plugin |
* |
* @param array $args array with attributes from parser |
* @param string $tag name of block function |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $tag, $compiler) |
{ |
$this->compiler = $compiler; |
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) { |
// opening tag of block plugin |
$this->required_attributes = array(); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// convert attributes into parameter array string |
$_paramsArray = array(); |
foreach ($_attr as $_key => $_value) { |
$_paramsArray[] = "'$_key'=>$_value"; |
} |
$_params = 'array(' . implode(",", $_paramsArray) . ')'; |
$this->_open_tag($tag, array($_params, $this->compiler->nocache)); |
// not cachable? |
if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) { |
$this->compiler->nocache = true; |
} |
// compile code |
$output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->plugin_handler->' . $tag . '(array(' . $_params . ', null, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\');while ($_block_repeat) { ob_start();?>'; |
} else { |
if ($this->compiler->nocache) { |
$this->compiler->tag_nocache = true; |
} |
// closing tag of block plugin |
list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5)); |
// This tag does create output |
$this->compiler->has_output = true; |
// compile code |
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->plugin_handler->' . substr($tag, 0, -5) . '(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\'); }?>'; |
} |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enableforcecompile.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableForceCompile |
* |
* Enable forced compiling |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable forced compiling |
*/ |
public function enableForceCompile($smarty) |
{ |
$smarty->force_compile = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_functionclose.php |
---|
Новый файл |
0,0 → 1,46 |
<?php |
/** |
* Smarty Internal Plugin Compile Function Close |
* |
* Compiles the {/function} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile FunctionClose Class |
*/ |
class Smarty_Internal_Compile_FunctionClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/function} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return boolean true |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->compiler->has_code = false; |
// turn off block code extraction |
$compiler->template->extract_code = false; |
// check and get attributes |
$this->optional_attributes = array('name'); |
$_attr = $this->_get_attributes($args); |
$saved_data = $this->_close_tag(array('function')); |
// if name does match to opening tag |
if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { |
$this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); |
} |
$_name = trim($saved_data[0]['name'], "'"); |
$compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code); |
$this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code; |
$this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter']; |
$compiler->template->extracted_compiled_code = $saved_data[1]; |
$compiler->template->extract_code = $saved_data[2]; |
return true; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_forclose.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty Internal Plugin Compile For Close |
* |
* Compiles the {/for} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile ForClose Class |
*/ |
class Smarty_Internal_Compile_ForClose extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {/for} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$_open_tag = $this->_close_tag(array('for', 'forelse')); |
if ($_open_tag == 'forelse') |
return "<?php } ?>"; |
else |
return "<?php }} ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.debug.php |
---|
Новый файл |
0,0 → 1,62 |
<?php |
/** |
* Smarty Internal Plugin Debug |
* |
* Class to collect data for the Smarty Debugging Consol |
* |
* @package Smarty |
* @subpackage Debug |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Debug Class |
*/ |
class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase { |
/** |
* Opens a window for the Smarty Debugging Consol and display the data |
*/ |
public static function display_debug($smarty) |
{ |
// get template names |
$i = 0; |
$_template_data = array(); |
if (is_array($smarty->template_objects)) { |
foreach ($smarty->template_objects as $_template_obj) { |
// exclude the debugging template from displayed data |
if ($smarty->debug_tpl != $_template_obj->resource_name) { |
$_template_data[$i]['name'] = $_template_obj->getTemplateFilepath(); |
$_template_data[$i]['compile_time'] = $_template_obj->compile_time; |
$_template_data[$i]['render_time'] = $_template_obj->render_time; |
$_template_data[$i]['cache_time'] = $_template_obj->cache_time; |
$i++; |
if (false && $i == 1) { |
foreach ($_template_obj->properties['file_dependency'] as $_file) { |
$_template_data[$i]['name'] = $_file[0]; |
$_template_data[$i]['compile_time'] = 0; |
$_template_data[$i]['render_time'] = 0; |
$_template_data[$i]['cache_time'] = 0; |
$i++; |
} |
} |
} |
} |
} |
// prepare information of assigned variables |
$_assigned_vars = $smarty->tpl_vars; |
ksort($_assigned_vars); |
$_config_vars = $smarty->config_vars; |
ksort($_config_vars); |
$_template = new Smarty_Template ($smarty->debug_tpl, $smarty); |
$_template->caching = false; |
$_template->force_compile = false; |
$_template->security = false; |
$_template->assign('template_data', $_template_data); |
$_template->assign('assigned_vars', $_assigned_vars); |
$_template->assign('config_vars', $_config_vars); |
$_template->assign('execution_time', $smarty->_get_time() - $smarty->start_time); |
echo $smarty->fetch($_template); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method._get_filter_name.php |
---|
Новый файл |
0,0 → 1,31 |
<?php |
/** |
* Smarty method _get_filter_name |
* |
* Return internal filter name |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Return internal filter name |
* |
* @param object $smarty |
* @param callback $function |
*/ |
function _get_filter_name($smarty, $function) |
{ |
if (is_array($function)) { |
$_class_name = (is_object($function[0]) ? |
get_class($function[0]) : $function[0]); |
return $_class_name . '_' . $function[1]; |
} |
else { |
return $function; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_compiler_function.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty method Register_Compiler_Function |
* |
* Registers a PHP function as Smarty compiler function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Register a PHP function as Smarty compiler function plugin |
*/ |
/** |
* Registers compiler function |
* |
* @param string $compiler_tag of template function |
* @param string $compiler_impl name of PHP function to register |
*/ |
function register_compiler_function($smarty, $compiler_tag, $compiler_impl, $cacheable = true) |
{ |
if (isset($smarty->registered_plugins[$compiler_tag])) { |
throw new Exception("Plugin tag \"{$compiler_tag}\" already registered"); |
} elseif (!is_callable($compiler_impl)) { |
throw new Exception("Plugin \"{$compiler_tag}\" not callable"); |
} else { |
$smarty->registered_plugins[$compiler_tag] = |
array('compiler', $compiler_impl, $cacheable); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enableconfigreadhidden.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableConfigReadHidden |
* |
* Enable config read hidden mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable config read hidden mode |
*/ |
function enableConfigReadHidden($smarty) |
{ |
$this->smarty->config_read_hidden = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getvariablefilter.php |
---|
Новый файл |
0,0 → 1,23 |
<?php |
/** |
* Smarty method getVariableFilter |
* |
* get status of filter on variable output |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Smarty class getVariableFilter |
* |
* get status of filter on variable output |
*/ |
function getVariableFilter($smarty) |
{ |
return $smarty->variable_filter; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.get_config_vars.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty method Get_Config_Vars |
* |
* Returns a single or all global config variables |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns a single or all global config variables |
*/ |
/** |
* Returns a single or all global config variables |
* |
* @param string $varname variable name or null |
* @return string variable value or or array of variables |
*/ |
function Get_Config_Vars($smarty, $varname = null) |
{ |
if (isset($varname)) { |
if (isset($smarty->config_vars[$varname])) { |
return $smarty->config_vars[$varname]; |
} else { |
return ''; |
} |
} else { |
return $smarty->config_vars; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_all_cache.php |
---|
Новый файл |
0,0 → 1,35 |
<?php |
/** |
* Smarty method Clear_All_Cache |
* |
* Empties the cache folder |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Empty cache folder |
* |
* @param object $smarty |
* @param integer $exp_time expiration time |
* @param string $type resource type |
* @return integer number of cache files deleted |
*/ |
function clear_all_cache($smarty, $exp_time = null, $type = 'file') |
{ |
// load cache resource |
if (!isset($smarty->cache_resource_objects[$type])) { |
$_cache_resource_class = 'Smarty_Internal_CacheResource_' . $type; |
if (!$smarty->loadPlugin($_cache_resource_class)) { |
throw new Exception("Undefined cache resource type {$type}"); |
} |
$smarty->cache_resource_objects[$type] = new $_cache_resource_class($smarty); |
} |
return $smarty->cache_resource_objects[$type]->clearAll($exp_time); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disableconfigbooleanize.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableConfigBooleanize |
* |
* Disable config booleanize mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable config booleanize mode |
*/ |
function disableConfigBooleanize($smarty) |
{ |
$this->smarty->config_booleanize = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_block.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method Unregister_Block |
* |
* Unregister a Smarty block function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a Smarty block function plugin |
*/ |
/** |
* Unregisters block function |
* |
* @param string $block_tag name of template function |
*/ |
function unregister_block($smarty, $block_tag) |
{ |
if (isset($smarty->registered_plugins[$block_tag]) && $smarty->registered_plugins[$block_tag][0] == 'block') { |
unset($smarty->registered_plugins[$block_tag]); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enablevariablefilter.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableVariableFilter |
* |
* Enable filter on variable output |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable filter on variable output |
*/ |
function enableVariableFilter($smarty) |
{ |
$smarty->variable_filter = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isforcecompile.php |
---|
Новый файл |
0,0 → 1,23 |
<?php |
/** |
* Smarty method isForceCompile |
* |
* is forced compiling |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* |
* is forced compiling |
*/ |
function isForceCompile($smarty) |
{ |
return $smarty->force_compile; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getconfigdir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getConfigDir |
* |
* Returns directory of config files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns directory of config files |
*/ |
/** |
* Returns directory of config files |
* |
* @return array config folder |
*/ |
function getConfigDir($smarty) |
{ |
return $smarty->config_dir; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_modifier.php |
---|
Новый файл |
0,0 → 1,29 |
<?php |
/** |
* Smarty method Unregister_Modifier |
* |
* Unregister a Smarty modifier plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Unregister a Smarty modifier plugin |
*/ |
/** |
* Unregisters modifier |
* |
* @param string $modifier name of template modifier |
*/ |
function unregister_modifier($smarty, $modifier) |
{ |
if (isset($smarty->registered_plugins[$modifier]) && $smarty->registered_plugins[$modifier][0] == 'modifier') { |
unset($smarty->registered_plugins[$modifier]); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.cacheresource_file.php |
---|
Новый файл |
0,0 → 1,185 |
<?php |
/** |
* Smarty Internal Plugin CacheResource File |
* |
* Implements the file system as resource for the HTML cache |
* Version ussing nocache inserts |
* |
* @package Smarty |
* @subpackage Cacher |
* @author Uwe Tews |
*/ |
/** |
* This class does contain all necessary methods for the HTML cache on file system |
*/ |
class Smarty_Internal_CacheResource_File { |
function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
/** |
* Returns the filepath of the cached template output |
* |
* @param object $template current template |
* @return string the cache filepath |
*/ |
public function getCachedFilepath($template) |
{ |
return $this->buildCachedFilepath ($template->resource_name, $template->cache_id, $template->compile_id); |
} |
/** |
* Returns the timpestamp of the cached template output |
* |
* @param object $template current template |
* @return integer |booelan the template timestamp or false if the file does not exist |
*/ |
public function getCachedTimestamp($template) |
{ |
return ($template->getCachedFilepath() && file_exists($template->getCachedFilepath())) ? filemtime($template->getCachedFilepath()) : false ; |
} |
/** |
* Returns the cached template output |
* |
* @param object $template current template |
* @return string |booelan the template content or false if the file does not exist |
*/ |
public function getCachedContents($template) |
{ |
ob_start(); |
$_smarty_tpl = $template; |
include $template->getCachedFilepath(); |
return ob_get_clean(); |
} |
/** |
* Writes the rendered template output to cache file |
* |
* @param object $template current template |
* @return boolean status |
*/ |
public function writeCachedContent($template, $content) |
{ |
if (!$template->isEvaluated()) { |
if (!is_object($this->smarty->write_file_object)) { |
require_once(SMARTY_SYSPLUGINS_DIR . 'internal.write_file.php'); |
// $this->smarty->loadPlugin("Smarty_Internal_Write_File"); |
$this->smarty->write_file_object = new Smarty_Internal_Write_File; |
} |
return $this->smarty->write_file_object->writeFile($template->getCachedFilepath(), $content); |
} else { |
return false; |
} |
} |
/** |
* Empty cache folder |
* |
* @param integer $exp_time expiration time |
* @return integer number of cache files deleted |
*/ |
public function clearAll($exp_time = null) |
{ |
return $this->clear(null, null, null, $exp_time); |
} |
/** |
* Empty cache for a specific template |
* |
* @param string $resource_name template name |
* @param string $cache_id cache id |
* @param string $compile_id compile id |
* @param integer $exp_time expiration time |
* @return integer number of cache files deleted |
*/ |
public function clear($resource_name, $cache_id, $compile_id, $exp_time) |
{ |
$_dir_sep = $this->smarty->use_sub_dirs ? DS : '^'; |
if (isset($resource_name)) { |
$_resource_part = (string)abs(crc32($resource_name)) . '.' . $resource_name . $this->smarty->php_ext; |
} else { |
$_resource_part = null; |
} |
$_dir = $this->smarty->cache_dir; |
if (strpos('/\\', substr($_dir, -1)) === false) { |
$_dir .= DS; |
} |
if ($this->smarty->use_sub_dirs && isset($cache_id)) { |
$_dir .= str_replace('|', $_dir_sep, $cache_id) . $_dir_sep; |
} |
$_compile_pos = $this->smarty->use_sub_dirs ? 5 : 2; |
$_count = 0; |
$_cacheDirs = new RecursiveDirectoryIterator($_dir); |
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); |
foreach ($_cache as $_file) { |
if (strpos($_file, '.svn') !== false) continue; |
if ($_file->isDir()) { |
if (!$_cache->isDot()) { |
// delete folder if empty |
@rmdir($_file->getPathname()); |
} |
} else { |
$_parts = explode($_dir_sep, $_file); |
$_parts_count = count($_parts); |
$_parts_compile_pos = $_parts_count - $_compile_pos; |
if ($_parts_compile_pos < 0) { |
$_parts_compile_pos = 0; |
} |
if ((substr_compare((string)$_file, $_dir, 0, strlen($_dir)) == 0 && |
(!isset($resource_name) || $_parts[$_parts_count-1] == $_resource_part) && |
(!isset($compile_id) || $_parts[$_parts_compile_pos] == $compile_id)) || |
(isset($resource_name) && (string)$_file == $_dir . $_resource_part)) { |
if (isset($exp_time)) { |
if (time() - @filemtime($_file) >= $exp_time) { |
$_count += unlink((string) $_file) ? 1 : 0; |
} |
} else { |
$_count += unlink((string) $_file) ? 1 : 0; |
} |
} |
} |
} |
return $_count; |
} |
/** |
* Get system filepath to cached file |
* |
* @param string $resource_name template name |
* @param string $cache_id cache id |
* @param string $compile_id compile id |
* @return string filepath of cache file |
*/ |
private function buildCachedFilepath ($resource_name, $cache_id, $compile_id) |
{ |
$_files = explode('|', $resource_name); |
$_filepath = (string)abs(crc32($resource_name)); |
// if use_sub_dirs, break file into directories |
if ($this->smarty->use_sub_dirs) { |
$_filepath = substr($_filepath, 0, 2) . DS |
. substr($_filepath, 2, 2) . DS |
. substr($_filepath, 4, 2) . DS |
. $_filepath; |
} |
$_compile_dir_sep = $this->smarty->use_sub_dirs ? DS : '^'; |
if (isset($cache_id)) { |
$_cache_id = str_replace('|', $_compile_dir_sep, $cache_id) . $_compile_dir_sep; |
} else { |
$_cache_id = ''; |
} |
if (isset($compile_id)) { |
$_compile_id = $compile_id . $_compile_dir_sep; |
} else { |
$_compile_id = ''; |
} |
$_cache_dir = $this->smarty->cache_dir; |
if (strpos('/\\', substr($_cache_dir, -1)) === false) { |
$_cache_dir .= DS; |
} |
return $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_files[count($_files)-1]) . $this->smarty->php_ext; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disablecaching.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableCaching |
* |
* Disable caching |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable caching |
*/ |
function DisableCaching() |
{ |
$this->smarty->caching = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disabledefaulttimezone.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableDefaultTimezone |
* |
* Disable setting of default timezone |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable setting of default timezone |
*/ |
function disableDefaultTimezone($smarty) |
{ |
$smarty->set_timezone = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enableconfigbooleanize.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableConfigBooleanize |
* |
* Enable config booleanize mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable config booleanize mode |
*/ |
function enableConfigBooleanize($smarty) |
{ |
$smarty->config_booleanize = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_internal_smarty_var.php |
---|
Новый файл |
0,0 → 1,106 |
<?php |
/** |
* Smarty Internal Plugin Compile Smarty |
* |
* Compiles the special $smarty variables |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Smarty Class |
*/ |
class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the speical $smarty variables |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$_index = explode(',', str_replace(array('][', '[', ']'), array(',', '', ''), $args)); |
$compiled_ref = ' '; |
switch (trim($_index[0], "'")) { |
case 'foreach': |
return "\$_smarty_tpl->getVariable('smarty')->value$args"; |
case 'section': |
return "\$_smarty_tpl->getVariable('smarty')->value$args"; |
case 'capture': |
return "\$_smarty_tpl->smarty->_smarty_vars$args"; |
case 'now': |
return 'time()'; |
case 'get': |
$compiled_ref = "\$_GET"; |
break; |
case 'post': |
$compiled_ref = "\$_POST"; |
break; |
case 'cookies': |
$compiled_ref = "\$_COOKIE"; |
break; |
case 'env': |
$compiled_ref = "\$_ENV"; |
break; |
case 'server': |
$compiled_ref = "\$_SERVER"; |
break; |
case 'session': |
$compiled_ref = "\$_SESSION"; |
break; |
case 'request': |
$compiled_ref = "\$_REQUEST"; |
break; |
case 'template': |
$_template_name = basename($compiler->template->getTemplateFilepath()); |
return "'$_template_name'"; |
case 'current_dir': |
$_template_dir_name = dirname($compiler->template->getTemplateFilepath()); |
return "'$_template_dir_name'"; |
case 'version': |
$_version = Smarty::$_version; |
return "'$_version'"; |
case 'const': |
if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) { |
$compiler->trigger_template_error("(secure mode) constants not permitted"); |
break; |
} |
return '@' . trim($_index[1], "'"); |
case 'config': |
return "\$_smarty_tpl->getConfigVariable($_index[1])"; |
case 'ldelim': |
$_ldelim = $compiler->smarty->left_delimiter; |
return "'$_ldelim'"; |
case 'rdelim': |
$_rdelim = $compiler->smarty->right_delimiter; |
return "'$_rdelim'"; |
default: |
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference'); |
break; |
} |
if (isset($_index[1])) { |
array_shift($_index); |
foreach ($_index as $_ind) { |
$compiled_ref = $compiled_ref . "[$_ind]"; |
} |
} |
return $compiled_ref; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_assign.php |
---|
Новый файл |
0,0 → 1,37 |
<?php |
/** |
* Smarty method Clear_Assign |
* |
* Deletes a assigned Smarty variable or array of variables at current level |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Delete a Smarty variable or array of variables |
* |
* @param object $smarty |
* @param string $ |array $varname variable name or array of variable names |
* @param object $data_object object which holds tpl_vars |
*/ |
function clear_assign($smarty, $varname, $data_object = null) |
{ |
foreach ((array)$varname as $variable) { |
if (isset($data_object)) { |
$ptr = $data_object; |
} else { |
$ptr = $smarty; |
} while ($ptr != null) { |
if (isset($ptr->tpl_vars[$variable])) { |
unset($ptr->tpl_vars[$variable]); |
} |
$ptr = $ptr->parent; |
} |
} |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_resource.php |
---|
Новый файл |
0,0 → 1,33 |
<?php |
/** |
* Smarty method Register_Resource |
* |
* Registers a Smarty template resource |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers a resource to fetch a template |
* |
* @param object $smarty |
* @param string $type name of resource |
* @param array $functions array of functions to handle resource |
*/ |
function register_resource($smarty, $type, $functions) |
{ |
if (count($functions) == 4) { |
$smarty->_plugins['resource'][$type] = |
array($functions, false); |
} elseif (count($functions) == 5) { |
$smarty->plugins['resource'][$type] = |
array(array(array(&$functions[0], $functions[1]) , array(&$functions[0], $functions[2]) , array(&$functions[0], $functions[3]) , array(&$functions[0], $functions[4])) , false); |
} else { |
throw new Exception("malformed function-list for '$type' in register_resource"); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_stream.php |
---|
Новый файл |
0,0 → 1,118 |
<?php |
/** |
* Smarty Internal Plugin Resource Stream |
* |
* Implements the streams as resource for Smarty template |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource Stream |
*/ |
class Smarty_Internal_Resource_Stream { |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
// classes used for compiling Smarty templates from file resource |
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
public $template_parser_class = 'Smarty_Internal_Templateparser'; |
/** |
* Return flag if template source is existing |
* |
* @return boolean true |
*/ |
public function isExisting($template) |
{ |
if ($template->getTemplateSource() == '') { |
return false; |
} else { |
return true; |
} |
} |
/** |
* Get filepath to template source |
* |
* @param object $_template template object |
* @return string return 'string' as template source is not a file |
*/ |
public function getTemplateFilepath($_template) |
{ |
// no filepath for strings |
// return resource name for compiler error messages |
return str_replace(':', '://', $_template->template_resource); |
} |
/** |
* Get timestamp to template source |
* |
* @param object $_template template object |
* @return boolean false as string resources have no timestamp |
*/ |
public function getTemplateTimestamp($_template) |
{ |
// strings must always be compiled and have no timestamp |
return false; |
} |
/** |
* Retuen template source from resource name |
* |
* @param object $_template template object |
* @return string content of template source |
*/ |
public function getTemplateSource($_template) |
{ |
// return template string |
$_template->template_source = ''; |
$fp = fopen(str_replace(':', '://', $_template->template_resource),'r+'); |
while (!feof($fp)) { |
$_template->template_source .= fgets($fp); |
} |
fclose($fp); |
return true; |
} |
/** |
* Return flag that this resource uses the compiler |
* |
* @return boolean true |
*/ |
public function usesCompiler() |
{ |
// resource string is template, needs compiler |
return true; |
} |
/** |
* Return flag that this resource is evaluated |
* |
* @return boolean true |
*/ |
public function isEvaluated() |
{ |
// compiled template is evaluated instead of saved to disk |
return true; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $_template template object |
* @return boolean return false as compiled template is not stored |
*/ |
public function getCompiledFilepath($_template) |
{ |
// no filepath for strings |
return false; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.configfilelexer.php |
---|
Новый файл |
0,0 → 1,267 |
<?php |
/** |
* Smarty Internal Plugin Configfilelexer |
* |
* This is the lexer to break the config file source into tokens |
* @package Smarty |
* @subpackage Config |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Templatelexer |
*/ |
class Smarty_Internal_Configfilelexer |
{ |
public $data; |
public $counter; |
public $token; |
public $value; |
public $node; |
public $line; |
private $state = 1; |
public $smarty_token_names = array ( // Text for parser error messages |
); |
function __construct($data, $smarty) |
{ |
// set instance object |
self::instance($this); |
$this->data = $data; |
$this->counter = 0; |
$this->line = 1; |
$this->smarty = $smarty; |
} |
public static function &instance($new_instance = null) |
{ |
static $instance = null; |
if (isset($new_instance) && is_object($new_instance)) |
$instance = $new_instance; |
return $instance; |
} |
private $_yy_state = 1; |
private $_yy_stack = array(); |
function yylex() |
{ |
return $this->{'yylex' . $this->_yy_state}(); |
} |
function yypushstate($state) |
{ |
array_push($this->_yy_stack, $this->_yy_state); |
$this->_yy_state = $state; |
} |
function yypopstate() |
{ |
$this->_yy_state = array_pop($this->_yy_stack); |
} |
function yybegin($state) |
{ |
$this->_yy_state = $state; |
} |
function yylex1() |
{ |
$tokenMap = array ( |
1 => 0, |
2 => 0, |
3 => 0, |
4 => 0, |
5 => 0, |
6 => 0, |
7 => 0, |
8 => 1, |
10 => 1, |
12 => 0, |
13 => 0, |
14 => 0, |
15 => 0, |
); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
$yy_global_pattern = "/^(#)|^('[^'\\\\\\\\]*(?:\\\\\\\\.[^'\\\\\\\\]*)*')|^(\"\"\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\"\")|^(\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\")|^(\\[)|^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)/"; |
do { |
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) { |
$yysubmatches = $yymatches; |
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
if (!count($yymatches)) { |
throw new Exception('Error: lexing failed because a rule matched' . |
'an empty string. Input "' . substr($this->data, |
$this->counter, 5) . '... state START'); |
} |
next($yymatches); // skip global match |
$this->token = key($yymatches); // token number |
if ($tokenMap[$this->token]) { |
// extract sub-patterns for passing to lex function |
$yysubmatches = array_slice($yysubmatches, $this->token + 1, |
$tokenMap[$this->token]); |
} else { |
$yysubmatches = array(); |
} |
$this->value = current($yymatches); // token value |
$r = $this->{'yy_r1_' . $this->token}($yysubmatches); |
if ($r === null) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
// accept this token |
return true; |
} elseif ($r === true) { |
// we have changed state |
// process this token in the new state |
return $this->yylex(); |
} elseif ($r === false) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
// skip this token |
continue; |
} else { $yy_yymore_patterns = array( |
1 => array(0, "^('[^'\\\\\\\\]*(?:\\\\\\\\.[^'\\\\\\\\]*)*')|^(\"\"\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\"\")|^(\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\")|^(\\[)|^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
2 => array(0, "^(\"\"\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\"\")|^(\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\")|^(\\[)|^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
3 => array(0, "^(\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\")|^(\\[)|^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
4 => array(0, "^(\\[)|^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
5 => array(0, "^(])|^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
6 => array(0, "^(\\s*=\\s*)|^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
7 => array(0, "^(\\d+(\\.\\d+)?)|^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
8 => array(1, "^((\n|\r\n))|^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
10 => array(2, "^([\s]+)|^(\\.)|^(\\w+)|^(.)"), |
12 => array(2, "^(\\.)|^(\\w+)|^(.)"), |
13 => array(2, "^(\\w+)|^(.)"), |
14 => array(2, "^(.)"), |
15 => array(2, ""), |
); |
// yymore is needed |
do { |
if (!strlen($yy_yymore_patterns[$this->token][1])) { |
throw new Exception('cannot do yymore for the last token'); |
} |
$yysubmatches = array(); |
if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/', |
substr($this->data, $this->counter), $yymatches)) { |
$yysubmatches = $yymatches; |
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns |
next($yymatches); // skip global match |
$this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number |
$this->value = current($yymatches); // token value |
$this->line = substr_count($this->value, "\n"); |
if ($tokenMap[$this->token]) { |
// extract sub-patterns for passing to lex function |
$yysubmatches = array_slice($yysubmatches, $this->token + 1, |
$tokenMap[$this->token]); |
} else { |
$yysubmatches = array(); |
} |
} |
$r = $this->{'yy_r1_' . $this->token}($yysubmatches); |
} while ($r !== null && !is_bool($r)); |
if ($r === true) { |
// we have changed state |
// process this token in the new state |
return $this->yylex(); |
} elseif ($r === false) { |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
if ($this->counter >= strlen($this->data)) { |
return false; // end of input |
} |
// skip this token |
continue; |
} else { |
// accept |
$this->counter += strlen($this->value); |
$this->line += substr_count($this->value, "\n"); |
return true; |
} |
} |
} else { |
throw new Exception('Unexpected input at line' . $this->line . |
': ' . $this->data[$this->counter]); |
} |
break; |
} while (true); |
} // end function |
const START = 1; |
function yy_r1_1($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART; |
} |
function yy_r1_2($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_SI_QSTR; |
} |
function yy_r1_3($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_ML_QSTR; |
} |
function yy_r1_4($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_DO_QSTR; |
} |
function yy_r1_5($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB; |
} |
function yy_r1_6($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB; |
} |
function yy_r1_7($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL; |
} |
function yy_r1_8($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_NUMBER; |
} |
function yy_r1_10($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_EOL; |
} |
function yy_r1_12($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_SPACE; |
} |
function yy_r1_13($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_DOT; |
} |
function yy_r1_14($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_ID; |
} |
function yy_r1_15($yy_subpatterns) |
{ |
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER; |
} |
} |
/branches/ant-ng/lib/sysplugins/internal.smartytemplatecompiler.php |
---|
Новый файл |
0,0 → 1,74 |
<?php |
/** |
* Smarty Internal Plugin Smarty Template Compiler Base |
* |
* This file contains the basic classes and methodes for compiling Smarty templates with lexer/parser |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Class SmartyTemplateCompiler |
*/ |
class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCompilerBase { |
/** |
* Initialize compiler |
*/ |
public function __construct($lexer_class, $parser_class, $smarty) |
{ |
$this->smarty = $smarty; |
parent::__construct(); |
// get required plugins |
$this->smarty->loadPlugin($lexer_class); |
$this->smarty->loadPlugin($parser_class); |
$this->lexer_class = $lexer_class; |
$this->parser_class = $parser_class; |
} |
/** |
* Methode to compile a Smarty template |
* |
* @param $_content template source |
* @return bool true if compiling succeeded, false if it failed |
*/ |
protected function doCompile($_content) |
{ |
/* here is where the compiling takes place. Smarty |
tags in the templates are replaces with PHP code, |
then written to compiled files. */ |
// init the lexer/parser to compile the template |
$lex = new $this->lexer_class($_content,$this->smarty); |
$parser = new $this->parser_class($lex, $this); |
// $parser->PrintTrace(); |
// get tokens from lexer and parse them |
while ($lex->yylex() && !$this->abort_and_recompile) { |
// echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; |
$parser->doParse($lex->token, $lex->value); |
} |
if ($this->abort_and_recompile) { |
// exit here on abort |
return false; |
} |
// finish parsing process |
$parser->doParse(0, 0); |
// check for unclosed tags |
if (count($this->_tag_stack) > 0) { |
// get stacked info |
list($_open_tag, $_data) = array_pop($this->_tag_stack); |
$this->trigger_template_error("unclosed {" . $_open_tag . "} tag"); |
} |
if (!$this->compile_error) { |
// return compiled code |
return $parser->retvalue; |
} else { |
// compilation error |
return false; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getcachedir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getCacheDir |
* |
* Returns directory of cache files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns directory of cache files |
*/ |
/** |
* Returns directory of cache files |
* |
* @return array cache folder |
*/ |
public function getCacheDir($smarty) |
{ |
return $this->smarty->cache_dir; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_function_plugin.php |
---|
Новый файл |
0,0 → 1,50 |
<?php |
/** |
* Smarty Internal Plugin Compile Function Plugin |
* |
* Compiles code for the execution of function plugin |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Function Plugin Class |
*/ |
class Smarty_Internal_Compile_Function_Plugin extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the execution of function plugin |
* |
* @param array $args array with attributes from parser |
* @param string $tag name of function |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $tag, $compiler) |
{ |
$this->compiler = $compiler; |
// This tag does create output |
$this->compiler->has_output = true; |
$this->required_attributes = array(); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// not cachable? |
if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) { |
$this->compiler->tag_nocache = true; |
} |
// convert attributes into parameter array string |
$_paramsArray = array(); |
foreach ($_attr as $_key => $_value) { |
$_paramsArray[] = "'$_key'=>$_value"; |
} |
$_params = 'array(' . implode(",", $_paramsArray) . ')'; |
// compile code |
$output = '<?php echo $_smarty_tpl->smarty->plugin_handler->' . $tag . '(array(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl),\'function\');?>'; |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isconfigoverwrite.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isConfigOverwrite |
* |
* is config overwrite mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is config overwrite mode |
*/ |
function isConfigOverwrite($smarty) |
{ |
return $smarty->config_overwrite; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disabledebugging.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method disableDebugging |
* |
* Disable debugging |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable debugging |
*/ |
function disableDebugging($smarty) |
{ |
$smarty->debugging = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.get_registered_object.php |
---|
Новый файл |
0,0 → 1,34 |
<?php |
/** |
* Smarty method Get_Registered_Object |
* |
* Registers a PHP object |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns a reference to a registered object |
*/ |
/** |
* return a reference to a registered object |
* |
* @param string $name |
* @return object |
*/ |
function get_registered_object($smarty, $name) |
{ |
if (!isset($smarty->registered_objects[$name])) |
throw new Exception("'$name' is not a registered object"); |
if (!is_object($smarty->registered_objects[$name][0])) |
throw new Exception("registered '$name' is not an object"); |
return $smarty->registered_objects[$name][0]; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.enableconfigoverwrite.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method enableConfigOverwrite |
* |
* Enable config overwrite mode |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Enable config overwrite mode |
*/ |
public function enableConfigOverwrite($smarty) |
{ |
$smarty->config_overwrite = true; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_debug.php |
---|
Новый файл |
0,0 → 1,34 |
<?php |
/** |
* Smarty Internal Plugin Compile Debug |
* |
* Compiles the {debug} tag |
* It opens a window the the Smarty Debugging Console |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Debug Class |
*/ |
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {debug} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// display debug template |
$_output = "\$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl->smarty);"; |
return "<?php $_output ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.setdebugtemplate.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method setDebugTemplate |
* |
* Sets debug template filepath |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Sets debug template filepath |
*/ |
/** |
* Sets debug template filepath |
* |
* @param string $ array debug template filepath |
*/ |
function SetDebugTemplate(smarty, $debug_tpl) |
{ |
$smarty->debug_tpl = $debug_tpl; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.isdebuggingurlctrl.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isDebuggingUrlCtrl |
* |
* is possibility to is debugging by SMARTY_DEBUG attribute |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is possibility to is debugging by SMARTY_DEBUG attribute |
*/ |
function isDebuggingUrlCtrl($smarty) |
{ |
return $smarty->debugging_ctrl != 'none'; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_registered.php |
---|
Новый файл |
0,0 → 1,152 |
<?php |
/** |
* Smarty Internal Plugin Resource Registered |
* |
* Implements the registered resource for Smarty template |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource Registered |
*/ |
class Smarty_Internal_Resource_Registered { |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
// classes used for compiling Smarty templates from file resource |
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
public $template_parser_class = 'Smarty_Internal_Templateparser'; |
/** |
* Return flag if template source is existing |
* |
* @return boolean true |
*/ |
public function isExisting($_template) |
{ |
if (is_integer($this->getTemplateTimestamp($_template))) { |
return true; |
} else { |
return false; |
} |
} |
/** |
* Get filepath to template source |
* |
* @param object $_template template object |
* @return string return 'string' as template source is not a file |
*/ |
public function getTemplateFilepath($_template) |
{ |
// no filepath for strings |
// return "string" for compiler error messages |
$_filepath = $_template->resource_type .':'.$_template->resource_name; |
return $_filepath; |
} |
/** |
* Get timestamp to template source |
* |
* @param object $_template template object |
* @return boolean false as string resources have no timestamp |
*/ |
public function getTemplateTimestamp($_template) |
{ |
// return timestamp |
$time_stamp = false; |
call_user_func_array($this->smarty->_plugins['resource'][$_template->resource_type][0][1], |
array($_template->resource_name, &$time_stamp, $this->smarty)); |
return $time_stamp; |
} |
/** |
* Get timestamp to template source by type and name |
* |
* @param object $_template template object |
* @return boolean false as string resources have no timestamp |
*/ |
public function getTemplateTimestampTypeName($_resource_type, $_resource_name) |
{ |
// return timestamp |
$time_stamp = false; |
call_user_func_array($this->smarty->_plugins['resource'][$_resource_type][0][1], |
array($_resource_name, &$time_stamp, $this->smarty)); |
return $time_stamp; |
} |
/** |
* Retuen template source from resource name |
* |
* @param object $_template template object |
* @return string content of template source |
*/ |
public function getTemplateSource($_template) |
{ |
// return template string |
return call_user_func_array($this->smarty->_plugins['resource'][$_template->resource_type][0][0], |
array($_template->resource_name, &$_template->template_source, $this->smarty)); |
} |
/** |
* Return flag that this resource uses the compiler |
* |
* @return boolean true |
*/ |
public function usesCompiler() |
{ |
// resource string is template, needs compiler |
return true; |
} |
/** |
* Return flag that this resource is evaluated |
* |
* @return boolean true |
*/ |
public function isEvaluated() |
{ |
// compiled template is evaluated instead of saved to disk |
return false; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $_template template object |
* @return boolean return false as compiled template is not stored |
*/ |
public function getCompiledFilepath($_template) |
{ |
// $_filepath = md5($_template->resource_name); |
$_filepath = (string)abs(crc32($_template->template_resource)); |
// if use_sub_dirs, break file into directories |
if ($_template->smarty->use_sub_dirs) { |
$_filepath = substr($_filepath, 0, 3) . DS |
. substr($_filepath, 0, 2) . DS |
. substr($_filepath, 0, 1) . DS |
. $_filepath; |
} |
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^'; |
if (isset($_template->compile_id)) { |
$_filepath = $_template->compile_id . $_compile_dir_sep . $_filepath; |
} |
if ($_template->caching) { |
$_cache = '.cache'; |
} else { |
$_cache = ''; |
} |
$_compile_dir = $_template->smarty->compile_dir; |
if (strpos('/\\', substr($_compile_dir, -1)) === false) { |
$_compile_dir .= DS; |
} |
return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_template->resource_name) . $_cache . $_template->smarty->php_ext; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.security_handler.php |
---|
Новый файл |
0,0 → 1,130 |
<?php |
/** |
* Smarty Internal Plugin Security Handler |
* |
* @package Smarty |
* @subpackage Security |
* @author Uwe Tews |
*/ |
/** |
* This class contains all methods for security checking |
*/ |
class Smarty_Internal_Security_Handler { |
function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
/** |
* Check if PHP function is trusted. |
* |
* @param string $function_name |
* @param object $compiler compiler object |
* @return boolean true if function is trusted |
*/ |
function isTrustedPhpFunction($function_name, $compiler) |
{ |
if (empty($this->smarty->security_policy->php_functions) || in_array($function_name, $this->smarty->security_policy->php_functions)) { |
return true; |
} else { |
$compiler->trigger_template_error ("PHP function \"" . $function_name . "\" not allowed by security setting"); |
return false; |
} |
} |
/** |
* Check if modifier is trusted. |
* |
* @param string $modifier_name |
* @param object $compiler compiler object |
* @return boolean true if modifier is trusted |
*/ |
function isTrustedModifier($modifier_name, $compiler) |
{ |
if (empty($this->smarty->security_policy->modifiers) || in_array($modifier_name, $this->smarty->security_policy->modifiers)) { |
return true; |
} else { |
$compiler->trigger_template_error ("modifier \"" . $modifier_name . "\" not allowed by security setting"); |
return false; |
} |
} |
/** |
* Check if stream is trusted. |
* |
* @param string $stream_name |
* @param object $compiler compiler object |
* @return boolean true if stream is trusted |
*/ |
function isTrustedStream($stream_name) |
{ |
if (empty($this->smarty->security_policy->streams) || in_array($stream_name, $this->smarty->security_policy->streams)) { |
return true; |
} else { |
throw new Exception ("stream \"" . $stream_name . "\" not allowed by security setting"); |
return false; |
} |
} |
/** |
* Check if directory of file resource is trusted. |
* |
* @param string $filepath |
* @param object $compiler compiler object |
* @return boolean true if directory is trusted |
*/ |
function isTrustedResourceDir($filepath) |
{ |
$_rp = realpath($filepath); |
if (isset($this->smarty->template_dir)) { |
foreach ((array)$this->smarty->template_dir as $curr_dir) { |
if (($_cd = realpath($curr_dir)) !== false && |
strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
(strlen($_rp) == strlen($_cd) || substr($_rp, strlen($_cd), 1) == DS)) { |
return true; |
} |
} |
} |
if (!empty($this->smarty->security_policy->secure_dir)) { |
foreach ((array)$this->smarty->security_policy->secure_dir as $curr_dir) { |
if (($_cd = realpath($curr_dir)) !== false) { |
if ($_cd == $_rp) { |
return true; |
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
(strlen($_rp) == strlen($_cd) || substr($_rp, strlen($_cd), 1) == DS)) { |
return true; |
} |
} |
} |
} |
throw new Exception ("directory \"" . $_rp . "\" not allowed by security setting"); |
return false; |
} |
/** |
* Check if directory of file resource is trusted. |
* |
* @param string $filepath |
* @param object $compiler compiler object |
* @return boolean true if directory is trusted |
*/ |
function isTrustedPHPDir($filepath) |
{ |
$_rp = realpath($filepath); |
if (!empty($this->smarty->security_policy->trusted_dir)) { |
foreach ((array)$this->smarty->security_policy->trusted_dir as $curr_dir) { |
if (($_cd = realpath($curr_dir)) !== false) { |
if ($_cd == $_rp) { |
return true; |
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && |
substr($_rp, strlen($_cd), 1) == DS) { |
return true; |
} |
} |
} |
} |
throw new Exception ("directory \"" . $_rp . "\" not allowed by security setting"); |
return false; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.run_filter.php |
---|
Новый файл |
0,0 → 1,68 |
<?php |
/** |
* Smarty Internal Plugin Run Filter |
* |
* Smarty run filter class |
* |
* @package Smarty |
* @subpackage PluginsInternal |
* @author Uwe Tews |
*/ |
/** |
* Class for filter processing |
*/ |
class Smarty_Internal_Run_Filter { |
function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
/** |
* Run filters over content |
* |
* The filters will be lazy loaded if required |
* class name format: Smarty_FilterType_FilterName |
* plugin filename format: filtertype.filtername.php |
* Smarty2 filter plugins could be used |
* |
* @param string $type the type of filter ('pre','post','output' or 'variable') which shall run |
* @param string $content the content which shall be processed by the filters |
* @return string the filtered content |
*/ |
public function execute($type, $content, $flag = null) |
{ |
$output = $content; |
if ($type != 'variable' || ($this->smarty->variable_filter && $flag !== false) || $flag === true) { |
// loop over autoload filters of specified type |
if (!empty($this->smarty->autoload_filters[$type])) { |
foreach ((array)$this->smarty->autoload_filters[$type] as $name) { |
$plugin_name = "Smarty_{$type}filter_{$name}"; |
if ($this->smarty->loadPlugin($plugin_name)) { |
// use class plugin if found |
if (class_exists($plugin_name, false)) { |
// loaded class of filter plugin |
$output = call_user_func_array(array($plugin_name, 'execute'), array($output, $this->smarty)); |
} elseif (function_exists($plugin_name)) { |
// use loaded Smarty2 style plugin |
$output = call_user_func_array($plugin_name, array($output, $this->smarty)); |
} |
} else { |
// nothing found, throw exception |
throw new Exception("Unable to load filter {$plugin_name}"); |
} |
} |
} |
// loop over registerd filters of specified type |
if (!empty($this->smarty->registered_filters[$type])) { |
foreach ($this->smarty->registered_filters[$type] as $key => $name) { |
$output = call_user_func_array($this->smarty->registered_filters[$type][$key], array($output, $this->smarty)); |
} |
} |
} |
// return filtered output |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.resource_string.php |
---|
Новый файл |
0,0 → 1,109 |
<?php |
/** |
* Smarty Internal Plugin Resource String |
* |
* Implements the strings as resource for Smarty template |
* |
* @package Smarty |
* @subpackage TemplateResources |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Resource String |
*/ |
class Smarty_Internal_Resource_String { |
public function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
// classes used for compiling Smarty templates from file resource |
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
public $template_parser_class = 'Smarty_Internal_Templateparser'; |
/** |
* Return flag if template source is existing |
* |
* @return boolean true |
*/ |
public function isExisting($template) |
{ |
return true; |
} |
/** |
* Get filepath to template source |
* |
* @param object $_template template object |
* @return string return 'string' as template source is not a file |
*/ |
public function getTemplateFilepath($_template) |
{ |
// no filepath for strings |
// return "string" for compiler error messages |
return 'string'; |
} |
/** |
* Get timestamp to template source |
* |
* @param object $_template template object |
* @return boolean false as string resources have no timestamp |
*/ |
public function getTemplateTimestamp($_template) |
{ |
// strings must always be compiled and have no timestamp |
return false; |
} |
/** |
* Retuen template source from resource name |
* |
* @param object $_template template object |
* @return string content of template source |
*/ |
public function getTemplateSource($_template) |
{ |
// return template string |
$_template->template_source = $_template->resource_name; |
return true; |
} |
/** |
* Return flag that this resource uses the compiler |
* |
* @return boolean true |
*/ |
public function usesCompiler() |
{ |
// resource string is template, needs compiler |
return true; |
} |
/** |
* Return flag that this resource is evaluated |
* |
* @return boolean true |
*/ |
public function isEvaluated() |
{ |
// compiled template is evaluated instead of saved to disk |
return true; |
} |
/** |
* Get filepath to compiled template |
* |
* @param object $_template template object |
* @return boolean return false as compiled template is not stored |
*/ |
public function getCompiledFilepath($_template) |
{ |
// no filepath for strings |
return false; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_elseif.php |
---|
Новый файл |
0,0 → 1,36 |
<?php |
/** |
* Smarty Internal Plugin Compile Else If |
* |
* Compiles the {elseif} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile ElseIf Class |
*/ |
class Smarty_Internal_Compile_ElseIf extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {elseif} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('if condition'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_close_tag(array('if', 'elseif')); |
$this->_open_tag('elseif'); |
return '<?php elseif (' . $args['if condition'] . '): ?>'; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_append.php |
---|
Новый файл |
0,0 → 1,61 |
<?php |
/** |
* Smarty Internal Plugin Compile Append |
* |
* Compiles the {append} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Append Class |
*/ |
class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {append} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('var', 'value'); |
$this->optional_attributes = array('scope', 'nocache', 'index'); |
$_nocache = 'null'; |
$_scope = 'null'; |
// check for nocache attribute before _get_attributes because |
// it shall not controll caching of the compiled code, but is a parameter |
if (isset($args['nocache'])) { |
if ($args['nocache'] == 'true') { |
$_nocache = 'true'; |
$_nocache_boolean = true; |
} |
unset($args['nocache']); |
} |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
if (isset($_attr['scope'])) { |
if ($_attr['scope'] == '\'parent\'') { |
$_scope = SMARTY_PARENT_SCOPE; |
} elseif ($_attr['scope'] == '\'root\'') { |
$_scope = SMARTY_ROOT_SCOPE; |
} elseif ($_attr['scope'] == '\'global\'') { |
$_scope = SMARTY_GLOBAL_SCOPE; |
} |
} |
// compiled output |
if (isset($_attr['index'])) { |
return "<?php \$_smarty_tpl->append($_attr[var],array($_attr[index] => $_attr[value]),true,$_nocache,$_scope);?>"; |
} else { |
return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>"; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_compiled_tpl.php |
---|
Новый файл |
0,0 → 1,64 |
<?php |
/** |
* Smarty method Clear_Compiled_Tpl |
* |
* Deletes compiled template files |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Delete compiled template file |
* |
* @param string $resource_name template name |
* @param string $compile_id compile id |
* @param integer $exp_time expiration time |
* @return integer number of template files deleted |
*/ |
function clear_compiled_tpl($smarty, $resource_name = null, $compile_id = null, $exp_time = null) |
{ |
$_dir_sep = $smarty->use_sub_dirs ? DS : '^'; |
if (isset($resource_name)) { |
$_resource_part_1 = $resource_name . $smarty->php_ext; |
$_resource_part_2 = $resource_name . '.cache' . $smarty->php_ext; |
} else { |
$_resource_part = ''; |
} |
$_dir = $smarty->compile_dir; |
if ($smarty->use_sub_dirs && isset($compile_id)) { |
$_dir .= $compile_id . $_dir_sep; |
} |
if (isset($compile_id)) { |
$_compile_id_part = $smarty->compile_dir . $compile_id . $_dir_sep; |
} |
$_count = 0; |
$_compileDirs = new RecursiveDirectoryIterator($_dir); |
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST); |
foreach ($_compile as $_file) { |
if (strpos($_file, '.svn') !== false) continue; |
if ($_file->isDir()) { |
if (!$_compile->isDot()) { |
// delete folder if empty |
@rmdir($_file->getPathname()); |
} |
} else { |
if ((!isset($compile_id) || substr_compare((string)$_file, $_compile_id_part, 0, strlen($_compile_id_part)) == 0) && |
(!isset($resource_name) || substr_compare((string)$_file, $_resource_part_1, - strlen($_resource_part_1), strlen($_resource_part_1)) == 0 || |
substr_compare((string)$_file, $_resource_part_2, - strlen($_resource_part_2), strlen($_resource_part_2)) == 0)) { |
if (isset($exp_time)) { |
if (time() - @filemtime($_file) >= $exp_time) { |
$_count += unlink((string) $_file) ? 1 : 0; |
} |
} else { |
$_count += unlink((string) $_file) ? 1 : 0; |
} |
} |
} |
} |
return $_count; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_foreachelse.php |
---|
Новый файл |
0,0 → 1,33 |
<?php |
/** |
* Smarty Internal Plugin Compile Foreach Else |
* |
* Compiles the {foreachelse} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Foreachelse Class |
*/ |
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {foreachelse} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$this->_close_tag('foreach'); |
$this->_open_tag('foreachelse'); |
return "<?php }} else { ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.plugin_handler.php |
---|
Новый файл |
0,0 → 1,104 |
<?php |
/** |
* Smarty Internal Plugin Handler |
* |
* @package Smarty |
* @subpackage PluginsInternal |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Handler Class |
*/ |
class Smarty_Internal_Plugin_Handler { |
function __construct($smarty) |
{ |
$this->smarty = $smarty; |
} |
/** |
* Call a Smarty plugin |
* |
* @param string $name block function name |
* @param array $args $args[0] = array of plugin attributes and $args[1] = plugin types to search for |
*/ |
public function __call($name, $args) |
{ |
if ($this->loadSmartyPlugin($name, $args[1])) { |
// call plugin |
return call_user_func_array($this->smarty->registered_plugins[$name][1], $args[0]); |
} else { |
// plugin not found |
throw new Exception("Unable to load plugin {$name}"); |
} |
} |
public function executeModifier($name, $args, $check_array) |
{ |
if ($this->loadSmartyPlugin($name, 'modifier')) { |
// call plugin |
if (!$check_array || !is_array($args[0])) { |
return call_user_func_array($this->smarty->registered_plugins[$name][1], $args); |
} else { |
$args0 = $args[0]; |
foreach ($args0 as $key => $arg0) { |
$args[0] = $arg0; |
$result[$key] = call_user_func_array($this->smarty->registered_plugins[$name][1], $args); |
} |
return $result; |
} |
} elseif (is_callable($name)) { |
if (!$check_array || !is_array($args[0])) { |
return call_user_func_array($name, $args); |
} else { |
$args0 = $args[0]; |
foreach ($args0 as $key => $arg0) { |
$args[0] = $arg0; |
$result[$key] = call_user_func_array($name, $args); |
} |
return $result; |
} |
} else { |
// plugin not found |
throw new Exception("Unable to load plugin {$name}"); |
} |
} |
/** |
* Lazy loads plugin files |
* class name format: Smarty_PluginType_FuncName |
* plugin filename format: plugintype.funcname.php |
* |
* @param string $name plugin name |
* @param array $type array of plugin types to search for |
*/ |
public function loadSmartyPlugin($name, $type) |
{ |
// load plugin if missing |
if (isset($this->smarty->registered_plugins[$name])) { |
return true; |
} else { |
foreach ((array)$type as $plugin_type) { |
$plugin = 'smarty_' . $plugin_type . '_' . $name; |
if ($this->smarty->loadPlugin($plugin)) { |
if (class_exists($plugin, false)) { |
$plugin = array(new $plugin, 'execute'); |
} |
if (is_callable($plugin)) { |
$this->smarty->registered_plugins[$name] = array($plugin_type, $plugin, true); |
return true; |
} else { |
throw new Exception("Plugin \"{$name}\" not callable"); |
} |
} |
} |
} |
if (!empty($this->smarty->default_plugin_handler_func)) { |
if (!is_callable($this->smarty->default_plugin_handler_func)) { |
throw new Exception("Default template handler not callable"); |
} else { |
return call_user_func_array($this->smarty->default_plugin_handler_func, array($name, $type, &$this)); |
} |
} |
return false; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_object_block_function.php |
---|
Новый файл |
0,0 → 1,58 |
<?php |
/** |
* Smarty Internal Plugin Compile Object Block Function |
* |
* Compiles code for registered objects as block function |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Object Block Function Class |
*/ |
class Smarty_Internal_Compile_Object_Block_Function extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the execution of block plugin |
* |
* @param array $args array with attributes from parser |
* @param string $tag name of block function |
* @param string $methode name of methode to call |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $tag, $methode, $compiler) |
{ |
$this->compiler = $compiler; |
if (strlen($tag) < 5 || substr_compare($tag, 'close', -5, 5) != 0) { |
// opening tag of block plugin |
$this->required_attributes = array(); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// convert attributes into parameter array string |
$_paramsArray = array(); |
foreach ($_attr as $_key => $_value) { |
$_paramsArray[] = "'$_key'=>$_value"; |
} |
$_params = 'array(' . implode(",", $_paramsArray) . ')'; |
$this->_open_tag($tag.'->'.$methode, $_params); |
// compile code |
$output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->registered_objects[\''.$tag.'\'][0]->' . $methode . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>'; |
} else { |
// closing tag of block plugin |
$_params = $this->_close_tag(substr($tag,0,-5).'->'.$methode); |
// This tag does create output |
$this->compiler->has_output = true; |
// compile code |
$output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->registered_objects[\''.substr($tag,0,-5).'\'][0]->' . $methode . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>'; |
} |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_function.php |
---|
Новый файл |
0,0 → 1,33 |
<?php |
/** |
* Smarty method Register_Function |
* |
* Registers a PHP function as Smarty function plugin |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers custom function to be used in templates |
* |
* @param object $smarty |
* @param string $function_tag the name of the template function |
* @param string $function_impl the name of the PHP function to register |
* @param boolean $cacheable if true (default) this fuction is cachable |
*/ |
function register_function($smarty, $function_tag, $function_impl, $cacheable = true, $cache_attr = array()) |
{ |
if (isset($smarty->registered_plugins[$function_tag])) { |
throw new Exception("Plugin tag \"{$function_tag}\" already registered"); |
} elseif (!is_callable($function_impl)) { |
throw new Exception("Plugin \"{$function_tag}\" not callable"); |
} else { |
$smarty->registered_plugins[$function_tag] = |
array('function', $function_impl, $cacheable, $cache_attr); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.disableforcecompile.php |
---|
Новый файл |
0,0 → 1,22 |
<?php |
/** |
* Smarty method disableForceCompile |
* |
* Disable forced compiling |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Disable forced compiling |
*/ |
function disableForceCompile($smarty) |
{ |
$smarty->force_compile = false; |
return; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_extend.php |
---|
Новый файл |
0,0 → 1,88 |
<?php |
/** |
* Smarty Internal Plugin Compile extend |
* |
* Compiles the {extend} tag |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile extend Class |
*/ |
class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {extend} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('file'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
$_smarty_tpl = $compiler->template; |
// $include_file = ''; |
eval('$include_file = ' . $_attr['file'] . ';'); |
// create template object |
$_template = new Smarty_Template ($include_file, $this->compiler->smarty, $compiler->template); |
// save file dependency |
$compiler->template->properties['file_dependency']['F'.abs(crc32($_template->getTemplateFilepath()))] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp()); |
$_old_source = $compiler->template->template_source; |
if (preg_match_all('/(' . $this->compiler->smarty->left_delimiter . 'block(.+?)' . $this->compiler->smarty->right_delimiter . ')/', $_old_source, $s, PREG_OFFSET_CAPTURE) != |
preg_match_all('/(' . $this->compiler->smarty->left_delimiter . '\/block(.*?)' . $this->compiler->smarty->right_delimiter . ')/', $_old_source, $c, PREG_OFFSET_CAPTURE)) { |
$this->compiler->trigger_template_error(" unmatched {block} {/block} pairs"); |
} |
$block_count = count($s[0]); |
for ($i = 0; $i < $block_count; $i++) { |
$block_content = str_replace($this->compiler->smarty->left_delimiter . '$smarty.parent' . $this->compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', |
substr($_old_source, $s[0][$i][1] + strlen($s[0][$i][0]), $c[0][$i][1] - $s[0][$i][1] - strlen($s[0][$i][0]))); |
$this->saveBlockData($block_content, $s[0][$i][0]); |
} |
$compiler->template->template_source = $_template->getTemplateSource(); |
$compiler->abort_and_recompile = true; |
return ' '; |
} |
protected function saveBlockData($block_content, $block_tag) |
{ |
if (0 == preg_match('/(.?)(name=)([^ ]*)/', $block_tag, $_match)) { |
$this->compiler->trigger_template_error("\"" . $block_tag . "\" missing name attribute"); |
} else { |
// compile block content |
$_tpl = $this->compiler->smarty->createTemplate('string:' . $block_content); |
$_tpl->template_filepath = $this->compiler->template->getTemplateFilepath(); |
$_tpl->suppressHeader = true; |
$_compiled_content = $_tpl->getCompiledTemplate(); |
unset($_tpl); |
$_name = trim($_match[3], "\"'}"); |
if (isset($this->compiler->template->block_data[$_name])) { |
if (strpos($this->compiler->template->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { |
$this->compiler->template->block_data[$_name]['compiled'] = |
str_replace('%%%%SMARTY_PARENT%%%%', $_compiled_content, $this->compiler->template->block_data[$_name]['compiled']); |
} elseif ($this->compiler->template->block_data[$_name]['mode'] == 'prepend') { |
$this->compiler->template->block_data[$_name]['compiled'] .= $_compiled_content; |
} elseif ($this->compiler->template->block_data[$_name]['mode'] == 'append') { |
$this->compiler->template->block_data[$_name]['compiled'] = $_compiled_content . $this->compiler->template->block_data[$_name]['compiled']; |
} |
} else { |
$this->compiler->template->block_data[$_name]['compiled'] = $_compiled_content; |
} |
if (preg_match('/(.?)(append=true)(.*)/', $block_tag, $_match) != 0) { |
$this->compiler->template->block_data[$_name]['mode'] = 'append'; |
} elseif (preg_match('/(.?)(prepend=true)(.*)/', $block_tag, $_match) != 0) { |
$this->compiler->template->block_data[$_name]['mode'] = 'prepend'; |
} else { |
$this->compiler->template->block_data[$_name]['mode'] = 'replace'; |
} |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_eval.php |
---|
Новый файл |
0,0 → 1,46 |
<?php |
/** |
* Smarty Internal Plugin Compile Eval |
* |
* Compiles the {eval} tag |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Eval Class |
*/ |
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the {eval} tag |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('var'); |
$this->optional_attributes = array('assign'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
if (isset($_attr['assign'])) { |
// output will be stored in a smarty variable instead of beind displayed |
$_assign = $_attr['assign']; |
} |
// create template object |
$_output = "\$_template = new Smarty_Template ('string:'.".$_attr['var'].", \$_smarty_tpl->smarty, \$_smarty_tpl);"; |
//was there an assign attribute? |
if (isset($_assign)) { |
$_output .= "\$_smarty_tpl->assign($_assign,\$_smarty_tpl->smarty->fetch(\$_template));"; |
} else { |
$_output .= "echo \$_smarty_tpl->smarty->fetch(\$_template);"; |
} |
return "<?php $_output ?>"; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.register_postfilter.php |
---|
Новый файл |
0,0 → 1,25 |
<?php |
/** |
* Smarty method Register_Postfilter |
* |
* Registers a PHP function as postfilter |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers a postfilter function to apply |
* to a compiled template after compilation |
* |
* @param object $smarty |
* @param callback $function |
*/ |
function register_postfilter($smarty, $function) |
{ |
$smarty->registered_filters['post'][$smarty->_get_filter_name($function)] = $function; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.templatebase.php |
---|
Новый файл |
0,0 → 1,407 |
<?php |
/** |
* Smarty Internal Plugin TemplateBase |
* |
* This file contains the basic classes and methodes for template and variable creation |
* |
* @package Smarty |
* @subpackage Templates |
* @author Uwe Tews |
*/ |
/** |
* Base class with template and variable methodes |
*/ |
class Smarty_Internal_TemplateBase { |
// class used for templates |
public $template_class = 'Smarty_Internal_Template'; |
/** |
* assigns a Smarty variable |
* |
* @param array $ |string $tpl_var the template variable name(s) |
* @param mixed $value the value to assign |
* @param boolean $nocache if true any output of this variable will be not cached |
* @param boolean $scope the scope the variable will have (local,parent or root) |
*/ |
public function assign($tpl_var, $value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) |
{ |
if (is_array($tpl_var)) { |
foreach ($tpl_var as $_key => $_val) { |
if ($_key != '') { |
$this->check_tplvar($_key); |
$this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache, $scope); |
} |
} |
} else { |
if ($tpl_var != '') { |
$this->check_tplvar($tpl_var); |
$this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache, $scope); |
} |
} |
} |
/** |
* assigns a global Smarty variable |
* |
* @param string $varname the global variable name |
* @param mixed $value the value to assign |
* @param boolean $nocache if true any output of this variable will be not cached |
*/ |
public function assign_global($varname, $value = null, $nocache = false) |
{ |
if ($varname != '') { |
$this->check_tplvar($varname); |
$this->smarty->global_tpl_vars[$varname] = new Smarty_variable($value, $nocache); |
} |
} |
/** |
* assigns values to template variables by reference |
* wrapper to assign |
*/ |
public function assign_by_ref($tpl_var, &$value, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) |
{ |
$this->assign($tpl_var, $value, $nocache, $scope); |
} |
/** |
* appends values to template variables |
* |
* @param array $ |string $tpl_var the template variable name(s) |
* @param mixed $value the value to append |
* @param boolean $merge flag if array elements shall be merged |
* @param boolean $nocache if true any output of this variable will be not cached |
* @param boolean $scope the scope the variable will have (local,parent or root) |
*/ |
public function append($tpl_var, $value = null, $merge = false, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) |
{ |
if (is_array($tpl_var)) { |
// $tpl_var is an array, ignore $value |
foreach ($tpl_var as $_key => $_val) { |
if ($_key != '') { |
if (!isset($this->tpl_vars[$_key])) { |
$this->check_tplvar($_key); |
$tpl_var_inst = $this->getVariable($_key, null, true, false); |
if ($tpl_var_inst instanceof Undefined_Smarty_Variable) { |
$this->tpl_vars[$_key] = new Smarty_variable(null, $nocache, $scope); |
} else { |
$this->tpl_vars[$_key] = clone $tpl_var_inst; |
if ($scope != SMARTY_LOCAL_SCOPE) { |
$this->tpl_vars[$_key]->scope = $scope; |
} |
} |
} |
if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) { |
settype($this->tpl_vars[$_key]->value, 'array'); |
} |
if ($merge && is_array($_val)) { |
foreach($_val as $_mkey => $_mval) { |
$this->tpl_vars[$_key]->value[$_mkey] = $_mval; |
} |
} else { |
$this->tpl_vars[$_key]->value[] = $_val; |
} |
} |
} |
} else { |
if ($tpl_var != '' && isset($value)) { |
if (!isset($this->tpl_vars[$tpl_var])) { |
$this->check_tplvar($tpl_var); |
$tpl_var_inst = $this->getVariable($tpl_var, null, true, false); |
if ($tpl_var_inst instanceof Undefined_Smarty_Variable) { |
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache, $scope); |
} else { |
$this->tpl_vars[$tpl_var] = clone $tpl_var_inst; |
if ($scope != SMARTY_LOCAL_SCOPE) { |
$this->tpl_vars[$tpl_var]->scope = $scope; |
} |
} |
} |
if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) { |
settype($this->tpl_vars[$tpl_var]->value, 'array'); |
} |
if ($merge && is_array($value)) { |
foreach($value as $_mkey => $_mval) { |
$this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval; |
} |
} else { |
$this->tpl_vars[$tpl_var]->value[] = $value; |
} |
} |
} |
} |
/** |
* appends values to template variables by reference |
* |
* wrapper to append |
*/ |
public function append_by_ref($tpl_var, $value = null, $merge = false, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) |
{ |
$this->append($tpl_var, $value, $merge, $nocache, $scope); |
} |
/** |
* check if template variable name is reserved. |
* |
* @param string $tpl_var the template variable |
*/ |
private function check_tplvar($tpl_var) |
{ |
if (in_array($tpl_var, array('this', 'smarty'))) { |
throw new Exception("Cannot assign value to reserved var '{$tpl_var}'"); |
} |
} |
/** |
* clear the given assigned template variable. |
* |
* @param string $ |array $tpl_var the template variable(s) to clear |
*/ |
public function clear_assign($tpl_var) |
{ |
if (is_array($tpl_var)) { |
foreach ($tpl_var as $curr_var) { |
unset($this->tpl_vars[$curr_var]); |
} |
} else { |
unset($this->tpl_vars[$tpl_var]); |
} |
} |
/** |
* clear all the assigned template variables. |
*/ |
public function clear_all_assign() |
{ |
$this->tpl_vars = array(); |
} |
/** |
* gets the object of a Smarty variable |
* |
* @param string $variable the name of the Smarty variable |
* @param object $_ptr optional pointer to data object |
* @param boolean $search_parents search also in parent data |
* @return object the object of the variable |
*/ |
public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true) |
{ |
if ($_ptr === null) { |
$_ptr = $this; |
} while ($_ptr !== null) { |
if (isset($_ptr->tpl_vars[$variable])) { |
// found it, return it |
return $_ptr->tpl_vars[$variable]; |
} |
// not found, try at parent |
if ($search_parents) { |
$_ptr = $_ptr->parent; |
} else { |
$_ptr = null; |
} |
} |
if (isset($this->smarty->global_tpl_vars[$variable])) { |
// found it, return it |
return $this->smarty->global_tpl_vars[$variable]; |
} |
if (Smarty::$error_unassigned && $error_enable) { |
throw new Exception('Undefined Smarty variable "' . $variable . '"'); |
} else { |
return new Undefined_Smarty_Variable; |
} |
} |
/** |
* gets a config variable |
* |
* @param string $variable the name of the config variable |
* @return mixed the value of the config variable |
*/ |
public function getConfigVariable($variable) |
{ |
$_ptr = $this; |
while ($_ptr !== null) { |
if (isset($_ptr->config_vars[$variable])) { |
// found it, return it |
return $_ptr->config_vars[$variable]; |
} |
// not found, try at parent |
$_ptr = $_ptr->parent; |
} |
if (Smarty::$error_unassigned) { |
throw new Exception('Undefined config variable "' . $variable . '"'); |
} else { |
return ''; |
} |
} |
/** |
* gets a stream variable |
* |
* @param string $variable the stream of the variable |
* @return mixed the value of the stream variable |
*/ |
public function getStreamVariable($variable) |
{ |
$_result = ''; |
if ($fp = fopen($variable, 'r+')) { |
while (!feof($fp)) { |
$_result .= fgets($fp); |
} |
fclose($fp); |
return $_result; |
} |
if (Smarty::$error_unassigned) { |
throw new Exception('Undefined stream variable "' . $variable . '"'); |
} else { |
return ''; |
} |
} |
/** |
* creates a template object |
* |
* @param string $template the resource handle of the template file |
* @param object $parent next higher level of Smarty variables |
* @param mixed $cache_id cache id to be used with this template |
* @param mixed $compile_id compile id to be used with this template |
* @returns object template object |
*/ |
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null) |
{ |
if (is_object($cache_id) || is_array($cache_id)) { |
$parent = $cache_id; |
$cache_id = null; |
} |
if (is_array($parent)) { |
$data = $parent; |
$parent = null; |
} else { |
$data = null; |
} |
if (!is_object($template)) { |
// we got a template resource |
$_templateId = $this->buildTemplateId ($template, $cache_id, $compile_id); |
// already in template cache? |
if (isset($this->smarty->template_objects[$_templateId])) { |
// return cached template object |
$tpl = $this->smarty->template_objects[$_templateId]; |
} else { |
// create and cache new template object |
$tpl = new $this->template_class($template, $this->smarty, $parent, $cache_id, $compile_id); |
} |
} else { |
// just return a copy of template class |
$tpl = $template; |
} |
// fill data if present |
if (is_array($data)) { |
// set up variable values |
foreach ($data as $_key => $_val) { |
$tpl->tpl_vars[$_key] = new Smarty_variable($_val); |
} |
} |
return $tpl; |
} |
/** |
* generates a template id |
* |
* @param string $_resource the resource handle of the template file |
* @param mixed $_cache_id cache id to be used with this template |
* @param mixed $_compile_id compile id to be used with this template |
* @returns string a unique template id |
*/ |
function buildTemplateId ($_resource, $_cache_id, $_compile_id) |
{ |
// return md5($_resource . md5($_cache_id) . md5($_compile_id)); |
return crc32($_resource . $_cache_id . $_compile_id); |
} |
/** |
* return current time |
* |
* @returns double current time |
*/ |
function _get_time() |
{ |
$_mtime = microtime(); |
$_mtime = explode(" ", $_mtime); |
return (double)($_mtime[1]) + (double)($_mtime[0]); |
} |
} |
/** |
* class for the Smarty data object |
* |
* The Smarty data object will hold Smarty variables in the current scope |
* |
* @param object $parent tpl_vars next higher level of Smarty variables |
*/ |
class Smarty_Data extends Smarty_Internal_TemplateBase { |
// array of variable objects |
public $tpl_vars = array(); |
// back pointer to parent object |
public $parent = null; |
// config vars |
public $config_vars = array(); |
/** |
* create Smarty data object |
*/ |
public function __construct ($_parent = null) |
{ |
if (is_object($_parent)) { |
// when object set up back pointer |
$this->parent = $_parent; |
} elseif (is_array($_parent)) { |
// set up variable values |
foreach ($_parent as $_key => $_val) { |
$this->tpl_vars[$_key] = new Smarty_variable($_val); |
} |
} else { |
throw new Exception("Wrong type for template variables"); |
} |
} |
} |
/** |
* class for the Smarty variable object |
* |
* This class defines the Smarty variable object |
*/ |
class Smarty_Variable { |
// template variable |
public $value; |
public $nocache; |
public $scope; |
/** |
* create Smarty variable object |
* |
* @param mixed $value the value to assign |
* @param boolean $nocache if true any output of this variable will be not cached |
* @param boolean $scope the scope the variable will have (local,parent or root) |
*/ |
public function __construct ($value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) |
{ |
$this->value = $value; |
$this->nocache = $nocache; |
$this->scope = $scope; |
} |
} |
/** |
* class for undefined variable object |
* |
* This class defines an object for undefined variable handling |
*/ |
class Undefined_Smarty_Variable { |
// return always false |
public function __get ($name) |
{ |
if ($name == 'nocache') { |
return false; |
} else { |
return null; |
} |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.config_load.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty methode Config_Load |
* |
* Loads a config file |
* |
* @package Smarty |
* @subpackage Config |
* @author Uwe Tews |
*/ |
/** |
* load a config file optionally load just selected sections |
* |
* @param object $smarty |
* @param string $config_file filename |
* @param mixed $sections array of section names, single section or null |
*/ |
function config_load($smarty, $config_file, $sections = null) |
{ |
// load Config class |
$smarty->loadPlugin('Smarty_Internal_Config'); |
$config = new Smarty_Internal_Config($config_file, $smarty); |
$config->loadConfigVars($sections, $smarty); |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.iscachemodifycheck.php |
---|
Новый файл |
0,0 → 1,21 |
<?php |
/** |
* Smarty method isCacheModifyCheck |
* |
* is cache modify check |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* is cache modify check |
*/ |
function isCacheModifyCheck() |
{ |
return $smarty->cache_modified_check; |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.registerdefaultpluginhandler.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method registerDefaultPluginhandlerHandler |
* |
* Registers a default plugin handler |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Registers a default plugin handler |
* |
* @param object $smarty |
* @param string $ |array $plugin class/methode name |
*/ |
function registerDefaultPluginHandler($smarty, $plugin) |
{ |
if (is_callable($plugin)) { |
$smarty->default_plugin_handler_func = $plugin; |
} else { |
throw new Exception('Default plugin handler "' . $plugin . '" not callable'); |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.clear_config.php |
---|
Новый файл |
0,0 → 1,30 |
<?php |
/** |
* Smarty method Get_Config_Vars |
* |
* Returns a single or all global config variables |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Deassigns a single or all global config variables |
* |
* @param object $smarty |
* @param string $varname variable name or null |
*/ |
function clear_config($smarty, $varname = null) |
{ |
if (isset($varname)) { |
unset($smarty->config_vars[$varname]); |
return; |
} else { |
$smarty->config_vars = array(); |
return; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.unregister_object.php |
---|
Новый файл |
0,0 → 1,28 |
<?php |
/** |
* Smarty method Unregister_Object |
* |
* Unregister a PHP object |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* |
* Unregister a PHP object |
*/ |
/** |
* Unregisters object |
* |
* @param string $object name of template object |
*/ |
function unregister_object($smarty, $object) |
{ |
unset($smarty->registered_objects[$object]); |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.configfileparser.php |
---|
Новый файл |
0,0 → 1,1162 |
<?php |
/** |
* Smarty Internal Plugin Templateparser |
* |
* This is the template parser. |
* It is generated from the internal.templateparser.y file |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* This can be used to store both the string representation of |
* a token, and any useful meta-data associated with the token. |
* |
* meta-data should be stored as an array |
*/ |
class TPC_yyToken implements ArrayAccess |
{ |
public $string = ''; |
public $metadata = array(); |
function __construct($s, $m = array()) |
{ |
if ($s instanceof TPC_yyToken) { |
$this->string = $s->string; |
$this->metadata = $s->metadata; |
} else { |
$this->string = (string) $s; |
if ($m instanceof TPC_yyToken) { |
$this->metadata = $m->metadata; |
} elseif (is_array($m)) { |
$this->metadata = $m; |
} |
} |
} |
function __toString() |
{ |
return $this->_string; |
} |
function offsetExists($offset) |
{ |
return isset($this->metadata[$offset]); |
} |
function offsetGet($offset) |
{ |
return $this->metadata[$offset]; |
} |
function offsetSet($offset, $value) |
{ |
if ($offset === null) { |
if (isset($value[0])) { |
$x = ($value instanceof TPC_yyToken) ? |
$value->metadata : $value; |
$this->metadata = array_merge($this->metadata, $x); |
return; |
} |
$offset = count($this->metadata); |
} |
if ($value === null) { |
return; |
} |
if ($value instanceof TPC_yyToken) { |
if ($value->metadata) { |
$this->metadata[$offset] = $value->metadata; |
} |
} elseif ($value) { |
$this->metadata[$offset] = $value; |
} |
} |
function offsetUnset($offset) |
{ |
unset($this->metadata[$offset]); |
} |
} |
/** The following structure represents a single element of the |
* parser's stack. Information stored includes: |
* |
* + The state number for the parser at this level of the stack. |
* |
* + The value of the token stored at this level of the stack. |
* (In other words, the "major" token.) |
* |
* + The semantic value stored at this level of the stack. This is |
* the information used by the action routines in the grammar. |
* It is sometimes called the "minor" token. |
*/ |
class TPC_yyStackEntry |
{ |
public $stateno; /* The state-number */ |
public $major; /* The major token value. This is the code |
** number for the token at this stack level */ |
public $minor; /* The user-supplied minor token value. This |
** is the value of the token */ |
}; |
// code external to the class is included here |
// declare_class is output here |
#line 12 "internal.configfileparser.y" |
class Smarty_Internal_Configfileparser#line 109 "internal.configfileparser.php" |
{ |
/* First off, code is included which follows the "include_class" declaration |
** in the input file. */ |
#line 14 "internal.configfileparser.y" |
// states whether the parse was successful or not |
public $successful = true; |
public $retvalue = 0; |
private $lex; |
private $internalError = false; |
function __construct($lex, $compiler) { |
// set instance object |
self::instance($this); |
$this->lex = $lex; |
$this->smarty = $compiler->smarty; |
$this->compiler = $compiler; |
$this->current_section = null; |
$this->hidden_section = false; |
} |
public static function &instance($new_instance = null) |
{ |
static $instance = null; |
if (isset($new_instance) && is_object($new_instance)) |
$instance = $new_instance; |
return $instance; |
} |
#line 139 "internal.configfileparser.php" |
/* Next is all token values, as class constants |
*/ |
/* |
** These constants (all generated automatically by the parser generator) |
** specify the various kinds of tokens (terminals) that the parser |
** understands. |
** |
** Each symbol here is a terminal symbol in the grammar. |
*/ |
const TPC_OTHER = 1; |
const TPC_COMMENTSTART = 2; |
const TPC_NUMBER = 3; |
const TPC_OPENB = 4; |
const TPC_CLOSEB = 5; |
const TPC_DOT = 6; |
const TPC_BOOLEANTRUE = 7; |
const TPC_BOOLEANFALSE = 8; |
const TPC_SI_QSTR = 9; |
const TPC_DO_QSTR = 10; |
const TPC_EQUAL = 11; |
const TPC_SPACE = 12; |
const TPC_ID = 13; |
const TPC_EOL = 14; |
const TPC_ML_QSTR = 15; |
const YY_NO_ACTION = 46; |
const YY_ACCEPT_ACTION = 45; |
const YY_ERROR_ACTION = 44; |
/* Next are that tables used to determine what action to take based on the |
** current state and lookahead token. These tables are used to implement |
** functions that take a state number and lookahead value and return an |
** action integer. |
** |
** Suppose the action integer is N. Then the action is determined as |
** follows |
** |
** 0 <= N < self::YYNSTATE Shift N. That is, |
** push the lookahead |
** token onto the stack |
** and goto state N. |
** |
** self::YYNSTATE <= N < self::YYNSTATE+self::YYNRULE Reduce by rule N-YYNSTATE. |
** |
** N == self::YYNSTATE+self::YYNRULE A syntax error has occurred. |
** |
** N == self::YYNSTATE+self::YYNRULE+1 The parser accepts its |
** input. (and concludes parsing) |
** |
** N == self::YYNSTATE+self::YYNRULE+2 No such action. Denotes unused |
** slots in the yy_action[] table. |
** |
** The action table is constructed as a single large static array $yy_action. |
** Given state S and lookahead X, the action is computed as |
** |
** self::$yy_action[self::$yy_shift_ofst[S] + X ] |
** |
** If the index value self::$yy_shift_ofst[S]+X is out of range or if the value |
** self::$yy_lookahead[self::$yy_shift_ofst[S]+X] is not equal to X or if |
** self::$yy_shift_ofst[S] is equal to self::YY_SHIFT_USE_DFLT, it means that |
** the action is not in the table and that self::$yy_default[S] should be used instead. |
** |
** The formula above is for computing the action when the lookahead is |
** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
** a reduce action) then the static $yy_reduce_ofst array is used in place of |
** the static $yy_shift_ofst array and self::YY_REDUCE_USE_DFLT is used in place of |
** self::YY_SHIFT_USE_DFLT. |
** |
** The following are the tables generated in this section: |
** |
** self::$yy_action A single table containing all actions. |
** self::$yy_lookahead A table containing the lookahead for each entry in |
** yy_action. Used to detect hash collisions. |
** self::$yy_shift_ofst For each state, the offset into self::$yy_action for |
** shifting terminals. |
** self::$yy_reduce_ofst For each state, the offset into self::$yy_action for |
** shifting non-terminals after a reduce. |
** self::$yy_default Default action for each state. |
*/ |
const YY_SZ_ACTTAB = 32; |
static public $yy_action = array( |
/* 0 */ 26, 20, 15, 4, 14, 2, 11, 6, 25, 27, |
/* 10 */ 8, 5, 14, 10, 18, 26, 9, 16, 45, 3, |
/* 20 */ 19, 7, 12, 13, 21, 23, 1, 26, 17, 24, |
/* 30 */ 41, 22, |
); |
static public $yy_lookahead = array( |
/* 0 */ 1, 14, 3, 21, 22, 2, 6, 4, 9, 10, |
/* 10 */ 20, 21, 22, 13, 15, 1, 13, 14, 17, 18, |
/* 20 */ 19, 5, 13, 5, 14, 14, 11, 1, 14, 22, |
/* 30 */ 23, 19, |
); |
const YY_SHIFT_USE_DFLT = -14; |
const YY_SHIFT_MAX = 13; |
static public $yy_shift_ofst = array( |
/* 0 */ 3, -1, 26, 3, 14, 26, 0, 10, -13, 15, |
/* 10 */ 16, 9, 18, 11, |
); |
const YY_REDUCE_USE_DFLT = -19; |
const YY_REDUCE_MAX = 5; |
static public $yy_reduce_ofst = array( |
/* 0 */ 1, -10, -18, 12, 7, 7, |
); |
static public $yyExpectedTokens = array( |
/* 0 */ array(2, 4, 13, 14, ), |
/* 1 */ array(1, 3, 9, 10, 15, ), |
/* 2 */ array(1, ), |
/* 3 */ array(2, 4, 13, 14, ), |
/* 4 */ array(1, 14, ), |
/* 5 */ array(1, ), |
/* 6 */ array(6, 13, ), |
/* 7 */ array(14, ), |
/* 8 */ array(14, ), |
/* 9 */ array(11, ), |
/* 10 */ array(5, ), |
/* 11 */ array(13, ), |
/* 12 */ array(5, ), |
/* 13 */ array(14, ), |
/* 14 */ array(), |
/* 15 */ array(), |
/* 16 */ array(), |
/* 17 */ array(), |
/* 18 */ array(), |
/* 19 */ array(), |
/* 20 */ array(), |
/* 21 */ array(), |
/* 22 */ array(), |
/* 23 */ array(), |
/* 24 */ array(), |
/* 25 */ array(), |
/* 26 */ array(), |
/* 27 */ array(), |
); |
static public $yy_default = array( |
/* 0 */ 44, 44, 44, 28, 44, 36, 44, 44, 44, 44, |
/* 10 */ 44, 44, 44, 44, 42, 40, 34, 35, 39, 29, |
/* 20 */ 33, 31, 30, 32, 41, 37, 43, 38, |
); |
/* The next thing included is series of defines which control |
** various aspects of the generated parser. |
** self::YYNOCODE is a number which corresponds |
** to no legal terminal or nonterminal number. This |
** number is used to fill in empty slots of the hash |
** table. |
** self::YYFALLBACK If defined, this indicates that one or more tokens |
** have fall-back values which should be used if the |
** original value of the token will not parse. |
** self::YYSTACKDEPTH is the maximum depth of the parser's stack. |
** self::YYNSTATE the combined number of states. |
** self::YYNRULE the number of rules in the grammar |
** self::YYERRORSYMBOL is the code number of the error symbol. If not |
** defined, then do no error processing. |
*/ |
const YYNOCODE = 24; |
const YYSTACKDEPTH = 100; |
const YYNSTATE = 28; |
const YYNRULE = 16; |
const YYERRORSYMBOL = 16; |
const YYERRSYMDT = 'yy0'; |
const YYFALLBACK = 1; |
/** The next table maps tokens into fallback tokens. If a construct |
* like the following: |
* |
* %fallback ID X Y Z. |
* |
* appears in the grammer, then ID becomes a fallback token for X, Y, |
* and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
* but it does not parse, the type of the token is changed to ID and |
* the parse is retried before an error is thrown. |
*/ |
static public $yyFallback = array( |
0, /* $ => nothing */ |
0, /* OTHER => nothing */ |
1, /* COMMENTSTART => OTHER */ |
1, /* NUMBER => OTHER */ |
1, /* OPENB => OTHER */ |
1, /* CLOSEB => OTHER */ |
1, /* DOT => OTHER */ |
1, /* BOOLEANTRUE => OTHER */ |
1, /* BOOLEANFALSE => OTHER */ |
1, /* SI_QSTR => OTHER */ |
1, /* DO_QSTR => OTHER */ |
1, /* EQUAL => OTHER */ |
1, /* SPACE => OTHER */ |
1, /* ID => OTHER */ |
0, /* EOL => nothing */ |
0, /* ML_QSTR => nothing */ |
); |
/** |
* Turn parser tracing on by giving a stream to which to write the trace |
* and a prompt to preface each trace message. Tracing is turned off |
* by making either argument NULL |
* |
* Inputs: |
* |
* - A stream resource to which trace output should be written. |
* If NULL, then tracing is turned off. |
* - A prefix string written at the beginning of every |
* line of trace output. If NULL, then tracing is |
* turned off. |
* |
* Outputs: |
* |
* - None. |
* @param resource |
* @param string |
*/ |
static function Trace($TraceFILE, $zTracePrompt) |
{ |
if (!$TraceFILE) { |
$zTracePrompt = 0; |
} elseif (!$zTracePrompt) { |
$TraceFILE = 0; |
} |
self::$yyTraceFILE = $TraceFILE; |
self::$yyTracePrompt = $zTracePrompt; |
} |
/** |
* Output debug information to output (php://output stream) |
*/ |
static function PrintTrace() |
{ |
self::$yyTraceFILE = fopen('php://output', 'w'); |
self::$yyTracePrompt = '<br>'; |
} |
/** |
* @var resource|0 |
*/ |
static public $yyTraceFILE; |
/** |
* String to prepend to debug output |
* @var string|0 |
*/ |
static public $yyTracePrompt; |
/** |
* @var int |
*/ |
public $yyidx; /* Index of top element in stack */ |
/** |
* @var int |
*/ |
public $yyerrcnt; /* Shifts left before out of the error */ |
/** |
* @var array |
*/ |
public $yystack = array(); /* The parser's stack */ |
/** |
* For tracing shifts, the names of all terminals and nonterminals |
* are required. The following table supplies these names |
* @var array |
*/ |
public $yyTokenName = array( |
'$', 'OTHER', 'COMMENTSTART', 'NUMBER', |
'OPENB', 'CLOSEB', 'DOT', 'BOOLEANTRUE', |
'BOOLEANFALSE', 'SI_QSTR', 'DO_QSTR', 'EQUAL', |
'SPACE', 'ID', 'EOL', 'ML_QSTR', |
'error', 'start', 'config', 'config_element', |
'value', 'text', 'textelement', |
); |
/** |
* For tracing reduce actions, the names of all rules are required. |
* @var array |
*/ |
static public $yyRuleName = array( |
/* 0 */ "start ::= config", |
/* 1 */ "config ::= config_element", |
/* 2 */ "config ::= config config_element", |
/* 3 */ "config_element ::= OPENB ID CLOSEB EOL", |
/* 4 */ "config_element ::= OPENB DOT ID CLOSEB EOL", |
/* 5 */ "config_element ::= ID EQUAL value EOL", |
/* 6 */ "config_element ::= EOL", |
/* 7 */ "config_element ::= COMMENTSTART text EOL", |
/* 8 */ "value ::= text", |
/* 9 */ "value ::= SI_QSTR", |
/* 10 */ "value ::= DO_QSTR", |
/* 11 */ "value ::= ML_QSTR", |
/* 12 */ "value ::= NUMBER", |
/* 13 */ "text ::= text textelement", |
/* 14 */ "text ::= textelement", |
/* 15 */ "textelement ::= OTHER", |
); |
/** |
* This function returns the symbolic name associated with a token |
* value. |
* @param int |
* @return string |
*/ |
function tokenName($tokenType) |
{ |
if ($tokenType === 0) { |
return 'End of Input'; |
} |
if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { |
return $this->yyTokenName[$tokenType]; |
} else { |
return "Unknown"; |
} |
} |
/** |
* The following function deletes the value associated with a |
* symbol. The symbol can be either a terminal or nonterminal. |
* @param int the symbol code |
* @param mixed the symbol's value |
*/ |
static function yy_destructor($yymajor, $yypminor) |
{ |
switch ($yymajor) { |
/* Here is inserted the actions which take place when a |
** terminal or non-terminal is destroyed. This can happen |
** when the symbol is popped from the stack during a |
** reduce or during error processing or when a parser is |
** being destroyed before it is finished parsing. |
** |
** Note: during a reduce, the only symbols destroyed are those |
** which appear on the RHS of the rule, but which are not used |
** inside the C code. |
*/ |
default: break; /* If no destructor action specified: do nothing */ |
} |
} |
/** |
* Pop the parser's stack once. |
* |
* If there is a destructor routine associated with the token which |
* is popped from the stack, then call it. |
* |
* Return the major token number for the symbol popped. |
* @param TPC_yyParser |
* @return int |
*/ |
function yy_pop_parser_stack() |
{ |
if (!count($this->yystack)) { |
return; |
} |
$yytos = array_pop($this->yystack); |
if (self::$yyTraceFILE && $this->yyidx >= 0) { |
fwrite(self::$yyTraceFILE, |
self::$yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . |
"\n"); |
} |
$yymajor = $yytos->major; |
self::yy_destructor($yymajor, $yytos->minor); |
$this->yyidx--; |
return $yymajor; |
} |
/** |
* Deallocate and destroy a parser. Destructors are all called for |
* all stack elements before shutting the parser down. |
*/ |
function __destruct() |
{ |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
if (is_resource(self::$yyTraceFILE)) { |
fclose(self::$yyTraceFILE); |
} |
} |
/** |
* Based on the current state and parser stack, get a list of all |
* possible lookahead tokens |
* @param int |
* @return array |
*/ |
function yy_get_expected_tokens($token) |
{ |
$state = $this->yystack[$this->yyidx]->stateno; |
$expected = self::$yyExpectedTokens[$state]; |
if (in_array($token, self::$yyExpectedTokens[$state], true)) { |
return $expected; |
} |
$stack = $this->yystack; |
$yyidx = $this->yyidx; |
do { |
$yyact = $this->yy_find_shift_action($token); |
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
// reduce action |
$done = 0; |
do { |
if ($done++ == 100) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// too much recursion prevents proper detection |
// so give up |
return array_unique($expected); |
} |
$yyruleno = $yyact - self::YYNSTATE; |
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs']; |
$nextstate = $this->yy_find_reduce_action( |
$this->yystack[$this->yyidx]->stateno, |
self::$yyRuleInfo[$yyruleno]['lhs']); |
if (isset(self::$yyExpectedTokens[$nextstate])) { |
$expected += self::$yyExpectedTokens[$nextstate]; |
if (in_array($token, |
self::$yyExpectedTokens[$nextstate], true)) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return array_unique($expected); |
} |
} |
if ($nextstate < self::YYNSTATE) { |
// we need to shift a non-terminal |
$this->yyidx++; |
$x = new TPC_yyStackEntry; |
$x->stateno = $nextstate; |
$x->major = self::$yyRuleInfo[$yyruleno]['lhs']; |
$this->yystack[$this->yyidx] = $x; |
continue 2; |
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// the last token was just ignored, we can't accept |
// by ignoring input, this is in essence ignoring a |
// syntax error! |
return array_unique($expected); |
} elseif ($nextstate === self::YY_NO_ACTION) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// input accepted, but not shifted (I guess) |
return $expected; |
} else { |
$yyact = $nextstate; |
} |
} while (true); |
} |
break; |
} while (true); |
return array_unique($expected); |
} |
/** |
* Based on the parser state and current parser stack, determine whether |
* the lookahead token is possible. |
* |
* The parser will convert the token value to an error token if not. This |
* catches some unusual edge cases where the parser would fail. |
* @param int |
* @return bool |
*/ |
function yy_is_expected_token($token) |
{ |
if ($token === 0) { |
return true; // 0 is not part of this |
} |
$state = $this->yystack[$this->yyidx]->stateno; |
if (in_array($token, self::$yyExpectedTokens[$state], true)) { |
return true; |
} |
$stack = $this->yystack; |
$yyidx = $this->yyidx; |
do { |
$yyact = $this->yy_find_shift_action($token); |
if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { |
// reduce action |
$done = 0; |
do { |
if ($done++ == 100) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// too much recursion prevents proper detection |
// so give up |
return true; |
} |
$yyruleno = $yyact - self::YYNSTATE; |
$this->yyidx -= self::$yyRuleInfo[$yyruleno]['rhs']; |
$nextstate = $this->yy_find_reduce_action( |
$this->yystack[$this->yyidx]->stateno, |
self::$yyRuleInfo[$yyruleno]['lhs']); |
if (isset(self::$yyExpectedTokens[$nextstate]) && |
in_array($token, self::$yyExpectedTokens[$nextstate], true)) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return true; |
} |
if ($nextstate < self::YYNSTATE) { |
// we need to shift a non-terminal |
$this->yyidx++; |
$x = new TPC_yyStackEntry; |
$x->stateno = $nextstate; |
$x->major = self::$yyRuleInfo[$yyruleno]['lhs']; |
$this->yystack[$this->yyidx] = $x; |
continue 2; |
} elseif ($nextstate == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
if (!$token) { |
// end of input: this is valid |
return true; |
} |
// the last token was just ignored, we can't accept |
// by ignoring input, this is in essence ignoring a |
// syntax error! |
return false; |
} elseif ($nextstate === self::YY_NO_ACTION) { |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
// input accepted, but not shifted (I guess) |
return true; |
} else { |
$yyact = $nextstate; |
} |
} while (true); |
} |
break; |
} while (true); |
$this->yyidx = $yyidx; |
$this->yystack = $stack; |
return true; |
} |
/** |
* Find the appropriate action for a parser given the terminal |
* look-ahead token iLookAhead. |
* |
* If the look-ahead token is YYNOCODE, then check to see if the action is |
* independent of the look-ahead. If it is, return the action, otherwise |
* return YY_NO_ACTION. |
* @param int The look-ahead token |
*/ |
function yy_find_shift_action($iLookAhead) |
{ |
$stateno = $this->yystack[$this->yyidx]->stateno; |
/* if ($this->yyidx < 0) return self::YY_NO_ACTION; */ |
if (!isset(self::$yy_shift_ofst[$stateno])) { |
// no shift actions |
return self::$yy_default[$stateno]; |
} |
$i = self::$yy_shift_ofst[$stateno]; |
if ($i === self::YY_SHIFT_USE_DFLT) { |
return self::$yy_default[$stateno]; |
} |
if ($iLookAhead == self::YYNOCODE) { |
return self::YY_NO_ACTION; |
} |
$i += $iLookAhead; |
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
self::$yy_lookahead[$i] != $iLookAhead) { |
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) |
&& ($iFallback = self::$yyFallback[$iLookAhead]) != 0) { |
if (self::$yyTraceFILE) { |
fwrite(self::$yyTraceFILE, self::$yyTracePrompt . "FALLBACK " . |
$this->yyTokenName[$iLookAhead] . " => " . |
$this->yyTokenName[$iFallback] . "\n"); |
} |
return $this->yy_find_shift_action($iFallback); |
} |
return self::$yy_default[$stateno]; |
} else { |
return self::$yy_action[$i]; |
} |
} |
/** |
* Find the appropriate action for a parser given the non-terminal |
* look-ahead token $iLookAhead. |
* |
* If the look-ahead token is self::YYNOCODE, then check to see if the action is |
* independent of the look-ahead. If it is, return the action, otherwise |
* return self::YY_NO_ACTION. |
* @param int Current state number |
* @param int The look-ahead token |
*/ |
function yy_find_reduce_action($stateno, $iLookAhead) |
{ |
/* $stateno = $this->yystack[$this->yyidx]->stateno; */ |
if (!isset(self::$yy_reduce_ofst[$stateno])) { |
return self::$yy_default[$stateno]; |
} |
$i = self::$yy_reduce_ofst[$stateno]; |
if ($i == self::YY_REDUCE_USE_DFLT) { |
return self::$yy_default[$stateno]; |
} |
if ($iLookAhead == self::YYNOCODE) { |
return self::YY_NO_ACTION; |
} |
$i += $iLookAhead; |
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || |
self::$yy_lookahead[$i] != $iLookAhead) { |
return self::$yy_default[$stateno]; |
} else { |
return self::$yy_action[$i]; |
} |
} |
/** |
* Perform a shift action. |
* @param int The new state to shift in |
* @param int The major token to shift in |
* @param mixed the minor token to shift in |
*/ |
function yy_shift($yyNewState, $yyMajor, $yypMinor) |
{ |
$this->yyidx++; |
if ($this->yyidx >= self::YYSTACKDEPTH) { |
$this->yyidx--; |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sStack Overflow!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will execute if the parser |
** stack ever overflows */ |
return; |
} |
$yytos = new TPC_yyStackEntry; |
$yytos->stateno = $yyNewState; |
$yytos->major = $yyMajor; |
$yytos->minor = $yypMinor; |
array_push($this->yystack, $yytos); |
if (self::$yyTraceFILE && $this->yyidx > 0) { |
fprintf(self::$yyTraceFILE, "%sShift %d\n", self::$yyTracePrompt, |
$yyNewState); |
fprintf(self::$yyTraceFILE, "%sStack:", self::$yyTracePrompt); |
for($i = 1; $i <= $this->yyidx; $i++) { |
fprintf(self::$yyTraceFILE, " %s", |
$this->yyTokenName[$this->yystack[$i]->major]); |
} |
fwrite(self::$yyTraceFILE,"\n"); |
} |
} |
/** |
* The following table contains information about every rule that |
* is used during the reduce. |
* |
* <pre> |
* array( |
* array( |
* int $lhs; Symbol on the left-hand side of the rule |
* int $nrhs; Number of right-hand side symbols in the rule |
* ),... |
* ); |
* </pre> |
*/ |
static public $yyRuleInfo = array( |
array( 'lhs' => 17, 'rhs' => 1 ), |
array( 'lhs' => 18, 'rhs' => 1 ), |
array( 'lhs' => 18, 'rhs' => 2 ), |
array( 'lhs' => 19, 'rhs' => 4 ), |
array( 'lhs' => 19, 'rhs' => 5 ), |
array( 'lhs' => 19, 'rhs' => 4 ), |
array( 'lhs' => 19, 'rhs' => 1 ), |
array( 'lhs' => 19, 'rhs' => 3 ), |
array( 'lhs' => 20, 'rhs' => 1 ), |
array( 'lhs' => 20, 'rhs' => 1 ), |
array( 'lhs' => 20, 'rhs' => 1 ), |
array( 'lhs' => 20, 'rhs' => 1 ), |
array( 'lhs' => 20, 'rhs' => 1 ), |
array( 'lhs' => 21, 'rhs' => 2 ), |
array( 'lhs' => 21, 'rhs' => 1 ), |
array( 'lhs' => 22, 'rhs' => 1 ), |
); |
/** |
* The following table contains a mapping of reduce action to method name |
* that handles the reduction. |
* |
* If a rule is not set, it has no handler. |
*/ |
static public $yyReduceMap = array( |
0 => 0, |
1 => 1, |
8 => 1, |
14 => 1, |
15 => 1, |
2 => 2, |
13 => 2, |
3 => 3, |
4 => 4, |
5 => 5, |
6 => 6, |
7 => 6, |
9 => 9, |
10 => 10, |
11 => 10, |
12 => 12, |
); |
/* Beginning here are the reduction cases. A typical example |
** follows: |
** #line <lineno> <grammarfile> |
** function yy_r0($yymsp){ ... } // User supplied code |
** #line <lineno> <thisfile> |
*/ |
#line 67 "internal.configfileparser.y" |
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 840 "internal.configfileparser.php" |
#line 73 "internal.configfileparser.y" |
function yy_r1(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } |
#line 843 "internal.configfileparser.php" |
#line 75 "internal.configfileparser.y" |
function yy_r2(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } |
#line 846 "internal.configfileparser.php" |
#line 81 "internal.configfileparser.y" |
function yy_r3(){ $this->hidden_section = false; $this->current_section = $this->yystack[$this->yyidx + -2]->minor; $this->_retvalue =''; } |
#line 849 "internal.configfileparser.php" |
#line 83 "internal.configfileparser.y" |
function yy_r4(){ if ($this->smarty->config_read_hidden) { |
$this->hidden_section = false; $this->current_section = $this->yystack[$this->yyidx + -2]->minor; |
} else {$this->hidden_section = true; } $this->_retvalue =''; } |
#line 854 "internal.configfileparser.php" |
#line 87 "internal.configfileparser.y" |
function yy_r5(){if (!$this->hidden_section) { |
$value=$this->yystack[$this->yyidx + -1]->minor; |
if ($this->smarty->config_booleanize) { |
if (in_array(strtolower($value),array('on','yes','true'))) |
$value = true; |
else if (in_array(strtolower($value),array('off','no','false'))) |
$value = false; |
} |
if ($this->current_section == null) { |
if ($this->smarty->config_overwrite) { |
$this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value; |
} else { |
settype($this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array'); |
$this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value; |
} |
} else { |
if ($this->smarty->config_overwrite) { |
$this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value; |
} else { |
settype($this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array'); |
$this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value; |
} |
}} $this->_retvalue =''; } |
#line 879 "internal.configfileparser.php" |
#line 111 "internal.configfileparser.y" |
function yy_r6(){ $this->_retvalue =''; } |
#line 882 "internal.configfileparser.php" |
#line 115 "internal.configfileparser.y" |
function yy_r9(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,"'"); } |
#line 885 "internal.configfileparser.php" |
#line 116 "internal.configfileparser.y" |
function yy_r10(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,'"'); } |
#line 888 "internal.configfileparser.php" |
#line 118 "internal.configfileparser.y" |
function yy_r12(){$this->_retvalue = (int)$this->yystack[$this->yyidx + 0]->minor; } |
#line 891 "internal.configfileparser.php" |
/** |
* placeholder for the left hand side in a reduce operation. |
* |
* For a parser with a rule like this: |
* <pre> |
* rule(A) ::= B. { A = 1; } |
* </pre> |
* |
* The parser will translate to something like: |
* |
* <code> |
* function yy_r0(){$this->_retvalue = 1;} |
* </code> |
*/ |
private $_retvalue; |
/** |
* Perform a reduce action and the shift that must immediately |
* follow the reduce. |
* |
* For a rule such as: |
* |
* <pre> |
* A ::= B blah C. { dosomething(); } |
* </pre> |
* |
* This function will first call the action, if any, ("dosomething();" in our |
* example), and then it will pop three states from the stack, |
* one for each entry on the right-hand side of the expression |
* (B, blah, and C in our example rule), and then push the result of the action |
* back on to the stack with the resulting state reduced to (as described in the .out |
* file) |
* @param int Number of the rule by which to reduce |
*/ |
function yy_reduce($yyruleno) |
{ |
//int $yygoto; /* The next state */ |
//int $yyact; /* The next action */ |
//mixed $yygotominor; /* The LHS of the rule reduced */ |
//TPC_yyStackEntry $yymsp; /* The top of the parser's stack */ |
//int $yysize; /* Amount to pop the stack */ |
$yymsp = $this->yystack[$this->yyidx]; |
if (self::$yyTraceFILE && $yyruleno >= 0 |
&& $yyruleno < count(self::$yyRuleName)) { |
fprintf(self::$yyTraceFILE, "%sReduce (%d) [%s].\n", |
self::$yyTracePrompt, $yyruleno, |
self::$yyRuleName[$yyruleno]); |
} |
$this->_retvalue = $yy_lefthand_side = null; |
if (array_key_exists($yyruleno, self::$yyReduceMap)) { |
// call the action |
$this->_retvalue = null; |
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}(); |
$yy_lefthand_side = $this->_retvalue; |
} |
$yygoto = self::$yyRuleInfo[$yyruleno]['lhs']; |
$yysize = self::$yyRuleInfo[$yyruleno]['rhs']; |
$this->yyidx -= $yysize; |
for($i = $yysize; $i; $i--) { |
// pop all of the right-hand side parameters |
array_pop($this->yystack); |
} |
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto); |
if ($yyact < self::YYNSTATE) { |
/* If we are not debugging and the reduce action popped at least |
** one element off the stack, then we can push the new element back |
** onto the stack here, and skip the stack overflow test in yy_shift(). |
** That gives a significant speed improvement. */ |
if (!self::$yyTraceFILE && $yysize) { |
$this->yyidx++; |
$x = new TPC_yyStackEntry; |
$x->stateno = $yyact; |
$x->major = $yygoto; |
$x->minor = $yy_lefthand_side; |
$this->yystack[$this->yyidx] = $x; |
} else { |
$this->yy_shift($yyact, $yygoto, $yy_lefthand_side); |
} |
} elseif ($yyact == self::YYNSTATE + self::YYNRULE + 1) { |
$this->yy_accept(); |
} |
} |
/** |
* The following code executes when the parse fails |
* |
* Code from %parse_fail is inserted here |
*/ |
function yy_parse_failed() |
{ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will be executed whenever the |
** parser fails */ |
} |
/** |
* The following code executes when a syntax error first occurs. |
* |
* %syntax_error code is inserted here |
* @param int The major type of the error token |
* @param mixed The minor type of the error token |
*/ |
function yy_syntax_error($yymajor, $TOKEN) |
{ |
#line 52 "internal.configfileparser.y" |
$this->internalError = true; |
$this->yymajor = $yymajor; |
$this->compiler->trigger_config_file_error(); |
#line 1009 "internal.configfileparser.php" |
} |
/** |
* The following is executed when the parser accepts |
* |
* %parse_accept code is inserted here |
*/ |
function yy_accept() |
{ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sAccept!\n", self::$yyTracePrompt); |
} |
while ($this->yyidx >= 0) { |
$stack = $this->yy_pop_parser_stack(); |
} |
/* Here code is inserted which will be executed whenever the |
** parser accepts */ |
#line 44 "internal.configfileparser.y" |
$this->successful = !$this->internalError; |
$this->internalError = false; |
$this->retvalue = $this->_retvalue; |
//echo $this->retvalue."\n\n"; |
#line 1034 "internal.configfileparser.php" |
} |
/** |
* The main parser program. |
* |
* The first argument is the major token number. The second is |
* the token value string as scanned from the input. |
* |
* @param int the token number |
* @param mixed the token value |
* @param mixed any extra arguments that should be passed to handlers |
*/ |
function doParse($yymajor, $yytokenvalue) |
{ |
// $yyact; /* The parser action. */ |
// $yyendofinput; /* True if we are at the end of input */ |
$yyerrorhit = 0; /* True if yymajor has invoked an error */ |
/* (re)initialize the parser, if necessary */ |
if ($this->yyidx === null || $this->yyidx < 0) { |
/* if ($yymajor == 0) return; // not sure why this was here... */ |
$this->yyidx = 0; |
$this->yyerrcnt = -1; |
$x = new TPC_yyStackEntry; |
$x->stateno = 0; |
$x->major = 0; |
$this->yystack = array(); |
array_push($this->yystack, $x); |
} |
$yyendofinput = ($yymajor==0); |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sInput %s\n", |
self::$yyTracePrompt, $this->yyTokenName[$yymajor]); |
} |
do { |
$yyact = $this->yy_find_shift_action($yymajor); |
if ($yymajor < self::YYERRORSYMBOL && |
!$this->yy_is_expected_token($yymajor)) { |
// force a syntax error |
$yyact = self::YY_ERROR_ACTION; |
} |
if ($yyact < self::YYNSTATE) { |
$this->yy_shift($yyact, $yymajor, $yytokenvalue); |
$this->yyerrcnt--; |
if ($yyendofinput && $this->yyidx >= 0) { |
$yymajor = 0; |
} else { |
$yymajor = self::YYNOCODE; |
} |
} elseif ($yyact < self::YYNSTATE + self::YYNRULE) { |
$this->yy_reduce($yyact - self::YYNSTATE); |
} elseif ($yyact == self::YY_ERROR_ACTION) { |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sSyntax Error!\n", |
self::$yyTracePrompt); |
} |
if (self::YYERRORSYMBOL) { |
/* A syntax error has occurred. |
** The response to an error depends upon whether or not the |
** grammar defines an error token "ERROR". |
** |
** This is what we do if the grammar does define ERROR: |
** |
** * Call the %syntax_error function. |
** |
** * Begin popping the stack until we enter a state where |
** it is legal to shift the error symbol, then shift |
** the error symbol. |
** |
** * Set the error count to three. |
** |
** * Begin accepting and shifting new tokens. No new error |
** processing will occur until three tokens have been |
** shifted successfully. |
** |
*/ |
if ($this->yyerrcnt < 0) { |
$this->yy_syntax_error($yymajor, $yytokenvalue); |
} |
$yymx = $this->yystack[$this->yyidx]->major; |
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit ){ |
if (self::$yyTraceFILE) { |
fprintf(self::$yyTraceFILE, "%sDiscard input token %s\n", |
self::$yyTracePrompt, $this->yyTokenName[$yymajor]); |
} |
$this->yy_destructor($yymajor, $yytokenvalue); |
$yymajor = self::YYNOCODE; |
} else { |
while ($this->yyidx >= 0 && |
$yymx != self::YYERRORSYMBOL && |
($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE |
){ |
$this->yy_pop_parser_stack(); |
} |
if ($this->yyidx < 0 || $yymajor==0) { |
$this->yy_destructor($yymajor, $yytokenvalue); |
$this->yy_parse_failed(); |
$yymajor = self::YYNOCODE; |
} elseif ($yymx != self::YYERRORSYMBOL) { |
$u2 = 0; |
$this->yy_shift($yyact, self::YYERRORSYMBOL, $u2); |
} |
} |
$this->yyerrcnt = 3; |
$yyerrorhit = 1; |
} else { |
/* YYERRORSYMBOL is not defined */ |
/* This is what we do if the grammar does not define ERROR: |
** |
** * Report an error message, and throw away the input token. |
** |
** * If the input token is $, then fail the parse. |
** |
** As before, subsequent error messages are suppressed until |
** three input tokens have been successfully shifted. |
*/ |
if ($this->yyerrcnt <= 0) { |
$this->yy_syntax_error($yymajor, $yytokenvalue); |
} |
$this->yyerrcnt = 3; |
$this->yy_destructor($yymajor, $yytokenvalue); |
if ($yyendofinput) { |
$this->yy_parse_failed(); |
} |
$yymajor = self::YYNOCODE; |
} |
} else { |
$this->yy_accept(); |
$yymajor = self::YYNOCODE; |
} |
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0); |
} |
} |
/branches/ant-ng/lib/sysplugins/method.test.php |
---|
Новый файл |
0,0 → 1,77 |
<?php |
/** |
* Smarty plugin |
* |
* @ignore |
* @package Smarty |
* @subpackage plugins |
*/ |
function test($smarty) |
{ |
echo "<PRE>\n"; |
echo "Smarty Installation test...\n"; |
echo "Testing template directory...\n"; |
foreach((array)$smarty->template_dir as $template_dir) { |
if (!is_dir($template_dir)) |
echo "FAILED: $template_dir is not a directory.\n"; |
elseif (!is_readable($template_dir)) |
echo "FAILED: $template_dir is not readable.\n"; |
else |
echo "$template_dir is OK.\n"; |
} |
echo "Testing compile directory...\n"; |
if (!is_dir($smarty->compile_dir)) |
echo "FAILED: $smarty->compile_dir is not a directory.\n"; |
elseif (!is_readable($smarty->compile_dir)) |
echo "FAILED: $smarty->compile_dir is not readable.\n"; |
elseif (!is_writable($smarty->compile_dir)) |
echo "FAILED: $smarty->compile_dir is not writable.\n"; |
else |
echo "{$smarty->compile_dir} is OK.\n"; |
echo "Testing plugins directory...\n"; |
foreach((array)$smarty->plugins_dir as $plugin_dir) { |
if (!is_dir($plugin_dir)) |
echo "FAILED: $plugin_dir is not a directory.\n"; |
elseif (!is_readable($plugin_dir)) |
echo "FAILED: $plugin_dir is not readable.\n"; |
else |
echo "$plugin_dir is OK.\n"; |
} |
echo "Testing cache directory...\n"; |
if (!is_dir($smarty->cache_dir)) |
echo "FAILED: $smarty->cache_dir is not a directory.\n"; |
elseif (!is_readable($smarty->cache_dir)) |
echo "FAILED: $smarty->cache_dir is not readable.\n"; |
elseif (!is_writable($smarty->cache_dir)) |
echo "FAILED: $smarty->cache_dir is not writable.\n"; |
else |
echo "{$smarty->cache_dir} is OK.\n"; |
echo "Testing configs directory...\n"; |
if (!is_dir($smarty->config_dir)) |
echo "FAILED: $smarty->config_dir is not a directory.\n"; |
elseif (!is_readable($smarty->config_dir)) |
echo "FAILED: $smarty->config_dir is not readable.\n"; |
else |
echo "{$smarty->config_dir} is OK.\n"; |
echo "Tests complete.\n"; |
echo "</PRE>\n"; |
return true; |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_print_expression.php |
---|
Новый файл |
0,0 → 1,57 |
<?php |
/** |
* Smarty Internal Plugin Compile Print Expression |
* |
* Compiles any tag which will output an expression or variable |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Print Expression Class |
*/ |
class Smarty_Internal_Compile_Print_Expression extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for gererting output from any expression |
* |
* @param array $args array with attributes from parser |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $compiler) |
{ |
$this->compiler = $compiler; |
$this->required_attributes = array('value'); |
$this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
if (isset($_attr['nocache'])) { |
if ($_attr['nocache'] == 'true') { |
$this->compiler->tag_nocache = true; |
} |
} |
if (!isset($_attr['filter'])) { |
$_attr['filter'] = 'null'; |
} |
if (isset($_attr['nofilter'])) { |
if ($_attr['nofilter'] == 'true') { |
$_attr['filter'] = 'false'; |
} |
} |
if (isset($_attr['assign'])) { |
// assign output to variable |
$output = '<?php $_smarty_tpl->assign(' . $_attr['assign'] . ',' . $_attr['value'] . ');?>'; |
} else { |
// display value |
$this->compiler->has_output = true; |
$output = '<?php echo $this->smarty->filter_handler->execute(\'variable\', ' . $_attr['value'] . ',' . $_attr['filter'] . ');?>'; |
} |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/internal.compile_object_function.php |
---|
Новый файл |
0,0 → 1,47 |
<?php |
/** |
* Smarty Internal Plugin Compile Object Funtion |
* |
* Compiles code for registered objects as function |
* |
* @package Smarty |
* @subpackage Compiler |
* @author Uwe Tews |
*/ |
/** |
* Smarty Internal Plugin Compile Object Function Class |
*/ |
class Smarty_Internal_Compile_Object_Function extends Smarty_Internal_CompileBase { |
/** |
* Compiles code for the execution of function plugin |
* |
* @param array $args array with attributes from parser |
* @param string $tag name of function |
* @param string $methode name of methode to call |
* @param object $compiler compiler object |
* @return string compiled code |
*/ |
public function compile($args, $tag, $methode, $compiler) |
{ |
$this->compiler = $compiler; |
// This tag does create output |
$this->compiler->has_output = true; |
$this->required_attributes = array(); |
$this->optional_attributes = array('_any'); |
// check and get attributes |
$_attr = $this->_get_attributes($args); |
// convert attributes into parameter array string |
$_paramsArray = array(); |
foreach ($_attr as $_key => $_value) { |
$_paramsArray[] = "'$_key'=>$_value"; |
} |
$_params = 'array(' . implode(",", $_paramsArray) . ')'; |
// compile code |
$output = '<?php echo $_smarty_tpl->smarty->registered_objects[\''.$tag.'\'][0]->' . $methode . '(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl);?>'; |
return $output; |
} |
} |
?> |
/branches/ant-ng/lib/sysplugins/method.getpluginsdir.php |
---|
Новый файл |
0,0 → 1,27 |
<?php |
/** |
* Smarty method getPluginsDir |
* |
* Returns directory of plugins |
* |
* @package Smarty |
* @subpackage SmartyMethod |
* @author Uwe Tews |
*/ |
/** |
* Returns directory of plugins |
*/ |
/** |
* Returns directory of plugins |
* |
* @return array plugins folder |
*/ |
function getPluginsDir($smarty) |
{ |
return $smarty->plugins_dir; |
} |
?> |