/** * This method is called automatically for each XML attribute that the * processor has registered during the postprocessing, if the instruction * requested this by setting the "postprocess" variable to "true" in the * attribute. It can handle many attributes, and the * default implementation redirects the processing to the private * user-created methods _postprocessAttrName for "opt:name" attribute. * * @param Opt_Xml_Node $node The node that contains the attribute. * @param Opt_Xml_Attribute $attr The attribute to be processed. */ public function postprocessAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr) { $name = '_postprocessAttr' . ucfirst($attr->getName()); $this->{$name}($node, $attr); }
/** * Processes the opt:attributes-build and opt:attributes-ignore attributes. * @internal * @param Opt_Xml_Element $node The node * @param Opt_Xml_Attribute $attr The attribute to process */ public function processAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr) { if ($attr->getName() == 'attributes-build') { $ignoreList = $node->getAttribute('opt:attributes-ignore'); if ($ignoreList instanceof Opt_Xml_Attribute) { $ignore = $this->_compiler->compileExpression($ignoreList->getValue(), false, Opt_Compiler_Class::ESCAPE_OFF); $ignore = $ignore[0]; } else { $ignore = 'array()'; } $expression = $this->_compiler->compileExpression($attr->getValue(), false, Opt_Compiler_Class::ESCAPE_OFF); $node->addAfter(Opt_Xml_Buffer::TAG_ENDING_ATTRIBUTES, 'echo Opt_Function::buildAttributes(' . $expression[0] . ', ' . $ignore . ', \' \'); '); } }
/** * Processes 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 processAttribute(Opt_Xml_Node $node, Opt_Xml_Attribute $attr) { // TODO: Add opt:omit-tag implementation, changed opt:on->opt:omit-tag, it should work as before switch ($attr->getName()) { case 'omit-tag': if (!$this->_compiler->isNamespace($node->getNamespace())) { $expr = $this->_compiler->compileExpression((string) $attr, false, Opt_Compiler_Class::ESCAPE_OFF); $node->addBefore(Opt_Xml_Buffer::TAG_OPENING_BEFORE, ' $_tag_' . $this->_cnt . ' = false; if(' . $expr[0] . '){ $_tag_' . $this->_cnt . ' = true; '); $node->addAfter(Opt_Xml_Buffer::TAG_OPENING_AFTER, ' } '); $node->addBefore(Opt_Xml_Buffer::TAG_CLOSING_BEFORE, ' if($_tag_' . $this->_cnt . ' === true){ '); $node->addAfter(Opt_Xml_Buffer::TAG_CLOSING_AFTER, ' } '); $this->_cnt++; break; } case 'if': // opt:if added to an section must be handled differently. // Wait for the section processor and add the condition in the postprocessing. if ($this->_compiler->isInstruction($node->getXmlName()) instanceof Opt_Instruction_BaseSection) { $attr->set('postprocess', true); return; } $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, ' } '); } }