@@ -192,6 +192,10 @@ |
||
| 192 | 192 | return $_html_result; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | +/** |
|
| 196 | + * @param string|null $id |
|
| 197 | + * @param integer $idx |
|
| 198 | + */ |
|
| 195 | 199 | function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx) |
| 196 | 200 | { |
| 197 | 201 | $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; |
@@ -35,170 +35,170 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | function smarty_function_html_options($params) |
| 37 | 37 | { |
| 38 | - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
| 39 | - |
|
| 40 | - $name = null; |
|
| 41 | - $values = null; |
|
| 42 | - $options = null; |
|
| 43 | - $selected = null; |
|
| 44 | - $output = null; |
|
| 45 | - $id = null; |
|
| 46 | - $class = null; |
|
| 47 | - |
|
| 48 | - $extra = ''; |
|
| 49 | - |
|
| 50 | - foreach ($params as $_key => $_val) { |
|
| 51 | - switch ($_key) { |
|
| 52 | - case 'name': |
|
| 53 | - case 'class': |
|
| 54 | - case 'id': |
|
| 55 | - $$_key = (string) $_val; |
|
| 56 | - break; |
|
| 57 | - |
|
| 58 | - case 'options': |
|
| 59 | - $options = (array) $_val; |
|
| 60 | - break; |
|
| 61 | - |
|
| 62 | - case 'values': |
|
| 63 | - case 'output': |
|
| 64 | - $$_key = array_values((array) $_val); |
|
| 65 | - break; |
|
| 66 | - |
|
| 67 | - case 'selected': |
|
| 68 | - if (is_array($_val)) { |
|
| 69 | - $selected = array(); |
|
| 70 | - foreach ($_val as $_sel) { |
|
| 71 | - if (is_object($_sel)) { |
|
| 72 | - if (method_exists($_sel, "__toString")) { |
|
| 73 | - $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); |
|
| 74 | - } else { |
|
| 75 | - trigger_error("html_options: selected attribute contains an object of class '" . |
|
| 76 | - get_class($_sel) . "' without __toString() method", E_USER_NOTICE); |
|
| 77 | - continue; |
|
| 78 | - } |
|
| 79 | - } else { |
|
| 80 | - $_sel = smarty_function_escape_special_chars((string) $_sel); |
|
| 81 | - } |
|
| 82 | - $selected[ $_sel ] = true; |
|
| 83 | - } |
|
| 84 | - } elseif (is_object($_val)) { |
|
| 85 | - if (method_exists($_val, "__toString")) { |
|
| 86 | - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); |
|
| 87 | - } else { |
|
| 88 | - trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) . |
|
| 89 | - "' without __toString() method", E_USER_NOTICE); |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - $selected = smarty_function_escape_special_chars((string) $_val); |
|
| 93 | - } |
|
| 94 | - break; |
|
| 95 | - |
|
| 96 | - case 'strict': |
|
| 97 | - break; |
|
| 98 | - |
|
| 99 | - case 'disabled': |
|
| 100 | - case 'readonly': |
|
| 101 | - if (!empty($params[ 'strict' ])) { |
|
| 102 | - if (!is_scalar($_val)) { |
|
| 103 | - trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
|
| 104 | - E_USER_NOTICE); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ($_val === true || $_val === $_key) { |
|
| 108 | - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - break; |
|
| 112 | - } |
|
| 113 | - // omit break; to fall through! |
|
| 114 | - |
|
| 115 | - default: |
|
| 116 | - if (!is_array($_val)) { |
|
| 117 | - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
| 118 | - } else { |
|
| 119 | - trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 120 | - } |
|
| 121 | - break; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if (!isset($options) && !isset($values)) { |
|
| 126 | - /* raise error here? */ |
|
| 127 | - |
|
| 128 | - return ''; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $_html_result = ''; |
|
| 132 | - $_idx = 0; |
|
| 133 | - |
|
| 134 | - if (isset($options)) { |
|
| 135 | - foreach ($options as $_key => $_val) { |
|
| 136 | - $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx); |
|
| 137 | - } |
|
| 138 | - } else { |
|
| 139 | - foreach ($values as $_i => $_key) { |
|
| 140 | - $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 141 | - $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (!empty($name)) { |
|
| 146 | - $_html_class = !empty($class) ? ' class="' . $class . '"' : ''; |
|
| 147 | - $_html_id = !empty($id) ? ' id="' . $id . '"' : ''; |
|
| 148 | - $_html_result = |
|
| 149 | - '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . |
|
| 150 | - '</select>' . "\n"; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return $_html_result; |
|
| 38 | + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
| 39 | + |
|
| 40 | + $name = null; |
|
| 41 | + $values = null; |
|
| 42 | + $options = null; |
|
| 43 | + $selected = null; |
|
| 44 | + $output = null; |
|
| 45 | + $id = null; |
|
| 46 | + $class = null; |
|
| 47 | + |
|
| 48 | + $extra = ''; |
|
| 49 | + |
|
| 50 | + foreach ($params as $_key => $_val) { |
|
| 51 | + switch ($_key) { |
|
| 52 | + case 'name': |
|
| 53 | + case 'class': |
|
| 54 | + case 'id': |
|
| 55 | + $$_key = (string) $_val; |
|
| 56 | + break; |
|
| 57 | + |
|
| 58 | + case 'options': |
|
| 59 | + $options = (array) $_val; |
|
| 60 | + break; |
|
| 61 | + |
|
| 62 | + case 'values': |
|
| 63 | + case 'output': |
|
| 64 | + $$_key = array_values((array) $_val); |
|
| 65 | + break; |
|
| 66 | + |
|
| 67 | + case 'selected': |
|
| 68 | + if (is_array($_val)) { |
|
| 69 | + $selected = array(); |
|
| 70 | + foreach ($_val as $_sel) { |
|
| 71 | + if (is_object($_sel)) { |
|
| 72 | + if (method_exists($_sel, "__toString")) { |
|
| 73 | + $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); |
|
| 74 | + } else { |
|
| 75 | + trigger_error("html_options: selected attribute contains an object of class '" . |
|
| 76 | + get_class($_sel) . "' without __toString() method", E_USER_NOTICE); |
|
| 77 | + continue; |
|
| 78 | + } |
|
| 79 | + } else { |
|
| 80 | + $_sel = smarty_function_escape_special_chars((string) $_sel); |
|
| 81 | + } |
|
| 82 | + $selected[ $_sel ] = true; |
|
| 83 | + } |
|
| 84 | + } elseif (is_object($_val)) { |
|
| 85 | + if (method_exists($_val, "__toString")) { |
|
| 86 | + $selected = smarty_function_escape_special_chars((string) $_val->__toString()); |
|
| 87 | + } else { |
|
| 88 | + trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) . |
|
| 89 | + "' without __toString() method", E_USER_NOTICE); |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + $selected = smarty_function_escape_special_chars((string) $_val); |
|
| 93 | + } |
|
| 94 | + break; |
|
| 95 | + |
|
| 96 | + case 'strict': |
|
| 97 | + break; |
|
| 98 | + |
|
| 99 | + case 'disabled': |
|
| 100 | + case 'readonly': |
|
| 101 | + if (!empty($params[ 'strict' ])) { |
|
| 102 | + if (!is_scalar($_val)) { |
|
| 103 | + trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
|
| 104 | + E_USER_NOTICE); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ($_val === true || $_val === $_key) { |
|
| 108 | + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + break; |
|
| 112 | + } |
|
| 113 | + // omit break; to fall through! |
|
| 114 | + |
|
| 115 | + default: |
|
| 116 | + if (!is_array($_val)) { |
|
| 117 | + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
| 118 | + } else { |
|
| 119 | + trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 120 | + } |
|
| 121 | + break; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if (!isset($options) && !isset($values)) { |
|
| 126 | + /* raise error here? */ |
|
| 127 | + |
|
| 128 | + return ''; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $_html_result = ''; |
|
| 132 | + $_idx = 0; |
|
| 133 | + |
|
| 134 | + if (isset($options)) { |
|
| 135 | + foreach ($options as $_key => $_val) { |
|
| 136 | + $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx); |
|
| 137 | + } |
|
| 138 | + } else { |
|
| 139 | + foreach ($values as $_i => $_key) { |
|
| 140 | + $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 141 | + $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (!empty($name)) { |
|
| 146 | + $_html_class = !empty($class) ? ' class="' . $class . '"' : ''; |
|
| 147 | + $_html_id = !empty($id) ? ' id="' . $id . '"' : ''; |
|
| 148 | + $_html_result = |
|
| 149 | + '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . |
|
| 150 | + '</select>' . "\n"; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return $_html_result; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx) |
| 157 | 157 | { |
| 158 | - if (!is_array($value)) { |
|
| 159 | - $_key = smarty_function_escape_special_chars($key); |
|
| 160 | - $_html_result = '<option value="' . $_key . '"'; |
|
| 161 | - if (is_array($selected)) { |
|
| 162 | - if (isset($selected[ $_key ])) { |
|
| 163 | - $_html_result .= ' selected="selected"'; |
|
| 164 | - } |
|
| 165 | - } elseif ($_key === $selected) { |
|
| 166 | - $_html_result .= ' selected="selected"'; |
|
| 167 | - } |
|
| 168 | - $_html_class = !empty($class) ? ' class="' . $class . ' option"' : ''; |
|
| 169 | - $_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : ''; |
|
| 170 | - if (is_object($value)) { |
|
| 171 | - if (method_exists($value, "__toString")) { |
|
| 172 | - $value = smarty_function_escape_special_chars((string) $value->__toString()); |
|
| 173 | - } else { |
|
| 174 | - trigger_error("html_options: value is an object of class '" . get_class($value) . |
|
| 175 | - "' without __toString() method", E_USER_NOTICE); |
|
| 176 | - |
|
| 177 | - return ''; |
|
| 178 | - } |
|
| 179 | - } else { |
|
| 180 | - $value = smarty_function_escape_special_chars((string) $value); |
|
| 181 | - } |
|
| 182 | - $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; |
|
| 183 | - $idx ++; |
|
| 184 | - } else { |
|
| 185 | - $_idx = 0; |
|
| 186 | - $_html_result = |
|
| 187 | - smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, |
|
| 188 | - $class, $_idx); |
|
| 189 | - $idx ++; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $_html_result; |
|
| 158 | + if (!is_array($value)) { |
|
| 159 | + $_key = smarty_function_escape_special_chars($key); |
|
| 160 | + $_html_result = '<option value="' . $_key . '"'; |
|
| 161 | + if (is_array($selected)) { |
|
| 162 | + if (isset($selected[ $_key ])) { |
|
| 163 | + $_html_result .= ' selected="selected"'; |
|
| 164 | + } |
|
| 165 | + } elseif ($_key === $selected) { |
|
| 166 | + $_html_result .= ' selected="selected"'; |
|
| 167 | + } |
|
| 168 | + $_html_class = !empty($class) ? ' class="' . $class . ' option"' : ''; |
|
| 169 | + $_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : ''; |
|
| 170 | + if (is_object($value)) { |
|
| 171 | + if (method_exists($value, "__toString")) { |
|
| 172 | + $value = smarty_function_escape_special_chars((string) $value->__toString()); |
|
| 173 | + } else { |
|
| 174 | + trigger_error("html_options: value is an object of class '" . get_class($value) . |
|
| 175 | + "' without __toString() method", E_USER_NOTICE); |
|
| 176 | + |
|
| 177 | + return ''; |
|
| 178 | + } |
|
| 179 | + } else { |
|
| 180 | + $value = smarty_function_escape_special_chars((string) $value); |
|
| 181 | + } |
|
| 182 | + $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; |
|
| 183 | + $idx ++; |
|
| 184 | + } else { |
|
| 185 | + $_idx = 0; |
|
| 186 | + $_html_result = |
|
| 187 | + smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, |
|
| 188 | + $class, $_idx); |
|
| 189 | + $idx ++; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $_html_result; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx) |
| 196 | 196 | { |
| 197 | - $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; |
|
| 198 | - foreach ($values as $key => $value) { |
|
| 199 | - $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx); |
|
| 200 | - } |
|
| 201 | - $optgroup_html .= "</optgroup>\n"; |
|
| 197 | + $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n"; |
|
| 198 | + foreach ($values as $key => $value) { |
|
| 199 | + $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx); |
|
| 200 | + } |
|
| 201 | + $optgroup_html .= "</optgroup>\n"; |
|
| 202 | 202 | |
| 203 | - return $optgroup_html; |
|
| 203 | + return $optgroup_html; |
|
| 204 | 204 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } else { |
| 80 | 80 | $_sel = smarty_function_escape_special_chars((string) $_sel); |
| 81 | 81 | } |
| 82 | - $selected[ $_sel ] = true; |
|
| 82 | + $selected[$_sel] = true; |
|
| 83 | 83 | } |
| 84 | 84 | } elseif (is_object($_val)) { |
| 85 | 85 | if (method_exists($_val, "__toString")) { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | case 'disabled': |
| 100 | 100 | case 'readonly': |
| 101 | - if (!empty($params[ 'strict' ])) { |
|
| 101 | + if (!empty($params['strict'])) { |
|
| 102 | 102 | if (!is_scalar($_val)) { |
| 103 | 103 | trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
| 104 | 104 | E_USER_NOTICE); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | } else { |
| 139 | 139 | foreach ($values as $_i => $_key) { |
| 140 | - $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 140 | + $_val = isset($output[$_i]) ? $output[$_i] : ''; |
|
| 141 | 141 | $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $_key = smarty_function_escape_special_chars($key); |
| 160 | 160 | $_html_result = '<option value="' . $_key . '"'; |
| 161 | 161 | if (is_array($selected)) { |
| 162 | - if (isset($selected[ $_key ])) { |
|
| 162 | + if (isset($selected[$_key])) { |
|
| 163 | 163 | $_html_result .= ' selected="selected"'; |
| 164 | 164 | } |
| 165 | 165 | } elseif ($_key === $selected) { |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | $value = smarty_function_escape_special_chars((string) $value); |
| 181 | 181 | } |
| 182 | 182 | $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; |
| 183 | - $idx ++; |
|
| 183 | + $idx++; |
|
| 184 | 184 | } else { |
| 185 | 185 | $_idx = 0; |
| 186 | 186 | $_html_result = |
| 187 | 187 | smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, |
| 188 | 188 | $class, $_idx); |
| 189 | - $idx ++; |
|
| 189 | + $idx++; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return $_html_result; |
@@ -164,6 +164,14 @@ |
||
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | +/** |
|
| 168 | + * @param string $name |
|
| 169 | + * @param string $extra |
|
| 170 | + * @param string $separator |
|
| 171 | + * @param boolean $labels |
|
| 172 | + * @param boolean $label_ids |
|
| 173 | + * @param boolean $escape |
|
| 174 | + */ |
|
| 167 | 175 | function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, |
| 168 | 176 | $escape) |
| 169 | 177 | { |
@@ -45,188 +45,188 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | function smarty_function_html_radios($params, $template) |
| 47 | 47 | { |
| 48 | - require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
| 49 | - |
|
| 50 | - $name = 'radio'; |
|
| 51 | - $values = null; |
|
| 52 | - $options = null; |
|
| 53 | - $selected = null; |
|
| 54 | - $separator = ''; |
|
| 55 | - $escape = true; |
|
| 56 | - $labels = true; |
|
| 57 | - $label_ids = false; |
|
| 58 | - $output = null; |
|
| 59 | - $extra = ''; |
|
| 60 | - |
|
| 61 | - foreach ($params as $_key => $_val) { |
|
| 62 | - switch ($_key) { |
|
| 63 | - case 'name': |
|
| 64 | - case 'separator': |
|
| 65 | - $$_key = (string) $_val; |
|
| 66 | - break; |
|
| 67 | - |
|
| 68 | - case 'checked': |
|
| 69 | - case 'selected': |
|
| 70 | - if (is_array($_val)) { |
|
| 71 | - trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); |
|
| 72 | - } elseif (is_object($_val)) { |
|
| 73 | - if (method_exists($_val, "__toString")) { |
|
| 74 | - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); |
|
| 75 | - } else { |
|
| 76 | - trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . |
|
| 77 | - "' without __toString() method", E_USER_NOTICE); |
|
| 78 | - } |
|
| 79 | - } else { |
|
| 80 | - $selected = (string) $_val; |
|
| 81 | - } |
|
| 82 | - break; |
|
| 83 | - |
|
| 84 | - case 'escape': |
|
| 85 | - case 'labels': |
|
| 86 | - case 'label_ids': |
|
| 87 | - $$_key = (bool) $_val; |
|
| 88 | - break; |
|
| 89 | - |
|
| 90 | - case 'options': |
|
| 91 | - $$_key = (array) $_val; |
|
| 92 | - break; |
|
| 93 | - |
|
| 94 | - case 'values': |
|
| 95 | - case 'output': |
|
| 96 | - $$_key = array_values((array) $_val); |
|
| 97 | - break; |
|
| 98 | - |
|
| 99 | - case 'radios': |
|
| 100 | - trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', |
|
| 101 | - E_USER_WARNING); |
|
| 102 | - $options = (array) $_val; |
|
| 103 | - break; |
|
| 104 | - |
|
| 105 | - case 'assign': |
|
| 106 | - break; |
|
| 107 | - |
|
| 108 | - case 'strict': |
|
| 109 | - break; |
|
| 110 | - |
|
| 111 | - case 'disabled': |
|
| 112 | - case 'readonly': |
|
| 113 | - if (!empty($params[ 'strict' ])) { |
|
| 114 | - if (!is_scalar($_val)) { |
|
| 115 | - trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
|
| 116 | - E_USER_NOTICE); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($_val === true || $_val === $_key) { |
|
| 120 | - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - break; |
|
| 124 | - } |
|
| 125 | - // omit break; to fall through! |
|
| 126 | - |
|
| 127 | - default: |
|
| 128 | - if (!is_array($_val)) { |
|
| 129 | - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
| 130 | - } else { |
|
| 131 | - trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 132 | - } |
|
| 133 | - break; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - if (!isset($options) && !isset($values)) { |
|
| 138 | - /* raise error here? */ |
|
| 139 | - |
|
| 140 | - return ''; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $_html_result = array(); |
|
| 144 | - |
|
| 145 | - if (isset($options)) { |
|
| 146 | - foreach ($options as $_key => $_val) { |
|
| 147 | - $_html_result[] = |
|
| 148 | - smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, |
|
| 149 | - $label_ids, $escape); |
|
| 150 | - } |
|
| 151 | - } else { |
|
| 152 | - foreach ($values as $_i => $_key) { |
|
| 153 | - $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 154 | - $_html_result[] = |
|
| 155 | - smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, |
|
| 156 | - $label_ids, $escape); |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if (!empty($params[ 'assign' ])) { |
|
| 161 | - $template->assign($params[ 'assign' ], $_html_result); |
|
| 162 | - } else { |
|
| 163 | - return implode("\n", $_html_result); |
|
| 164 | - } |
|
| 48 | + require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); |
|
| 49 | + |
|
| 50 | + $name = 'radio'; |
|
| 51 | + $values = null; |
|
| 52 | + $options = null; |
|
| 53 | + $selected = null; |
|
| 54 | + $separator = ''; |
|
| 55 | + $escape = true; |
|
| 56 | + $labels = true; |
|
| 57 | + $label_ids = false; |
|
| 58 | + $output = null; |
|
| 59 | + $extra = ''; |
|
| 60 | + |
|
| 61 | + foreach ($params as $_key => $_val) { |
|
| 62 | + switch ($_key) { |
|
| 63 | + case 'name': |
|
| 64 | + case 'separator': |
|
| 65 | + $$_key = (string) $_val; |
|
| 66 | + break; |
|
| 67 | + |
|
| 68 | + case 'checked': |
|
| 69 | + case 'selected': |
|
| 70 | + if (is_array($_val)) { |
|
| 71 | + trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING); |
|
| 72 | + } elseif (is_object($_val)) { |
|
| 73 | + if (method_exists($_val, "__toString")) { |
|
| 74 | + $selected = smarty_function_escape_special_chars((string) $_val->__toString()); |
|
| 75 | + } else { |
|
| 76 | + trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . |
|
| 77 | + "' without __toString() method", E_USER_NOTICE); |
|
| 78 | + } |
|
| 79 | + } else { |
|
| 80 | + $selected = (string) $_val; |
|
| 81 | + } |
|
| 82 | + break; |
|
| 83 | + |
|
| 84 | + case 'escape': |
|
| 85 | + case 'labels': |
|
| 86 | + case 'label_ids': |
|
| 87 | + $$_key = (bool) $_val; |
|
| 88 | + break; |
|
| 89 | + |
|
| 90 | + case 'options': |
|
| 91 | + $$_key = (array) $_val; |
|
| 92 | + break; |
|
| 93 | + |
|
| 94 | + case 'values': |
|
| 95 | + case 'output': |
|
| 96 | + $$_key = array_values((array) $_val); |
|
| 97 | + break; |
|
| 98 | + |
|
| 99 | + case 'radios': |
|
| 100 | + trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', |
|
| 101 | + E_USER_WARNING); |
|
| 102 | + $options = (array) $_val; |
|
| 103 | + break; |
|
| 104 | + |
|
| 105 | + case 'assign': |
|
| 106 | + break; |
|
| 107 | + |
|
| 108 | + case 'strict': |
|
| 109 | + break; |
|
| 110 | + |
|
| 111 | + case 'disabled': |
|
| 112 | + case 'readonly': |
|
| 113 | + if (!empty($params[ 'strict' ])) { |
|
| 114 | + if (!is_scalar($_val)) { |
|
| 115 | + trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
|
| 116 | + E_USER_NOTICE); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($_val === true || $_val === $_key) { |
|
| 120 | + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + break; |
|
| 124 | + } |
|
| 125 | + // omit break; to fall through! |
|
| 126 | + |
|
| 127 | + default: |
|
| 128 | + if (!is_array($_val)) { |
|
| 129 | + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; |
|
| 130 | + } else { |
|
| 131 | + trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE); |
|
| 132 | + } |
|
| 133 | + break; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + if (!isset($options) && !isset($values)) { |
|
| 138 | + /* raise error here? */ |
|
| 139 | + |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $_html_result = array(); |
|
| 144 | + |
|
| 145 | + if (isset($options)) { |
|
| 146 | + foreach ($options as $_key => $_val) { |
|
| 147 | + $_html_result[] = |
|
| 148 | + smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, |
|
| 149 | + $label_ids, $escape); |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + foreach ($values as $_i => $_key) { |
|
| 153 | + $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 154 | + $_html_result[] = |
|
| 155 | + smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, |
|
| 156 | + $label_ids, $escape); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if (!empty($params[ 'assign' ])) { |
|
| 161 | + $template->assign($params[ 'assign' ], $_html_result); |
|
| 162 | + } else { |
|
| 163 | + return implode("\n", $_html_result); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, |
| 168 | - $escape) |
|
| 168 | + $escape) |
|
| 169 | 169 | { |
| 170 | - $_output = ''; |
|
| 171 | - |
|
| 172 | - if (is_object($value)) { |
|
| 173 | - if (method_exists($value, "__toString")) { |
|
| 174 | - $value = (string) $value->__toString(); |
|
| 175 | - } else { |
|
| 176 | - trigger_error("html_options: value is an object of class '" . get_class($value) . |
|
| 177 | - "' without __toString() method", E_USER_NOTICE); |
|
| 178 | - |
|
| 179 | - return ''; |
|
| 180 | - } |
|
| 181 | - } else { |
|
| 182 | - $value = (string) $value; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - if (is_object($output)) { |
|
| 186 | - if (method_exists($output, "__toString")) { |
|
| 187 | - $output = (string) $output->__toString(); |
|
| 188 | - } else { |
|
| 189 | - trigger_error("html_options: output is an object of class '" . get_class($output) . |
|
| 190 | - "' without __toString() method", E_USER_NOTICE); |
|
| 191 | - |
|
| 192 | - return ''; |
|
| 193 | - } |
|
| 194 | - } else { |
|
| 195 | - $output = (string) $output; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - if ($labels) { |
|
| 199 | - if ($label_ids) { |
|
| 200 | - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', |
|
| 201 | - $name . '_' . $value)); |
|
| 202 | - $_output .= '<label for="' . $_id . '">'; |
|
| 203 | - } else { |
|
| 204 | - $_output .= '<label>'; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $name = smarty_function_escape_special_chars($name); |
|
| 209 | - $value = smarty_function_escape_special_chars($value); |
|
| 210 | - if ($escape) { |
|
| 211 | - $output = smarty_function_escape_special_chars($output); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"'; |
|
| 215 | - |
|
| 216 | - if ($labels && $label_ids) { |
|
| 217 | - $_output .= ' id="' . $_id . '"'; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - if ($value === $selected) { |
|
| 221 | - $_output .= ' checked="checked"'; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - $_output .= $extra . ' />' . $output; |
|
| 225 | - if ($labels) { |
|
| 226 | - $_output .= '</label>'; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $_output .= $separator; |
|
| 230 | - |
|
| 231 | - return $_output; |
|
| 170 | + $_output = ''; |
|
| 171 | + |
|
| 172 | + if (is_object($value)) { |
|
| 173 | + if (method_exists($value, "__toString")) { |
|
| 174 | + $value = (string) $value->__toString(); |
|
| 175 | + } else { |
|
| 176 | + trigger_error("html_options: value is an object of class '" . get_class($value) . |
|
| 177 | + "' without __toString() method", E_USER_NOTICE); |
|
| 178 | + |
|
| 179 | + return ''; |
|
| 180 | + } |
|
| 181 | + } else { |
|
| 182 | + $value = (string) $value; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + if (is_object($output)) { |
|
| 186 | + if (method_exists($output, "__toString")) { |
|
| 187 | + $output = (string) $output->__toString(); |
|
| 188 | + } else { |
|
| 189 | + trigger_error("html_options: output is an object of class '" . get_class($output) . |
|
| 190 | + "' without __toString() method", E_USER_NOTICE); |
|
| 191 | + |
|
| 192 | + return ''; |
|
| 193 | + } |
|
| 194 | + } else { |
|
| 195 | + $output = (string) $output; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + if ($labels) { |
|
| 199 | + if ($label_ids) { |
|
| 200 | + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', |
|
| 201 | + $name . '_' . $value)); |
|
| 202 | + $_output .= '<label for="' . $_id . '">'; |
|
| 203 | + } else { |
|
| 204 | + $_output .= '<label>'; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $name = smarty_function_escape_special_chars($name); |
|
| 209 | + $value = smarty_function_escape_special_chars($value); |
|
| 210 | + if ($escape) { |
|
| 211 | + $output = smarty_function_escape_special_chars($output); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"'; |
|
| 215 | + |
|
| 216 | + if ($labels && $label_ids) { |
|
| 217 | + $_output .= ' id="' . $_id . '"'; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + if ($value === $selected) { |
|
| 221 | + $_output .= ' checked="checked"'; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + $_output .= $extra . ' />' . $output; |
|
| 225 | + if ($labels) { |
|
| 226 | + $_output .= '</label>'; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $_output .= $separator; |
|
| 230 | + |
|
| 231 | + return $_output; |
|
| 232 | 232 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | case 'disabled': |
| 112 | 112 | case 'readonly': |
| 113 | - if (!empty($params[ 'strict' ])) { |
|
| 113 | + if (!empty($params['strict'])) { |
|
| 114 | 114 | if (!is_scalar($_val)) { |
| 115 | 115 | trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", |
| 116 | 116 | E_USER_NOTICE); |
@@ -150,15 +150,15 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | } else { |
| 152 | 152 | foreach ($values as $_i => $_key) { |
| 153 | - $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; |
|
| 153 | + $_val = isset($output[$_i]) ? $output[$_i] : ''; |
|
| 154 | 154 | $_html_result[] = |
| 155 | 155 | smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, |
| 156 | 156 | $label_ids, $escape); |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if (!empty($params[ 'assign' ])) { |
|
| 161 | - $template->assign($params[ 'assign' ], $_html_result); |
|
| 160 | + if (!empty($params['assign'])) { |
|
| 161 | + $template->assign($params['assign'], $_html_result); |
|
| 162 | 162 | } else { |
| 163 | 163 | return implode("\n", $_html_result); |
| 164 | 164 | } |
@@ -164,6 +164,10 @@ |
||
| 164 | 164 | return $output; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | +/** |
|
| 168 | + * @param string $name |
|
| 169 | + * @param string $var |
|
| 170 | + */ |
|
| 167 | 171 | function smarty_function_html_table_cycle($name, $var, $no) |
| 168 | 172 | { |
| 169 | 173 | if (!is_array($var)) { |
@@ -49,128 +49,128 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | function smarty_function_html_table($params) |
| 51 | 51 | { |
| 52 | - $table_attr = 'border="1"'; |
|
| 53 | - $tr_attr = ''; |
|
| 54 | - $th_attr = ''; |
|
| 55 | - $td_attr = ''; |
|
| 56 | - $cols = $cols_count = 3; |
|
| 57 | - $rows = 3; |
|
| 58 | - $trailpad = ' '; |
|
| 59 | - $vdir = 'down'; |
|
| 60 | - $hdir = 'right'; |
|
| 61 | - $inner = 'cols'; |
|
| 62 | - $caption = ''; |
|
| 63 | - $loop = null; |
|
| 64 | - |
|
| 65 | - if (!isset($params[ 'loop' ])) { |
|
| 66 | - trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING); |
|
| 67 | - |
|
| 68 | - return; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - foreach ($params as $_key => $_value) { |
|
| 72 | - switch ($_key) { |
|
| 73 | - case 'loop': |
|
| 74 | - $$_key = (array) $_value; |
|
| 75 | - break; |
|
| 76 | - |
|
| 77 | - case 'cols': |
|
| 78 | - if (is_array($_value) && !empty($_value)) { |
|
| 79 | - $cols = $_value; |
|
| 80 | - $cols_count = count($_value); |
|
| 81 | - } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) { |
|
| 82 | - $cols = explode(',', $_value); |
|
| 83 | - $cols_count = count($cols); |
|
| 84 | - } elseif (!empty($_value)) { |
|
| 85 | - $cols_count = (int) $_value; |
|
| 86 | - } else { |
|
| 87 | - $cols_count = $cols; |
|
| 88 | - } |
|
| 89 | - break; |
|
| 90 | - |
|
| 91 | - case 'rows': |
|
| 92 | - $$_key = (int) $_value; |
|
| 93 | - break; |
|
| 94 | - |
|
| 95 | - case 'table_attr': |
|
| 96 | - case 'trailpad': |
|
| 97 | - case 'hdir': |
|
| 98 | - case 'vdir': |
|
| 99 | - case 'inner': |
|
| 100 | - case 'caption': |
|
| 101 | - $$_key = (string) $_value; |
|
| 102 | - break; |
|
| 103 | - |
|
| 104 | - case 'tr_attr': |
|
| 105 | - case 'td_attr': |
|
| 106 | - case 'th_attr': |
|
| 107 | - $$_key = $_value; |
|
| 108 | - break; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $loop_count = count($loop); |
|
| 113 | - if (empty($params[ 'rows' ])) { |
|
| 114 | - /* no rows specified */ |
|
| 115 | - $rows = ceil($loop_count / $cols_count); |
|
| 116 | - } elseif (empty($params[ 'cols' ])) { |
|
| 117 | - if (!empty($params[ 'rows' ])) { |
|
| 118 | - /* no cols specified, but rows */ |
|
| 119 | - $cols_count = ceil($loop_count / $rows); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $output = "<table $table_attr>\n"; |
|
| 124 | - |
|
| 125 | - if (!empty($caption)) { |
|
| 126 | - $output .= '<caption>' . $caption . "</caption>\n"; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if (is_array($cols)) { |
|
| 130 | - $cols = ($hdir == 'right') ? $cols : array_reverse($cols); |
|
| 131 | - $output .= "<thead><tr>\n"; |
|
| 132 | - |
|
| 133 | - for ($r = 0; $r < $cols_count; $r ++) { |
|
| 134 | - $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; |
|
| 135 | - $output .= $cols[ $r ]; |
|
| 136 | - $output .= "</th>\n"; |
|
| 137 | - } |
|
| 138 | - $output .= "</tr></thead>\n"; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - $output .= "<tbody>\n"; |
|
| 142 | - for ($r = 0; $r < $rows; $r ++) { |
|
| 143 | - $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; |
|
| 144 | - $rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count; |
|
| 145 | - |
|
| 146 | - for ($c = 0; $c < $cols_count; $c ++) { |
|
| 147 | - $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c; |
|
| 148 | - if ($inner != 'cols') { |
|
| 149 | - /* shuffle x to loop over rows*/ |
|
| 150 | - $x = floor($x / $cols_count) + ($x % $cols_count) * $rows; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if ($x < $loop_count) { |
|
| 154 | - $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n"; |
|
| 155 | - } else { |
|
| 156 | - $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n"; |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - $output .= "</tr>\n"; |
|
| 160 | - } |
|
| 161 | - $output .= "</tbody>\n"; |
|
| 162 | - $output .= "</table>\n"; |
|
| 163 | - |
|
| 164 | - return $output; |
|
| 52 | + $table_attr = 'border="1"'; |
|
| 53 | + $tr_attr = ''; |
|
| 54 | + $th_attr = ''; |
|
| 55 | + $td_attr = ''; |
|
| 56 | + $cols = $cols_count = 3; |
|
| 57 | + $rows = 3; |
|
| 58 | + $trailpad = ' '; |
|
| 59 | + $vdir = 'down'; |
|
| 60 | + $hdir = 'right'; |
|
| 61 | + $inner = 'cols'; |
|
| 62 | + $caption = ''; |
|
| 63 | + $loop = null; |
|
| 64 | + |
|
| 65 | + if (!isset($params[ 'loop' ])) { |
|
| 66 | + trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING); |
|
| 67 | + |
|
| 68 | + return; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + foreach ($params as $_key => $_value) { |
|
| 72 | + switch ($_key) { |
|
| 73 | + case 'loop': |
|
| 74 | + $$_key = (array) $_value; |
|
| 75 | + break; |
|
| 76 | + |
|
| 77 | + case 'cols': |
|
| 78 | + if (is_array($_value) && !empty($_value)) { |
|
| 79 | + $cols = $_value; |
|
| 80 | + $cols_count = count($_value); |
|
| 81 | + } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) { |
|
| 82 | + $cols = explode(',', $_value); |
|
| 83 | + $cols_count = count($cols); |
|
| 84 | + } elseif (!empty($_value)) { |
|
| 85 | + $cols_count = (int) $_value; |
|
| 86 | + } else { |
|
| 87 | + $cols_count = $cols; |
|
| 88 | + } |
|
| 89 | + break; |
|
| 90 | + |
|
| 91 | + case 'rows': |
|
| 92 | + $$_key = (int) $_value; |
|
| 93 | + break; |
|
| 94 | + |
|
| 95 | + case 'table_attr': |
|
| 96 | + case 'trailpad': |
|
| 97 | + case 'hdir': |
|
| 98 | + case 'vdir': |
|
| 99 | + case 'inner': |
|
| 100 | + case 'caption': |
|
| 101 | + $$_key = (string) $_value; |
|
| 102 | + break; |
|
| 103 | + |
|
| 104 | + case 'tr_attr': |
|
| 105 | + case 'td_attr': |
|
| 106 | + case 'th_attr': |
|
| 107 | + $$_key = $_value; |
|
| 108 | + break; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $loop_count = count($loop); |
|
| 113 | + if (empty($params[ 'rows' ])) { |
|
| 114 | + /* no rows specified */ |
|
| 115 | + $rows = ceil($loop_count / $cols_count); |
|
| 116 | + } elseif (empty($params[ 'cols' ])) { |
|
| 117 | + if (!empty($params[ 'rows' ])) { |
|
| 118 | + /* no cols specified, but rows */ |
|
| 119 | + $cols_count = ceil($loop_count / $rows); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $output = "<table $table_attr>\n"; |
|
| 124 | + |
|
| 125 | + if (!empty($caption)) { |
|
| 126 | + $output .= '<caption>' . $caption . "</caption>\n"; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if (is_array($cols)) { |
|
| 130 | + $cols = ($hdir == 'right') ? $cols : array_reverse($cols); |
|
| 131 | + $output .= "<thead><tr>\n"; |
|
| 132 | + |
|
| 133 | + for ($r = 0; $r < $cols_count; $r ++) { |
|
| 134 | + $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; |
|
| 135 | + $output .= $cols[ $r ]; |
|
| 136 | + $output .= "</th>\n"; |
|
| 137 | + } |
|
| 138 | + $output .= "</tr></thead>\n"; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + $output .= "<tbody>\n"; |
|
| 142 | + for ($r = 0; $r < $rows; $r ++) { |
|
| 143 | + $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; |
|
| 144 | + $rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count; |
|
| 145 | + |
|
| 146 | + for ($c = 0; $c < $cols_count; $c ++) { |
|
| 147 | + $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c; |
|
| 148 | + if ($inner != 'cols') { |
|
| 149 | + /* shuffle x to loop over rows*/ |
|
| 150 | + $x = floor($x / $cols_count) + ($x % $cols_count) * $rows; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if ($x < $loop_count) { |
|
| 154 | + $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n"; |
|
| 155 | + } else { |
|
| 156 | + $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n"; |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + $output .= "</tr>\n"; |
|
| 160 | + } |
|
| 161 | + $output .= "</tbody>\n"; |
|
| 162 | + $output .= "</table>\n"; |
|
| 163 | + |
|
| 164 | + return $output; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function smarty_function_html_table_cycle($name, $var, $no) |
| 168 | 168 | { |
| 169 | - if (!is_array($var)) { |
|
| 170 | - $ret = $var; |
|
| 171 | - } else { |
|
| 172 | - $ret = $var[ $no % count($var) ]; |
|
| 173 | - } |
|
| 169 | + if (!is_array($var)) { |
|
| 170 | + $ret = $var; |
|
| 171 | + } else { |
|
| 172 | + $ret = $var[ $no % count($var) ]; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return ($ret) ? ' ' . $ret : ''; |
|
| 175 | + return ($ret) ? ' ' . $ret : ''; |
|
| 176 | 176 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $caption = ''; |
| 63 | 63 | $loop = null; |
| 64 | 64 | |
| 65 | - if (!isset($params[ 'loop' ])) { |
|
| 65 | + if (!isset($params['loop'])) { |
|
| 66 | 66 | trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING); |
| 67 | 67 | |
| 68 | 68 | return; |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $loop_count = count($loop); |
| 113 | - if (empty($params[ 'rows' ])) { |
|
| 113 | + if (empty($params['rows'])) { |
|
| 114 | 114 | /* no rows specified */ |
| 115 | 115 | $rows = ceil($loop_count / $cols_count); |
| 116 | - } elseif (empty($params[ 'cols' ])) { |
|
| 117 | - if (!empty($params[ 'rows' ])) { |
|
| 116 | + } elseif (empty($params['cols'])) { |
|
| 117 | + if (!empty($params['rows'])) { |
|
| 118 | 118 | /* no cols specified, but rows */ |
| 119 | 119 | $cols_count = ceil($loop_count / $rows); |
| 120 | 120 | } |
@@ -130,20 +130,20 @@ discard block |
||
| 130 | 130 | $cols = ($hdir == 'right') ? $cols : array_reverse($cols); |
| 131 | 131 | $output .= "<thead><tr>\n"; |
| 132 | 132 | |
| 133 | - for ($r = 0; $r < $cols_count; $r ++) { |
|
| 133 | + for ($r = 0; $r < $cols_count; $r++) { |
|
| 134 | 134 | $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; |
| 135 | - $output .= $cols[ $r ]; |
|
| 135 | + $output .= $cols[$r]; |
|
| 136 | 136 | $output .= "</th>\n"; |
| 137 | 137 | } |
| 138 | 138 | $output .= "</tr></thead>\n"; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $output .= "<tbody>\n"; |
| 142 | - for ($r = 0; $r < $rows; $r ++) { |
|
| 142 | + for ($r = 0; $r < $rows; $r++) { |
|
| 143 | 143 | $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; |
| 144 | 144 | $rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count; |
| 145 | 145 | |
| 146 | - for ($c = 0; $c < $cols_count; $c ++) { |
|
| 146 | + for ($c = 0; $c < $cols_count; $c++) { |
|
| 147 | 147 | $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c; |
| 148 | 148 | if ($inner != 'cols') { |
| 149 | 149 | /* shuffle x to loop over rows*/ |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ($x < $loop_count) { |
| 154 | - $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[ $x ] . "</td>\n"; |
|
| 154 | + $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n"; |
|
| 155 | 155 | } else { |
| 156 | 156 | $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n"; |
| 157 | 157 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | if (!is_array($var)) { |
| 170 | 170 | $ret = $var; |
| 171 | 171 | } else { |
| 172 | - $ret = $var[ $no % count($var) ]; |
|
| 172 | + $ret = $var[$no % count($var)]; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return ($ret) ? ' ' . $ret : ''; |
@@ -1159,7 +1159,7 @@ |
||
| 1159 | 1159 | * @param string $template_name |
| 1160 | 1160 | * @param null|mixed $cache_id |
| 1161 | 1161 | * @param null|mixed $compile_id |
| 1162 | - * @param null $caching |
|
| 1162 | + * @param integer $caching |
|
| 1163 | 1163 | * @param \Smarty_Internal_Template $template |
| 1164 | 1164 | * |
| 1165 | 1165 | * @return string |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * define shorthand directory separator constant |
| 35 | 35 | */ |
| 36 | 36 | if (!defined('DS')) { |
| 37 | - define('DS', DIRECTORY_SEPARATOR); |
|
| 37 | + define('DS', DIRECTORY_SEPARATOR); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Sets SMARTY_DIR only if user application has not already defined it. |
| 43 | 43 | */ |
| 44 | 44 | if (!defined('SMARTY_DIR')) { |
| 45 | - define('SMARTY_DIR', dirname(__FILE__) . DS); |
|
| 45 | + define('SMARTY_DIR', dirname(__FILE__) . DS); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -50,26 +50,26 @@ discard block |
||
| 50 | 50 | * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. |
| 51 | 51 | */ |
| 52 | 52 | if (!defined('SMARTY_SYSPLUGINS_DIR')) { |
| 53 | - define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); |
|
| 53 | + define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS); |
|
| 54 | 54 | } |
| 55 | 55 | if (!defined('SMARTY_PLUGINS_DIR')) { |
| 56 | - define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); |
|
| 56 | + define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); |
|
| 57 | 57 | } |
| 58 | 58 | if (!defined('SMARTY_MBSTRING')) { |
| 59 | - define('SMARTY_MBSTRING', function_exists('mb_get_info')); |
|
| 59 | + define('SMARTY_MBSTRING', function_exists('mb_get_info')); |
|
| 60 | 60 | } |
| 61 | 61 | if (!defined('SMARTY_RESOURCE_CHAR_SET')) { |
| 62 | - // UTF-8 can only be done properly when mbstring is available! |
|
| 63 | - /** |
|
| 64 | - * @deprecated in favor of Smarty::$_CHARSET |
|
| 65 | - */ |
|
| 66 | - define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1'); |
|
| 62 | + // UTF-8 can only be done properly when mbstring is available! |
|
| 63 | + /** |
|
| 64 | + * @deprecated in favor of Smarty::$_CHARSET |
|
| 65 | + */ |
|
| 66 | + define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1'); |
|
| 67 | 67 | } |
| 68 | 68 | if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { |
| 69 | - /** |
|
| 70 | - * @deprecated in favor of Smarty::$_DATE_FORMAT |
|
| 71 | - */ |
|
| 72 | - define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); |
|
| 69 | + /** |
|
| 70 | + * @deprecated in favor of Smarty::$_DATE_FORMAT |
|
| 71 | + */ |
|
| 72 | + define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | * Otherwise we may have a global autoloader like Composer |
| 79 | 79 | */ |
| 80 | 80 | if (!class_exists('Smarty_Autoloader', false)) { |
| 81 | - if (!class_exists('Smarty_Internal_Data', true)) { |
|
| 82 | - require_once dirname(__FILE__) . '/Autoloader.php'; |
|
| 83 | - Smarty_Autoloader::registerBC(); |
|
| 84 | - } |
|
| 81 | + if (!class_exists('Smarty_Internal_Data', true)) { |
|
| 82 | + require_once dirname(__FILE__) . '/Autoloader.php'; |
|
| 83 | + Smarty_Autoloader::registerBC(); |
|
| 84 | + } |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Load always needed external class files |
| 89 | 89 | */ |
| 90 | 90 | if (!class_exists('Smarty_Internal_Data', false)) { |
| 91 | - require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; |
|
| 91 | + require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; |
|
| 92 | 92 | } |
| 93 | 93 | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php'; |
| 94 | 94 | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; |
@@ -114,1385 +114,1385 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | class Smarty extends Smarty_Internal_TemplateBase |
| 116 | 116 | { |
| 117 | - /**#@+ |
|
| 117 | + /**#@+ |
|
| 118 | 118 | * constant definitions |
| 119 | 119 | */ |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * smarty version |
|
| 123 | - */ |
|
| 124 | - const SMARTY_VERSION = '3.1.30'; |
|
| 121 | + /** |
|
| 122 | + * smarty version |
|
| 123 | + */ |
|
| 124 | + const SMARTY_VERSION = '3.1.30'; |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * define variable scopes |
|
| 128 | - */ |
|
| 129 | - const SCOPE_LOCAL = 1; |
|
| 126 | + /** |
|
| 127 | + * define variable scopes |
|
| 128 | + */ |
|
| 129 | + const SCOPE_LOCAL = 1; |
|
| 130 | 130 | |
| 131 | - const SCOPE_PARENT = 2; |
|
| 131 | + const SCOPE_PARENT = 2; |
|
| 132 | 132 | |
| 133 | - const SCOPE_TPL_ROOT = 4; |
|
| 133 | + const SCOPE_TPL_ROOT = 4; |
|
| 134 | 134 | |
| 135 | - const SCOPE_ROOT = 8; |
|
| 135 | + const SCOPE_ROOT = 8; |
|
| 136 | 136 | |
| 137 | - const SCOPE_SMARTY = 16; |
|
| 137 | + const SCOPE_SMARTY = 16; |
|
| 138 | 138 | |
| 139 | - const SCOPE_GLOBAL = 32; |
|
| 139 | + const SCOPE_GLOBAL = 32; |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * define caching modes |
|
| 143 | - */ |
|
| 144 | - const CACHING_OFF = 0; |
|
| 141 | + /** |
|
| 142 | + * define caching modes |
|
| 143 | + */ |
|
| 144 | + const CACHING_OFF = 0; |
|
| 145 | 145 | |
| 146 | - const CACHING_LIFETIME_CURRENT = 1; |
|
| 146 | + const CACHING_LIFETIME_CURRENT = 1; |
|
| 147 | 147 | |
| 148 | - const CACHING_LIFETIME_SAVED = 2; |
|
| 148 | + const CACHING_LIFETIME_SAVED = 2; |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * define constant for clearing cache files be saved expiration dates |
|
| 152 | - */ |
|
| 153 | - const CLEAR_EXPIRED = - 1; |
|
| 150 | + /** |
|
| 151 | + * define constant for clearing cache files be saved expiration dates |
|
| 152 | + */ |
|
| 153 | + const CLEAR_EXPIRED = - 1; |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * define compile check modes |
|
| 157 | - */ |
|
| 158 | - const COMPILECHECK_OFF = 0; |
|
| 155 | + /** |
|
| 156 | + * define compile check modes |
|
| 157 | + */ |
|
| 158 | + const COMPILECHECK_OFF = 0; |
|
| 159 | 159 | |
| 160 | - const COMPILECHECK_ON = 1; |
|
| 160 | + const COMPILECHECK_ON = 1; |
|
| 161 | 161 | |
| 162 | - const COMPILECHECK_CACHEMISS = 2; |
|
| 162 | + const COMPILECHECK_CACHEMISS = 2; |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * define debug modes |
|
| 166 | - */ |
|
| 167 | - const DEBUG_OFF = 0; |
|
| 164 | + /** |
|
| 165 | + * define debug modes |
|
| 166 | + */ |
|
| 167 | + const DEBUG_OFF = 0; |
|
| 168 | 168 | |
| 169 | - const DEBUG_ON = 1; |
|
| 169 | + const DEBUG_ON = 1; |
|
| 170 | 170 | |
| 171 | - const DEBUG_INDIVIDUAL = 2; |
|
| 171 | + const DEBUG_INDIVIDUAL = 2; |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * modes for handling of "<?php ... ?>" tags in templates. |
|
| 175 | - */ |
|
| 176 | - const PHP_PASSTHRU = 0; //-> print tags as plain text |
|
| 173 | + /** |
|
| 174 | + * modes for handling of "<?php ... ?>" tags in templates. |
|
| 175 | + */ |
|
| 176 | + const PHP_PASSTHRU = 0; //-> print tags as plain text |
|
| 177 | 177 | |
| 178 | - const PHP_QUOTE = 1; //-> escape tags as entities |
|
| 178 | + const PHP_QUOTE = 1; //-> escape tags as entities |
|
| 179 | 179 | |
| 180 | - const PHP_REMOVE = 2; //-> escape tags as entities |
|
| 180 | + const PHP_REMOVE = 2; //-> escape tags as entities |
|
| 181 | 181 | |
| 182 | - const PHP_ALLOW = 3; //-> escape tags as entities |
|
| 182 | + const PHP_ALLOW = 3; //-> escape tags as entities |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * filter types |
|
| 186 | - */ |
|
| 187 | - const FILTER_POST = 'post'; |
|
| 184 | + /** |
|
| 185 | + * filter types |
|
| 186 | + */ |
|
| 187 | + const FILTER_POST = 'post'; |
|
| 188 | 188 | |
| 189 | - const FILTER_PRE = 'pre'; |
|
| 189 | + const FILTER_PRE = 'pre'; |
|
| 190 | 190 | |
| 191 | - const FILTER_OUTPUT = 'output'; |
|
| 191 | + const FILTER_OUTPUT = 'output'; |
|
| 192 | 192 | |
| 193 | - const FILTER_VARIABLE = 'variable'; |
|
| 193 | + const FILTER_VARIABLE = 'variable'; |
|
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * plugin types |
|
| 197 | - */ |
|
| 198 | - const PLUGIN_FUNCTION = 'function'; |
|
| 195 | + /** |
|
| 196 | + * plugin types |
|
| 197 | + */ |
|
| 198 | + const PLUGIN_FUNCTION = 'function'; |
|
| 199 | 199 | |
| 200 | - const PLUGIN_BLOCK = 'block'; |
|
| 200 | + const PLUGIN_BLOCK = 'block'; |
|
| 201 | 201 | |
| 202 | - const PLUGIN_COMPILER = 'compiler'; |
|
| 202 | + const PLUGIN_COMPILER = 'compiler'; |
|
| 203 | 203 | |
| 204 | - const PLUGIN_MODIFIER = 'modifier'; |
|
| 204 | + const PLUGIN_MODIFIER = 'modifier'; |
|
| 205 | 205 | |
| 206 | - const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; |
|
| 206 | + const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * Resource caching modes |
|
| 210 | - * (not used since 3.1.30) |
|
| 211 | - */ |
|
| 212 | - const RESOURCE_CACHE_OFF = 0; |
|
| 208 | + /** |
|
| 209 | + * Resource caching modes |
|
| 210 | + * (not used since 3.1.30) |
|
| 211 | + */ |
|
| 212 | + const RESOURCE_CACHE_OFF = 0; |
|
| 213 | 213 | |
| 214 | - const RESOURCE_CACHE_AUTOMATIC = 1; // cache template objects by rules |
|
| 214 | + const RESOURCE_CACHE_AUTOMATIC = 1; // cache template objects by rules |
|
| 215 | 215 | |
| 216 | - const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects |
|
| 216 | + const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects |
|
| 217 | 217 | |
| 218 | - const RESOURCE_CACHE_ON = 4; // cache source and compiled resources |
|
| 218 | + const RESOURCE_CACHE_ON = 4; // cache source and compiled resources |
|
| 219 | 219 | |
| 220 | - /**#@-*/ |
|
| 220 | + /**#@-*/ |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * assigned global tpl vars |
|
| 224 | - */ |
|
| 225 | - public static $global_tpl_vars = array(); |
|
| 222 | + /** |
|
| 223 | + * assigned global tpl vars |
|
| 224 | + */ |
|
| 225 | + public static $global_tpl_vars = array(); |
|
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * error handler returned by set_error_handler() in Smarty::muteExpectedErrors() |
|
| 229 | - */ |
|
| 230 | - public static $_previous_error_handler = null; |
|
| 227 | + /** |
|
| 228 | + * error handler returned by set_error_handler() in Smarty::muteExpectedErrors() |
|
| 229 | + */ |
|
| 230 | + public static $_previous_error_handler = null; |
|
| 231 | 231 | |
| 232 | - /** |
|
| 233 | - * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() |
|
| 234 | - */ |
|
| 235 | - public static $_muted_directories = array(); |
|
| 232 | + /** |
|
| 233 | + * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() |
|
| 234 | + */ |
|
| 235 | + public static $_muted_directories = array(); |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Flag denoting if Multibyte String functions are available |
|
| 239 | - */ |
|
| 240 | - public static $_MBSTRING = SMARTY_MBSTRING; |
|
| 237 | + /** |
|
| 238 | + * Flag denoting if Multibyte String functions are available |
|
| 239 | + */ |
|
| 240 | + public static $_MBSTRING = SMARTY_MBSTRING; |
|
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * The character set to adhere to (e.g. "UTF-8") |
|
| 244 | - */ |
|
| 245 | - public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; |
|
| 242 | + /** |
|
| 243 | + * The character set to adhere to (e.g. "UTF-8") |
|
| 244 | + */ |
|
| 245 | + public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; |
|
| 246 | 246 | |
| 247 | - /** |
|
| 248 | - * The date format to be used internally |
|
| 249 | - * (accepts date() and strftime()) |
|
| 250 | - */ |
|
| 251 | - public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; |
|
| 247 | + /** |
|
| 248 | + * The date format to be used internally |
|
| 249 | + * (accepts date() and strftime()) |
|
| 250 | + */ |
|
| 251 | + public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Flag denoting if PCRE should run in UTF-8 mode |
|
| 255 | - */ |
|
| 256 | - public static $_UTF8_MODIFIER = 'u'; |
|
| 253 | + /** |
|
| 254 | + * Flag denoting if PCRE should run in UTF-8 mode |
|
| 255 | + */ |
|
| 256 | + public static $_UTF8_MODIFIER = 'u'; |
|
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Flag denoting if operating system is windows |
|
| 260 | - */ |
|
| 261 | - public static $_IS_WINDOWS = false; |
|
| 258 | + /** |
|
| 259 | + * Flag denoting if operating system is windows |
|
| 260 | + */ |
|
| 261 | + public static $_IS_WINDOWS = false; |
|
| 262 | 262 | |
| 263 | - /**#@+ |
|
| 263 | + /**#@+ |
|
| 264 | 264 | * variables |
| 265 | 265 | */ |
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * auto literal on delimiters with whitespace |
|
| 269 | - * |
|
| 270 | - * @var boolean |
|
| 271 | - */ |
|
| 272 | - public $auto_literal = true; |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * display error on not assigned variables |
|
| 276 | - * |
|
| 277 | - * @var boolean |
|
| 278 | - */ |
|
| 279 | - public $error_unassigned = false; |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * look up relative file path in include_path |
|
| 283 | - * |
|
| 284 | - * @var boolean |
|
| 285 | - */ |
|
| 286 | - public $use_include_path = false; |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * template directory |
|
| 290 | - * |
|
| 291 | - * @var array |
|
| 292 | - */ |
|
| 293 | - protected $template_dir = array('./templates/'); |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * flags for normalized template directory entries |
|
| 297 | - * |
|
| 298 | - * @var array |
|
| 299 | - */ |
|
| 300 | - protected $_processedTemplateDir = array(); |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * flag if template_dir is normalized |
|
| 304 | - * |
|
| 305 | - * @var bool |
|
| 306 | - */ |
|
| 307 | - public $_templateDirNormalized = false; |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * joined template directory string used in cache keys |
|
| 311 | - * |
|
| 312 | - * @var string |
|
| 313 | - */ |
|
| 314 | - public $_joined_template_dir = null; |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * config directory |
|
| 318 | - * |
|
| 319 | - * @var array |
|
| 320 | - */ |
|
| 321 | - protected $config_dir = array('./configs/'); |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * flags for normalized template directory entries |
|
| 325 | - * |
|
| 326 | - * @var array |
|
| 327 | - */ |
|
| 328 | - protected $_processedConfigDir = array(); |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * flag if config_dir is normalized |
|
| 332 | - * |
|
| 333 | - * @var bool |
|
| 334 | - */ |
|
| 335 | - public $_configDirNormalized = false; |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * joined config directory string used in cache keys |
|
| 339 | - * |
|
| 340 | - * @var string |
|
| 341 | - */ |
|
| 342 | - public $_joined_config_dir = null; |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * default template handler |
|
| 346 | - * |
|
| 347 | - * @var callable |
|
| 348 | - */ |
|
| 349 | - public $default_template_handler_func = null; |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * default config handler |
|
| 353 | - * |
|
| 354 | - * @var callable |
|
| 355 | - */ |
|
| 356 | - public $default_config_handler_func = null; |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * default plugin handler |
|
| 360 | - * |
|
| 361 | - * @var callable |
|
| 362 | - */ |
|
| 363 | - public $default_plugin_handler_func = null; |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * compile directory |
|
| 367 | - * |
|
| 368 | - * @var string |
|
| 369 | - */ |
|
| 370 | - protected $compile_dir = './templates_c/'; |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * flag if template_dir is normalized |
|
| 374 | - * |
|
| 375 | - * @var bool |
|
| 376 | - */ |
|
| 377 | - public $_compileDirNormalized = false; |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * plugins directory |
|
| 381 | - * |
|
| 382 | - * @var array |
|
| 383 | - */ |
|
| 384 | - protected $plugins_dir = array(); |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * flag if plugins_dir is normalized |
|
| 388 | - * |
|
| 389 | - * @var bool |
|
| 390 | - */ |
|
| 391 | - public $_pluginsDirNormalized = false; |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * cache directory |
|
| 395 | - * |
|
| 396 | - * @var string |
|
| 397 | - */ |
|
| 398 | - protected $cache_dir = './cache/'; |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * flag if template_dir is normalized |
|
| 402 | - * |
|
| 403 | - * @var bool |
|
| 404 | - */ |
|
| 405 | - public $_cacheDirNormalized = false; |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * force template compiling? |
|
| 409 | - * |
|
| 410 | - * @var boolean |
|
| 411 | - */ |
|
| 412 | - public $force_compile = false; |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * check template for modifications? |
|
| 416 | - * |
|
| 417 | - * @var boolean |
|
| 418 | - */ |
|
| 419 | - public $compile_check = true; |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * use sub dirs for compiled/cached files? |
|
| 423 | - * |
|
| 424 | - * @var boolean |
|
| 425 | - */ |
|
| 426 | - public $use_sub_dirs = false; |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * allow ambiguous resources (that are made unique by the resource handler) |
|
| 430 | - * |
|
| 431 | - * @var boolean |
|
| 432 | - */ |
|
| 433 | - public $allow_ambiguous_resources = false; |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * merge compiled includes |
|
| 437 | - * |
|
| 438 | - * @var boolean |
|
| 439 | - */ |
|
| 440 | - public $merge_compiled_includes = false; |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * force cache file creation |
|
| 444 | - * |
|
| 445 | - * @var boolean |
|
| 446 | - */ |
|
| 447 | - public $force_cache = false; |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * template left-delimiter |
|
| 451 | - * |
|
| 452 | - * @var string |
|
| 453 | - */ |
|
| 454 | - public $left_delimiter = "{"; |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * template right-delimiter |
|
| 458 | - * |
|
| 459 | - * @var string |
|
| 460 | - */ |
|
| 461 | - public $right_delimiter = "}"; |
|
| 462 | - |
|
| 463 | - /**#@+ |
|
| 267 | + /** |
|
| 268 | + * auto literal on delimiters with whitespace |
|
| 269 | + * |
|
| 270 | + * @var boolean |
|
| 271 | + */ |
|
| 272 | + public $auto_literal = true; |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * display error on not assigned variables |
|
| 276 | + * |
|
| 277 | + * @var boolean |
|
| 278 | + */ |
|
| 279 | + public $error_unassigned = false; |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * look up relative file path in include_path |
|
| 283 | + * |
|
| 284 | + * @var boolean |
|
| 285 | + */ |
|
| 286 | + public $use_include_path = false; |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * template directory |
|
| 290 | + * |
|
| 291 | + * @var array |
|
| 292 | + */ |
|
| 293 | + protected $template_dir = array('./templates/'); |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * flags for normalized template directory entries |
|
| 297 | + * |
|
| 298 | + * @var array |
|
| 299 | + */ |
|
| 300 | + protected $_processedTemplateDir = array(); |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * flag if template_dir is normalized |
|
| 304 | + * |
|
| 305 | + * @var bool |
|
| 306 | + */ |
|
| 307 | + public $_templateDirNormalized = false; |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * joined template directory string used in cache keys |
|
| 311 | + * |
|
| 312 | + * @var string |
|
| 313 | + */ |
|
| 314 | + public $_joined_template_dir = null; |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * config directory |
|
| 318 | + * |
|
| 319 | + * @var array |
|
| 320 | + */ |
|
| 321 | + protected $config_dir = array('./configs/'); |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * flags for normalized template directory entries |
|
| 325 | + * |
|
| 326 | + * @var array |
|
| 327 | + */ |
|
| 328 | + protected $_processedConfigDir = array(); |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * flag if config_dir is normalized |
|
| 332 | + * |
|
| 333 | + * @var bool |
|
| 334 | + */ |
|
| 335 | + public $_configDirNormalized = false; |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * joined config directory string used in cache keys |
|
| 339 | + * |
|
| 340 | + * @var string |
|
| 341 | + */ |
|
| 342 | + public $_joined_config_dir = null; |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * default template handler |
|
| 346 | + * |
|
| 347 | + * @var callable |
|
| 348 | + */ |
|
| 349 | + public $default_template_handler_func = null; |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * default config handler |
|
| 353 | + * |
|
| 354 | + * @var callable |
|
| 355 | + */ |
|
| 356 | + public $default_config_handler_func = null; |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * default plugin handler |
|
| 360 | + * |
|
| 361 | + * @var callable |
|
| 362 | + */ |
|
| 363 | + public $default_plugin_handler_func = null; |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * compile directory |
|
| 367 | + * |
|
| 368 | + * @var string |
|
| 369 | + */ |
|
| 370 | + protected $compile_dir = './templates_c/'; |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * flag if template_dir is normalized |
|
| 374 | + * |
|
| 375 | + * @var bool |
|
| 376 | + */ |
|
| 377 | + public $_compileDirNormalized = false; |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * plugins directory |
|
| 381 | + * |
|
| 382 | + * @var array |
|
| 383 | + */ |
|
| 384 | + protected $plugins_dir = array(); |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * flag if plugins_dir is normalized |
|
| 388 | + * |
|
| 389 | + * @var bool |
|
| 390 | + */ |
|
| 391 | + public $_pluginsDirNormalized = false; |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * cache directory |
|
| 395 | + * |
|
| 396 | + * @var string |
|
| 397 | + */ |
|
| 398 | + protected $cache_dir = './cache/'; |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * flag if template_dir is normalized |
|
| 402 | + * |
|
| 403 | + * @var bool |
|
| 404 | + */ |
|
| 405 | + public $_cacheDirNormalized = false; |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * force template compiling? |
|
| 409 | + * |
|
| 410 | + * @var boolean |
|
| 411 | + */ |
|
| 412 | + public $force_compile = false; |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * check template for modifications? |
|
| 416 | + * |
|
| 417 | + * @var boolean |
|
| 418 | + */ |
|
| 419 | + public $compile_check = true; |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * use sub dirs for compiled/cached files? |
|
| 423 | + * |
|
| 424 | + * @var boolean |
|
| 425 | + */ |
|
| 426 | + public $use_sub_dirs = false; |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * allow ambiguous resources (that are made unique by the resource handler) |
|
| 430 | + * |
|
| 431 | + * @var boolean |
|
| 432 | + */ |
|
| 433 | + public $allow_ambiguous_resources = false; |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * merge compiled includes |
|
| 437 | + * |
|
| 438 | + * @var boolean |
|
| 439 | + */ |
|
| 440 | + public $merge_compiled_includes = false; |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * force cache file creation |
|
| 444 | + * |
|
| 445 | + * @var boolean |
|
| 446 | + */ |
|
| 447 | + public $force_cache = false; |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * template left-delimiter |
|
| 451 | + * |
|
| 452 | + * @var string |
|
| 453 | + */ |
|
| 454 | + public $left_delimiter = "{"; |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * template right-delimiter |
|
| 458 | + * |
|
| 459 | + * @var string |
|
| 460 | + */ |
|
| 461 | + public $right_delimiter = "}"; |
|
| 462 | + |
|
| 463 | + /**#@+ |
|
| 464 | 464 | * security |
| 465 | 465 | */ |
| 466 | - /** |
|
| 467 | - * class name |
|
| 468 | - * This should be instance of Smarty_Security. |
|
| 469 | - * |
|
| 470 | - * @var string |
|
| 471 | - * @see Smarty_Security |
|
| 472 | - */ |
|
| 473 | - public $security_class = 'Smarty_Security'; |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * implementation of security class |
|
| 477 | - * |
|
| 478 | - * @var Smarty_Security |
|
| 479 | - */ |
|
| 480 | - public $security_policy = null; |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * controls handling of PHP-blocks |
|
| 484 | - * |
|
| 485 | - * @var integer |
|
| 486 | - */ |
|
| 487 | - public $php_handling = self::PHP_PASSTHRU; |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * controls if the php template file resource is allowed |
|
| 491 | - * |
|
| 492 | - * @var bool |
|
| 493 | - */ |
|
| 494 | - public $allow_php_templates = false; |
|
| 495 | - |
|
| 496 | - /**#@-*/ |
|
| 497 | - /** |
|
| 498 | - * debug mode |
|
| 499 | - * Setting this to true enables the debug-console. |
|
| 500 | - * |
|
| 501 | - * @var boolean |
|
| 502 | - */ |
|
| 503 | - public $debugging = false; |
|
| 504 | - |
|
| 505 | - /** |
|
| 506 | - * This determines if debugging is enable-able from the browser. |
|
| 507 | - * <ul> |
|
| 508 | - * <li>NONE => no debugging control allowed</li> |
|
| 509 | - * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li> |
|
| 510 | - * </ul> |
|
| 511 | - * |
|
| 512 | - * @var string |
|
| 513 | - */ |
|
| 514 | - public $debugging_ctrl = 'NONE'; |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * Name of debugging URL-param. |
|
| 518 | - * Only used when $debugging_ctrl is set to 'URL'. |
|
| 519 | - * The name of the URL-parameter that activates debugging. |
|
| 520 | - * |
|
| 521 | - * @var string |
|
| 522 | - */ |
|
| 523 | - public $smarty_debug_id = 'SMARTY_DEBUG'; |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * Path of debug template. |
|
| 527 | - * |
|
| 528 | - * @var string |
|
| 529 | - */ |
|
| 530 | - public $debug_tpl = null; |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * When set, smarty uses this value as error_reporting-level. |
|
| 534 | - * |
|
| 535 | - * @var int |
|
| 536 | - */ |
|
| 537 | - public $error_reporting = null; |
|
| 538 | - |
|
| 539 | - /**#@+ |
|
| 466 | + /** |
|
| 467 | + * class name |
|
| 468 | + * This should be instance of Smarty_Security. |
|
| 469 | + * |
|
| 470 | + * @var string |
|
| 471 | + * @see Smarty_Security |
|
| 472 | + */ |
|
| 473 | + public $security_class = 'Smarty_Security'; |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * implementation of security class |
|
| 477 | + * |
|
| 478 | + * @var Smarty_Security |
|
| 479 | + */ |
|
| 480 | + public $security_policy = null; |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * controls handling of PHP-blocks |
|
| 484 | + * |
|
| 485 | + * @var integer |
|
| 486 | + */ |
|
| 487 | + public $php_handling = self::PHP_PASSTHRU; |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * controls if the php template file resource is allowed |
|
| 491 | + * |
|
| 492 | + * @var bool |
|
| 493 | + */ |
|
| 494 | + public $allow_php_templates = false; |
|
| 495 | + |
|
| 496 | + /**#@-*/ |
|
| 497 | + /** |
|
| 498 | + * debug mode |
|
| 499 | + * Setting this to true enables the debug-console. |
|
| 500 | + * |
|
| 501 | + * @var boolean |
|
| 502 | + */ |
|
| 503 | + public $debugging = false; |
|
| 504 | + |
|
| 505 | + /** |
|
| 506 | + * This determines if debugging is enable-able from the browser. |
|
| 507 | + * <ul> |
|
| 508 | + * <li>NONE => no debugging control allowed</li> |
|
| 509 | + * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li> |
|
| 510 | + * </ul> |
|
| 511 | + * |
|
| 512 | + * @var string |
|
| 513 | + */ |
|
| 514 | + public $debugging_ctrl = 'NONE'; |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * Name of debugging URL-param. |
|
| 518 | + * Only used when $debugging_ctrl is set to 'URL'. |
|
| 519 | + * The name of the URL-parameter that activates debugging. |
|
| 520 | + * |
|
| 521 | + * @var string |
|
| 522 | + */ |
|
| 523 | + public $smarty_debug_id = 'SMARTY_DEBUG'; |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * Path of debug template. |
|
| 527 | + * |
|
| 528 | + * @var string |
|
| 529 | + */ |
|
| 530 | + public $debug_tpl = null; |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * When set, smarty uses this value as error_reporting-level. |
|
| 534 | + * |
|
| 535 | + * @var int |
|
| 536 | + */ |
|
| 537 | + public $error_reporting = null; |
|
| 538 | + |
|
| 539 | + /**#@+ |
|
| 540 | 540 | * config var settings |
| 541 | 541 | */ |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Controls whether variables with the same name overwrite each other. |
|
| 545 | - * |
|
| 546 | - * @var boolean |
|
| 547 | - */ |
|
| 548 | - public $config_overwrite = true; |
|
| 543 | + /** |
|
| 544 | + * Controls whether variables with the same name overwrite each other. |
|
| 545 | + * |
|
| 546 | + * @var boolean |
|
| 547 | + */ |
|
| 548 | + public $config_overwrite = true; |
|
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Controls whether config values of on/true/yes and off/false/no get converted to boolean. |
|
| 552 | - * |
|
| 553 | - * @var boolean |
|
| 554 | - */ |
|
| 555 | - public $config_booleanize = true; |
|
| 550 | + /** |
|
| 551 | + * Controls whether config values of on/true/yes and off/false/no get converted to boolean. |
|
| 552 | + * |
|
| 553 | + * @var boolean |
|
| 554 | + */ |
|
| 555 | + public $config_booleanize = true; |
|
| 556 | 556 | |
| 557 | - /** |
|
| 558 | - * Controls whether hidden config sections/vars are read from the file. |
|
| 559 | - * |
|
| 560 | - * @var boolean |
|
| 561 | - */ |
|
| 562 | - public $config_read_hidden = false; |
|
| 557 | + /** |
|
| 558 | + * Controls whether hidden config sections/vars are read from the file. |
|
| 559 | + * |
|
| 560 | + * @var boolean |
|
| 561 | + */ |
|
| 562 | + public $config_read_hidden = false; |
|
| 563 | 563 | |
| 564 | - /**#@-*/ |
|
| 564 | + /**#@-*/ |
|
| 565 | 565 | |
| 566 | - /**#@+ |
|
| 566 | + /**#@+ |
|
| 567 | 567 | * resource locking |
| 568 | 568 | */ |
| 569 | 569 | |
| 570 | - /** |
|
| 571 | - * locking concurrent compiles |
|
| 572 | - * |
|
| 573 | - * @var boolean |
|
| 574 | - */ |
|
| 575 | - public $compile_locking = true; |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Controls whether cache resources should use locking mechanism |
|
| 579 | - * |
|
| 580 | - * @var boolean |
|
| 581 | - */ |
|
| 582 | - public $cache_locking = false; |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * seconds to wait for acquiring a lock before ignoring the write lock |
|
| 586 | - * |
|
| 587 | - * @var float |
|
| 588 | - */ |
|
| 589 | - public $locking_timeout = 10; |
|
| 590 | - |
|
| 591 | - /**#@-*/ |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * resource type used if none given |
|
| 595 | - * Must be an valid key of $registered_resources. |
|
| 596 | - * |
|
| 597 | - * @var string |
|
| 598 | - */ |
|
| 599 | - public $default_resource_type = 'file'; |
|
| 600 | - |
|
| 601 | - /** |
|
| 602 | - * caching type |
|
| 603 | - * Must be an element of $cache_resource_types. |
|
| 604 | - * |
|
| 605 | - * @var string |
|
| 606 | - */ |
|
| 607 | - public $caching_type = 'file'; |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * config type |
|
| 611 | - * |
|
| 612 | - * @var string |
|
| 613 | - */ |
|
| 614 | - public $default_config_type = 'file'; |
|
| 615 | - |
|
| 616 | - /** |
|
| 617 | - * check If-Modified-Since headers |
|
| 618 | - * |
|
| 619 | - * @var boolean |
|
| 620 | - */ |
|
| 621 | - public $cache_modified_check = false; |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * registered plugins |
|
| 625 | - * |
|
| 626 | - * @var array |
|
| 627 | - */ |
|
| 628 | - public $registered_plugins = array(); |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * registered objects |
|
| 632 | - * |
|
| 633 | - * @var array |
|
| 634 | - */ |
|
| 635 | - public $registered_objects = array(); |
|
| 636 | - |
|
| 637 | - /** |
|
| 638 | - * registered classes |
|
| 639 | - * |
|
| 640 | - * @var array |
|
| 641 | - */ |
|
| 642 | - public $registered_classes = array(); |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * registered filters |
|
| 646 | - * |
|
| 647 | - * @var array |
|
| 648 | - */ |
|
| 649 | - public $registered_filters = array(); |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * registered resources |
|
| 653 | - * |
|
| 654 | - * @var array |
|
| 655 | - */ |
|
| 656 | - public $registered_resources = array(); |
|
| 657 | - |
|
| 658 | - /** |
|
| 659 | - * registered cache resources |
|
| 660 | - * |
|
| 661 | - * @var array |
|
| 662 | - */ |
|
| 663 | - public $registered_cache_resources = array(); |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * autoload filter |
|
| 667 | - * |
|
| 668 | - * @var array |
|
| 669 | - */ |
|
| 670 | - public $autoload_filters = array(); |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * default modifier |
|
| 674 | - * |
|
| 675 | - * @var array |
|
| 676 | - */ |
|
| 677 | - public $default_modifiers = array(); |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * autoescape variable output |
|
| 681 | - * |
|
| 682 | - * @var boolean |
|
| 683 | - */ |
|
| 684 | - public $escape_html = false; |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * start time for execution time calculation |
|
| 688 | - * |
|
| 689 | - * @var int |
|
| 690 | - */ |
|
| 691 | - public $start_time = 0; |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * required by the compiler for BC |
|
| 695 | - * |
|
| 696 | - * @var string |
|
| 697 | - */ |
|
| 698 | - public $_current_file = null; |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * internal flag to enable parser debugging |
|
| 702 | - * |
|
| 703 | - * @var bool |
|
| 704 | - */ |
|
| 705 | - public $_parserdebug = false; |
|
| 706 | - |
|
| 707 | - /** |
|
| 708 | - * This object type (Smarty = 1, template = 2, data = 4) |
|
| 709 | - * |
|
| 710 | - * @var int |
|
| 711 | - */ |
|
| 712 | - public $_objType = 1; |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * Debug object |
|
| 716 | - * |
|
| 717 | - * @var Smarty_Internal_Debug |
|
| 718 | - */ |
|
| 719 | - public $_debug = null; |
|
| 720 | - |
|
| 721 | - /** |
|
| 722 | - * removed properties |
|
| 723 | - * |
|
| 724 | - * @var string[] |
|
| 725 | - */ |
|
| 726 | - private $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security', |
|
| 727 | - '_dir_perms', '_file_perms', 'plugin_search_order', |
|
| 728 | - 'inheritance_merge_compiled_includes', 'resource_cache_mode',); |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * List of private properties which will call getter/setter on a direct access |
|
| 732 | - * |
|
| 733 | - * @var string[] |
|
| 734 | - */ |
|
| 735 | - private $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir', |
|
| 736 | - 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir', |
|
| 737 | - 'cache_dir' => 'CacheDir',); |
|
| 738 | - |
|
| 739 | - /**#@-*/ |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * Initialize new Smarty object |
|
| 743 | - */ |
|
| 744 | - public function __construct() |
|
| 745 | - { |
|
| 746 | - parent::__construct(); |
|
| 747 | - if (is_callable('mb_internal_encoding')) { |
|
| 748 | - mb_internal_encoding(Smarty::$_CHARSET); |
|
| 749 | - } |
|
| 750 | - $this->start_time = microtime(true); |
|
| 751 | - |
|
| 752 | - if (isset($_SERVER[ 'SCRIPT_NAME' ])) { |
|
| 753 | - Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new Smarty_Variable($_SERVER[ 'SCRIPT_NAME' ]); |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - // Check if we're running on windows |
|
| 757 | - Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; |
|
| 758 | - // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 |
|
| 759 | - if (Smarty::$_CHARSET !== 'UTF-8') { |
|
| 760 | - Smarty::$_UTF8_MODIFIER = ''; |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - /** |
|
| 765 | - * Check if a template resource exists |
|
| 766 | - * |
|
| 767 | - * @param string $resource_name template name |
|
| 768 | - * |
|
| 769 | - * @return boolean status |
|
| 770 | - */ |
|
| 771 | - public function templateExists($resource_name) |
|
| 772 | - { |
|
| 773 | - // create source object |
|
| 774 | - $source = Smarty_Template_Source::load(null, $this, $resource_name); |
|
| 775 | - return $source->exists; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Loads security class and enables security |
|
| 780 | - * |
|
| 781 | - * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
| 782 | - * |
|
| 783 | - * @return Smarty current Smarty instance for chaining |
|
| 784 | - * @throws SmartyException when an invalid class name is provided |
|
| 785 | - */ |
|
| 786 | - public function enableSecurity($security_class = null) |
|
| 787 | - { |
|
| 788 | - Smarty_Security::enableSecurity($this, $security_class); |
|
| 789 | - return $this; |
|
| 790 | - } |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * Disable security |
|
| 794 | - * |
|
| 795 | - * @return Smarty current Smarty instance for chaining |
|
| 796 | - */ |
|
| 797 | - public function disableSecurity() |
|
| 798 | - { |
|
| 799 | - $this->security_policy = null; |
|
| 800 | - |
|
| 801 | - return $this; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - /** |
|
| 805 | - * Set template directory |
|
| 806 | - * |
|
| 807 | - * @param string|array $template_dir directory(s) of template sources |
|
| 808 | - * @param bool $isConfig true for config_dir |
|
| 809 | - * |
|
| 810 | - * @return \Smarty current Smarty instance for chaining |
|
| 811 | - */ |
|
| 812 | - public function setTemplateDir($template_dir, $isConfig = false) |
|
| 813 | - { |
|
| 814 | - if ($isConfig) { |
|
| 815 | - $this->config_dir = array(); |
|
| 816 | - $this->_processedConfigDir = array(); |
|
| 817 | - } else { |
|
| 818 | - $this->template_dir = array(); |
|
| 819 | - $this->_processedTemplateDir = array(); |
|
| 820 | - } |
|
| 821 | - $this->addTemplateDir($template_dir, null, $isConfig); |
|
| 822 | - return $this; |
|
| 823 | - } |
|
| 824 | - |
|
| 825 | - /** |
|
| 826 | - * Add template directory(s) |
|
| 827 | - * |
|
| 828 | - * @param string|array $template_dir directory(s) of template sources |
|
| 829 | - * @param string $key of the array element to assign the template dir to |
|
| 830 | - * @param bool $isConfig true for config_dir |
|
| 831 | - * |
|
| 832 | - * @return Smarty current Smarty instance for chaining |
|
| 833 | - */ |
|
| 834 | - public function addTemplateDir($template_dir, $key = null, $isConfig = false) |
|
| 835 | - { |
|
| 836 | - if ($isConfig) { |
|
| 837 | - $processed = &$this->_processedConfigDir; |
|
| 838 | - $dir = &$this->config_dir; |
|
| 839 | - $this->_configDirNormalized = false; |
|
| 840 | - } else { |
|
| 841 | - $processed = &$this->_processedTemplateDir; |
|
| 842 | - $dir = &$this->template_dir; |
|
| 843 | - $this->_templateDirNormalized = false; |
|
| 844 | - } |
|
| 845 | - if (is_array($template_dir)) { |
|
| 846 | - foreach ($template_dir as $k => $v) { |
|
| 847 | - if (is_int($k)) { |
|
| 848 | - // indexes are not merged but appended |
|
| 849 | - $dir[] = $v; |
|
| 850 | - } else { |
|
| 851 | - // string indexes are overridden |
|
| 852 | - $dir[ $k ] = $v; |
|
| 853 | - unset($processed[ $key ]); |
|
| 854 | - } |
|
| 855 | - } |
|
| 856 | - } else { |
|
| 857 | - if ($key !== null) { |
|
| 858 | - // override directory at specified index |
|
| 859 | - $dir[ $key ] = $template_dir; |
|
| 860 | - unset($processed[ $key ]); |
|
| 861 | - } else { |
|
| 862 | - // append new directory |
|
| 863 | - $dir[] = $template_dir; |
|
| 864 | - } |
|
| 865 | - } |
|
| 866 | - return $this; |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - /** |
|
| 870 | - * Get template directories |
|
| 871 | - * |
|
| 872 | - * @param mixed $index index of directory to get, null to get all |
|
| 873 | - * @param bool $isConfig true for config_dir |
|
| 874 | - * |
|
| 875 | - * @return array list of template directories, or directory of $index |
|
| 876 | - */ |
|
| 877 | - public function getTemplateDir($index = null, $isConfig = false) |
|
| 878 | - { |
|
| 879 | - if ($isConfig) { |
|
| 880 | - $dir = &$this->config_dir; |
|
| 881 | - } else { |
|
| 882 | - $dir = &$this->template_dir; |
|
| 883 | - } |
|
| 884 | - if ($isConfig ? !$this->_configDirNormalized : !$this->_templateDirNormalized) { |
|
| 885 | - $this->_nomalizeTemplateConfig($isConfig); |
|
| 886 | - } |
|
| 887 | - if ($index !== null) { |
|
| 888 | - return isset($dir[ $index ]) ? $dir[ $index ] : null; |
|
| 889 | - } |
|
| 890 | - return $dir; |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - /** |
|
| 894 | - * Set config directory |
|
| 895 | - * |
|
| 896 | - * @param $config_dir |
|
| 897 | - * |
|
| 898 | - * @return Smarty current Smarty instance for chaining |
|
| 899 | - */ |
|
| 900 | - public function setConfigDir($config_dir) |
|
| 901 | - { |
|
| 902 | - return $this->setTemplateDir($config_dir, true); |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - /** |
|
| 906 | - * Add config directory(s) |
|
| 907 | - * |
|
| 908 | - * @param string|array $config_dir directory(s) of config sources |
|
| 909 | - * @param mixed $key key of the array element to assign the config dir to |
|
| 910 | - * |
|
| 911 | - * @return Smarty current Smarty instance for chaining |
|
| 912 | - */ |
|
| 913 | - public function addConfigDir($config_dir, $key = null) |
|
| 914 | - { |
|
| 915 | - return $this->addTemplateDir($config_dir, $key, true); |
|
| 916 | - } |
|
| 917 | - |
|
| 918 | - /** |
|
| 919 | - * Get config directory |
|
| 920 | - * |
|
| 921 | - * @param mixed $index index of directory to get, null to get all |
|
| 922 | - * |
|
| 923 | - * @return array configuration directory |
|
| 924 | - */ |
|
| 925 | - public function getConfigDir($index = null) |
|
| 926 | - { |
|
| 927 | - return $this->getTemplateDir($index, true); |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - /** |
|
| 931 | - * Set plugins directory |
|
| 932 | - * |
|
| 933 | - * @param string|array $plugins_dir directory(s) of plugins |
|
| 934 | - * |
|
| 935 | - * @return Smarty current Smarty instance for chaining |
|
| 936 | - */ |
|
| 937 | - public function setPluginsDir($plugins_dir) |
|
| 938 | - { |
|
| 939 | - $this->plugins_dir = (array) $plugins_dir; |
|
| 940 | - $this->_pluginsDirNormalized = false; |
|
| 941 | - return $this; |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * Adds directory of plugin files |
|
| 946 | - * |
|
| 947 | - * @param null|array $plugins_dir |
|
| 948 | - * |
|
| 949 | - * @return Smarty current Smarty instance for chaining |
|
| 950 | - */ |
|
| 951 | - public function addPluginsDir($plugins_dir) |
|
| 952 | - { |
|
| 953 | - if (empty($this->plugins_dir)) { |
|
| 954 | - $this->plugins_dir[] = SMARTY_PLUGINS_DIR; |
|
| 955 | - } |
|
| 956 | - $this->plugins_dir = array_merge($this->plugins_dir, (array) $plugins_dir); |
|
| 957 | - $this->_pluginsDirNormalized = false; |
|
| 958 | - return $this; |
|
| 959 | - } |
|
| 960 | - |
|
| 961 | - /** |
|
| 962 | - * Get plugin directories |
|
| 963 | - * |
|
| 964 | - * @return array list of plugin directories |
|
| 965 | - */ |
|
| 966 | - public function getPluginsDir() |
|
| 967 | - { |
|
| 968 | - if (empty($this->plugins_dir)) { |
|
| 969 | - $this->plugins_dir[] = SMARTY_PLUGINS_DIR; |
|
| 970 | - $this->_pluginsDirNormalized = false; |
|
| 971 | - } |
|
| 972 | - if (!$this->_pluginsDirNormalized) { |
|
| 973 | - if (!is_array($this->plugins_dir)) { |
|
| 974 | - $this->plugins_dir = (array) $this->plugins_dir; |
|
| 975 | - } |
|
| 976 | - foreach ($this->plugins_dir as $k => $v) { |
|
| 977 | - $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 978 | - } |
|
| 979 | - $this->_cache[ 'plugin_files' ] = array(); |
|
| 980 | - $this->_pluginsDirNormalized = true; |
|
| 981 | - } |
|
| 982 | - return $this->plugins_dir; |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * |
|
| 987 | - * @param string $compile_dir directory to store compiled templates in |
|
| 988 | - * |
|
| 989 | - * @return Smarty current Smarty instance for chaining |
|
| 990 | - */ |
|
| 991 | - public function setCompileDir($compile_dir) |
|
| 992 | - { |
|
| 993 | - $this->_normalizeDir('compile_dir', $compile_dir); |
|
| 994 | - $this->_compileDirNormalized = true; |
|
| 995 | - return $this; |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - /** |
|
| 999 | - * Get compiled directory |
|
| 1000 | - * |
|
| 1001 | - * @return string path to compiled templates |
|
| 1002 | - */ |
|
| 1003 | - public function getCompileDir() |
|
| 1004 | - { |
|
| 1005 | - if (!$this->_compileDirNormalized) { |
|
| 1006 | - $this->_normalizeDir('compile_dir', $this->compile_dir); |
|
| 1007 | - $this->_compileDirNormalized = true; |
|
| 1008 | - } |
|
| 1009 | - return $this->compile_dir; |
|
| 1010 | - } |
|
| 1011 | - |
|
| 1012 | - /** |
|
| 1013 | - * Set cache directory |
|
| 1014 | - * |
|
| 1015 | - * @param string $cache_dir directory to store cached templates in |
|
| 1016 | - * |
|
| 1017 | - * @return Smarty current Smarty instance for chaining |
|
| 1018 | - */ |
|
| 1019 | - public function setCacheDir($cache_dir) |
|
| 1020 | - { |
|
| 1021 | - $this->_normalizeDir('cache_dir', $cache_dir); |
|
| 1022 | - $this->_cacheDirNormalized = true; |
|
| 1023 | - return $this; |
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - /** |
|
| 1027 | - * Get cache directory |
|
| 1028 | - * |
|
| 1029 | - * @return string path of cache directory |
|
| 1030 | - */ |
|
| 1031 | - public function getCacheDir() |
|
| 1032 | - { |
|
| 1033 | - if (!$this->_cacheDirNormalized) { |
|
| 1034 | - $this->_normalizeDir('cache_dir', $this->cache_dir); |
|
| 1035 | - $this->_cacheDirNormalized = true; |
|
| 1036 | - } |
|
| 1037 | - return $this->cache_dir; |
|
| 1038 | - } |
|
| 1039 | - |
|
| 1040 | - /** |
|
| 1041 | - * Normalize and set directory string |
|
| 1042 | - * |
|
| 1043 | - * @param string $dirName cache_dir or compile_dir |
|
| 1044 | - * @param string $dir filepath of folder |
|
| 1045 | - */ |
|
| 1046 | - private function _normalizeDir($dirName, $dir) |
|
| 1047 | - { |
|
| 1048 | - $this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DS, true); |
|
| 1049 | - if (!isset(Smarty::$_muted_directories[ $this->{$dirName} ])) { |
|
| 1050 | - Smarty::$_muted_directories[ $this->{$dirName} ] = null; |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - /** |
|
| 1055 | - * Normalize template_dir or config_dir |
|
| 1056 | - * |
|
| 1057 | - * @param bool $isConfig true for config_dir |
|
| 1058 | - * |
|
| 1059 | - */ |
|
| 1060 | - private function _nomalizeTemplateConfig($isConfig) |
|
| 1061 | - { |
|
| 1062 | - if ($isConfig) { |
|
| 1063 | - $processed = &$this->_processedConfigDir; |
|
| 1064 | - $dir = &$this->config_dir; |
|
| 1065 | - } else { |
|
| 1066 | - $processed = &$this->_processedTemplateDir; |
|
| 1067 | - $dir = &$this->template_dir; |
|
| 1068 | - } |
|
| 1069 | - if (!is_array($dir)) { |
|
| 1070 | - $dir = (array) $dir; |
|
| 1071 | - } |
|
| 1072 | - foreach ($dir as $k => $v) { |
|
| 1073 | - if (!isset($processed[ $k ])) { |
|
| 1074 | - $dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 1075 | - $processed[ $k ] = true; |
|
| 1076 | - } |
|
| 1077 | - } |
|
| 1078 | - $isConfig ? $this->_configDirNormalized = true : $this->_templateDirNormalized = true; |
|
| 1079 | - $isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) : |
|
| 1080 | - $this->_joined_template_dir = join('#', $this->template_dir); |
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - /** |
|
| 1084 | - * creates a template object |
|
| 1085 | - * |
|
| 1086 | - * @param string $template the resource handle of the template file |
|
| 1087 | - * @param mixed $cache_id cache id to be used with this template |
|
| 1088 | - * @param mixed $compile_id compile id to be used with this template |
|
| 1089 | - * @param object $parent next higher level of Smarty variables |
|
| 1090 | - * @param boolean $do_clone flag is Smarty object shall be cloned |
|
| 1091 | - * |
|
| 1092 | - * @return object template object |
|
| 1093 | - */ |
|
| 1094 | - public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) |
|
| 1095 | - { |
|
| 1096 | - if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { |
|
| 1097 | - $parent = $cache_id; |
|
| 1098 | - $cache_id = null; |
|
| 1099 | - } |
|
| 1100 | - if ($parent !== null && is_array($parent)) { |
|
| 1101 | - $data = $parent; |
|
| 1102 | - $parent = null; |
|
| 1103 | - } else { |
|
| 1104 | - $data = null; |
|
| 1105 | - } |
|
| 1106 | - $_templateId = $this->_getTemplateId($template, $cache_id, $compile_id); |
|
| 1107 | - $tpl = null; |
|
| 1108 | - if ($this->caching && isset($this->_cache[ 'isCached' ][ $_templateId ])) { |
|
| 1109 | - $tpl = $do_clone ? clone $this->_cache[ 'isCached' ][ $_templateId ] : |
|
| 1110 | - $this->_cache[ 'isCached' ][ $_templateId ]; |
|
| 1111 | - $tpl->tpl_vars = $tpl->config_vars = array(); |
|
| 1112 | - } else if (!$do_clone && isset($this->_cache[ 'tplObjects' ][ $_templateId ])) { |
|
| 1113 | - $tpl = clone $this->_cache[ 'tplObjects' ][ $_templateId ]; |
|
| 1114 | - } else { |
|
| 1115 | - /* @var Smarty_Internal_Template $tpl */ |
|
| 1116 | - $tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null); |
|
| 1117 | - $tpl->templateId = $_templateId; |
|
| 1118 | - } |
|
| 1119 | - if ($do_clone) { |
|
| 1120 | - $tpl->smarty = clone $tpl->smarty; |
|
| 1121 | - } |
|
| 1122 | - $tpl->parent = $parent ? $parent : $this; |
|
| 1123 | - // fill data if present |
|
| 1124 | - if (!empty($data) && is_array($data)) { |
|
| 1125 | - // set up variable values |
|
| 1126 | - foreach ($data as $_key => $_val) { |
|
| 1127 | - $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 1128 | - } |
|
| 1129 | - } |
|
| 1130 | - if ($this->debugging || $this->debugging_ctrl == 'URL') { |
|
| 1131 | - $tpl->smarty->_debug = new Smarty_Internal_Debug(); |
|
| 1132 | - // check URL debugging control |
|
| 1133 | - if (!$this->debugging && $this->debugging_ctrl == 'URL') { |
|
| 1134 | - $tpl->smarty->_debug->debugUrl($tpl->smarty); |
|
| 1135 | - } |
|
| 1136 | - } |
|
| 1137 | - return $tpl; |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - /** |
|
| 1141 | - * Takes unknown classes and loads plugin files for them |
|
| 1142 | - * class name format: Smarty_PluginType_PluginName |
|
| 1143 | - * plugin filename format: plugintype.pluginname.php |
|
| 1144 | - * |
|
| 1145 | - * @param string $plugin_name class plugin name to load |
|
| 1146 | - * @param bool $check check if already loaded |
|
| 1147 | - * |
|
| 1148 | - * @throws SmartyException |
|
| 1149 | - * @return string |boolean filepath of loaded file or false |
|
| 1150 | - */ |
|
| 1151 | - public function loadPlugin($plugin_name, $check = true) |
|
| 1152 | - { |
|
| 1153 | - return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check); |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - /** |
|
| 1157 | - * Get unique template id |
|
| 1158 | - * |
|
| 1159 | - * @param string $template_name |
|
| 1160 | - * @param null|mixed $cache_id |
|
| 1161 | - * @param null|mixed $compile_id |
|
| 1162 | - * @param null $caching |
|
| 1163 | - * @param \Smarty_Internal_Template $template |
|
| 1164 | - * |
|
| 1165 | - * @return string |
|
| 1166 | - */ |
|
| 1167 | - public function _getTemplateId($template_name, $cache_id = null, $compile_id = null, $caching = null, |
|
| 1168 | - Smarty_Internal_Template $template = null) |
|
| 1169 | - { |
|
| 1170 | - $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : |
|
| 1171 | - $template_name; |
|
| 1172 | - $cache_id = $cache_id === null ? $this->cache_id : $cache_id; |
|
| 1173 | - $compile_id = $compile_id === null ? $this->compile_id : $compile_id; |
|
| 1174 | - $caching = (int) ($caching === null ? $this->caching : $caching); |
|
| 1175 | - |
|
| 1176 | - if ((isset($template) && strpos($template_name, ':.') !== false) || $this->allow_ambiguous_resources) { |
|
| 1177 | - $_templateId = |
|
| 1178 | - Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) . |
|
| 1179 | - "#{$cache_id}#{$compile_id}#{$caching}"; |
|
| 1180 | - } else { |
|
| 1181 | - $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}"; |
|
| 1182 | - } |
|
| 1183 | - if (isset($_templateId[ 150 ])) { |
|
| 1184 | - $_templateId = sha1($_templateId); |
|
| 1185 | - } |
|
| 1186 | - return $_templateId; |
|
| 1187 | - } |
|
| 1188 | - |
|
| 1189 | - /** |
|
| 1190 | - * Normalize path |
|
| 1191 | - * - remove /./ and /../ |
|
| 1192 | - * - make it absolute if required |
|
| 1193 | - * |
|
| 1194 | - * @param string $path file path |
|
| 1195 | - * @param bool $realpath if true - convert to absolute |
|
| 1196 | - * false - convert to relative |
|
| 1197 | - * null - keep as it is but remove /./ /../ |
|
| 1198 | - * |
|
| 1199 | - * @return string |
|
| 1200 | - */ |
|
| 1201 | - public function _realpath($path, $realpath = null) |
|
| 1202 | - { |
|
| 1203 | - $nds = DS == '/' ? '\\' : '/'; |
|
| 1204 | - // normalize DS |
|
| 1205 | - $path = str_replace($nds, DS, $path); |
|
| 1206 | - preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%', |
|
| 1207 | - $path, $parts); |
|
| 1208 | - $path = $parts[ 'path' ]; |
|
| 1209 | - if ($parts[ 'root' ] == '\\') { |
|
| 1210 | - $parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ]; |
|
| 1211 | - } else { |
|
| 1212 | - if ($realpath !== null && !$parts[ 'root' ]) { |
|
| 1213 | - $path = getcwd() . DS . $path; |
|
| 1214 | - } |
|
| 1215 | - } |
|
| 1216 | - // remove noop 'DS DS' and 'DS.DS' patterns |
|
| 1217 | - $path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#', DS, $path); |
|
| 1218 | - // resolve '..DS' pattern, smallest first |
|
| 1219 | - if (strpos($path, '..' . DS) != false && |
|
| 1220 | - preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#', $path, $match) |
|
| 1221 | - ) { |
|
| 1222 | - $counts = array(); |
|
| 1223 | - foreach ($match[ 0 ] as $m) { |
|
| 1224 | - $counts[] = (int) ((strlen($m) - 1) / 3); |
|
| 1225 | - } |
|
| 1226 | - sort($counts); |
|
| 1227 | - foreach ($counts as $count) { |
|
| 1228 | - $path = preg_replace('#(([\\\\/]([.]?[\\\\/])*[^\\\\/.]+){' . $count . |
|
| 1229 | - '}[\\\\/]([.]?[\\\\/])*([.][.][\\\\/]([.]?[\\\\/])*){' . $count . '})(?=[^.])#', |
|
| 1230 | - DS, $path); |
|
| 1231 | - } |
|
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - return $parts[ 'root' ] . $path; |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * Empty template objects cache |
|
| 1239 | - */ |
|
| 1240 | - public function _clearTemplateCache() |
|
| 1241 | - { |
|
| 1242 | - $this->_cache[ 'isCached' ] = array(); |
|
| 1243 | - $this->_cache[ 'tplObjects' ] = array(); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - /** |
|
| 1247 | - * @param boolean $compile_check |
|
| 1248 | - */ |
|
| 1249 | - public function setCompileCheck($compile_check) |
|
| 1250 | - { |
|
| 1251 | - $this->compile_check = $compile_check; |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - /** |
|
| 1255 | - * @param boolean $use_sub_dirs |
|
| 1256 | - */ |
|
| 1257 | - public function setUseSubDirs($use_sub_dirs) |
|
| 1258 | - { |
|
| 1259 | - $this->use_sub_dirs = $use_sub_dirs; |
|
| 1260 | - } |
|
| 1261 | - |
|
| 1262 | - /** |
|
| 1263 | - * @param int $error_reporting |
|
| 1264 | - */ |
|
| 1265 | - public function setErrorReporting($error_reporting) |
|
| 1266 | - { |
|
| 1267 | - $this->error_reporting = $error_reporting; |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - /** |
|
| 1271 | - * @param boolean $escape_html |
|
| 1272 | - */ |
|
| 1273 | - public function setEscapeHtml($escape_html) |
|
| 1274 | - { |
|
| 1275 | - $this->escape_html = $escape_html; |
|
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - /** |
|
| 1279 | - * @param boolean $auto_literal |
|
| 1280 | - */ |
|
| 1281 | - public function setAutoLiteral($auto_literal) |
|
| 1282 | - { |
|
| 1283 | - $this->auto_literal = $auto_literal; |
|
| 1284 | - } |
|
| 1285 | - |
|
| 1286 | - /** |
|
| 1287 | - * @param boolean $force_compile |
|
| 1288 | - */ |
|
| 1289 | - public function setForceCompile($force_compile) |
|
| 1290 | - { |
|
| 1291 | - $this->force_compile = $force_compile; |
|
| 1292 | - } |
|
| 1293 | - |
|
| 1294 | - /** |
|
| 1295 | - * @param boolean $merge_compiled_includes |
|
| 1296 | - */ |
|
| 1297 | - public function setMergeCompiledIncludes($merge_compiled_includes) |
|
| 1298 | - { |
|
| 1299 | - $this->merge_compiled_includes = $merge_compiled_includes; |
|
| 1300 | - } |
|
| 1301 | - |
|
| 1302 | - /** |
|
| 1303 | - * @param string $left_delimiter |
|
| 1304 | - */ |
|
| 1305 | - public function setLeftDelimiter($left_delimiter) |
|
| 1306 | - { |
|
| 1307 | - $this->left_delimiter = $left_delimiter; |
|
| 1308 | - } |
|
| 1309 | - |
|
| 1310 | - /** |
|
| 1311 | - * @param string $right_delimiter |
|
| 1312 | - */ |
|
| 1313 | - public function setRightDelimiter($right_delimiter) |
|
| 1314 | - { |
|
| 1315 | - $this->right_delimiter = $right_delimiter; |
|
| 1316 | - } |
|
| 1317 | - |
|
| 1318 | - /** |
|
| 1319 | - * @param boolean $debugging |
|
| 1320 | - */ |
|
| 1321 | - public function setDebugging($debugging) |
|
| 1322 | - { |
|
| 1323 | - $this->debugging = $debugging; |
|
| 1324 | - } |
|
| 1325 | - |
|
| 1326 | - /** |
|
| 1327 | - * @param boolean $config_overwrite |
|
| 1328 | - */ |
|
| 1329 | - public function setConfigOverwrite($config_overwrite) |
|
| 1330 | - { |
|
| 1331 | - $this->config_overwrite = $config_overwrite; |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - /** |
|
| 1335 | - * @param boolean $config_booleanize |
|
| 1336 | - */ |
|
| 1337 | - public function setConfigBooleanize($config_booleanize) |
|
| 1338 | - { |
|
| 1339 | - $this->config_booleanize = $config_booleanize; |
|
| 1340 | - } |
|
| 1341 | - |
|
| 1342 | - /** |
|
| 1343 | - * @param boolean $config_read_hidden |
|
| 1344 | - */ |
|
| 1345 | - public function setConfigReadHidden($config_read_hidden) |
|
| 1346 | - { |
|
| 1347 | - $this->config_read_hidden = $config_read_hidden; |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - /** |
|
| 1351 | - * @param boolean $compile_locking |
|
| 1352 | - */ |
|
| 1353 | - public function setCompileLocking($compile_locking) |
|
| 1354 | - { |
|
| 1355 | - $this->compile_locking = $compile_locking; |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - /** |
|
| 1359 | - * @param string $default_resource_type |
|
| 1360 | - */ |
|
| 1361 | - public function setDefaultResourceType($default_resource_type) |
|
| 1362 | - { |
|
| 1363 | - $this->default_resource_type = $default_resource_type; |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * @param string $caching_type |
|
| 1368 | - */ |
|
| 1369 | - public function setCachingType($caching_type) |
|
| 1370 | - { |
|
| 1371 | - $this->caching_type = $caching_type; |
|
| 1372 | - } |
|
| 1373 | - |
|
| 1374 | - /** |
|
| 1375 | - * Test install |
|
| 1376 | - * |
|
| 1377 | - * @param null $errors |
|
| 1378 | - */ |
|
| 1379 | - public function testInstall(&$errors = null) |
|
| 1380 | - { |
|
| 1381 | - Smarty_Internal_TestInstall::testInstall($this, $errors); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * <<magic>> Generic getter. |
|
| 1386 | - * Calls the appropriate getter function. |
|
| 1387 | - * Issues an E_USER_NOTICE if no valid getter is found. |
|
| 1388 | - * |
|
| 1389 | - * @param string $name property name |
|
| 1390 | - * |
|
| 1391 | - * @return mixed |
|
| 1392 | - */ |
|
| 1393 | - public function __get($name) |
|
| 1394 | - { |
|
| 1395 | - if (isset($this->accessMap[ $name ])) { |
|
| 1396 | - $method = 'get' . $this->accessMap[ $name ]; |
|
| 1397 | - return $this->{$method}(); |
|
| 1398 | - } elseif (isset($this->_cache[ $name ])) { |
|
| 1399 | - return $this->_cache[ $name ]; |
|
| 1400 | - } elseif (in_array($name, $this->obsoleteProperties)) { |
|
| 1401 | - return null; |
|
| 1402 | - } else { |
|
| 1403 | - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); |
|
| 1404 | - } |
|
| 1405 | - return null; |
|
| 1406 | - } |
|
| 1407 | - |
|
| 1408 | - /** |
|
| 1409 | - * <<magic>> Generic setter. |
|
| 1410 | - * Calls the appropriate setter function. |
|
| 1411 | - * Issues an E_USER_NOTICE if no valid setter is found. |
|
| 1412 | - * |
|
| 1413 | - * @param string $name property name |
|
| 1414 | - * @param mixed $value parameter passed to setter |
|
| 1415 | - */ |
|
| 1416 | - public function __set($name, $value) |
|
| 1417 | - { |
|
| 1418 | - if (isset($this->accessMap[ $name ])) { |
|
| 1419 | - $method = 'set' . $this->accessMap[ $name ]; |
|
| 1420 | - $this->{$method}($value); |
|
| 1421 | - } elseif (in_array($name, $this->obsoleteProperties)) { |
|
| 1422 | - return; |
|
| 1423 | - } else { |
|
| 1424 | - if (is_object($value) && method_exists($value, $name)) { |
|
| 1425 | - $this->$name = $value; |
|
| 1426 | - } else { |
|
| 1427 | - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); |
|
| 1428 | - } |
|
| 1429 | - } |
|
| 1430 | - } |
|
| 1431 | - |
|
| 1432 | - /** |
|
| 1433 | - * Error Handler to mute expected messages |
|
| 1434 | - * |
|
| 1435 | - * @link http://php.net/set_error_handler |
|
| 1436 | - * |
|
| 1437 | - * @param integer $errno Error level |
|
| 1438 | - * @param $errstr |
|
| 1439 | - * @param $errfile |
|
| 1440 | - * @param $errline |
|
| 1441 | - * @param $errcontext |
|
| 1442 | - * |
|
| 1443 | - * @return bool|void |
|
| 1444 | - */ |
|
| 1445 | - public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) |
|
| 1446 | - { |
|
| 1447 | - $_is_muted_directory = false; |
|
| 1448 | - |
|
| 1449 | - // add the SMARTY_DIR to the list of muted directories |
|
| 1450 | - if (!isset(Smarty::$_muted_directories[ SMARTY_DIR ])) { |
|
| 1451 | - $smarty_dir = realpath(SMARTY_DIR); |
|
| 1452 | - if ($smarty_dir !== false) { |
|
| 1453 | - Smarty::$_muted_directories[ SMARTY_DIR ] = |
|
| 1454 | - array('file' => $smarty_dir, 'length' => strlen($smarty_dir),); |
|
| 1455 | - } |
|
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - // walk the muted directories and test against $errfile |
|
| 1459 | - foreach (Smarty::$_muted_directories as $key => &$dir) { |
|
| 1460 | - if (!$dir) { |
|
| 1461 | - // resolve directory and length for speedy comparisons |
|
| 1462 | - $file = realpath($key); |
|
| 1463 | - if ($file === false) { |
|
| 1464 | - // this directory does not exist, remove and skip it |
|
| 1465 | - unset(Smarty::$_muted_directories[ $key ]); |
|
| 1466 | - continue; |
|
| 1467 | - } |
|
| 1468 | - $dir = array('file' => $file, 'length' => strlen($file),); |
|
| 1469 | - } |
|
| 1470 | - if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) { |
|
| 1471 | - $_is_muted_directory = true; |
|
| 1472 | - break; |
|
| 1473 | - } |
|
| 1474 | - } |
|
| 1475 | - // pass to next error handler if this error did not occur inside SMARTY_DIR |
|
| 1476 | - // or the error was within smarty but masked to be ignored |
|
| 1477 | - if (!$_is_muted_directory || ($errno && $errno & error_reporting())) { |
|
| 1478 | - if (Smarty::$_previous_error_handler) { |
|
| 1479 | - return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, |
|
| 1480 | - $errcontext); |
|
| 1481 | - } else { |
|
| 1482 | - return false; |
|
| 1483 | - } |
|
| 1484 | - } |
|
| 1485 | - return; |
|
| 1486 | - } |
|
| 1487 | - |
|
| 1488 | - /** |
|
| 1489 | - * Enable error handler to mute expected messages |
|
| 1490 | - * |
|
| 1491 | - * @return void |
|
| 1492 | - */ |
|
| 1493 | - public static function muteExpectedErrors() |
|
| 1494 | - { |
|
| 1495 | - /* |
|
| 570 | + /** |
|
| 571 | + * locking concurrent compiles |
|
| 572 | + * |
|
| 573 | + * @var boolean |
|
| 574 | + */ |
|
| 575 | + public $compile_locking = true; |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Controls whether cache resources should use locking mechanism |
|
| 579 | + * |
|
| 580 | + * @var boolean |
|
| 581 | + */ |
|
| 582 | + public $cache_locking = false; |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * seconds to wait for acquiring a lock before ignoring the write lock |
|
| 586 | + * |
|
| 587 | + * @var float |
|
| 588 | + */ |
|
| 589 | + public $locking_timeout = 10; |
|
| 590 | + |
|
| 591 | + /**#@-*/ |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * resource type used if none given |
|
| 595 | + * Must be an valid key of $registered_resources. |
|
| 596 | + * |
|
| 597 | + * @var string |
|
| 598 | + */ |
|
| 599 | + public $default_resource_type = 'file'; |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * caching type |
|
| 603 | + * Must be an element of $cache_resource_types. |
|
| 604 | + * |
|
| 605 | + * @var string |
|
| 606 | + */ |
|
| 607 | + public $caching_type = 'file'; |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * config type |
|
| 611 | + * |
|
| 612 | + * @var string |
|
| 613 | + */ |
|
| 614 | + public $default_config_type = 'file'; |
|
| 615 | + |
|
| 616 | + /** |
|
| 617 | + * check If-Modified-Since headers |
|
| 618 | + * |
|
| 619 | + * @var boolean |
|
| 620 | + */ |
|
| 621 | + public $cache_modified_check = false; |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * registered plugins |
|
| 625 | + * |
|
| 626 | + * @var array |
|
| 627 | + */ |
|
| 628 | + public $registered_plugins = array(); |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * registered objects |
|
| 632 | + * |
|
| 633 | + * @var array |
|
| 634 | + */ |
|
| 635 | + public $registered_objects = array(); |
|
| 636 | + |
|
| 637 | + /** |
|
| 638 | + * registered classes |
|
| 639 | + * |
|
| 640 | + * @var array |
|
| 641 | + */ |
|
| 642 | + public $registered_classes = array(); |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * registered filters |
|
| 646 | + * |
|
| 647 | + * @var array |
|
| 648 | + */ |
|
| 649 | + public $registered_filters = array(); |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * registered resources |
|
| 653 | + * |
|
| 654 | + * @var array |
|
| 655 | + */ |
|
| 656 | + public $registered_resources = array(); |
|
| 657 | + |
|
| 658 | + /** |
|
| 659 | + * registered cache resources |
|
| 660 | + * |
|
| 661 | + * @var array |
|
| 662 | + */ |
|
| 663 | + public $registered_cache_resources = array(); |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * autoload filter |
|
| 667 | + * |
|
| 668 | + * @var array |
|
| 669 | + */ |
|
| 670 | + public $autoload_filters = array(); |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * default modifier |
|
| 674 | + * |
|
| 675 | + * @var array |
|
| 676 | + */ |
|
| 677 | + public $default_modifiers = array(); |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * autoescape variable output |
|
| 681 | + * |
|
| 682 | + * @var boolean |
|
| 683 | + */ |
|
| 684 | + public $escape_html = false; |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * start time for execution time calculation |
|
| 688 | + * |
|
| 689 | + * @var int |
|
| 690 | + */ |
|
| 691 | + public $start_time = 0; |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * required by the compiler for BC |
|
| 695 | + * |
|
| 696 | + * @var string |
|
| 697 | + */ |
|
| 698 | + public $_current_file = null; |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * internal flag to enable parser debugging |
|
| 702 | + * |
|
| 703 | + * @var bool |
|
| 704 | + */ |
|
| 705 | + public $_parserdebug = false; |
|
| 706 | + |
|
| 707 | + /** |
|
| 708 | + * This object type (Smarty = 1, template = 2, data = 4) |
|
| 709 | + * |
|
| 710 | + * @var int |
|
| 711 | + */ |
|
| 712 | + public $_objType = 1; |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * Debug object |
|
| 716 | + * |
|
| 717 | + * @var Smarty_Internal_Debug |
|
| 718 | + */ |
|
| 719 | + public $_debug = null; |
|
| 720 | + |
|
| 721 | + /** |
|
| 722 | + * removed properties |
|
| 723 | + * |
|
| 724 | + * @var string[] |
|
| 725 | + */ |
|
| 726 | + private $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security', |
|
| 727 | + '_dir_perms', '_file_perms', 'plugin_search_order', |
|
| 728 | + 'inheritance_merge_compiled_includes', 'resource_cache_mode',); |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * List of private properties which will call getter/setter on a direct access |
|
| 732 | + * |
|
| 733 | + * @var string[] |
|
| 734 | + */ |
|
| 735 | + private $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir', |
|
| 736 | + 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir', |
|
| 737 | + 'cache_dir' => 'CacheDir',); |
|
| 738 | + |
|
| 739 | + /**#@-*/ |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * Initialize new Smarty object |
|
| 743 | + */ |
|
| 744 | + public function __construct() |
|
| 745 | + { |
|
| 746 | + parent::__construct(); |
|
| 747 | + if (is_callable('mb_internal_encoding')) { |
|
| 748 | + mb_internal_encoding(Smarty::$_CHARSET); |
|
| 749 | + } |
|
| 750 | + $this->start_time = microtime(true); |
|
| 751 | + |
|
| 752 | + if (isset($_SERVER[ 'SCRIPT_NAME' ])) { |
|
| 753 | + Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new Smarty_Variable($_SERVER[ 'SCRIPT_NAME' ]); |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + // Check if we're running on windows |
|
| 757 | + Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; |
|
| 758 | + // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 |
|
| 759 | + if (Smarty::$_CHARSET !== 'UTF-8') { |
|
| 760 | + Smarty::$_UTF8_MODIFIER = ''; |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + /** |
|
| 765 | + * Check if a template resource exists |
|
| 766 | + * |
|
| 767 | + * @param string $resource_name template name |
|
| 768 | + * |
|
| 769 | + * @return boolean status |
|
| 770 | + */ |
|
| 771 | + public function templateExists($resource_name) |
|
| 772 | + { |
|
| 773 | + // create source object |
|
| 774 | + $source = Smarty_Template_Source::load(null, $this, $resource_name); |
|
| 775 | + return $source->exists; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * Loads security class and enables security |
|
| 780 | + * |
|
| 781 | + * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
| 782 | + * |
|
| 783 | + * @return Smarty current Smarty instance for chaining |
|
| 784 | + * @throws SmartyException when an invalid class name is provided |
|
| 785 | + */ |
|
| 786 | + public function enableSecurity($security_class = null) |
|
| 787 | + { |
|
| 788 | + Smarty_Security::enableSecurity($this, $security_class); |
|
| 789 | + return $this; |
|
| 790 | + } |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * Disable security |
|
| 794 | + * |
|
| 795 | + * @return Smarty current Smarty instance for chaining |
|
| 796 | + */ |
|
| 797 | + public function disableSecurity() |
|
| 798 | + { |
|
| 799 | + $this->security_policy = null; |
|
| 800 | + |
|
| 801 | + return $this; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + /** |
|
| 805 | + * Set template directory |
|
| 806 | + * |
|
| 807 | + * @param string|array $template_dir directory(s) of template sources |
|
| 808 | + * @param bool $isConfig true for config_dir |
|
| 809 | + * |
|
| 810 | + * @return \Smarty current Smarty instance for chaining |
|
| 811 | + */ |
|
| 812 | + public function setTemplateDir($template_dir, $isConfig = false) |
|
| 813 | + { |
|
| 814 | + if ($isConfig) { |
|
| 815 | + $this->config_dir = array(); |
|
| 816 | + $this->_processedConfigDir = array(); |
|
| 817 | + } else { |
|
| 818 | + $this->template_dir = array(); |
|
| 819 | + $this->_processedTemplateDir = array(); |
|
| 820 | + } |
|
| 821 | + $this->addTemplateDir($template_dir, null, $isConfig); |
|
| 822 | + return $this; |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * Add template directory(s) |
|
| 827 | + * |
|
| 828 | + * @param string|array $template_dir directory(s) of template sources |
|
| 829 | + * @param string $key of the array element to assign the template dir to |
|
| 830 | + * @param bool $isConfig true for config_dir |
|
| 831 | + * |
|
| 832 | + * @return Smarty current Smarty instance for chaining |
|
| 833 | + */ |
|
| 834 | + public function addTemplateDir($template_dir, $key = null, $isConfig = false) |
|
| 835 | + { |
|
| 836 | + if ($isConfig) { |
|
| 837 | + $processed = &$this->_processedConfigDir; |
|
| 838 | + $dir = &$this->config_dir; |
|
| 839 | + $this->_configDirNormalized = false; |
|
| 840 | + } else { |
|
| 841 | + $processed = &$this->_processedTemplateDir; |
|
| 842 | + $dir = &$this->template_dir; |
|
| 843 | + $this->_templateDirNormalized = false; |
|
| 844 | + } |
|
| 845 | + if (is_array($template_dir)) { |
|
| 846 | + foreach ($template_dir as $k => $v) { |
|
| 847 | + if (is_int($k)) { |
|
| 848 | + // indexes are not merged but appended |
|
| 849 | + $dir[] = $v; |
|
| 850 | + } else { |
|
| 851 | + // string indexes are overridden |
|
| 852 | + $dir[ $k ] = $v; |
|
| 853 | + unset($processed[ $key ]); |
|
| 854 | + } |
|
| 855 | + } |
|
| 856 | + } else { |
|
| 857 | + if ($key !== null) { |
|
| 858 | + // override directory at specified index |
|
| 859 | + $dir[ $key ] = $template_dir; |
|
| 860 | + unset($processed[ $key ]); |
|
| 861 | + } else { |
|
| 862 | + // append new directory |
|
| 863 | + $dir[] = $template_dir; |
|
| 864 | + } |
|
| 865 | + } |
|
| 866 | + return $this; |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + /** |
|
| 870 | + * Get template directories |
|
| 871 | + * |
|
| 872 | + * @param mixed $index index of directory to get, null to get all |
|
| 873 | + * @param bool $isConfig true for config_dir |
|
| 874 | + * |
|
| 875 | + * @return array list of template directories, or directory of $index |
|
| 876 | + */ |
|
| 877 | + public function getTemplateDir($index = null, $isConfig = false) |
|
| 878 | + { |
|
| 879 | + if ($isConfig) { |
|
| 880 | + $dir = &$this->config_dir; |
|
| 881 | + } else { |
|
| 882 | + $dir = &$this->template_dir; |
|
| 883 | + } |
|
| 884 | + if ($isConfig ? !$this->_configDirNormalized : !$this->_templateDirNormalized) { |
|
| 885 | + $this->_nomalizeTemplateConfig($isConfig); |
|
| 886 | + } |
|
| 887 | + if ($index !== null) { |
|
| 888 | + return isset($dir[ $index ]) ? $dir[ $index ] : null; |
|
| 889 | + } |
|
| 890 | + return $dir; |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + /** |
|
| 894 | + * Set config directory |
|
| 895 | + * |
|
| 896 | + * @param $config_dir |
|
| 897 | + * |
|
| 898 | + * @return Smarty current Smarty instance for chaining |
|
| 899 | + */ |
|
| 900 | + public function setConfigDir($config_dir) |
|
| 901 | + { |
|
| 902 | + return $this->setTemplateDir($config_dir, true); |
|
| 903 | + } |
|
| 904 | + |
|
| 905 | + /** |
|
| 906 | + * Add config directory(s) |
|
| 907 | + * |
|
| 908 | + * @param string|array $config_dir directory(s) of config sources |
|
| 909 | + * @param mixed $key key of the array element to assign the config dir to |
|
| 910 | + * |
|
| 911 | + * @return Smarty current Smarty instance for chaining |
|
| 912 | + */ |
|
| 913 | + public function addConfigDir($config_dir, $key = null) |
|
| 914 | + { |
|
| 915 | + return $this->addTemplateDir($config_dir, $key, true); |
|
| 916 | + } |
|
| 917 | + |
|
| 918 | + /** |
|
| 919 | + * Get config directory |
|
| 920 | + * |
|
| 921 | + * @param mixed $index index of directory to get, null to get all |
|
| 922 | + * |
|
| 923 | + * @return array configuration directory |
|
| 924 | + */ |
|
| 925 | + public function getConfigDir($index = null) |
|
| 926 | + { |
|
| 927 | + return $this->getTemplateDir($index, true); |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * Set plugins directory |
|
| 932 | + * |
|
| 933 | + * @param string|array $plugins_dir directory(s) of plugins |
|
| 934 | + * |
|
| 935 | + * @return Smarty current Smarty instance for chaining |
|
| 936 | + */ |
|
| 937 | + public function setPluginsDir($plugins_dir) |
|
| 938 | + { |
|
| 939 | + $this->plugins_dir = (array) $plugins_dir; |
|
| 940 | + $this->_pluginsDirNormalized = false; |
|
| 941 | + return $this; |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + /** |
|
| 945 | + * Adds directory of plugin files |
|
| 946 | + * |
|
| 947 | + * @param null|array $plugins_dir |
|
| 948 | + * |
|
| 949 | + * @return Smarty current Smarty instance for chaining |
|
| 950 | + */ |
|
| 951 | + public function addPluginsDir($plugins_dir) |
|
| 952 | + { |
|
| 953 | + if (empty($this->plugins_dir)) { |
|
| 954 | + $this->plugins_dir[] = SMARTY_PLUGINS_DIR; |
|
| 955 | + } |
|
| 956 | + $this->plugins_dir = array_merge($this->plugins_dir, (array) $plugins_dir); |
|
| 957 | + $this->_pluginsDirNormalized = false; |
|
| 958 | + return $this; |
|
| 959 | + } |
|
| 960 | + |
|
| 961 | + /** |
|
| 962 | + * Get plugin directories |
|
| 963 | + * |
|
| 964 | + * @return array list of plugin directories |
|
| 965 | + */ |
|
| 966 | + public function getPluginsDir() |
|
| 967 | + { |
|
| 968 | + if (empty($this->plugins_dir)) { |
|
| 969 | + $this->plugins_dir[] = SMARTY_PLUGINS_DIR; |
|
| 970 | + $this->_pluginsDirNormalized = false; |
|
| 971 | + } |
|
| 972 | + if (!$this->_pluginsDirNormalized) { |
|
| 973 | + if (!is_array($this->plugins_dir)) { |
|
| 974 | + $this->plugins_dir = (array) $this->plugins_dir; |
|
| 975 | + } |
|
| 976 | + foreach ($this->plugins_dir as $k => $v) { |
|
| 977 | + $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 978 | + } |
|
| 979 | + $this->_cache[ 'plugin_files' ] = array(); |
|
| 980 | + $this->_pluginsDirNormalized = true; |
|
| 981 | + } |
|
| 982 | + return $this->plugins_dir; |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * |
|
| 987 | + * @param string $compile_dir directory to store compiled templates in |
|
| 988 | + * |
|
| 989 | + * @return Smarty current Smarty instance for chaining |
|
| 990 | + */ |
|
| 991 | + public function setCompileDir($compile_dir) |
|
| 992 | + { |
|
| 993 | + $this->_normalizeDir('compile_dir', $compile_dir); |
|
| 994 | + $this->_compileDirNormalized = true; |
|
| 995 | + return $this; |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + /** |
|
| 999 | + * Get compiled directory |
|
| 1000 | + * |
|
| 1001 | + * @return string path to compiled templates |
|
| 1002 | + */ |
|
| 1003 | + public function getCompileDir() |
|
| 1004 | + { |
|
| 1005 | + if (!$this->_compileDirNormalized) { |
|
| 1006 | + $this->_normalizeDir('compile_dir', $this->compile_dir); |
|
| 1007 | + $this->_compileDirNormalized = true; |
|
| 1008 | + } |
|
| 1009 | + return $this->compile_dir; |
|
| 1010 | + } |
|
| 1011 | + |
|
| 1012 | + /** |
|
| 1013 | + * Set cache directory |
|
| 1014 | + * |
|
| 1015 | + * @param string $cache_dir directory to store cached templates in |
|
| 1016 | + * |
|
| 1017 | + * @return Smarty current Smarty instance for chaining |
|
| 1018 | + */ |
|
| 1019 | + public function setCacheDir($cache_dir) |
|
| 1020 | + { |
|
| 1021 | + $this->_normalizeDir('cache_dir', $cache_dir); |
|
| 1022 | + $this->_cacheDirNormalized = true; |
|
| 1023 | + return $this; |
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + /** |
|
| 1027 | + * Get cache directory |
|
| 1028 | + * |
|
| 1029 | + * @return string path of cache directory |
|
| 1030 | + */ |
|
| 1031 | + public function getCacheDir() |
|
| 1032 | + { |
|
| 1033 | + if (!$this->_cacheDirNormalized) { |
|
| 1034 | + $this->_normalizeDir('cache_dir', $this->cache_dir); |
|
| 1035 | + $this->_cacheDirNormalized = true; |
|
| 1036 | + } |
|
| 1037 | + return $this->cache_dir; |
|
| 1038 | + } |
|
| 1039 | + |
|
| 1040 | + /** |
|
| 1041 | + * Normalize and set directory string |
|
| 1042 | + * |
|
| 1043 | + * @param string $dirName cache_dir or compile_dir |
|
| 1044 | + * @param string $dir filepath of folder |
|
| 1045 | + */ |
|
| 1046 | + private function _normalizeDir($dirName, $dir) |
|
| 1047 | + { |
|
| 1048 | + $this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DS, true); |
|
| 1049 | + if (!isset(Smarty::$_muted_directories[ $this->{$dirName} ])) { |
|
| 1050 | + Smarty::$_muted_directories[ $this->{$dirName} ] = null; |
|
| 1051 | + } |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + /** |
|
| 1055 | + * Normalize template_dir or config_dir |
|
| 1056 | + * |
|
| 1057 | + * @param bool $isConfig true for config_dir |
|
| 1058 | + * |
|
| 1059 | + */ |
|
| 1060 | + private function _nomalizeTemplateConfig($isConfig) |
|
| 1061 | + { |
|
| 1062 | + if ($isConfig) { |
|
| 1063 | + $processed = &$this->_processedConfigDir; |
|
| 1064 | + $dir = &$this->config_dir; |
|
| 1065 | + } else { |
|
| 1066 | + $processed = &$this->_processedTemplateDir; |
|
| 1067 | + $dir = &$this->template_dir; |
|
| 1068 | + } |
|
| 1069 | + if (!is_array($dir)) { |
|
| 1070 | + $dir = (array) $dir; |
|
| 1071 | + } |
|
| 1072 | + foreach ($dir as $k => $v) { |
|
| 1073 | + if (!isset($processed[ $k ])) { |
|
| 1074 | + $dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 1075 | + $processed[ $k ] = true; |
|
| 1076 | + } |
|
| 1077 | + } |
|
| 1078 | + $isConfig ? $this->_configDirNormalized = true : $this->_templateDirNormalized = true; |
|
| 1079 | + $isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) : |
|
| 1080 | + $this->_joined_template_dir = join('#', $this->template_dir); |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + /** |
|
| 1084 | + * creates a template object |
|
| 1085 | + * |
|
| 1086 | + * @param string $template the resource handle of the template file |
|
| 1087 | + * @param mixed $cache_id cache id to be used with this template |
|
| 1088 | + * @param mixed $compile_id compile id to be used with this template |
|
| 1089 | + * @param object $parent next higher level of Smarty variables |
|
| 1090 | + * @param boolean $do_clone flag is Smarty object shall be cloned |
|
| 1091 | + * |
|
| 1092 | + * @return object template object |
|
| 1093 | + */ |
|
| 1094 | + public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) |
|
| 1095 | + { |
|
| 1096 | + if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) { |
|
| 1097 | + $parent = $cache_id; |
|
| 1098 | + $cache_id = null; |
|
| 1099 | + } |
|
| 1100 | + if ($parent !== null && is_array($parent)) { |
|
| 1101 | + $data = $parent; |
|
| 1102 | + $parent = null; |
|
| 1103 | + } else { |
|
| 1104 | + $data = null; |
|
| 1105 | + } |
|
| 1106 | + $_templateId = $this->_getTemplateId($template, $cache_id, $compile_id); |
|
| 1107 | + $tpl = null; |
|
| 1108 | + if ($this->caching && isset($this->_cache[ 'isCached' ][ $_templateId ])) { |
|
| 1109 | + $tpl = $do_clone ? clone $this->_cache[ 'isCached' ][ $_templateId ] : |
|
| 1110 | + $this->_cache[ 'isCached' ][ $_templateId ]; |
|
| 1111 | + $tpl->tpl_vars = $tpl->config_vars = array(); |
|
| 1112 | + } else if (!$do_clone && isset($this->_cache[ 'tplObjects' ][ $_templateId ])) { |
|
| 1113 | + $tpl = clone $this->_cache[ 'tplObjects' ][ $_templateId ]; |
|
| 1114 | + } else { |
|
| 1115 | + /* @var Smarty_Internal_Template $tpl */ |
|
| 1116 | + $tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null); |
|
| 1117 | + $tpl->templateId = $_templateId; |
|
| 1118 | + } |
|
| 1119 | + if ($do_clone) { |
|
| 1120 | + $tpl->smarty = clone $tpl->smarty; |
|
| 1121 | + } |
|
| 1122 | + $tpl->parent = $parent ? $parent : $this; |
|
| 1123 | + // fill data if present |
|
| 1124 | + if (!empty($data) && is_array($data)) { |
|
| 1125 | + // set up variable values |
|
| 1126 | + foreach ($data as $_key => $_val) { |
|
| 1127 | + $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 1128 | + } |
|
| 1129 | + } |
|
| 1130 | + if ($this->debugging || $this->debugging_ctrl == 'URL') { |
|
| 1131 | + $tpl->smarty->_debug = new Smarty_Internal_Debug(); |
|
| 1132 | + // check URL debugging control |
|
| 1133 | + if (!$this->debugging && $this->debugging_ctrl == 'URL') { |
|
| 1134 | + $tpl->smarty->_debug->debugUrl($tpl->smarty); |
|
| 1135 | + } |
|
| 1136 | + } |
|
| 1137 | + return $tpl; |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + /** |
|
| 1141 | + * Takes unknown classes and loads plugin files for them |
|
| 1142 | + * class name format: Smarty_PluginType_PluginName |
|
| 1143 | + * plugin filename format: plugintype.pluginname.php |
|
| 1144 | + * |
|
| 1145 | + * @param string $plugin_name class plugin name to load |
|
| 1146 | + * @param bool $check check if already loaded |
|
| 1147 | + * |
|
| 1148 | + * @throws SmartyException |
|
| 1149 | + * @return string |boolean filepath of loaded file or false |
|
| 1150 | + */ |
|
| 1151 | + public function loadPlugin($plugin_name, $check = true) |
|
| 1152 | + { |
|
| 1153 | + return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check); |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + /** |
|
| 1157 | + * Get unique template id |
|
| 1158 | + * |
|
| 1159 | + * @param string $template_name |
|
| 1160 | + * @param null|mixed $cache_id |
|
| 1161 | + * @param null|mixed $compile_id |
|
| 1162 | + * @param null $caching |
|
| 1163 | + * @param \Smarty_Internal_Template $template |
|
| 1164 | + * |
|
| 1165 | + * @return string |
|
| 1166 | + */ |
|
| 1167 | + public function _getTemplateId($template_name, $cache_id = null, $compile_id = null, $caching = null, |
|
| 1168 | + Smarty_Internal_Template $template = null) |
|
| 1169 | + { |
|
| 1170 | + $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : |
|
| 1171 | + $template_name; |
|
| 1172 | + $cache_id = $cache_id === null ? $this->cache_id : $cache_id; |
|
| 1173 | + $compile_id = $compile_id === null ? $this->compile_id : $compile_id; |
|
| 1174 | + $caching = (int) ($caching === null ? $this->caching : $caching); |
|
| 1175 | + |
|
| 1176 | + if ((isset($template) && strpos($template_name, ':.') !== false) || $this->allow_ambiguous_resources) { |
|
| 1177 | + $_templateId = |
|
| 1178 | + Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) . |
|
| 1179 | + "#{$cache_id}#{$compile_id}#{$caching}"; |
|
| 1180 | + } else { |
|
| 1181 | + $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}"; |
|
| 1182 | + } |
|
| 1183 | + if (isset($_templateId[ 150 ])) { |
|
| 1184 | + $_templateId = sha1($_templateId); |
|
| 1185 | + } |
|
| 1186 | + return $_templateId; |
|
| 1187 | + } |
|
| 1188 | + |
|
| 1189 | + /** |
|
| 1190 | + * Normalize path |
|
| 1191 | + * - remove /./ and /../ |
|
| 1192 | + * - make it absolute if required |
|
| 1193 | + * |
|
| 1194 | + * @param string $path file path |
|
| 1195 | + * @param bool $realpath if true - convert to absolute |
|
| 1196 | + * false - convert to relative |
|
| 1197 | + * null - keep as it is but remove /./ /../ |
|
| 1198 | + * |
|
| 1199 | + * @return string |
|
| 1200 | + */ |
|
| 1201 | + public function _realpath($path, $realpath = null) |
|
| 1202 | + { |
|
| 1203 | + $nds = DS == '/' ? '\\' : '/'; |
|
| 1204 | + // normalize DS |
|
| 1205 | + $path = str_replace($nds, DS, $path); |
|
| 1206 | + preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%', |
|
| 1207 | + $path, $parts); |
|
| 1208 | + $path = $parts[ 'path' ]; |
|
| 1209 | + if ($parts[ 'root' ] == '\\') { |
|
| 1210 | + $parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ]; |
|
| 1211 | + } else { |
|
| 1212 | + if ($realpath !== null && !$parts[ 'root' ]) { |
|
| 1213 | + $path = getcwd() . DS . $path; |
|
| 1214 | + } |
|
| 1215 | + } |
|
| 1216 | + // remove noop 'DS DS' and 'DS.DS' patterns |
|
| 1217 | + $path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#', DS, $path); |
|
| 1218 | + // resolve '..DS' pattern, smallest first |
|
| 1219 | + if (strpos($path, '..' . DS) != false && |
|
| 1220 | + preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#', $path, $match) |
|
| 1221 | + ) { |
|
| 1222 | + $counts = array(); |
|
| 1223 | + foreach ($match[ 0 ] as $m) { |
|
| 1224 | + $counts[] = (int) ((strlen($m) - 1) / 3); |
|
| 1225 | + } |
|
| 1226 | + sort($counts); |
|
| 1227 | + foreach ($counts as $count) { |
|
| 1228 | + $path = preg_replace('#(([\\\\/]([.]?[\\\\/])*[^\\\\/.]+){' . $count . |
|
| 1229 | + '}[\\\\/]([.]?[\\\\/])*([.][.][\\\\/]([.]?[\\\\/])*){' . $count . '})(?=[^.])#', |
|
| 1230 | + DS, $path); |
|
| 1231 | + } |
|
| 1232 | + } |
|
| 1233 | + |
|
| 1234 | + return $parts[ 'root' ] . $path; |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + /** |
|
| 1238 | + * Empty template objects cache |
|
| 1239 | + */ |
|
| 1240 | + public function _clearTemplateCache() |
|
| 1241 | + { |
|
| 1242 | + $this->_cache[ 'isCached' ] = array(); |
|
| 1243 | + $this->_cache[ 'tplObjects' ] = array(); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + /** |
|
| 1247 | + * @param boolean $compile_check |
|
| 1248 | + */ |
|
| 1249 | + public function setCompileCheck($compile_check) |
|
| 1250 | + { |
|
| 1251 | + $this->compile_check = $compile_check; |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + /** |
|
| 1255 | + * @param boolean $use_sub_dirs |
|
| 1256 | + */ |
|
| 1257 | + public function setUseSubDirs($use_sub_dirs) |
|
| 1258 | + { |
|
| 1259 | + $this->use_sub_dirs = $use_sub_dirs; |
|
| 1260 | + } |
|
| 1261 | + |
|
| 1262 | + /** |
|
| 1263 | + * @param int $error_reporting |
|
| 1264 | + */ |
|
| 1265 | + public function setErrorReporting($error_reporting) |
|
| 1266 | + { |
|
| 1267 | + $this->error_reporting = $error_reporting; |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + /** |
|
| 1271 | + * @param boolean $escape_html |
|
| 1272 | + */ |
|
| 1273 | + public function setEscapeHtml($escape_html) |
|
| 1274 | + { |
|
| 1275 | + $this->escape_html = $escape_html; |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /** |
|
| 1279 | + * @param boolean $auto_literal |
|
| 1280 | + */ |
|
| 1281 | + public function setAutoLiteral($auto_literal) |
|
| 1282 | + { |
|
| 1283 | + $this->auto_literal = $auto_literal; |
|
| 1284 | + } |
|
| 1285 | + |
|
| 1286 | + /** |
|
| 1287 | + * @param boolean $force_compile |
|
| 1288 | + */ |
|
| 1289 | + public function setForceCompile($force_compile) |
|
| 1290 | + { |
|
| 1291 | + $this->force_compile = $force_compile; |
|
| 1292 | + } |
|
| 1293 | + |
|
| 1294 | + /** |
|
| 1295 | + * @param boolean $merge_compiled_includes |
|
| 1296 | + */ |
|
| 1297 | + public function setMergeCompiledIncludes($merge_compiled_includes) |
|
| 1298 | + { |
|
| 1299 | + $this->merge_compiled_includes = $merge_compiled_includes; |
|
| 1300 | + } |
|
| 1301 | + |
|
| 1302 | + /** |
|
| 1303 | + * @param string $left_delimiter |
|
| 1304 | + */ |
|
| 1305 | + public function setLeftDelimiter($left_delimiter) |
|
| 1306 | + { |
|
| 1307 | + $this->left_delimiter = $left_delimiter; |
|
| 1308 | + } |
|
| 1309 | + |
|
| 1310 | + /** |
|
| 1311 | + * @param string $right_delimiter |
|
| 1312 | + */ |
|
| 1313 | + public function setRightDelimiter($right_delimiter) |
|
| 1314 | + { |
|
| 1315 | + $this->right_delimiter = $right_delimiter; |
|
| 1316 | + } |
|
| 1317 | + |
|
| 1318 | + /** |
|
| 1319 | + * @param boolean $debugging |
|
| 1320 | + */ |
|
| 1321 | + public function setDebugging($debugging) |
|
| 1322 | + { |
|
| 1323 | + $this->debugging = $debugging; |
|
| 1324 | + } |
|
| 1325 | + |
|
| 1326 | + /** |
|
| 1327 | + * @param boolean $config_overwrite |
|
| 1328 | + */ |
|
| 1329 | + public function setConfigOverwrite($config_overwrite) |
|
| 1330 | + { |
|
| 1331 | + $this->config_overwrite = $config_overwrite; |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + /** |
|
| 1335 | + * @param boolean $config_booleanize |
|
| 1336 | + */ |
|
| 1337 | + public function setConfigBooleanize($config_booleanize) |
|
| 1338 | + { |
|
| 1339 | + $this->config_booleanize = $config_booleanize; |
|
| 1340 | + } |
|
| 1341 | + |
|
| 1342 | + /** |
|
| 1343 | + * @param boolean $config_read_hidden |
|
| 1344 | + */ |
|
| 1345 | + public function setConfigReadHidden($config_read_hidden) |
|
| 1346 | + { |
|
| 1347 | + $this->config_read_hidden = $config_read_hidden; |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + /** |
|
| 1351 | + * @param boolean $compile_locking |
|
| 1352 | + */ |
|
| 1353 | + public function setCompileLocking($compile_locking) |
|
| 1354 | + { |
|
| 1355 | + $this->compile_locking = $compile_locking; |
|
| 1356 | + } |
|
| 1357 | + |
|
| 1358 | + /** |
|
| 1359 | + * @param string $default_resource_type |
|
| 1360 | + */ |
|
| 1361 | + public function setDefaultResourceType($default_resource_type) |
|
| 1362 | + { |
|
| 1363 | + $this->default_resource_type = $default_resource_type; |
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + /** |
|
| 1367 | + * @param string $caching_type |
|
| 1368 | + */ |
|
| 1369 | + public function setCachingType($caching_type) |
|
| 1370 | + { |
|
| 1371 | + $this->caching_type = $caching_type; |
|
| 1372 | + } |
|
| 1373 | + |
|
| 1374 | + /** |
|
| 1375 | + * Test install |
|
| 1376 | + * |
|
| 1377 | + * @param null $errors |
|
| 1378 | + */ |
|
| 1379 | + public function testInstall(&$errors = null) |
|
| 1380 | + { |
|
| 1381 | + Smarty_Internal_TestInstall::testInstall($this, $errors); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * <<magic>> Generic getter. |
|
| 1386 | + * Calls the appropriate getter function. |
|
| 1387 | + * Issues an E_USER_NOTICE if no valid getter is found. |
|
| 1388 | + * |
|
| 1389 | + * @param string $name property name |
|
| 1390 | + * |
|
| 1391 | + * @return mixed |
|
| 1392 | + */ |
|
| 1393 | + public function __get($name) |
|
| 1394 | + { |
|
| 1395 | + if (isset($this->accessMap[ $name ])) { |
|
| 1396 | + $method = 'get' . $this->accessMap[ $name ]; |
|
| 1397 | + return $this->{$method}(); |
|
| 1398 | + } elseif (isset($this->_cache[ $name ])) { |
|
| 1399 | + return $this->_cache[ $name ]; |
|
| 1400 | + } elseif (in_array($name, $this->obsoleteProperties)) { |
|
| 1401 | + return null; |
|
| 1402 | + } else { |
|
| 1403 | + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); |
|
| 1404 | + } |
|
| 1405 | + return null; |
|
| 1406 | + } |
|
| 1407 | + |
|
| 1408 | + /** |
|
| 1409 | + * <<magic>> Generic setter. |
|
| 1410 | + * Calls the appropriate setter function. |
|
| 1411 | + * Issues an E_USER_NOTICE if no valid setter is found. |
|
| 1412 | + * |
|
| 1413 | + * @param string $name property name |
|
| 1414 | + * @param mixed $value parameter passed to setter |
|
| 1415 | + */ |
|
| 1416 | + public function __set($name, $value) |
|
| 1417 | + { |
|
| 1418 | + if (isset($this->accessMap[ $name ])) { |
|
| 1419 | + $method = 'set' . $this->accessMap[ $name ]; |
|
| 1420 | + $this->{$method}($value); |
|
| 1421 | + } elseif (in_array($name, $this->obsoleteProperties)) { |
|
| 1422 | + return; |
|
| 1423 | + } else { |
|
| 1424 | + if (is_object($value) && method_exists($value, $name)) { |
|
| 1425 | + $this->$name = $value; |
|
| 1426 | + } else { |
|
| 1427 | + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); |
|
| 1428 | + } |
|
| 1429 | + } |
|
| 1430 | + } |
|
| 1431 | + |
|
| 1432 | + /** |
|
| 1433 | + * Error Handler to mute expected messages |
|
| 1434 | + * |
|
| 1435 | + * @link http://php.net/set_error_handler |
|
| 1436 | + * |
|
| 1437 | + * @param integer $errno Error level |
|
| 1438 | + * @param $errstr |
|
| 1439 | + * @param $errfile |
|
| 1440 | + * @param $errline |
|
| 1441 | + * @param $errcontext |
|
| 1442 | + * |
|
| 1443 | + * @return bool|void |
|
| 1444 | + */ |
|
| 1445 | + public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) |
|
| 1446 | + { |
|
| 1447 | + $_is_muted_directory = false; |
|
| 1448 | + |
|
| 1449 | + // add the SMARTY_DIR to the list of muted directories |
|
| 1450 | + if (!isset(Smarty::$_muted_directories[ SMARTY_DIR ])) { |
|
| 1451 | + $smarty_dir = realpath(SMARTY_DIR); |
|
| 1452 | + if ($smarty_dir !== false) { |
|
| 1453 | + Smarty::$_muted_directories[ SMARTY_DIR ] = |
|
| 1454 | + array('file' => $smarty_dir, 'length' => strlen($smarty_dir),); |
|
| 1455 | + } |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + // walk the muted directories and test against $errfile |
|
| 1459 | + foreach (Smarty::$_muted_directories as $key => &$dir) { |
|
| 1460 | + if (!$dir) { |
|
| 1461 | + // resolve directory and length for speedy comparisons |
|
| 1462 | + $file = realpath($key); |
|
| 1463 | + if ($file === false) { |
|
| 1464 | + // this directory does not exist, remove and skip it |
|
| 1465 | + unset(Smarty::$_muted_directories[ $key ]); |
|
| 1466 | + continue; |
|
| 1467 | + } |
|
| 1468 | + $dir = array('file' => $file, 'length' => strlen($file),); |
|
| 1469 | + } |
|
| 1470 | + if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) { |
|
| 1471 | + $_is_muted_directory = true; |
|
| 1472 | + break; |
|
| 1473 | + } |
|
| 1474 | + } |
|
| 1475 | + // pass to next error handler if this error did not occur inside SMARTY_DIR |
|
| 1476 | + // or the error was within smarty but masked to be ignored |
|
| 1477 | + if (!$_is_muted_directory || ($errno && $errno & error_reporting())) { |
|
| 1478 | + if (Smarty::$_previous_error_handler) { |
|
| 1479 | + return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, |
|
| 1480 | + $errcontext); |
|
| 1481 | + } else { |
|
| 1482 | + return false; |
|
| 1483 | + } |
|
| 1484 | + } |
|
| 1485 | + return; |
|
| 1486 | + } |
|
| 1487 | + |
|
| 1488 | + /** |
|
| 1489 | + * Enable error handler to mute expected messages |
|
| 1490 | + * |
|
| 1491 | + * @return void |
|
| 1492 | + */ |
|
| 1493 | + public static function muteExpectedErrors() |
|
| 1494 | + { |
|
| 1495 | + /* |
|
| 1496 | 1496 | error muting is done because some people implemented custom error_handlers using |
| 1497 | 1497 | http://php.net/set_error_handler and for some reason did not understand the following paragraph: |
| 1498 | 1498 | |
@@ -1508,22 +1508,22 @@ discard block |
||
| 1508 | 1508 | - between file_exists() and filemtime() a possible race condition is opened, |
| 1509 | 1509 | which does not exist using the simple @filemtime() approach. |
| 1510 | 1510 | */ |
| 1511 | - $error_handler = array('Smarty', 'mutingErrorHandler'); |
|
| 1512 | - $previous = set_error_handler($error_handler); |
|
| 1513 | - |
|
| 1514 | - // avoid dead loops |
|
| 1515 | - if ($previous !== $error_handler) { |
|
| 1516 | - Smarty::$_previous_error_handler = $previous; |
|
| 1517 | - } |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - /** |
|
| 1521 | - * Disable error handler muting expected messages |
|
| 1522 | - * |
|
| 1523 | - * @return void |
|
| 1524 | - */ |
|
| 1525 | - public static function unmuteExpectedErrors() |
|
| 1526 | - { |
|
| 1527 | - restore_error_handler(); |
|
| 1528 | - } |
|
| 1511 | + $error_handler = array('Smarty', 'mutingErrorHandler'); |
|
| 1512 | + $previous = set_error_handler($error_handler); |
|
| 1513 | + |
|
| 1514 | + // avoid dead loops |
|
| 1515 | + if ($previous !== $error_handler) { |
|
| 1516 | + Smarty::$_previous_error_handler = $previous; |
|
| 1517 | + } |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + /** |
|
| 1521 | + * Disable error handler muting expected messages |
|
| 1522 | + * |
|
| 1523 | + * @return void |
|
| 1524 | + */ |
|
| 1525 | + public static function unmuteExpectedErrors() |
|
| 1526 | + { |
|
| 1527 | + restore_error_handler(); |
|
| 1528 | + } |
|
| 1529 | 1529 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects |
| 217 | 217 | |
| 218 | - const RESOURCE_CACHE_ON = 4; // cache source and compiled resources |
|
| 218 | + const RESOURCE_CACHE_ON = 4; // cache source and compiled resources |
|
| 219 | 219 | |
| 220 | 220 | /**#@-*/ |
| 221 | 221 | |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | $this->start_time = microtime(true); |
| 751 | 751 | |
| 752 | - if (isset($_SERVER[ 'SCRIPT_NAME' ])) { |
|
| 753 | - Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new Smarty_Variable($_SERVER[ 'SCRIPT_NAME' ]); |
|
| 752 | + if (isset($_SERVER['SCRIPT_NAME'])) { |
|
| 753 | + Smarty::$global_tpl_vars['SCRIPT_NAME'] = new Smarty_Variable($_SERVER['SCRIPT_NAME']); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | // Check if we're running on windows |
@@ -849,15 +849,15 @@ discard block |
||
| 849 | 849 | $dir[] = $v; |
| 850 | 850 | } else { |
| 851 | 851 | // string indexes are overridden |
| 852 | - $dir[ $k ] = $v; |
|
| 853 | - unset($processed[ $key ]); |
|
| 852 | + $dir[$k] = $v; |
|
| 853 | + unset($processed[$key]); |
|
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | } else { |
| 857 | 857 | if ($key !== null) { |
| 858 | 858 | // override directory at specified index |
| 859 | - $dir[ $key ] = $template_dir; |
|
| 860 | - unset($processed[ $key ]); |
|
| 859 | + $dir[$key] = $template_dir; |
|
| 860 | + unset($processed[$key]); |
|
| 861 | 861 | } else { |
| 862 | 862 | // append new directory |
| 863 | 863 | $dir[] = $template_dir; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | $this->_nomalizeTemplateConfig($isConfig); |
| 886 | 886 | } |
| 887 | 887 | if ($index !== null) { |
| 888 | - return isset($dir[ $index ]) ? $dir[ $index ] : null; |
|
| 888 | + return isset($dir[$index]) ? $dir[$index] : null; |
|
| 889 | 889 | } |
| 890 | 890 | return $dir; |
| 891 | 891 | } |
@@ -974,9 +974,9 @@ discard block |
||
| 974 | 974 | $this->plugins_dir = (array) $this->plugins_dir; |
| 975 | 975 | } |
| 976 | 976 | foreach ($this->plugins_dir as $k => $v) { |
| 977 | - $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 977 | + $this->plugins_dir[$k] = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 978 | 978 | } |
| 979 | - $this->_cache[ 'plugin_files' ] = array(); |
|
| 979 | + $this->_cache['plugin_files'] = array(); |
|
| 980 | 980 | $this->_pluginsDirNormalized = true; |
| 981 | 981 | } |
| 982 | 982 | return $this->plugins_dir; |
@@ -1046,8 +1046,8 @@ discard block |
||
| 1046 | 1046 | private function _normalizeDir($dirName, $dir) |
| 1047 | 1047 | { |
| 1048 | 1048 | $this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DS, true); |
| 1049 | - if (!isset(Smarty::$_muted_directories[ $this->{$dirName} ])) { |
|
| 1050 | - Smarty::$_muted_directories[ $this->{$dirName} ] = null; |
|
| 1049 | + if (!isset(Smarty::$_muted_directories[$this->{$dirName}])) { |
|
| 1050 | + Smarty::$_muted_directories[$this->{$dirName}] = null; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | |
@@ -1070,14 +1070,13 @@ discard block |
||
| 1070 | 1070 | $dir = (array) $dir; |
| 1071 | 1071 | } |
| 1072 | 1072 | foreach ($dir as $k => $v) { |
| 1073 | - if (!isset($processed[ $k ])) { |
|
| 1074 | - $dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 1075 | - $processed[ $k ] = true; |
|
| 1073 | + if (!isset($processed[$k])) { |
|
| 1074 | + $dir[$k] = $v = $this->_realpath(rtrim($v, "/\\") . DS, true); |
|
| 1075 | + $processed[$k] = true; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | } |
| 1078 | 1078 | $isConfig ? $this->_configDirNormalized = true : $this->_templateDirNormalized = true; |
| 1079 | - $isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) : |
|
| 1080 | - $this->_joined_template_dir = join('#', $this->template_dir); |
|
| 1079 | + $isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) : $this->_joined_template_dir = join('#', $this->template_dir); |
|
| 1081 | 1080 | } |
| 1082 | 1081 | |
| 1083 | 1082 | /** |
@@ -1105,12 +1104,11 @@ discard block |
||
| 1105 | 1104 | } |
| 1106 | 1105 | $_templateId = $this->_getTemplateId($template, $cache_id, $compile_id); |
| 1107 | 1106 | $tpl = null; |
| 1108 | - if ($this->caching && isset($this->_cache[ 'isCached' ][ $_templateId ])) { |
|
| 1109 | - $tpl = $do_clone ? clone $this->_cache[ 'isCached' ][ $_templateId ] : |
|
| 1110 | - $this->_cache[ 'isCached' ][ $_templateId ]; |
|
| 1107 | + if ($this->caching && isset($this->_cache['isCached'][$_templateId])) { |
|
| 1108 | + $tpl = $do_clone ? clone $this->_cache['isCached'][$_templateId] : $this->_cache['isCached'][$_templateId]; |
|
| 1111 | 1109 | $tpl->tpl_vars = $tpl->config_vars = array(); |
| 1112 | - } else if (!$do_clone && isset($this->_cache[ 'tplObjects' ][ $_templateId ])) { |
|
| 1113 | - $tpl = clone $this->_cache[ 'tplObjects' ][ $_templateId ]; |
|
| 1110 | + } else if (!$do_clone && isset($this->_cache['tplObjects'][$_templateId])) { |
|
| 1111 | + $tpl = clone $this->_cache['tplObjects'][$_templateId]; |
|
| 1114 | 1112 | } else { |
| 1115 | 1113 | /* @var Smarty_Internal_Template $tpl */ |
| 1116 | 1114 | $tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null); |
@@ -1124,7 +1122,7 @@ discard block |
||
| 1124 | 1122 | if (!empty($data) && is_array($data)) { |
| 1125 | 1123 | // set up variable values |
| 1126 | 1124 | foreach ($data as $_key => $_val) { |
| 1127 | - $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val); |
|
| 1125 | + $tpl->tpl_vars[$_key] = new Smarty_Variable($_val); |
|
| 1128 | 1126 | } |
| 1129 | 1127 | } |
| 1130 | 1128 | if ($this->debugging || $this->debugging_ctrl == 'URL') { |
@@ -1167,8 +1165,7 @@ discard block |
||
| 1167 | 1165 | public function _getTemplateId($template_name, $cache_id = null, $compile_id = null, $caching = null, |
| 1168 | 1166 | Smarty_Internal_Template $template = null) |
| 1169 | 1167 | { |
| 1170 | - $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : |
|
| 1171 | - $template_name; |
|
| 1168 | + $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : $template_name; |
|
| 1172 | 1169 | $cache_id = $cache_id === null ? $this->cache_id : $cache_id; |
| 1173 | 1170 | $compile_id = $compile_id === null ? $this->compile_id : $compile_id; |
| 1174 | 1171 | $caching = (int) ($caching === null ? $this->caching : $caching); |
@@ -1180,7 +1177,7 @@ discard block |
||
| 1180 | 1177 | } else { |
| 1181 | 1178 | $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}"; |
| 1182 | 1179 | } |
| 1183 | - if (isset($_templateId[ 150 ])) { |
|
| 1180 | + if (isset($_templateId[150])) { |
|
| 1184 | 1181 | $_templateId = sha1($_templateId); |
| 1185 | 1182 | } |
| 1186 | 1183 | return $_templateId; |
@@ -1205,11 +1202,11 @@ discard block |
||
| 1205 | 1202 | $path = str_replace($nds, DS, $path); |
| 1206 | 1203 | preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%', |
| 1207 | 1204 | $path, $parts); |
| 1208 | - $path = $parts[ 'path' ]; |
|
| 1209 | - if ($parts[ 'root' ] == '\\') { |
|
| 1210 | - $parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ]; |
|
| 1205 | + $path = $parts['path']; |
|
| 1206 | + if ($parts['root'] == '\\') { |
|
| 1207 | + $parts['root'] = substr(getcwd(), 0, 2) . $parts['root']; |
|
| 1211 | 1208 | } else { |
| 1212 | - if ($realpath !== null && !$parts[ 'root' ]) { |
|
| 1209 | + if ($realpath !== null && !$parts['root']) { |
|
| 1213 | 1210 | $path = getcwd() . DS . $path; |
| 1214 | 1211 | } |
| 1215 | 1212 | } |
@@ -1220,7 +1217,7 @@ discard block |
||
| 1220 | 1217 | preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#', $path, $match) |
| 1221 | 1218 | ) { |
| 1222 | 1219 | $counts = array(); |
| 1223 | - foreach ($match[ 0 ] as $m) { |
|
| 1220 | + foreach ($match[0] as $m) { |
|
| 1224 | 1221 | $counts[] = (int) ((strlen($m) - 1) / 3); |
| 1225 | 1222 | } |
| 1226 | 1223 | sort($counts); |
@@ -1231,7 +1228,7 @@ discard block |
||
| 1231 | 1228 | } |
| 1232 | 1229 | } |
| 1233 | 1230 | |
| 1234 | - return $parts[ 'root' ] . $path; |
|
| 1231 | + return $parts['root'] . $path; |
|
| 1235 | 1232 | } |
| 1236 | 1233 | |
| 1237 | 1234 | /** |
@@ -1239,8 +1236,8 @@ discard block |
||
| 1239 | 1236 | */ |
| 1240 | 1237 | public function _clearTemplateCache() |
| 1241 | 1238 | { |
| 1242 | - $this->_cache[ 'isCached' ] = array(); |
|
| 1243 | - $this->_cache[ 'tplObjects' ] = array(); |
|
| 1239 | + $this->_cache['isCached'] = array(); |
|
| 1240 | + $this->_cache['tplObjects'] = array(); |
|
| 1244 | 1241 | } |
| 1245 | 1242 | |
| 1246 | 1243 | /** |
@@ -1392,11 +1389,11 @@ discard block |
||
| 1392 | 1389 | */ |
| 1393 | 1390 | public function __get($name) |
| 1394 | 1391 | { |
| 1395 | - if (isset($this->accessMap[ $name ])) { |
|
| 1396 | - $method = 'get' . $this->accessMap[ $name ]; |
|
| 1392 | + if (isset($this->accessMap[$name])) { |
|
| 1393 | + $method = 'get' . $this->accessMap[$name]; |
|
| 1397 | 1394 | return $this->{$method}(); |
| 1398 | - } elseif (isset($this->_cache[ $name ])) { |
|
| 1399 | - return $this->_cache[ $name ]; |
|
| 1395 | + } elseif (isset($this->_cache[$name])) { |
|
| 1396 | + return $this->_cache[$name]; |
|
| 1400 | 1397 | } elseif (in_array($name, $this->obsoleteProperties)) { |
| 1401 | 1398 | return null; |
| 1402 | 1399 | } else { |
@@ -1415,8 +1412,8 @@ discard block |
||
| 1415 | 1412 | */ |
| 1416 | 1413 | public function __set($name, $value) |
| 1417 | 1414 | { |
| 1418 | - if (isset($this->accessMap[ $name ])) { |
|
| 1419 | - $method = 'set' . $this->accessMap[ $name ]; |
|
| 1415 | + if (isset($this->accessMap[$name])) { |
|
| 1416 | + $method = 'set' . $this->accessMap[$name]; |
|
| 1420 | 1417 | $this->{$method}($value); |
| 1421 | 1418 | } elseif (in_array($name, $this->obsoleteProperties)) { |
| 1422 | 1419 | return; |
@@ -1447,10 +1444,10 @@ discard block |
||
| 1447 | 1444 | $_is_muted_directory = false; |
| 1448 | 1445 | |
| 1449 | 1446 | // add the SMARTY_DIR to the list of muted directories |
| 1450 | - if (!isset(Smarty::$_muted_directories[ SMARTY_DIR ])) { |
|
| 1447 | + if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) { |
|
| 1451 | 1448 | $smarty_dir = realpath(SMARTY_DIR); |
| 1452 | 1449 | if ($smarty_dir !== false) { |
| 1453 | - Smarty::$_muted_directories[ SMARTY_DIR ] = |
|
| 1450 | + Smarty::$_muted_directories[SMARTY_DIR] = |
|
| 1454 | 1451 | array('file' => $smarty_dir, 'length' => strlen($smarty_dir),); |
| 1455 | 1452 | } |
| 1456 | 1453 | } |
@@ -1462,12 +1459,12 @@ discard block |
||
| 1462 | 1459 | $file = realpath($key); |
| 1463 | 1460 | if ($file === false) { |
| 1464 | 1461 | // this directory does not exist, remove and skip it |
| 1465 | - unset(Smarty::$_muted_directories[ $key ]); |
|
| 1462 | + unset(Smarty::$_muted_directories[$key]); |
|
| 1466 | 1463 | continue; |
| 1467 | 1464 | } |
| 1468 | 1465 | $dir = array('file' => $file, 'length' => strlen($file),); |
| 1469 | 1466 | } |
| 1470 | - if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) { |
|
| 1467 | + if (!strncmp($errfile, $dir['file'], $dir['length'])) { |
|
| 1471 | 1468 | $_is_muted_directory = true; |
| 1472 | 1469 | break; |
| 1473 | 1470 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
| 69 | 69 | * @param array $parameter array with compilation parameter |
| 70 | 70 | * |
| 71 | - * @return bool true |
|
| 71 | + * @return boolean|null true |
|
| 72 | 72 | */ |
| 73 | 73 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 74 | 74 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
| 159 | 159 | * @param array $parameter array with compilation parameter |
| 160 | 160 | * |
| 161 | - * @return bool true |
|
| 161 | + * @return string true |
|
| 162 | 162 | */ |
| 163 | 163 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 164 | 164 | { |
@@ -15,134 +15,134 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inheritance |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Attribute definition: Overwrites base class. |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - * @see Smarty_Internal_CompileBase |
|
| 23 | - */ |
|
| 24 | - public $required_attributes = array('name'); |
|
| 18 | + /** |
|
| 19 | + * Attribute definition: Overwrites base class. |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + * @see Smarty_Internal_CompileBase |
|
| 23 | + */ |
|
| 24 | + public $required_attributes = array('name'); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Attribute definition: Overwrites base class. |
|
| 28 | - * |
|
| 29 | - * @var array |
|
| 30 | - * @see Smarty_Internal_CompileBase |
|
| 31 | - */ |
|
| 32 | - public $shorttag_order = array('name'); |
|
| 26 | + /** |
|
| 27 | + * Attribute definition: Overwrites base class. |
|
| 28 | + * |
|
| 29 | + * @var array |
|
| 30 | + * @see Smarty_Internal_CompileBase |
|
| 31 | + */ |
|
| 32 | + public $shorttag_order = array('name'); |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Attribute definition: Overwrites base class. |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - * @see Smarty_Internal_CompileBase |
|
| 39 | - */ |
|
| 40 | - public $option_flags = array('hide', 'nocache'); |
|
| 34 | + /** |
|
| 35 | + * Attribute definition: Overwrites base class. |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + * @see Smarty_Internal_CompileBase |
|
| 39 | + */ |
|
| 40 | + public $option_flags = array('hide', 'nocache'); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Attribute definition: Overwrites base class. |
|
| 44 | - * |
|
| 45 | - * @var array |
|
| 46 | - * @see Smarty_Internal_CompileBase |
|
| 47 | - */ |
|
| 48 | - public $optional_attributes = array('assign'); |
|
| 42 | + /** |
|
| 43 | + * Attribute definition: Overwrites base class. |
|
| 44 | + * |
|
| 45 | + * @var array |
|
| 46 | + * @see Smarty_Internal_CompileBase |
|
| 47 | + */ |
|
| 48 | + public $optional_attributes = array('assign'); |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * nesting level of block tags |
|
| 52 | - * |
|
| 53 | - * @var int |
|
| 54 | - */ |
|
| 55 | - public static $blockTagNestingLevel = 0; |
|
| 50 | + /** |
|
| 51 | + * nesting level of block tags |
|
| 52 | + * |
|
| 53 | + * @var int |
|
| 54 | + */ |
|
| 55 | + public static $blockTagNestingLevel = 0; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Saved compiler object |
|
| 59 | - * |
|
| 60 | - * @var Smarty_Internal_TemplateCompilerBase |
|
| 61 | - */ |
|
| 62 | - public $compiler = null; |
|
| 57 | + /** |
|
| 58 | + * Saved compiler object |
|
| 59 | + * |
|
| 60 | + * @var Smarty_Internal_TemplateCompilerBase |
|
| 61 | + */ |
|
| 62 | + public $compiler = null; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Compiles code for the {block} tag |
|
| 66 | - * |
|
| 67 | - * @param array $args array with attributes from parser |
|
| 68 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 69 | - * @param array $parameter array with compilation parameter |
|
| 70 | - * |
|
| 71 | - * @return bool true |
|
| 72 | - */ |
|
| 73 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 74 | - { |
|
| 75 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 76 | - $compiler->_cache[ 'blockNesting' ] = 0; |
|
| 77 | - } |
|
| 78 | - if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 79 | - // make sure that inheritance gets initialized in template code |
|
| 80 | - $this->registerInit($compiler); |
|
| 81 | - $this->option_flags = array('hide', 'nocache', 'append', 'prepend'); |
|
| 82 | - } else { |
|
| 83 | - $this->option_flags = array('hide', 'nocache'); |
|
| 84 | - } |
|
| 85 | - // check and get attributes |
|
| 86 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 87 | - $compiler->_cache[ 'blockNesting' ] ++; |
|
| 88 | - $compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ]; |
|
| 89 | - $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array(); |
|
| 90 | - $this->openTag($compiler, 'block', array($_attr, $compiler->nocache, $compiler->parser->current_buffer, |
|
| 91 | - $compiler->template->compiled->has_nocache_code, |
|
| 92 | - $compiler->template->caching)); |
|
| 93 | - // must whole block be nocache ? |
|
| 94 | - if ($compiler->tag_nocache) { |
|
| 95 | - $i = 0; |
|
| 96 | - } |
|
| 97 | - $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; |
|
| 98 | - if ($_attr[ 'nocache' ] === true) { |
|
| 64 | + /** |
|
| 65 | + * Compiles code for the {block} tag |
|
| 66 | + * |
|
| 67 | + * @param array $args array with attributes from parser |
|
| 68 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 69 | + * @param array $parameter array with compilation parameter |
|
| 70 | + * |
|
| 71 | + * @return bool true |
|
| 72 | + */ |
|
| 73 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 74 | + { |
|
| 75 | + if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 76 | + $compiler->_cache[ 'blockNesting' ] = 0; |
|
| 77 | + } |
|
| 78 | + if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 79 | + // make sure that inheritance gets initialized in template code |
|
| 80 | + $this->registerInit($compiler); |
|
| 81 | + $this->option_flags = array('hide', 'nocache', 'append', 'prepend'); |
|
| 82 | + } else { |
|
| 83 | + $this->option_flags = array('hide', 'nocache'); |
|
| 84 | + } |
|
| 85 | + // check and get attributes |
|
| 86 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 87 | + $compiler->_cache[ 'blockNesting' ] ++; |
|
| 88 | + $compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ]; |
|
| 89 | + $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array(); |
|
| 90 | + $this->openTag($compiler, 'block', array($_attr, $compiler->nocache, $compiler->parser->current_buffer, |
|
| 91 | + $compiler->template->compiled->has_nocache_code, |
|
| 92 | + $compiler->template->caching)); |
|
| 93 | + // must whole block be nocache ? |
|
| 94 | + if ($compiler->tag_nocache) { |
|
| 95 | + $i = 0; |
|
| 96 | + } |
|
| 97 | + $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; |
|
| 98 | + if ($_attr[ 'nocache' ] === true) { |
|
| 99 | 99 | |
| 100 | - } |
|
| 101 | - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 102 | - $compiler->template->compiled->has_nocache_code = false; |
|
| 103 | - $compiler->suppressNocacheProcessing = true; |
|
| 104 | - } |
|
| 100 | + } |
|
| 101 | + $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 102 | + $compiler->template->compiled->has_nocache_code = false; |
|
| 103 | + $compiler->suppressNocacheProcessing = true; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Compile saved child block source |
|
| 108 | - * |
|
| 109 | - * @param \Smarty_Internal_TemplateCompilerBase compiler object |
|
| 110 | - * @param string $_name optional name of child block |
|
| 111 | - * |
|
| 112 | - * @return string compiled code of child block |
|
| 113 | - */ |
|
| 114 | - static function compileChildBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
|
| 115 | - { |
|
| 116 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 117 | - $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', |
|
| 118 | - $compiler->parser->lex->taglineno); |
|
| 119 | - } |
|
| 120 | - $compiler->has_code = true; |
|
| 121 | - $compiler->suppressNocacheProcessing = true; |
|
| 122 | - $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true'; |
|
| 123 | - $output = "<?php \n\$_smarty_tpl->inheritance->callChild(\$_smarty_tpl, \$this);\n?>\n"; |
|
| 124 | - return $output; |
|
| 125 | - } |
|
| 106 | + /** |
|
| 107 | + * Compile saved child block source |
|
| 108 | + * |
|
| 109 | + * @param \Smarty_Internal_TemplateCompilerBase compiler object |
|
| 110 | + * @param string $_name optional name of child block |
|
| 111 | + * |
|
| 112 | + * @return string compiled code of child block |
|
| 113 | + */ |
|
| 114 | + static function compileChildBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
|
| 115 | + { |
|
| 116 | + if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 117 | + $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', |
|
| 118 | + $compiler->parser->lex->taglineno); |
|
| 119 | + } |
|
| 120 | + $compiler->has_code = true; |
|
| 121 | + $compiler->suppressNocacheProcessing = true; |
|
| 122 | + $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true'; |
|
| 123 | + $output = "<?php \n\$_smarty_tpl->inheritance->callChild(\$_smarty_tpl, \$this);\n?>\n"; |
|
| 124 | + return $output; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Compile $smarty.block.parent |
|
| 129 | - * |
|
| 130 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 131 | - * @param string $_name optional name of child block |
|
| 132 | - * |
|
| 133 | - * @return string compiled code of child block |
|
| 134 | - */ |
|
| 135 | - static function compileParentBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
|
| 136 | - { |
|
| 137 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 138 | - $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', |
|
| 139 | - $compiler->parser->lex->taglineno); |
|
| 140 | - } |
|
| 141 | - $compiler->suppressNocacheProcessing = true; |
|
| 142 | - $compiler->has_code = true; |
|
| 143 | - $output = "<?php \n\$_smarty_tpl->inheritance->callParent(\$_smarty_tpl, \$this);\n?>\n"; |
|
| 144 | - return $output; |
|
| 145 | - } |
|
| 127 | + /** |
|
| 128 | + * Compile $smarty.block.parent |
|
| 129 | + * |
|
| 130 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 131 | + * @param string $_name optional name of child block |
|
| 132 | + * |
|
| 133 | + * @return string compiled code of child block |
|
| 134 | + */ |
|
| 135 | + static function compileParentBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
|
| 136 | + { |
|
| 137 | + if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 138 | + $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', |
|
| 139 | + $compiler->parser->lex->taglineno); |
|
| 140 | + } |
|
| 141 | + $compiler->suppressNocacheProcessing = true; |
|
| 142 | + $compiler->has_code = true; |
|
| 143 | + $output = "<?php \n\$_smarty_tpl->inheritance->callParent(\$_smarty_tpl, \$this);\n?>\n"; |
|
| 144 | + return $output; |
|
| 145 | + } |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -151,95 +151,95 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance |
| 153 | 153 | { |
| 154 | - /** |
|
| 155 | - * Compiles code for the {/block} tag |
|
| 156 | - * |
|
| 157 | - * @param array $args array with attributes from parser |
|
| 158 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 159 | - * @param array $parameter array with compilation parameter |
|
| 160 | - * |
|
| 161 | - * @return bool true |
|
| 162 | - */ |
|
| 163 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 164 | - { |
|
| 165 | - list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block')); |
|
| 166 | - // init block parameter |
|
| 167 | - $_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]; |
|
| 168 | - unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]); |
|
| 169 | - $_name = $_attr[ 'name' ]; |
|
| 170 | - $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null; |
|
| 171 | - unset($_attr[ 'assign' ], $_attr[ 'name' ]); |
|
| 172 | - foreach ($_attr as $name => $stat) { |
|
| 173 | - if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat != 'false')) { |
|
| 174 | - $_block[ $name ] = 'true'; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - $_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true)); |
|
| 178 | - // get compiled block code |
|
| 179 | - $_functionCode = $compiler->parser->current_buffer; |
|
| 180 | - // setup buffer for template function code |
|
| 181 | - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 154 | + /** |
|
| 155 | + * Compiles code for the {/block} tag |
|
| 156 | + * |
|
| 157 | + * @param array $args array with attributes from parser |
|
| 158 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 159 | + * @param array $parameter array with compilation parameter |
|
| 160 | + * |
|
| 161 | + * @return bool true |
|
| 162 | + */ |
|
| 163 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 164 | + { |
|
| 165 | + list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block')); |
|
| 166 | + // init block parameter |
|
| 167 | + $_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]; |
|
| 168 | + unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]); |
|
| 169 | + $_name = $_attr[ 'name' ]; |
|
| 170 | + $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null; |
|
| 171 | + unset($_attr[ 'assign' ], $_attr[ 'name' ]); |
|
| 172 | + foreach ($_attr as $name => $stat) { |
|
| 173 | + if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat != 'false')) { |
|
| 174 | + $_block[ $name ] = 'true'; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + $_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true)); |
|
| 178 | + // get compiled block code |
|
| 179 | + $_functionCode = $compiler->parser->current_buffer; |
|
| 180 | + // setup buffer for template function code |
|
| 181 | + $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 182 | 182 | |
| 183 | - $output = "<?php\n"; |
|
| 184 | - $output .= "/* {block {$_name}} */\n"; |
|
| 185 | - $output .= "class {$_className} extends Smarty_Internal_Block\n"; |
|
| 186 | - $output .= "{\n"; |
|
| 187 | - foreach ($_block as $property => $value) { |
|
| 188 | - $output .= "public \${$property} = {$value};\n"; |
|
| 189 | - } |
|
| 190 | - $output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n"; |
|
| 191 | - if ($compiler->template->compiled->has_nocache_code) { |
|
| 192 | - $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n"; |
|
| 193 | - } |
|
| 194 | - if (isset($_assign)) { |
|
| 195 | - $output .= "ob_start();\n"; |
|
| 196 | - } |
|
| 197 | - $output .= "?>\n"; |
|
| 198 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 199 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 200 | - $output)); |
|
| 201 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 202 | - $output = "<?php\n"; |
|
| 203 | - if (isset($_assign)) { |
|
| 204 | - $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 205 | - } |
|
| 206 | - $output .= "}\n"; |
|
| 207 | - $output .= "}\n"; |
|
| 208 | - $output .= "/* {/block {$_name}} */\n\n"; |
|
| 209 | - $output .= "?>\n"; |
|
| 210 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 211 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 212 | - $output)); |
|
| 213 | - $compiler->blockOrFunctionCode .= $f = $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
|
| 214 | - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 215 | - // nocache plugins must be copied |
|
| 216 | - if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 217 | - foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 218 | - foreach ($tmp as $type => $data) { |
|
| 219 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 220 | - $data; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 183 | + $output = "<?php\n"; |
|
| 184 | + $output .= "/* {block {$_name}} */\n"; |
|
| 185 | + $output .= "class {$_className} extends Smarty_Internal_Block\n"; |
|
| 186 | + $output .= "{\n"; |
|
| 187 | + foreach ($_block as $property => $value) { |
|
| 188 | + $output .= "public \${$property} = {$value};\n"; |
|
| 189 | + } |
|
| 190 | + $output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n"; |
|
| 191 | + if ($compiler->template->compiled->has_nocache_code) { |
|
| 192 | + $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n"; |
|
| 193 | + } |
|
| 194 | + if (isset($_assign)) { |
|
| 195 | + $output .= "ob_start();\n"; |
|
| 196 | + } |
|
| 197 | + $output .= "?>\n"; |
|
| 198 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 199 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 200 | + $output)); |
|
| 201 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 202 | + $output = "<?php\n"; |
|
| 203 | + if (isset($_assign)) { |
|
| 204 | + $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; |
|
| 205 | + } |
|
| 206 | + $output .= "}\n"; |
|
| 207 | + $output .= "}\n"; |
|
| 208 | + $output .= "/* {/block {$_name}} */\n\n"; |
|
| 209 | + $output .= "?>\n"; |
|
| 210 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 211 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 212 | + $output)); |
|
| 213 | + $compiler->blockOrFunctionCode .= $f = $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
|
| 214 | + $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 215 | + // nocache plugins must be copied |
|
| 216 | + if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 217 | + foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 218 | + foreach ($tmp as $type => $data) { |
|
| 219 | + $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 220 | + $data; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - // restore old status |
|
| 226 | - $compiler->template->compiled->has_nocache_code = $_has_nocache_code; |
|
| 227 | - $compiler->tag_nocache = $compiler->nocache; |
|
| 228 | - $compiler->nocache = $_nocache; |
|
| 229 | - $compiler->parser->current_buffer = $_buffer; |
|
| 230 | - $output = "<?php \n"; |
|
| 231 | - if ($compiler->_cache[ 'blockNesting' ] == 1) { |
|
| 232 | - $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n"; |
|
| 233 | - } else { |
|
| 234 | - $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n"; |
|
| 235 | - } |
|
| 236 | - $output .= "?>\n"; |
|
| 237 | - $compiler->_cache[ 'blockNesting' ] --; |
|
| 238 | - if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 239 | - unset($compiler->_cache[ 'blockNesting' ]); |
|
| 240 | - } |
|
| 241 | - $compiler->has_code = true; |
|
| 242 | - $compiler->suppressNocacheProcessing = true; |
|
| 243 | - return $output; |
|
| 244 | - } |
|
| 225 | + // restore old status |
|
| 226 | + $compiler->template->compiled->has_nocache_code = $_has_nocache_code; |
|
| 227 | + $compiler->tag_nocache = $compiler->nocache; |
|
| 228 | + $compiler->nocache = $_nocache; |
|
| 229 | + $compiler->parser->current_buffer = $_buffer; |
|
| 230 | + $output = "<?php \n"; |
|
| 231 | + if ($compiler->_cache[ 'blockNesting' ] == 1) { |
|
| 232 | + $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n"; |
|
| 233 | + } else { |
|
| 234 | + $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n"; |
|
| 235 | + } |
|
| 236 | + $output .= "?>\n"; |
|
| 237 | + $compiler->_cache[ 'blockNesting' ] --; |
|
| 238 | + if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 239 | + unset($compiler->_cache[ 'blockNesting' ]); |
|
| 240 | + } |
|
| 241 | + $compiler->has_code = true; |
|
| 242 | + $compiler->suppressNocacheProcessing = true; |
|
| 243 | + return $output; |
|
| 244 | + } |
|
| 245 | 245 | } |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 74 | 74 | { |
| 75 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 76 | - $compiler->_cache[ 'blockNesting' ] = 0; |
|
| 75 | + if (!isset($compiler->_cache['blockNesting'])) { |
|
| 76 | + $compiler->_cache['blockNesting'] = 0; |
|
| 77 | 77 | } |
| 78 | - if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 78 | + if ($compiler->_cache['blockNesting'] == 0) { |
|
| 79 | 79 | // make sure that inheritance gets initialized in template code |
| 80 | 80 | $this->registerInit($compiler); |
| 81 | 81 | $this->option_flags = array('hide', 'nocache', 'append', 'prepend'); |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | // check and get attributes |
| 86 | 86 | $_attr = $this->getAttributes($compiler, $args); |
| 87 | - $compiler->_cache[ 'blockNesting' ] ++; |
|
| 88 | - $compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ]; |
|
| 89 | - $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array(); |
|
| 87 | + $compiler->_cache['blockNesting']++; |
|
| 88 | + $compiler->_cache['blockName'][$compiler->_cache['blockNesting']] = $_attr['name']; |
|
| 89 | + $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']] = array(); |
|
| 90 | 90 | $this->openTag($compiler, 'block', array($_attr, $compiler->nocache, $compiler->parser->current_buffer, |
| 91 | 91 | $compiler->template->compiled->has_nocache_code, |
| 92 | 92 | $compiler->template->caching)); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $i = 0; |
| 96 | 96 | } |
| 97 | 97 | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; |
| 98 | - if ($_attr[ 'nocache' ] === true) { |
|
| 98 | + if ($_attr['nocache'] === true) { |
|
| 99 | 99 | |
| 100 | 100 | } |
| 101 | 101 | $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | static function compileChildBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
| 115 | 115 | { |
| 116 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 116 | + if (!isset($compiler->_cache['blockNesting'])) { |
|
| 117 | 117 | $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', |
| 118 | 118 | $compiler->parser->lex->taglineno); |
| 119 | 119 | } |
| 120 | 120 | $compiler->has_code = true; |
| 121 | 121 | $compiler->suppressNocacheProcessing = true; |
| 122 | - $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true'; |
|
| 122 | + $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]['callsChild'] = 'true'; |
|
| 123 | 123 | $output = "<?php \n\$_smarty_tpl->inheritance->callChild(\$_smarty_tpl, \$this);\n?>\n"; |
| 124 | 124 | return $output; |
| 125 | 125 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | static function compileParentBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null) |
| 136 | 136 | { |
| 137 | - if (!isset($compiler->_cache[ 'blockNesting' ])) { |
|
| 137 | + if (!isset($compiler->_cache['blockNesting'])) { |
|
| 138 | 138 | $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', |
| 139 | 139 | $compiler->parser->lex->taglineno); |
| 140 | 140 | } |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block')); |
| 166 | 166 | // init block parameter |
| 167 | - $_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]; |
|
| 168 | - unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]); |
|
| 169 | - $_name = $_attr[ 'name' ]; |
|
| 170 | - $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null; |
|
| 171 | - unset($_attr[ 'assign' ], $_attr[ 'name' ]); |
|
| 167 | + $_block = $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]; |
|
| 168 | + unset($compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]); |
|
| 169 | + $_name = $_attr['name']; |
|
| 170 | + $_assign = isset($_attr['assign']) ? $_attr['assign'] : null; |
|
| 171 | + unset($_attr['assign'], $_attr['name']); |
|
| 172 | 172 | foreach ($_attr as $name => $stat) { |
| 173 | 173 | if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat != 'false')) { |
| 174 | - $_block[ $name ] = 'true'; |
|
| 174 | + $_block[$name] = 'true'; |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | $_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true)); |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $compiler->blockOrFunctionCode .= $f = $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
| 214 | 214 | $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
| 215 | 215 | // nocache plugins must be copied |
| 216 | - if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 217 | - foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 216 | + if (!empty($compiler->template->compiled->required_plugins['nocache'])) { |
|
| 217 | + foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) { |
|
| 218 | 218 | foreach ($tmp as $type => $data) { |
| 219 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 219 | + $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$plugin][$type] = |
|
| 220 | 220 | $data; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -228,15 +228,15 @@ discard block |
||
| 228 | 228 | $compiler->nocache = $_nocache; |
| 229 | 229 | $compiler->parser->current_buffer = $_buffer; |
| 230 | 230 | $output = "<?php \n"; |
| 231 | - if ($compiler->_cache[ 'blockNesting' ] == 1) { |
|
| 231 | + if ($compiler->_cache['blockNesting'] == 1) { |
|
| 232 | 232 | $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n"; |
| 233 | 233 | } else { |
| 234 | 234 | $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n"; |
| 235 | 235 | } |
| 236 | 236 | $output .= "?>\n"; |
| 237 | - $compiler->_cache[ 'blockNesting' ] --; |
|
| 238 | - if ($compiler->_cache[ 'blockNesting' ] == 0) { |
|
| 239 | - unset($compiler->_cache[ 'blockNesting' ]); |
|
| 237 | + $compiler->_cache['blockNesting']--; |
|
| 238 | + if ($compiler->_cache['blockNesting'] == 0) { |
|
| 239 | + unset($compiler->_cache['blockNesting']); |
|
| 240 | 240 | } |
| 241 | 241 | $compiler->has_code = true; |
| 242 | 242 | $compiler->suppressNocacheProcessing = true; |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | /** |
| 120 | 120 | * Create source code for {extends} from source components array |
| 121 | 121 | * |
| 122 | - * @param []\Smarty_Internal_Template_Source $components |
|
| 122 | + * @param Smarty_Template_Source[] $components |
|
| 123 | 123 | * |
| 124 | 124 | * @return string |
| 125 | 125 | */ |
@@ -17,118 +17,118 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Attribute definition: Overwrites base class. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - * @see Smarty_Internal_CompileBase |
|
| 25 | - */ |
|
| 26 | - public $required_attributes = array('file'); |
|
| 20 | + /** |
|
| 21 | + * Attribute definition: Overwrites base class. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + * @see Smarty_Internal_CompileBase |
|
| 25 | + */ |
|
| 26 | + public $required_attributes = array('file'); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Array of names of optional attribute required by tag |
|
| 30 | - * use array('_any') if there is no restriction of attributes names |
|
| 31 | - * |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - public $optional_attributes = array('extends_resource'); |
|
| 28 | + /** |
|
| 29 | + * Array of names of optional attribute required by tag |
|
| 30 | + * use array('_any') if there is no restriction of attributes names |
|
| 31 | + * |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + public $optional_attributes = array('extends_resource'); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Attribute definition: Overwrites base class. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - * @see Smarty_Internal_CompileBase |
|
| 41 | - */ |
|
| 42 | - public $shorttag_order = array('file'); |
|
| 36 | + /** |
|
| 37 | + * Attribute definition: Overwrites base class. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + * @see Smarty_Internal_CompileBase |
|
| 41 | + */ |
|
| 42 | + public $shorttag_order = array('file'); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Compiles code for the {extends} tag extends: resource |
|
| 46 | - * |
|
| 47 | - * @param array $args array with attributes from parser |
|
| 48 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | - * |
|
| 50 | - * @return string compiled code |
|
| 51 | - * @throws \SmartyCompilerException |
|
| 52 | - * @throws \SmartyException |
|
| 53 | - */ |
|
| 54 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 55 | - { |
|
| 56 | - // check and get attributes |
|
| 57 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 58 | - if ($_attr[ 'nocache' ] === true) { |
|
| 59 | - $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
|
| 60 | - } |
|
| 61 | - if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 62 | - $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
|
| 63 | - } |
|
| 64 | - // add code to initialize inheritance |
|
| 65 | - $this->registerInit($compiler, true); |
|
| 66 | - $file = trim($_attr[ 'file' ], '\'"'); |
|
| 67 | - if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
|
| 68 | - // generate code for each template |
|
| 69 | - $files = array_reverse(explode('|', substr($file, 8))); |
|
| 70 | - $i = 0; |
|
| 71 | - foreach ($files as $file) { |
|
| 72 | - if ($file[ 0 ] == '"') { |
|
| 73 | - $file = trim($file, '".'); |
|
| 74 | - } else { |
|
| 75 | - $file = "'{$file}'"; |
|
| 76 | - } |
|
| 77 | - $i ++; |
|
| 78 | - if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 79 | - $this->compileEndChild($compiler); |
|
| 80 | - } |
|
| 81 | - $this->compileInclude($compiler, $file); |
|
| 82 | - } |
|
| 83 | - if (!isset($_attr[ 'extends_resource' ])) { |
|
| 84 | - $this->compileEndChild($compiler); |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - $this->compileEndChild($compiler); |
|
| 88 | - $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 89 | - } |
|
| 90 | - $compiler->has_code = false; |
|
| 91 | - return ''; |
|
| 92 | - } |
|
| 44 | + /** |
|
| 45 | + * Compiles code for the {extends} tag extends: resource |
|
| 46 | + * |
|
| 47 | + * @param array $args array with attributes from parser |
|
| 48 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | + * |
|
| 50 | + * @return string compiled code |
|
| 51 | + * @throws \SmartyCompilerException |
|
| 52 | + * @throws \SmartyException |
|
| 53 | + */ |
|
| 54 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 55 | + { |
|
| 56 | + // check and get attributes |
|
| 57 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 58 | + if ($_attr[ 'nocache' ] === true) { |
|
| 59 | + $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
|
| 60 | + } |
|
| 61 | + if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 62 | + $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
|
| 63 | + } |
|
| 64 | + // add code to initialize inheritance |
|
| 65 | + $this->registerInit($compiler, true); |
|
| 66 | + $file = trim($_attr[ 'file' ], '\'"'); |
|
| 67 | + if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
|
| 68 | + // generate code for each template |
|
| 69 | + $files = array_reverse(explode('|', substr($file, 8))); |
|
| 70 | + $i = 0; |
|
| 71 | + foreach ($files as $file) { |
|
| 72 | + if ($file[ 0 ] == '"') { |
|
| 73 | + $file = trim($file, '".'); |
|
| 74 | + } else { |
|
| 75 | + $file = "'{$file}'"; |
|
| 76 | + } |
|
| 77 | + $i ++; |
|
| 78 | + if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 79 | + $this->compileEndChild($compiler); |
|
| 80 | + } |
|
| 81 | + $this->compileInclude($compiler, $file); |
|
| 82 | + } |
|
| 83 | + if (!isset($_attr[ 'extends_resource' ])) { |
|
| 84 | + $this->compileEndChild($compiler); |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + $this->compileEndChild($compiler); |
|
| 88 | + $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 89 | + } |
|
| 90 | + $compiler->has_code = false; |
|
| 91 | + return ''; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Add code for inheritance endChild() method to end of template |
|
| 96 | - * |
|
| 97 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 98 | - */ |
|
| 99 | - private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 100 | - { |
|
| 101 | - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 102 | - "<?php \$_smarty_tpl->inheritance->endChild();\n?>\n"); |
|
| 103 | - } |
|
| 94 | + /** |
|
| 95 | + * Add code for inheritance endChild() method to end of template |
|
| 96 | + * |
|
| 97 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 98 | + */ |
|
| 99 | + private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 100 | + { |
|
| 101 | + $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 102 | + "<?php \$_smarty_tpl->inheritance->endChild();\n?>\n"); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Add code for including subtemplate to end of template |
|
| 107 | - * |
|
| 108 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 109 | - * @param string $file subtemplate name |
|
| 110 | - */ |
|
| 111 | - private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file) |
|
| 112 | - { |
|
| 113 | - $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 114 | - $compiler->compileTag('include', |
|
| 115 | - array($file, |
|
| 116 | - array('scope' => 'parent')))); |
|
| 117 | - } |
|
| 105 | + /** |
|
| 106 | + * Add code for including subtemplate to end of template |
|
| 107 | + * |
|
| 108 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 109 | + * @param string $file subtemplate name |
|
| 110 | + */ |
|
| 111 | + private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file) |
|
| 112 | + { |
|
| 113 | + $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 114 | + $compiler->compileTag('include', |
|
| 115 | + array($file, |
|
| 116 | + array('scope' => 'parent')))); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Create source code for {extends} from source components array |
|
| 121 | - * |
|
| 122 | - * @param []\Smarty_Internal_Template_Source $components |
|
| 123 | - * |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 126 | - public static function extendsSourceArrayCode($components) |
|
| 127 | - { |
|
| 128 | - $resources = array(); |
|
| 129 | - foreach ($components as $source) { |
|
| 130 | - $resources[] = $source->resource; |
|
| 131 | - } |
|
| 132 | - return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}'; |
|
| 133 | - } |
|
| 119 | + /** |
|
| 120 | + * Create source code for {extends} from source components array |
|
| 121 | + * |
|
| 122 | + * @param []\Smarty_Internal_Template_Source $components |
|
| 123 | + * |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | + public static function extendsSourceArrayCode($components) |
|
| 127 | + { |
|
| 128 | + $resources = array(); |
|
| 129 | + foreach ($components as $source) { |
|
| 130 | + $resources[] = $source->resource; |
|
| 131 | + } |
|
| 132 | + return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}'; |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -55,37 +55,37 @@ |
||
| 55 | 55 | { |
| 56 | 56 | // check and get attributes |
| 57 | 57 | $_attr = $this->getAttributes($compiler, $args); |
| 58 | - if ($_attr[ 'nocache' ] === true) { |
|
| 58 | + if ($_attr['nocache'] === true) { |
|
| 59 | 59 | $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1); |
| 60 | 60 | } |
| 61 | - if (strpos($_attr[ 'file' ], '$_tmp') !== false) { |
|
| 61 | + if (strpos($_attr['file'], '$_tmp') !== false) { |
|
| 62 | 62 | $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1); |
| 63 | 63 | } |
| 64 | 64 | // add code to initialize inheritance |
| 65 | 65 | $this->registerInit($compiler, true); |
| 66 | - $file = trim($_attr[ 'file' ], '\'"'); |
|
| 66 | + $file = trim($_attr['file'], '\'"'); |
|
| 67 | 67 | if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { |
| 68 | 68 | // generate code for each template |
| 69 | 69 | $files = array_reverse(explode('|', substr($file, 8))); |
| 70 | 70 | $i = 0; |
| 71 | 71 | foreach ($files as $file) { |
| 72 | - if ($file[ 0 ] == '"') { |
|
| 72 | + if ($file[0] == '"') { |
|
| 73 | 73 | $file = trim($file, '".'); |
| 74 | 74 | } else { |
| 75 | 75 | $file = "'{$file}'"; |
| 76 | 76 | } |
| 77 | - $i ++; |
|
| 78 | - if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { |
|
| 77 | + $i++; |
|
| 78 | + if ($i == count($files) && isset($_attr['extends_resource'])) { |
|
| 79 | 79 | $this->compileEndChild($compiler); |
| 80 | 80 | } |
| 81 | 81 | $this->compileInclude($compiler, $file); |
| 82 | 82 | } |
| 83 | - if (!isset($_attr[ 'extends_resource' ])) { |
|
| 83 | + if (!isset($_attr['extends_resource'])) { |
|
| 84 | 84 | $this->compileEndChild($compiler); |
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | 87 | $this->compileEndChild($compiler); |
| 88 | - $this->compileInclude($compiler, $_attr[ 'file' ]); |
|
| 88 | + $this->compileInclude($compiler, $_attr['file']); |
|
| 89 | 89 | } |
| 90 | 90 | $compiler->has_code = false; |
| 91 | 91 | return ''; |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | * Compiles code for the {/function} tag |
| 93 | 93 | * |
| 94 | 94 | * @param array $args array with attributes from parser |
| 95 | - * @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 95 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 96 | 96 | * @param array $parameter array with compilation parameter |
| 97 | 97 | * |
| 98 | 98 | * @return bool true |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | // check and get attributes |
| 57 | 57 | $_attr = $this->getAttributes($compiler, $args); |
| 58 | 58 | |
| 59 | - if ($_attr[ 'nocache' ] === true) { |
|
| 59 | + if ($_attr['nocache'] === true) { |
|
| 60 | 60 | $compiler->trigger_template_error('nocache option not allowed', null, true); |
| 61 | 61 | } |
| 62 | - unset($_attr[ 'nocache' ]); |
|
| 63 | - $_name = trim($_attr[ 'name' ], "'\""); |
|
| 64 | - $compiler->parent_compiler->tpl_function[ $_name ] = array(); |
|
| 62 | + unset($_attr['nocache']); |
|
| 63 | + $_name = trim($_attr['name'], "'\""); |
|
| 64 | + $compiler->parent_compiler->tpl_function[$_name] = array(); |
|
| 65 | 65 | $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, |
| 66 | 66 | $compiler->template->caching); |
| 67 | 67 | $this->openTag($compiler, 'function', $save); |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $this->compiler = $compiler; |
| 103 | 103 | $saved_data = $this->closeTag($compiler, array('function')); |
| 104 | - $_attr = $saved_data[ 0 ]; |
|
| 105 | - $_name = trim($_attr[ 'name' ], "'\""); |
|
| 106 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] = |
|
| 104 | + $_attr = $saved_data[0]; |
|
| 105 | + $_name = trim($_attr['name'], "'\""); |
|
| 106 | + $compiler->parent_compiler->tpl_function[$_name]['compiled_filepath'] = |
|
| 107 | 107 | $compiler->parent_compiler->template->compiled->filepath; |
| 108 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid; |
|
| 108 | + $compiler->parent_compiler->tpl_function[$_name]['uid'] = $compiler->template->source->uid; |
|
| 109 | 109 | $_parameter = $_attr; |
| 110 | - unset($_parameter[ 'name' ]); |
|
| 110 | + unset($_parameter['name']); |
|
| 111 | 111 | // default parameter |
| 112 | 112 | $_paramsArray = array(); |
| 113 | 113 | foreach ($_parameter as $_key => $_value) { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}"; |
| 131 | 131 | $_funcNameCaching = $_funcName . '_nocache'; |
| 132 | 132 | if ($compiler->template->compiled->has_nocache_code) { |
| 133 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching; |
|
| 133 | + $compiler->parent_compiler->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching; |
|
| 134 | 134 | $output = "<?php\n"; |
| 135 | 135 | $output .= "/* {$_funcNameCaching} */\n"; |
| 136 | 136 | $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | array($this, 'removeNocache'), |
| 163 | 163 | $_functionCode->to_smarty_php($compiler->parser))); |
| 164 | 164 | } |
| 165 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName; |
|
| 165 | + $compiler->parent_compiler->tpl_function[$_name]['call_name'] = $_funcName; |
|
| 166 | 166 | $output = "<?php\n"; |
| 167 | 167 | $output .= "/* {$_funcName} */\n"; |
| 168 | 168 | $output .= "if (!function_exists('{$_funcName}')) {\n"; |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | $output)); |
| 182 | 182 | $compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
| 183 | 183 | // nocache plugins must be copied |
| 184 | - if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 185 | - foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 184 | + if (!empty($compiler->template->compiled->required_plugins['nocache'])) { |
|
| 185 | + foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) { |
|
| 186 | 186 | foreach ($tmp as $type => $data) { |
| 187 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 187 | + $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$plugin][$type] = |
|
| 188 | 188 | $data; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | // restore old buffer |
| 193 | 193 | |
| 194 | - $compiler->parser->current_buffer = $saved_data[ 1 ]; |
|
| 194 | + $compiler->parser->current_buffer = $saved_data[1]; |
|
| 195 | 195 | // restore old status |
| 196 | - $compiler->template->compiled->has_nocache_code = $saved_data[ 2 ]; |
|
| 197 | - $compiler->template->caching = $saved_data[ 3 ]; |
|
| 196 | + $compiler->template->compiled->has_nocache_code = $saved_data[2]; |
|
| 197 | + $compiler->template->caching = $saved_data[3]; |
|
| 198 | 198 | return true; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $code = |
| 211 | 211 | preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", |
| 212 | - '', $match[ 0 ]); |
|
| 212 | + '', $match[0]); |
|
| 213 | 213 | $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code); |
| 214 | 214 | return $code; |
| 215 | 215 | } |
@@ -17,59 +17,59 @@ discard block |
||
| 17 | 17 | class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Attribute definition: Overwrites base class. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - * @see Smarty_Internal_CompileBase |
|
| 25 | - */ |
|
| 26 | - public $required_attributes = array('name'); |
|
| 20 | + /** |
|
| 21 | + * Attribute definition: Overwrites base class. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + * @see Smarty_Internal_CompileBase |
|
| 25 | + */ |
|
| 26 | + public $required_attributes = array('name'); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Attribute definition: Overwrites base class. |
|
| 30 | - * |
|
| 31 | - * @var array |
|
| 32 | - * @see Smarty_Internal_CompileBase |
|
| 33 | - */ |
|
| 34 | - public $shorttag_order = array('name'); |
|
| 28 | + /** |
|
| 29 | + * Attribute definition: Overwrites base class. |
|
| 30 | + * |
|
| 31 | + * @var array |
|
| 32 | + * @see Smarty_Internal_CompileBase |
|
| 33 | + */ |
|
| 34 | + public $shorttag_order = array('name'); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Attribute definition: Overwrites base class. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - * @see Smarty_Internal_CompileBase |
|
| 41 | - */ |
|
| 42 | - public $optional_attributes = array('_any'); |
|
| 36 | + /** |
|
| 37 | + * Attribute definition: Overwrites base class. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + * @see Smarty_Internal_CompileBase |
|
| 41 | + */ |
|
| 42 | + public $optional_attributes = array('_any'); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Compiles code for the {function} tag |
|
| 46 | - * |
|
| 47 | - * @param array $args array with attributes from parser |
|
| 48 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | - * @param array $parameter array with compilation parameter |
|
| 50 | - * |
|
| 51 | - * @return bool true |
|
| 52 | - * @throws \SmartyCompilerException |
|
| 53 | - */ |
|
| 54 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 55 | - { |
|
| 56 | - // check and get attributes |
|
| 57 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 44 | + /** |
|
| 45 | + * Compiles code for the {function} tag |
|
| 46 | + * |
|
| 47 | + * @param array $args array with attributes from parser |
|
| 48 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 49 | + * @param array $parameter array with compilation parameter |
|
| 50 | + * |
|
| 51 | + * @return bool true |
|
| 52 | + * @throws \SmartyCompilerException |
|
| 53 | + */ |
|
| 54 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 55 | + { |
|
| 56 | + // check and get attributes |
|
| 57 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 58 | 58 | |
| 59 | - if ($_attr[ 'nocache' ] === true) { |
|
| 60 | - $compiler->trigger_template_error('nocache option not allowed', null, true); |
|
| 61 | - } |
|
| 62 | - unset($_attr[ 'nocache' ]); |
|
| 63 | - $_name = trim($_attr[ 'name' ], "'\""); |
|
| 64 | - $compiler->parent_compiler->tpl_function[ $_name ] = array(); |
|
| 65 | - $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, |
|
| 66 | - $compiler->template->caching); |
|
| 67 | - $this->openTag($compiler, 'function', $save); |
|
| 68 | - // Init temporary context |
|
| 69 | - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 70 | - $compiler->template->compiled->has_nocache_code = false; |
|
| 71 | - return true; |
|
| 72 | - } |
|
| 59 | + if ($_attr[ 'nocache' ] === true) { |
|
| 60 | + $compiler->trigger_template_error('nocache option not allowed', null, true); |
|
| 61 | + } |
|
| 62 | + unset($_attr[ 'nocache' ]); |
|
| 63 | + $_name = trim($_attr[ 'name' ], "'\""); |
|
| 64 | + $compiler->parent_compiler->tpl_function[ $_name ] = array(); |
|
| 65 | + $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, |
|
| 66 | + $compiler->template->caching); |
|
| 67 | + $this->openTag($compiler, 'function', $save); |
|
| 68 | + // Init temporary context |
|
| 69 | + $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 70 | + $compiler->template->compiled->has_nocache_code = false; |
|
| 71 | + return true; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -81,136 +81,136 @@ discard block |
||
| 81 | 81 | class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase |
| 82 | 82 | { |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Compiler object |
|
| 86 | - * |
|
| 87 | - * @var object |
|
| 88 | - */ |
|
| 89 | - private $compiler = null; |
|
| 84 | + /** |
|
| 85 | + * Compiler object |
|
| 86 | + * |
|
| 87 | + * @var object |
|
| 88 | + */ |
|
| 89 | + private $compiler = null; |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Compiles code for the {/function} tag |
|
| 93 | - * |
|
| 94 | - * @param array $args array with attributes from parser |
|
| 95 | - * @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 96 | - * @param array $parameter array with compilation parameter |
|
| 97 | - * |
|
| 98 | - * @return bool true |
|
| 99 | - */ |
|
| 100 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 101 | - { |
|
| 102 | - $this->compiler = $compiler; |
|
| 103 | - $saved_data = $this->closeTag($compiler, array('function')); |
|
| 104 | - $_attr = $saved_data[ 0 ]; |
|
| 105 | - $_name = trim($_attr[ 'name' ], "'\""); |
|
| 106 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] = |
|
| 107 | - $compiler->parent_compiler->template->compiled->filepath; |
|
| 108 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid; |
|
| 109 | - $_parameter = $_attr; |
|
| 110 | - unset($_parameter[ 'name' ]); |
|
| 111 | - // default parameter |
|
| 112 | - $_paramsArray = array(); |
|
| 113 | - foreach ($_parameter as $_key => $_value) { |
|
| 114 | - if (is_int($_key)) { |
|
| 115 | - $_paramsArray[] = "$_key=>$_value"; |
|
| 116 | - } else { |
|
| 117 | - $_paramsArray[] = "'$_key'=>$_value"; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - if (!empty($_paramsArray)) { |
|
| 121 | - $_params = 'array(' . implode(",", $_paramsArray) . ')'; |
|
| 122 | - $_paramsCode = "\$params = array_merge($_params, \$params);\n"; |
|
| 123 | - } else { |
|
| 124 | - $_paramsCode = ''; |
|
| 125 | - } |
|
| 126 | - $_functionCode = $compiler->parser->current_buffer; |
|
| 127 | - // setup buffer for template function code |
|
| 128 | - $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 91 | + /** |
|
| 92 | + * Compiles code for the {/function} tag |
|
| 93 | + * |
|
| 94 | + * @param array $args array with attributes from parser |
|
| 95 | + * @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 96 | + * @param array $parameter array with compilation parameter |
|
| 97 | + * |
|
| 98 | + * @return bool true |
|
| 99 | + */ |
|
| 100 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 101 | + { |
|
| 102 | + $this->compiler = $compiler; |
|
| 103 | + $saved_data = $this->closeTag($compiler, array('function')); |
|
| 104 | + $_attr = $saved_data[ 0 ]; |
|
| 105 | + $_name = trim($_attr[ 'name' ], "'\""); |
|
| 106 | + $compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] = |
|
| 107 | + $compiler->parent_compiler->template->compiled->filepath; |
|
| 108 | + $compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid; |
|
| 109 | + $_parameter = $_attr; |
|
| 110 | + unset($_parameter[ 'name' ]); |
|
| 111 | + // default parameter |
|
| 112 | + $_paramsArray = array(); |
|
| 113 | + foreach ($_parameter as $_key => $_value) { |
|
| 114 | + if (is_int($_key)) { |
|
| 115 | + $_paramsArray[] = "$_key=>$_value"; |
|
| 116 | + } else { |
|
| 117 | + $_paramsArray[] = "'$_key'=>$_value"; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + if (!empty($_paramsArray)) { |
|
| 121 | + $_params = 'array(' . implode(",", $_paramsArray) . ')'; |
|
| 122 | + $_paramsCode = "\$params = array_merge($_params, \$params);\n"; |
|
| 123 | + } else { |
|
| 124 | + $_paramsCode = ''; |
|
| 125 | + } |
|
| 126 | + $_functionCode = $compiler->parser->current_buffer; |
|
| 127 | + // setup buffer for template function code |
|
| 128 | + $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template(); |
|
| 129 | 129 | |
| 130 | - $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}"; |
|
| 131 | - $_funcNameCaching = $_funcName . '_nocache'; |
|
| 132 | - if ($compiler->template->compiled->has_nocache_code) { |
|
| 133 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching; |
|
| 134 | - $output = "<?php\n"; |
|
| 135 | - $output .= "/* {$_funcNameCaching} */\n"; |
|
| 136 | - $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; |
|
| 137 | - $output .= "function {$_funcNameCaching} (\$_smarty_tpl,\$params) {\n"; |
|
| 138 | - $output .= "ob_start();\n"; |
|
| 139 | - $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n"; |
|
| 140 | - $output .= $_paramsCode; |
|
| 141 | - $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}"; |
|
| 142 | - $output .= "\$params = var_export(\$params, true);\n"; |
|
| 143 | - $output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php "; |
|
| 144 | - $output .= "\\\$_smarty_tpl->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>"; |
|
| 145 | - $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n\";?>"; |
|
| 146 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 147 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 148 | - $output)); |
|
| 149 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 150 | - $output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php "; |
|
| 151 | - $output .= "\\\$_smarty_tpl->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n"; |
|
| 152 | - $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>"; |
|
| 153 | - $output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n"; |
|
| 154 | - $output .= "}\n}\n"; |
|
| 155 | - $output .= "/*/ {$_funcName}_nocache */\n\n"; |
|
| 156 | - $output .= "?>\n"; |
|
| 157 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 158 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 159 | - $output)); |
|
| 160 | - $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 161 | - preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", |
|
| 162 | - array($this, 'removeNocache'), |
|
| 163 | - $_functionCode->to_smarty_php($compiler->parser))); |
|
| 164 | - } |
|
| 165 | - $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName; |
|
| 166 | - $output = "<?php\n"; |
|
| 167 | - $output .= "/* {$_funcName} */\n"; |
|
| 168 | - $output .= "if (!function_exists('{$_funcName}')) {\n"; |
|
| 169 | - $output .= "function {$_funcName}(\$_smarty_tpl,\$params) {\n"; |
|
| 170 | - $output .= $_paramsCode; |
|
| 171 | - $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}?>"; |
|
| 172 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 173 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 174 | - $output)); |
|
| 175 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 176 | - $output = "<?php\n}}\n"; |
|
| 177 | - $output .= "/*/ {$_funcName} */\n\n"; |
|
| 178 | - $output .= "?>\n"; |
|
| 179 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 180 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 181 | - $output)); |
|
| 182 | - $compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
|
| 183 | - // nocache plugins must be copied |
|
| 184 | - if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 185 | - foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 186 | - foreach ($tmp as $type => $data) { |
|
| 187 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 188 | - $data; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - // restore old buffer |
|
| 130 | + $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}"; |
|
| 131 | + $_funcNameCaching = $_funcName . '_nocache'; |
|
| 132 | + if ($compiler->template->compiled->has_nocache_code) { |
|
| 133 | + $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching; |
|
| 134 | + $output = "<?php\n"; |
|
| 135 | + $output .= "/* {$_funcNameCaching} */\n"; |
|
| 136 | + $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; |
|
| 137 | + $output .= "function {$_funcNameCaching} (\$_smarty_tpl,\$params) {\n"; |
|
| 138 | + $output .= "ob_start();\n"; |
|
| 139 | + $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n"; |
|
| 140 | + $output .= $_paramsCode; |
|
| 141 | + $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}"; |
|
| 142 | + $output .= "\$params = var_export(\$params, true);\n"; |
|
| 143 | + $output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php "; |
|
| 144 | + $output .= "\\\$_smarty_tpl->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>"; |
|
| 145 | + $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n\";?>"; |
|
| 146 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 147 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 148 | + $output)); |
|
| 149 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 150 | + $output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php "; |
|
| 151 | + $output .= "\\\$_smarty_tpl->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n"; |
|
| 152 | + $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>"; |
|
| 153 | + $output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n"; |
|
| 154 | + $output .= "}\n}\n"; |
|
| 155 | + $output .= "/*/ {$_funcName}_nocache */\n\n"; |
|
| 156 | + $output .= "?>\n"; |
|
| 157 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 158 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 159 | + $output)); |
|
| 160 | + $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 161 | + preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", |
|
| 162 | + array($this, 'removeNocache'), |
|
| 163 | + $_functionCode->to_smarty_php($compiler->parser))); |
|
| 164 | + } |
|
| 165 | + $compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName; |
|
| 166 | + $output = "<?php\n"; |
|
| 167 | + $output .= "/* {$_funcName} */\n"; |
|
| 168 | + $output .= "if (!function_exists('{$_funcName}')) {\n"; |
|
| 169 | + $output .= "function {$_funcName}(\$_smarty_tpl,\$params) {\n"; |
|
| 170 | + $output .= $_paramsCode; |
|
| 171 | + $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}?>"; |
|
| 172 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 173 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 174 | + $output)); |
|
| 175 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode); |
|
| 176 | + $output = "<?php\n}}\n"; |
|
| 177 | + $output .= "/*/ {$_funcName} */\n\n"; |
|
| 178 | + $output .= "?>\n"; |
|
| 179 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 180 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 181 | + $output)); |
|
| 182 | + $compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser); |
|
| 183 | + // nocache plugins must be copied |
|
| 184 | + if (!empty($compiler->template->compiled->required_plugins[ 'nocache' ])) { |
|
| 185 | + foreach ($compiler->template->compiled->required_plugins[ 'nocache' ] as $plugin => $tmp) { |
|
| 186 | + foreach ($tmp as $type => $data) { |
|
| 187 | + $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin ][ $type ] = |
|
| 188 | + $data; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + // restore old buffer |
|
| 193 | 193 | |
| 194 | - $compiler->parser->current_buffer = $saved_data[ 1 ]; |
|
| 195 | - // restore old status |
|
| 196 | - $compiler->template->compiled->has_nocache_code = $saved_data[ 2 ]; |
|
| 197 | - $compiler->template->caching = $saved_data[ 3 ]; |
|
| 198 | - return true; |
|
| 199 | - } |
|
| 194 | + $compiler->parser->current_buffer = $saved_data[ 1 ]; |
|
| 195 | + // restore old status |
|
| 196 | + $compiler->template->compiled->has_nocache_code = $saved_data[ 2 ]; |
|
| 197 | + $compiler->template->caching = $saved_data[ 3 ]; |
|
| 198 | + return true; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Remove nocache code |
|
| 203 | - * |
|
| 204 | - * @param $match |
|
| 205 | - * |
|
| 206 | - * @return string |
|
| 207 | - */ |
|
| 208 | - public function removeNocache($match) |
|
| 209 | - { |
|
| 210 | - $code = |
|
| 211 | - preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", |
|
| 212 | - '', $match[ 0 ]); |
|
| 213 | - $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code); |
|
| 214 | - return $code; |
|
| 215 | - } |
|
| 201 | + /** |
|
| 202 | + * Remove nocache code |
|
| 203 | + * |
|
| 204 | + * @param $match |
|
| 205 | + * |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 208 | + public function removeNocache($match) |
|
| 209 | + { |
|
| 210 | + $code = |
|
| 211 | + preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", |
|
| 212 | + '', $match[ 0 ]); |
|
| 213 | + $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code); |
|
| 214 | + return $code; |
|
| 215 | + } |
|
| 216 | 216 | } |
@@ -111,7 +111,7 @@ |
||
| 111 | 111 | * |
| 112 | 112 | * This code has been moved from lexer here fo easier debugging and maintenance |
| 113 | 113 | * |
| 114 | - * @param $lex |
|
| 114 | + * @param Smarty_Internal_Templatelexer $lex |
|
| 115 | 115 | */ |
| 116 | 116 | public function parsePhp($lex) |
| 117 | 117 | { |
@@ -17,204 +17,204 @@ |
||
| 17 | 17 | class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Attribute definition: Overwrites base class. |
|
| 22 | - * |
|
| 23 | - * @var array |
|
| 24 | - * @see Smarty_Internal_CompileBase |
|
| 25 | - */ |
|
| 26 | - public $required_attributes = array('code', 'type'); |
|
| 20 | + /** |
|
| 21 | + * Attribute definition: Overwrites base class. |
|
| 22 | + * |
|
| 23 | + * @var array |
|
| 24 | + * @see Smarty_Internal_CompileBase |
|
| 25 | + */ |
|
| 26 | + public $required_attributes = array('code', 'type'); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Compiles code for generating output from any expression |
|
| 30 | - * |
|
| 31 | - * @param array $args array with attributes from parser |
|
| 32 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 33 | - * @param array $parameter array with compilation parameter |
|
| 34 | - * |
|
| 35 | - * @return string |
|
| 36 | - * @throws \SmartyException |
|
| 37 | - */ |
|
| 38 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 39 | - { |
|
| 40 | - // check and get attributes |
|
| 41 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 42 | - $compiler->has_code = false; |
|
| 43 | - if ($_attr[ 'type' ] == 'xml') { |
|
| 44 | - $compiler->tag_nocache = true; |
|
| 45 | - $save = $compiler->template->compiled->has_nocache_code; |
|
| 46 | - $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 47 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 48 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 49 | - $compiler->processNocacheCode("<?php echo '" . |
|
| 50 | - $output . |
|
| 51 | - "';?>", |
|
| 52 | - true))); |
|
| 53 | - $compiler->template->compiled->has_nocache_code = $save; |
|
| 54 | - return ''; |
|
| 55 | - } |
|
| 56 | - if ($_attr[ 'type' ] != 'tag') { |
|
| 57 | - if ($compiler->php_handling == Smarty::PHP_REMOVE) { |
|
| 58 | - return ''; |
|
| 59 | - } elseif ($compiler->php_handling == Smarty::PHP_QUOTE) { |
|
| 60 | - $output = |
|
| 61 | - preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', |
|
| 62 | - array($this, 'quote'), $_attr[ 'code' ]); |
|
| 63 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 64 | - new Smarty_Internal_ParseTree_Text($output)); |
|
| 65 | - return ''; |
|
| 66 | - } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') { |
|
| 67 | - $compiler->tag_nocache = true; |
|
| 68 | - $save = $compiler->template->compiled->has_nocache_code; |
|
| 69 | - $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 70 | - $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 71 | - new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 72 | - $compiler->processNocacheCode("<?php echo '" . |
|
| 73 | - $output . |
|
| 74 | - "';?>", |
|
| 75 | - true))); |
|
| 76 | - $compiler->template->compiled->has_nocache_code = $save; |
|
| 77 | - return ''; |
|
| 78 | - } elseif ($compiler->php_handling == Smarty::PHP_ALLOW) { |
|
| 79 | - if (!($compiler->smarty instanceof SmartyBC)) { |
|
| 80 | - $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', |
|
| 81 | - null, true); |
|
| 82 | - } |
|
| 83 | - $compiler->has_code = true; |
|
| 84 | - return $_attr[ 'code' ]; |
|
| 85 | - } else { |
|
| 86 | - $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true); |
|
| 87 | - } |
|
| 88 | - } else { |
|
| 89 | - $compiler->has_code = true; |
|
| 90 | - if (!($compiler->smarty instanceof SmartyBC)) { |
|
| 91 | - $compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null, |
|
| 92 | - true); |
|
| 93 | - } |
|
| 94 | - $ldel = preg_quote($compiler->smarty->left_delimiter, '#'); |
|
| 95 | - $rdel = preg_quote($compiler->smarty->right_delimiter, '#'); |
|
| 96 | - preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match); |
|
| 97 | - if (!empty($match[ 2 ])) { |
|
| 98 | - if ('nocache' == trim($match[ 2 ])) { |
|
| 99 | - $compiler->tag_nocache = true; |
|
| 100 | - } else { |
|
| 101 | - $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), |
|
| 105 | - array('<?php ', '?>'), $_attr[ 'code' ]); |
|
| 106 | - } |
|
| 107 | - } |
|
| 28 | + /** |
|
| 29 | + * Compiles code for generating output from any expression |
|
| 30 | + * |
|
| 31 | + * @param array $args array with attributes from parser |
|
| 32 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 33 | + * @param array $parameter array with compilation parameter |
|
| 34 | + * |
|
| 35 | + * @return string |
|
| 36 | + * @throws \SmartyException |
|
| 37 | + */ |
|
| 38 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 39 | + { |
|
| 40 | + // check and get attributes |
|
| 41 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 42 | + $compiler->has_code = false; |
|
| 43 | + if ($_attr[ 'type' ] == 'xml') { |
|
| 44 | + $compiler->tag_nocache = true; |
|
| 45 | + $save = $compiler->template->compiled->has_nocache_code; |
|
| 46 | + $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 47 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 48 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 49 | + $compiler->processNocacheCode("<?php echo '" . |
|
| 50 | + $output . |
|
| 51 | + "';?>", |
|
| 52 | + true))); |
|
| 53 | + $compiler->template->compiled->has_nocache_code = $save; |
|
| 54 | + return ''; |
|
| 55 | + } |
|
| 56 | + if ($_attr[ 'type' ] != 'tag') { |
|
| 57 | + if ($compiler->php_handling == Smarty::PHP_REMOVE) { |
|
| 58 | + return ''; |
|
| 59 | + } elseif ($compiler->php_handling == Smarty::PHP_QUOTE) { |
|
| 60 | + $output = |
|
| 61 | + preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', |
|
| 62 | + array($this, 'quote'), $_attr[ 'code' ]); |
|
| 63 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 64 | + new Smarty_Internal_ParseTree_Text($output)); |
|
| 65 | + return ''; |
|
| 66 | + } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') { |
|
| 67 | + $compiler->tag_nocache = true; |
|
| 68 | + $save = $compiler->template->compiled->has_nocache_code; |
|
| 69 | + $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 70 | + $compiler->parser->current_buffer->append_subtree($compiler->parser, |
|
| 71 | + new Smarty_Internal_ParseTree_Tag($compiler->parser, |
|
| 72 | + $compiler->processNocacheCode("<?php echo '" . |
|
| 73 | + $output . |
|
| 74 | + "';?>", |
|
| 75 | + true))); |
|
| 76 | + $compiler->template->compiled->has_nocache_code = $save; |
|
| 77 | + return ''; |
|
| 78 | + } elseif ($compiler->php_handling == Smarty::PHP_ALLOW) { |
|
| 79 | + if (!($compiler->smarty instanceof SmartyBC)) { |
|
| 80 | + $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', |
|
| 81 | + null, true); |
|
| 82 | + } |
|
| 83 | + $compiler->has_code = true; |
|
| 84 | + return $_attr[ 'code' ]; |
|
| 85 | + } else { |
|
| 86 | + $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true); |
|
| 87 | + } |
|
| 88 | + } else { |
|
| 89 | + $compiler->has_code = true; |
|
| 90 | + if (!($compiler->smarty instanceof SmartyBC)) { |
|
| 91 | + $compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null, |
|
| 92 | + true); |
|
| 93 | + } |
|
| 94 | + $ldel = preg_quote($compiler->smarty->left_delimiter, '#'); |
|
| 95 | + $rdel = preg_quote($compiler->smarty->right_delimiter, '#'); |
|
| 96 | + preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match); |
|
| 97 | + if (!empty($match[ 2 ])) { |
|
| 98 | + if ('nocache' == trim($match[ 2 ])) { |
|
| 99 | + $compiler->tag_nocache = true; |
|
| 100 | + } else { |
|
| 101 | + $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), |
|
| 105 | + array('<?php ', '?>'), $_attr[ 'code' ]); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Lexer code for PHP tags |
|
| 111 | - * |
|
| 112 | - * This code has been moved from lexer here fo easier debugging and maintenance |
|
| 113 | - * |
|
| 114 | - * @param $lex |
|
| 115 | - */ |
|
| 116 | - public function parsePhp($lex) |
|
| 117 | - { |
|
| 118 | - $lex->token = Smarty_Internal_Templateparser::TP_PHP; |
|
| 119 | - $close = 0; |
|
| 120 | - $lex->taglineno = $lex->line; |
|
| 121 | - $closeTag = '?>'; |
|
| 122 | - if (strpos($lex->value, '<?xml') === 0) { |
|
| 123 | - $lex->is_xml = true; |
|
| 124 | - $lex->token = Smarty_Internal_Templateparser::TP_NOCACHE; |
|
| 125 | - return; |
|
| 126 | - } elseif (strpos($lex->value, '<?') === 0) { |
|
| 127 | - $lex->phpType = 'php'; |
|
| 128 | - } elseif (strpos($lex->value, '<%') === 0) { |
|
| 129 | - $lex->phpType = 'asp'; |
|
| 130 | - $closeTag = '%>'; |
|
| 131 | - } elseif (strpos($lex->value, '%>') === 0) { |
|
| 132 | - $lex->phpType = 'unmatched'; |
|
| 133 | - } elseif (strpos($lex->value, '?>') === 0) { |
|
| 134 | - if ($lex->is_xml) { |
|
| 135 | - $lex->is_xml = false; |
|
| 136 | - $lex->token = Smarty_Internal_Templateparser::TP_NOCACHE; |
|
| 137 | - return; |
|
| 138 | - } |
|
| 139 | - $lex->phpType = 'unmatched'; |
|
| 140 | - } elseif (strpos($lex->value, '<s') === 0) { |
|
| 141 | - $lex->phpType = 'script'; |
|
| 142 | - $closeTag = '</script>'; |
|
| 143 | - } elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) { |
|
| 144 | - if ($lex->isAutoLiteral()) { |
|
| 145 | - $lex->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
| 146 | - return; |
|
| 147 | - } |
|
| 148 | - $closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}"; |
|
| 149 | - if ($lex->value == $closeTag) { |
|
| 150 | - $lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'"); |
|
| 151 | - } |
|
| 152 | - $lex->phpType = 'tag'; |
|
| 153 | - } |
|
| 154 | - if ($lex->phpType == 'unmatched') { |
|
| 155 | - return; |
|
| 156 | - } |
|
| 157 | - if (($lex->phpType == 'php' || $lex->phpType == 'asp') && |
|
| 158 | - ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE) |
|
| 159 | - ) { |
|
| 160 | - return; |
|
| 161 | - } |
|
| 162 | - $start = $lex->counter + strlen($lex->value); |
|
| 163 | - $body = true; |
|
| 164 | - if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
|
| 165 | - $close = $match[ 0 ][ 1 ]; |
|
| 166 | - } else { |
|
| 167 | - $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
|
| 168 | - } |
|
| 169 | - while ($body) { |
|
| 170 | - if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', |
|
| 171 | - $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
|
| 172 | - $value = $match[ 0 ][ 0 ]; |
|
| 173 | - $from = $pos = $match[ 0 ][ 1 ]; |
|
| 174 | - if ($pos > $close) { |
|
| 175 | - $body = false; |
|
| 176 | - } else { |
|
| 177 | - $start = $pos + strlen($value); |
|
| 178 | - $phpCommentStart = $value == '/*'; |
|
| 179 | - if ($phpCommentStart) { |
|
| 180 | - $phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start); |
|
| 181 | - if ($phpCommentEnd) { |
|
| 182 | - $pos2 = $match[ 0 ][ 1 ]; |
|
| 183 | - $start = $pos2 + strlen($match[ 0 ][ 0 ]); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - while ($close > $pos && $close < $start) { |
|
| 187 | - if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, |
|
| 188 | - $from)) { |
|
| 189 | - $close = $match[ 0 ][ 1 ]; |
|
| 190 | - $from = $close + strlen($match[ 0 ][ 0 ]); |
|
| 191 | - } else { |
|
| 192 | - $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) { |
|
| 196 | - $lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n"); |
|
| 197 | - $lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'"); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } else { |
|
| 201 | - $body = false; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - $lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter); |
|
| 205 | - } |
|
| 109 | + /** |
|
| 110 | + * Lexer code for PHP tags |
|
| 111 | + * |
|
| 112 | + * This code has been moved from lexer here fo easier debugging and maintenance |
|
| 113 | + * |
|
| 114 | + * @param $lex |
|
| 115 | + */ |
|
| 116 | + public function parsePhp($lex) |
|
| 117 | + { |
|
| 118 | + $lex->token = Smarty_Internal_Templateparser::TP_PHP; |
|
| 119 | + $close = 0; |
|
| 120 | + $lex->taglineno = $lex->line; |
|
| 121 | + $closeTag = '?>'; |
|
| 122 | + if (strpos($lex->value, '<?xml') === 0) { |
|
| 123 | + $lex->is_xml = true; |
|
| 124 | + $lex->token = Smarty_Internal_Templateparser::TP_NOCACHE; |
|
| 125 | + return; |
|
| 126 | + } elseif (strpos($lex->value, '<?') === 0) { |
|
| 127 | + $lex->phpType = 'php'; |
|
| 128 | + } elseif (strpos($lex->value, '<%') === 0) { |
|
| 129 | + $lex->phpType = 'asp'; |
|
| 130 | + $closeTag = '%>'; |
|
| 131 | + } elseif (strpos($lex->value, '%>') === 0) { |
|
| 132 | + $lex->phpType = 'unmatched'; |
|
| 133 | + } elseif (strpos($lex->value, '?>') === 0) { |
|
| 134 | + if ($lex->is_xml) { |
|
| 135 | + $lex->is_xml = false; |
|
| 136 | + $lex->token = Smarty_Internal_Templateparser::TP_NOCACHE; |
|
| 137 | + return; |
|
| 138 | + } |
|
| 139 | + $lex->phpType = 'unmatched'; |
|
| 140 | + } elseif (strpos($lex->value, '<s') === 0) { |
|
| 141 | + $lex->phpType = 'script'; |
|
| 142 | + $closeTag = '</script>'; |
|
| 143 | + } elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) { |
|
| 144 | + if ($lex->isAutoLiteral()) { |
|
| 145 | + $lex->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
| 146 | + return; |
|
| 147 | + } |
|
| 148 | + $closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}"; |
|
| 149 | + if ($lex->value == $closeTag) { |
|
| 150 | + $lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'"); |
|
| 151 | + } |
|
| 152 | + $lex->phpType = 'tag'; |
|
| 153 | + } |
|
| 154 | + if ($lex->phpType == 'unmatched') { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 157 | + if (($lex->phpType == 'php' || $lex->phpType == 'asp') && |
|
| 158 | + ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE) |
|
| 159 | + ) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 162 | + $start = $lex->counter + strlen($lex->value); |
|
| 163 | + $body = true; |
|
| 164 | + if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
|
| 165 | + $close = $match[ 0 ][ 1 ]; |
|
| 166 | + } else { |
|
| 167 | + $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
|
| 168 | + } |
|
| 169 | + while ($body) { |
|
| 170 | + if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', |
|
| 171 | + $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
|
| 172 | + $value = $match[ 0 ][ 0 ]; |
|
| 173 | + $from = $pos = $match[ 0 ][ 1 ]; |
|
| 174 | + if ($pos > $close) { |
|
| 175 | + $body = false; |
|
| 176 | + } else { |
|
| 177 | + $start = $pos + strlen($value); |
|
| 178 | + $phpCommentStart = $value == '/*'; |
|
| 179 | + if ($phpCommentStart) { |
|
| 180 | + $phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start); |
|
| 181 | + if ($phpCommentEnd) { |
|
| 182 | + $pos2 = $match[ 0 ][ 1 ]; |
|
| 183 | + $start = $pos2 + strlen($match[ 0 ][ 0 ]); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + while ($close > $pos && $close < $start) { |
|
| 187 | + if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, |
|
| 188 | + $from)) { |
|
| 189 | + $close = $match[ 0 ][ 1 ]; |
|
| 190 | + $from = $close + strlen($match[ 0 ][ 0 ]); |
|
| 191 | + } else { |
|
| 192 | + $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) { |
|
| 196 | + $lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n"); |
|
| 197 | + $lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'"); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } else { |
|
| 201 | + $body = false; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + $lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - /* |
|
| 207 | + /* |
|
| 208 | 208 | * Call back function for $php_handling = PHP_QUOTE |
| 209 | 209 | * |
| 210 | 210 | */ |
| 211 | - /** |
|
| 212 | - * @param $match |
|
| 213 | - * |
|
| 214 | - * @return string |
|
| 215 | - */ |
|
| 216 | - private function quote($match) |
|
| 217 | - { |
|
| 218 | - return htmlspecialchars($match[ 0 ], ENT_QUOTES); |
|
| 219 | - } |
|
| 211 | + /** |
|
| 212 | + * @param $match |
|
| 213 | + * |
|
| 214 | + * @return string |
|
| 215 | + */ |
|
| 216 | + private function quote($match) |
|
| 217 | + { |
|
| 218 | + return htmlspecialchars($match[ 0 ], ENT_QUOTES); |
|
| 219 | + } |
|
| 220 | 220 | } |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | // check and get attributes |
| 41 | 41 | $_attr = $this->getAttributes($compiler, $args); |
| 42 | 42 | $compiler->has_code = false; |
| 43 | - if ($_attr[ 'type' ] == 'xml') { |
|
| 43 | + if ($_attr['type'] == 'xml') { |
|
| 44 | 44 | $compiler->tag_nocache = true; |
| 45 | 45 | $save = $compiler->template->compiled->has_nocache_code; |
| 46 | - $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 46 | + $output = addcslashes($_attr['code'], "'\\"); |
|
| 47 | 47 | $compiler->parser->current_buffer->append_subtree($compiler->parser, |
| 48 | 48 | new Smarty_Internal_ParseTree_Tag($compiler->parser, |
| 49 | 49 | $compiler->processNocacheCode("<?php echo '" . |
@@ -53,20 +53,20 @@ discard block |
||
| 53 | 53 | $compiler->template->compiled->has_nocache_code = $save; |
| 54 | 54 | return ''; |
| 55 | 55 | } |
| 56 | - if ($_attr[ 'type' ] != 'tag') { |
|
| 56 | + if ($_attr['type'] != 'tag') { |
|
| 57 | 57 | if ($compiler->php_handling == Smarty::PHP_REMOVE) { |
| 58 | 58 | return ''; |
| 59 | 59 | } elseif ($compiler->php_handling == Smarty::PHP_QUOTE) { |
| 60 | 60 | $output = |
| 61 | 61 | preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', |
| 62 | - array($this, 'quote'), $_attr[ 'code' ]); |
|
| 62 | + array($this, 'quote'), $_attr['code']); |
|
| 63 | 63 | $compiler->parser->current_buffer->append_subtree($compiler->parser, |
| 64 | 64 | new Smarty_Internal_ParseTree_Text($output)); |
| 65 | 65 | return ''; |
| 66 | - } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') { |
|
| 66 | + } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') { |
|
| 67 | 67 | $compiler->tag_nocache = true; |
| 68 | 68 | $save = $compiler->template->compiled->has_nocache_code; |
| 69 | - $output = addcslashes($_attr[ 'code' ], "'\\"); |
|
| 69 | + $output = addcslashes($_attr['code'], "'\\"); |
|
| 70 | 70 | $compiler->parser->current_buffer->append_subtree($compiler->parser, |
| 71 | 71 | new Smarty_Internal_ParseTree_Tag($compiler->parser, |
| 72 | 72 | $compiler->processNocacheCode("<?php echo '" . |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | null, true); |
| 82 | 82 | } |
| 83 | 83 | $compiler->has_code = true; |
| 84 | - return $_attr[ 'code' ]; |
|
| 84 | + return $_attr['code']; |
|
| 85 | 85 | } else { |
| 86 | 86 | $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true); |
| 87 | 87 | } |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | $ldel = preg_quote($compiler->smarty->left_delimiter, '#'); |
| 95 | 95 | $rdel = preg_quote($compiler->smarty->right_delimiter, '#'); |
| 96 | - preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match); |
|
| 97 | - if (!empty($match[ 2 ])) { |
|
| 98 | - if ('nocache' == trim($match[ 2 ])) { |
|
| 96 | + preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match); |
|
| 97 | + if (!empty($match[2])) { |
|
| 98 | + if ('nocache' == trim($match[2])) { |
|
| 99 | 99 | $compiler->tag_nocache = true; |
| 100 | 100 | } else { |
| 101 | 101 | $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true); |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), |
| 105 | - array('<?php ', '?>'), $_attr[ 'code' ]); |
|
| 105 | + array('<?php ', '?>'), $_attr['code']); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | $start = $lex->counter + strlen($lex->value); |
| 163 | 163 | $body = true; |
| 164 | 164 | if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
| 165 | - $close = $match[ 0 ][ 1 ]; |
|
| 165 | + $close = $match[0][1]; |
|
| 166 | 166 | } else { |
| 167 | 167 | $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
| 168 | 168 | } |
| 169 | 169 | while ($body) { |
| 170 | 170 | if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', |
| 171 | 171 | $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) { |
| 172 | - $value = $match[ 0 ][ 0 ]; |
|
| 173 | - $from = $pos = $match[ 0 ][ 1 ]; |
|
| 172 | + $value = $match[0][0]; |
|
| 173 | + $from = $pos = $match[0][1]; |
|
| 174 | 174 | if ($pos > $close) { |
| 175 | 175 | $body = false; |
| 176 | 176 | } else { |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | if ($phpCommentStart) { |
| 180 | 180 | $phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start); |
| 181 | 181 | if ($phpCommentEnd) { |
| 182 | - $pos2 = $match[ 0 ][ 1 ]; |
|
| 183 | - $start = $pos2 + strlen($match[ 0 ][ 0 ]); |
|
| 182 | + $pos2 = $match[0][1]; |
|
| 183 | + $start = $pos2 + strlen($match[0][0]); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | while ($close > $pos && $close < $start) { |
| 187 | 187 | if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, |
| 188 | 188 | $from)) { |
| 189 | - $close = $match[ 0 ][ 1 ]; |
|
| 190 | - $from = $close + strlen($match[ 0 ][ 0 ]); |
|
| 189 | + $close = $match[0][1]; |
|
| 190 | + $from = $close + strlen($match[0][0]); |
|
| 191 | 191 | } else { |
| 192 | 192 | $lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'"); |
| 193 | 193 | } |
@@ -215,6 +215,6 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | private function quote($match) |
| 217 | 217 | { |
| 218 | - return htmlspecialchars($match[ 0 ], ENT_QUOTES); |
|
| 218 | + return htmlspecialchars($match[0], ENT_QUOTES); |
|
| 219 | 219 | } |
| 220 | 220 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
| 24 | 24 | * @param array $parameter array with compilation parameter |
| 25 | 25 | * |
| 26 | - * @return string compiled code |
|
| 26 | + * @return boolean compiled code |
|
| 27 | 27 | */ |
| 28 | 28 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 29 | 29 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param array $args array with attributes from parser |
| 52 | 52 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
| 53 | 53 | * |
| 54 | - * @return string compiled code |
|
| 54 | + * @return boolean compiled code |
|
| 55 | 55 | */ |
| 56 | 56 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
| 57 | 57 | { |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Compiles code for setfilter tag |
|
| 21 | - * |
|
| 22 | - * @param array $args array with attributes from parser |
|
| 23 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | - * @param array $parameter array with compilation parameter |
|
| 25 | - * |
|
| 26 | - * @return string compiled code |
|
| 27 | - */ |
|
| 28 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 29 | - { |
|
| 30 | - $compiler->variable_filter_stack[] = $compiler->variable_filters; |
|
| 31 | - $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 32 | - // this tag does not return compiled code |
|
| 33 | - $compiler->has_code = false; |
|
| 19 | + /** |
|
| 20 | + * Compiles code for setfilter tag |
|
| 21 | + * |
|
| 22 | + * @param array $args array with attributes from parser |
|
| 23 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 24 | + * @param array $parameter array with compilation parameter |
|
| 25 | + * |
|
| 26 | + * @return string compiled code |
|
| 27 | + */ |
|
| 28 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 29 | + { |
|
| 30 | + $compiler->variable_filter_stack[] = $compiler->variable_filters; |
|
| 31 | + $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 32 | + // this tag does not return compiled code |
|
| 33 | + $compiler->has_code = false; |
|
| 34 | 34 | |
| 35 | - return true; |
|
| 36 | - } |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,27 +44,27 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * Compiles code for the {/setfilter} tag |
|
| 49 | - * This tag does not generate compiled output. It resets variable filter. |
|
| 50 | - * |
|
| 51 | - * @param array $args array with attributes from parser |
|
| 52 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 53 | - * |
|
| 54 | - * @return string compiled code |
|
| 55 | - */ |
|
| 56 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 57 | - { |
|
| 58 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 59 | - // reset variable filter to previous state |
|
| 60 | - if (count($compiler->variable_filter_stack)) { |
|
| 61 | - $compiler->variable_filters = array_pop($compiler->variable_filter_stack); |
|
| 62 | - } else { |
|
| 63 | - $compiler->variable_filters = array(); |
|
| 64 | - } |
|
| 65 | - // this tag does not return compiled code |
|
| 66 | - $compiler->has_code = false; |
|
| 47 | + /** |
|
| 48 | + * Compiles code for the {/setfilter} tag |
|
| 49 | + * This tag does not generate compiled output. It resets variable filter. |
|
| 50 | + * |
|
| 51 | + * @param array $args array with attributes from parser |
|
| 52 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 53 | + * |
|
| 54 | + * @return string compiled code |
|
| 55 | + */ |
|
| 56 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 57 | + { |
|
| 58 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 59 | + // reset variable filter to previous state |
|
| 60 | + if (count($compiler->variable_filter_stack)) { |
|
| 61 | + $compiler->variable_filters = array_pop($compiler->variable_filter_stack); |
|
| 62 | + } else { |
|
| 63 | + $compiler->variable_filters = array(); |
|
| 64 | + } |
|
| 65 | + // this tag does not return compiled code |
|
| 66 | + $compiler->has_code = false; |
|
| 67 | 67 | |
| 68 | - return true; |
|
| 69 | - } |
|
| 68 | + return true; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
| 29 | 29 | { |
| 30 | 30 | $compiler->variable_filter_stack[] = $compiler->variable_filters; |
| 31 | - $compiler->variable_filters = $parameter[ 'modifier_list' ]; |
|
| 31 | + $compiler->variable_filters = $parameter['modifier_list']; |
|
| 32 | 32 | // this tag does not return compiled code |
| 33 | 33 | $compiler->has_code = false; |
| 34 | 34 | |