예제 #1
0
 /**
  * Closes the XML comment for the commented item.
  *
  * @internal
  * @param Opt_Xml_Node $item The commented item.
  * @param String &$output The reference to the output buffer.
  */
 protected function _closeComments($item)
 {
     if ($item->get('commented')) {
         $this->_comments--;
         if ($this->_comments == 0) {
             // According to the XML grammar, the construct "--->" is not allowed.
             if (strlen($this->_output) > 0 && $this->_output[strlen($this->_output) - 1] == '-') {
                 throw new Opt_XmlComment_Exception('--->');
             }
             $this->_output .= '-->';
         }
     }
 }
예제 #2
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);
 }
예제 #3
0
 /**
  * Finishes the public processing of the component.
  *
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function postprocessComponent(Opt_Xml_Node $node)
 {
     if (!is_null($attribute = $node->get('_componentTemplate'))) {
         $this->_compiler->processor('snippet')->postprocessAttribute($node, $attribute);
         $node->set('_componentTemplate', NULL);
     }
     $this->_stack->pop();
 }
예제 #4
0
 /**
  * Finalizes the opt:show attribute. If there was no section in opt:show,
  * it initializes a section for a moment just to generate the condition,
  * but does not add it to the stack.
  *
  * @param Opt_Xml_Node $node The node.
  */
 protected function _postprocessShow(Opt_Xml_Node $node)
 {
     if (!is_null($node->get('priv:initialized'))) {
         return;
     }
     $section = $this->_extractSectionAttributes($node, null);
     $section['show'] = $node;
     $section['node'] = null;
     $section['attribute'] = null;
     $this->_validateSection($section);
     $this->_createShowCondition($node, $section);
 }
예제 #5
0
 /**
  * Postprocesses the opt:attribute instruction tag.
  * @internal
  * @param Opt_Xml_Node $node XML node.
  */
 public function postprocessNode(Opt_Xml_Node $node)
 {
     // We must copy the buffers here, because the instruction might have some attributes
     // which may also use "postprocess" to generate their code. Here we are sure they've completed
     // their work.
     $attribute = $node->get('priv:attr');
     $attribute->copyBuffer($node, Opt_Xml_Buffer::TAG_BEFORE, Opt_Xml_Buffer::ATTRIBUTE_BEGIN);
     $attribute->copyBuffer($node, Opt_Xml_Buffer::TAG_AFTER, Opt_Xml_Buffer::ATTRIBUTE_END);
     $node->set('priv:attr', null);
 }
예제 #6
0
 /**
  * Finishes the processing of the opt:extend node. In this particular
  * case it handles the support of snippet extending, where the snippets
  * need to be scanned AFTER they are actually loaded.
  *
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function postprocessNode(Opt_Xml_Node $node)
 {
     if ($this->_compiler->processor('snippet')->isSnippet($node->get('branch'))) {
         $node->getParent()->set('snippet', $node->get('branch'));
     } else {
         $node->getParent()->set('extend', $node->get('branch'));
     }
 }
예제 #7
0
 /**
  * A postprocessing routine for opt:use
  * @internal
  * @param Opt_Xml_Node $node
  * @param Opt_Xml_Attribute $attr
  */
 public function postprocessAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr)
 {
     if (!is_null($attr->get('size'))) {
         $snippet = $attr->get('snippetObj');
         unset($snippet[$attr->get('size')]);
     }
     // Restore the original escaping state
     $this->_compiler->set('escaping', $node->get('escaping'));
     array_pop($this->_current);
 }
예제 #8
0
 /**
  * Finishes the processing of the opt:foreach node.
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function postprocessNode(Opt_Xml_Node $node)
 {
     $params = $node->get('params');
     $this->_compiler->unsetConversion('##var_' . $params['value']);
     $this->_compiler->unsetConversion('##var_' . $params['index']);
     $this->_nesting--;
 }
예제 #9
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);
 }
예제 #10
0
 /**
  * Postprocessing routine for opt:tag element.
  * @internal
  * @param Opt_Xml_Node $node The found node.
  */
 public function postprocessNode(Opt_Xml_Node $node)
 {
     if ($node->get('single')) {
         $node->removeChildren();
     }
     $node->setNamespace(null);
     $node->setName('__default__');
 }