> Generic getter.
73 | *
74 | * @param string $property_name valid: content, timestamp, exists
75 | * @throws SmartyException when the given property name is not valid
76 | */
77 | public function __get($property_name)
78 | {
79 | switch ($property_name) {
80 | case 'timestamp':
81 | case 'exists':
82 | $this->handler->populateTimestamp($this);
83 | return $this->$property_name;
84 |
85 | case 'content':
86 | return $this->content = $this->handler->getContent($this);
87 |
88 | default:
89 | throw new SmartyException("config property '$property_name' does not exist.");
90 | }
91 | }
92 |
93 | }
94 |
95 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_resource_registered.php:
--------------------------------------------------------------------------------
1 | filepath = $source->type . ':' . $source->name;
32 | $source->uid = sha1($source->filepath);
33 | if ($source->smarty->compile_check) {
34 | $source->timestamp = $this->getTemplateTimestamp($source);
35 | $source->exists = !!$source->timestamp;
36 | }
37 | }
38 |
39 | /**
40 | * populate Source Object with timestamp and exists from Resource
41 | *
42 | * @param Smarty_Template_Source $source source object
43 | * @return void
44 | */
45 | public function populateTimestamp(Smarty_Template_Source $source)
46 | {
47 | $source->timestamp = $this->getTemplateTimestamp($source);
48 | $source->exists = !!$source->timestamp;
49 | }
50 |
51 | /**
52 | * Get timestamp (epoch) the template source was modified
53 | *
54 | * @param Smarty_Template_Source $source source object
55 | * @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
56 | */
57 | public function getTemplateTimestamp(Smarty_Template_Source $source)
58 | {
59 | // return timestamp
60 | $time_stamp = false;
61 | call_user_func_array($source->smarty->registered_resources[$source->type][0][1], array($source->name, &$time_stamp, $source->smarty));
62 | return is_numeric($time_stamp) ? (int) $time_stamp : $time_stamp;
63 | }
64 |
65 | /**
66 | * Load template's source by invoking the registered callback into current template object
67 | *
68 | * @param Smarty_Template_Source $source source object
69 | * @return string template source
70 | * @throws SmartyException if source cannot be loaded
71 | */
72 | public function getContent(Smarty_Template_Source $source)
73 | {
74 | // return template string
75 | $t = call_user_func_array($source->smarty->registered_resources[$source->type][0][0], array($source->name, &$source->content, $source->smarty));
76 | if (is_bool($t) && !$t) {
77 | throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
78 | }
79 | return $source->content;
80 | }
81 |
82 | /**
83 | * Determine basename for compiled filename
84 | *
85 | * @param Smarty_Template_Source $source source object
86 | * @return string resource's basename
87 | */
88 | protected function getBasename(Smarty_Template_Source $source)
89 | {
90 | return basename($source->name);
91 | }
92 |
93 | }
94 |
95 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_assign.php:
--------------------------------------------------------------------------------
1 | required_attributes = array('var', 'value');
32 | $this->shorttag_order = array('var', 'value');
33 | $this->optional_attributes = array('scope');
34 | $_nocache = 'null';
35 | $_scope = Smarty::SCOPE_LOCAL;
36 | // check and get attributes
37 | $_attr = $this->getAttributes($compiler, $args);
38 | // nocache ?
39 | if ($compiler->tag_nocache || $compiler->nocache) {
40 | $_nocache = 'true';
41 | // create nocache var to make it know for further compiling
42 | $compiler->template->tpl_vars[trim($_attr['var'], "'")] = new Smarty_variable(null, true);
43 | }
44 | // scope setup
45 | if (isset($_attr['scope'])) {
46 | $_attr['scope'] = trim($_attr['scope'], "'\"");
47 | if ($_attr['scope'] == 'parent') {
48 | $_scope = Smarty::SCOPE_PARENT;
49 | } elseif ($_attr['scope'] == 'root') {
50 | $_scope = Smarty::SCOPE_ROOT;
51 | } elseif ($_attr['scope'] == 'global') {
52 | $_scope = Smarty::SCOPE_GLOBAL;
53 | } else {
54 | $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
55 | }
56 | }
57 | // compiled output
58 | if (isset($parameter['smarty_internal_index'])) {
59 | $output = "createLocalArrayVariable($_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
60 | } else {
61 | $output = "tpl_vars[$_attr[var]] = new Smarty_variable($_attr[value], $_nocache, $_scope);";
62 | }
63 | if ($_scope == Smarty::SCOPE_PARENT) {
64 | $output .= "\nif (\$_smarty_tpl->parent != null) \$_smarty_tpl->parent->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
65 | } elseif ($_scope == Smarty::SCOPE_ROOT || $_scope == Smarty::SCOPE_GLOBAL) {
66 | $output .= "\n\$_ptr = \$_smarty_tpl->parent; while (\$_ptr != null) {\$_ptr->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]]; \$_ptr = \$_ptr->parent; }";
67 | }
68 | if ( $_scope == Smarty::SCOPE_GLOBAL) {
69 | $output .= "\nSmarty::\$global_tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
70 | }
71 | $output .= '?>';
72 | return $output;
73 | }
74 |
75 | }
76 |
77 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_capture.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
46 |
47 | $buffer = isset($_attr['name']) ? $_attr['name'] : "'default'";
48 | $assign = isset($_attr['assign']) ? $_attr['assign'] : 'null';
49 | $append = isset($_attr['append']) ? $_attr['append'] : 'null';
50 |
51 | $compiler->_capture_stack[] = array($buffer, $assign, $append, $compiler->nocache);
52 | // maybe nocache because of nocache variables
53 | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
54 | $_output = "_capture_stack[] = array($buffer, $assign, $append); ob_start(); ?>";
55 |
56 | return $_output;
57 | }
58 |
59 | }
60 |
61 | /**
62 | * Smarty Internal Plugin Compile Captureclose Class
63 | *
64 | * @package Smarty
65 | * @subpackage Compiler
66 | */
67 | class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase {
68 |
69 | /**
70 | * Compiles code for the {/capture} tag
71 | *
72 | * @param array $args array with attributes from parser
73 | * @param object $compiler compiler object
74 | * @return string compiled code
75 | */
76 | public function compile($args, $compiler)
77 | {
78 | // check and get attributes
79 | $_attr = $this->getAttributes($compiler, $args);
80 | // must endblock be nocache?
81 | if ($compiler->nocache) {
82 | $compiler->tag_nocache = true;
83 | }
84 |
85 | list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack);
86 |
87 | $_output = "_capture_stack);\n";
88 | $_output .= "if (!empty(\$_capture_buffer)) {\n";
89 | $_output .= " if (isset(\$_capture_assign)) \$_smarty_tpl->assign(\$_capture_assign, ob_get_contents());\n";
90 | $_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n";
91 | $_output .= " Smarty::\$_smarty_vars['capture'][\$_capture_buffer]=ob_get_clean();\n";
92 | $_output .= "} else \$_smarty_tpl->capture_error();?>";
93 | return $_output;
94 | }
95 |
96 | }
97 |
98 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/debug.tpl:
--------------------------------------------------------------------------------
1 | {capture name='_smarty_debug' assign=debug_output}
2 |
3 |
4 |
5 | Smarty Debug Console
6 |
86 |
87 |
88 |
89 | Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var nofilter}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}
90 |
91 | {if !empty($template_data)}
92 | included templates & config files (load time in seconds)
93 |
94 |
95 | {foreach $template_data as $template}
96 | {$template.name}
97 |
98 | (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
99 |
100 |
101 | {/foreach}
102 |
103 | {/if}
104 |
105 | assigned template variables
106 |
107 |
108 | {foreach $assigned_vars as $vars}
109 |
110 | | ${$vars@key|escape:'html'} |
111 | {$vars|debug_print_var nofilter} |
112 | {/foreach}
113 |
114 |
115 | assigned config file variables (outer template scope)
116 |
117 |
118 | {foreach $config_vars as $vars}
119 |
120 | | {$vars@key|escape:'html'} |
121 | {$vars|debug_print_var nofilter} |
122 | {/foreach}
123 |
124 |
125 |
126 |
127 | {/capture}
128 |
134 |
--------------------------------------------------------------------------------
/test/util/diff/release.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TEST_PATH=/home/work/repos/fis2.0_pc/test/util/diff
4 | FISP_PATH=/home/work/repos/fis2.0_pc/
5 | cd ${TEST_PATH}
6 | WENKU_CODE_PATH=${TEST_PATH}/product_code/wenku
7 | WENKU_OUTPUT_PATH=${TEST_PATH}/product_output/wenku
8 |
9 | TIEBA_CODE_PATH=${TEST_PATH}/product_code/tieba
10 | TIEBA_OUTPUT_PATH=${TEST_PATH}/product_output/tieba
11 |
12 | BATMAN_CODE_PATH=${TEST_PATH}/product_code/batman
13 | BATMAN_OUTPUT_PATH=${TEST_PATH}/product_output/batman
14 | BATMAN_MODULES=(transit place common index addr feedback drive walk)
15 |
16 | PLACE_CODE_PATH=${TEST_PATH}/product_code/place
17 | PLACE_OUTPUT_PATH=${TEST_PATH}/product_output/place
18 | PLACE_MODULES=(admin beauty cater common detail hotel movie scope)
19 |
20 | #获取fis version
21 | if [ $1 = 'new' ]
22 | then
23 | version=$(node ${FISP_PATH}/bin/fis-pc -v --no-color)
24 | else
25 | version=$(fisp -v --no-color)
26 | fi
27 |
28 | OLD_IFS="$IFS"
29 | IFS=" "
30 | arr=($version)
31 | IFS="$OLD_IFS"
32 | v=${arr[1]}
33 |
34 | # 执行release
35 | if [ $1 = 'new' ]
36 | then
37 | #wenku
38 | rm -rf ${WENKU_OUTPUT_PATH}/output_new
39 | cd ${WENKU_CODE_PATH}
40 | node ${FISP_PATH}/bin/fis-pc release -md ${WENKU_OUTPUT_PATH}/output_new --no-color
41 | echo $v > ${WENKU_OUTPUT_PATH}/output_new/fis_version.txt
42 | chmod 777 ${WENKU_OUTPUT_PATH}
43 |
44 | #tieba
45 | rm -rf ${TIEBA_OUTPUT_PATH}/output_new
46 | cd ${TIEBA_CODE_PATH}
47 | node ${FISP_PATH}/bin/fis-pc release -md ${TIEBA_OUTPUT_PATH}/output_new --no-color
48 | echo $v > ${TIEBA_OUTPUT_PATH}/output_new/fis_version.txt
49 | chmod 777 ${TIEBA_OUTPUT_PATH}
50 |
51 | #batman
52 | rm -rf ${BATMAN_OUTPUT_PATH}/output_new
53 | for module in ${BATMAN_MODULES[@]}
54 | do
55 | cd ${BATMAN_CODE_PATH}/$module
56 | node ${FISP_PATH}/bin/fis-pc release -md ${BATMAN_OUTPUT_PATH}/output_new --no-color
57 | done
58 | echo $v > ${BATMAN_OUTPUT_PATH}/output_new/fis_version.txt
59 | chmod 777 ${BATMAN_OUTPUT_PATH}
60 |
61 | #place
62 | rm -rf ${PLACE_OUTPUT_PATH}/output_new
63 | for module in ${PLACE_MODULES[@]}
64 | do
65 | cd ${PLACE_CODE_PATH}/$module
66 | node ${FISP_PATH}/bin/fis-pc release -md ${PLACE_OUTPUT_PATH}/output_new --no-color
67 | done
68 | echo $v > ${PLACE_OUTPUT_PATH}/output_new/fis_version.txt
69 | chmod 777 ${PLACE_OUTPUT_PATH}
70 | else
71 | #wenku
72 | rm -rf ${WENKU_OUTPUT_PATH}/output_old
73 | cd ${WENKU_CODE_PATH}
74 | fisp release -md ${WENKU_OUTPUT_PATH}/output_old --no-color
75 | echo $v > ${WENKU_OUTPUT_PATH}/output_old/fis_version.txt
76 | chmod 777 -R ${WENKU_OUTPUT_PATH}/output_old
77 |
78 | #tieba
79 | rm -rf ${TIEBA_OUTPUT_PATH}/output_old
80 | cd ${TIEBA_CODE_PATH}
81 | fisp release -md ${TIEBA_OUTPUT_PATH}/output_old
82 | echo $v > ${TIEBA_OUTPUT_PATH}/output_old/fis_version.txt
83 | chmod 777 -R ${TIEBA_OUTPUT_PATH}/output_old
84 |
85 | #batman
86 | rm -rf ${BATMAN_OUTPUT_PATH}/output_old
87 | for module in ${BATMAN_MODULES[@]}
88 | do
89 | cd ${BATMAN_CODE_PATH}/$module
90 | fisp release -md ${BATMAN_OUTPUT_PATH}/output_old --no-color
91 | done
92 | echo $v > ${BATMAN_OUTPUT_PATH}/output_old/fis_version.txt
93 | chmod 777 -R ${BATMAN_OUTPUT_PATH}/output_old
94 |
95 | #place
96 | rm -rf ${PLACE_OUTPUT_PATH}/output_old
97 | for module in ${PLACE_MODULES[@]}
98 | do
99 | cd ${PLACE_CODE_PATH}/$module
100 | fisp release -md ${PLACE_OUTPUT_PATH}/output_old --no-color
101 | done
102 | echo $v > ${PLACE_OUTPUT_PATH}/output_old/fis_version.txt
103 | chmod 777 -R ${PLACE_OUTPUT_PATH}/output_old
104 | fi
105 |
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/outputfilter.trimwhitespace.php:
--------------------------------------------------------------------------------
1 | .*?#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
30 | foreach ($matches as $match) {
31 | $store[] = $match[0][0];
32 | $_length = strlen($match[0][0]);
33 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
34 | $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
35 |
36 | $_offset += $_length - strlen($replace);
37 | $_store++;
38 | }
39 | }
40 |
41 | // Strip all HTML-Comments
42 | $source = preg_replace( '##ms', '', $source );
43 |
44 | // capture html elements not to be messed with
45 | $_offset = 0;
46 | if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?\\1>#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
47 | foreach ($matches as $match) {
48 | $store[] = $match[0][0];
49 | $_length = strlen($match[0][0]);
50 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
51 | $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
52 |
53 | $_offset += $_length - strlen($replace);
54 | $_store++;
55 | }
56 | }
57 |
58 | $expressions = array(
59 | // replace multiple spaces between tags by a single space
60 | // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
61 | '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
62 | // remove spaces between attributes (but not in attribute values!)
63 | '#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
64 | // note: for some very weird reason trim() seems to remove spaces inside attributes.
65 | // maybe a \0 byte or something is interfering?
66 | '#^\s+<#Ss' => '<',
67 | '#>\s+$#Ss' => '>',
68 | );
69 |
70 | $source = preg_replace( array_keys($expressions), array_values($expressions), $source );
71 | // note: for some very weird reason trim() seems to remove spaces inside attributes.
72 | // maybe a \0 byte or something is interfering?
73 | // $source = trim( $source );
74 |
75 | // capture html elements not to be messed with
76 | $_offset = 0;
77 | if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
78 | foreach ($matches as $match) {
79 | $store[] = $match[0][0];
80 | $_length = strlen($match[0][0]);
81 | $replace = array_shift($store);
82 | $source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
83 |
84 | $_offset += strlen($replace) - $_length;
85 | $_store++;
86 | }
87 | }
88 |
89 | return $source;
90 | }
91 |
92 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_private_block_plugin.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
44 | if ($_attr['nocache'] === true) {
45 | $compiler->tag_nocache = true;
46 | }
47 | unset($_attr['nocache']);
48 | // convert attributes into parameter array string
49 | $_paramsArray = array();
50 | foreach ($_attr as $_key => $_value) {
51 | if (is_int($_key)) {
52 | $_paramsArray[] = "$_key=>$_value";
53 | } else {
54 | $_paramsArray[] = "'$_key'=>$_value";
55 | }
56 | }
57 | $_params = 'array(' . implode(",", $_paramsArray) . ')';
58 |
59 | $this->openTag($compiler, $tag, array($_params, $compiler->nocache));
60 | // maybe nocache because of nocache variables or nocache plugin
61 | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
62 | // compile code
63 | $output = "smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
64 | } else {
65 | // must endblock be nocache?
66 | if ($compiler->nocache) {
67 | $compiler->tag_nocache = true;
68 | }
69 | // closing tag of block plugin, restore nocache
70 | list($_params, $compiler->nocache) = $this->closeTag($compiler, substr($tag, 0, -5));
71 | // This tag does create output
72 | $compiler->has_output = true;
73 | // compile code
74 | if (!isset($parameter['modifier_list'])) {
75 | $mod_pre = $mod_post ='';
76 | } else {
77 | $mod_pre = ' ob_start(); ';
78 | $mod_post = 'echo '.$compiler->compileTag('private_modifier',array(),array('modifierlist'=>$parameter['modifier_list'],'value'=>'ob_get_clean()')).';';
79 | }
80 | $output = "smarty->_tag_stack);?>";
81 | }
82 | return $output . "\n";
83 | }
84 |
85 | }
86 |
87 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/modifiercompiler.escape.php:
--------------------------------------------------------------------------------
1 |
18 | * Name: escape
19 | * Purpose: escape string for output
20 | *
21 | * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
22 | * @author Rodney Rehm
23 | * @param array $params parameters
24 | * @return string with compiled code
25 | */
26 | function smarty_modifiercompiler_escape($params, $compiler)
27 | {
28 | try {
29 | $esc_type = smarty_literal_compiler_param($params, 1, 'html');
30 | $char_set = smarty_literal_compiler_param($params, 2, SMARTY_RESOURCE_CHAR_SET);
31 | $double_encode = smarty_literal_compiler_param($params, 3, true);
32 |
33 | if (!$char_set) {
34 | $char_set = SMARTY_RESOURCE_CHAR_SET;
35 | }
36 |
37 | switch ($esc_type) {
38 | case 'html':
39 | return 'htmlspecialchars('
40 | . $params[0] .', ENT_QUOTES, '
41 | . var_export($char_set, true) . ', '
42 | . var_export($double_encode, true) . ')';
43 |
44 | case 'htmlall':
45 | if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
46 | return 'mb_convert_encoding(htmlspecialchars('
47 | . $params[0] .', ENT_QUOTES, '
48 | . var_export($char_set, true) . ', '
49 | . var_export($double_encode, true)
50 | . '), "HTML-ENTITIES", '
51 | . var_export($char_set, true) . ')';
52 | }
53 |
54 | // no MBString fallback
55 | return 'htmlentities('
56 | . $params[0] .', ENT_QUOTES, '
57 | . var_export($char_set, true) . ', '
58 | . var_export($double_encode, true) . ')';
59 |
60 | case 'url':
61 | return 'rawurlencode(' . $params[0] . ')';
62 |
63 | case 'urlpathinfo':
64 | return 'str_replace("%2F", "/", rawurlencode(' . $params[0] . '))';
65 |
66 | case 'quotes':
67 | // escape unescaped single quotes
68 | return 'preg_replace("%(? "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "" => "<\/" ))';
73 |
74 | }
75 | } catch(SmartyException $e) {
76 | // pass through to regular plugin fallback
77 | }
78 |
79 | // could not optimize |escape call, so fallback to regular plugin
80 | if ($compiler->tag_nocache | $compiler->nocache) {
81 | $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
82 | $compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
83 | } else {
84 | $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
85 | $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
86 | }
87 | return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
88 | }
89 |
90 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/function.cycle.php:
--------------------------------------------------------------------------------
1 |
13 | * Name: cycle
14 | * Date: May 3, 2002
15 | * Purpose: cycle through given values
16 | * Params:
17 | *
18 | * - name - name of cycle (optional)
19 | * - values - comma separated list of values to cycle, or an array of values to cycle
20 | * (this can be left out for subsequent calls)
21 | * - reset - boolean - resets given var to true
22 | * - print - boolean - print var or not. default is true
23 | * - advance - boolean - whether or not to advance the cycle
24 | * - delimiter - the value delimiter, default is ","
25 | * - assign - boolean, assigns to template var instead of printed.
26 | *
27 | * Examples:
28 | *
29 | * {cycle values="#eeeeee,#d0d0d0d"}
30 | * {cycle name=row values="one,two,three" reset=true}
31 | * {cycle name=row}
32 | *
33 | *
34 | * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
35 | * (Smarty online manual)
36 | * @author Monte Ohrt
37 | * @author credit to Mark Priatel
38 | * @author credit to Gerard
39 | * @author credit to Jason Sweat
40 | * @version 1.3
41 | * @param array $params parameters
42 | * @param Smarty_Internal_Template $template template object
43 | * @return string|null
44 | */
45 |
46 | function smarty_function_cycle($params, $template)
47 | {
48 | static $cycle_vars;
49 |
50 | $name = (empty($params['name'])) ? 'default' : $params['name'];
51 | $print = (isset($params['print'])) ? (bool)$params['print'] : true;
52 | $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
53 | $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
54 |
55 | if (!isset($params['values'])) {
56 | if(!isset($cycle_vars[$name]['values'])) {
57 | trigger_error("cycle: missing 'values' parameter");
58 | return;
59 | }
60 | } else {
61 | if(isset($cycle_vars[$name]['values'])
62 | && $cycle_vars[$name]['values'] != $params['values'] ) {
63 | $cycle_vars[$name]['index'] = 0;
64 | }
65 | $cycle_vars[$name]['values'] = $params['values'];
66 | }
67 |
68 | if (isset($params['delimiter'])) {
69 | $cycle_vars[$name]['delimiter'] = $params['delimiter'];
70 | } elseif (!isset($cycle_vars[$name]['delimiter'])) {
71 | $cycle_vars[$name]['delimiter'] = ',';
72 | }
73 |
74 | if(is_array($cycle_vars[$name]['values'])) {
75 | $cycle_array = $cycle_vars[$name]['values'];
76 | } else {
77 | $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
78 | }
79 |
80 | if(!isset($cycle_vars[$name]['index']) || $reset ) {
81 | $cycle_vars[$name]['index'] = 0;
82 | }
83 |
84 | if (isset($params['assign'])) {
85 | $print = false;
86 | $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
87 | }
88 |
89 | if($print) {
90 | $retval = $cycle_array[$cycle_vars[$name]['index']];
91 | } else {
92 | $retval = null;
93 | }
94 |
95 | if($advance) {
96 | if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
97 | $cycle_vars[$name]['index'] = 0;
98 | } else {
99 | $cycle_vars[$name]['index']++;
100 | }
101 | }
102 |
103 | return $retval;
104 | }
105 |
106 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_include_php.php:
--------------------------------------------------------------------------------
1 | smarty instanceof SmartyBC)) {
52 | throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
53 | }
54 | // check and get attributes
55 | $_attr = $this->getAttributes($compiler, $args);
56 |
57 | $_output = 'template;
60 | $_filepath = false;
61 | eval('$_file = ' . $_attr['file'] . ';');
62 | if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
63 | $_filepath = $_file;
64 | } else {
65 | if (isset($compiler->smarty->security_policy)) {
66 | $_dir = $compiler->smarty->security_policy->trusted_dir;
67 | } else {
68 | $_dir = $compiler->smarty->trusted_dir;
69 | }
70 | if (!empty($_dir)) {
71 | foreach((array)$_dir as $_script_dir) {
72 | $_script_dir = rtrim($_script_dir, '/\\') . DS;
73 | if (file_exists($_script_dir . $_file)) {
74 | $_filepath = $_script_dir . $_file;
75 | break;
76 | }
77 | }
78 | }
79 | }
80 | if ($_filepath == false) {
81 | $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno);
82 | }
83 |
84 | if (isset($compiler->smarty->security_policy)) {
85 | $compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
86 | }
87 |
88 | if (isset($_attr['assign'])) {
89 | // output will be stored in a smarty variable instead of being displayed
90 | $_assign = $_attr['assign'];
91 | }
92 | $_once = '_once';
93 | if (isset($_attr['once'])) {
94 | if ($_attr['once'] == 'false') {
95 | $_once = '';
96 | }
97 | }
98 |
99 | if (isset($_assign)) {
100 | return "assign({$_assign},ob_get_contents()); ob_end_clean();?>";
101 | } else {
102 | return "\n";
103 | }
104 | }
105 |
106 | }
107 |
108 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/block.textformat.php:
--------------------------------------------------------------------------------
1 |
13 | * Name: textformat
14 | * Purpose: format text a certain way with preset styles
15 | * or custom wrap/indent settings
16 | * Params:
17 | *
18 | * - style - string (email)
19 | * - indent - integer (0)
20 | * - wrap - integer (80)
21 | * - wrap_char - string ("\n")
22 | * - indent_char - string (" ")
23 | * - wrap_boundary - boolean (true)
24 | *
25 | *
26 | * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
27 | * (Smarty online manual)
28 | * @param array $params parameters
29 | * @param string $content contents of the block
30 | * @param Smarty_Internal_Template $template template object
31 | * @param boolean &$repeat repeat flag
32 | * @return string content re-formatted
33 | * @author Monte Ohrt
34 | */
35 | function smarty_block_textformat($params, $content, $template, &$repeat)
36 | {
37 | if (is_null($content)) {
38 | return;
39 | }
40 |
41 | $style = null;
42 | $indent = 0;
43 | $indent_first = 0;
44 | $indent_char = ' ';
45 | $wrap = 80;
46 | $wrap_char = "\n";
47 | $wrap_cut = false;
48 | $assign = null;
49 |
50 | foreach ($params as $_key => $_val) {
51 | switch ($_key) {
52 | case 'style':
53 | case 'indent_char':
54 | case 'wrap_char':
55 | case 'assign':
56 | $$_key = (string)$_val;
57 | break;
58 |
59 | case 'indent':
60 | case 'indent_first':
61 | case 'wrap':
62 | $$_key = (int)$_val;
63 | break;
64 |
65 | case 'wrap_cut':
66 | $$_key = (bool)$_val;
67 | break;
68 |
69 | default:
70 | trigger_error("textformat: unknown attribute '$_key'");
71 | }
72 | }
73 |
74 | if ($style == 'email') {
75 | $wrap = 72;
76 | }
77 | // split into paragraphs
78 | $_paragraphs = preg_split('![\r\n]{2}!', $content);
79 | $_output = '';
80 |
81 |
82 | foreach ($_paragraphs as &$_paragraph) {
83 | if (!$_paragraph) {
84 | continue;
85 | }
86 | // convert mult. spaces & special chars to single space
87 | $_paragraph = preg_replace(array('!\s+!u', '!(^\s+)|(\s+$)!u'), array(' ', ''), $_paragraph);
88 | // indent first line
89 | if ($indent_first > 0) {
90 | $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
91 | }
92 | // wordwrap sentences
93 | if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
94 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
95 | $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
96 | } else {
97 | $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
98 | }
99 | // indent lines
100 | if ($indent > 0) {
101 | $_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);
102 | }
103 | }
104 | $_output = implode($wrap_char . $wrap_char, $_paragraphs);
105 |
106 | if ($assign) {
107 | $template->assign($assign, $_output);
108 | } else {
109 | return $_output;
110 | }
111 | }
112 |
113 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_private_modifier.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
33 | $output = $parameter['value'];
34 | // loop over list of modifiers
35 | foreach ($parameter['modifierlist'] as $single_modifier) {
36 | $modifier = $single_modifier[0];
37 | $single_modifier[0] = $output;
38 | $params = implode(',', $single_modifier);
39 | // check for registered modifier
40 | if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier])) {
41 | $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
42 | if (!is_array($function)) {
43 | $output = "{$function}({$params})";
44 | } else {
45 | if (is_object($function[0])) {
46 | $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
47 | } else {
48 | $output = $function[0] . '::' . $function[1] . '(' . $params . ')';
49 | }
50 | }
51 | } else if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0])) {
52 | $output = call_user_func($compiler->smarty->registered_plugins[Smarty::PLUGIN_MODIFIERCOMPILER][$modifier][0], $single_modifier, $compiler->smarty);
53 | // check for plugin modifiercompiler
54 | } else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
55 | // check if modifier allowed
56 | if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
57 | $plugin = 'smarty_modifiercompiler_' . $modifier;
58 | $output = $plugin($single_modifier, $compiler);
59 | }
60 | // check for plugin modifier
61 | } else if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
62 | // check if modifier allowed
63 | if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
64 | $output = "{$function}({$params})";
65 | }
66 | // check if trusted PHP function
67 | } else if (is_callable($modifier)) {
68 | // check if modifier allowed
69 | if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
70 | $output = "{$modifier}({$params})";
71 | }
72 | } else {
73 | $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
74 | }
75 | }
76 | return $output;
77 | }
78 |
79 | }
80 |
81 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_smartytemplatecompiler.php:
--------------------------------------------------------------------------------
1 | smarty = $smarty;
77 | parent::__construct();
78 | // get required plugins
79 | $this->lexer_class = $lexer_class;
80 | $this->parser_class = $parser_class;
81 | }
82 |
83 | /**
84 | * Methode to compile a Smarty template
85 | *
86 | * @param mixed $_content template source
87 | * @return bool true if compiling succeeded, false if it failed
88 | */
89 | protected function doCompile($_content)
90 | {
91 | /* here is where the compiling takes place. Smarty
92 | tags in the templates are replaces with PHP code,
93 | then written to compiled files. */
94 | // init the lexer/parser to compile the template
95 | $this->lex = new $this->lexer_class($_content, $this);
96 | $this->parser = new $this->parser_class($this->lex, $this);
97 | if ($this->smarty->_parserdebug)
98 | $this->parser->PrintTrace();
99 | // get tokens from lexer and parse them
100 | while ($this->lex->yylex() && !$this->abort_and_recompile) {
101 | if ($this->smarty->_parserdebug) {
102 | echo "Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token " .
103 | htmlentities($this->lex->value) . "";
104 | }
105 | $this->parser->doParse($this->lex->token, $this->lex->value);
106 | }
107 |
108 | if ($this->abort_and_recompile) {
109 | // exit here on abort
110 | return false;
111 | }
112 | // finish parsing process
113 | $this->parser->doParse(0, 0);
114 | // check for unclosed tags
115 | if (count($this->_tag_stack) > 0) {
116 | // get stacked info
117 | list($openTag, $_data) = array_pop($this->_tag_stack);
118 | $this->trigger_template_error("unclosed {" . $openTag . "} tag");
119 | }
120 | // return compiled code
121 | // return str_replace(array("? >\nparser->retvalue);
122 | return $this->parser->retvalue;
123 | }
124 |
125 | }
126 |
127 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_while.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
32 | $this->openTag($compiler, 'while', $compiler->nocache);
33 |
34 | if (!array_key_exists("if condition",$parameter)) {
35 | $compiler->trigger_template_error("missing while condition", $compiler->lex->taglineno);
36 | }
37 |
38 | // maybe nocache because of nocache variables
39 | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
40 | if (is_array($parameter['if condition'])) {
41 | if ($compiler->nocache) {
42 | $_nocache = ',true';
43 | // create nocache var to make it know for further compiling
44 | if (is_array($parameter['if condition']['var'])) {
45 | $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
46 | } else {
47 | $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
48 | }
49 | } else {
50 | $_nocache = '';
51 | }
52 | if (is_array($parameter['if condition']['var'])) {
53 | $_output = "tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
54 | $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . "){?>";
55 | } else {
56 | $_output = "tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
57 | $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . "){?>";
58 | }
59 | return $_output;
60 | } else {
61 | return "";
62 | }
63 | }
64 |
65 | }
66 |
67 | /**
68 | * Smarty Internal Plugin Compile Whileclose Class
69 | *
70 | * @package Smarty
71 | * @subpackage Compiler
72 | */
73 | class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
74 |
75 | /**
76 | * Compiles code for the {/while} tag
77 | *
78 | * @param array $args array with attributes from parser
79 | * @param object $compiler compiler object
80 | * @return string compiled code
81 | */
82 | public function compile($args, $compiler)
83 | {
84 | // must endblock be nocache?
85 | if ($compiler->nocache) {
86 | $compiler->tag_nocache = true;
87 | }
88 | $compiler->nocache = $this->closeTag($compiler, array('while'));
89 | return "";
90 | }
91 |
92 | }
93 |
94 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_private_object_block_function.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
44 | if ($_attr['nocache'] === true) {
45 | $compiler->tag_nocache = true;
46 | }
47 | unset($_attr['nocache']);
48 | // convert attributes into parameter array string
49 | $_paramsArray = array();
50 | foreach ($_attr as $_key => $_value) {
51 | if (is_int($_key)) {
52 | $_paramsArray[] = "$_key=>$_value";
53 | } else {
54 | $_paramsArray[] = "'$_key'=>$_value";
55 | }
56 | }
57 | $_params = 'array(' . implode(",", $_paramsArray) . ')';
58 |
59 | $this->openTag($compiler, $tag . '->' . $method, array($_params, $compiler->nocache));
60 | // maybe nocache because of nocache variables or nocache plugin
61 | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
62 | // compile code
63 | $output = "smarty->_tag_stack[] = array('{$tag}->{$method}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
64 | } else {
65 | $base_tag = substr($tag, 0, -5);
66 | // must endblock be nocache?
67 | if ($compiler->nocache) {
68 | $compiler->tag_nocache = true;
69 | }
70 | // closing tag of block plugin, restore nocache
71 | list($_params, $compiler->nocache) = $this->closeTag($compiler, $base_tag . '->' . $method);
72 | // This tag does create output
73 | $compiler->has_output = true;
74 | // compile code
75 | if (!isset($parameter['modifier_list'])) {
76 | $mod_pre = $mod_post = '';
77 | } else {
78 | $mod_pre = ' ob_start(); ';
79 | $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], 'value' => 'ob_get_clean()')) . ';';
80 | }
81 | $output = "smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
82 | }
83 | return $output . "\n";
84 | }
85 |
86 | }
87 |
88 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_private_special_variable.php:
--------------------------------------------------------------------------------
1 | getVariable('smarty')->value$parameter";
35 | case 'section':
36 | return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
37 | case 'capture':
38 | return "Smarty::\$_smarty_vars$parameter";
39 | case 'now':
40 | return 'time()';
41 | case 'cookies':
42 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
43 | $compiler->trigger_template_error("(secure mode) super globals not permitted");
44 | break;
45 | }
46 | $compiled_ref = '$_COOKIE';
47 | break;
48 |
49 | case 'get':
50 | case 'post':
51 | case 'env':
52 | case 'server':
53 | case 'session':
54 | case 'request':
55 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
56 | $compiler->trigger_template_error("(secure mode) super globals not permitted");
57 | break;
58 | }
59 | $compiled_ref = '$_'.strtoupper($variable);
60 | break;
61 |
62 | case 'template':
63 | return 'basename($_smarty_tpl->source->filepath)';
64 |
65 | case 'current_dir':
66 | return 'dirname($_smarty_tpl->source->filepath)';
67 |
68 | case 'version':
69 | $_version = Smarty::SMARTY_VERSION;
70 | return "'$_version'";
71 |
72 | case 'const':
73 | if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
74 | $compiler->trigger_template_error("(secure mode) constants not permitted");
75 | break;
76 | }
77 | return '@' . trim($_index[1], "'");
78 |
79 | case 'config':
80 | return "\$_smarty_tpl->getConfigVariable($_index[1])";
81 | case 'ldelim':
82 | $_ldelim = $compiler->smarty->left_delimiter;
83 | return "'$_ldelim'";
84 |
85 | case 'rdelim':
86 | $_rdelim = $compiler->smarty->right_delimiter;
87 | return "'$_rdelim'";
88 |
89 | default:
90 | $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
91 | break;
92 | }
93 | if (isset($_index[1])) {
94 | array_shift($_index);
95 | foreach ($_index as $_ind) {
96 | $compiled_ref = $compiled_ref . "[$_ind]";
97 | }
98 | }
99 | return $compiled_ref;
100 | }
101 |
102 | }
103 |
104 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/modifier.debug_print_var.php:
--------------------------------------------------------------------------------
1 |
13 | * Name: debug_print_var
14 | * Purpose: formats variable contents for display in the console
15 | *
16 | * @author Monte Ohrt
17 | * @param array|object $var variable to be formatted
18 | * @param integer $depth maximum recursion depth if $var is an array
19 | * @param integer $length maximum string length if $var is a string
20 | * @return string
21 | */
22 | function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
23 | {
24 | $_replace = array("\n" => '\n',
25 | "\r" => '\r',
26 | "\t" => '\t'
27 | );
28 |
29 | switch (gettype($var)) {
30 | case 'array' :
31 | $results = 'Array (' . count($var) . ')';
32 | foreach ($var as $curr_key => $curr_val) {
33 | $results .= '
' . str_repeat(' ', $depth * 2)
34 | . '' . strtr($curr_key, $_replace) . ' => '
35 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
36 | $depth--;
37 | }
38 | break;
39 |
40 | case 'object' :
41 | $object_vars = get_object_vars($var);
42 | $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')';
43 | foreach ($object_vars as $curr_key => $curr_val) {
44 | $results .= '
' . str_repeat(' ', $depth * 2)
45 | . ' ->' . strtr($curr_key, $_replace) . ' = '
46 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
47 | $depth--;
48 | }
49 | break;
50 |
51 | case 'boolean' :
52 | case 'NULL' :
53 | case 'resource' :
54 | if (true === $var) {
55 | $results = 'true';
56 | } elseif (false === $var) {
57 | $results = 'false';
58 | } elseif (null === $var) {
59 | $results = 'null';
60 | } else {
61 | $results = htmlspecialchars((string) $var);
62 | }
63 | $results = '' . $results . '';
64 | break;
65 |
66 | case 'integer' :
67 | case 'float' :
68 | $results = htmlspecialchars((string) $var);
69 | break;
70 |
71 | case 'string' :
72 | $results = strtr($var, $_replace);
73 | if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
74 | if (mb_strlen($var, SMARTY_RESOURCE_CHAR_SET) > $length) {
75 | $results = mb_substr($var, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
76 | }
77 | } else {
78 | if (isset($var[$length])) {
79 | $results = substr($var, 0, $length - 3) . '...';
80 | }
81 | }
82 |
83 | $results = htmlspecialchars('"' . $results . '"');
84 | break;
85 |
86 | case 'unknown type' :
87 | default :
88 | $results = strtr((string) $var, $_replace);
89 | if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
90 | if (mb_strlen($results, SMARTY_RESOURCE_CHAR_SET) > $length) {
91 | $results = mb_substr($results, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
92 | }
93 | } else {
94 | if (strlen($results) > $length) {
95 | $results = substr($results, 0, $length - 3) . '...';
96 | }
97 | }
98 |
99 | $results = htmlspecialchars($results);
100 | }
101 |
102 | return $results;
103 | }
104 |
105 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_resource_php.php:
--------------------------------------------------------------------------------
1 | short_open_tag = ini_get( 'short_open_tag' );
27 | }
28 |
29 | /**
30 | * populate Source Object with meta data from Resource
31 | *
32 | * @param Smarty_Template_Source $source source object
33 | * @param Smarty_Internal_Template $_template template object
34 | * @return void
35 | */
36 | public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
37 | {
38 | $source->filepath = $this->buildFilepath($source, $_template);
39 |
40 | if ($source->filepath !== false) {
41 | if (is_object($source->smarty->security_policy)) {
42 | $source->smarty->security_policy->isTrustedResourceDir($source->filepath);
43 | }
44 |
45 | $source->uid = sha1($source->filepath);
46 | if ($source->smarty->compile_check) {
47 | $source->timestamp = @filemtime($source->filepath);
48 | $source->exists = !!$source->timestamp;
49 | }
50 | }
51 | }
52 |
53 | /**
54 | * populate Source Object with timestamp and exists from Resource
55 | *
56 | * @param Smarty_Template_Source $source source object
57 | * @return void
58 | */
59 | public function populateTimestamp(Smarty_Template_Source $source)
60 | {
61 | $source->timestamp = @filemtime($source->filepath);
62 | $source->exists = !!$source->timestamp;
63 | }
64 |
65 | /**
66 | * Load template's source from file into current template object
67 | *
68 | * @param Smarty_Template_Source $source source object
69 | * @return string template source
70 | * @throws SmartyException if source cannot be loaded
71 | */
72 | public function getContent(Smarty_Template_Source $source)
73 | {
74 | if ($source->timestamp) {
75 | return '';
76 | }
77 | throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
78 | }
79 |
80 | /**
81 | * Render and output the template (without using the compiler)
82 | *
83 | * @param Smarty_Template_Source $source source object
84 | * @param Smarty_Internal_Template $_template template object
85 | * @return void
86 | * @throws SmartyException if template cannot be loaded or allow_php_templates is disabled
87 | */
88 | public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template)
89 | {
90 | $_smarty_template = $_template;
91 |
92 | if (!$source->smarty->allow_php_templates) {
93 | throw new SmartyException("PHP templates are disabled");
94 | }
95 | if (!$source->exists) {
96 | if ($_template->parent instanceof Smarty_Internal_Template) {
97 | $parent_resource = " in '{$_template->parent->template_resource}'";
98 | } else {
99 | $parent_resource = '';
100 | }
101 | throw new SmartyException("Unable to load template {$source->type} '{$source->name}'{$parent_resource}");
102 | }
103 |
104 | // prepare variables
105 | extract($_template->getTemplateVars());
106 |
107 | // include PHP template with short open tags enabled
108 | ini_set( 'short_open_tag', '1' );
109 | include($source->filepath);
110 | ini_set( 'short_open_tag', $this->short_open_tag );
111 | }
112 | }
113 |
114 | ?>
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ##FIS-PC
2 | [](http://badge.fury.io/js/fis-pc)
3 |
4 | > FIS-PC提供了一套贯穿开发流程的开发体系和集成开发环境,为产品线提供前端开发底层架构,帮助工程师提高开发效率,沟通协作效率,快速实现需求并达到代码的最优化。
5 |
6 | ## 快速上手
7 |
8 | * [安装](https://github.com/xiangshouding/fis-pc/wiki/快速上手#)
9 | * npm install **-g** fis-pc
10 | * [三条命令,满足你的所有开发需求](https://github.com/xiangshouding/fis-pc/wiki/%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B#%E4%B8%89%E6%9D%A1%E5%91%BD%E4%BB%A4%E6%BB%A1%E8%B6%B3%E4%BD%A0%E7%9A%84%E6%89%80%E6%9C%89%E9%9C%80%E6%B1%82)
11 | * fis-pc install <name>
12 | * fis-pc release [options]
13 | * fis-pc server <command> [options]
14 |
15 | ## 示例演示
16 |
17 | * [示例安装](https://github.com/xiangshouding/fis-pc/wiki/%E7%A4%BA%E4%BE%8B#%E7%A4%BA%E4%BE%8B%E5%AE%89%E8%A3%85)
18 | * [示例预览](https://github.com/xiangshouding/fis-pc/wiki/%E7%A4%BA%E4%BE%8B#%E7%A4%BA%E4%BE%8B%E9%A2%84%E8%A7%88)
19 |
20 | ## 解决方案规范
21 |
22 | * [站点目录结构](https://github.com/xiangshouding/fis-pc/wiki/%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E8%A7%84%E8%8C%83#)
23 | * [组件化](https://github.com/xiangshouding/fis-pc/wiki/%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E8%A7%84%E8%8C%83#-1)
24 |
25 | ## 编译开发
26 |
27 | * 基础开发
28 | * [模板](https://github.com/xiangshouding/fis-pc/wiki/模板)
29 | * [页面](https://github.com/xiangshouding/fis-pc/wiki/%E6%A8%A1%E6%9D%BF#%E9%A1%B5%E9%9D%A2)
30 | * [widget](https://github.com/xiangshouding/fis-pc/wiki/%E6%A8%A1%E6%9D%BF#widget)
31 | * [语言能力](https://github.com/xiangshouding/fis-pc/wiki/%E6%A8%A1%E6%9D%BF#widget)
32 | * [JS](https://github.com/xiangshouding/fis-pc/wiki/js)
33 | * [widget](https://github.com/xiangshouding/fis-pc/wiki/js#widget)
34 | * [其他](https://github.com/xiangshouding/fis-pc/wiki/js#%E5%85%B6%E4%BB%96)
35 | * [语言能力](https://github.com/xiangshouding/fis-pc/wiki/js#%E8%AF%AD%E8%A8%80%E8%83%BD%E5%8A%9B)
36 | * [CSS](https://github.com/xiangshouding/fis-pc/wiki/css)
37 | * [widget](https://github.com/xiangshouding/fis-pc/wiki/css#widget)
38 | * [其他](https://github.com/xiangshouding/fis-pc/wiki/css#%E5%85%B6%E4%BB%96)
39 | * [语言能力](https://github.com/xiangshouding/fis-pc/wiki/css#%E8%AF%AD%E8%A8%80%E8%83%BD%E5%8A%9B)
40 | * 自动化工具
41 | * [模板XSS修复工具](https://github.com/xiangshouding/fis-pc/wiki/%E8%87%AA%E5%8A%A8%E5%8C%96%E5%B7%A5%E5%85%B7#xss)
42 | * [图片合并工具](https://github.com/xiangshouding/fis-pc/wiki/%E8%87%AA%E5%8A%A8%E5%8C%96%E5%B7%A5%E5%85%B7#%E5%9B%BE%E7%89%87%E5%90%88%E5%B9%B6%E5%B7%A5%E5%85%B7)
43 | * [模板压缩工具](https://github.com/xiangshouding/fis-pc/wiki/%E8%87%AA%E5%8A%A8%E5%8C%96%E5%B7%A5%E5%85%B7#%E6%A8%A1%E6%9D%BF%E5%8E%8B%E7%BC%A9%E5%B7%A5%E5%85%B7)
44 | * [JS压缩工具](https://github.com/xiangshouding/fis-pc/wiki/%E8%87%AA%E5%8A%A8%E5%8C%96%E5%B7%A5%E5%85%B7#js%E5%8E%8B%E7%BC%A9%E5%B7%A5%E5%85%B7)
45 | * [CSS压缩工具](https://github.com/xiangshouding/fis-pc/wiki/%E8%87%AA%E5%8A%A8%E5%8C%96%E5%B7%A5%E5%85%B7#css%E5%8E%8B%E7%BC%A9%E5%B7%A5%E5%85%B7)
46 | * 插件使用
47 | * [html](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#html)
48 | * [head](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#head)
49 | * [body](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#body)
50 | * [script](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#script)
51 | * [require](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#require)
52 | * [widget](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8#widget)
53 | * 开发配置
54 | * [基础配置](https://github.com/xiangshouding/fis-pc/wiki/%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE)
55 | * [打包配置](https://github.com/xiangshouding/fis-pc/wiki/%E6%89%93%E5%8C%85%E9%85%8D%E7%BD%AE)
56 | * [插件配置](https://github.com/xiangshouding/fis-pc/wiki/%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE)
57 | * [产出配置](https://github.com/xiangshouding/fis-pc/wiki/%E4%BA%A7%E5%87%BA%E9%85%8D%E7%BD%AE)
58 |
59 | ## 联调自测
60 |
61 | * [本地模拟请求转发功能](https://github.com/xiangshouding/fis-pc/wiki/%E6%9C%AC%E5%9C%B0%E6%A8%A1%E6%8B%9F%E8%AF%B7%E6%B1%82%E8%BD%AC%E5%8F%91%E5%8A%9F%E8%83%BD)
62 | * [本地调试数据功能](https://github.com/xiangshouding/fis-pc/wiki/%E6%9C%AC%E5%9C%B0%E8%B0%83%E8%AF%95%E6%95%B0%E6%8D%AE%E5%8A%9F%E8%83%BD)
63 | * [线上调试测试](https://github.com/xiangshouding/fis-pc/wiki/%E7%BA%BF%E4%B8%8A%E8%B0%83%E8%AF%95%E6%B5%8B%E8%AF%95)
64 |
65 | ## 上传部署
66 |
67 | * [产出目录](https://github.com/xiangshouding/fis-pc/wiki/%E4%B8%8A%E4%BC%A0%E9%83%A8%E7%BD%B2#%E4%BA%A7%E5%87%BA%E7%9B%AE%E5%BD%95)
68 | * [上传配置](https://github.com/xiangshouding/fis-pc/wiki/%E4%B8%8A%E4%BC%A0%E9%83%A8%E7%BD%B2#%E4%B8%8A%E4%BC%A0%E9%85%8D%E7%BD%AE)
69 |
70 | ## 编译提测
71 |
72 | * [编译脚本](https://github.com/xiangshouding/fis-pc/wiki/%E7%BC%96%E8%AF%91%E6%8F%90%E6%B5%8B#%E7%BC%96%E8%AF%91%E8%84%9A%E6%9C%AC)
73 | * [icafe编译](https://github.com/xiangshouding/fis-pc/wiki/%E7%BC%96%E8%AF%91%E6%8F%90%E6%B5%8B#icafe%E7%BC%96%E8%AF%91)
74 |
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_config_file_compiler.php:
--------------------------------------------------------------------------------
1 | smarty = $smarty;
64 | $this->config_data['sections'] = array();
65 | $this->config_data['vars'] = array();
66 | }
67 |
68 | /**
69 | * Method to compile a Smarty template.
70 | *
71 | * @param Smarty_Internal_Config $config config object
72 | * @return bool true if compiling succeeded, false if it failed
73 | */
74 | public function compileSource(Smarty_Internal_Config $config)
75 | {
76 | /* here is where the compiling takes place. Smarty
77 | tags in the templates are replaces with PHP code,
78 | then written to compiled files. */
79 | $this->config = $config;
80 | // get config file source
81 | $_content = $config->source->content . "\n";
82 | // on empty template just return
83 | if ($_content == '') {
84 | return true;
85 | }
86 | // init the lexer/parser to compile the config file
87 | $lex = new Smarty_Internal_Configfilelexer($_content, $this->smarty);
88 | $parser = new Smarty_Internal_Configfileparser($lex, $this);
89 | if ($this->smarty->_parserdebug) $parser->PrintTrace();
90 | // get tokens from lexer and parse them
91 | while ($lex->yylex()) {
92 | if ($this->smarty->_parserdebug) echo "
Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
93 | $parser->doParse($lex->token, $lex->value);
94 | }
95 | // finish parsing process
96 | $parser->doParse(0, 0);
97 | $config->compiled_config = 'config_data, true) . '; ?>';
98 | }
99 |
100 | /**
101 | * display compiler error messages without dying
102 | *
103 | * If parameter $args is empty it is a parser detected syntax error.
104 | * In this case the parser is called to obtain information about exspected tokens.
105 | *
106 | * If parameter $args contains a string this is used as error message
107 | *
108 | * @param string $args individual error message or null
109 | */
110 | public function trigger_config_file_error($args = null)
111 | {
112 | $this->lex = Smarty_Internal_Configfilelexer::instance();
113 | $this->parser = Smarty_Internal_Configfileparser::instance();
114 | // get template source line which has error
115 | $line = $this->lex->line;
116 | if (isset($args)) {
117 | // $line--;
118 | }
119 | $match = preg_split("/\n/", $this->lex->data);
120 | $error_text = "Syntax error in config file '{$this->config->source->filepath}' on line {$line} '{$match[$line-1]}' ";
121 | if (isset($args)) {
122 | // individual error message
123 | $error_text .= $args;
124 | } else {
125 | // exspected token from parser
126 | foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
127 | $exp_token = $this->parser->yyTokenName[$token];
128 | if (isset($this->lex->smarty_token_names[$exp_token])) {
129 | // token type from lexer
130 | $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
131 | } else {
132 | // otherwise internal token name
133 | $expect[] = $this->parser->yyTokenName[$token];
134 | }
135 | }
136 | // output parser error message
137 | $error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
138 | }
139 | throw new SmartyCompilerException($error_text);
140 | }
141 |
142 | }
143 |
144 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/plugins/function.html_image.php:
--------------------------------------------------------------------------------
1 |
13 | * Name: html_image
14 | * Date: Feb 24, 2003
15 | * Purpose: format HTML tags for the image
16 | * Examples: {html_image file="/images/masthead.gif"}
17 | * Output: 
18 | * Params:
19 | *
20 | * - file - (required) - file (and path) of image
21 | * - height - (optional) - image height (default actual height)
22 | * - width - (optional) - image width (default actual width)
23 | * - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
24 | * - path_prefix - prefix for path output (optional, default empty)
25 | *
26 | *
27 | * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
28 | * (Smarty online manual)
29 | * @author Monte Ohrt
30 | * @author credits to Duda
31 | * @version 1.0
32 | * @param array $params parameters
33 | * @param Smarty_Internal_Template $template template object
34 | * @return string
35 | * @uses smarty_function_escape_special_chars()
36 | */
37 | function smarty_function_html_image($params, $template)
38 | {
39 | require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
40 |
41 | $alt = '';
42 | $file = '';
43 | $height = '';
44 | $width = '';
45 | $extra = '';
46 | $prefix = '';
47 | $suffix = '';
48 | $path_prefix = '';
49 | $server_vars = $_SERVER;
50 | $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
51 | foreach($params as $_key => $_val) {
52 | switch ($_key) {
53 | case 'file':
54 | case 'height':
55 | case 'width':
56 | case 'dpi':
57 | case 'path_prefix':
58 | case 'basedir':
59 | $$_key = $_val;
60 | break;
61 |
62 | case 'alt':
63 | if (!is_array($_val)) {
64 | $$_key = smarty_function_escape_special_chars($_val);
65 | } else {
66 | throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
67 | }
68 | break;
69 |
70 | case 'link':
71 | case 'href':
72 | $prefix = '';
73 | $suffix = '';
74 | break;
75 |
76 | default:
77 | if (!is_array($_val)) {
78 | $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
79 | } else {
80 | throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
81 | }
82 | break;
83 | }
84 | }
85 |
86 | if (empty($file)) {
87 | trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
88 | return;
89 | }
90 |
91 | if (substr($file, 0, 1) == '/') {
92 | $_image_path = $basedir . $file;
93 | } else {
94 | $_image_path = $file;
95 | }
96 |
97 | if (!isset($params['width']) || !isset($params['height'])) {
98 | if (!$_image_data = @getimagesize($_image_path)) {
99 | if (!file_exists($_image_path)) {
100 | trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
101 | return;
102 | } else if (!is_readable($_image_path)) {
103 | trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
104 | return;
105 | } else {
106 | trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
107 | return;
108 | }
109 | }
110 | if (isset($template->smarty->security_policy)) {
111 | if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
112 | return;
113 | }
114 | }
115 |
116 | if (!isset($params['width'])) {
117 | $width = $_image_data[0];
118 | }
119 | if (!isset($params['height'])) {
120 | $height = $_image_data[1];
121 | }
122 | }
123 |
124 | if (isset($params['dpi'])) {
125 | if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
126 | $dpi_default = 72;
127 | } else {
128 | $dpi_default = 96;
129 | }
130 | $_resize = $dpi_default / $params['dpi'];
131 | $width = round($width * $_resize);
132 | $height = round($height * $_resize);
133 | }
134 |
135 | return $prefix . '
' . $suffix;
136 | }
137 |
138 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_call.php:
--------------------------------------------------------------------------------
1 | getAttributes($compiler, $args);
54 | // save possible attributes
55 | if (isset($_attr['assign'])) {
56 | // output will be stored in a smarty variable instead of beind displayed
57 | $_assign = $_attr['assign'];
58 | }
59 | $_name = $_attr['name'];
60 | if ($compiler->compiles_template_function) {
61 | $compiler->called_functions[] = trim($_name, "'\"");
62 | }
63 | unset($_attr['name'], $_attr['assign'], $_attr['nocache']);
64 | // set flag (compiled code of {function} must be included in cache file
65 | if ($compiler->nocache || $compiler->tag_nocache) {
66 | $_nocache = 'true';
67 | } else {
68 | $_nocache = 'false';
69 | }
70 | $_paramsArray = array();
71 | foreach ($_attr as $_key => $_value) {
72 | if (is_int($_key)) {
73 | $_paramsArray[] = "$_key=>$_value";
74 | } else {
75 | $_paramsArray[] = "'$_key'=>$_value";
76 | }
77 | }
78 | if (isset($compiler->template->properties['function'][$_name]['parameter'])) {
79 | foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) {
80 | if (!isset($_attr[$_key])) {
81 | if (is_int($_key)) {
82 | $_paramsArray[] = "$_key=>$_value";
83 | } else {
84 | $_paramsArray[] = "'$_key'=>$_value";
85 | }
86 | }
87 | }
88 | } elseif (isset($compiler->smarty->template_functions[$_name]['parameter'])) {
89 | foreach ($compiler->smarty->template_functions[$_name]['parameter'] as $_key => $_value) {
90 | if (!isset($_attr[$_key])) {
91 | if (is_int($_key)) {
92 | $_paramsArray[] = "$_key=>$_value";
93 | } else {
94 | $_paramsArray[] = "'$_key'=>$_value";
95 | }
96 | }
97 | }
98 | }
99 | //varibale name?
100 | if (!(strpos($_name, '$') === false)) {
101 | $call_cache = $_name;
102 | $call_function = '$tmp = "smarty_template_function_".' . $_name . '; $tmp';
103 | } else {
104 | $_name = trim($_name, "'\"");
105 | $call_cache = "'{$_name}'";
106 | $call_function = 'smarty_template_function_' . $_name;
107 | }
108 |
109 | $_params = 'array(' . implode(",", $_paramsArray) . ')';
110 | $_hash = str_replace('-', '_', $compiler->template->properties['nocache_hash']);
111 | // was there an assign attribute
112 | if (isset($_assign)) {
113 | if ($compiler->template->caching) {
114 | $_output = "assign({$_assign}, ob_get_clean());?>\n";
115 | } else {
116 | $_output = "assign({$_assign}, ob_get_clean());?>\n";
117 | }
118 | } else {
119 | if ($compiler->template->caching) {
120 | $_output = "\n";
121 | } else {
122 | $_output = "\n";
123 | }
124 | }
125 | return $_output;
126 | }
127 |
128 | }
129 |
130 | ?>
--------------------------------------------------------------------------------
/test/libs/smarty-3.1.5/sysplugins/smarty_internal_compile_extends.php:
--------------------------------------------------------------------------------
1 | true, 'eval' => true);
46 | $this->_rdl = preg_quote($compiler->smarty->right_delimiter);
47 | $this->_ldl = preg_quote($compiler->smarty->left_delimiter);
48 | $filepath = $compiler->template->source->filepath;
49 | // check and get attributes
50 | $_attr = $this->getAttributes($compiler, $args);
51 | if ($_attr['nocache'] === true) {
52 | $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
53 | }
54 |
55 | $_smarty_tpl = $compiler->template;
56 | $include_file = null;
57 | if (strpos($_attr['file'], '$_tmp') !== false) {
58 | $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
59 | }
60 | eval('$include_file = ' . $_attr['file'] . ';');
61 | // create template object
62 | $_template = new $compiler->smarty->template_class($include_file, $compiler->smarty, $compiler->template);
63 | // save file dependency
64 | if (isset($_is_stringy[$_template->source->type])) {
65 | $template_sha1 = sha1($include_file);
66 | } else {
67 | $template_sha1 = sha1($_template->source->filepath);
68 | }
69 | if (isset($compiler->template->properties['file_dependency'][$template_sha1])) {
70 | $compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
71 | }
72 | $compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
73 | $_content = substr($compiler->template->source->content, $compiler->lex->counter - 1);
74 | if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
75 | preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
76 | $compiler->trigger_template_error('unmatched {block} {/block} pairs');
77 | }
78 | preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
79 | $_result_count = count($_result[0]);
80 | $_start = 0;
81 | while ($_start+1 < $_result_count) {
82 | $_end = 0;
83 | $_level = 1;
84 | if (substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
85 | $_start++;
86 | continue;
87 | }
88 | while ($_level != 0) {
89 | $_end++;
90 | if (substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
91 | continue;
92 | }
93 | if (!strpos($_result[0][$_start + $_end][0], '/')) {
94 | $_level++;
95 | } else {
96 | $_level--;
97 | }
98 | }
99 | $_block_content = str_replace($compiler->smarty->left_delimiter . '$smarty.block.parent' . $compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
100 | substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0])));
101 | Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
102 | $_start = $_start + $_end + 1;
103 | }
104 | if ($_template->source->type == 'extends') {
105 | $_template->block_data = $compiler->template->block_data;
106 | }
107 | $compiler->template->source->content = $_template->source->content;
108 | if ($_template->source->type == 'extends') {
109 | $compiler->template->block_data = $_template->block_data;
110 | foreach ($_template->source->components as $key => $component) {
111 | $compiler->template->properties['file_dependency'][$key] = array($component->filepath, $component->timestamp, $component->type);
112 | }
113 | }
114 | $compiler->template->source->filepath = $_template->source->filepath;
115 | $compiler->abort_and_recompile = true;
116 | return '';
117 | }
118 |
119 | }
120 |
121 | ?>
--------------------------------------------------------------------------------