private function adjustMetaDate(ezcDocumentOdt $odt)
 {
     $fakeDate = '2009-12-04T10:14:00+01:00';
     $creationDate = $odt->getDomDocument()->getElementsByTagnameNS(ezcDocumentOdt::NS_ODT_META, 'creation-date')->item(0);
     $creationDate->nodeValue = $fakeDate;
     $date = $odt->getDomDocument()->getElementsByTagnameNS(ezcDocumentOdt::NS_DC, 'date')->item(0);
     $date->nodeValue = $fakeDate;
 }
예제 #2
0
 /**
  * Create document from structure
  *
  * Build a ezcDocumentDocument object from the structure created during the
  * visiting process.
  *
  * @param mixed $content
  * @return ezcDocumentDocument
  */
 protected function createDocument($content)
 {
     $document = $content->ownerDocument;
     $odt = new ezcDocumentOdt();
     $odt->setDomDocument($document);
     return $odt;
 }
 /**
  * @dataProvider getTestDocuments
  */
 public function testCommonConversions($from, $to)
 {
     $tempDir = $this->createTempDir('odt_tests_') . '/';
     $imgDir = $tempDir . 'img';
     mkdir($imgDir);
     $options = new ezcDocumentOdtOptions();
     $options->imageDir = $imgDir;
     $document = new ezcDocumentOdt();
     $document->setFilters(array(new ezcDocumentOdtImageFilter($options), new ezcDocumentOdtElementFilter(), new ezcDocumentOdtStyleFilter()));
     $document->loadFile($from);
     $docbook = $document->getAsDocbook();
     $xml = $docbook->save();
     $xml = $this->verifyAndReplaceImages(basename($to, '.xml'), $xml);
     // Store test file, to have something to compare on failure
     file_put_contents($tempDir . basename($to), $xml);
     $this->assertTrue($docbook->validateString($xml));
     if (!is_file($to)) {
         $this->fail("Missing comparison file '{$to}'.");
     }
     $this->assertEquals(file_get_contents($to), $xml, 'Document not visited as expected.');
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }
예제 #4
0
<?php

require 'tutorial_autoload.php';
$docbook = new ezcDocumentDocbook();
$docbook->loadFile('docbook.xml');
$odt = new ezcDocumentOdt();
$odt->createFromDocbook($docbook);
echo $odt->save();
예제 #5
0
function fodt2text($filename,$id) {    
    Env::useLibrary('ezcomponents');
    
    $odt = new ezcDocumentOdt();
    $odt->loadFile( $filename );

    $docbook = $odt->getAsDocbook();

    $converter = new ezcDocumentDocbookToRstConverter();
    $rst = $converter->convert( $docbook );
    
    $file_path_txt = 'tmp/fodt2text_' . $id . '.txt';
    file_put_contents( $file_path_txt, $rst );
    $content = file_get_contents($file_path_txt); //Guardamos archivo.txt en $archivo
    unlink($file_path_txt);
    return $content;
}