Example #1
0
 public function viewAction($path)
 {
     $doc = $this->getSource($path);
     $document = new ezcDocumentConfluenceWiki();
     $document->options->errorReporting = E_PARSE | E_ERROR | E_WARNING;
     $document->loadString($doc);
     $docbook = $document->getAsDocbook();
     $converter = new ezcDocumentDocbookToHtmlConverter();
     $converter->options->styleSheet = null;
     // Add custom CSS style sheets
     $converter->options->styleSheets = array('/styles/screen.css');
     $html = $converter->convert($docbook);
     $xml = $html->save();
     $doc = new DOMDocument();
     $doc->loadXML($xml);
     $xp = new DOMXPath($doc);
     $xp->registerNamespace("xhtml", "http://www.w3.org/1999/xhtml");
     $res = $xp->query("/xhtml:html/xhtml:body/node()");
     $html = "";
     foreach ($res as $node) {
         $html .= $doc->saveXML($node);
     }
     $html .= '<div id="action"><a href="?action=edit" accesskey="e">Edit</a></div>';
     return $html;
 }
 public function testWithStylesheets()
 {
     $from = dirname(__FILE__) . '/files/docbook/xhtml/s_021_field_list.xml';
     $to = dirname(__FILE__) . '/files/docbook/xhtml/s_021_field_list_stylesheets.html';
     $doc = new ezcDocumentDocbook();
     $doc->loadFile($from);
     $converter = new ezcDocumentDocbookToHtmlConverter();
     $converter->options->formatOutput = true;
     $converter->options->dublinCoreMetadata = true;
     $converter->options->styleSheets = array('foo.css', 'http://example.org/bar.css');
     $created = $converter->convert($doc);
     $this->assertTrue($created instanceof ezcDocumentXhtml);
     // Store test file, to have something to compare on failure
     $tempDir = $this->createTempDir('docbook_html_custom_') . '/';
     file_put_contents($tempDir . basename($to), $xml = $created->save());
     $this->assertEquals(file_get_contents($to), $xml);
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }
<?php

require 'tutorial_autoload.php';
$docbook = new ezcDocumentDocbook();
$docbook->loadFile('docbook.xml');
$converter = new ezcDocumentDocbookToHtmlConverter();
// Remove the inline CSS
$converter->options->styleSheet = null;
// Add custom CSS style sheets
$converter->options->styleSheets = array('/styles/screen.css');
$html = $converter->convert($docbook);
echo $html->save();
Example #4
0
 /**
  * Create document from docbook document
  *
  * A document of the docbook format is provided and the internal document
  * structure should be created out of this.
  *
  * This method is required for all formats to have one central format, so
  * that each format can be compiled into each other format using docbook as
  * an intermediate format.
  *
  * You may of course just call an existing converter for this conversion.
  *
  * @param ezcDocumentDocbook $document
  * @return void
  */
 public function createFromDocbook(ezcDocumentDocbook $document)
 {
     if ($this->options->validate && $document->validateString($document) !== true) {
         $this->triggerError(E_WARNING, "You try to convert an invalid docbook document. This may lead to invalid output.");
     }
     $this->path = $document->getPath();
     $converter = new ezcDocumentDocbookToHtmlConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $doc = $converter->convert($document);
     $this->document = $doc->getDomDocument();
 }
Example #5
0
 /**
  * Create document from docbook document
  *
  * A document of the docbook format is provided and the internal document
  * structure should be created out of this.
  *
  * This method is required for all formats to have one central format, so
  * that each format can be compiled into each other format using docbook as
  * an intermediate format.
  *
  * You may of course just call an existing converter for this conversion.
  * 
  * @param ezcDocumentDocbook $document 
  * @return void
  */
 public function createFromDocbook(ezcDocumentDocbook $document)
 {
     $converter = new ezcDocumentDocbookToHtmlConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $doc = $converter->convert($document);
     $this->document = $doc->getDomDocument();
 }