compile.include.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Template Lite
  4. *
  5. * Type: compile
  6. * Name: section_start
  7. */
  8. function compile_include($arguments, &$object)
  9. {
  10. $_args = $object->_parse_arguments($arguments);
  11. $arg_list = array();
  12. if (empty($_args['file']))
  13. {
  14. $object->trigger_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
  15. }
  16. foreach ($_args as $arg_name => $arg_value)
  17. {
  18. if ($arg_name == 'file')
  19. {
  20. $include_file = $arg_value;
  21. continue;
  22. }
  23. else if ($arg_name == 'assign')
  24. {
  25. $assign_var = $arg_value;
  26. continue;
  27. }
  28. if (is_bool($arg_value))
  29. {
  30. $arg_value = $arg_value ? 'true' : 'false';
  31. }
  32. $arg_list[] = "'$arg_name' => $arg_value";
  33. }
  34. if (isset($assign_var))
  35. {
  36. $output = '<?php $_templatelite_tpl_vars = $this->_vars;' .
  37. "\n\$this->assign(" . $assign_var . ", \$this->_fetch_compile_include(" . $include_file . ", array(".implode(',', (array)$arg_list).")));\n" .
  38. "\$this->_vars = \$_templatelite_tpl_vars;\n" .
  39. "unset(\$_templatelite_tpl_vars);\n" .
  40. ' ?>';
  41. }
  42. else
  43. {
  44. $output = '<?php $_templatelite_tpl_vars = $this->_vars;' .
  45. "\necho \$this->_fetch_compile_include(" . $include_file . ", array(".implode(',', (array)$arg_list)."));\n" .
  46. "\$this->_vars = \$_templatelite_tpl_vars;\n" .
  47. "unset(\$_templatelite_tpl_vars);\n" .
  48. ' ?>';
  49. }
  50. return $output;
  51. }
  52. ?>