PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/Opl/Opt/Instruction/Root.php

https://bitbucket.org/kandsten/hitta.sverok.se
PHP | 60 lines | 42 code | 6 blank | 12 comment | 6 complexity | 100247409e858d5dddc59cad28f481d4 MD5 | raw file
Possible License(s): GPL-3.0, MIT
  1. <?php
  2. /*
  3. * OPEN POWER LIBS <http://www.invenzzia.org>
  4. *
  5. * This file is subject to the new BSD license that is bundled
  6. * with this package in the file LICENSE. It is also available through
  7. * WWW at this URL: <http://www.invenzzia.org/license/new-bsd>
  8. *
  9. * Copyright (c) Invenzzia Group <http://www.invenzzia.org>
  10. * and other contributors. See website for details.
  11. *
  12. * $Id: Root.php 231 2009-09-19 07:13:14Z zyxist $
  13. */
  14. class Opt_Instruction_Root extends Opt_Compiler_Processor
  15. {
  16. protected $_name = 'root';
  17. public function configure()
  18. {
  19. $this->_addInstructions(array('opt:root'));
  20. } // end configure();
  21. public function processNode(Opt_Xml_Node $node)
  22. {
  23. if($node->getParent()->getType() != 'Opt_Xml_Root')
  24. {
  25. throw new Opt_InstructionInvalidParent_Exception($node->getXmlName(), 'ROOT');
  26. }
  27. $params = array(
  28. 'escaping' => array(0 => self::OPTIONAL, self::BOOL, NULL),
  29. 'include' => array(0 => self::OPTIONAL, self::HARD_STRING, NULL),
  30. 'dynamic' => array(0 => self::OPTIONAL, self::BOOL, false),
  31. );
  32. $this->_extractAttributes($node, $params);
  33. if(!is_null($params['include']))
  34. {
  35. $file = $params['include'];
  36. if($params['dynamic'])
  37. {
  38. if(is_null($file = $this->_compiler->inherits($this->_compiler->get('currentTemplate'))))
  39. {
  40. $file = $params['include'];
  41. }
  42. }
  43. $this->_compiler->addDependantTemplate($file);
  44. $compiler = new Opt_Compiler_Class($this->_compiler);
  45. $compiler->compile($this->_tpl->_getSource($file), $file, NULL, $this->_compiler->get('mode'));
  46. $this->_compiler->importDependencies($compiler);
  47. }
  48. if(!is_null($params['escaping']))
  49. {
  50. $this->_compiler->set('escaping', $params['escaping']);
  51. }
  52. $this->_process($node);
  53. } // end processNode();
  54. } // end Opt_Instruction_Root;