Beispiel #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);
 }
Beispiel #2
0
 /**
  * Adds the PHP code with dependencies to the code buffers in the tree
  * root node.
  *
  * @internal
  * @param Opt_Xml_Node $tree The tree root node.
  */
 protected function _addDependencies($tree)
 {
     // OK, there is really some info to include!
     $list = '';
     foreach ($this->_dependencies as $a) {
         $list .= '\'' . $a . '\',';
     }
     $tree->addBefore(Opt_Xml_Buffer::TAG_BEFORE, 'if(!$this->_massPreprocess($compileTime, array(' . $list . '))){ ');
     $tree->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' }else{ $compileTime = $this->_compile($this->_template, $mode); require(__FILE__); } ');
 }
Beispiel #3
0
 /**
  * A postprocessing routine for attributed opt:selector
  * @internal
  * @param Opt_Xml_Node $node
  * @param Opt_Xml_Attribute $attr
  */
 protected function _postprocessAttrSelector(Opt_Xml_Node $node, Opt_Xml_Attribute $attr)
 {
     $section = self::getSection($node->get('priv:section'));
     $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, $section['format']->get('section:endLoop'));
     $this->_sectionEnd($node);
 }
Beispiel #4
0
 /**
  * Finalizes the processing of the opt:if and opt:omit-tag attributes.
  * @internal
  * @param Opt_Xml_Node $node The node with the attribute
  * @param Opt_Xml_Attribute $attr The recognized attribute.
  */
 public function postprocessAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr)
 {
     $expr = $this->_compiler->compileExpression((string) $attr, false, Opt_Compiler_Class::ESCAPE_OFF);
     $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' if(' . $expr[0] . '){ ');
     $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, ' } ');
 }
Beispiel #5
0
 /**
  * Processes the opt:capture attribute.
  * @internal
  * @param Opt_Xml_Node $node The node with the attribute
  * @param Opt_Xml_Attribute $attr The recognized attribute.
  */
 public function processAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr)
 {
     if ($this->_compiler->isIdentifier($attr->getValue())) {
         $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, 'ob_start(); ');
         $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, 'self::$_capture[\'' . $attr->getValue() . '\'] = ob_get_clean();');
         $this->_process($node);
     } else {
         throw new Opt_InvalidAttributeType_Exception('opt:capture', 'identifier');
     }
 }
Beispiel #6
0
 /**
  * Processes the opt:empty-item tag.
  * @internal
  * @param Opt_Xml_Element $node The recognized node.
  */
 protected function _processEmptyItem(Opt_Xml_Node $node)
 {
     if (is_null($node->get('priv:section'))) {
         throw new Opt_InstructionInvalidLocation_Exception('opt:item', 'opt:grid');
     }
     $section = $node->get('priv:section');
     $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, ' if($_' . $section['name'] . '_remain > 0 && !' . $section['format']->get('section:valid') . ') { for($_' . $section['name'] . '_k = 0; $_' . $section['name'] . '_k < $_' . $section['name'] . '_remain; $_' . $section['name'] . '_k++) { ');
     $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, ' } } ');
     $this->_process($node);
 }