openMemory(); /* * Set indenting using three spaces, * so output is formatted */ $this->setIndent(true); $this->setIndentString(' '); /* * Create the XML document */ $this->startDocument('1.0', 'UTF-8'); } /** * Starts Dia Document * * dia document starts by first initializing dia:diagram tag * then dia:diagramdata contains all the attributes that needed * to define the document, then finally a Layer starts which * holds all the objects. * * @see XMLWriter::startElement() * @see XMLWriter::writeAttribute() * @see XMLWriter::writeRaw() * * @param string $paper the size of the paper/document * @param float $topMargin top margin of the paper/document in cm * @param float $bottomMargin bottom margin of the paper/document in cm * @param float $leftMargin left margin of the paper/document in cm * @param float $rightMargin right margin of the paper/document in cm * @param string $orientation orientation of the document, portrait or landscape */ public function startDiaDoc( $paper, $topMargin, $bottomMargin, $leftMargin, $rightMargin, $orientation ): void { $isPortrait = 'false'; if ($orientation === 'P') { $isPortrait = 'true'; } $this->startElement('dia:diagram'); $this->writeAttribute('xmlns:dia', 'http://www.lysator.liu.se/~alla/dia/'); $this->startElement('dia:diagramdata'); $this->writeRaw( ' #' . $paper . '# ' ); $this->endElement(); $this->startElement('dia:layer'); $this->writeAttribute('name', 'Background'); $this->writeAttribute('visible', 'true'); $this->writeAttribute('active', 'true'); } /** * Ends Dia Document * * @see XMLWriter::endElement() * @see XMLWriter::endDocument() */ public function endDiaDoc(): void { $this->endElement(); $this->endDocument(); } /** * Output Dia Document for download * * @see XMLWriter::flush() * * @param string $fileName name of the dia document */ public function showOutput($fileName): void { if (ob_get_clean()) { ob_end_clean(); } $output = $this->flush(); ResponseRenderer::getInstance()->disable(); Core::downloadHeader( $fileName, 'application/x-dia-diagram', strlen($output) ); print $output; } }