Fill in output context

@param  DOMDocument $ir
@return void
172760
protected function setOutputContext(DOMDocument $ir)
	{
		foreach ($this->query('//output') as $output)
		{
			$output->setAttribute('escape', $this->getOutputContext($output));
		}
	}
68706
private function addContexts( &$document, $xbrldiPrefix )
	{
		foreach ( $this->contexts as $contextRef => $context )
		{
			$document[] = "  <context id=\"$contextRef\">";

			if ( isset( $context['entity'] ) )
			{
				$document[] = "    <entity>";

				if ( isset( $context['entity']['identifier'] ) )
				{
					$document[] = "      <identifier scheme=\"{$context['entity']['identifier']['scheme']}\">{$context['entity']['identifier']['value']}</identifier>";
				}

				if ( isset( $context['entity']['segment'] ) )
				{
					$this->addComponent( "segment", $context['entity']['segment'], $document, "      ", $xbrldiPrefix );
				}

				if ( isset( $context['entity']['scenario'] ) )
				{
					$this->addComponent( "scenario", $context['entity']['scenario'], $document, "    ", $xbrldiPrefix );
				}

				$document[] = "    </entity>";
			}

			if ( isset( $context['period'] ) )
			{
				$document[] = "    <period>";

				if ( $context['period']['is_instant'] )
				{
					$document[] = "      <instant>{$context['period']['startDate']}</instant>";
				}
				else if ( isset( $context['period']['type'] ) && $context['period']['type'] == 'forever' )
				{
					$document[] = "      <forever/>";
				}
				else if ( isset( $context['period']['type'] ) && $context['period']['type'] == 'duration' )
				{
					$document[] = "      <startDate>{$context['period']['startDate']}</startDate>";
					$document[] = "      <endDate>{$context['period']['endDate']}</endDate>";
				}
				$document[] = "    </period>";
			}

			if ( isset( $context['segment'] ) )
			{
				$this->addComponent( "segment", $context['segment'], $document, "    ", $xbrldiPrefix );
			}

			if ( isset( $context['scenario'] ) )
			{
				$this->addComponent( "scenario", $context['scenario'], $document, "  ", $xbrldiPrefix );
			}

			$document[] = "  </context>";
			$document[] = "";
		}
	}
116352
public static function init($version = '1.0', $encoding = 'UTF-8', $formatOutput = true)
        {
            self::$xml = new \DomDocument($version, $encoding);
            self::$xml->formatOutput = $formatOutput;
            self::$encoding = $encoding;
        }
674729
protected function addCloseTagElements(DOMDocument $ir)
	{
		$exprs = [
			'//applyTemplates[not(ancestor::attribute)]',
			'//comment',
			'//element',
			'//output[not(ancestor::attribute)]'
		];
		foreach ($this->query(implode('|', $exprs)) as $node)
		{
			$parentElementId = $this->getParentElementId($node);
			if (isset($parentElementId))
			{
				$node->parentNode
				     ->insertBefore($ir->createElement('closeTag'), $node)
				     ->setAttribute('id', $parentElementId);
			}

			// Append a <closeTag/> to <element/> nodes to ensure that empty elements get closed
			if ($node->nodeName === 'element')
			{
				$id = $node->getAttribute('id');
				$this->appendElement($node, 'closeTag')->setAttribute('id', $id);
			}
		}
	}
962415
protected function parseXslValueOf(DOMElement $ir, DOMElement $node)
	{
		$this->appendXPathOutput($ir, $node->getAttribute('select'));
		if ($node->getAttribute('disable-output-escaping') === 'yes')
		{
			$ir->lastChild->setAttribute('disable-output-escaping', 'yes');
		}
	}
991533
function &outputText()
    {
        if ( !$this->XMLData )
        {
            $output = '';
            return $output;
        }

        $this->Tpl = eZTemplate::factory();
        $this->Res = eZTemplateDesignResource::instance();
        if ( $this->ContentObjectAttribute )
        {
            $this->Res->setKeys( array( array( 'attribute_identifier', $this->ContentObjectAttribute->attribute( 'contentclass_attribute_identifier' ) ) ) );
        }

        $this->Document = new DOMDocument( '1.0', 'utf-8' );
        $success = $this->Document->loadXML( $this->XMLData );

        if ( !$success )
        {
            $this->Output = '';
            return $this->Output;
        }

        $this->prefetch();

        $this->XMLSchema = eZXMLSchema::instance();

        // Add missing elements to the OutputTags array
        foreach( $this->XMLSchema->availableElements() as $element )
        {
            if ( !isset( $this->OutputTags[$element] ) )
            {
                 $this->OutputTags[$element] = array();
             }
        }

        $this->NestingLevel = 0;
        $params = array();

        $output = $this->outputTag( $this->Document->documentElement, $params );
        $this->Output = $output[1];

        unset( $this->Document );

        $this->Res->removeKey( 'attribute_identifier' );
        return $this->Output;
    }
