compile.compile_custom_block.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Template Lite compile custom block - template internal module
  4. *
  5. * Type: template
  6. * Name: compile_custom_block
  7. */
  8. function compile_compile_custom_block($function, $modifiers, $arguments, &$_result, &$object)
  9. {
  10. if ($function{0} == '/')
  11. {
  12. $start_tag = false;
  13. $function = substr($function, 1);
  14. }
  15. else
  16. {
  17. $start_tag = true;
  18. }
  19. if ($function = $object->_plugin_exists($function, "block"))
  20. {
  21. if ($start_tag)
  22. {
  23. $_args = $object->_parse_arguments($arguments);
  24. foreach($_args as $key => $value)
  25. {
  26. if (is_bool($value))
  27. {
  28. $value = $value ? 'true' : 'false';
  29. }
  30. if (is_null($value))
  31. {
  32. $value = 'null';
  33. }
  34. $_args[$key] = "'$key' => $value";
  35. }
  36. $_result = "<?php \$this->_tag_stack[] = array('$function', array(".implode(',', (array)$_args).")); ";
  37. $_result .= $function . '(array(' . implode(',', (array)$_args) .'), null, $this); ';
  38. $_result .= 'ob_start(); ?>';
  39. }
  40. else
  41. {
  42. $_result .= '<?php $this->_block_content = ob_get_contents(); ob_end_clean(); ';
  43. $_result .= '$this->_block_content = ' . $function . '($this->_tag_stack[count($this->_tag_stack) - 1][1], $this->_block_content, $this); ';
  44. if (!empty($modifiers))
  45. {
  46. $_result .= '$this->_block_content = ' . $object->_parse_modifier('$this->_block_content', $modifiers) . '; ';
  47. }
  48. $_result .= 'echo $this->_block_content; array_pop($this->_tag_stack); ?>';
  49. }
  50. return true;
  51. }
  52. else
  53. {
  54. return false;
  55. }
  56. }
  57. ?>