Example #1
0
 /**
  * Processes the opt:selectorelse element.
  * @internal
  * @param Opt_Xml_Element $node
  * @throws Opt_InstructionInvalidParent_Exception
  */
 protected function _processSelectorelse(Opt_Xml_Element $node)
 {
     $parent = $node->getParent();
     if ($parent instanceof Opt_Xml_Element && $parent->getXmlName() == 'opt:selector') {
         $parent->set('priv:alternative', true);
         $section = self::getSection($parent->get('priv:section'));
         $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' } ' . $section['format']->get('section:endLoop') . ' } else { ');
         $this->_sectionEnd($parent);
         $this->_process($node);
     } else {
         throw new Opt_InstructionInvalidParent_Exception($node->getXmlName(), 'opt:section');
     }
 }
Example #2
0
 /**
  * Processes opt:treeelse node.
  * @internal
  * @param Opt_Xml_Element $node The instruction node found by the compiler.
  */
 protected function _processTreeelse(Opt_Xml_Element $node)
 {
     $parent = $node->getParent();
     if ($parent instanceof Opt_Xml_Element && $parent->getXmlName() == 'opt:tree') {
         $parent->set('sectionElse', true);
         $section = $this->getSection($parent->get('sectionName'));
         $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' } else { ');
         $this->_process($node);
     }
 }
Example #3
0
 /**
  * Processes the opt:sectionelse element.
  * @internal
  * @param Opt_Xml_Element $node The recognized element.
  */
 protected function _processSectionelse(Opt_Xml_Element $node)
 {
     $parent = $node->getParent();
     if ($parent instanceof Opt_Xml_Element && $parent->getXmlName() == 'opt:section') {
         $parent->set('priv:alternative', true);
         $section = self::getSection($parent->get('priv:section'));
         if (!is_array($section)) {
             throw new Opt_APINoDataReturned_Exception('Opt_Instruction_BaseSection::getSection', 'processing opt:sectionelse');
         }
         $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, $section['format']->get('section:endLoop') . ' } else { ');
         $this->_sectionEnd($parent);
         $this->_process($node);
     } else {
         throw new Opt_InstructionInvalidParent_Exception($node->getXmlName(), 'opt:section');
     }
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * Processes the opt:gridelse tag.
  * @internal
  * @param Opt_Xml_Element $node The recognized node.
  */
 protected function _processGridelse(Opt_Xml_Element $node)
 {
     $parent = $node->getParent();
     if ($parent instanceof Opt_Xml_Element && $parent->getXmlName() == 'opt:grid') {
         $parent->set('priv:alternative', true);
         $section = $parent->get('priv:section');
         $node->addBefore(Opt_Xml_Buffer::TAG_BEFORE, ' } else { ');
         //	$this->_deactivateSection($parent->get('sectionName'));
         $this->_process($node);
     }
 }