PageRenderTime 36ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/dwoo/plugins/builtin/blocks/smartyinterface.php

https://github.com/stormeus/Kusaba-Z
PHP | 61 lines | 40 code | 7 blank | 14 comment | 7 complexity | 4f79e0075851fc06ca9731d83267cc7d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Smarty compatibility layer for block plugins, this is used internally and you should not call it
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * In no event will the authors be held liable for any damages arising from the use of this software.
  7. *
  8. * @author Jordi Boggiano <j.boggiano@seld.be>
  9. * @copyright Copyright (c) 2008, Jordi Boggiano
  10. * @license http://dwoo.org/LICENSE Modified BSD License
  11. * @link http://dwoo.org/
  12. * @version 1.0.0
  13. * @date 2008-10-23
  14. * @package Dwoo
  15. */
  16. class Dwoo_Plugin_smartyinterface extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
  17. {
  18. public function init($__funcname, $__functype, array $rest=array()) {}
  19. public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
  20. {
  21. $params = $compiler->getCompiledParams($params);
  22. $func = $params['__funcname'];
  23. $pluginType = $params['__functype'];
  24. $paramsOut = '';
  25. if(isset($params['*'])) {
  26. $params = $params['*'];
  27. foreach ($params as $i=>$p) {
  28. $paramsOut .= var_export($i, true).' => '.$p.',';
  29. }
  30. }
  31. if ($pluginType & Dwoo::CUSTOM_PLUGIN) {
  32. $customPlugins = $compiler->getDwoo()->getCustomPlugins();
  33. $callback = $customPlugins[$func]['callback'];
  34. if (is_array($callback)) {
  35. if (is_object($callback[0])) {
  36. $callback = '$this->customPlugins[\''.$func.'\'][0]->'.$callback[1].'(';
  37. } else {
  38. $callback = ''.$callback[0].'::'.$callback[1].'(';
  39. }
  40. } else {
  41. $callback = $callback.'(';
  42. }
  43. } else {
  44. $callback = 'smarty_block_'.$func.'(';
  45. }
  46. $curBlock =& $compiler->getCurrentBlock();
  47. $curBlock['params']['postOut'] = Dwoo_Compiler::PHP_OPEN.' $_block_content = ob_get_clean(); $_block_repeat=false; echo '.$callback.'$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);'.Dwoo_Compiler::PHP_CLOSE;
  48. return Dwoo_Compiler::PHP_OPEN.$prepend.' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array('.$paramsOut.'); $_block_repeat=true; '.$callback.'$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();'.Dwoo_Compiler::PHP_CLOSE;
  49. }
  50. public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
  51. {
  52. return $content . $params['postOut'];
  53. }
  54. }