334173
protected function parseXslComment(DOMElement $ir, DOMElement $node)
	{
		$comment = $this->appendElement($ir, 'comment');
		$this->parseChildren($comment, $node);
	}
672135
protected function processPrefix(\DOMElement $element, ContextInterface $context)
    {
        if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) {
            $prefixes = preg_split('/\s+/', $element->getAttribute('prefix'));
            while (count($prefixes)) {
                $prefix = rtrim(array_shift($prefixes), ':');
                $uri = array_shift($prefixes);
                $context = $context->registerVocabulary($prefix, $uri);
            }
        }

        return $context;
    }
957400
private function writeListing( array $elements, int $indentLevel, string $lineChar ) : void
	{
		if ( 0 === count( $elements ) )
		{
			return;
		}

		$indent = str_repeat( ' ', $indentLevel * 2 );

		$this->write(
			"%s%s %s  \n\n",
			$indent,
			$lineChar,
			implode( "  \n{$indent}{$lineChar} ", $elements )
		);
	}
1236600
public function output($response, $context = null)
    {
        $this->builder->output()->response($response, $context);
    }
50710
protected function optimizeCloseTagElements(DOMDocument $ir)
	{
		$this->cloneCloseTagElementsIntoSwitch($ir);
		$this->cloneCloseTagElementsOutOfSwitch($ir);
		$this->removeRedundantCloseTagElementsInSwitch($ir);
		$this->removeRedundantCloseTagElements($ir);
	}
834951
private function doFix(\DOMText $childNode, \DOMNode $node, \DOMDocument $dom)
    {
        $content = $childNode->wholeText;
        $current_node = new StateNode($childNode, $node, $dom);

        $this->stateBag->setCurrentNode($current_node);

        // run the string on all the fixers
        foreach ($this->_rules as $fixer) {
            $content = $fixer->fix($content, $this->stateBag);
        }

        // update the DOM only if the node has changed
        if ($childNode->wholeText !== $content) {
            $new_node = $dom->createTextNode($content);
            $node->replaceChild($new_node, $childNode);

            // As the node is replaced, we also update it in the StateNode
            $current_node->replaceNode($new_node);
        }
    }
855187
public function setElement($document, $element = null)
    {
        if (empty($document)) {
            // Make sure we always have an element to query against which should not return any returns.
            $document = new DOMDocument();
            $document->loadXML('<dummy/>');
        }
        $this->document = $document;

        if (empty($element)) {
            $element = $this->document->documentElement;
        }
        $this->element = $element;
    }
879696
public function render(\DOMDocument $domDocument)
    {
        $frame = new Frame();
        $frame->setId($this->frameId);
        $frame->setAlign($this->hAlign, $this->vAlign);
        $frame->setPosition($this->startX, $this->startY);
        $frame->addClasses($this->frameClasses);
        $sizeY = 0;
        $sizeX = 0;
        /** @var Control $oldElement */
        $oldElement = null;
        foreach ($this->elements as $idx => $element) {

            if ($idx === 0) {
                $start = $this->getRelativeStartPosition($element);
            } else {
                $start = $this->getStartPosition($oldElement) + $this->margin;
            }

            if ($oldElement) {

                if ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + $oldElement->getWidth() + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "left" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + $oldElement->getWidth() + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "left") {
                    $element->setX($start + $oldElement->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "center" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $oldElement->getWidth() + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "center") {
                    $element->setX($start + ($element->getWidth() / 2));
                } elseif ($oldElement->getHorizontalAlign() == "left" && $element->getHorizontalAlign() == "right") {
                    $element->setX($start + $oldElement->getWidth() + $element->getWidth());
                } elseif ($oldElement->getHorizontalAlign() == "right" && $element->getHorizontalAlign() == "left") {
                    $element->setX($start);
                } else {
                    $element->setX($start + $oldElement->getWidth());
                }
            } else {
                $element->setX($start);
            }

            if ((abs($element->getY()) + $element->getHeight()) > $sizeY) {
                $sizeY = abs($element->getY()) + $element->getHeight();
                $this->setHeight($sizeY);
            }
            $frame->addChild($element);
            $oldElement = $element;
            $sizeX += $element->getWidth() + $this->margin;
        }

        $this->setWidth($sizeX);

        return $frame->render($domDocument);
    }
124182
protected function removeContentFromVoidElements(DOMDocument $ir)
	{
		foreach ($this->query('//element[@void="yes"]') as $element)
		{
			$id    = $element->getAttribute('id');
			$query = './/closeTag[@id="' . $id . '"]/following-sibling::*';

			$this->removeNodes($ir, $query, $element);
		}
	}
996478
protected function serializeChildren(DOMElement $ir)
	{
		$php = '';
		foreach ($ir->childNodes as $node)
		{
			if ($node instanceof DOMElement)
			{
				$methodName = 'serialize' . ucfirst($node->localName);
				$php .= $this->$methodName($node);
			}
		}

		return $php;
	}
437542
public function WriteContent() {
        $output = $this->WriteGetListMethod();
        $output .= PhpCodeSnippets::CRLF;
        fwrite($this->writer, $output);
    }