예제 #1
0
 /**
  * Processes the opt:dynamic node.
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function processNode(Opt_Xml_Node $node)
 {
     // Add capturing the content for the caching purposes
     $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, '$this->_outputBuffer[] = ob_get_contents();');
     $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' ob_start(); ');
     // Inform the compiler to store this piece of compiled
     // template in an extra file, where it will be accessible
     // to the caching system.
     $node->set('dynamic', true);
     $this->_process($node);
 }
예제 #2
0
 /**
  * Processes the opt:block node.
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function processNode(Opt_Xml_Node $node)
 {
     $node->set('block', true);
     // Undefined block processing
     $params = array('from' => array(self::REQUIRED, self::EXPRESSION, null), '__UNKNOWN__' => array(self::OPTIONAL, self::EXPRESSION, null));
     $vars = $this->_extractAttributes($node, $params);
     $this->_stack->push($params['from']);
     $mainCode = ' if(is_object(' . $params['from'] . ') && ' . $params['from'] . ' instanceof Opt_Block_Interface){ ' . $params['from'] . '->setView($this); ';
     $mainCode .= $this->_commonProcessing($node, $params['from'], $vars);
     $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, $mainCode);
     $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
 }
예제 #3
0
 /**
  * Processes the opt:component, opt:on-event and opt:display nodes.
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function processNode(Opt_Xml_Node $node)
 {
     switch ($node->getName()) {
         case 'component':
             $node->set('component', true);
             // Undefined component processing
             $params = array('from' => array(self::REQUIRED, self::EXPRESSION, null), 'datasource' => array(self::OPTIONAL, self::EXPRESSION, null), 'template' => array(self::OPTIONAL, self::ID, null), '__UNKNOWN__' => array(self::OPTIONAL, self::EXPRESSION, null));
             $vars = $this->_extractAttributes($node, $params);
             $this->_stack->push($params['from']);
             $mainCode = ' if(is_object(' . $params['from'] . ') && ' . $params['from'] . ' instanceof Opt_Component_Interface){ ' . $params['from'] . '->setView($this); ';
             if (!is_null($params['datasource'])) {
                 $mainCode .= $params['from'] . '->setDatasource(' . $params['datasource'] . '); ';
             }
             $mainCode .= $this->_commonProcessing($node, $params['from'], $params, $vars);
             $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, $mainCode);
             $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
             break;
         case 'onEvent':
             if ($this->_stack->count() == 0) {
                 throw new Opt_ComponentNotActive_Exception($node->getXmlName());
             }
             $tagParams = array('name' => array(self::REQUIRED, self::EXPRESSION));
             $this->_extractAttributes($node, $tagParams);
             $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, ' if(' . $this->_stack->top() . '->processEvent(' . $tagParams['name'] . ')){ ');
             $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
             $this->_process($node);
             break;
         case 'display':
             if ($this->_stack->count() == 0) {
                 throw new Opt_ComponentNotActive_Exception($node->getXmlName());
             }
             $node->set('hidden', false);
             $node->removeChildren();
             // The opt:display attributes must be packed into array and sent
             // to Opt_Component_Interface::display()
             $subCode = '';
             if ($node->hasAttributes()) {
                 $params = array('__UNKNOWN__' => array(self::OPTIONAL, self::EXPRESSION, null));
                 $vars = $this->_extractAttributes($node, $params);
                 $subCode = 'array(';
                 foreach ($vars as $name => $value) {
                     $subCode .= '\'' . $name . '\' => ' . $value . ',';
                 }
                 $subCode .= ')';
             }
             $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, $this->_stack->top() . '->display(' . $subCode . '); ');
             break;
     }
 }
예제 #4
0
 /**
  * A dummy opt:show processor that actually does nothing, because
  * it must wait for the right section instruction. If such instruction
  * will not appear, the node will be parsed in the postprocessing.
  *
  * @internal
  * @param Opt_Xml_Node $node The node
  */
 protected function _processShow(Opt_Xml_Node $node)
 {
     $node->set('postprocess', true);
     $this->_sortSectionContents($node, 'opt', 'showelse');
     $this->_process($node);
 }
예제 #5
0
 /**
  * Processes the opt:item tag.
  * @internal
  * @param Opt_Xml_Element $node The recognized node.
  */
 protected function _processItem(Opt_Xml_Node $node)
 {
     if (is_null($node->get('priv:section'))) {
         throw new Opt_InstructionInvalidLocation_Exception('opt:item', 'opt:grid');
     }
     // We're at home. For this particular node we have to activate the section.
     $section = $node->get('priv:section');
     $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, ' for($_' . $section['name'] . '_k = 0; $_' . $section['name'] . '_k < ' . $section['cols'] . ' && ' . $section['format']->get('section:valid') . '; $_' . $section['name'] . '_k++) { ' . $section['format']->get('section:populate'));
     $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, $section['format']->get('section:next') . ' } ');
     $this->_sectionStart($section);
     $node->set('postprocess', true);
     if (!is_null($node->get('call:use'))) {
         $this->_compiler->setConversion('##simplevar_' . $node->get('call:use'), $section['name']);
         $node->set('postprocess', true);
     }
     $this->_process($node);
 }
예제 #6
0
 /**
  * Postprocesses the opt:single instruction attribute.
  *
  * @internal
  * @param Opt_Xml_Node $node XML node.
  * @param Opt_Xml_Attribute $attr XML attribute.
  */
 public function postprocessAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr)
 {
     if ($attr->getValue() == 'yes') {
         $node->set('single', true);
         $node->removeChildren();
     }
 }