| 22 | | var $tpl_name; |
|---|
| 23 | | var $tpl_data; |
|---|
| 24 | | var $tpl_options; |
|---|
| 25 | | |
|---|
| 26 | | var $dtpl_name; |
|---|
| 27 | | var $dtpl_data; |
|---|
| 28 | | var $dtpl_options; |
|---|
| 29 | | var $dtpl_values; |
|---|
| 30 | | |
|---|
| 31 | | var $namespace; |
|---|
| 32 | | |
|---|
| 33 | | var $root_dir; |
|---|
| 34 | | |
|---|
| 35 | | var $tpl_start_tag; |
|---|
| 36 | | var $tpl_end_tag; |
|---|
| 37 | | var $tpl_start_tag_name; |
|---|
| 38 | | var $tpl_end_tag_name; |
|---|
| 39 | | var $tpl_name_rexpr; |
|---|
| 40 | | |
|---|
| 41 | | var $tpl_start_rexpr; |
|---|
| 42 | | var $tpl_end_rexpr; |
|---|
| 43 | | |
|---|
| 44 | | var $last_parsed; |
|---|
| 45 | | |
|---|
| 46 | | var $stack; |
|---|
| 47 | | var $sp; |
|---|
| 48 | | |
|---|
| 49 | | function pTemplate($r_dir = '') { |
|---|
| 50 | | $this->tpl_name = array(); |
|---|
| 51 | | $this->tpl_data = array(); |
|---|
| 52 | | $this->tpl_options = array(); |
|---|
| 53 | | |
|---|
| 54 | | $this->dtpl_name = array(); |
|---|
| 55 | | $this->dtpl_data = array(); |
|---|
| 56 | | $this->dtpl_options = array(); |
|---|
| 57 | | $this->dtpl_values = array(); |
|---|
| 58 | | |
|---|
| 59 | | $this->namespace = array(); |
|---|
| 60 | | |
|---|
| 61 | | if ($r_dir) { |
|---|
| 62 | | $this->set_root($r_dir); |
|---|
| 63 | | } else { |
|---|
| 64 | | $this->set_root(); |
|---|
| 65 | | } |
|---|
| 66 | | |
|---|
| 67 | | $this->tpl_start_tag = '<!-- '; |
|---|
| 68 | | $this->tpl_end_tag = ' -->'; |
|---|
| 69 | | $this->tpl_start_tag_name = 'BDP: '; |
|---|
| 70 | | $this->tpl_end_tag_name = 'EDP: '; |
|---|
| 71 | | $this->tpl_name_rexpr = '([a-z0-9][a-z0-9\_]*)'; |
|---|
| 72 | | |
|---|
| 73 | | $this->tpl_start_rexpr = '/'; |
|---|
| 74 | | $this->tpl_start_rexpr .= $this->tpl_start_tag; |
|---|
| 75 | | $this->tpl_start_rexpr .= $this->tpl_start_tag_name; |
|---|
| 76 | | $this->tpl_start_rexpr .= $this->tpl_name_rexpr; |
|---|
| 77 | | $this->tpl_start_rexpr .= $this->tpl_end_tag . '/' ; |
|---|
| 78 | | |
|---|
| 79 | | $this->tpl_end_rexpr = '/'; |
|---|
| 80 | | $this->tpl_end_rexpr .= $this->tpl_start_tag; |
|---|
| 81 | | $this->tpl_end_rexpr .= $this->tpl_end_tag_name; |
|---|
| 82 | | $this->tpl_end_rexpr .= $this->tpl_name_rexpr; |
|---|
| 83 | | $this->tpl_end_rexpr .= $this->tpl_end_tag . '/'; |
|---|
| 84 | | |
|---|
| 85 | | $this->last_parsed = ''; |
|---|
| 86 | | |
|---|
| 87 | | $this->stack = array(); |
|---|
| 88 | | $this->sp = 0; |
|---|
| 89 | | } |
|---|
| 90 | | |
|---|
| 91 | | function set_root($set_dir = '.') { |
|---|
| 92 | | $this->root_dir = $set_dir; |
|---|
| 93 | | } |
|---|
| 94 | | |
|---|
| 95 | | function assign($nsp_name, $nsp_data = '') { |
|---|
| 96 | | if (gettype($nsp_name) == "array") { |
|---|
| 97 | | foreach ($nsp_name as $key => $value) { |
|---|
| 98 | | $this->namespace[$key] = $value; |
|---|
| 99 | | } |
|---|
| 100 | | } else { |
|---|
| 101 | | $this->namespace[$nsp_name] = $nsp_data; |
|---|
| 102 | | } |
|---|
| 103 | | } |
|---|
| 104 | | |
|---|
| 105 | | function unsign($nsp_name) { |
|---|
| 106 | | if (gettype($nsp_name) == "array") { |
|---|
| 107 | | foreach ($nsp_name as $key => $value) { |
|---|
| 108 | | unset($this->namespace[$key]); |
|---|
| 109 | | } |
|---|
| 110 | | } else { |
|---|
| 111 | | unset($this->namespace[$nsp_name]); |
|---|
| 112 | | } |
|---|
| 113 | | } |
|---|
| 114 | | |
|---|
| 115 | | function define($t_name, $t_value = '') { |
|---|
| 116 | | if (gettype($t_name) == "array") { |
|---|
| 117 | | foreach ($t_name as $key => $value) { |
|---|
| 118 | | $this->tpl_name[$key] = $value; |
|---|
| 119 | | $this->tpl_data[$key] = ''; |
|---|
| 120 | | $this->tpl_options[$key] = ''; |
|---|
| 121 | | } |
|---|
| 122 | | } else { |
|---|
| 123 | | $this->tpl_name[$t_name] = $t_value; |
|---|
| 124 | | $this->tpl_data[$t_name] = ''; |
|---|
| 125 | | $this->tpl_options[$t_name] = ''; |
|---|
| 126 | | } |
|---|
| 127 | | } |
|---|
| 128 | | |
|---|
| 129 | | function define_dynamic($t_name, $t_value = '') { |
|---|
| 130 | | if (gettype($t_name) == "array") { |
|---|
| 131 | | foreach ($t_name as $key => $value) { |
|---|
| 132 | | $this->dtpl_name[$key] = $value; |
|---|
| 133 | | $this->dtpl_data[$key] = ''; |
|---|
| 134 | | $this->dtpl_options[$key] = ''; |
|---|
| 135 | | } |
|---|
| 136 | | } else { |
|---|
| 137 | | $this->dtpl_name[$t_name] = $t_value; |
|---|
| 138 | | $this->dtpl_data[$t_name] = ''; |
|---|
| 139 | | $this->dtpl_options[$t_name] = ''; |
|---|
| 140 | | } |
|---|
| 141 | | } |
|---|
| 142 | | |
|---|
| 143 | | function define_no_file($t_name, $t_value = '') { |
|---|
| 144 | | if (gettype($t_name) == "array") { |
|---|
| 145 | | foreach ($t_name as $key => $value) { |
|---|
| 146 | | $this->tpl_name[$key] = '_no_file_'; |
|---|
| 147 | | $this->tpl_data[$key] = $value; |
|---|
| 148 | | $this->tpl_options[$key] = ''; |
|---|
| 149 | | } |
|---|
| 150 | | } else { |
|---|
| 151 | | $this->tpl_name[$t_name] = '_no_file_'; |
|---|
| 152 | | $this->tpl_data[$t_name] = $t_value; |
|---|
| 153 | | $this->tpl_options[$t_name] = ''; |
|---|
| 154 | | } |
|---|
| 155 | | } |
|---|
| 156 | | |
|---|
| 157 | | function define_no_file_dynamic($t_name, $t_value = '') { |
|---|
| 158 | | if (gettype($t_name) == "array") { |
|---|
| 159 | | foreach ($t_name as $key => $value) { |
|---|
| 160 | | $this->dtpl_name[$key] = '_no_file_'; |
|---|
| 161 | | |
|---|
| 162 | | $this->dtpl_data[$key] = $value; |
|---|
| 163 | | |
|---|
| 164 | | $this->dtpl_data[strtoupper($key)] = $value; |
|---|
| 165 | | |
|---|
| 166 | | $this->dtpl_options[$key] = ''; |
|---|
| 167 | | } |
|---|
| 168 | | } else { |
|---|
| 169 | | $this->dtpl_name[$t_name] = '_no_file_'; |
|---|
| 170 | | |
|---|
| 171 | | $this->dtpl_data[$t_name] = $t_value; |
|---|
| 172 | | |
|---|
| 173 | | $this->dtpl_data[strtoupper($t_name)] = @$t_value; |
|---|
| 174 | | |
|---|
| 175 | | $this->dtpl_options[$t_name] = ''; |
|---|
| 176 | | } |
|---|
| 177 | | } |
|---|
| 178 | | |
|---|
| 179 | | function find_next($data, $spos) { |
|---|
| 180 | | do { |
|---|
| 181 | | $tag_spos = strpos($data, $this->tpl_start_tag, $spos + 1); |
|---|
| 182 | | |
|---|
| 183 | | if (gettype($tag_spos) == 'boolean') { |
|---|
| 184 | | return false; |
|---|
| 185 | | } |
|---|
| 186 | | |
|---|
| 187 | | $tag_epos = strpos($data, $this->tpl_end_tag, $tag_spos + 1); |
|---|
| 188 | | |
|---|
| 189 | | if (gettype($tag_epos) == 'boolean') { |
|---|
| 190 | | return false; |
|---|
| 191 | | } |
|---|
| 192 | | |
|---|
| 193 | | $length = $tag_epos + strlen($this->tpl_end_tag) - $tag_spos; |
|---|
| 194 | | |
|---|
| 195 | | $tag = substr($data, $tag_spos, $length); |
|---|
| 196 | | |
|---|
| 197 | | if ($tag) { |
|---|
| 198 | | if (preg_match($this->tpl_start_rexpr, $tag, $matches)) { |
|---|
| 199 | | return array($matches[1], 'b', $tag_spos, $tag_epos + strlen($this->tpl_end_tag) - 1); |
|---|
| 200 | | } else if (preg_match($this->tpl_end_rexpr, $tag, $matches)) { |
|---|
| 201 | | return array($matches[1], 'e', $tag_spos, $tag_epos + strlen($this->tpl_end_tag) - 1); |
|---|
| 202 | | } else { |
|---|
| 203 | | $spos = $tag_epos; |
|---|
| 204 | | } |
|---|
| 205 | | } else { |
|---|
| 206 | | return false; |
|---|
| 207 | | } |
|---|
| 208 | | } while (true); |
|---|
| 209 | | } |
|---|
| 210 | | |
|---|
| 211 | | function find_next_curl($data, $spos) { |
|---|
| 212 | | $curl_b = strpos($data, '{', $spos + 1); |
|---|
| 213 | | |
|---|
| 214 | | $curl_e = strpos($data, '}', $spos + 1); |
|---|
| 215 | | |
|---|
| 216 | | if ($curl_b) { |
|---|
| 217 | | if ($curl_e) { |
|---|
| 218 | | if ($curl_b < $curl_e) { |
|---|
| 219 | | return array('{', $curl_b); |
|---|
| 220 | | } else { |
|---|
| 221 | | return array('}', $curl_e); |
|---|
| 222 | | } |
|---|
| 223 | | } else { |
|---|
| 224 | | return array('{', $curl_b); |
|---|
| 225 | | } |
|---|
| 226 | | } else { |
|---|
| 227 | | if ($curl_e) { |
|---|
| 228 | | return array('}', $curl_e); |
|---|
| 229 | | } else { |
|---|
| 230 | | return false; |
|---|
| 231 | | } |
|---|
| 232 | | } |
|---|
| 233 | | } |
|---|
| 234 | | |
|---|
| 235 | | function devide_dynamic($data) { |
|---|
| 236 | | $start_from = -1; |
|---|
| 237 | | |
|---|
| 238 | | $tag = $this->find_next($data, $start_from); |
|---|
| 239 | | |
|---|
| 240 | | while ($tag) { |
|---|
| 241 | | if ($tag[1] == 'b') { |
|---|
| 242 | | $this->stack[$this->sp++] = $tag; |
|---|
| 243 | | |
|---|
| 244 | | $start_from = $tag[3]; |
|---|
| 245 | | } else { |
|---|
| 246 | | $tpl_name = $tag[0]; |
|---|
| 247 | | |
|---|
| 248 | | $tpl_eb_pos = $tag[2]; |
|---|
| 249 | | $tpl_ee_pos = $tag[3]; |
|---|
| 250 | | |
|---|
| 251 | | $tag = $this->stack [--$this->sp]; |
|---|
| 252 | | |
|---|
| 253 | | $tpl_bb_pos = $tag[2]; |
|---|
| 254 | | $tpl_be_pos = $tag[3]; |
|---|
| 255 | | |
|---|
| 256 | | $this->dtpl_data[strtoupper($tpl_name)] = substr($data, $tpl_be_pos + 1, $tpl_eb_pos - $tpl_be_pos - 1); |
|---|
| 257 | | |
|---|
| 258 | | $this->dtpl_data[$tpl_name] = substr($data, $tpl_be_pos + 1, $tpl_eb_pos - $tpl_be_pos - 1); |
|---|
| 259 | | |
|---|
| 260 | | $data = substr_replace($data, "{" . strtoupper($tpl_name) . "}", $tpl_bb_pos, $tpl_ee_pos - $tpl_bb_pos + 1); |
|---|
| 261 | | |
|---|
| 262 | | $start_from = $tpl_bb_pos + strlen("{" . $tpl_name . "}") - 1; |
|---|
| 263 | | } |
|---|
| 264 | | |
|---|
| 265 | | $tag = $this->find_next($data, $start_from); |
|---|
| 266 | | } |
|---|
| 267 | | |
|---|
| 268 | | return $data; |
|---|
| 269 | | } |
|---|
| 270 | | |
|---|
| 271 | | function substitute_dynamic($data) { |
|---|
| 272 | | $this->sp = 0; |
|---|
| 273 | | |
|---|
| 274 | | $start_from = -1; |
|---|
| 275 | | |
|---|
| 276 | | $curl_b = substr($data, '{', $start_from); |
|---|
| 277 | | |
|---|
| 278 | | if ($curl_b) { |
|---|
| 279 | | $this->stack[$this->sp++] = array('{', $curl_b); |
|---|
| 280 | | |
|---|
| 281 | | $curl = $this->find_next_curl($data, $start_from); |
|---|
| 282 | | |
|---|
| 283 | | while ($curl) { |
|---|
| 284 | | if ($curl[0] == '{') { |
|---|
| 285 | | $this->stack[$this->sp++] = $curl; |
|---|
| 286 | | |
|---|
| 287 | | $start_from = $curl[1]; |
|---|
| 288 | | } else { |
|---|
| 289 | | $curl_e = $curl[1]; |
|---|
| 290 | | |
|---|
| 291 | | if ($this->sp > 0) { |
|---|
| 292 | | $curl = $this->stack [--$this->sp]; |
|---|
| 293 | | /* CHECK for empty stack must be done HERE ! */ |
|---|
| 294 | | |
|---|
| 295 | | $curl_b = $curl[1]; |
|---|
| 296 | | |
|---|
| 297 | | if ($curl_b < $curl_e + 1) { |
|---|
| 298 | | $var_name = substr($data, $curl_b + 1, $curl_e - $curl_b - 1); |
|---|
| 299 | | |
|---|
| 300 | | /* |
|---|
| 301 | | * |
|---|
| 302 | | * The whole WORK goes here :) ; |
|---|
| 303 | | * |
|---|
| 304 | | */ |
|---|
| 305 | | |
|---|
| 306 | | if (preg_match('/[A-Z0-9][A-Z0-9\_]*/', $var_name)) { |
|---|
| 307 | | if (isset($this->namespace[$var_name])) { |
|---|
| 308 | | $data = substr_replace($data, $this->namespace[$var_name], $curl_b, $curl_e - $curl_b + 1); |
|---|
| 309 | | |
|---|
| 310 | | $start_from = $curl_b - 1; |
|---|
| 311 | | /* new value may also begin with '{' */ |
|---|
| 312 | | |
|---|
| 313 | | } else if (isset($this->dtpl_data[$var_name])) { |
|---|
| 314 | | $data = substr_replace($data, $this->dtpl_data[$var_name], $curl_b, $curl_e - $curl_b + 1); |
|---|
| 315 | | |
|---|
| 316 | | $start_from = $curl_b - 1; |
|---|
| 317 | | /* new value may also begin with '{' */ |
|---|
| 318 | | |
|---|
| 319 | | } else { |
|---|
| 320 | | $start_from = $curl_b; |
|---|
| 321 | | /* no soutable value found -> go forward */ |
|---|
| 322 | | |
|---|
| 323 | | } |
|---|
| 324 | | } else { |
|---|
| 325 | | $start_from = $curl_b; |
|---|
| 326 | | /* go forward, we have {not varialbe} here :) */ |
|---|
| 327 | | |
|---|
| 328 | | } |
|---|
| 329 | | } else { |
|---|
| 330 | | $start_from = $curl_e; |
|---|
| 331 | | /* go forward, we have {} here :) */ |
|---|
| 332 | | |
|---|
| 333 | | } |
|---|
| 334 | | } else { |
|---|
| 335 | | $start_from = $curl_e; |
|---|
| 336 | | } |
|---|
| 337 | | } |
|---|
| 338 | | |
|---|
| 339 | | $curl = $this->find_next_curl($data, $start_from); |
|---|
| 340 | | } |
|---|
| 341 | | |
|---|
| 342 | | return $data; |
|---|
| 343 | | } else { |
|---|
| 344 | | return $data; |
|---|
| 345 | | /* tghere is nothing to substitute in $data */ |
|---|
| 346 | | |
|---|
| 347 | | } |
|---|
| 348 | | } |
|---|
| 349 | | |
|---|
| 350 | | function is_safe($fname) { |
|---|
| 351 | | if (file_exists(($this->root_dir) . '/' . $fname)) { |
|---|
| 352 | | return true; |
|---|
| 353 | | } |
|---|
| 354 | | |
|---|
| 355 | | return false; |
|---|
| 356 | | } |
|---|
| 357 | | |
|---|
| 358 | | function get_file($fname) { |
|---|
| 359 | | if ($this->is_safe($fname)) { |
|---|
| 360 | | if (!($fp = fopen(($this->root_dir) . '/' . $fname, 'r'))) { |
|---|
| 361 | | return ''; |
|---|
| 362 | | } |
|---|
| 363 | | |
|---|
| 364 | | $res = fread($fp, filesize(($this->root_dir) . '/' . $fname)); |
|---|
| 365 | | |
|---|
| 366 | | if (!$res) { |
|---|
| 367 | | return ''; |
|---|
| 368 | | } |
|---|
| 369 | | |
|---|
| 370 | | fclose($fp); |
|---|
| 371 | | |
|---|
| 372 | | return $res; |
|---|
| 373 | | } |
|---|
| 374 | | |
|---|
| 375 | | return ''; |
|---|
| 376 | | } |
|---|
| 377 | | |
|---|
| 378 | | function find_origin($tname) { |
|---|
| 379 | | if (!@$this->dtpl_name[$tname]) { |
|---|
| 380 | | return false; |
|---|
| 381 | | } while (!preg_match('/\.[Tt][Pp][Ll]/', $this->dtpl_name[$tname]) && !preg_match('/_no_file_/', $this->dtpl_name[$tname]) |
|---|
| 382 | | ) { |
|---|
| 383 | | $tname = $this->dtpl_name[$tname]; |
|---|
| 384 | | } |
|---|
| 385 | | |
|---|
| 386 | | return $tname; |
|---|
| 387 | | } |
|---|
| 388 | | |
|---|
| 389 | | function parse_dynamic($pname, $tname, $ADD_FLAG) { |
|---|
| 390 | | $CHILD = false; |
|---|
| 391 | | $parent = ''; |
|---|
| 392 | | $swap = ''; |
|---|
| 393 | | |
|---|
| 394 | | if (!preg_match('/\.[Tt][Pp][Ll]/', @$this->dtpl_name[$tname]) && !preg_match('/_no_file_/', @$this->dtpl_name[$tname]) |
|---|
| 395 | | ) { |
|---|
| 396 | | $CHILD = true; |
|---|
| 397 | | |
|---|
| 398 | | $parent = $this->find_origin($tname); |
|---|
| 399 | | |
|---|
| 400 | | if (!$parent) { |
|---|
| 401 | | return false; |
|---|
| 402 | | } |
|---|
| 403 | | } |
|---|
| 404 | | |
|---|
| 405 | | if ($CHILD) { |
|---|
| 406 | | $swap = $parent; |
|---|
| 407 | | $parent = $tname; |
|---|
| 408 | | $tname = $swap; |
|---|
| 409 | | } |
|---|
| 410 | | |
|---|
| 411 | | if (!@$this->dtpl_data[$tname]) { |
|---|
| 412 | | @$this->dtpl_data[$tname] = $this->get_file(@$this->dtpl_name[$tname]); |
|---|
| 413 | | } |
|---|
| 414 | | |
|---|
| 415 | | if (!preg_match('/d\_/', @$this->dtpl_options[$tname])) { |
|---|
| 416 | | @$this->dtpl_options[$tname] .= 'd_'; |
|---|
| 417 | | |
|---|
| 418 | | $tpl_origin = @$this->dtpl_data[$tname]; |
|---|
| 419 | | |
|---|
| 420 | | @$this->dtpl_data[$tname] = $this->devide_dynamic($tpl_origin); |
|---|
| 421 | | } |
|---|
| 422 | | |
|---|
| 423 | | if ($CHILD) { |
|---|
| 424 | | $swap = $parent; |
|---|
| 425 | | $parent = $tname; |
|---|
| 426 | | $tname = $swap; |
|---|
| 427 | | } |
|---|
| 428 | | |
|---|
| 429 | | if ($ADD_FLAG) { |
|---|
| 430 | | $safe = @$this->namespace[$pname]; |
|---|
| 431 | | |
|---|
| 432 | | $this->namespace[$pname] = $safe . ($this->substitute_dynamic($this->dtpl_data[$tname], $ADD_FLAG)); |
|---|
| 433 | | } else { |
|---|
| 434 | | $this->namespace[$pname] = $this->substitute_dynamic($this->dtpl_data[$tname], $ADD_FLAG); |
|---|
| 435 | | } |
|---|
| 436 | | |
|---|
| 437 | | return true; |
|---|
| 438 | | } |
|---|
| 439 | | |
|---|
| 440 | | function parse($pname, $tname) { |
|---|
| 441 | | if (!preg_match('/[A-Z0-9][A-Z0-9\_]*/', $pname)) { |
|---|
| 442 | | return false; |
|---|
| 443 | | } |
|---|
| 444 | | |
|---|
| 445 | | if (!preg_match('/[A-Za-z0-9][A-Za-z0-9\_]*/', $tname)) { |
|---|
| 446 | | return false; |
|---|
| 447 | | } |
|---|
| 448 | | |
|---|
| 449 | | $ADD_FLAG = false; |
|---|
| 450 | | |
|---|
| 451 | | if (preg_match('/^\./', $tname)) { |
|---|
| 452 | | $tname = substr($tname, 1); |
|---|
| 453 | | |
|---|
| 454 | | $ADD_FLAG = true; |
|---|
| 455 | | } |
|---|
| 456 | | |
|---|
| 457 | | if (@$this->tpl_name[$tname] == '_no_file_' || preg_match('/\.[Tt][Pp][Ll]/', @$this->tpl_name[$tname])) { |
|---|
| 458 | | /* static NO FILE *//* static FILE */ |
|---|
| 459 | | |
|---|
| 460 | | if (@$this->tpl_data[$tname] == '') { |
|---|
| 461 | | $this->tpl_data[$tname] = $this->get_file($this->tpl_name[$tname]); |
|---|
| 462 | | } |
|---|
| 463 | | |
|---|
| 464 | | if ($ADD_FLAG) { |
|---|
| 465 | | @$this->namespace[$pname] .= $this->substitute_dynamic($this->tpl_data[$tname]); |
|---|
| 466 | | } else { |
|---|
| 467 | | $this->namespace[$pname] = $this->substitute_dynamic($this->tpl_data[$tname]); |
|---|
| 468 | | } |
|---|
| 469 | | |
|---|
| 470 | | $this->last_parsed = $this->namespace[$pname]; |
|---|
| 471 | | } else if (@$this->dtpl_name[$tname] == '_no_file_' || preg_match('/\.[Tt][Pp][Ll]/', @$this->dtpl_name[$tname]) || $this->find_origin($tname)) { |
|---|
| 472 | | /* dynamic NO FILE *//* dynamic FILE */ |
|---|
| 473 | | |
|---|
| 474 | | $dres = $this->parse_dynamic($pname, $tname, $ADD_FLAG); |
|---|
| 475 | | |
|---|
| 476 | | if (!$dres) { |
|---|
| 477 | | return $dres; |
|---|
| 478 | | } |
|---|
| 479 | | |
|---|
| 480 | | $this->last_parsed = $this->namespace[$pname]; |
|---|
| 481 | | } else { |
|---|
| 482 | | if ($ADD_FLAG) { |
|---|
| 483 | | @$this->namespace[$pname] .= $this->namespace[$tname]; |
|---|
| 484 | | } else { |
|---|
| 485 | | $this->namespace[$pname] = $this->namespace[$tname]; |
|---|
| 486 | | } |
|---|
| 487 | | } |
|---|
| 488 | | } |
|---|
| 489 | | |
|---|
| 490 | | function prnt($pname = '') { |
|---|
| 491 | | if ($pname) { |
|---|
| 492 | | print @$this->namespace[$pname]; |
|---|
| 493 | | } else { |
|---|
| 494 | | print @$this->last_parsed; |
|---|
| 495 | | } |
|---|
| 496 | | } |
|---|
| 497 | | |
|---|
| 498 | | function FastPrint($pname = '') { |
|---|
| 499 | | if ($pname) { |
|---|
| 500 | | $this->prnt($pname); |
|---|
| 501 | | } else { |
|---|
| 502 | | $this->prnt(); |
|---|
| 503 | | } |
|---|
| 504 | | } |
|---|
| 505 | | |
|---|
| 506 | | /* functions added for backward compatibility and debugging */ |
|---|
| 507 | | |
|---|
| 508 | | function strict() { |
|---|
| 509 | | } |
|---|
| 510 | | |
|---|
| 511 | | function no_strict() { |
|---|
| 512 | | } |
|---|
| 513 | | |
|---|
| 514 | | function show_unknown() { |
|---|
| 515 | | } |
|---|
| 516 | | |
|---|
| 517 | | function print_namespace() { |
|---|
| 518 | | print "<br><u>'namespace' contents</u><br>"; |
|---|
| 519 | | |
|---|
| 520 | | foreach($this->namespace as $key => $value) { |
|---|
| 521 | | print "$key => $value<br>"; |
|---|
| 522 | | } |
|---|
| 523 | | } |
|---|
| 524 | | |
|---|
| 525 | | function print_tpl_name() { |
|---|
| 526 | | print "<br><u>'tpl_name' contents</u><br>"; |
|---|
| 527 | | |
|---|
| 528 | | foreach($this->tpl_name as $key => $value) { |
|---|
| 529 | | print "$key => $value<br>"; |
|---|
| 530 | | } |
|---|
| 531 | | } |
|---|
| 532 | | |
|---|
| 533 | | function print_dtpl_name() { |
|---|
| 534 | | print "<br><u>'dtpl_name' contents</u><br>"; |
|---|
| 535 | | |
|---|
| 536 | | foreach($this->dtpl_name as $key => $value) { |
|---|
| 537 | | print "$key => $value<br>"; |
|---|
| 538 | | } |
|---|
| 539 | | } |
|---|
| 540 | | |
|---|
| 541< |
|---|