/** * Postprocesses the opt:tree node. * @internal * @param Opt_Xml_Element $node The node found by the compiler. */ protected function _postprocessTree(Opt_Xml_Element $node) { $section = $this->getSection($node->get('sectionName')); if ($node->hasAttributes()) { if (!$node->get('sectionElse')) { $this->_sortSectionContents($node, 'opt', 'treeelse'); } } $this->_sectionEnd($node); }
/** * Finishes the processing of the opt:section tag. * @internal * @param Opt_Xml_Element $node The recognized element. */ protected function _postprocessSection(Opt_Xml_Element $node) { $section = self::getSection($node->get('priv:section')); if (!$node->get('priv:alternative')) { $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, $section['format']->get('section:endLoop')); $this->_sectionEnd($node); } }
/** * Adds the show condition PHP code to the specified node, using the * information from the section record. * * @internal * @param Opt_Xml_Element $node The node, where to add the show condition. * @param Array &$section The section info record */ private function _createShowCondition(Opt_Xml_Element $node, &$section) { // First, try to check for the call:use tag variable. if ($node->get('call:use') !== NULL) { $section['node']->set('call:use', $node->get('call:use')); } // Deal with the data formats $format = $section['format']; $format->assign('section', $section); $request = $format->property('section:anyRequests'); if (!is_null($request)) { // Send the requested data, if the data format needs any. switch ($request) { case 'ancestorNames': self::$_stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP); $list = array(); $parent = $section['parent']; foreach (self::$_stack as $up) { if ($up == $parent) { $parent = self::$_sections[$up]['parent']; $list[] = self::$_sections[$up]['name']; } } $format->assign('requestedData', array_reverse($list)); break; case 'ancestorNumbers': self::$_stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP); $list = array(); $parent = $section['parent']; $iteration = self::$_stack->count(); foreach (self::$_stack as $up) { if ($up == $parent) { $parent = self::$_sections[$up]['parent']; $list[] = $iteration; } $iteration--; } $format->assign('requestedData', array_reverse($list)); break; } } $code = $format->get('section:init'); if (is_null($section['display'])) { $code .= ' if(' . $format->get('section:isNotEmpty') . '){ '; } else { $code .= ' if(' . $format->get('section:isNotEmpty') . ' && ' . $section['display'] . '){ '; } $code .= $format->get('section:started'); $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, $code); $code = $format->get('section:finished') . ' } ' . $format->get('section:done'); $node->addAfter(Opt_Xml_Buffer::TAG_AFTER, $code); $node->set('priv:initialized', true); }
/** * Postprocesses the opt:insert element. * @internal * @param Opt_Xml_Element $node The found element. */ public function _postprocessInsert(Opt_Xml_Element $node) { // Freeing the fake node, if necessary. if (!is_null($node->get('insertSize'))) { $this->_snippets[$node->get('insertSnippet')][$node->get('insertSize')]->dispose(); unset($this->_snippets[$node->get('insertSnippet')][$node->get('insertSize')]); } // Restore the original escaping state $this->_compiler->set('escaping', $node->get('escaping')); array_pop($this->_current); }
/** * The common processing part of the dynamically and statically * deployed components. Returns the compiled PHP code ready to * be appended to the XML tag. The caller must generate a component * variable name that will be used in the generated code to refer * to the component object. Furthermore, he must pass the returned results * of _extractAttributes() method. * * @internal * @param Opt_Xml_Element $node The node with the component data. * @param string $blockVariable The PHP block variable name. * @param array $args The array of custom block attributes. * @return string */ private function _commonProcessing(Opt_Xml_Element $node, $blockVariable, array $args) { // Common part of the component processing $argList = 'array( '; foreach ($args as $name => $value) { $argList .= '\'' . $name . '\' => ' . $value . ', '; } $argList .= ')'; if ($node->get('single')) { $node->addAfter(Opt_Xml_Buffer::TAG_SINGLE_BEFORE, $blockVariable . '->onSingle(' . $argList . '); '); } else { $node->addAfter(Opt_Xml_Buffer::TAG_BEFORE, ' if(' . $blockVariable . '->onOpen(' . $argList . ')){ '); $node->addBefore(Opt_Xml_Buffer::TAG_AFTER, ' } ' . $blockVariable . '->onClose(); '); } $this->_process($node); }
/** * Finishes the processing of the opt:item tag. * @internal * @param Opt_Xml_Element $node The recognized node. */ protected function _postprocessItem(Opt_Xml_Element $node) { if (!is_null($node->get('call:use'))) { $section = $node->get('priv:section'); $this->_compiler->unsetConversion('##simplevar_' . $section['name']); } // Deactivating the section. $this->_sectionEnd($node); }