Exemplo n.º 1
0
function profile($dump = false)
{
    $trace = debug_backtrace();
    array_pop($trace);
    $k = reset($trace);
    Opl_Debug::writeErr($k['function'] . ',' . $k['file'] . ',' . $k['line']);
}
Exemplo n.º 2
0
 /**
  * The internal magic shared by the selector elements. Locates the node elements
  * and constructs the switch() statement for them.
  * @internal
  * @param Opt_Xml_Element $node The found element
  * @param array $section The reference to the section data.
  * @param string $type The name of the selection item.
  * @throws Opt_InstructionTooManyItems_Exception
  */
 private function _internalMagic($node, &$section, $type)
 {
     $section['format']->assign('item', !$type ? $section['test'] : 'item');
     // Check, if there are no instruction tags in the children list.
     $instructions = array();
     $cases = array();
     $alternative = null;
     foreach ($node as $subnode) {
         if ($subnode instanceof Opt_Xml_Element && $this->_compiler->isNamespace($subnode->getNamespace())) {
             if ($this->_compiler->isInstruction($subnode->getXmlName()) || $subnode->getXmlName() == 'opt:separator') {
                 if ($subnode != 'opt:selectorelse') {
                     $instructions[] = $subnode;
                 } else {
                     if (!is_null($alternative)) {
                         throw new Opt_InstructionTooManyItems_Exception('opt:selectorelse', $node->getXmlName(), 'Zero or one');
                     }
                     $alternative = $subnode;
                 }
             } else {
                 $cases[] = $subnode;
             }
         } else {
             $node->removeChild($subnode);
         }
     }
     if (sizeof($instructions) > 0) {
         // There are instructions in opt:selector. We have to move the
         // cases to a fake node in order to sanitize them.
         $node->removeChildren();
         foreach ($instructions as $instruction) {
             $node->appendChild($instruction);
         }
         $fake = new Opt_Xml_Element('opt:_');
         foreach ($cases as $case) {
             $fake->appendChild($case);
         }
         $fake->set('processAll', true);
         $fake->set('hidden', false);
         $node->appendChild($fake);
         if (!is_null($alternative)) {
             $node->appendChild($alternative);
         }
     } else {
         $fake = $node;
     }
     $fake->addAfter(Opt_Xml_Buffer::TAG_CONTENT_BEFORE, 'switch(' . $section['format']->get('section:variable') . '){');
     // If opt:selectorelse is used, the ending curly bracket is created by
     // _processSelectorelse().
     if (is_null($alternative)) {
         $fake->addBefore(Opt_Xml_Buffer::TAG_CONTENT_AFTER, ' } ');
     }
     foreach ($cases as $case) {
         if ($case->getXmlName() == 'opt:separator') {
             Opl_Debug::write('Print shit');
         }
         if ($case->getName() == 'default') {
             $case->addAfter(Opt_Xml_Buffer::TAG_CONTENT_BEFORE, ' default: ');
         } else {
             $case->addAfter(Opt_Xml_Buffer::TAG_CONTENT_BEFORE, ' case \'' . $case->getName() . '\': ');
         }
         $case->addBefore(Opt_Xml_Buffer::TAG_CONTENT_AFTER, ' break; ');
         $case->set('processAll', true);
         $case->set('hidden', false);
     }
 }