From: <yaw...@us...> - 2006-03-08 23:15:33
|
Revision: 8 Author: yawnster Date: 2006-03-08 15:15:08 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=8&view=rev Log Message: ----------- - Restructured class inclusion, it now uses __autoload() to do this automatically. - Now using a single file extension, (.php), this was done to help the __autoload() function, please check your Inbox for documentation on this. - Built in a UI to TestOutput.php to select Document Type - Removed all traces of .php3-5 extensions from the build.xml file. Modified Paths: -------------- poc/build.xml Added Paths: ----------- poc/src/OpenDocument.php poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentContent.php poc/src/OpenDocumentContentBody.php poc/src/OpenDocumentContentBodyText.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentStyle.php poc/src/TestOutput.php poc/src/ZipFile.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-08 10:31:35 UTC (rev 7) +++ poc/build.xml 2006-03-08 23:15:08 UTC (rev 8) @@ -22,11 +22,7 @@ <coverage-setup database="reports/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> - <include name="**/*.php3"/> - <include name="**/*.php5"/> <exclude name="**/*Test.php"/> - <exclude name="**/*Test.php3"/> - <exclude name="**/*Test.php5"/> </fileset> </coverage-setup> @@ -36,8 +32,6 @@ <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> - <include name="**/*Test.php3"/> - <include name="**/*Test.php5"/> </fileset> </batchtest> </phpunit2> @@ -57,8 +51,6 @@ <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> - <include name="**/*Test.php5"/> - <include name="**/*Test.php3"/> </fileset> </batchtest> </phpunit2> Added: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php (rev 0) +++ poc/src/OpenDocument.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,34 @@ +<?php +/** + * OpenDocument interface + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 5 $ + * @package OpenDocument + * + * $Id: OpenDocument.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ +interface OpenDocument { + /** + * get the whole OpenDocument as string. + */ + public function get(); + + public function getMeta(); + + public function getContent(); + + public function getStyle(); + + /** + * get mimetype of the document + * + * @return string Mimetype of the document + */ + public function getMimeType(); + + // public function getSetting(); +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php (rev 0) +++ poc/src/OpenDocumentAbstract.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,77 @@ +<?php +/** + * OpenDocumentAbstract Class + * (C) by Norman Markgraf in 2006 + * + * OpenDocumentAbstract is the basic class for all OpenDocument classes + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +class OpenDocumentAbstract { + /** + * + */ + const Revision = "ALPHA"; + const Release = "0.4.1"; + const Copyright = "(C) in 2006 by Norman Markgraf published under GPL 2.0"; + const PackageName = "OpenDocumentPHP"; + + protected $logger; + + protected $mimetype; + + /** + * This is the storage for all OpenDocument objects + */ + protected $DocumentObjects; + + public function __construct( $mimetype = 0 ) { + $this->logger = &Log::factory( "null", "", "OpenDocument" ); + //$this->logger = &Log::factory( "file", "d:/PHP/OpenDocumentPHP.log", "OpenDocument" ); + $this->logger->debug( "Constructing OpenDocumentAbstract." ); + + $this->DocumentObjects = array(); + + if (!empty($mimetype)) { + $this->mimetype = $mimetype; + } + } + + /** + * + */ + public function __destruct() { + $this->logger->debug( "OpenDocumentAbstract destructed." ); + $this->logger->close(); + } + + final public function getRevision() { + return self::Revision; + } + + final public function getRelease() { + return self::Release.".".self::Revision; + } + + final public function getPackageInformation() { + return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; + } + + final public function attachObserverToLogger( $observer ) { + $this->logger->attach( $observer ); + } + + final public function getMimeType() { + return $this->mimetype; + } + + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php (rev 0) +++ poc/src/OpenDocumentContent.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,128 @@ +<?php +/** + * OpenDocumentContent Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentContent.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +class OpenDocumentContent extends OpenDocumentObjectAbstract { + + private $root; + private $meta; + private $FontFaceDecl; + private $body; + private $text; + + /**I + * + */ + public function __construct( $dom=0 ) { + parent::__construct(); + $this->logger->debug( "Constructing OpenDocumentContent." ); + if (empty($dom)) { + // this is part of a package document + $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->dom->formatOutput = true; + + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-content" ); + $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + + $this->content = $this->dom; + } else { + // this is part of a single document + $this->dom = $dom; + $this->content = $this->dom; + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:content" ); + } + $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->body = new OpenDocumentContentBody( $this->dom ); +/* + $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); + $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); +*/ + + } + + /** + * + */ + public function __destruct() { + unset( $this->dom ); + unset( $this->root ); + unset( $this->meta ); + unset( $this->FontFaceDecl ); + } + + public function addNoScript() { + $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:script" ) ); + } + + public function addFontFace( $name, $fontFamily ) { + $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); + $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); + $font->setAttributeNS( self::NS_SVG, "svg:font-family", $fontFamily ); + $this->FontFaceDecl->appendChild( $font ); + unset( $font ); + } + + public function addAutomaticStyles() { + + } + + public function addNoAutomaticStyles() { + $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:automatics-sytles" ) ); + } + + +/* + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + </text:sequence-decls> + +*/ + + public function getBody() { + return $this->body; + } + + + /** + * + */ + public function commit() { + $this->root->appendChild( $this->FontFaceDecl ); + // $this->body->appendChild( $this->text ); + $this->root->appendChild( $this->body->get() ); + $this->content->appendChild( $this->root ); + $this->dom->normalize(); + $this->isCommited = true; + } + + /** + * @return + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + return $this->dom; + } + + /** + * + */ + final public function save( $filename ) { + $this->get()->save( $filename ); + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentContentBody.php =================================================================== --- poc/src/OpenDocumentContentBody.php (rev 0) +++ poc/src/OpenDocumentContentBody.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,76 @@ +<?php +/** + * OpenDocumentContentBody Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 2 $ + * @package OpenDocument.Content.Body + * @since POC 0.5 + * + * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + */ + +class OpenDocumentContentBody extends OpenDocumentObjectAbstract { + + private $DomFragment; + private $body; + + private $Fragments; + + public function __construct( $dom ) { + parent::__construct(); + $this->logger->debug( "Constructing OpenDocumentContentBody." ); + + $this->dom = $dom; + $this->BodyFragment = $this->dom->createDocumentFragment(); + $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); + $this->Fragments = array(); + } + + public function commit() { + $this->logger->debug( "OpenDocumentContentBody->commit()" ); + foreach( $this->Fragments as $namespace => $class ) { + $tmp = $class->get(); + if (!empty( $tmp )) { + $this->BodyFragment->appendChild( $class->get() ); + } + } + if (!empty( $this->BodyFragment )) { + $this->body->appendChild( $this->BodyFragment ); + } + $this->isCommited = true; + } + + private function getByNamespace( $NS, $class ) { + $this->logger->debug( "OpenDocumentContentBody->getByNamespace(\"".$NS."\", \"".$class."\")" ); + if (!array_key_exists( $NS, $this->Fragments ) ) { + $this->Fragments[ $NS ] = new $class( $this->dom ); + } + return $this->Fragments[ $NS ]; + } + + public function getText() { + $this->logger->debug( "OpenDocumentContentBody->getText()" ); + return $this->getByNamespace( self::NS_TEXT, "OpenDocumentContentBodyText" ); + } + + public function getTable() { + $this->logger->debug( "OpenDocumentContentBody->getTable()" ); + return $this->getByNamespace( self::NS_TABLE, "OpenDocumentContentBodyTable" ); + } + + /** + * @return DOMDocumentFragment body fragment + */ + final public function get() { + $this->logger->debug( "OpenDocumentContentBody->get()" ); + if (!$this->isCommited) { + $this->commit(); + } + return $this->body; + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentContentBodyText.php =================================================================== --- poc/src/OpenDocumentContentBodyText.php (rev 0) +++ poc/src/OpenDocumentContentBodyText.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,78 @@ +<?php +/** + * OpenDocumentContentBodyText Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 2 $ + * @package OpenDocument.Content.Body.Text + * @since POC 0.5 + * + * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + */ + +class OpenDocumentContentBodyText extends OpenDocumentObjectAbstract { + + public function __construct( $dom ) { + parent::__construct(); + $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); + + $this->dom = $dom; + $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); + } + + public function commit() { + $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); + $this->isCommited = true; + } + + public function getTextParagraph( $styleName, $parText=0 ) { + $this->logger->debug( "OpenDocumentContentBodyText->getTextParagraph(\"".$styleName."\",\"".$parText."\")" ); + if (empty($parText)) { + $par = $this->dom->createElementNS( self::NS_TEXT, "text:p" ); + } else { + $par = $this->dom->createElementNS( self::NS_TEXT, "text:p", $parText ); + } + $par->setAttributeNS( self::NS_STYLE, "style:name", $styleName ); + return $par; + } + + public function addToText( $Node ) { + $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); + $this->text->appendChild( $Node ); + } + + public function getTextHeading( $styleName, $headText=0 ) { + $this->logger->debug( "OpenDocumentContentBodyText->getTextHeading()" ); + if (empty($headText)) { + $head = $this->dom->createElementNS( self::NS_TEXT, "text:h" ); + } else { + $head = $this->dom->createElementNS( self::NS_TEXT, "text:h", $headText ); + } + $head->setAttributeNS( self::NS_STYLE, "style:name", $styleName ); + return $head; + } + + public function addNoForms() { + $this->logger->debug( "OpenDocumentContentBodyText->addNoForms()" ); + $forms = $this->dom->createElementNS( self::NS_OFFICE, "office:forms" ); + + $forms->setAttributeNS( self::NS_FORM, "form:automatic-focus", "false" ); + $forms->setAttributeNS( self::NS_FORM, "form:apply-design-mode", "false" ); + + $this->text->appendChild( $forms ); + unset( $forms ); + } + + /** + * @return DOMDocumentFragment body fragment + */ + final public function get() { + $this->logger->debug( "OpenDocumentContentBodyText->get()" ); + if (!$this->isCommited) { + $this->commit(); + } + return $this->text; + } +} +?> \ No newline at end of file Added: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php (rev 0) +++ poc/src/OpenDocumentFactory.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,38 @@ +<?php +/** + * OpenDocumentFactoy Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 7 $ + * @package OpenDocument + * + * $Id: OpenDocumentFactory.php5 7 2006-03-08 10:31:35Z nmarkgraf $ + */ + +function __autoload($class_name) { + if($class_name != 'Log_null') + { + require_once("$class_name.php"); + } +} + +class OpenDocumentFactory { + +/** + * Creates a OpenDocument. + * + * @return OpenDocument + */ + static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType="application/vnd.oasis.opendocument.text" ) { + if ( $singleDocument ) { + return new OpenDocumentSingle( $mimeType ); + return 0; + } else { + return new OpenDocumentPackage( $documentName, $documentPath, $mimeType ); + } + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php (rev 0) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,78 @@ +<?php +/** + * OpenDocumentFactoyTest Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 4 $ + * @package OpenDocumentTest + * + * $Id: OpenDocumentFactory.php5 4 2006-03-06 15:15:30Z nmarkgraf $ + */ +require_once "PHPUnit2/Framework/TestCase.php"; +require_once( "OpenDocumentFactory.php" ); +require_once( "OpenDocumentSingle.php" ); +require_once( "OpenDocumentPackage.php" ); + +class OpenDocumentFactoryTest extends PHPUnit2_Framework_TestCase { + + function testFactoryForSingleDocument() { + $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); + $this->assertNotNull( $OD ); + + $this->assertType( "OpenDocumentSingle", $OD ); + + unset( $OD ); + } + + function testFactoryForMimetypeInSingleDocument() { + $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); + + $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly." ); + + $ODA = OpenDocumentFactory::createOpenDocument( "test.odf", "", true, "TestMimeType" ); + $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly." ); + + unset( $OD ); + unset( $ODA ); + } + + function testFactoryForPackageDocument() { + $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", false ); + $this->assertNotNull( $OD ); + + $this->assertType( "OpenDocumentPackage", $OD ); + + unset( $OD ); + } + + function testFactoryForMimetypeInPackageDocument() { + $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", false ); + + $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly." ); + + $ODA = OpenDocumentFactory::createOpenDocument( "test.odf", "", false, "TestMimeType" ); + $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly." ); + + unset( $OD ); + unset( $ODA ); + } + + +/** + * Creates a OpenDocument. + * + * @return OpenDocument + static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType="application/vnd.oasis.opendocument.text" ) { + if ( $singleDocument ) { + return new OpenDocumentSingle( $mimeType ); + return 0; + } else { + return new OpenDocumentPackage( $documentName, $documentPath, $mimeType ); + } + } + */ + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php (rev 0) +++ poc/src/OpenDocumentManifest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,125 @@ +<?php +/** + * OpenDocumentManifest.php + * + * Release information: + * 0.1 - 0.3 : 17/21-Feb-2006 (nm) Initial programmings + * 0.4 : 22-Feb-2006 (nm) Declared <c>getManifest<c> as deprecated. + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 5 $ + * @package OpenDocument + * + * $Id: OpenDocumentManifest.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ + +class OpenDocumentManifest extends OpenDocumentObjectAbstract { + const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; + const odmSYSTEM = "Manifest.dtd"; + const odmROOT = "manifest:manifest"; + + private $root; + + /** + * + */ + public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { + parent::__construct( $mimetype ); + $this->createManifestDOM(); + } + + /** + * + */ + public function __destruct() { + unset( $dom ); + unset( $root ); + unset( $mimetype ); + } + + /** + * + * @access private + */ + final private function createManifestDOM() { + $impl = new DOMImplementation; + + $dtd = $impl->createDocumentType( self::odmROOT, self::odmPUBLIC, self::odmSYSTEM ); + + $this->dom = $impl->createDocument( "", "", $dtd ); + $this->dom->encoding = "UTF-8"; + $this->dom->formatOutput = true; + + $this->root = $this->dom->createElementNS( self::NS_MANIFEST, self::odmROOT ); + + $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:media-type", $this->mimetype ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", "/" ); + + $this->root->appendChild( $node ); + + unset( $impl ); + unset( $dtd ); + unset( $node ); + } + + /** + * + */ + final public function addEntryToManifest( $fullpath, $mimetype, $size=-1, $encrypt=0 ) { + $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:mediatype", $mimetype ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", $filename ); + if ( $size >= 0 ) { + $node->setAttributeNS( self::NS_MANIFEST, "manifest:size", $size ); + } + if (!empty($encrypt)) { + $node->appendChild( $encrypt ); + } + $this->root->appendChild( $node ); + unset( $node ); + } + + /** + * + */ + final public function createEncryptionData( ) { + return $this->dom->createElmentNS( self::NS_MANIFEST, "manifest:encryption-data" ); + } + + /** + * Returns the whole OpenDocument Manifest as DOM. + * + * @access public + * + * @return DOM manifest as DOM. + */ + final public function get() { + $this->dom->appendChild( $this->root ); + $this->dom->normalize(); + return $this->dom; + } + + /** + * Same as <c>get<c>! + * + * @deprecated + */ + final public function getManifest() { + return $this->get(); + } + + /** + * Save the whole OpenDocument Manifest in a file + * + * @access public + * + * @param string name of file + */ + final public function save( $filename ) { + $this->get()->save( $filename ); + } +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php (rev 0) +++ poc/src/OpenDocumentManifestTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,31 @@ +<?php +/** + * Test Class for OpenDocumentManifest + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocumentUnitTest + * + * $Id: OpenDocumentManifestTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "OpenDocumentManifest.php"; + +class OpenDocumentManifestTest extends PHPUnit2_Framework_TestCase { + + function testConstrution() { + + $ODM = new OpenDocumentManifest(); + + $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + + $ODMMT = new OpenDocumentManifest( "alternateMimeType" ); + + $this->assertNotNull( $ODMMT, "Error constructing OpenDocumentManifest with a given mimetype." ); + + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php (rev 0) +++ poc/src/OpenDocumentMeta.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,220 @@ +<?php +/** + * OpenDocumentMeta Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocument + * + * $Id: OpenDocumentMeta.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ + +class OpenDocumentMeta extends OpenDocumentObjectAbstract { + + private $root; + private $meta; + + /** + * + */ + public function __construct( $dom=0 ) { + parent::__construct(); + + $this->logger->debug( "Constructing OpenDocumentMeta." ); + + if (empty($dom)) { + // this is part of a package document + $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->dom->formatOutput = true; + + $node = $this->dom->createElementNS( self::NS_OFFICE, "office:document-meta" ); + $node->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + + $this->dom->appendChild( $node ); + $this->meta = $node; + unset( $node ); + } else { + // this is part of a single document + $this->dom = $dom; + $this->meta = $this->dom; + } + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); + } + + /** + * + */ + public function __destruct() { + unset( $dom ); + unset( $root ); + unset( $meta ); + + $this->logger->debug( "OpenDocumentMeta destructed." ); + + parent::__destruct(); + } + + public function load( $filename ) { + $tmpDom = new DOMDocument(); + + if($tmpDom->load( $filename ) === false) { + trigger_error( 'Could not parse XML contents in OpenDocument file' ); + $this->logger->crit( "Could not parse XML contents in OpenDocument file" ); + return false; + } + + $OFFICE_PREFIX = $tmpDom->getElementsByTagNameNS( self::NS_OFFICE, "*").item( 0 )->prefix; + + // Figgure out if file is part of a package or a single document; + $isSingleDoc = (count($tmpDom->getElementsByTagNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta" ))==0); + if ($isSingleDoc) { + $this->dom = $tmpDoc; + $this->meta = $tmpDoc; + } else { + $this->dom = $tmpDoc; + $this->meta = $tmtDoc->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta").item( 0 ); + } + + $this->root = $this->dom->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":meta").item( 0 ); + + return true; + } + + /** + * + */ + public function addDublinCore( $dc, $value) { + $this->logger->debug( "OpenDocumentMeta->addDublinCore: ". $value ."." ); + $node = $this->dom->createElementNS( self::NS_DC, "dc:".$dc, $value ); + $this->root->appendChild( $node ); + unset( $node ); + } + + /** + * + */ + public function getDublicCore( $dc ) { + $retValue = ""; + $nodelist = $this->dom->getElementsByTagNameNS( self::NS_DC, $dc ); + if ($nodelist->length == 1) { + $retValue = $nodelist->item( 0 )->nodeValue; + } + unset( $nodelist ); + $this->logger->debug( "OpenDocumentMeta->getDublinCore: ". $retValue ."." ); + return $retValue; + } + + /** + * + */ + public function addGenerator( $generator ) { + $lgenerator = ""; + + if (empty($generator)) { + $lgenerator = "OpenDocmentPHP/".$this->getRelease(); + } else { + $lgenerator = $generator; + } + + $this->logger->debug( "OpenDocumentMeta->addGenerator: ". $lgenerator ."." ); + + $node = $this->dom->createElementNS( self::NS_META, "meta:generator", $lgenerator ); + + $this->root->appendChild( $node ); + + unset( $lgenerator ); + } + + /** + * + */ + public function getGenerator() { + $retValue = ""; + + $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "generator" ); + + if ($nodelist->length == 1) { + $retValue = $nodelist->item( 0 )->nodeValue; + } + unset( $nodelist ); + $this->logger->debug( "OpenDocumentMeta->getGenerator: ". $retValue ."." ); + return $retValue; + } + + /** + * + */ + public function addInitialCreator( $initialCreator ) { + $this->logger->debug( "OpenDocumentMeta->addInitialCreator: ". $initialCreator ."." ); + $node = $this->dom->createElementNS( self::NS_META, "meta:initial-creator", $initialCreator ); + $this->root->appendChild( $node ); + } + + /** + * + */ + public function getInitialCreator() { + $retValue = ""; + $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "initial-creator" ); + if ($nodelist->length == 1) { + $retValue = $nodelist->item( 0 )->nodeValue; + } +// unset( $nodelist ); + $this->logger->debug( "OpenDocumentMeta->getInitialCreator: ". $retValue ."." ); + return $retValue; + } + + /** + * + */ + public function addUserDefinedMetadata( $name, $type, $value ) { + $node = $this->dom->createElementNS( self::NS_META, "meta:user-defined" ); + $node->setAttributeNS( self::NS_META, "meta:name", $name ); + if ( !empty( $type ) ) { + $node->setAttributeNS( self::NS_META, "meta:type", $type ); + } + if ( !empty( $value ) ) { + $node->setAttributeNS( self::NS_META, "meta:value", $value ); + } + $this->root->appendChild( $node ); + unset( $node ); + } + + /** + * + */ + public function commit() { + $this->meta->appendChild( $this->root ); + $this->dom->normalize(); + $this->isCommited = true; + $this->logger->debug( "OpenDocumentMeta->commit()." ); + } + + /** + * @depricated + */ + final public function getMeta() { + return $this->get(); + } + + /** + * @return + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + $this->logger->debug( "OpenDocumentMeta->get()." ); + return $this->dom; + } + + /** + * + */ + final public function save( $filename ) { + $this->logger->debug( "OpenDocumentMeta->save(". $filename .")." ); + $this->get()->save( $filename ); + } + +} \ No newline at end of file Added: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php (rev 0) +++ poc/src/OpenDocumentMetaTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,129 @@ +<?php +/** + * Test class for OpenDocumentMeta + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocumentUnitTest + * + * $Id: OpenDocumentMetaTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "OpenDocumentMeta.php"; + + class OpenDocumentMetaTest extends PHPUnit2_Framework_TestCase + { + /** + * namespace OpenDocument office + */ + const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + /** + * namespace Dublin Core + */ + const NS_DC = "http://purl.org/dc/elements/1.1"; + + public function testConstructWithoutDom(){ + $ODM = new OpenDocumentMeta(); + + $this->assertNotNull( $ODM ); + + $resultDom = $ODM->get(); + $this->assertNotNull($resultDom, "No result." ); + //$this->assertType(new DOMC$resultDom, new DOMDocument(), "Result is not for type DOMDocument!" ); + + $xpath = new DOMXPath( $resultDom ); + $xpath->registerNamespace( "office", self::NS_OFFICE ); + + // test for right root tag + $query = "/office:document-meta"; + $entries = $xpath->query( $query ); + $this->assertEquals( 1, $entries->length, "Wrong root tag." ); + + // test for right version + $query = '/office:document-meta[@office:version="1.0"]'; + $entries = $xpath->query( $query ); + $this->assertEquals( 1, $entries->length, "Wrong document version." ); + + // test for right body tag + $query = "/office:document-meta/office:meta"; + $entries = $xpath->query( $query ); + $this->assertEquals( 1, $entries->length, "Wrong meta tag" ); + + unset( $ODM ); + unset( $resultDom ); + unset( $query ); + unset( $entries ); + } + + public function testConstructWithDom(){ + $testDom = new DOMDocument(); + + $ODM = new OpenDocumentMeta( $testDom ); + $this->assertNotNull( $ODM ); + + $resultDom = $ODM->get(); + $this->assertNotNull($resultDom, "No result." ); + //$this->assertType($resultDom, new DOMDocument(), "Result is not for type DOMDocument!" ); + + $xpath = new DOMXPath( $resultDom ); + $xpath->registerNamespace( "office", self::NS_OFFICE ); + + + // test for right root tag + $query = "/office:meta"; + $entries = $xpath->query( $query ); + $this->assertEquals( 1, $entries->length, "Wrong meta tag" ); + + unset( $ODM ); + unset( $resultDom ); + unset( $query ); + unset( $entries ); + } + + public function testAddGetDublinCore() { + $ODM = new OpenDocumentMeta(); + + $this->assertNotNull( $ODM ); + + $this->assertEquals( "", $ODM->getDublicCore( "xxx" ), "Returned Dublin Core should be empty, was not." ); + + $ODM->addDublinCore( "peek", "poke"); + $ODM->commit(); + + $this->assertEquals( "poke", $ODM->getDublicCore( "peek"), "Dublin Core entry was not correctly returned." ); + unset( $ODM ); + } + + public function testAddGetGenerator() { + $ODM = new OpenDocumentMeta(); + + $this->assertNotNull( $ODM ); + + $this->assertEquals( "", $ODM->getGenerator(), "Generator should be empty, was not." ); + + $ODM->addGenerator( "TEST" ); + $ODM->commit(); + + $this->assertEquals( "TEST", $ODM->getGenerator(), "Generator was not correctly returned. (".$ODM->getGenerator().")" ); + + unset( $ODM ); + } + + public function testAddGetInitialCreator() { + $ODM = new OpenDocumentMeta(); + + $this->assertNotNull( $ODM ); + + $this->assertEquals( "", $ODM->getInitialCreator(), "InitialCreator should be empty, was not." ); + + $ODM->addInitialCreator( "InitCreator" ); + $ODM->commit(); + + $this->assertEquals( "InitCreator", $ODM->getInitialCreator(), "InitialCreator was not correctly returned." ); + + unset( $ODM ); + } + + + } \ No newline at end of file Added: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php (rev 0) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,115 @@ +<?php +/** + * OpenDocumentObjectAbstract Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentObjectAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +class OpenDocumentObjectAbstract extends OpenDocumentAbstract { + + /** + * namespace Dublin Core + */ + const NS_DC = "http://purl.org/dc/elements/1.1"; + + /** + * namespace OpenDocument meta + */ + const NS_META = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; + + /** + * namespace OpenDocument office + */ + const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + + /** + * namespace OpenDocument manifest + */ + const NS_MANIFEST = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; + + /** + * namespace OpenDocument style + */ + const NS_STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; + + /** + * namespace OpenDocument svg + */ + const NS_SVG = "urn:oasis:names:tc:openedocument:xmlsns:svg-compartible:1.0"; + + /** + * namespace OpenDocument fo (formation objects) + */ + const NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compartible:1.0"; + + /** + * namespace OpenDocument text + */ + const NS_TEXT = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"; + + /** + * namespace OpenDocument draw + */ + const NS_DRAW = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; + + /** + * namespace OpenDocument table + */ + const NS_TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"; + + /** + * namespace OpenDocument number + */ + const NS_NUMBER = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; + + /** + * namespace OpenDocument chart + */ + const NS_CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; + + /** + * namespace OpenDocument form + */ + const NS_FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; + + + protected $dom; + + protected $isCommited; + + /** + * + */ + public function __construct( $mimetype = 0 ) { + parent::__construct( $mimetype ); + $this->logger->debug( "Constructing OpenDocumentObjectAbstract." ); + $this->isCommited = false; + } + + /** + * + */ + public function __destruct() { + $this->logger->debug( "OpenDocumentObjectAbstract destructed." ); + parent::__destruct(); + } + + public function get() { + return $this->dom; + } + + /** + * + */ + public function save( $filename ) { + $tmp =& $this->dom; + + $tmp->save( $filename ); + } +} +?> \ No newline at end of file Added: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php (rev 0) +++ poc/src/OpenDocumentPackage.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,233 @@ +<?php +/** + * OpenDocumentPackage Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 5 $ + * @package OpenDocument + * + * $Id: OpenDocumentPackage.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ + +class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { + private $manifest; + private $packagename; + private $packagetmp; + private $zip; + private $isCommited; + // + public $tmp = "c:/TEMP/"; + public $path = ""; + + /** + * + */ + public function __construct( $documentName=0, $documentPath=0, $mimetype="application/vnd.oasis.opendocument.text" ) { + parent::__construct( $mimetype ); + + $this->logger->debug( "Constructing OpenDocumentPackage." ); + + $this->isCommited = false; + + $this->logger->debug( "Generating ZipFile object." ); + $this->zip = new ZipFile; + $this->logger->debug( "Generating OpenDocumentManifest with mimetype \"".$this->getMimeType()."\"." ); + $this->manifest = new OpenDocumentManifest( $this->getMimeType() ); + + if ( !empty( $documentName ) ) { + $this->setPackageName( $documentName ); + if ( !empty( $documentPath ) ) { + $this->path = $documentPath; + } + } + } + + /** + * + */ + public function __destruct() { + $this->logger->debug( "Destructing OpenDocumentPackage." ); + $this->removeTmpPackage(); + + unset( $this->manifest ); + unset( $this->packagename ); + unset( $this->packagetmp ); + unset( $this->tmp ); + unset( $this->path ); + + $this->logger->debug( "OpenDocumentPackage destructed." ); + + parent::__destruct(); + } + + /** + * + */ + public function createPackage() { + //$this->compartibility->makeDir( $this->packagetmp ); + } + + /** + * + */ + private function writeDOMToPackage( $fullpath, $dom ) { + //$dom->save( str_replace( "\\", "/", $this->packagetmp . $fullpath) ); + $tmp = str_replace( "\\", "/", $fullpath ); + + $this->logger->debug( "Write DOM to package, use fullpath \"" . $tmp . "\"." ); + $this->zip->addFile( $dom->saveXML(), $tmp ); + + unset( $tmp ); + } + + /** + * + */ + public function writeZIPFile( $data, $alt=0 ) { + if (empty($alt)) { + $tmp = $this->path . $this->packagename; + } else { + $tmp = $alt; + } + clearstatcache(); + + $this->logger->debug( "OpenDocumentPackage->writeZIPFile: Write zip file to \"". $tmp ."\"" ); + + if ( file_exists( $tmp ) ) { + $this->logger->warning( "OpenDocumentPackage->writeZIPFile: Found old file \"". $tmp ."\", so I remove it first!" ); + unlink( $tmp ); + } + $handle = fopen( $tmp, "wb" ); + fputs( $handle, $data ); + fclose( $handle ); + unset( $tmp ); + } + + /** + * + */ + private function removeTmpPackage() { + // $this->compartibility->removeDir( $this->packagetmp ); + } + + /** + * + */ + private function makeSubDir( $path ) { + //$this->compartibility->makeDir( $this->packagetmp . $this->compartibility->sep . $path ); + } + + /** + * + */ + public function setPackageName( $filename ) { + global $logger; + $this->logger->debug( "OpenDocumentPackage->setPackageName(" . $filename . ")." ); + $this->packagename = $filename; + //$this->packagetmp = $this->tmp . $filename . ".tmp" . $this->compartibility->sep; + $this->packagetmp = $this->tmp . $filename . ".tmp/"; + $this->logger->debug( "OpenDocumentPackage->set packagetmp to \"" . $this->packagetmp . "\" ..." ); + } + + /** + * + */ + public function getPackageName() { + return $this->packagename; + } + + /** + * + */ + public function addManifest( $manifest ) { + $this->logger->debug( "OpenDocumentPackage->addManifest(...)." ); + $this->manifest = $manifest; + } + + + /** + * + */ + public function addImage( $fullpath, $origimage, $mimetype ) { + $this->copyFileToPackage( $origimage, $fullpath ); + $this->makeSubDir( "Pictures" ); + $this->manifest->addEntryToManifest( $fullpath, $mimetype ); + } + + /** + * + */ + public function addXMLDocument( $fullpath, $dom, $mimetype="text/xml" ) { + $this->logger->info( "OpenDocumentPackage->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); + + $this->manifest->addEntryToManifest( $fullpath, $mimetype ); + $this->writeDOMToPackage( $fullpath, $dom ); + } + + private function commit() { + $this->logger->debug( "OpenDocumentPackage->commit()." ); + foreach($this->DocumentObjects as $key => $docObj) { + $this->logger->debug( "OpenDocumentPackage->commit: found \"" . $key . "\" in DocumentObjects array." ); + switch ($key) { + case "meta" : + $this->addXMLDocument( "meta.xml", $docObj->get() ); + break; + case "style" : + $this->addXMLDocument( "style.xml", $docObj->get() ); + break; + case "content" : + $this->addXMLDocument( "content.xml", $docObj->get() ); + break; +/* + case "settings" : + $this->addXMLDocument( "settings.xml", $dom ); + break; +*/ + } + } + + $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->manifest->getManifest() ); + $this->logger->debug( "OpenDocumentPackage->commit: Write mimetype \"". $this->getMimeType()."\" to file \"mimetype\"..." ); + $this->zip->addFile( $this->getMimeType(), "mimetype" ); + $this->logger->debug( "OpenDocumentPackage->commit: Commited package named \"" . $this->packagename . "\"..." ); + + $this->isCommited = true; + } + + public function get() { + if (!($this->isCommited)) { + $this->commit(); + } + $this->logger->debug( "OpenDocumentPackage->get()" ); + return $this->zip->file(); + } + + public function save( $altFilename=0 ) { + $this->writeZIPFile( $this->get() ); + } + + public function getMeta() { + if (!array_key_exists ( "meta", $this->DocumentObjects) ) { + $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta(); + } + return $this->DocumentObjects[ "meta" ]; + } + + public function getContent() { + if (!array_key_exists ( "content", $this->DocumentObjects) ) { + $this->DocumentObjects[ "content" ] = new OpenDocumentContent(); + } + return $this->DocumentObjects[ "content" ]; + } + + public function getStyle() { + if (!array_key_exists ( "style", $this->DocumentObjects) ) { + $this->DocumentObjects[ "style" ] = new OpenDocumentStyle(); + } + return $this->DocumentObjects[ "style" ]; + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php (rev 0) +++ poc/src/OpenDocumentSingle.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,99 @@ +<?php +/** + * OpenDocumentSingle Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocument + * + * $Id: OpenDocumentPackage.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ + +class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { + private $isCommited; + private $dom; + + /** + * + */ + public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { + parent::__construct( $mimetype ); + + $this->logger->debug( "Constructing OpenDocumentSingle." ); + + $this->isCommited = false; + + $this->dom = new DOMDocument( "1.0", "utf-8" ); + } + + /** + * + */ + public function __destruct() { + $this->logger->debug( "OpenDocumentSingle destructed." ); + + parent::__destruct(); + } + + /** + * + */ + public function addImage( $fullpath, $origimage, $mimetype ) { + $this->copyFileToPackage( $origimage, $fullpath ); + $this->makeSubDir( "Pictures" ); + $this->manifest->addEntryToManifest( $fullpath, $mimetype ); + } + + /** + * + */ + public function addXMLDocument( $fullpath, $domFrag, $mimetype="text/xml" ) { + $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); + $this->dom->appendChild( $domFrag ); + } + + private function commit() { + $this->logger->debug( "OpenDocumentSingle->commit()" ); + foreach( $this->DocumentObjects as $key => $class) { + $class->commit(); + } + $this->isCommited = true; + } + + public function get() { + if (!($this->isCommited)) { + $this->commit(); + } + $this->logger->debug( "OpenDocumentSingle->get()" ); + return $this->dom->saveXML(); + } + + public function save( $altFilename=0 ) { + $this->writeZIPFile( $this->get() ); + } + + public function getMeta() { + if (!array_key_exists ( "meta", $this->DocumentObjects) ) { + $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta( $this->dom ); + } + return $this->DocumentObjects[ "meta" ]; + } + + public function getContent() { + if (!array_key_exists ( "content", $this->DocumentObjects) ) { + $this->DocumentObjects[ "content" ] = new OpenDocumentContent( $this->dom ); + } + return $this->DocumentObjects[ "content" ]; + } + + public function getStyle() { + if (!array_key_exists ( "style", $this->DocumentObjects) ) { + $this->DocumentObjects[ "style" ] = new OpenDocumentStyle( $this->dom ); + } + return $this->DocumentObjects[ "style" ]; + } + +} + +?> \ No newline at end of file Added: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php (rev 0) +++ poc/src/OpenDocumentStyle.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,164 @@ +<?php +/** + * OpenDocumentStyle Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 2 $ + * @package OpenDocument + * + * $Id: OpenDocumentStyle.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + */ + +class OpenDocumentStyle extends OpenDocumentObjectAbstract { + + private $root; + private $style; + private $FontFaceDecl; + private $Styles; + private $DefaultStyles; + /** + * + */ + public function __construct( $dom=0 ) { + parent::__construct(); + + if (empty($dom)) { + // this is part of a package document + $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->dom->formatOutput = true; + + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-styles" ); + $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + + $this->style = $this->dom; + } else { + // this is part of a single document + $this->dom = $dom; + $this->style = $this->dom; + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); + } + $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->Styles = array(); + $this->DefaultStyles = array(); + } + + /** + * + */ + public function __destruct() { + unset( $this->dom ); + unset( $this->root ); + unset( $this->style ); + } + + public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { + $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); + $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); + $font->setAttributeNS( self::NS_SVG, "svg:font-family", $fontFamily ); + if (!empty($genericFamily)) { + $font->setAttributeNS( self::NS_STYLE, "style:font-family-genric", $genericFamily ); + } + if (!empty($fontPitch)) { + $font->setAttributeNS( self::NS_STYLE, "style:font-pitch", $fontPitch ); + } + if (!empty($fontCharset)) { + $font->setAttributeNS( self::NS_STYLE, "style:font-charset", $fontCharset ); + } + $this->FontFaceDecl->appendChild( $font ); + unset( $font ); + } + + public function getDom() { + return $this->dom; + } + + /** + * + * common family names: graphic, paragraph, table, table-row + */ + public function getDefaultStyle( $family=0 ) { + if (!empty($gamily) && array_key_exists($family, $this->DefaultStyles) ) { + return $this->DefaultStyles[$name]; + } else { + $node = $this->dom->createElementNS( self::NS_STYLE, "style:default-style" ); + if (!empty($family)) { + $node->setAttributeNS( self::NS_STYLE, "style:family", $family ); + } + return $node; + } + } + /** + * + * common family names: graphic, paragraph, table, table-row + */ + public function addDefaultStyle( $DefaultStyle, $family=0 ) { + if (empty($family)) { + $this->DefaultStyles[] = $DefaultStyle; + } else { + $this->DefaultStyles[$name] = $DefaultStyle; + } + } + + public function getStyle( $name ) { + if (array_key_exists($name, $this->Styles) ) { + return $this->Styles[$name]; + } else { + $node = $this->dom->createElementNS( self::NS_STYLE, "style:style" ); + $node->setAttributeNS( self::NS_STYLE, "style:name", $name ); + return $node; + } + } + + public function addStyle( $Style, $name=0 ) { + if (empty($name)) { + $this->Styles[] = $Style; + } else { + $this->Styles[$name] = $Style; + } + } + + + /** + * + */ + public function commit() { + $this->root->appendChild( $this->FontFaceDecl ); + $styleStyle = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); + + // Add all DefaultStyles + foreach( $this->DefaultStyles as $aDefaultStyle) { + $styleStyle->appendChild( $aDefaultStyle ); + } + + // Add all Styles + foreach( $this->Styles as $aStyle) { + $styleStyle->appendChild( $aStyle ); + } + $this->root->appendChild( $styleStyle ); + + $this->style->appendChild( $this->root ); + $this->dom->normalize(); + $this->isCommited = true; + } + + /** + * @return + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + return $this->dom; + } + + /** + * + */ + final public function save( $filename ) { + $this->get()->save( $filename ); + } + +} + +?> \ No newline at end of file Added: poc/src/TestOutput.php =================================================================== --- poc/src/TestOutput.php (rev 0) +++ poc/src/TestOutput.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,195 @@ +<?php +/** + * SampleClass produces a little OpenDocument and send it to the client + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument.Samples + * + * $Id: TestOutput.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +require_once( "OpenDocumentFactory.php" ); +require_once( "Log/observer.php" ); + +class TestOutput { + + private $logger; + + function __construct() { + /* ***TO DO *** This raises a warning ... + // $conf = array( "mode" => 0600 ); + $this->logger = &Log_observer::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); + $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); + */ + + /* + Console output: + $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); + + File output: + $this->logger = &Log_observer::factory( "file", "OpenDocument.log", "OpenDocument" ); + */ + } + + function makeMeta( $meta ) { + $meta->addDublinCore( "title", "This is a test!" ); + $meta->addDublinCore( "creator", "Norman Markgraf" ); + $meta->addDublinCore( "language", "en-EN" ); + $meta->addGenerator( "" ); + $meta->addInitialCreator( "Norman Markgraf" ); + } + + function makeContent( $content ) { + $content->addNoScript(); + + $content->addFontFace( "Test", "Tahoma" ); + + $content->addNoAutomaticStyles(); + + $text = $content->getBody()->getText(); + + $text->addNoForms(); + + $text->addToText( $text->getTextHeading( "Heading", "The first step" ) ); + $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); + } + + function makeStyle( $style ) { + $NS_STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; + $NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compartible:1.0"; + + $style->addFontFace( "Test", "Tahoma" ); + + // Set default style + $defStyle = $style->getDefaultStyle( "paragraph" ); + + $defProp = $style->getDom()->createElementNS( $NS_STYLE, "style:paragraph-properties" ); + $defProp->setAttributeNS( $NS_FO, "fo:hypenation-ladder-count", "no-limit" ); + $defProp->setAttributeNS( $NS_STYLE, "style:text-autospace", "ideograph-alpha" ); + $defProp->setAttributeNS( $NS_STYLE, "style:punctuation-wrap", "hanging" ); + $defProp->setAttributeNS( $NS_STYLE, "style:line-break", "strict" ); + $defProp->setAttributeNS( $NS_STYLE, "style:tab-stop-distance", "1.251cm" ); + $defProp->setAttributeNS( $NS_STYLE, "style:writeing-mode", "page" ); + $defStyle->appendChild( $defProp ); + + $defProp = $style->getDom()->createElementNS( $NS_STYLE, "style:text-properties" ); + $defProp->setAttributeNS( $NS_FO, "fo:font-size", "12pt" ); + $defProp->setAttributeNS( $NS_FO, "fo:language", "de" ); + $defProp->setAttributeNS( $NS_FO, "fo:country", "DE" ); + $defProp->setAttributeNS( $NS_FO, "fo:hyphenate", "false" ); + $defProp->setAttributeNS( $NS_FO, "fo:hypenation-remain-char-count", "2" ); + $defProp->setAttributeNS( $NS_FO, "fo:hypenation-push-char-count", "2" ); + $defProp->setAttributeNS( $NS_STYLE, "style:use-window-font-color", "true" ); + $defProp->setAttributeNS( $NS_STYLE, "style:font-name", "Times New Roman" ); + $defProp->setAttributeNS( $NS_STYLE, "style:font-name-asian", "Arial Unicode MS" ); + $defProp->setAttributeNS( $NS_STYLE, "style:font-size-asian", "12pt" ); + $defProp->setAttributeNS( $NS_STYLE, "style:language-asian", "none" ); + $defProp->setAttributeNS( $NS_STYLE, "style:country-asian", "none" ); + $defProp->setAttributeNS( $NS_STYLE, "style:font-name-complex", "Tahoma" ); + $defProp->setAttributeNS( $NS_STYLE, "style:font-site-complex", "12pt" ); + $defProp->setAttributeNS( $NS_STYLE, "style:language-complex", "none" ); + $defProp->setAttributeNS( $NS_STYLE, "style:country-complex", "none" ); + $defStyle->appendChild( $defProp ); + + $style->addDefaultStyle( $defStyle ); + + //Set a style + $aStyle = $style->getStyle( "Paragraph" ); + $aStyle->setAttributeNS ( $NS_STYLE, "style:family", "paragraph" ); + $aStyle->setAttributeNS ( $NS_STYLE, "style:class", "text" ); + + $style->addStyle( $aStyle, "Paragraph" ); + + //Set a style + $aStyle = $style->getStyle( "Heading" ); + $aStyle->setAttributeNS ( $NS_STYLE, "style:family", "paragraph" ); + $aStyle->setAttributeNS ( $NS_STYLE, "style:class", "text" ); + + $aStyleProp = $style->getDom()->createElementNS( $NS_STYLE, "style:paragraph-properties" ); + $aStyleProp->setAttributeNS ( $NS_FO, "fo:margin-top", "0.423cm" ); + $aStyleProp->setAttributeNS ( $NS_FO, "fo:margin-bottom", "0.212cm" ); + $aStyleProp->setAttributeNS ( $NS_FO, "fo:keep-with-next", "always" ); + $aStyle->appendChild( $aStyleProp ); + + $aStyleProp = $style->getDom()->createElementNS( $NS_STYLE, "style:text-properties" ); + $aStyleProp->setAttributeNS ( $NS_FO, "fo:font-size", "20pt" ); + $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name", "Arial" ); + $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name-asian", "MS Mincho" ); + $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-size-asian", "20pt" ); + $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name-complex", "Tahoma1" ); + $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-size-complex", "20pt" ); + $aStyle->appendChild( $aStyleProp ); + + $style->addStyle( $aStyle, "Paragraph" ); + } + + function run($SingleDocument) { + if (!function_exists('gzencode')) { + $out = "<p>You have to enable zlib at compile time of your PHP! "; + $out .= "use <emph>--with-zlib=[DIR]</emph> at the <emph>configure</emph> "; + $out .= "procedure</p>"; + echo $out; + return; + } + + $DocumentName = "test.odt"; + + //header( "Content-type: application/odt" ); + //header( "Content-Disposition: attachment; filename=".$DocumentName ); + + + // Get a OpenDocument object from the factory: + + if(isset($SingleDocument)) + { + $TestDoc = OpenDocumentFactory::createOpenDocument( + $DocumentName, + "D:/PHP/OpenDocument/", + $SingleDocument + ); + + /* + $TestDoc->attachObserverToLogger( $this->logger ); + */ + + $this->makeMeta( $TestDoc->getMeta() ); + $this->makeStyle( $TestDoc->getStyle() ); + $this->makeContent( $TestDoc->getContent() ); + + echo $TestDoc->get(); + + //$TestDoc->save(); + } + + + } +} + +if(isset($_POST['SingleDocument'])) +{ + $SingleDocument = $_POST['SingleDocument']; + $TestOutput = new TestOutput(); + $TestOutput->run($SingleDocument); +} + + + +?> + +<html> +<head> +<title>TestOutput File!</title> +</head> +<body> +<form method="POST" action=""> + <fieldset> + <legend>Document Type:</legend> + Single <input type="radio" name="SingleDocument" value="TRUE" checked="checked" /> + Package <input type="radio" name="SingleDocument" value="FALSE" /><br /> + <input type="submit" value="Submit!" /> + </fieldset> +</form> +</body> +</html> Added: poc/src/ZipFile.php =================================================================== --- poc/src/ZipFile.php (rev 0) +++ poc/src/ZipFile.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,184 @@ +<?php +/** + * Zip file creation class. + * Makes zip files. + * + * Based on : + * + * http://www.zend.com/codex.php?id=535&single=1 + * By Eric Mueller <er...@th...> + * + * http://www.zend.com/codex.php?id=470&single=1 + * by Denis125 <web...@at...> + * + * a patch from Peter Listiak <ml...@us...> for last modified + * date and time of the compressed file + * + * Official ZIP file format: http://www.pkware.com/appnote.txt + * + * @access public + */ +class ZipFile +{ + /** + * Array to store compressed data + * + * @var array $datasec + */ + var $datasec = array(); + + /** + * Central directory + * + * @var array $ctrl_dir + */ + var $ctrl_dir = array(); + + /** + * End of central directory record + * + * @var string $eof_ctrl_dir + */ + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + + /** + * Last offset position + * + * @var integer $old_offset + */ + var $old_offset = 0; + + + /** + * Converts an Unix timestamp to a four byte DOS date and time format (date + * in high two bytes, time in low two bytes allowing magnitude comparison). + * + * @param integer the current Unix timestamp + * + * @return integer the current date in a four byte DOS format + * + * @access private + */ + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + + ... [truncated message content] |
From: <nma...@us...> - 2006-03-13 08:59:07
|
Revision: 20 Author: nmarkgraf Date: 2006-03-13 00:58:48 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=20&view=rev Log Message: ----------- Only a few bug fixes: - build.xml was updated to run only on non-samples. - all test needs to be in an new subpackage - minor things in FontFaceDeclaration and OpenDocumentSingle class. :D Norman Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentSingle.php poc/src/styles/FontFaceDeclaration.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-13 08:14:08 UTC (rev 19) +++ poc/build.xml 2006-03-13 08:58:48 UTC (rev 20) @@ -23,6 +23,7 @@ <fileset dir="src"> <include name="**/*.php"/> <exclude name="**/*Test.php"/> + <exclude name="**/samples/*.php"/> </fileset> </coverage-setup> Modified: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -5,7 +5,8 @@ * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentTest + * @package OpenDocument + * @subpackage UnitTest * * $Id$ */ Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentManifestTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -6,7 +6,8 @@ * @lecense GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentUnitTest + * @package OpenDocument + * @subpackage UnitTest * * @since 0.4.0 * Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentMeta.php 2006-03-13 08:58:48 UTC (rev 20) @@ -24,7 +24,7 @@ * * @since 0.3.0 */ - public function __construct( $dom=0, $root=0 ) { + public function __construct( $dom=0, $_root=0 ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentMeta." ); @@ -39,11 +39,10 @@ $this->dom->appendChild( $node ); $this->meta = $node; - unset( $node ); } else { // this is part of a single document $this->dom = $dom; - $this->meta = $root; + $this->meta = $_root; } $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); } Modified: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentMetaTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -5,7 +5,8 @@ * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentUnitTest + * @package OpenDocument + * @subpackage UnitTest * * $Id$ */ @@ -21,7 +22,7 @@ /** * namespace Dublin Core */ - const NS_DC = "http://purl.org/dc/elements/1.1"; + const NS_DC = "http://purl.org/dc/elements/1.1/"; public function testConstructWithoutDom(){ $ODM = new OpenDocumentMeta(); @@ -58,8 +59,11 @@ public function testConstructWithDom(){ $testDom = new DOMDocument(); + $node = $testDom->createElementNS( self::NS_OFFICE, "office:meta" ); - $ODM = new OpenDocumentMeta( $testDom ); + $ODM = new OpenDocumentMeta( $testDom, $node ); + $testDom->appendChild( $node ); + $this->assertNotNull( $ODM ); $resultDom = $ODM->get(); Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-13 08:58:48 UTC (rev 20) @@ -86,19 +86,9 @@ const NS_ANIM = "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"; /** - * namespace OpenDocument chart - */ - const NS_CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; - - /** * namespace OpenDocument script */ const NS_SCRIPT = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"; - - /** - * namespace OpenDocument number - */ - const NS_NUMBER = "urn:oasis:names:tc:opendocument:xmlns:number:1.0"; /** * namespace OpenDocument svg Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentSingle.php 2006-03-13 08:58:48 UTC (rev 20) @@ -18,6 +18,11 @@ private $dom; private $root; + /** + * namespace OpenDocument office + */ + const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + /** * * @access public Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-13 08:58:48 UTC (rev 20) @@ -82,7 +82,7 @@ * * @since 0.4.2 */ - private function checkStyle( $key, $value ) { + private function checkSVG( $key, $value ) { switch ($key) { default: // ***FIX ME*** should be "false"! return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-14 13:58:22
|
Revision: 25 Author: nmarkgraf Date: 2006-03-14 05:57:51 -0800 (Tue, 14 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=25&view=rev Log Message: ----------- Lots of changes today. I mostly disable __autoload again, because it does not work for me. We can put the part in the distribution if we find a solution that works under any condition. - Added .htaccess to samples directory for better Apache support. - New /etc/* stuff for the current SVN release of PHing. - New build.xml to avoid some things that confuses PHIng and Code Coverage Reports. Modified Paths: -------------- poc/build.xml poc/etc/coverage-frames.xsl poc/etc/log.xsl poc/etc/phpunit2-frames.xsl poc/etc/phpunit2-noframes.xsl poc/etc/str.replace.function.xsl poc/src/OpenDocumentContent.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentObjectAbstract.php poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php poc/src/styles/FontFaceDeclaration.php Added Paths: ----------- poc/src/samples/.htaccess Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-13 15:13:43 UTC (rev 24) +++ poc/build.xml 2006-03-14 13:57:51 UTC (rev 25) @@ -17,8 +17,14 @@ <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> </target> + + <target name="preparereport"> + <mkdir dir="reports"/> + <mkdir dir="reports/coverage"/> + <mkdir dir="reports/tests"/> + </target> - <target name="reports"> + <target name="reports" depends="preparereport"> <coverage-setup database="reports/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> @@ -27,8 +33,7 @@ </fileset> </coverage-setup> - <phpunit2 codecoverage="true" haltonerror="false" haltonfailure="false" printsummary="true"> - <!-- phpunit2 --> + <phpunit2 codecoverage="true" haltonerror="false" haltonfailure="false" printsummary="false"> <formatter type="xml" todir="reports"/> <batchtest> <fileset dir="src"> @@ -39,11 +44,9 @@ <phpunit2report infile="reports/testsuites.xml" format="frames" todir="reports/tests" styledir="etc"/> - <!-- --> <coverage-report outfile="reports/coverage.xml"> <report todir="reports/coverage" styledir="etc"/> </coverage-report> - <!-- --> </target> <target name="test" depends="preparetest"> @@ -72,16 +75,32 @@ </target> <target name="dev-dist" depends="preparedist"> - <zip destfile="dist/OpenDocumentPHPdev.zip" basedir="."/> - <tar destfile="dist/OpenDocumentPHPdev.tar" basedir="."/> + <zip destfile="dist/OpenDocumentPHPdev.zip" basedir="."> + <fileset dir="."> + <include name="**/**"/> + <exclude name="**/?svn/**"/> + </fileset> + </zip> + <tar destfile="dist/OpenDocumentPHPdev.tar" basedir="."> + <fileset dir="."> + <include name="**/**"/> + <exclude name="**/?svn/**"/> + </fileset> + </tar> </target> <target name="build" depends="prepare,test,reports,docs,dist"> </target> + <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist"> + </target> + + <target name="clean"> <delete file="reports/coverage.db"/> <delete file="reports/testsuites.xml"/> + <delete dir="reports/tests"/> + <delete dir="reports/coverage"/> <delete dir="docs"/> <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> Modified: poc/etc/coverage-frames.xsl =================================================================== --- poc/etc/coverage-frames.xsl 2006-03-13 15:13:43 UTC (rev 24) +++ poc/etc/coverage-frames.xsl 2006-03-14 13:57:51 UTC (rev 25) @@ -1,636 +1,666 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" - xmlns:exsl="http://exslt.org/common" - xmlns:date="http://exslt.org/dates-and-times" - extension-element-prefixes="exsl date"> -<xsl:output method="html" indent="yes"/> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> -<!-- - Copyright 2001-2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> - -<!-- - - Sample stylesheet to be used with Xdebug/Phing code coverage output. - Based on JProbe stylesheets from Apache Ant. - - It creates a set of HTML files a la javadoc where you can browse easily - through all packages and classes. - - @author Michiel Rook <a href="mailto:mi...@tr..."/> - @author Stephane Bailliez <a href="mailto:sba...@ap..."/> - ---> - -<!-- default output directory is current directory --> -<xsl:param name="output.dir" select="'.'"/> - -<!-- ====================================================================== - Root element - ======================================================================= --> -<xsl:template match="/snapshot"> - <!-- create the index.html --> - <exsl:document href="efile://{$output.dir}/index.html"> - <xsl:call-template name="index.html"/> - </exsl:document> - - <!-- create the stylesheet.css --> - <exsl:document href="efile://{$output.dir}/stylesheet.css"> - <xsl:call-template name="stylesheet.css"/> - </exsl:document> - - <!-- create the overview-packages.html at the root --> - <exsl:document href="efile://{$output.dir}/overview-summary.html"> - <xsl:apply-templates select="." mode="overview.packages"/> - </exsl:document> - - <!-- create the all-packages.html at the root --> - <exsl:document href="efile://{$output.dir}/overview-frame.html"> - <xsl:apply-templates select="." mode="all.packages"/> - </exsl:document> - - <!-- create the all-classes.html at the root --> - <exsl:document href="efile://{$output.dir}/allclasses-frame.html"> - <xsl:apply-templates select="." mode="all.classes"/> - </exsl:document> - - <!-- process all packages --> - <xsl:apply-templates select="./package" mode="write"/> -</xsl:template> - -<!-- ======================================================================= - Frameset definition. Entry point for the report. - 3 frames: packageListFrame, classListFrame, classFrame - ======================================================================= --> -<xsl:template name="index.html"> -<html> - <head><title>Coverage Results.</title></head> - <frameset cols="20%,80%"> - <frameset rows="30%,70%"> - <frame src="overview-frame.html" name="packageListFrame"/> - <frame src="allclasses-frame.html" name="classListFrame"/> - </frameset> - <frame src="overview-summary.html" name="classFrame"/> - </frameset> - <noframes> - <h2>Frame Alert</h2> - <p> - This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. - </p> - </noframes> -</html> -</xsl:template> - -<!-- ======================================================================= - Stylesheet CSS used - ======================================================================= --> -<!-- this is the stylesheet css to use for nearly everything --> -<xsl:template name="stylesheet.css"> - .bannercell { - border: 0px; - padding: 0px; - } - body { - margin-left: 10; - margin-right: 10; - background-color:#FFFFFF; - font-family: verdana,arial,sanserif; - color:#000000; - } - a { - color: #003399; - } - a:hover { - color: #888888; - } - .a td { - background: #efefef; - } - .b td { - background: #fff; - } - th, td { - text-align: left; - vertical-align: top; - } - th { - font-weight:bold; - background: #ccc; - color: black; - } - table, th, td { - font-size: 12px; - border: none - } - table.log tr td, tr th { - } - h2 { - font-weight:bold; - font-size: 12px; - margin-bottom: 5; - } - h3 { - font-size:100%; - font-weight: 12px; - background: #DFDFDF - color: white; - text-decoration: none; - padding: 5px; - margin-right: 2px; - margin-left: 2px; - margin-bottom: 0; - } - .small { - font-size: 9px; - } -TD.empty { - FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; - color: #c0c0c0; -} -TD.fullcover { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; - color: #00df00; -} -TD.covered { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; - color: #00df00; -} -TD.uncovered { - FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; - color: #df0000; -} -PRE.srcLine { - BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; -} -td.lineCount, td.coverageCount { - BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.lineCountHighlight { - background: #C8C8F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.coverageCountHighlight { - background: #F0C8C8; PADDING-RIGHT: 3px; - text-align: right; -} -span.srcLineHighlight { - background: #F0C8C8; -} -span.srcLine { - background: #C8C8F0; -} -TD.srcLineClassStart { - WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; -} -.srcLine , .srcLine ol, .srcLine ol li {margin: 0;} -.srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} -.srcLine .imp {font-weight: bold; color: red;} -.srcLine .kw1 {color: #b1b100;} -.srcLine .kw2 {color: #000000; font-weight: bold;} -.srcLine .kw3 {color: #000066;} -.srcLine .co1 {color: #808080; font-style: italic;} -.srcLine .co2 {color: #808080; font-style: italic;} -.srcLine .coMULTI {color: #808080; font-style: italic;} -.srcLine .es0 {color: #000099; font-weight: bold;} -.srcLine .br0 {color: #66cc66;} -.srcLine .st0 {color: #ff0000;} -.srcLine .nu0 {color: #cc66cc;} -.srcLine .me1 {color: #006600;} -.srcLine .me2 {color: #006600;} -.srcLine .re0 {color: #0000ff;} -</xsl:template> - -<!-- ======================================================================= - List of all classes in all packages - This will be the first page in the classListFrame - ======================================================================= --> -<xsl:template match="snapshot" mode="all.classes"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body> - <h2>All Classes</h2> - <table width="100%"> - <xsl:for-each select="package/class"> - <xsl:sort select="@name"/> - <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> - <xsl:variable name="link"> - <xsl:if test="not($package.name='')"> - <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text> - </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text> - </xsl:variable> - <tr> - <td nowrap="nowrap"> - <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <i> (-)</i> - </xsl:when> - <xsl:otherwise> - <i> (<xsl:value-of select="format-number(@methodscovered div @methodcount, '0.0%')"/>)</i> - </xsl:otherwise> - </xsl:choose> - </td> - </tr> - </xsl:for-each> - </table> - </body> - </html> -</xsl:template> - -<!-- list of all packages --> -<xsl:template match="snapshot" mode="all.packages"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body> - <h2><a href="overview-summary.html" target="classFrame">Overview</a></h2> - <h2>All Packages</h2> - <table width="100%"> - <xsl:for-each select="package"> - <xsl:sort select="@name" order="ascending"/> - <tr> - <td nowrap="nowrap"> - <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame"> - <xsl:value-of select="@name"/> - </a> - </td> - </tr> - </xsl:for-each> - </table> - </body> - </html> -</xsl:template> - -<!-- overview of statistics in packages --> -<xsl:template match="snapshot" mode="overview.packages"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body onload="open('allclasses-frame.html','classListFrame')"> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr class="a"> - <td class="small">Packages: <xsl:value-of select="count(package)"/></td> - <td class="small">Classes: <xsl:value-of select="count(package/class)"/></td> - <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> - <td class="small">LOC: <xsl:value-of select="count(package/class/sourcefile/sourceline)"/></td> - </tr> - </table> - <br/> - - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%" nowrap="nowrap"></th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <tr class="a"> - <td>Total coverage</td> - <xsl:call-template name="stats.formatted"/> - </tr> - <tr> - <td colspan="3"><br/></td> - </tr> - <tr> - <th width="100%">Packages</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <!-- display packages and sort them via their coverage rate --> - <xsl:for-each select="package"> - <xsl:sort data-type="number" select="@methodscovered div @methodcount"/> - <tr> - <xsl:call-template name="alternate-row"/> - <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td> - <xsl:call-template name="stats.formatted"/> - </tr> - </xsl:for-each> - </table> - <xsl:call-template name="pageFooter"/> - </body> - </html> -</xsl:template> - -<!-- - detailed info for a package. It will output the list of classes -, the summary page, and the info for each class ---> -<xsl:template match="package" mode="write"> - <xsl:variable name="package.dir"> - <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if> - <xsl:if test="@name = ''">.</xsl:if> - </xsl:variable> - - <!-- create a classes-list.html in the package directory --> - <exsl:document href="efile://{$output.dir}/{$package.dir}/package-frame.html"> - <xsl:apply-templates select="." mode="classes.list"/> - </exsl:document> - - <!-- create a package-summary.html in the package directory --> - <exsl:document href="efile://{$output.dir}/{$package.dir}/package-summary.html"> - <xsl:apply-templates select="." mode="package.summary"/> - </exsl:document> - - <!-- for each class, creates a @name.html --> - <xsl:for-each select="class"> - <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}.html"> - <xsl:apply-templates select="." mode="class.details"/> - </exsl:document> - </xsl:for-each> -</xsl:template> - -<!-- list of classes in a package --> -<xsl:template match="package" mode="classes.list"> - <html> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="@name"/> - </xsl:call-template> - </HEAD> - <BODY> - <table width="100%"> - <tr> - <td nowrap="nowrap"> - <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2> - </td> - </tr> - </table> - - <H2>Classes</H2> - <TABLE WIDTH="100%"> - <xsl:for-each select="class"> - <xsl:sort select="@name"/> - <tr> - <td nowrap="nowrap"> - <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <i> (-)</i> - </xsl:when> - <xsl:otherwise> - <i>(<xsl:value-of select="format-number(@methodscovered div @methodcount, '0.0%')"/>)</i> - </xsl:otherwise> - </xsl:choose> - </td> - </tr> - </xsl:for-each> - </TABLE> - </BODY> - </html> -</xsl:template> - -<!-- summary of a package --> -<xsl:template match="package" mode="package.summary"> - <HTML> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="@name"/> - </xsl:call-template> - </HEAD> - <!-- when loading this package, it will open the classes into the frame --> - <BODY onload="open('package-frame.html','classListFrame')"> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr class="a"> - <td class="small">Classes: <xsl:value-of select="count(class)"/></td> - <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> - <td class="small">LOC: <xsl:value-of select="count(class/sourcefile/sourceline)"/></td> - </tr> - </table> - <br/> - - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%">Package</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <xsl:apply-templates select="." mode="stats"/> - - <xsl:if test="count(class) > 0"> - <tr> - <td colspan="3"><br/></td> - </tr> - <tr> - <th width="100%">Classes</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <xsl:apply-templates select="class" mode="stats"> - <xsl:sort data-type="number" select="@methodscovered div @methodcount"/> - </xsl:apply-templates> - </xsl:if> - </table> - <xsl:call-template name="pageFooter"/> - </BODY> - </HTML> -</xsl:template> - -<!-- details of a class --> -<xsl:template match="class" mode="class.details"> - <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> - <HTML> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="$package.name"/> - </xsl:call-template> - </HEAD> - <BODY> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr class="a"> - <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> - <td class="small">LOC: <xsl:value-of select="count(sourcefile/sourceline)"/></td> - </tr> - </table> - <br/> - - <!-- class summary --> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%">Source file</th> - <th width="250" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <tr> - <xsl:call-template name="alternate-row"/> - <td><xsl:value-of select="sourcefile/@name"/></td> - <xsl:call-template name="stats.formatted"/> - </tr> - </table> - <table cellspacing="0" cellpadding="0" width="100%"> - <xsl:apply-templates select="sourcefile/sourceline"/> - </table> - <br/> - <xsl:call-template name="pageFooter"/> - </BODY> - </HTML> - -</xsl:template> - -<!-- Page Header --> -<xsl:template name="pageHeader"> - <!-- jakarta logo --> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> - <tr> - <td class="bannercell" rowspan="2"> - <a href="http://phing.info/"> - <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> - </a> - </td> - <td style="text-align:right"><h2>Source Code Coverage</h2></td> - </tr> - <tr> - <td style="text-align:right">Designed for use with <a href='http://pear.php.net/package/PHPUnit2'>PHPUnit2</a>, <a href='http://www.xdebug.org/'>Xdebug</a> and <a href='http://phing.info/'>Phing</a>.</td> - </tr> - </table> - <hr size="1"/> -</xsl:template> - -<!-- Page Footer --> -<xsl:template name="pageFooter"> - <table width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - <tr><td class="small">Report generated at <xsl:value-of select="date:date-time()"/></td></tr> - </table> -</xsl:template> - -<xsl:template match="package" mode="stats"> - <tr> - <xsl:call-template name="alternate-row"/> - <td><xsl:value-of select="@name"/></td> - <xsl:call-template name="stats.formatted"/> - </tr> -</xsl:template> - -<xsl:template match="class" mode="stats"> - <tr> - <xsl:call-template name="alternate-row"/> - <td><a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a></td> - <xsl:call-template name="stats.formatted"/> - </tr> -</xsl:template> - -<xsl:template name="stats.formatted"> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <td>-</td> - <td> - <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> - <tr> - <td class="empty" width="200" height="12"> </td> - </tr> - </table> - </td> - </xsl:when> - <xsl:otherwise> - <td> - <xsl:value-of select="format-number(@methodscovered div @methodcount,'0.0%')"/> - </td> - <td> - <xsl:variable name="leftwidth"><xsl:value-of select="format-number((@methodscovered * 200) div @methodcount,'0')"/></xsl:variable> - <xsl:variable name="rightwidth"><xsl:value-of select="format-number(200 - (@methodscovered * 200) div @methodcount,'0')"/></xsl:variable> - <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> - <tr> - <xsl:choose> - <xsl:when test="$leftwidth=200"> - <td class="fullcover" width="200" height="12"> </td> - </xsl:when> - <xsl:otherwise> - <xsl:if test="not($leftwidth=0)"> - <td class="covered" width="{$leftwidth}" height="12"> </td> - </xsl:if> - <xsl:if test="not($rightwidth=0)"> - <td class="uncovered" width="{$rightwidth}" height="12"> </td> - </xsl:if> - </xsl:otherwise> - </xsl:choose> - </tr> - </table> - </td> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template match="sourceline"> - <tr> - <xsl:if test="@coveredcount>0"> - <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> - <td class="lineCountHighlight"><xsl:value-of select="@coveredcount"/></td> - </xsl:if> - <xsl:if test="@coveredcount<0"> - <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> - <td class="coverageCountHighlight">0</td> - </xsl:if> - <xsl:if test="@coveredcount=0"> - <td class="lineCount"><xsl:value-of select="position()"/></td> - <td class="coverageCount"></td> - </xsl:if> - <td> - <xsl:if test="@startclass=1"> - <xsl:attribute name="class">srcLineClassStart</xsl:attribute> - </xsl:if> - <xsl:if test="@coveredcount>0"> - <span class="srcLine"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </span> - </xsl:if> - <xsl:if test="@coveredcount<0"> - <span class="srcLineHighlight"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </span> - </xsl:if> - <xsl:if test="@coveredcount=0"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </xsl:if> - </td> - </tr> -</xsl:template> - -<!-- - transform string like a.b.c to ../../../ - @param path the path to transform into a descending directory path ---> -<xsl:template name="path"> - <xsl:param name="path"/> - <xsl:if test="contains($path,'.')"> - <xsl:text>../</xsl:text> - <xsl:call-template name="path"> - <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> - </xsl:call-template> - </xsl:if> - <xsl:if test="not(contains($path,'.')) and not($path = '')"> - <xsl:text>../</xsl:text> - </xsl:if> -</xsl:template> - - -<!-- create the link to the stylesheet based on the package name --> -<xsl:template name="create.stylesheet.link"> - <xsl:param name="package.name"/> - <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK> -</xsl:template> - -<!-- alternated row style --> -<xsl:template name="alternate-row"> -<xsl:attribute name="class"> - <xsl:if test="position() mod 2 = 1">a</xsl:if> - <xsl:if test="position() mod 2 = 0">b</xsl:if> -</xsl:attribute> -</xsl:template> - -</xsl:stylesheet> - - +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" + xmlns:exsl="http://exslt.org/common" + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="exsl date"> +<xsl:output method="html" indent="yes"/> +<xsl:decimal-format decimal-separator="." grouping-separator="," /> +<!-- + Copyright 2001-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!-- + + Sample stylesheet to be used with Xdebug/Phing code coverage output. + Based on JProbe stylesheets from Apache Ant. + + It creates a set of HTML files a la javadoc where you can browse easily + through all packages and classes. + + @author Michiel Rook <a href="mailto:mi...@tr..."/> + @author Stephane Bailliez <a href="mailto:sba...@ap..."/> + +--> + +<!-- default output directory is current directory --> +<xsl:param name="output.dir" select="'.'"/> + +<!-- ====================================================================== + Root element + ======================================================================= --> +<xsl:template match="/snapshot"> + <!-- create the index.html --> + <exsl:document href="efile://{$output.dir}/index.html"> + <xsl:call-template name="index.html"/> + </exsl:document> + + <!-- create the stylesheet.css --> + <exsl:document href="efile://{$output.dir}/stylesheet.css"> + <xsl:call-template name="stylesheet.css"/> + </exsl:document> + + <!-- create the overview-packages.html at the root --> + <exsl:document href="efile://{$output.dir}/overview-summary.html"> + <xsl:apply-templates select="." mode="overview.packages"/> + </exsl:document> + + <!-- create the all-packages.html at the root --> + <exsl:document href="efile://{$output.dir}/overview-frame.html"> + <xsl:apply-templates select="." mode="all.packages"/> + </exsl:document> + + <!-- create the all-classes.html at the root --> + <exsl:document href="efile://{$output.dir}/allclasses-frame.html"> + <xsl:apply-templates select="." mode="all.classes"/> + </exsl:document> + + <!-- process all packages --> + <xsl:apply-templates select="./package" mode="write"/> +</xsl:template> + +<!-- ======================================================================= + Frameset definition. Entry point for the report. + 3 frames: packageListFrame, classListFrame, classFrame + ======================================================================= --> +<xsl:template name="index.html"> +<html> + <head><title>Coverage Results.</title></head> + <frameset cols="20%,80%"> + <frameset rows="30%,70%"> + <frame src="overview-frame.html" name="packageListFrame"/> + <frame src="allclasses-frame.html" name="classListFrame"/> + </frameset> + <frame src="overview-summary.html" name="classFrame"/> + </frameset> + <noframes> + <h2>Frame Alert</h2> + <p> + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. + </p> + </noframes> +</html> +</xsl:template> + +<!-- ======================================================================= + Stylesheet CSS used + ======================================================================= --> +<!-- this is the stylesheet css to use for nearly everything --> +<xsl:template name="stylesheet.css"> + .bannercell { + border: 0px; + padding: 0px; + } + body { + margin-left: 10; + margin-right: 10; + background-color:#FFFFFF; + font-family: verdana,arial,sanserif; + color:#000000; + } + a { + color: #003399; + } + a:hover { + color: #888888; + } + .a td { + background: #efefef; + } + .b td { + background: #fff; + } + th, td { + text-align: left; + vertical-align: top; + } + th { + font-weight:bold; + background: #ccc; + color: black; + } + table, th, td { + font-size: 12px; + border: none + } + table.log tr td, tr th { + } + h2 { + font-weight:bold; + font-size: 12px; + margin-bottom: 5; + } + h3 { + font-size:100%; + font-weight: 12px; + background: #DFDFDF + color: white; + text-decoration: none; + padding: 5px; + margin-right: 2px; + margin-left: 2px; + margin-bottom: 0; + } + .small { + font-size: 9px; + } +TD.empty { + FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; + color: #c0c0c0; +} +TD.fullcover { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; + color: #00df00; +} +TD.covered { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; + color: #00df00; +} +TD.uncovered { + FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; + color: #df0000; +} +PRE.srcLine { + BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; +} +td.lineCount, td.coverageCount { + BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; + text-align: right; +} +td.lineCountHighlight { + background: #C8C8F0; PADDING-RIGHT: 3px; + text-align: right; +} +td.coverageCountHighlight { + background: #F0C8C8; PADDING-RIGHT: 3px; + text-align: right; +} +span.srcLineHighlight { + background: #F0C8C8; +} +span.srcLine { + background: #C8C8F0; +} +TD.srcLineClassStart { + WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; +} +.srcLine , .srcLine ol, .srcLine ol li {margin: 0;} +.srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} +.srcLine .imp {font-weight: bold; color: red;} +.srcLine .kw1 {color: #b1b100;} +.srcLine .kw2 {color: #000000; font-weight: bold;} +.srcLine .kw3 {color: #000066;} +.srcLine .co1 {color: #808080; font-style: italic;} +.srcLine .co2 {color: #808080; font-style: italic;} +.srcLine .coMULTI {color: #808080; font-style: italic;} +.srcLine .es0 {color: #000099; font-weight: bold;} +.srcLine .br0 {color: #66cc66;} +.srcLine .st0 {color: #ff0000;} +.srcLine .nu0 {color: #cc66cc;} +.srcLine .me1 {color: #006600;} +.srcLine .me2 {color: #006600;} +.srcLine .re0 {color: #0000ff;} +</xsl:template> + +<!-- ======================================================================= + List of all classes in all packages + This will be the first page in the classListFrame + ======================================================================= --> +<xsl:template match="snapshot" mode="all.classes"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body> + <h2>All Classes</h2> + <table width="100%"> + <xsl:for-each select="package/class"> + <xsl:sort select="@name"/> + <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> + <xsl:variable name="link"> + <xsl:if test="not($package.name='')"> + <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text> + </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text> + </xsl:variable> + <tr> + <td nowrap="nowrap"> + <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <i> (-)</i> + </xsl:when> + <xsl:otherwise> + <i> (<xsl:value-of select="format-number(@totalcovered div @totalcount, '0.0%')"/>)</i> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + </xsl:for-each> + </table> + </body> + </html> +</xsl:template> + +<!-- list of all packages --> +<xsl:template match="snapshot" mode="all.packages"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body> + <h2><a href="overview-summary.html" target="classFrame">Overview</a></h2> + <h2>All Packages</h2> + <table width="100%"> + <xsl:for-each select="package"> + <xsl:sort select="@name" order="ascending"/> + <tr> + <td nowrap="nowrap"> + <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame"> + <xsl:value-of select="@name"/> + </a> + </td> + </tr> + </xsl:for-each> + </table> + </body> + </html> +</xsl:template> + +<!-- overview of statistics in packages --> +<xsl:template match="snapshot" mode="overview.packages"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body onload="open('allclasses-frame.html','classListFrame')"> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr class="a"> + <td class="small">Packages: <xsl:value-of select="count(package)"/></td> + <td class="small">Classes: <xsl:value-of select="count(package/class)"/></td> + <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> + <td class="small">LOC: <xsl:value-of select="count(package/class/sourcefile/sourceline)"/></td> + </tr> + </table> + <br/> + + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%" nowrap="nowrap"></th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <tr class="a"> + <td><b>Project</b></td> + <xsl:call-template name="stats.formatted"/> + </tr> + <tr> + <td colspan="3"><br/></td> + </tr> + <tr> + <th width="100%">Packages</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <!-- display packages and sort them via their coverage rate --> + <xsl:for-each select="package"> + <xsl:sort data-type="number" select="@totalcovered div @totalcount"/> + <tr> + <xsl:call-template name="alternate-row"/> + <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td> + <xsl:call-template name="stats.formatted"/> + </tr> + </xsl:for-each> + </table> + <xsl:call-template name="pageFooter"/> + </body> + </html> +</xsl:template> + +<!-- + detailed info for a package. It will output the list of classes +, the summary page, and the info for each class +--> +<xsl:template match="package" mode="write"> + <xsl:variable name="package.dir"> + <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if> + <xsl:if test="@name = ''">.</xsl:if> + </xsl:variable> + + <!-- create a classes-list.html in the package directory --> + <exsl:document href="efile://{$output.dir}/{$package.dir}/package-frame.html"> + <xsl:apply-templates select="." mode="classes.list"/> + </exsl:document> + + <!-- create a package-summary.html in the package directory --> + <exsl:document href="efile://{$output.dir}/{$package.dir}/package-summary.html"> + <xsl:apply-templates select="." mode="package.summary"/> + </exsl:document> + + <!-- for each class, creates a @name.html --> + <xsl:for-each select="class"> + <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}.html"> + <xsl:apply-templates select="." mode="class.details"/> + </exsl:document> + </xsl:for-each> +</xsl:template> + +<!-- list of classes in a package --> +<xsl:template match="package" mode="classes.list"> + <html> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="@name"/> + </xsl:call-template> + </HEAD> + <BODY> + <table width="100%"> + <tr> + <td nowrap="nowrap"> + <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2> + </td> + </tr> + </table> + + <H2>Classes</H2> + <TABLE WIDTH="100%"> + <xsl:for-each select="class"> + <xsl:sort select="@name"/> + <tr> + <td nowrap="nowrap"> + <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <i> (-)</i> + </xsl:when> + <xsl:otherwise> + <i>(<xsl:value-of select="format-number(@totalcovered div @totalcount, '0.0%')"/>)</i> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + </xsl:for-each> + </TABLE> + </BODY> + </html> +</xsl:template> + +<!-- summary of a package --> +<xsl:template match="package" mode="package.summary"> + <HTML> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="@name"/> + </xsl:call-template> + </HEAD> + <!-- when loading this package, it will open the classes into the frame --> + <BODY onload="open('package-frame.html','classListFrame')"> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr class="a"> + <td class="small">Classes: <xsl:value-of select="count(class)"/></td> + <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> + <td class="small">LOC: <xsl:value-of select="count(class/sourcefile/sourceline)"/></td> + </tr> + </table> + <br/> + + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%">Package</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <xsl:apply-templates select="." mode="stats"/> + + <xsl:if test="count(class) > 0"> + <tr> + <td colspan="3"><br/></td> + </tr> + <tr> + <th width="100%">Classes</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <xsl:apply-templates select="class" mode="stats"> + <xsl:sort data-type="number" select="@totalcovered div @totalcount"/> + </xsl:apply-templates> + </xsl:if> + </table> + <xsl:call-template name="pageFooter"/> + </BODY> + </HTML> +</xsl:template> + +<!-- details of a class --> +<xsl:template match="class" mode="class.details"> + <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> + <HTML> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="$package.name"/> + </xsl:call-template> + </HEAD> + <BODY> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr class="a"> + <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> + <td class="small">LOC: <xsl:value-of select="count(sourcefile/sourceline)"/></td> + </tr> + </table> + <br/> + + <!-- class summary --> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%">Source file</th> + <th>Statements</th> + <th>Methods</th> + <th width="250" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <tr> + <xsl:call-template name="alternate-row"/> + <td><xsl:value-of select="sourcefile/@name"/></td> + <xsl:call-template name="stats.formatted"/> + </tr> + </table> + <table cellspacing="0" cellpadding="0" width="100%"> + <xsl:apply-templates select="sourcefile/sourceline"/> + </table> + <br/> + <xsl:call-template name="pageFooter"/> + </BODY> + </HTML> + +</xsl:template> + +<!-- Page Header --> +<xsl:template name="pageHeader"> + <!-- jakarta logo --> + <table border="0" cellpadding="0" cellspacing="0" width="100%"> + <tr> + <td class="bannercell" rowspan="2"> + <a href="http://phing.info/"> + <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> + </a> + </td> + <td style="text-align:right"><h2>Source Code Coverage</h2></td> + </tr> + <tr> + <td style="text-align:right">Designed for use with <a href='http://pear.php.net/package/PHPUnit2'>PHPUnit2</a>, <a href='http://www.xdebug.org/'>Xdebug</a> and <a href='http://phing.info/'>Phing</a>.</td> + </tr> + </table> + <hr size="1"/> +</xsl:template> + +<!-- Page Footer --> +<xsl:template name="pageFooter"> + <table width="100%"> + <tr><td><hr noshade="yes" size="1"/></td></tr> + <tr><td class="small">Report generated at <xsl:value-of select="date:date-time()"/></td></tr> + </table> +</xsl:template> + +<xsl:template match="package" mode="stats"> + <tr> + <xsl:call-template name="alternate-row"/> + <td><xsl:value-of select="@name"/></td> + <xsl:call-template name="stats.formatted"/> + </tr> +</xsl:template> + +<xsl:template match="class" mode="stats"> + <tr> + <xsl:call-template name="alternate-row"/> + <td><a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a></td> + <xsl:call-template name="stats.formatted"/> + </tr> +</xsl:template> + +<xsl:template name="stats.formatted"> + <xsl:choose> + <xsl:when test="@statementcount=0"> + <td>-</td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@statementscovered div @statementcount,'0.0%')"/> + </td> + </xsl:otherwise> + </xsl:choose> + <xsl:choose> + <xsl:when test="@methodcount=0"> + <td>-</td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@methodscovered div @methodcount,'0.0%')"/> + </td> + </xsl:otherwise> + </xsl:choose> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <td>-</td> + <td> + <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> + <tr> + <td class="empty" width="200" height="12"> </td> + </tr> + </table> + </td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@totalcovered div @totalcount,'0.0%')"/> + </td> + <td> + <xsl:variable name="leftwidth"><xsl:value-of select="format-number((@totalcovered * 200) div @totalcount,'0')"/></xsl:variable> + <xsl:variable name="rightwidth"><xsl:value-of select="format-number(200 - (@totalcovered * 200) div @totalcount,'0')"/></xsl:variable> + <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> + <tr> + <xsl:choose> + <xsl:when test="$leftwidth=200"> + <td class="fullcover" width="200" height="12"> </td> + </xsl:when> + <xsl:otherwise> + <xsl:if test="not($leftwidth=0)"> + <td class="covered" width="{$leftwidth}" height="12"> </td> + </xsl:if> + <xsl:if test="not($rightwidth=0)"> + <td class="uncovered" width="{$rightwidth}" height="12"> </td> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </tr> + </table> + </td> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="sourceline"> + <tr> + <xsl:if test="@coveredcount>0"> + <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> + <td class="lineCountHighlight"><xsl:value-of select="@coveredcount"/></td> + </xsl:if> + <xsl:if test="@coveredcount<0"> + <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> + <td class="coverageCountHighlight">0</td> + </xsl:if> + <xsl:if test="@coveredcount=0"> + <td class="lineCount"><xsl:value-of select="position()"/></td> + <td class="coverageCount"></td> + </xsl:if> + <td> + <xsl:if test="@startclass=1"> + <xsl:attribute name="class">srcLineClassStart</xsl:attribute> + </xsl:if> + <xsl:if test="@coveredcount>0"> + <span class="srcLine"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </span> + </xsl:if> + <xsl:if test="@coveredcount<0"> + <span class="srcLineHighlight"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </span> + </xsl:if> + <xsl:if test="@coveredcount=0"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </xsl:if> + </td> + </tr> +</xsl:template> + +<!-- + transform string like a.b.c to ../../../ + @param path the path to transform into a descending directory path +--> +<xsl:template name="path"> + <xsl:param name="path"/> + <xsl:if test="contains($path,'.')"> + <xsl:text>../</xsl:text> + <xsl:call-template name="path"> + <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:if test="not(contains($path,'.')) and not($path = '')"> + <xsl:text>../</xsl:text> + </xsl:if> +</xsl:template> + + +<!-- create the link to the stylesheet based on the package name --> +<xsl:template name="create.stylesheet.link"> + <xsl:param name="package.name"/> + <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK> +</xsl:template> + +<!-- alternated row style --> +<xsl:template name="alternate-row"> +<xsl:attribute name="class"> + <xsl:if test="position() mod 2 = 1">a</xsl:if> + <xsl:if test="position() mod 2 = 0">b</xsl:if> +</xsl:attribute> +</xsl:template> + +</xsl:stylesheet> + + Modified: poc/etc/log.xsl =================================================================== --- poc/etc/log.xsl 2006-03-13 15:13:43 UTC (rev 24) +++ poc/etc/log.xsl 2006-03-14 13:57:51 UTC (rev 25) @@ -1,216 +1,216 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> -<xsl:output method="html" indent="yes" encoding="US-ASCII"/> -<!-- - Copyright 2000-2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> - -<!-- - - The purpose have this XSL is to provide a nice way to look at the output - from the Ant XmlLogger (ie: ant -listener org.apache.tools.ant.XmlLogger ) - - @author <a href="mailto:mi...@tr...>Michiel Rook</a> - @author <a href="mailto:sba...@ap...">Stephane Bailliez</a> - ---> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> - -<xsl:template match="/"> -<html> - <head> - <title>Phing Build Log</title> - <style type="text/css"> - .bannercell { - border: 0px; - padding: 0px; - } - body { - margin: 0; - font:normal 100% arial,helvetica,sanserif; - background-color:#FFFFFF; - color:#000000; - } - table.status { - font:bold 80% arial,helvetica,sanserif; - background-color:#525D76; - color:#ffffff; - } - table.log tr td, tr th { - font-size: 80%; - } - .error { - color:red; - } - .warn { - color:brown; - } - .info { - color:gray; - } - .debug{ - color:gray; - } - .failed { - font-size:80%; - background-color: red; - color:#FFFFFF; - font-weight: bold - } - .complete { - font-size:80%; - background-color: #525D76; - color:#FFFFFF; - font-weight: bold - } - .a td { - background: #efefef; - } - .b td { - background: #fff; - } - th, td { - text-align: left; - vertical-align: top; - } - th { - background: #ccc; - color: black; - } - table, th, td { - border: none - } - h3 { - font:bold 80% arial,helvetica,sanserif; - background: #525D76; - color: white; - text-decoration: none; - padding: 5px; - margin-right: 2px; - margin-left: 2px; - margin-bottom: 0; - } - a { - color: #003399; - } - a:hover { - color: #888888; - } - </style> - </head> - <body> - <!-- jakarta logo --> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> - <tr> - <td valign="top" class="bannercell"> - <a href="http://phing.info/"> - <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> - </a> - </td> - <td style="text-align:right;vertical-align:bottom"> - <a href="http://phing.info/">Phing</a> - </td> - </tr> - </table> - - <table border="0" width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - </table> - - <xsl:apply-templates select="build"/> - - <!-- FOOTER --> - <table width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - <tr><td> - <div align="center"><font color="#525D76" size="-1"><em> - <a href="http://phing.info/">Phing</a> - </em></font></div> - </td></tr> - </table> - </body> -</html> -</xsl:template> - -<xsl:template match="build"> - <!-- build status --> - <table width="100%"> - <xsl:attribute name="class"> - <xsl:if test="@error">failed</xsl:if> - <xsl:if test="not(@error)">complete</xsl:if> - </xsl:attribute> - <tr> - <xsl:if test="@error"> - <td nowrap="yes">Build Failed</td> - </xsl:if> - <xsl:if test="not(@error)"> - <td nowrap="yes">Build Complete</td> - </xsl:if> - <td style="text-align:right" nowrap="yes">Total Time: <xsl:value-of select="@time"/></td> - </tr> - <tr> - <td colspan="2"> - <xsl:if test="@error"> - <tt><xsl:value-of select="@error"/></tt><br/> - <i style="font-size:80%">See the <a href="#stacktrace" alt="Click for details">stacktrace</a>.</i> - </xsl:if> - </td> - </tr> - </table> - <table border="1" cellspacing="2" cellpadding="3" width="100%" style="font-size:80%"> - <tr class="a"><td width="1">phing.file</td><td><xsl:value-of select="substring-after(//message[contains(text(),'phing.file')], '->')"/></td></tr> - <tr class="b"><td width="1">phing.version</td><td><xsl:value-of select="substring-after(//message[contains(text(),'phing.version')], '->')"/></td></tr> - </table> - <!-- build information --> - <h3>Build events</h3> - <table class="log" border="1" cellspacing="2" cellpadding="3" width="100%"> - <tr> - <th nowrap="yes" align="left" width="1%">target</th> - <th nowrap="yes" align="left" width="1%">task</th> - <th nowrap="yes" align="left">message</th> - </tr> - <xsl:apply-templates select=".//message[@priority != 'debug']"/> - </table> - <p> - <!-- stacktrace --> - <xsl:if test="stacktrace"> - <a name="stacktrace"/> - <h3>Error details</h3> - <table width="100%"> - <tr><td> - <pre><xsl:value-of select="stacktrace"/></pre> - </td></tr> - </table> - </xsl:if> - </p> -</xsl:template> - -<!-- report every message but those with debug priority --> -<xsl:template match="message[@priority!='debug']"> - <tr valign="top"> - <!-- alternated row style --> - <xsl:attribute name="class"> - <xsl:if test="position() mod 2 = 1">a</xsl:if> - <xsl:if test="position() mod 2 = 0">b</xsl:if> - </xsl:attribute> - <td nowrap="yes" width="1%"><xsl:value-of select="../../@name"/></td> - <td nowrap="yes" style="text-align:right" width="1%">[ <xsl:value-of select="../@name"/> ]</td> - <td class="{@priority}" nowrap="yes"> - <xsl:value-of select="text()"/> - </td> - </tr> -</xsl:template> - -</xsl:stylesheet> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> +<xsl:output method="html" indent="yes" encoding="US-ASCII"/> +<!-- + Copyright 2000-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!-- + + The purpose have this XSL is to provide a nice way to look at the output + from the An... [truncated message content] |
From: <nma...@us...> - 2006-03-16 08:08:20
|
Revision: 28 Author: nmarkgraf Date: 2006-03-16 00:08:09 -0800 (Thu, 16 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=28&view=rev Log Message: ----------- Only minor changes: - Added copyright stuff to AllInclude.inc - Make some minor changes in build.xml Modified Paths: -------------- poc/build.xml poc/src/AllInclude.inc Property Changed: ---------------- poc/src/AllInclude.inc Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-15 12:34:45 UTC (rev 27) +++ poc/build.xml 2006-03-16 08:08:09 UTC (rev 28) @@ -6,6 +6,7 @@ <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> <mkdir dir="docs"/> + <mkdir dir="production"/> </target> <target name="preparedist"> @@ -88,11 +89,21 @@ </fileset> </tar> </target> + + <target name="production" depends="prepare"> + <copy todir="production"> + <fileset dir="src"> + <include name="**/*.php"/> + <include name="**/*.inc"/> + <exclude name="**/*Test.php"/> + </fileset> + </copy> + </target> <target name="build" depends="prepare,test,reports,docs,dist"> </target> - <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist"> + <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist,production"> </target> @@ -104,6 +115,7 @@ <delete dir="docs"/> <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> + <delete dir="production"/> </target> <target name="proper" depends="clean"> Modified: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc 2006-03-15 12:34:45 UTC (rev 27) +++ poc/src/AllInclude.inc 2006-03-16 08:08:09 UTC (rev 28) @@ -1,5 +1,22 @@ <?php +/** + * AllInclude include file + * + * I hope this is a temporay solution to the massiv require_once problem, + * but Axel is working on this, I hope. + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * + * @since 0.4.3 + */ +// Our own stuff: require_once( "OpenDocument.php" ); require_once( "OpenDocumentAbstract.php" ); require_once( "OpenDocumentObjectAbstract.php" ); @@ -13,6 +30,8 @@ require_once( "content/BodyText.php" ); require_once( "content/BodyTable.php" ); require_once( "styles/FontFaceDeclaration.php" ); +// Non-PEAR and not our stuff: require_once( "ZipFile.php" ); +// PEAR stuff: require_once( "Log.php" ); ?> \ No newline at end of file Property changes on: poc/src/AllInclude.inc ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-28 12:38:30
|
Revision: 37 Author: nmarkgraf Date: 2006-03-28 04:38:15 -0800 (Tue, 28 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=37&view=rev Log Message: ----------- New features: - PHing can make a copy for use in a production environment. Try "phing production" and look at "OpenDocumentPHP-0.5.0-solid.php" in "./dist" directory. - PHing can now create a single file out of all (nes.) files. Try "phing solid-production" and look in the "./production" directory. - New file "build.properties" now has the current release informations in i, and "build.xml" uses this information to build better names for produced files. Like "OpenDocumentPHP-0.5.0.zip" or "OpenDocumentPHP-0.5.0-solid.php" ... Norman Modified Paths: -------------- poc/build.xml Added Paths: ----------- poc/build.properties poc/etc/solid.txt Added: poc/build.properties =================================================================== --- poc/build.properties (rev 0) +++ poc/build.properties 2006-03-28 12:38:15 UTC (rev 37) @@ -0,0 +1,10 @@ +# This is the main build.xml property file. +# (C) by Norman Markgraf, Alex Latchford, et al. +# Published under GPL 2.0 or above. +# +# Last edited by $Author$ +# +# $Id$ +release=0.5.0 +releaseDos=0_5_0 +revision=$revision$ \ No newline at end of file Property changes on: poc/build.properties ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-23 09:06:06 UTC (rev 36) +++ poc/build.xml 2006-03-28 12:38:15 UTC (rev 37) @@ -1,6 +1,10 @@ <?xml version="1.0"?> <project name="OpenDocumentPHP" default="build" basedir="."> + + <property file="build.properties" /> + <property name="OpenDocumentPHPSolid" value="OpenDocumentPHP-${release}-solid.php" /> + <target name="prepare"> <mkdir dir="reports"/> <mkdir dir="reports/coverage"/> @@ -71,18 +75,18 @@ </target> <target name="dist" depends="preparedist"> - <zip destfile="dist/OpenDocumentPHP.zip" basedir="src"/> - <tar destfile="dist/OpenDocumentPHP.tar" basedir="src"/> + <zip destfile="dist/OpenDocumentPHP-${release}.zip" basedir="src"/> + <tar destfile="dist/OpenDocumentPHP-${release}.tar" basedir="src"/> </target> <target name="dev-dist" depends="preparedist"> - <zip destfile="dist/OpenDocumentPHPdev.zip" basedir="."> + <zip destfile="dist/OpenDocumentPHP-${release}-dev.zip" basedir="."> <fileset dir="."> <include name="**/**"/> <exclude name="**/?svn/**"/> </fileset> </zip> - <tar destfile="dist/OpenDocumentPHPdev.tar" basedir="."> + <tar destfile="dist/OpenDocumentPHP-${release}-dev.tar" basedir="."> <fileset dir="."> <include name="**/**"/> <exclude name="**/?svn/**"/> @@ -99,11 +103,34 @@ </fileset> </copy> </target> + + <target name="solid-production" depends="production"> + <mkdir dir="solid-production"/> + <copy todir="solid-production"> <!--"/OpenDocumentPHP-solid.php" overwrite="true" --> + <fileset dir="production"> + <include name="**/*.php" /> + </fileset> + <filterchain> + <replaceregexp> + <regexp pattern=".*require_once" replace="//require_once" ignoreCase="true" /> + <regexp pattern=".*include_once" replace="//include_once" ignoreCase="true" /> + <regexp pattern=".+this-.logger.+" replace="//this-logger-" /> + </replaceregexp> + <stripphpcomments /> + </filterchain> + </copy> + <!-- echo msg="${OpenDocumentPHPSolid}"/--> + <!-- echo msg="${os.name}"/--> + <exec command="copy ..\etc\solid.txt + *.php + manifest\*.php + content\*.php + settings\*.php + styles\*.php tmp.tmp" dir="solid-production"/> + <exec command="cat ../etc/solid.txt > ../tmp.tmp && cat *.php >> ../tmp.tmp && cat */*.php >> ../tmp.tmp" dir="solid-production" os="linux"/> + <copy file="solid-production/tmp.tmp" tofile="dist/${OpenDocumentPHPSolid}" overwrite="true"/> + <delete dir="solid-production"/> + </target> <target name="build" depends="prepare,test,reports,docs,dist"> </target> - <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist,production"> + <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist,production,solid-production"> </target> @@ -116,9 +143,11 @@ <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> <delete dir="production"/> + <delete dir="solid-production"/> </target> <target name="proper" depends="clean"> <delete dir="reports"/> + <delete file="${OpenDocumentPHPSolid}"/> </target> </project> Added: poc/etc/solid.txt =================================================================== --- poc/etc/solid.txt (rev 0) +++ poc/etc/solid.txt 2006-03-28 12:38:15 UTC (rev 37) @@ -0,0 +1,20 @@ +<?php +/** + * OpenDocumentPHP in one solid file! + * + * This is a generated Text, please do not edit any thing in this file! Use the + * non solid files instead! + * + * + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * + * @since 0.5.0 + */ + ?> \ No newline at end of file Property changes on: poc/etc/solid.txt ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-29 09:00:18
|
Revision: 39 Author: nmarkgraf Date: 2006-03-29 00:59:58 -0800 (Wed, 29 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=39&view=rev Log Message: ----------- Some changes: - ZipFile.php is now in the others directory, to show that this is mainly not our code. - The TestInput.php and TestOutput.php in the samples directory are now checking in they used with the right PHP version. - Added some descriptions to build.xml, so "phing -projecthelp" will display something useful. Modified Paths: -------------- poc/build.xml poc/src/AllInclude.inc poc/src/OpenDocumentPackage.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php Added Paths: ----------- poc/src/others/ poc/src/others/ZipFile.php Removed Paths: ------------- poc/src/ZipFile.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-29 08:36:06 UTC (rev 38) +++ poc/build.xml 2006-03-29 08:59:58 UTC (rev 39) @@ -10,6 +10,7 @@ <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> <mkdir dir="docs"/> + <mkdir dir="docs/${release}"/> <mkdir dir="production"/> </target> @@ -19,8 +20,12 @@ <target name="preparetest"> <mkdir dir="reports"/> + <mkdir dir="reports/data"/> + <mkdir dir="reports/data/${release}"/> <mkdir dir="reports/coverage"/> + <mkdir dir="reports/coverage/${release}"/> <mkdir dir="reports/tests"/> + <mkdir dir="reports/tests/${release}"/> </target> <target name="preparereport"> @@ -30,7 +35,7 @@ </target> <target name="reports" depends="preparereport"> - <coverage-setup database="reports/coverage.db"> + <coverage-setup database="reports/data/${release}/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> <exclude name="**/*Test.php"/> @@ -39,7 +44,7 @@ </coverage-setup> <phpunit2 codecoverage="true" haltonerror="false" haltonfailure="false" printsummary="false"> - <formatter type="xml" todir="reports"/> + <formatter type="xml" todir="reports/data/${release}"/> <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> @@ -47,16 +52,16 @@ </batchtest> </phpunit2> - <phpunit2report infile="reports/testsuites.xml" format="frames" todir="reports/tests" styledir="etc"/> + <phpunit2report infile="reports/data/${release}/testsuites.xml" format="frames" todir="reports/tests/${release}" styledir="etc"/> - <coverage-report outfile="reports/coverage.xml"> - <report todir="reports/coverage" styledir="etc"/> + <coverage-report outfile="reports/data/${release}/coverage.xml"> + <report todir="reports/coverage/${release}" styledir="etc"/> </coverage-report> </target> <target name="test" depends="preparetest"> <phpunit2 haltonerror="false" haltonfailure="false" printsummary="true"> - <formatter todir="reports" type="xml"/> + <formatter todir="reports/data/${release}" type="xml"/> <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> @@ -64,22 +69,27 @@ </batchtest> </phpunit2> - <phpunit2report infile="reports/testsuites.xml" format="frames" todir="reports/tests" styledir="etc"/> + <phpunit2report infile="reports/data/${release}/testsuites.xml" format="frames" todir="reports/tests/${release}" styledir="etc"/> </target> - <target name="docs"> - <phpdoc title="OpenDocumentPHP" destdir="docs" + <target name="docs" description="Creates PHPDocumentor documents in a directory in the docs directory."> + <phpdoc title="OpenDocumentPHP" destdir="docs/${release}" sourcepath="src" output="HTML:Smarty:PHP" linksource="true"/> </target> - <target name="dist" depends="preparedist"> - <zip destfile="dist/OpenDocumentPHP-${release}.zip" basedir="src"/> - <tar destfile="dist/OpenDocumentPHP-${release}.tar" basedir="src"/> + <target name="dist" depends="production" description="Creates a snapshot of the current production release in a zip and a tar file in the dist directory."> + <zip destfile="dist/OpenDocumentPHP-${release}.zip" basedir="production"/> + <tar destfile="dist/OpenDocumentPHP-${release}.tar" basedir="production"/> </target> - <target name="dev-dist" depends="preparedist"> + <target name="dist-src" depends="preparedist" description="Creates a snapshot of the current src directory in a zip and a tar file in the dist directory."> + <zip destfile="dist/OpenDocumentPHP-${release}-src.zip" basedir="src"/> + <tar destfile="dist/OpenDocumentPHP-${release}-src.tar" basedir="src"/> + </target> + + <target name="dev-dist" depends="preparedist" description="Creates a snapshot of the all the current project directories in a zip and a tar file in the dist directory."> <zip destfile="dist/OpenDocumentPHP-${release}-dev.zip" basedir="."> <fileset dir="."> <include name="**/**"/> @@ -94,7 +104,7 @@ </tar> </target> - <target name="production" depends="prepare"> + <target name="production" depends="prepare" description="Creates a production release without unit tests in the production directory."> <copy todir="production"> <fileset dir="src"> <include name="**/*.php"/> @@ -104,7 +114,7 @@ </copy> </target> - <target name="solid-production" depends="production"> + <target name="solid-production" depends="production" description="Creates a single file production release without unit tests in the dist directory."> <mkdir dir="solid-production"/> <copy todir="solid-production"> <!--"/OpenDocumentPHP-solid.php" overwrite="true" --> <fileset dir="production"> @@ -116,7 +126,10 @@ <regexp pattern=".*include_once" replace="//include_once" ignoreCase="true" /> <regexp pattern=".+this-.logger.+" replace="//this-logger-" /> </replaceregexp> - <stripphpcomments /> + <!-- stripphpcomments /--> + <striplinecomments> + <comment value="//" /> + </striplinecomments> </filterchain> </copy> <!-- echo msg="${OpenDocumentPHPSolid}"/--> @@ -139,7 +152,7 @@ <delete file="reports/testsuites.xml"/> <delete dir="reports/tests"/> <delete dir="reports/coverage"/> - <delete dir="docs"/> + <delete dir="docs/${release}"/> <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> <delete dir="production"/> @@ -148,6 +161,7 @@ <target name="proper" depends="clean"> <delete dir="reports"/> - <delete file="${OpenDocumentPHPSolid}"/> + <delete file="${OpenDocumentPHPSolid}"/> + <delete dir="docs"/> </target> </project> Modified: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc 2006-03-29 08:36:06 UTC (rev 38) +++ poc/src/AllInclude.inc 2006-03-29 08:59:58 UTC (rev 39) @@ -32,7 +32,7 @@ require_once( "content/BodyTable.php" ); require_once( "styles/FontFaceDeclaration.php" ); // Non-PEAR and not our stuff: -require_once( "ZipFile.php" ); +require_once( "others/ZipFile.php" ); // PEAR stuff: require_once( "Log.php" ); ?> \ No newline at end of file Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-29 08:36:06 UTC (rev 38) +++ poc/src/OpenDocumentPackage.php 2006-03-29 08:59:58 UTC (rev 39) @@ -26,6 +26,8 @@ require_once( "content/Body.php" ); require_once( "OpenDocumentAbstract.php" ); +require_once( "others/ZipFile.php" ); + class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { private $packagename; @@ -49,7 +51,7 @@ $this->isCommited = false; $this->logger->debug( "Generating ZipFile object." ); - $this->zip = new ZipFile; + $this->zip = new ZipFile(); if ( !empty( $documentName ) ) { $this->setPackageName( $documentName ); Deleted: poc/src/ZipFile.php =================================================================== --- poc/src/ZipFile.php 2006-03-29 08:36:06 UTC (rev 38) +++ poc/src/ZipFile.php 2006-03-29 08:59:58 UTC (rev 39) @@ -1,184 +0,0 @@ -<?php -/** - * Zip file creation class. - * Makes zip files. - * - * Based on : - * - * http://www.zend.com/codex.php?id=535&single=1 - * By Eric Mueller <er...@th...> - * - * http://www.zend.com/codex.php?id=470&single=1 - * by Denis125 <web...@at...> - * - * a patch from Peter Listiak <ml...@us...> for last modified - * date and time of the compressed file - * - * Official ZIP file format: http://www.pkware.com/appnote.txt - * - * @access public - */ -class ZipFile -{ - /** - * Array to store compressed data - * - * @var array $datasec - */ - private $datasec = array(); - - /** - * Central directory - * - * @var array $ctrl_dir - */ - private $ctrl_dir = array(); - - /** - * End of central directory record - * - * @var string $eof_ctrl_dir - */ - private $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; - - /** - * Last offset position - * - * @var integer $old_offset - */ - private $old_offset = 0; - - - /** - * Converts an Unix timestamp to a four byte DOS date and time format (date - * in high two bytes, time in low two bytes allowing magnitude comparison). - * - * @param integer the current Unix timestamp - * - * @return integer the current date in a four byte DOS format - * - * @access private - */ - private function unix2DosTime($unixtime = 0) { - $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); - - if ($timearray['year'] < 1980) { - $timearray['year'] = 1980; - $timearray['mon'] = 1; - $timearray['mday'] = 1; - $timearray['hours'] = 0; - $timearray['minutes'] = 0; - $timearray['seconds'] = 0; - } // end if - - return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | - ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); - } // end of the 'unix2DosTime()' method - - - /** - * Adds "file" to archive - * - * @param string file contents - * @param string name of the file in the archive (may contains the path) - * @param integer the current timestamp - * - * @access public - */ - public function addFile($data, $name, $time = 0) - { - $name = str_replace('\\', '/', $name); - - $dtime = dechex($this->unix2DosTime($time)); - $hexdtime = '\x' . $dtime[6] . $dtime[7] - . '\x' . $dtime[4] . $dtime[5] - . '\x' . $dtime[2] . $dtime[3] - . '\x' . $dtime[0] . $dtime[1]; - eval('$hexdtime = "' . $hexdtime . '";'); - - $fr = "\x50\x4b\x03\x04"; - $fr .= "\x14\x00"; // ver needed to extract - $fr .= "\x00\x00"; // gen purpose bit flag - $fr .= "\x08\x00"; // compression method - $fr .= $hexdtime; // last mod time and date - - // "local file header" segment - $unc_len = strlen($data); - $crc = crc32($data); - $zdata = gzcompress($data); - $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug - $c_len = strlen($zdata); - $fr .= pack('V', $crc); // crc32 - $fr .= pack('V', $c_len); // compressed filesize - $fr .= pack('V', $unc_len); // uncompressed filesize - $fr .= pack('v', strlen($name)); // length of filename - $fr .= pack('v', 0); // extra field length - $fr .= $name; - - // "file data" segment - $fr .= $zdata; - - // "data descriptor" segment (optional but necessary if archive is not - // served as file) - // nijel(2004-10-19): this seems not to be needed at all and causes - // problems in some cases (bug #1037737) - //$fr .= pack('V', $crc); // crc32 - //$fr .= pack('V', $c_len); // compressed filesize - //$fr .= pack('V', $unc_len); // uncompressed filesize - - // add this entry to array - $this -> datasec[] = $fr; - - // now add to central directory record - $cdrec = "\x50\x4b\x01\x02"; - $cdrec .= "\x00\x00"; // version made by - $cdrec .= "\x14\x00"; // version needed to extract - $cdrec .= "\x00\x00"; // gen purpose bit flag - $cdrec .= "\x08\x00"; // compression method - $cdrec .= $hexdtime; // last mod time & date - $cdrec .= pack('V', $crc); // crc32 - $cdrec .= pack('V', $c_len); // compressed filesize - $cdrec .= pack('V', $unc_len); // uncompressed filesize - $cdrec .= pack('v', strlen($name) ); // length of filename - $cdrec .= pack('v', 0 ); // extra field length - $cdrec .= pack('v', 0 ); // file comment length - $cdrec .= pack('v', 0 ); // disk number start - $cdrec .= pack('v', 0 ); // internal file attributes - $cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set - - $cdrec .= pack('V', $this -> old_offset ); // relative offset of local header - $this -> old_offset += strlen($fr); - - $cdrec .= $name; - - // optional extra field, file comment goes here - // save to central directory - $this -> ctrl_dir[] = $cdrec; - } // end of the 'addFile()' method - - - /** - * Dumps out file - * - * @return string the zipped file - * - * @access public - */ - public function file() - { - $data = implode('', $this -> datasec); - $ctrldir = implode('', $this -> ctrl_dir); - - return - $data . - $ctrldir . - $this -> eof_ctrl_dir . - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall - pack('V', strlen($ctrldir)) . // size of central dir - pack('V', strlen($data)) . // offset to start of central dir - "\x00\x00"; // .zip file comment length - } // end of the 'file()' method - -} // end of the 'zipfile' class -?> \ No newline at end of file Added: poc/src/others/ZipFile.php =================================================================== --- poc/src/others/ZipFile.php (rev 0) +++ poc/src/others/ZipFile.php 2006-03-29 08:59:58 UTC (rev 39) @@ -0,0 +1,196 @@ +<?php +/** + * + * THIS IS NOT PART OF THE CODE DEVELOPT BY THE OpenDocumentPHP TEAM! + * ================================================================== + * $Id$ + * + * @version $Revision$ + * @package OpenDocument + * @subpackage others + * @since 0.4.0 + * + * ================================================================== + * + * Zip file creation class. + * Makes zip files. + * + * Based on : + * + * http://www.zend.com/codex.php?id=535&single=1 + * By Eric Mueller <er...@th...> + * + * http://www.zend.com/codex.php?id=470&single=1 + * by Denis125 <web...@at...> + * + * a patch from Peter Listiak <ml...@us...> for last modified + * date and time of the compressed file + * + * Official ZIP file format: http://www.pkware.com/appnote.txt + * + * @access public + */ +class ZipFile +{ + /** + * Array to store compressed data + * + * @var array $datasec + */ + private $datasec = array(); + + /** + * Central directory + * + * @var array $ctrl_dir + */ + private $ctrl_dir = array(); + + /** + * End of central directory record + * + * @var string $eof_ctrl_dir + */ + private $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + + /** + * Last offset position + * + * @var integer $old_offset + */ + private $old_offset = 0; + + + /** + * Converts an Unix timestamp to a four byte DOS date and time format (date + * in high two bytes, time in low two bytes allowing magnitude comparison). + * + * @param integer the current Unix timestamp + * + * @return integer the current date in a four byte DOS format + * + * @access private + */ + private function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); + } // end of the 'unix2DosTime()' method + + + /** + * Adds "file" to archive + * + * @param string file contents + * @param string name of the file in the archive (may contains the path) + * @param integer the current timestamp + * + * @access public + */ + public function addFile($data, $name, $time = 0) + { + $name = str_replace('\\', '/', $name); + + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; // ver needed to extract + $fr .= "\x00\x00"; // gen purpose bit flag + $fr .= "\x08\x00"; // compression method + $fr .= $hexdtime; // last mod time and date + + // "local file header" segment + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug + $c_len = strlen($zdata); + $fr .= pack('V', $crc); // crc32 + $fr .= pack('V', $c_len); // compressed filesize + $fr .= pack('V', $unc_len); // uncompressed filesize + $fr .= pack('v', strlen($name)); // length of filename + $fr .= pack('v', 0); // extra field length + $fr .= $name; + + // "file data" segment + $fr .= $zdata; + + // "data descriptor" segment (optional but necessary if archive is not + // served as file) + // nijel(2004-10-19): this seems not to be needed at all and causes + // problems in some cases (bug #1037737) + //$fr .= pack('V', $crc); // crc32 + //$fr .= pack('V', $c_len); // compressed filesize + //$fr .= pack('V', $unc_len); // uncompressed filesize + + // add this entry to array + $this -> datasec[] = $fr; + + // now add to central directory record + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; // version made by + $cdrec .= "\x14\x00"; // version needed to extract + $cdrec .= "\x00\x00"; // gen purpose bit flag + $cdrec .= "\x08\x00"; // compression method + $cdrec .= $hexdtime; // last mod time & date + $cdrec .= pack('V', $crc); // crc32 + $cdrec .= pack('V', $c_len); // compressed filesize + $cdrec .= pack('V', $unc_len); // uncompressed filesize + $cdrec .= pack('v', strlen($name) ); // length of filename + $cdrec .= pack('v', 0 ); // extra field length + $cdrec .= pack('v', 0 ); // file comment length + $cdrec .= pack('v', 0 ); // disk number start + $cdrec .= pack('v', 0 ); // internal file attributes + $cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set + + $cdrec .= pack('V', $this -> old_offset ); // relative offset of local header + $this -> old_offset += strlen($fr); + + $cdrec .= $name; + + // optional extra field, file comment goes here + // save to central directory + $this -> ctrl_dir[] = $cdrec; + } // end of the 'addFile()' method + + + /** + * Dumps out file + * + * @return string the zipped file + * + * @access public + */ + public function file() + { + $data = implode('', $this -> datasec); + $ctrldir = implode('', $this -> ctrl_dir); + + return + $data . + $ctrldir . + $this -> eof_ctrl_dir . + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall + pack('V', strlen($ctrldir)) . // size of central dir + pack('V', strlen($data)) . // offset to start of central dir + "\x00\x00"; // .zip file comment length + } // end of the 'file()' method + +} // end of the 'zipfile' class +?> \ No newline at end of file Property changes on: poc/src/others/ZipFile.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-29 08:36:06 UTC (rev 38) +++ poc/src/samples/TestInput.php 2006-03-29 08:59:58 UTC (rev 39) @@ -55,6 +55,9 @@ <title>TestOutput File!</title> </head> <body> +<?php if (version_compare(PHP_VERSION, "5.0.0") < 0) { + ?><p>This web server runs PHP <?php echo PHP_VERSION ?> ! Be aware that <strong>OpenDocumentPHP</strong> will <strong>not work</strong>!</p><?php +}?> <form method="POST" action="TestOutput.php"> <fieldset> <legend>Generate a sample OpenDocument:</legend> Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-29 08:36:06 UTC (rev 38) +++ poc/src/samples/TestOutput.php 2006-03-29 08:59:58 UTC (rev 39) @@ -21,10 +21,16 @@ ini_set( "include_path", ini_get( "include_path" ). "$sep$IP" ); include_once( "AllInclude.inc" ); - require_once( "OpenDocumentFactory.php" ); require_once( "Log/observer.php" ); +/* If you remove all "$this->logger" statements you and the *_once lines above you can try this: */ +// require_once( "OpenDocumentPHP-0.5.0-solid.php" ); + +if (version_compare(PHP_VERSION, "5.0.0") < 0) { + die( "You need at least PHP 5.0.0 to run this script!" ); +} + class TestOutput { const DocumentName = "test.odt"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-29 11:01:19
|
Revision: 40 Author: nmarkgraf Date: 2006-03-29 03:01:01 -0800 (Wed, 29 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=40&view=rev Log Message: ----------- Minor updates: - Fixed some bugs in the OpenDocumentSingle, Styles and FontFaceDeclaration classes. - PHing now removes "?><?php" lines when make solid file. TestOutput now works, but OpenOffice still does not take the document as it should be. This is a BUG that must be solved before 0.5.0 can be announced. Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentSingle.php poc/src/samples/TestOutput.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/Styles.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-29 08:59:58 UTC (rev 39) +++ poc/build.xml 2006-03-29 11:01:01 UTC (rev 40) @@ -134,9 +134,15 @@ </copy> <!-- echo msg="${OpenDocumentPHPSolid}"/--> <!-- echo msg="${os.name}"/--> - <exec command="copy ..\etc\solid.txt + *.php + manifest\*.php + content\*.php + settings\*.php + styles\*.php tmp.tmp" dir="solid-production"/> + <exec command="copy ..\etc\solid.txt + *.php + manifest\*.php + content\*.php + settings\*.php + styles\*.php + meta\*.php tmp.tmp" dir="solid-production"/> <exec command="cat ../etc/solid.txt > ../tmp.tmp && cat *.php >> ../tmp.tmp && cat */*.php >> ../tmp.tmp" dir="solid-production" os="linux"/> - <copy file="solid-production/tmp.tmp" tofile="dist/${OpenDocumentPHPSolid}" overwrite="true"/> + <copy file="solid-production/tmp.tmp" tofile="dist/${OpenDocumentPHPSolid}" overwrite="true"> + <filterchain> + <replaceregexp> + <regexp pattern="\?>.\?php" replace=" " /> + </replaceregexp> + </filterchain> + </copy> <delete dir="solid-production"/> </target> Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-29 08:59:58 UTC (rev 39) +++ poc/src/OpenDocumentSingle.php 2006-03-29 11:01:01 UTC (rev 40) @@ -109,8 +109,7 @@ * @since 0.3.0 */ public function addXMLDocument( $fullpath, $domFrag, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . - ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); + $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); $this->dom->appendChild( $domFrag ); } Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-29 08:59:58 UTC (rev 39) +++ poc/src/samples/TestOutput.php 2006-03-29 11:01:01 UTC (rev 40) @@ -65,10 +65,28 @@ function makeFontFaceDecl( $fontFaceDecl ) { $styleAttr = array(); - $styleAttr[ "font-family" ] ="Tahoma"; - $fontFaceDecl->addFontFace( "Test", $styleAttr ); + $svgAttr = array(); + + $styleAttr[ "font-pitch" ] = "variable"; + $svgAttr [ "font-family" ] = "'Arial Unicode MS'"; + $fontFaceDecl->addFontFace( "Arial Unicode MS", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "Tahoma"; + $fontFaceDecl->addFontFace( "Tahoma", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "'MS Mincho'"; + $fontFaceDecl->addFontFace( "MS Mincho", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "'Times New Roman'"; + $styleAttr[ "font-family-generic" ] = "roman"; + $fontFaceDecl->addFontFace( "Times New Roman", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "Arial"; + $styleAttr[ "font-family-generic" ] = "swiss"; + $fontFaceDecl->addFontFace( "Arial", $styleAttr, $svgAttr ); } + function makeAutomaticStyles( $automaticStyles ) { // return $automaticStyles; } @@ -77,7 +95,7 @@ // return $scripts; } - function makeStyle( $style ) { + function makeStyle( $style ) { // Set default style $style->addDefaultStyle( "paragraph" ); @@ -119,10 +137,21 @@ //Set a style $styleAttr = array( "family"=>"paragraph", "class"=>"text" ); + $style->addStyle( "Standard", $styleAttr ); + + //Set a style + $styleAttr = array( "family"=>"paragraph", "class"=>"text" ); + $styleAttr[ "display-name" ] = "Paragraph ODP"; + $styleAttr[ "parent-style-name" ] = "Standard"; $style->addStyle( "Paragraph", $styleAttr ); - //Set a style - $style->addStyle( "Heading", $styleAttr ); + //Set a style + $styleAttr[ "default-outline-level" ] = "1"; + $styleAttr[ "display-name" ] = "Heading ODP"; + $styleAttr[ "parent-style-name" ] = "Standard"; + $styleAttr[ "next-style-name" ] = "Standard"; + $foAttr[ "font-weight" ] = "bold"; + $style->addStyle( "Heading", $styleAttr, $foAttr ); unset( $styleAttr ); unset( $foAttr ); @@ -137,7 +166,7 @@ $styleAttr[ "font-name" ] = "Arial"; $styleAttr[ "font-name-asian" ] = "MS Mincho"; $styleAttr[ "font-size" ] = "20pt"; - $styleAttr[ "font-name-complex" ] = "Tahoma1"; + $styleAttr[ "font-name-complex" ] = "Tahoma"; $styleAttr[ "font-size-complex" ] = "20pt"; $style->addStyleTextProperties( "Heading", $styleAttr, $foAttr ); } Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-29 08:59:58 UTC (rev 39) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-29 11:01:01 UTC (rev 40) @@ -124,7 +124,7 @@ } } } - if (!empty($SVGAtrr)) { + if (!empty($SVGAttr)) { foreach( $SVGAttr as $key => $value ) { // ***FIX ME*** Here we should check if the keys are possible if ($this->checkSVG( $key, $value )) { Modified: poc/src/styles/Styles.php =================================================================== --- poc/src/styles/Styles.php 2006-03-29 08:59:58 UTC (rev 39) +++ poc/src/styles/Styles.php 2006-03-29 11:01:01 UTC (rev 40) @@ -120,7 +120,8 @@ $this->root->appendChild( $this->MasterStyles->get() ); $this->styles->appendChild( $this->root ); - $this->dom->normalize(); + $this->dom->normalize(); + $this->dom->normalize(); $this->isCommited = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-30 08:24:56
|
Revision: 42 Author: nmarkgraf Date: 2006-03-30 00:24:22 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=42&view=rev Log Message: ----------- Refactoring session: - Removed OpenDocumentObjectAbstractTest, because namespaces now have a class names NameSpaces. Most of the unit test is now in NameSpacesTest.php. - Much fixes in other classes to match these changes. Remarks: - I think OpenDocumentObjectAbstract is obsolete and can be removed in future. Most of the stuff in it can be made in OpenDocumentAbstract. - All base classes should moved to util directory to clean up a little bit. Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php poc/src/content/Content.php poc/src/content/Scripts.php poc/src/manifest/Manifest.php poc/src/meta/Meta.php poc/src/samples/TestOutput.php poc/src/settings/Settings.php poc/src/styles/AutomaticStyles.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/MasterStyles.php poc/src/styles/Style.php poc/src/styles/Styles.php Added Paths: ----------- poc/src/util/ poc/src/util/NameSpaces.php poc/src/util/NameSpacesTest.php Removed Paths: ------------- poc/src/OpenDocumentObjectAbstractTest.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-29 13:59:14 UTC (rev 41) +++ poc/build.xml 2006-03-30 08:24:22 UTC (rev 42) @@ -81,12 +81,12 @@ <target name="dist" depends="production" description="Creates a snapshot of the current production release in a zip and a tar file in the dist directory."> <zip destfile="dist/OpenDocumentPHP-${release}.zip" basedir="production"/> - <tar destfile="dist/OpenDocumentPHP-${release}.tar" basedir="production"/> + <tar destfile="dist/OpenDocumentPHP-${release}.tar.gz" basedir="production" compression="gzip"/> </target> <target name="dist-src" depends="preparedist" description="Creates a snapshot of the current src directory in a zip and a tar file in the dist directory."> <zip destfile="dist/OpenDocumentPHP-${release}-src.zip" basedir="src"/> - <tar destfile="dist/OpenDocumentPHP-${release}-src.tar" basedir="src"/> + <tar destfile="dist/OpenDocumentPHP-${release}-src.tar.gz" basedir="src" compression="gzip"/> </target> <target name="dev-dist" depends="preparedist" description="Creates a snapshot of the all the current project directories in a zip and a tar file in the dist directory."> @@ -94,16 +94,27 @@ <fileset dir="."> <include name="**/**"/> <exclude name="**/?svn/**"/> + <exclude name="**/dist/**"/> + <exclude name="**/reports/**"/> + <exclude name="**/docs/**"/> + <exclude name="**/production/**"/> </fileset> </zip> - <tar destfile="dist/OpenDocumentPHP-${release}-dev.tar" basedir="."> + <tar destfile="dist/OpenDocumentPHP-${release}-dev.tar.gz" basedir="." compression="gzip"> <fileset dir="."> <include name="**/**"/> <exclude name="**/?svn/**"/> + <exclude name="**/dist/**"/> + <exclude name="**/reports/**"/> + <exclude name="**/docs/**"/> + <exclude name="**/production/**"/> </fileset> - </tar> + </tar> </target> + <target name="dist-all" depends="dist,dist-src,dev-dist,solid-production" description="Creates a all snapshots in the dist directory."> + </target> + <target name="production" depends="prepare" description="Creates a production release without unit tests in the production directory."> <copy todir="production"> <fileset dir="src"> Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-30 08:24:22 UTC (rev 42) @@ -15,118 +15,8 @@ require_once( "OpenDocumentAbstract.php" ); class OpenDocumentObjectAbstract extends OpenDocumentAbstract { - - /** - * namespace OpenDocument meta - */ - const NS_META = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; - - /** - * namespace OpenDocument office - */ - const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; - - /** - * namespace OpenDocument manifest - */ - const NS_MANIFEST = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; /** - * namespace OpenDocument style - */ - const NS_STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; - - /** - * namespace OpenDocument text - */ - const NS_TEXT = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"; - - /** - * namespace OpenDocument draw - */ - const NS_DRAW = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; - - /** - * namespace OpenDocument table - */ - const NS_TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"; - - /** - * namespace OpenDocument number - */ - const NS_NUMBER = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; - - /** - * namespace OpenDocument chart - */ - const NS_CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; - - /** - * namespace OpenDocument form - */ - const NS_FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; - - /** - * namespace OpenDocument config - */ - const NS_CONFIG = "urn:oasis:names:tc:opendocument:xmlns:config:1.0"; - - /** - * namespace OpenDocument presentation - */ - const NS_PRESENTATION = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"; - - /** - * namespace OpenDocument dr3d - */ - const NS_DR3D = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; - - /** - * namespace OpenDocument animation - */ - const NS_ANIM = "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"; - - /** - * namespace OpenDocument script - */ - const NS_SCRIPT = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"; - - /** - * namespace OpenDocument svg - */ - const NS_SVG = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; - - /** - * namespace OpenDocument fo (formation objects) - */ - const NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; - - /** - * namespace OpenDocument smil - */ - const NS_SMIL = "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"; - - /** - * namespace Dublin Core - */ - const NS_DC = "http://purl.org/dc/elements/1.1/"; - - /** - * namespace XLink - */ - const NS_XLINK = "http://www.w3.org/1999/xlink"; - - /** - * namespace XForms - */ - const NS_XFORMS = "http://www.w3.org/2002/xforms"; - - /** - * namespace MathML - */ - const NS_MATHML = "http://www.w3.org/1998/Math/MathML"; - - /** * @access protected */ protected $dom; Deleted: poc/src/OpenDocumentObjectAbstractTest.php =================================================================== --- poc/src/OpenDocumentObjectAbstractTest.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/OpenDocumentObjectAbstractTest.php 2006-03-30 08:24:22 UTC (rev 42) @@ -1,74 +0,0 @@ -<?php -/** - * TestCase for OpenDocumentObjectAbstract class - * - * $Id$ - * - * @copyright Copyright © 2006, Norman Markgraf, et al. - * @license GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * @subpackage UnitTest - * @since 0.5.0 - */ - -require_once "PHPUnit2/Framework/TestCase.php"; -require_once "OpenDocumentObjectAbstract.php"; - -class OpenDocumentObjectAbstractTest extends PHPUnit2_Framework_TestCase { - -const office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"; -const style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"; -const text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"; -const table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"; -const draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; -const fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; -const xlink="http://www.w3.org/1999/xlink"; -const dc="http://purl.org/dc/elements/1.1/"; -const meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; -const number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; -const svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; -const chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; -const dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; -const math="http://www.w3.org/1998/Math/MathML"; -const form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"; -const script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"; -const ooo="http://openoffice.org/2004/office"; -const ooow="http://openoffice.org/2004/writer"; -const oooc="http://openoffice.org/2004/calc"; -const dom="http://www.w3.org/2001/xml-events"; - - /** - * This test will check all name spaces. The namespaces in this file are extracted from - * an OpenOffice document, so they are not written by hand out of the OpenDocument documentation. - * This should help to fix typos. (And it did!!!) - * - * @since 0.5.0 - */ - function testNamespaces() { - $this->assertEquals( OpenDocumentObjectAbstract::NS_OFFICE, self::office ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_STYLE, self::style ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_TEXT, self::text ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_TABLE, self::table ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_DRAW, self::draw ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_FO, self::fo ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_XLINK, self::xlink ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_DC, self::dc ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_META, self::meta ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_NUMBER, self::number ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_SVG, self::svg ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_CHART, self::chart ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_DR3D, self::dr3d ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_MATHML, self::math ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_FORM, self::form ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_SCRIPT, self::script ); -/* - $this->assertEquals( OpenDocumentObjectAbstract::NS_OOO, self::ooo ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_OOOW, self::ooow ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_OOOC, self::oooc ); - $this->assertEquals( OpenDocumentObjectAbstract::NS_DOM, self::dom ); -*/ - } -} -?> \ No newline at end of file Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/OpenDocumentSingle.php 2006-03-30 08:24:22 UTC (rev 42) @@ -25,6 +25,7 @@ require_once( "styles/MasterStyles.php" ); require_once( "content/Body.php" ); require_once( "OpenDocumentAbstract.php" ); +require_once( "util/NameSpaces.php" ); class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { /** @@ -49,12 +50,6 @@ private $root; /** - * namespace OpenDocument office - * @since 0.3.0 - */ - const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; - - /** * * @access public * @@ -68,8 +63,8 @@ $this->isCommited = false; $this->dom = new DOMDocument( "1.0", "utf-8" ); - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:document" ); + $this->root->setAttributeNS( NS::OFFICE, "office:mimetype", $mimetype ); $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); Modified: poc/src/OpenDocumentSingleTest.php =================================================================== --- poc/src/OpenDocumentSingleTest.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/OpenDocumentSingleTest.php 2006-03-30 08:24:22 UTC (rev 42) @@ -38,12 +38,30 @@ $meta->addInitialCreator( "Testo Tester" ); $meta->addCreationDate(); - /* Initialize Font Face Declarations: */ + /* Initialize Font Face Declarations: */ + $fontfacedecl = $ODT->getFontFaceDeclaration(); + $styleAttr = array(); - $styleAttr[ "font-family" ] ="Tahoma"; - - $fontfacedelc = $ODT->getFontFaceDeclaration(); - $fontfacedelc->addFontFace( "Test", $styleAttr ); + $svgAttr = array(); + + $styleAttr[ "font-pitch" ] = "variable"; + $svgAttr [ "font-family" ] = "'Arial Unicode MS'"; + $fontfacedecl->addFontFace( "Arial Unicode MS", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "Tahoma"; + $fontfacedecl->addFontFace( "Tahoma", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "'MS Mincho'"; + $fontfacedecl->addFontFace( "MS Mincho", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "'Times New Roman'"; + $styleAttr[ "font-family-generic" ] = "roman"; + $fontfacedecl->addFontFace( "Times New Roman", $styleAttr, $svgAttr ); + + $svgAttr [ "font-family" ] = "Arial"; + $styleAttr[ "font-family-generic" ] = "swiss"; + $fontfacedecl->addFontFace( "Arial", $styleAttr, $svgAttr ); + unset( $styleAttr ); /* Add text to Body: */ Modified: poc/src/content/Body.php =================================================================== --- poc/src/content/Body.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/content/Body.php 2006-03-30 08:24:22 UTC (rev 42) @@ -15,6 +15,7 @@ require_once( "OpenDocumentObjectAbstract.php" ); require_once( "content/BodyText.php" ); require_once( "content/BodyTable.php" ); +require_once( "util/NameSpaces.php" ); class Body extends OpenDocumentObjectAbstract { @@ -51,7 +52,7 @@ $this->dom = $dom; $this->BodyFragment = $this->dom->createDocumentFragment(); - $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); + $this->body = $this->dom->createElementNS( NS::OFFICE, "office:body" ); $this->Fragments = array(); } @@ -94,7 +95,7 @@ */ public function getText() { $this->logger->debug( "content/Body->getText()" ); - return $this->getByNamespace( self::NS_TEXT, "BodyText" ); + return $this->getByNamespace( NS::TEXT, "BodyText" ); } /** @@ -104,7 +105,7 @@ */ public function getTable() { $this->logger->debug( "content/Body->getTable()" ); - return $this->getByNamespace( self::NS_TABLE, "BodyTable" ); + return $this->getByNamespace( NS::TABLE, "BodyTable" ); } /** Modified: poc/src/content/BodyTable.php =================================================================== --- poc/src/content/BodyTable.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/content/BodyTable.php 2006-03-30 08:24:22 UTC (rev 42) @@ -14,6 +14,7 @@ */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class BodyTable extends OpenDocumentObjectAbstract { /** @@ -27,7 +28,7 @@ $this->dom = $dom; $this->DomFragment = $dom->createDocumentFragment(); - $this->body = $this->DomFragment->createElementNS( self::NS_OFFICE, "office:table" ); + $this->body = $this->DomFragment->createElementNS( NS::OFFICE, "office:table" ); } /** Modified: poc/src/content/BodyText.php =================================================================== --- poc/src/content/BodyText.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/content/BodyText.php 2006-03-30 08:24:22 UTC (rev 42) @@ -13,6 +13,7 @@ */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class BodyText extends OpenDocumentObjectAbstract { /** @@ -27,7 +28,7 @@ $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); $this->dom = $dom; - $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); + $this->text = $this->dom->createElementNS( NS::OFFICE, "office:text" ); } /** @@ -50,11 +51,11 @@ public function getTextParagraph( $styleName, $parText=0 ) { $this->logger->debug( "OpenDocumentContentBodyText->getTextParagraph(\"".$styleName."\",\"".$parText."\")" ); if (empty($parText)) { - $par = $this->dom->createElementNS( self::NS_TEXT, "text:p" ); + $par = $this->dom->createElementNS( NS::TEXT, "text:p" ); } else { - $par = $this->dom->createElementNS( self::NS_TEXT, "text:p", $parText ); + $par = $this->dom->createElementNS( NS::TEXT, "text:p", $parText ); } - $par->setAttributeNS( self::NS_TEXT, "text:style-name", $styleName ); + $par->setAttributeNS( NS::TEXT, "text:style-name", $styleName ); return $par; } @@ -78,12 +79,12 @@ public function getTextHeading( $styleName, $outlineLevel=1, $headText=0 ) { $this->logger->debug( "OpenDocumentContentBodyText->getTextHeading()" ); if (empty($headText)) { - $head = $this->dom->createElementNS( self::NS_TEXT, "text:h" ); + $head = $this->dom->createElementNS( NS::TEXT, "text:h" ); } else { - $head = $this->dom->createElementNS( self::NS_TEXT, "text:h", $headText ); + $head = $this->dom->createElementNS( NS::TEXT, "text:h", $headText ); } - $head->setAttributeNS( self::NS_TEXT, "text:style-name", $styleName ); - $head->setAttributeNS( self::NS_TEXT, "text:outline-level", $outlineLevel ); + $head->setAttributeNS( NS::TEXT, "text:style-name", $styleName ); + $head->setAttributeNS( NS::TEXT, "text:outline-level", $outlineLevel ); return $head; } @@ -95,10 +96,10 @@ */ public function addNoForms() { $this->logger->debug( "OpenDocumentContentBodyText->addNoForms()" ); - $forms = $this->dom->createElementNS( self::NS_OFFICE, "office:forms" ); + $forms = $this->dom->createElementNS( NS::OFFICE, "office:forms" ); - $forms->setAttributeNS( self::NS_FORM, "form:automatic-focus", "false" ); - $forms->setAttributeNS( self::NS_FORM, "form:apply-design-mode", "false" ); + $forms->setAttributeNS( NS::FORM, "form:automatic-focus", "false" ); + $forms->setAttributeNS( NS::FORM, "form:apply-design-mode", "false" ); $this->text->appendChild( $forms ); unset( $forms ); Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/content/Content.php 2006-03-30 08:24:22 UTC (rev 42) @@ -18,6 +18,7 @@ require_once( "styles/AutomaticStyles.php" ); require_once( "content/Body.php" ); require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class Content extends OpenDocumentObjectAbstract { @@ -42,8 +43,8 @@ $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->dom->formatOutput = true; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-content" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:document-content" ); + $this->root->setAttributeNS( NS::OFFICE, "office:version", "1.0" ); $this->content = $this->dom; $this->Scripts = new Scripts( $this->dom, $this->root ); Modified: poc/src/content/Scripts.php =================================================================== --- poc/src/content/Scripts.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/content/Scripts.php 2006-03-30 08:24:22 UTC (rev 42) @@ -16,6 +16,7 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class Scripts extends OpenDocumentObjectAbstract { /** @@ -45,7 +46,7 @@ $this->logger->debug( "Constructing content/Scripts." ); $this->dom = $dom; - $this->scripts = $this->dom->createElementNS( self::NS_OFFICE, "office:scripts" ); + $this->scripts = $this->dom->createElementNS( NS::OFFICE, "office:scripts" ); $this->root = 0; } Modified: poc/src/manifest/Manifest.php =================================================================== --- poc/src/manifest/Manifest.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/manifest/Manifest.php 2006-03-30 08:24:22 UTC (rev 42) @@ -13,7 +13,8 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); - +require_once( "util/NameSpaces.php" ); + class Manifest extends OpenDocumentObjectAbstract { const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; const odmSYSTEM = "Manifest.dtd"; @@ -61,11 +62,11 @@ $this->dom->encoding = "UTF-8"; $this->dom->formatOutput = true; - $this->root = $this->dom->createElementNS( self::NS_MANIFEST, self::odmROOT ); + $this->root = $this->dom->createElementNS( NS::MANIFEST, self::odmROOT ); - $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:media-type", $this->mimetype ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", "/" ); + $node = $this->dom->createElementNS( NS::MANIFEST, "manifest:file-entry" ); + $node->setAttributeNS( NS::MANIFEST, "manifest:media-type", $this->mimetype ); + $node->setAttributeNS( NS::MANIFEST, "manifest:full-path", "/" ); $this->root->appendChild( $node ); @@ -82,11 +83,11 @@ * @since 0.4.0 */ final public function addEntryToManifest( $fullpath, $mimetype, $size=-1, $encrypt=0 ) { - $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:media-type", $mimetype ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", $fullpath ); + $node = $this->dom->createElementNS( NS::MANIFEST, "manifest:file-entry" ); + $node->setAttributeNS( NS::MANIFEST, "manifest:media-type", $mimetype ); + $node->setAttributeNS( NS::MANIFEST, "manifest:full-path", $fullpath ); if ( $size >= 0 ) { - $node->setAttributeNS( self::NS_MANIFEST, "manifest:size", $size ); + $node->setAttributeNS( NS::MANIFEST, "manifest:size", $size ); } if (!empty($encrypt)) { $node->appendChild( $encrypt ); @@ -103,7 +104,7 @@ * @since 0.4.0 */ final public function createEncryptionData( ) { - return $this->dom->createElmentNS( self::NS_MANIFEST, "manifest:encryption-data" ); + return $this->dom->createElmentNS( NS::MANIFEST, "manifest:encryption-data" ); } /** Modified: poc/src/meta/Meta.php =================================================================== --- poc/src/meta/Meta.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/meta/Meta.php 2006-03-30 08:24:22 UTC (rev 42) @@ -16,6 +16,10 @@ * @since 0.4.4 */ +require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); + + class Meta extends OpenDocumentObjectAbstract { /** @@ -50,8 +54,8 @@ $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->dom->formatOutput = true; - $node = $this->dom->createElementNS( self::NS_OFFICE, "office:document-meta" ); - $node->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + $node = $this->dom->createElementNS( NS::OFFICE, "office:document-meta" ); + $node->setAttributeNS( NS::OFFICE, "office:version", "1.0" ); $this->dom->appendChild( $node ); $this->meta = $node; @@ -60,7 +64,7 @@ $this->dom = $dom; $this->meta = $root; } - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:meta" ); } /** @@ -95,19 +99,19 @@ return false; } - $OFFICE_PREFIX = $tmpDom->getElementsByTagNameNS( self::NS_OFFICE, "*").item( 0 )->prefix; + $OFFICE_PREFIX = $tmpDom->getElementsByTagNameNS( NS::OFFICE, "*").item( 0 )->prefix; // Figgure out if file is part of a package or a single document; - $isSingleDoc = (count($tmpDom->getElementsByTagNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta" ))==0); + $isSingleDoc = (count($tmpDom->getElementsByTagNameNS( NS::OFFICE, $OFFICE_PREFIX.":document-meta" ))==0); if ($isSingleDoc) { $this->dom = $tmpDoc; $this->meta = $tmpDoc; } else { $this->dom = $tmpDoc; - $this->meta = $tmtDoc->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta").item( 0 ); + $this->meta = $tmtDoc->getElementsByTageNameNS( NS::OFFICE, $OFFICE_PREFIX.":document-meta").item( 0 ); } - $this->root = $this->dom->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":meta").item( 0 ); + $this->root = $this->dom->getElementsByTageNameNS( NS::OFFICE, $OFFICE_PREFIX.":meta").item( 0 ); return true; } @@ -123,7 +127,7 @@ */ public function addDublinCore( $dc, $value) { $this->logger->debug( "meta/Meta->addDublinCore: ". $value ."." ); - $node = $this->dom->createElementNS( self::NS_DC, "dc:".$dc, $value ); + $node = $this->dom->createElementNS( NS::DC, "dc:".$dc, $value ); $this->root->appendChild( $node ); unset( $node ); } @@ -140,7 +144,7 @@ */ public function getDublicCore( $dc ) { $retValue = ""; - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_DC, $dc ); + $nodelist = $this->dom->getElementsByTagNameNS( NS::DC, $dc ); if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; } @@ -176,7 +180,7 @@ } $this->logger->debug( "meta/Meta->addCreationTime: ". $creation_time ."." ); - $node = $this->dom->createElementNS( self::NS_META, "meta:creation-date", $creation_time ); + $node = $this->dom->createElementNS( NS::META, "meta:creation-date", $creation_time ); $this->root->appendChild( $node ); @@ -214,7 +218,7 @@ $this->logger->debug( "meta/Meta->addGenerator: ". $lgenerator ."." ); - $node = $this->dom->createElementNS( self::NS_META, "meta:generator", $lgenerator ); + $node = $this->dom->createElementNS( NS::META, "meta:generator", $lgenerator ); $this->root->appendChild( $node ); @@ -245,7 +249,7 @@ public function getGenerator() { $retValue = ""; - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "generator" ); + $nodelist = $this->dom->getElementsByTagNameNS( NS::META, "generator" ); if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; @@ -263,7 +267,7 @@ */ public function addInitialCreator( $initialCreator ) { $this->logger->debug( "meta/Meta->addInitialCreator: ". $initialCreator ."." ); - $node = $this->dom->createElementNS( self::NS_META, "meta:initial-creator", $initialCreator ); + $node = $this->dom->createElementNS( NS::META, "meta:initial-creator", $initialCreator ); $this->root->appendChild( $node ); } @@ -275,7 +279,7 @@ */ public function getInitialCreator() { $retValue = ""; - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "initial-creator" ); + $nodelist = $this->dom->getElementsByTagNameNS( NS::META, "initial-creator" ); if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; } @@ -291,13 +295,13 @@ * @since 0.4.0 */ public function addUserDefinedMetadata( $name, $type, $value ) { - $node = $this->dom->createElementNS( self::NS_META, "meta:user-defined" ); - $node->setAttributeNS( self::NS_META, "meta:name", $name ); + $node = $this->dom->createElementNS( NS::META, "meta:user-defined" ); + $node->setAttributeNS( NS::META, "meta:name", $name ); if ( !empty( $type ) ) { - $node->setAttributeNS( self::NS_META, "meta:type", $type ); + $node->setAttributeNS( NS::META, "meta:type", $type ); } if ( !empty( $value ) ) { - $node->setAttributeNS( self::NS_META, "meta:value", $value ); + $node->setAttributeNS( NS::META, "meta:value", $value ); } $this->root->appendChild( $node ); unset( $node ); Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/samples/TestOutput.php 2006-03-30 08:24:22 UTC (rev 42) @@ -68,16 +68,16 @@ $svgAttr = array(); $styleAttr[ "font-pitch" ] = "variable"; - $svgAttr [ "font-family" ] = "'Arial Unicode MS'"; + $svgAttr [ "font-family" ] = "'Arial Unicode MS'"; $fontFaceDecl->addFontFace( "Arial Unicode MS", $styleAttr, $svgAttr ); $svgAttr [ "font-family" ] = "Tahoma"; $fontFaceDecl->addFontFace( "Tahoma", $styleAttr, $svgAttr ); - $svgAttr [ "font-family" ] = "'MS Mincho'"; + $svgAttr [ "font-family" ] = "'MS Mincho'"; $fontFaceDecl->addFontFace( "MS Mincho", $styleAttr, $svgAttr ); - $svgAttr [ "font-family" ] = "'Times New Roman'"; + $svgAttr [ "font-family" ] = "'Times New Roman'"; $styleAttr[ "font-family-generic" ] = "roman"; $fontFaceDecl->addFontFace( "Times New Roman", $styleAttr, $svgAttr ); Modified: poc/src/settings/Settings.php =================================================================== --- poc/src/settings/Settings.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/settings/Settings.php 2006-03-30 08:24:22 UTC (rev 42) @@ -16,6 +16,7 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class Settings extends OpenDocumentObjectAbstract { /** @@ -55,15 +56,15 @@ $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->dom->formatOutput = true; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-settings" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:document-settings" ); + $this->root->setAttributeNS( NS::OFFICE, "office:version", "1.0" ); $this->settings = $this->dom; } else { // this is part of a single document $this->dom = $dom; $this->settings = $root; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:settings" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:settings" ); } } Modified: poc/src/styles/AutomaticStyles.php =================================================================== --- poc/src/styles/AutomaticStyles.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/styles/AutomaticStyles.php 2006-03-30 08:24:22 UTC (rev 42) @@ -15,6 +15,7 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class AutomaticStyles extends OpenDocumentObjectAbstract { @@ -44,7 +45,7 @@ $this->logger->debug( "Constructing styles/AutomaticStyles." ); $this->dom = $dom; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:automatic-styles" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:automatic-styles" ); } /** Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-30 08:24:22 UTC (rev 42) @@ -13,6 +13,7 @@ * @since 0.4.2 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class FontFaceDeclaration extends OpenDocumentObjectAbstract { @@ -35,7 +36,7 @@ $this->dom = $dom; $this->useDom2 = false; - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decls" ); + $this->FontFaceDecl = $this->dom->createElementNS( NS::OFFICE, "office:font-face-decls" ); } /** @@ -114,13 +115,13 @@ * @since 0.4.2 */ public function addFontFace( $name, $styleAttr=0, $SVGAttr=0 ) { - $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); - $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); + $font = $this->dom->createElementNS( NS::STYLE, "style:font-face" ); + $font->setAttributeNS( NS::STYLE, "style:name", $name ); if (!empty($styleAttr)) { foreach( $styleAttr as $key => $value ) { // ***FIX ME*** Here we should check if the keys are possible if ($this->checkStyle($key, $value)) { - $font->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + $font->setAttributeNS( NS::STYLE, "style:".$key, $value ); } } } @@ -128,7 +129,7 @@ foreach( $SVGAttr as $key => $value ) { // ***FIX ME*** Here we should check if the keys are possible if ($this->checkSVG( $key, $value )) { - $font->setAttributeNS( self::NS_SVG, "svg:".$key, $value ); + $font->setAttributeNS( NS::SVG, "svg:".$key, $value ); } } } Modified: poc/src/styles/MasterStyles.php =================================================================== --- poc/src/styles/MasterStyles.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/styles/MasterStyles.php 2006-03-30 08:24:22 UTC (rev 42) @@ -15,6 +15,7 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class MasterStyles extends OpenDocumentObjectAbstract { @@ -43,7 +44,7 @@ $this->dom = $dom; $this->style = $root; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:master-styles" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:master-styles" ); } /** Modified: poc/src/styles/Style.php =================================================================== --- poc/src/styles/Style.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/styles/Style.php 2006-03-30 08:24:22 UTC (rev 42) @@ -13,6 +13,7 @@ * @since 0.4.4 */ require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "util/NameSpaces.php" ); class Style extends OpenDocumentObjectAbstract { @@ -54,7 +55,7 @@ $this->logger->debug( "Constructing style/Style." ); $this->dom = $dom; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:styles" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:styles" ); $this->Styles = array(); $this->DefaultStyles = array(); @@ -69,9 +70,9 @@ * @since 0.4.2 */ public function addDefaultStyle( $family = 0 ) { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:default-style" ); + $node = $this->dom->createElementNS( NS::STYLE, "style:default-style" ); if (!empty($family)) { - $node->setAttributeNS( self::NS_STYLE, "style:family", $family ); + $node->setAttributeNS( NS::STYLE, "style:family", $family ); } $this->DefaultStyles[ $family ] = $node; } @@ -84,15 +85,15 @@ * @since 0.4.2 */ private function addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ) { - $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:paragraph-properties" ); + $ParProp = $this->dom->createElementNS( NS::STYLE, "style:paragraph-properties" ); if (!empty($styleAttr)) { foreach( $styleAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + $ParProp->setAttributeNS( NS::STYLE, "style:".$key, $value ); } } if (!empty($foAttr)) { foreach( $foAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); + $ParProp->setAttributeNS( NS::FO, "fo:".$key, $value ); } } $node->appendChild( $ParProp ); @@ -106,15 +107,15 @@ * @since 0.4.2 */ private function addTextPropertiesToNode( $node, $styleAttr, $foAttr ) { - $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:text-properties" ); + $ParProp = $this->dom->createElementNS( NS::STYLE, "style:text-properties" ); if (!empty($styleAttr)) { foreach( $styleAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + $ParProp->setAttributeNS( NS::STYLE, "style:".$key, $value ); } } if (!empty($foAttr)) { foreach( $foAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); + $ParProp->setAttributeNS( NS::FO, "fo:".$key, $value ); } } $node->appendChild( $ParProp ); @@ -190,11 +191,11 @@ * @since 0.4.2 */ public function addStyle( $name, $styleAttr=0 ) { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:style" ); - $node->setAttributeNS( self::NS_STYLE, "style:name", $name ); + $node = $this->dom->createElementNS( NS::STYLE, "style:style" ); + $node->setAttributeNS( NS::STYLE, "style:name", $name ); if (!empty($styleAttr)) { foreach( $styleAttr as $key=>$value ) { - $node->setAttributeNS ( self::NS_STYLE, "style:".$key, $value ); + $node->setAttributeNS ( NS::STYLE, "style:".$key, $value ); } } $this->Styles[ $name ] = $node; Modified: poc/src/styles/Styles.php =================================================================== --- poc/src/styles/Styles.php 2006-03-29 13:59:14 UTC (rev 41) +++ poc/src/styles/Styles.php 2006-03-30 08:24:22 UTC (rev 42) @@ -16,6 +16,7 @@ require_once( "styles/Style.php" ); require_once( "styles/AutomaticStyles.php" ); require_once( "styles/MasterStyles.php" ); +require_once( "util/NameSpaces.php" ); class Styles extends OpenDocumentObjectAbstract { @@ -43,8 +44,8 @@ $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->dom->formatOutput = true; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-styles" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); + $this->root = $this->dom->createElementNS( NS::OFFICE, "office:document-styles" ); + $this->root->setAttributeNS( NS::OFFICE, "office:version", "1.0" ); $this->styles = $this->dom; $this->FontFaceDecl = new FontFaceDeclaration( $this->dom, $this->root ); Added: poc/src/util/NameSpaces.php =================================================================== --- poc/src/util/NameSpaces.php (rev 0) +++ poc/src/util/NameSpaces.php 2006-03-30 08:24:22 UTC (rev 42) @@ -0,0 +1,144 @@ +<?php +/** + * NameSpaces Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage util + * @since 0.5.0 + */ + +class NameSpaces { + + /** + * namespace OpenDocument meta + */ + const META = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; + + /** + * namespace OpenDocument office + */ + const OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + + /** + * namespace OpenDocument manifest + */ + const MANIFEST = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; + + /** + * namespace OpenDocument style + */ + const STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; + + /** + * namespace OpenDocument text + */ + const TEXT = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"; + + /** + * namespace OpenDocument draw + */ + const DRAW = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; + + /** + * namespace OpenDocument table + */ + const TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"; + + /** + * namespace OpenDocument number + */ + const NUMBER = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; + + /** + * namespace OpenDocument chart + */ + const CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; + + /** + * namespace OpenDocument form + */ + const FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; + + /** + * namespace OpenDocument config + */ + const CONFIG = "urn:oasis:names:tc:opendocument:xmlns:config:1.0"; + + /** + * namespace OpenDocument presentation + */ + const PRESENTATION = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"; + + /** + * namespace OpenDocument dr3d + */ + const DR3D = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; + + /** + * namespace OpenDocument animation + */ + const ANIM = "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"; + + /** + * namespace OpenDocument script + */ + const SCRIPT = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"; + + /** + * namespace OpenDocument svg + */ + const SVG = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; + + /** + * namespace OpenDocument fo (formation objects) + */ + const FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; + + /** + * namespace OpenDocument smil + */ + const SMIL = "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"; + + /** + * namespace Dublin Core + */ + const DC = "http://purl.org/dc/elements/1.1/"; + + /** + * namespace XLink + */ + const XLINK = "http://www.w3.org/1999/xlink"; + + /** + * namespace XForms + */ + const XFORMS = "http://www.w3.org/2002/xforms"; + + /** + * namespace MathML + */ + const MATHML = "http://www.w3.org/1998/Math/MathML"; + +} + +/** + * This is just a shortcast to the NameSpaces Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @since 0.5.0 + */ +class NS extends NameSpaces { + +}; Property changes on: poc/src/util/NameSpaces.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/util/NameSpacesTest.php =================================================================== --- poc/src/util/NameSpacesTest.php (rev 0) +++ poc/src/util/NameSpacesTest.php 2006-03-30 08:24:22 UTC (rev 42) @@ -0,0 +1,101 @@ +<?php +/** + * TestCase for OpenDocumentObjectAbstract class + * + * $Id$ + * + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @license GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage UnitTest + * @since 0.5.0 + */ + +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "util/NameSpaces.php"; + +class NameSpaceTest extends PHPUnit2_Framework_TestCase { + +const office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"; +const style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"; +const text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"; +const table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"; +const draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; +const fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; +const xlink="http://www.w3.org/1999/xlink"; +const dc="http://purl.org/dc/elements/1.1/"; +const meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; +const number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; +const svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; +const chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; +const dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; +const math="http://www.w3.org/1998/Math/MathML"; +const form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"; +const script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"; +const ooo="http://openoffice.org/2004/office"; +const ooow="http://openoffice.org/2004/writer"; +const oooc="http://openoffice.org/2004/calc"; +const dom="http://www.w3.org/2001/xml-events"; + + /** + * This test will check all name spaces. The namespaces in this file are extracted from + * an OpenOffice document, so they are not written by hand out of the OpenDocument documentation. + * This should help to fix typos. (And it did!!!) + * + * @since 0.5.0 + */ + function testNamespaces() { + $this->assertEquals( NameSpaces::OFFICE, self::office ); + $this->assertEquals( NameSpaces::STYLE, self::style ); + $this->assertEquals( NameSpaces::TEXT, self::text ); + $this->assertEquals( NameSpaces::TABLE, self::table ); + $this->assertEquals( NameSpaces::DRAW, self::draw ); + $this->assertEquals( NameSpaces::FO, self::fo ); + $this->assertEquals( NameSpaces::XLINK, self::xlink ); + $this->assertEquals( NameSpaces::DC, self::dc ); + $this->assertEquals( NameSpaces::META, self::meta ); + $this->assertEquals( NameSpaces::NUMBER, self::number ); + $this->assertEquals( NameSpaces::SVG, self::svg ); + $this->assertEquals( NameSpaces::CHART, self::chart ); + $this->assertEquals( NameSpaces::DR3D, self::dr3d ); + $this->assertEquals( NameSpaces::MATHML, self::math ); + $this->assertEquals( NameSpaces::FORM, self::form ); + $this->assertEquals( NameSpaces::SCRIPT, self::script ); +/* + $this->assertEquals( NameSpace::OOO, self::ooo ); + $this->assertEquals( NameSpace::OOOW, self::ooow ); + $this->assertEquals( NameSpace::OOOC, self::oooc ); + $this->assertEquals( NameSpace::DOM, self::dom ); +*/ + } + + /** + * This test will check all name spaces. The namespaces in this file are extracted from + * an OpenOffice document, so they are not written by hand out of the OpenDocument documentation. + * This should help to fix typos. (And it did!!!) + * + * @since 0.5.0 + */ + function testNS() { + $this->assertEquals( NS::OFFICE, self::office ); + $this->assertEquals( NS::STYLE, self::style ); + $this->assertEquals( NS::TEXT, self::text ); + $this->assertEquals( NS::TABLE, self::table ); + $this->assertEquals( NS::DRAW, self::draw ); + $this->assertEquals( NS::FO, self::fo ); + $this->assertEquals( NS::XLINK, self::xlink ); + $this->assertEquals( NS::DC, self::dc ); + $this->assertEquals( NS::META, self::meta ); + $this->assertEquals( NS::NUMBER, self::number ); + $this->assertEquals( NS::SVG, self::svg ); + $this->assertEquals( NS::CHART, self::chart ); + $this->assertEquals( NS::DR3D, self::dr3d ); + $this->assertEquals( NS::MATHML, self::math ); + $this->assertEquals( NS::FORM, self::form ); + $this->assertEquals( NS::SCRIPT, self::script ); + } + +} +?> \ No newline at end of file Property changes on: poc/src/util/NameSpacesTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-30 10:47:14
|
Revision: 43 Author: nmarkgraf Date: 2006-03-30 02:47:03 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=43&view=rev Log Message: ----------- We are now heading to POC 0.4.6... ;) Modified Paths: -------------- poc/build.properties poc/src/OpenDocumentAbstract.php Modified: poc/build.properties =================================================================== --- poc/build.properties 2006-03-30 08:24:22 UTC (rev 42) +++ poc/build.properties 2006-03-30 10:47:03 UTC (rev 43) @@ -5,6 +5,5 @@ # Last edited by $Author$ # # $Id$ -release=0.5.0 -releaseDos=0_5_0 -revision=$revision$ \ No newline at end of file +release=0.4.6 +releaseDos=0_4_6 Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-30 08:24:22 UTC (rev 42) +++ poc/src/OpenDocumentAbstract.php 2006-03-30 10:47:03 UTC (rev 43) @@ -28,7 +28,7 @@ * X = 0 : "proof of concept" (a.k.a POC) code * X = 1 : "stage 1" code */ - const Release = "0.4.3"; + const Release = "0.4.6"; /** * Copyright notice for this package. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-30 13:20:53
|
Revision: 44 Author: nmarkgraf Date: 2006-03-30 05:20:40 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=44&view=rev Log Message: ----------- New feature: - The release property in build.properties will be used to update OpenDocumentAbstract::Release. We need an build.xml refactoring as soon as we heading to 0.6.0 ...;) Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentAbstract.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-30 10:47:03 UTC (rev 43) +++ poc/build.xml 2006-03-30 13:20:40 UTC (rev 44) @@ -5,7 +5,7 @@ <property file="build.properties" /> <property name="OpenDocumentPHPSolid" value="OpenDocumentPHP-${release}-solid.php" /> - <target name="prepare"> + <target name="prepare" depends="updateReleaseInfo"> <mkdir dir="reports"/> <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> @@ -34,6 +34,21 @@ <mkdir dir="reports/tests"/> </target> + <target name="updateReleaseInfo"> + <copy file="src/OpenDocumentAbstract.php" tofile="tmp.tmp" overwrite="true"> + <filterchain> + <replaceregexp> + <regexp pattern=".*const.*Release.*=.*" replace="##release##"/> + </replaceregexp> + <replacetokens begintoken="##" endtoken="##"> + <token key="release" value=" const Release = '${release}';" /> + </replacetokens> + </filterchain> + </copy> + <copy file="tmp.tmp" tofile="src/OpenDocumentAbstract.php" overwrite="true" /> + <delete file="tmp.tmp" /> + </target> + <target name="reports" depends="preparereport"> <coverage-setup database="reports/data/${release}/coverage.db"> <fileset dir="src"> @@ -125,36 +140,36 @@ </copy> </target> - <target name="solid-production" depends="production" description="Creates a single file production release without unit tests in the dist directory."> - <mkdir dir="solid-production"/> - <copy todir="solid-production"> <!--"/OpenDocumentPHP-solid.php" overwrite="true" --> - <fileset dir="production"> - <include name="**/*.php" /> - </fileset> + <target name="solid-file" depends="production"> + <delete file="dist/tmp.tmp"/> + <append destFile="dist/tmp.tmp"> + <fileset dir="."> + <include name="**/etc/solid.txt" /> + <include name="**/production/**/*.php" /> + </fileset> <filterchain> <replaceregexp> <regexp pattern=".*require_once" replace="//require_once" ignoreCase="true" /> <regexp pattern=".*include_once" replace="//include_once" ignoreCase="true" /> - <regexp pattern=".+this-.logger.+" replace="//this-logger-" /> - </replaceregexp> - <!-- stripphpcomments /--> + <regexp pattern=".+this-.logger.+" replace="//this-logger-" /> + </replaceregexp> + </filterchain> + </append> + </target> + + <target name="solid-production" depends="solid-file" description="Creates a single file production release without unit tests in the dist directory."> + <copy file="dist/tmp.tmp" tofile="dist/${OpenDocumentPHPSolid}" overwrite="true"> + <filterchain> + <replaceregexp> + <regexp pattern="\?>.\?php" replace="//" /> + </replaceregexp> <striplinecomments> <comment value="//" /> </striplinecomments> - </filterchain> - </copy> - <!-- echo msg="${OpenDocumentPHPSolid}"/--> - <!-- echo msg="${os.name}"/--> - <exec command="copy ..\etc\solid.txt + *.php + manifest\*.php + content\*.php + settings\*.php + styles\*.php + meta\*.php tmp.tmp" dir="solid-production"/> - <exec command="cat ../etc/solid.txt > ../tmp.tmp && cat *.php >> ../tmp.tmp && cat */*.php >> ../tmp.tmp" dir="solid-production" os="linux"/> - <copy file="solid-production/tmp.tmp" tofile="dist/${OpenDocumentPHPSolid}" overwrite="true"> - <filterchain> - <replaceregexp> - <regexp pattern="\?>.\?php" replace=" " /> - </replaceregexp> + <!--stripphpcomments /--> </filterchain> - </copy> - <delete dir="solid-production"/> + </copy> + <delete file="dist/tmp.tmp"/> </target> <target name="build" depends="prepare,test,reports,docs,dist"> @@ -174,6 +189,7 @@ <delete file="OpenDocumentPHP.tar"/> <delete dir="production"/> <delete dir="solid-production"/> + <delete file="dist/tmp.tmp"/> </target> <target name="proper" depends="clean"> Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-30 10:47:03 UTC (rev 43) +++ poc/src/OpenDocumentAbstract.php 2006-03-30 13:20:40 UTC (rev 44) @@ -28,7 +28,7 @@ * X = 0 : "proof of concept" (a.k.a POC) code * X = 1 : "stage 1" code */ - const Release = "0.4.6"; + const Release = '0.4.6'; /** * Copyright notice for this package. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-30 13:37:34
|
Revision: 45 Author: nmarkgraf Date: 2006-03-30 05:37:20 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=45&view=rev Log Message: ----------- Tiny bug fixes. Modified Paths: -------------- poc/build.xml poc/src/util/NameSpaces.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-30 13:20:40 UTC (rev 44) +++ poc/build.xml 2006-03-30 13:37:20 UTC (rev 45) @@ -146,6 +146,7 @@ <fileset dir="."> <include name="**/etc/solid.txt" /> <include name="**/production/**/*.php" /> + <exclude name="**/samples/**/*.php" /> </fileset> <filterchain> <replaceregexp> Modified: poc/src/util/NameSpaces.php =================================================================== --- poc/src/util/NameSpaces.php 2006-03-30 13:20:40 UTC (rev 44) +++ poc/src/util/NameSpaces.php 2006-03-30 13:37:20 UTC (rev 45) @@ -142,3 +142,5 @@ class NS extends NameSpaces { }; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-30 14:12:29
|
Revision: 46 Author: nmarkgraf Date: 2006-03-30 06:12:08 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=46&view=rev Log Message: ----------- Moved release information in a new, generated class util/ReleaseInformation.php. This file will be created by PHing. Because of that, some changes in OpenDocumentAbstract and a new template file (etc/ReleaseInformation.tpl). Modified Paths: -------------- poc/build.properties poc/build.xml poc/src/OpenDocumentAbstract.php Added Paths: ----------- poc/etc/ReleaseInformation.tpl Modified: poc/build.properties =================================================================== --- poc/build.properties 2006-03-30 13:37:20 UTC (rev 45) +++ poc/build.properties 2006-03-30 14:12:08 UTC (rev 46) @@ -7,3 +7,5 @@ # $Id$ release=0.4.6 releaseDos=0_4_6 +# This could be ALPHA, BETA or STABLE +revision=ALPHA \ No newline at end of file Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-30 13:37:20 UTC (rev 45) +++ poc/build.xml 2006-03-30 14:12:08 UTC (rev 46) @@ -35,18 +35,14 @@ </target> <target name="updateReleaseInfo"> - <copy file="src/OpenDocumentAbstract.php" tofile="tmp.tmp" overwrite="true"> + <copy file="etc/ReleaseInformation.tpl" tofile="src/util/ReleaseInformation.php" overwrite="true"> <filterchain> - <replaceregexp> - <regexp pattern=".*const.*Release.*=.*" replace="##release##"/> - </replaceregexp> <replacetokens begintoken="##" endtoken="##"> - <token key="release" value=" const Release = '${release}';" /> + <token key="release" value="${release}" /> + <token key="revision" value="${revision}" /> </replacetokens> </filterchain> </copy> - <copy file="tmp.tmp" tofile="src/OpenDocumentAbstract.php" overwrite="true" /> - <delete file="tmp.tmp" /> </target> <target name="reports" depends="preparereport"> Added: poc/etc/ReleaseInformation.tpl =================================================================== --- poc/etc/ReleaseInformation.tpl (rev 0) +++ poc/etc/ReleaseInformation.tpl 2006-03-30 14:12:08 UTC (rev 46) @@ -0,0 +1,30 @@ +<?php +/** + * DO NOT EDIT THIS FILE! It is automaticaly generated by PHing build script! + * + * $Id $ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 39 $ + * @package OpenDocument + * @subpackage util + * + * @since 0.4.6 + */ +class ReleaseInformation { + /** + * Is this ALPHA, BETA or STABLE code? + */ + const Revision = "##revision##"; + + /** + * Release number: X.Y.Z + * + * X = 0 : "proof of concept" (a.k.a POC) code + * X = 1 : "stage 1" code + */ + const Release = "##release##"; +} +?> \ No newline at end of file Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-30 13:37:20 UTC (rev 45) +++ poc/src/OpenDocumentAbstract.php 2006-03-30 14:12:08 UTC (rev 46) @@ -16,21 +16,11 @@ * @since 0.3.0 */ +require_once( "util/ReleaseInformation.php" ); + class OpenDocumentAbstract { - /** - * Is this ALPHA, BETA or STABLE code? - */ - const Revision = "ALPHA"; /** - * Release number: X.Y.Z - * - * X = 0 : "proof of concept" (a.k.a POC) code - * X = 1 : "stage 1" code - */ - const Release = '0.4.6'; - - /** * Copyright notice for this package. */ const Copyright = "(C) in 2006 by Norman Markgraf, Alex Latchford, et al."; @@ -113,7 +103,7 @@ */ final public function getRevision() { $Revision = ""; - return "(".substr("$Revision$",-2).")".self::Revision; + return "(".substr("$Revision$",-2).")".ReleaseInformation::Revision; } /** @@ -125,7 +115,7 @@ * @since 0.4.0 */ final public function getRelease() { - return self::Release.".".self::Revision; + return ReleaseInformation::Release.".".ReleaseInformation::Revision; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-05 15:52:56
|
Revision: 47 Author: nmarkgraf Date: 2006-04-05 08:52:08 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=47&view=rev Log Message: ----------- A lot of refactoring work: - Added some new classes: AbstractDocument (which will replace OpenDocumentAbstract), MimeTypes, AutomaticStylesSplitter (this is a kind of FontFaceDeclSplitter for AutomaticStyles). - Added some interfaces (FontFaceDeclInterface and AutomaticStylesInterface) to keep track of changes in *Splitter and the unsplited classes. - Moved some Stuff from OpenDocumentAbstract to ReleaseInformation(.tpl). Modified Paths: -------------- poc/build.properties poc/build.xml poc/etc/ReleaseInformation.tpl poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php poc/src/content/Content.php poc/src/content/Scripts.php poc/src/manifest/Manifest.php poc/src/meta/Meta.php poc/src/settings/Settings.php poc/src/styles/AutomaticStyles.php poc/src/styles/FontFaceDeclSplitter.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/MasterStyles.php poc/src/styles/Style.php poc/src/styles/Styles.php poc/src/util/NameSpaces.php Added Paths: ----------- poc/src/styles/AutomaticStylesInterface.php poc/src/styles/AutomaticStylesSplitter.php poc/src/styles/FontFaceDeclInterface.php poc/src/util/AbstractDocument.php poc/src/util/MimeTypes.php Property Changed: ---------------- poc/etc/ReleaseInformation.tpl Modified: poc/build.properties =================================================================== --- poc/build.properties 2006-03-30 14:12:08 UTC (rev 46) +++ poc/build.properties 2006-04-05 15:52:08 UTC (rev 47) @@ -5,7 +5,7 @@ # Last edited by $Author$ # # $Id$ -release=0.4.6 -releaseDos=0_4_6 +release=0.4.7 +releaseDos=0_4_7 # This could be ALPHA, BETA or STABLE revision=ALPHA \ No newline at end of file Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-30 14:12:08 UTC (rev 46) +++ poc/build.xml 2006-04-05 15:52:08 UTC (rev 47) @@ -194,4 +194,12 @@ <delete file="${OpenDocumentPHPSolid}"/> <delete dir="docs"/> </target> + + <target name="clue"> + <php function="ini_set"> + <param value="'include_path'" /> + <param value="${php.classpath};C:\" /> + </php> + <echo msg="${php.classpath}" /> + </target> </project> Modified: poc/etc/ReleaseInformation.tpl =================================================================== --- poc/etc/ReleaseInformation.tpl 2006-03-30 14:12:08 UTC (rev 46) +++ poc/etc/ReleaseInformation.tpl 2006-04-05 15:52:08 UTC (rev 47) @@ -7,7 +7,7 @@ * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> - * @version $Revision: 39 $ + * @version $Revision$ * @package OpenDocument * @subpackage util * @@ -26,5 +26,44 @@ * X = 1 : "stage 1" code */ const Release = "##release##"; + + /** + * Returns revision information + * + * @return string Revision information. + * @access public + * @final + * @since 0.4.0 + */ + final static public function getRevision() { + $Revision = ""; + return "(".substr("$Revision$",-2).")".self::Revision; + } + + /** + * Returns release and revision information. + * + * @return string Release and revision information. + * @access public + * @final + * @since 0.4.0 + */ + final static public function getRelease() { + return ReleaseInformation::Release.".".self::Revision; + } + + /** + * Returns some informations about this package, release and copyright. + * + * @return string Package name, release and copyright. + * @access public + * @final + * @since 0.4.0 + */ + final static public function getPackageInformation() { + return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; + } + + } ?> \ No newline at end of file Property changes on: poc/etc/ReleaseInformation.tpl ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/OpenDocumentPackage.php 2006-04-05 15:52:08 UTC (rev 47) @@ -25,10 +25,11 @@ require_once( "styles/MasterStyles.php" ); require_once( "content/Body.php" ); require_once( "OpenDocumentAbstract.php" ); +require_once( "util/AbstractDocument.php" ); require_once( "others/ZipFile.php" ); -class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { +class OpenDocumentPackage extends AbstractDocument implements OpenDocument { private $packagename; private $packagetmp; @@ -45,12 +46,9 @@ */ public function __construct( $documentName=0, $documentPath=0, $mimetype="application/vnd.oasis.opendocument.text" ) { parent::__construct( $mimetype ); - - $this->logger->debug( "Constructing OpenDocumentPackage." ); $this->isCommited = false; - $this->logger->debug( "Generating ZipFile object." ); $this->zip = new ZipFile(); if ( !empty( $documentName ) ) { @@ -59,24 +57,23 @@ $this->path = $documentPath; } } - $this->logger->debug( "Generating Manifest with mimetype \"".$this->getMimeType()."\"." ); - $this->DocumentObjects[ "manifest" ] = new Manifest( $this->getMimeType() ); - $this->DocumentObjects[ "meta" ] = new Meta( ); -// $this->DocumentObjects[ "settings" ] = new Settings( ); - - $this->DocumentObjects[ "content" ] = new Content();; + $this->Manifest = new Manifest( $this->getMimeType() ); + $this->Meta = new Meta(); - $this->DocumentObjects[ "styles" ] = new Styles(); + $this->Content = new Content(); + $this->Styles = new Styles(); - $this->DocumentObjects[ "body" ] = $this->DocumentObjects["content"]->getBody(); - - $this->DocumentObjects[ "style" ] = $this->DocumentObjects["styles"]->getStyle(); - $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( - $this->DocumentObjects[ "content" ]->getFontFaceDecl(), - $this->DocumentObjects[ "styles" ]->getFontFaceDecl() + $this->Body = $this->Content->getBody(); + $this->Style = $this->Styles->getStyle(); + $this->FontFaceDeclaration = new FontFaceDeclSplitter( + $this->Content->getFontFaceDecl(), + $this->Styles->getFontFaceDecl() ); // Because all other parts will be inserted on demand, there is no need to initialise them here! - + $this->Settings = NULL; + $this->AutomaticStyles = NULL; + $this->MasterStyles = NULL; + $this->Scripts = NULL; } /** @@ -85,17 +82,6 @@ * @since 0.4.0 */ public function __destruct() { - $this->logger->debug( "Destructing OpenDocumentPackage." ); - $this->removeTmpPackage(); - - unset( $this->manifest ); - unset( $this->packagename ); - unset( $this->packagetmp ); - unset( $this->tmp ); - unset( $this->path ); - - $this->logger->debug( "OpenDocumentPackage destructed." ); - parent::__destruct(); } @@ -114,10 +100,7 @@ * @since 0.4.0 */ private function writeDOMToPackage( $fullpath, $dom ) { - //$dom->save( str_replace( "\\", "/", $this->packagetmp . $fullpath) ); $tmp = str_replace( "\\", "/", $fullpath ); - - $this->logger->debug( "Write DOM to package, use fullpath \"" . $tmp . "\"." ); $this->zip->addFile( $dom->saveXML(), $tmp ); unset( $tmp ); @@ -134,12 +117,10 @@ } else { $tmp = $alt; } + clearstatcache(); - $this->logger->debug( "OpenDocumentPackage->writeZIPFile: Write zip file to \"". $tmp ."\"" ); - if ( file_exists( $tmp ) ) { - $this->logger->warning( "OpenDocumentPackage->writeZIPFile: Found old file \"". $tmp ."\", so I remove it first!" ); unlink( $tmp ); } $handle = fopen( $tmp, "wb" ); @@ -147,39 +128,16 @@ fclose( $handle ); unset( $tmp ); } - + /** * - * @access private - * @depricated - * @since 0.4.0 - */ - private function removeTmpPackage() { - // $this->compartibility->removeDir( $this->packagetmp ); - } - - /** - * - * @access private - * @depricated - * @since 0.4.0 - */ - private function makeSubDir( $path ) { - //$this->compartibility->makeDir( $this->packagetmp . $this->compartibility->sep . $path ); - } - - /** - * * @access public * @since 0.4.0 */ public function setPackageName( $filename ) { global $logger; - $this->logger->debug( "OpenDocumentPackage->setPackageName(" . $filename . ")." ); $this->packagename = $filename; - //$this->packagetmp = $this->tmp . $filename . ".tmp" . $this->compartibility->sep; $this->packagetmp = $this->tmp . $filename . ".tmp/"; - $this->logger->debug( "OpenDocumentPackage->set packagetmp to \"" . $this->packagetmp . "\" ..." ); } /** @@ -197,8 +155,7 @@ * @since 0.4.0 */ public function addManifest( $manifest ) { - $this->logger->debug( "OpenDocumentPackage->addManifest(...)." ); - $this->manifest = $manifest; + $this->Manifest = $manifest; } @@ -219,9 +176,7 @@ * @since 0.4.0 */ public function addXMLDocument( $fullpath, $dom, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentPackage->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); - - $this->DocumentObjects[ "manifest" ]->addEntryToManifest( $fullpath, $mimetype ); + $this->Manifest->addEntryToManifest( $fullpath, $mimetype ); $this->writeDOMToPackage( $fullpath, $dom ); } @@ -231,30 +186,14 @@ * @since 0.4.0 */ private function commit() { - $this->logger->debug( "OpenDocumentPackage->commit()." ); - foreach($this->DocumentObjects as $key => $docObj) { - $this->logger->debug( "OpenDocumentPackage->commit: found \"" . $key . "\" in DocumentObjects array." ); - switch ($key) { - case "meta" : - $this->addXMLDocument( "meta.xml", $docObj->get() ); - break; - case "styles" : - $this->addXMLDocument( "styles.xml", $docObj->get() ); - break; - case "content" : - $this->addXMLDocument( "content.xml", $docObj->get() ); - break; - case "settings" : - $this->addXMLDocument( "settings.xml", $domObj->get() ); - break; - } - } - - $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->DocumentObjects[ "manifest" ]->get() ); - $this->logger->debug( "OpenDocumentPackage->commit: Write mimetype \"". $this->getMimeType()."\" to file \"mimetype\"..." ); + $this->addXMLDocument( "meta.xml", $this->Meta->get() ); + $this->addXMLDocument( "styles.xml", $this->Styles->get() ); + $this->addXMLDocument( "content.xml", $this->Styles->get() ); + if (!empty($this->Settings)) { + $this->addXMLDocument( "settings.xml", $this->Settings->get() ); + } + $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->Manifest->get() ); $this->zip->addFile( $this->getMimeType(), "mimetype" ); - $this->logger->debug( "OpenDocumentPackage->commit: Commited package named \"" . $this->packagename . "\"..." ); - $this->isCommited = true; } @@ -267,7 +206,6 @@ if (!($this->isCommited)) { $this->commit(); } - $this->logger->debug( "OpenDocumentPackage->get()" ); return $this->zip->file(); } @@ -279,29 +217,17 @@ public function save( $altFilename=0 ) { $this->writeZIPFile( $this->get() ); } - + /** * * @access public * @since 0.4.0 */ - public function getMeta() { - if (!array_key_exists ( "meta", $this->DocumentObjects) ) { - $this->DocumentObjects[ "meta" ] = new Meta(); - } - return $this->DocumentObjects[ "meta" ]; - } - - /** - * - * @access public - * @since 0.4.0 - */ public function getContent() { - if (!array_key_exists ( "content", $this->DocumentObjects) ) { - $this->DocumentObjects[ "content" ] = new Content(); + if (empty($this->Content) ) { + $this->Content = new Content(); } - return $this->DocumentObjects[ "content" ]; + return $this->Content; } /** @@ -309,11 +235,11 @@ * @access public * @since 0.4.0 */ - public function getStyle() { - if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = $this->DocumentObjects[ "styles" ]->getStyle(); + public function getStyles() { + if (empty($this->Styles) ) { + $this->Styles = new Styles(); } - return $this->DocumentObjects[ "style" ]; + return $this->Styles; } /** @@ -321,10 +247,9 @@ * @access public * @since 0.4.0 */ - public function getStyles() { - return getStyle(); + public function getStyle() { + return $this->Style; } - /** * @@ -333,46 +258,22 @@ * @since 0.4.4 */ public function getFontFaceDeclaration(){ - return $this->DocumentObjects[ "fontfacedecl" ]; + return $this->FontFaceDeclaration; } - - /** - * - * @access public - * - * @since 0.4.4 - */ - public function getSettings(){ - if (!array_key_exists ( "settings", $this->DocumentObjects) ) { - $this->DocumentObjects[ "settings" ] = new Settings(); - } - return $this->DocumentObjects[ "settings" ]; - } /** * * @access public * - * @since 0.4.0 - */ - public function getBody() { - return $this->DocumentObjects[ "body" ]; - } - - /** - * - * @access public - * * @since 0.4.4 */ public function getScripts(){ - if ( !array_key_exists( "scripts", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "scripts" ] = $this->DocumentObjects[ "content" ]->getScripts(); + if ( empty($this->Scripts) ) { + $this->Scripts = $this->Content->getScripts(); } - return $this->DocumentObjects[ "scripts" ]; + return $this->Scripts; } - /** * * @access public @@ -380,18 +281,13 @@ * @since 0.4.4 */ public function getAutomaticStyles(){ - if ( !array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "automaticstyles" ] = 0; -/* -// This should be something like: - $this->DocumentObjects[ "automaticstyles" ] = new AutmaticStylesSplitter( - $this->DocumentObjects[ "content" ]->getAutmaticStyles(), - $this->DocumentObjects[ "styles" ]->getAutomaticStyles() - ); - -*/ + if (empty($this->AutomaticStyles)) { + $this->AutomaticStyles= new AutmaticStylesSplitter( + $this->Content->getAutmaticStyles(), + $this->Styles->getAutomaticStyles() + ); } - return $this->DocumentObjects[ "automaticstyles" ]; + return $this->AutomaticStyles; } /** @@ -401,10 +297,10 @@ * @since 0.4.4 */ public function getMasterStyles(){ - if ( !array_key_exists( "masterstyles", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "masterstyles" ] = $this->DocumentObjects[ "styles" ]->getMasterStyles(); + if ( empty($this->MasterStyles) ) { + $this->MasterStyles = $this->Styles->getMasterStyles(); } - return $this->DocumentObjects[ "masterstyles" ]; + return $this->MasterStyles; } } Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/OpenDocumentSingle.php 2006-04-05 15:52:08 UTC (rev 47) @@ -24,10 +24,11 @@ require_once( "styles/AutomaticStyles.php" ); require_once( "styles/MasterStyles.php" ); require_once( "content/Body.php" ); -require_once( "OpenDocumentAbstract.php" ); require_once( "util/NameSpaces.php" ); +require_once( "util/MimeTypes.php" ); +require_once( "util/AbstractDocument.php" ); -class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { +class OpenDocumentSingle extends AbstractDocument implements OpenDocument { /** * * @access private @@ -49,28 +50,31 @@ */ private $root; - /** + /** * * @access public * * @since 0.3.0 */ - public function __construct( $mimetype = self::defaultMimeType ) { + public function __construct( $mimetype = MimeTypes::defaultMimeType ) { parent::__construct( $mimetype ); - $this->logger->debug( "Constructing OpenDocumentSingle." ); - $this->isCommited = false; $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->root = $this->dom->createElementNS( NS::OFFICE, "office:document" ); $this->root->setAttributeNS( NS::OFFICE, "office:mimetype", $mimetype ); - - $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); - $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); - $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); - $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); - // Because all other parts will be inserted on demand, there is no need to initialise them here! + + $this->Meta = new Meta( $this->dom, $this->root ); + $this->FontFaceDeclaration = new FontFaceDeclaration( $this->dom, $this->root ); + $this->Style = new Style( $this->dom, $this->root ); + $this->Body = new Body( $this->dom, $this->root ); + + $this->Settings = NULL; + $this->AutomaticStyles = NULL; + $this->MasterStyles = NULL; + $this->Scripts = NULL; + } /** @@ -80,8 +84,6 @@ * @since 0.3.0 */ public function __destruct() { - $this->logger->debug( "OpenDocumentSingle destructed." ); - parent::__destruct(); } @@ -104,7 +106,6 @@ * @since 0.3.0 */ public function addXMLDocument( $fullpath, $domFrag, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); $this->dom->appendChild( $domFrag ); } @@ -115,31 +116,30 @@ * @since 0.3.0 */ private function commit() { - $this->logger->debug( "OpenDocumentSingle->commit()" ); // Add Meta data - $this->DocumentObjects[ "meta" ]->commit(); + $this->Meta->commit(); // Add settings, if needed - if ( array_key_exists( "settings", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "settings" ]->commit(); + if ( !empty( $this->Settings ) ){ + $this->Settings->commit(); } // Add scripts, if needed - if ( array_key_exists( "scripts", $this->DocumentObjects ) ) { - $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); + if ( !empty( $this->Script ) ) { + $this->root->appendChild( $this->Script->get() ); } // Add FontFaceDeclarations - $this->root->appendChild( $this->DocumentObjects[ "fontfacedecl" ]->get() ); + $this->root->appendChild( $this->FontFaceDeclaration->get() ); // Add Style - $this->root->appendChild( $this->DocumentObjects[ "style" ]->get() ); + $this->root->appendChild( $this->Style->get() ); // Add AutomaticSytles, if needed - if ( array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { - $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); + if ( !empty( $this->AutomaticStyles ) ) { + $this->root->appendChild( $this->AutomaticStyles->get() ); } // Add MasterStyles, if needed - if ( array_key_exists( "masterstyles", $this->DocumentObjects ) ) { - $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); + if ( !empty( $this->MasterStyles ) ) { + $this->root->appendChild( $this->MasterStyles->get() ); } // Add Body - $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); + $this->root->appendChild( $this->Body->get() ); // Add all to DOM document $this->dom->appendChild( $this->root ); // Normalzise DOM document @@ -155,7 +155,6 @@ * @since 0.3.0 */ public function get() { - $this->logger->debug( "OpenDocumentSingle->get()" ); return $this->getAsDOM()->saveXML(); } @@ -169,7 +168,6 @@ if (!($this->isCommited)) { $this->commit(); } - $this->logger->debug( "OpenDocumentSingle->getAsDOM()" ); return $this->dom; } @@ -191,10 +189,10 @@ * @since 0.3.0 */ public function getMeta() { - if ( !array_key_exists( "meta", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); + if ( empty($this->Meta)) { + $this->Meta = new Meta( $this->dom, $this->root ); } - return $this->DocumentObjects[ "meta" ]; + return $this->Meta; } /** @@ -216,7 +214,7 @@ * @since 0.3.0 */ public function getStyles() { - return $this->getStyle(); + return 0; } /** @@ -226,10 +224,10 @@ * @since 0.3.0 */ public function getStyle() { - if ( !array_key_exists( "style", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); + if ( empty($this->Style)) { + $this->Style = new Style( $this->dom, $this->root ); } - return $this->DocumentObjects[ "style" ]; + return $this->Style; } /** @@ -239,7 +237,10 @@ * @since 0.4.0 */ public function getBody() { - return $this->DocumentObjects[ "body" ]; + if ( empty($this->Body)) { + $this->Body = new Body( $this->dom, $this->root ); + } + return $this->Body; } /** @@ -249,7 +250,10 @@ * @since 0.4.4 */ public function getFontFaceDeclaration(){ - return $this->DocumentObjects[ "fontfacedecl" ]; + if ( empty($this->FontFaceDeclaration)) { + $this->FontFaceDeclaration = new FontFaceDeclaration( $this->dom, $this->root ); + } + return $this->FontFaceDeclaration; } /** @@ -259,10 +263,10 @@ * @since 0.4.4 */ public function getSettings(){ - if ( !array_key_exists( "settings", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); + if ( empty($this->Settings)) { + $this->Settings = new Settings( $this->dom, $this->root ); } - return $this->DocumentObjects[ "settings" ]; + return $this->Settings; } /** @@ -272,10 +276,10 @@ * @since 0.4.4 */ public function getScripts(){ - if ( !array_key_exists( "scripts", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + if ( empty($this->Scripts)) { + $this->Scripts = new Scripts( $this->dom, $this->root ); } - return $this->DocumentObjects[ "scripts" ]; + return $this->Scripts; } @@ -286,10 +290,10 @@ * @since 0.4.4 */ public function getAutomaticStyles(){ - if ( !array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + if ( empty($this->AutomaticStyles)) { + $this->AutomaticStyles = new AutomaticStyles( $this->dom, $this->root ); } - return $this->DocumentObjects[ "automaticstyles" ]; + return $this->AutomaticStyles; } /** @@ -299,11 +303,10 @@ * @since 0.4.4 */ public function getMasterStyles(){ - if ( !array_key_exists( "masterstyles", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "masterstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + if ( empty($this->MasterStyles)) { + $this->MasterStyles = new MasterStyles( $this->dom, $this->root ); } - return $this->DocumentObjects[ "masterstyles" ]; + return $this->MasterStyles; } - } ?> \ No newline at end of file Modified: poc/src/content/Body.php =================================================================== --- poc/src/content/Body.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/content/Body.php 2006-04-05 15:52:08 UTC (rev 47) @@ -12,16 +12,29 @@ * @subpackage content * @since 0.4.3 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "content/BodyText.php" ); require_once( "content/BodyTable.php" ); require_once( "util/NameSpaces.php" ); -class Body extends OpenDocumentObjectAbstract { - +class Body { /** * * @access private + * @since 0.4.7 + */ + private $dom; + + /** + * + * @access private + * @since 0.4.7 + */ + private $isCommited; + + /** + * + * @depricated + * @access private * @since 0.4.3 */ private $DomFragment; @@ -46,10 +59,7 @@ * @access public * @since 0.4.3 */ - public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing content/Body." ); - + public function __construct( $dom ) { $this->dom = $dom; $this->BodyFragment = $this->dom->createDocumentFragment(); $this->body = $this->dom->createElementNS( NS::OFFICE, "office:body" ); @@ -62,7 +72,6 @@ * @since 0.4.3 */ public function commit() { - $this->logger->debug( "content/Body->commit()" ); foreach( $this->Fragments as $namespace => $class ) { $tmp = $class->get(); if (!empty( $tmp )) { @@ -81,7 +90,6 @@ * @since 0.4.3 */ private function getByNamespace( $NS, $class ) { - $this->logger->debug( "content/Body->getByNamespace(\"".$NS."\", \"".$class."\")" ); if (!array_key_exists( $NS, $this->Fragments ) ) { $this->Fragments[ $NS ] = new $class( $this->dom ); } @@ -94,7 +102,6 @@ * @since 0.4.3 */ public function getText() { - $this->logger->debug( "content/Body->getText()" ); return $this->getByNamespace( NS::TEXT, "BodyText" ); } @@ -104,7 +111,6 @@ * @since 0.4.3 */ public function getTable() { - $this->logger->debug( "content/Body->getTable()" ); return $this->getByNamespace( NS::TABLE, "BodyTable" ); } @@ -115,7 +121,6 @@ * @since 0.4.3 */ final public function get() { - $this->logger->debug( "content/Body->get()" ); if (!$this->isCommited) { $this->commit(); } Modified: poc/src/content/BodyTable.php =================================================================== --- poc/src/content/BodyTable.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/content/BodyTable.php 2006-04-05 15:52:08 UTC (rev 47) @@ -13,19 +13,24 @@ * @since 0.4.3 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class BodyTable extends OpenDocumentObjectAbstract { +class BodyTable { + + /** + * + * @access private + * @since 0.4.7 + */ + private $dom; + /** * Class construtor. * * @access public * @since 0.4.3 */ - public function __construct( $dom ) { - parent::__construct(); - + public function __construct( $dom ) { $this->dom = $dom; $this->DomFragment = $dom->createDocumentFragment(); $this->body = $this->DomFragment->createElementNS( NS::OFFICE, "office:table" ); Modified: poc/src/content/BodyText.php =================================================================== --- poc/src/content/BodyText.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/content/BodyText.php 2006-04-05 15:52:08 UTC (rev 47) @@ -12,11 +12,24 @@ * @since 0.4.0 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class BodyText extends OpenDocumentObjectAbstract { +class BodyText { /** + * + * @access private + * @since 0.4.7 + */ + private $dom; + + /** + * + * @access private + * @since 0.4.7 + */ + private $isCommited; + + /** * Class construtor. * * @access public @@ -24,9 +37,6 @@ * @since 0.4.0 */ public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); - $this->dom = $dom; $this->text = $this->dom->createElementNS( NS::OFFICE, "office:text" ); } @@ -38,7 +48,6 @@ * @since 0.4.0 */ public function commit() { - $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); $this->isCommited = true; } @@ -49,7 +58,6 @@ * @since 0.4.0 */ public function getTextParagraph( $styleName, $parText=0 ) { - $this->logger->debug( "OpenDocumentContentBodyText->getTextParagraph(\"".$styleName."\",\"".$parText."\")" ); if (empty($parText)) { $par = $this->dom->createElementNS( NS::TEXT, "text:p" ); } else { @@ -66,7 +74,6 @@ * @since 0.4.0 */ public function addToText( $Node ) { - $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); $this->text->appendChild( $Node ); } @@ -77,7 +84,6 @@ * @since 0.4.0 */ public function getTextHeading( $styleName, $outlineLevel=1, $headText=0 ) { - $this->logger->debug( "OpenDocumentContentBodyText->getTextHeading()" ); if (empty($headText)) { $head = $this->dom->createElementNS( NS::TEXT, "text:h" ); } else { @@ -95,7 +101,6 @@ * @since 0.4.0 */ public function addNoForms() { - $this->logger->debug( "OpenDocumentContentBodyText->addNoForms()" ); $forms = $this->dom->createElementNS( NS::OFFICE, "office:forms" ); $forms->setAttributeNS( NS::FORM, "form:automatic-focus", "false" ); @@ -112,7 +117,6 @@ * @since 0.4.0 */ final public function get() { - $this->logger->debug( "OpenDocumentContentBodyText->get()" ); if (!$this->isCommited) { $this->commit(); } Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/content/Content.php 2006-04-05 15:52:08 UTC (rev 47) @@ -20,13 +20,54 @@ require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class Content extends OpenDocumentObjectAbstract { +class Content { + /** + * + * @access private + * @since 0.4.4 + */ + private $root; - private $root; + /** + * + * @access private + * @since 0.4.7 + */ + private $dom; + + /** + * + * @access private + * @since 0.4.4 + */ private $Scripts; + + /** + * + * @access private + * @since 0.4.4 + */ private $FontFaceDecl; + + /** + * + * @access private + * @since 0.4.4 + */ private $AutomaticStyles; + + /** + * + * @access private + * @since 0.4.4 + */ private $Body; + + /** + * + * @access private + * @since 0.4.4 + */ private $text; /** @@ -37,8 +78,6 @@ * @since 0.4.0 */ public function __construct() { - parent::__construct(); - $this->logger->debug( "Constructing content/Content." ); // this is part of a package document $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->dom->formatOutput = true; Modified: poc/src/content/Scripts.php =================================================================== --- poc/src/content/Scripts.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/content/Scripts.php 2006-04-05 15:52:08 UTC (rev 47) @@ -15,14 +15,13 @@ * * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class Scripts extends OpenDocumentObjectAbstract { +class Scripts { + /** * * @access private - * * @since 0.4.4 */ private $scripts; @@ -30,10 +29,16 @@ /** * * @access private - * * @since 0.4.4 */ private $root; + + /** + * + * @access private + * @since 0.4.7 + */ + private $dom; /** * Class construtor. @@ -41,10 +46,7 @@ * @access public * @since 0.4.4 */ - public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing content/Scripts." ); - + public function __construct( $dom ) { $this->dom = $dom; $this->scripts = $this->dom->createElementNS( NS::OFFICE, "office:scripts" ); Modified: poc/src/manifest/Manifest.php =================================================================== --- poc/src/manifest/Manifest.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/manifest/Manifest.php 2006-04-05 15:52:08 UTC (rev 47) @@ -12,17 +12,38 @@ * @subpackage manifest * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class Manifest extends OpenDocumentObjectAbstract { +class Manifest { const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; const odmSYSTEM = "Manifest.dtd"; const odmROOT = "manifest:manifest"; const defaultMimeType = "application/vnd.oasis.opendocument.text"; + /** + * + * @access private + * + * @since 0.4.4 + */ private $root; + /** + * + * @access private + * + * @since 0.4.7 + */ + private $dom; + + /** + * + * @access private + * + * @since 0.4.7 + */ + private $mimetype; + /** * * @access public @@ -30,7 +51,6 @@ * @since 0.4.0 */ public function __construct( $mimetype = self::defaultMimeType ) { - parent::__construct( $mimetype ); $this->createManifestDOM(); } Modified: poc/src/meta/Meta.php =================================================================== --- poc/src/meta/Meta.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/meta/Meta.php 2006-04-05 15:52:08 UTC (rev 47) @@ -16,18 +16,33 @@ * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); +require_once( "util/ReleaseInformation.php" ); +class Meta { -class Meta extends OpenDocumentObjectAbstract { - /** * This points to the "root" element of the meta data. * * @since 0.3.0 */ private $root; + + /** + * + * @access private + * + * @since 0.4.7 + */ + private $dom; + + /** + * + * @access private + * + * @since 0.4.7 + */ + private $isCommited; /** * This points to the "root" element of the document meta data structure. @@ -45,10 +60,6 @@ * @since 0.3.0 */ public function __construct( $dom=0, $root=0 ) { - parent::__construct(); - - $this->logger->debug( "Constructing meta/Meta." ); - if (empty($dom)) { // this is part of a package document $this->dom = new DOMDocument( "1.0", "utf-8" ); @@ -73,14 +84,7 @@ * * @since 0.3.0 */ - public function __destruct() { - unset( $dom ); - unset( $root ); - unset( $meta ); - - $this->logger->debug( "meta/Meta destructed." ); - - parent::__destruct(); + public function __destruct() { } /** @@ -95,7 +99,6 @@ if($tmpDom->load( $filename ) === false) { trigger_error( 'Could not parse XML contents in OpenDocument file' ); - $this->logger->crit( "Could not parse XML contents in OpenDocument file" ); return false; } @@ -126,7 +129,6 @@ * @since 0.3.2 */ public function addDublinCore( $dc, $value) { - $this->logger->debug( "meta/Meta->addDublinCore: ". $value ."." ); $node = $this->dom->createElementNS( NS::DC, "dc:".$dc, $value ); $this->root->appendChild( $node ); unset( $node ); @@ -148,8 +150,6 @@ if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; } - unset( $nodelist ); - $this->logger->debug( "meta/Meta->getDublinCore: ". $retValue ."." ); return $retValue; } @@ -178,14 +178,10 @@ } else { $creation_time = date( "Y-m-d\TH:i:s", $date ); } - $this->logger->debug( "meta/Meta->addCreationTime: ". $creation_time ."." ); - $node = $this->dom->createElementNS( NS::META, "meta:creation-date", $creation_time ); $this->root->appendChild( $node ); - - unset( $creation_time ); - + } /** @@ -209,20 +205,17 @@ */ public function addGenerator( $generator=0 ) { $lgenerator = ""; - + /* FIX ME !!!*/ if (empty($generator)) { - $lgenerator = "OpenDocmentPHP/".$this->getRelease(); + $lgenerator = "OpenDocmentPHP/" /*.ReleaseInformation->getRelease() */; } else { $lgenerator = $generator; } - $this->logger->debug( "meta/Meta->addGenerator: ". $lgenerator ."." ); - $node = $this->dom->createElementNS( NS::META, "meta:generator", $lgenerator ); $this->root->appendChild( $node ); - unset( $lgenerator ); } /** @@ -254,8 +247,7 @@ if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; } - unset( $nodelist ); - $this->logger->debug( "meta/Meta->getGenerator: ". $retValue ."." ); + return $retValue; } @@ -266,7 +258,6 @@ * @since 0.4.0 */ public function addInitialCreator( $initialCreator ) { - $this->logger->debug( "meta/Meta->addInitialCreator: ". $initialCreator ."." ); $node = $this->dom->createElementNS( NS::META, "meta:initial-creator", $initialCreator ); $this->root->appendChild( $node ); } @@ -283,8 +274,6 @@ if ($nodelist->length == 1) { $retValue = $nodelist->item( 0 )->nodeValue; } -// unset( $nodelist ); - $this->logger->debug( "meta/Meta->getInitialCreator: ". $retValue ."." ); return $retValue; } @@ -304,7 +293,6 @@ $node->setAttributeNS( NS::META, "meta:value", $value ); } $this->root->appendChild( $node ); - unset( $node ); } /** @@ -320,7 +308,6 @@ $this->meta->appendChild( $this->root ); $this->dom->normalize(); $this->isCommited = true; - $this->logger->debug( "meta/Meta->commit()." ); } /** @@ -340,7 +327,6 @@ if (!$this->isCommited) { $this->commit(); } - $this->logger->debug( "OpenDocumentMeta->get()." ); return $this->dom; } @@ -352,7 +338,6 @@ * @since 0.4.0 */ final public function save( $filename ) { - $this->logger->debug( "OpenDocumentMeta->save(". $filename .")." ); $this->get()->save( $filename ); } } Modified: poc/src/settings/Settings.php =================================================================== --- poc/src/settings/Settings.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/settings/Settings.php 2006-04-05 15:52:08 UTC (rev 47) @@ -15,14 +15,12 @@ * * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class Settings extends OpenDocumentObjectAbstract { +class Settings { /** * * @access private - * * @since 0.4.4 */ private $settings; @@ -30,18 +28,18 @@ /** * * @access private - * * @since 0.4.4 */ private $root; /** - * This is true, if something was added to settings. - * @accedd private - * @since 0.4.4 + * + * @access private + * @since 0.4.7 */ - private $somethingAdded; - + private $dom; + + /** * Class construtor. * @@ -49,7 +47,6 @@ * @since 0.4.4 */ public function __construct( $dom=0, $root=0 ) { - parent::__construct(); $this->logger->debug( "Constructing settings/Settings." ); if (empty($dom)) { // this is part of a package document Modified: poc/src/styles/AutomaticStyles.php =================================================================== --- poc/src/styles/AutomaticStyles.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/AutomaticStyles.php 2006-04-05 15:52:08 UTC (rev 47) @@ -14,10 +14,10 @@ * @subpackage styles * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "styles/AutomaticStylesInterface.php" ); require_once( "util/NameSpaces.php" ); -class AutomaticStyles extends OpenDocumentObjectAbstract { +class AutomaticStyles{ /** * @@ -33,6 +33,12 @@ /** * + * @since 0.4.7 + */ + private $dom; + + /** + * * @param DOMDocument $dom * * @access public @@ -40,10 +46,6 @@ * @since 0.4.4 */ public function __construct( $dom, $root=0) { - parent::__construct(); - - $this->logger->debug( "Constructing styles/AutomaticStyles." ); - $this->dom = $dom; $this->root = $this->dom->createElementNS( NS::OFFICE, "office:automatic-styles" ); } Added: poc/src/styles/AutomaticStylesInterface.php =================================================================== --- poc/src/styles/AutomaticStylesInterface.php (rev 0) +++ poc/src/styles/AutomaticStylesInterface.php 2006-04-05 15:52:08 UTC (rev 47) @@ -0,0 +1,28 @@ +<?php +/** + * AutomaticStyles Interface + * + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage styles + * @since 0.4.7 + */ + +interface AutomaticStylesInterface { + + /** + * + * @access public + * + * @since 0.4.7 + */ + public function commit(); + +} +?> \ No newline at end of file Property changes on: poc/src/styles/AutomaticStylesInterface.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/styles/AutomaticStylesSplitter.php =================================================================== --- poc/src/styles/AutomaticStylesSplitter.php (rev 0) +++ poc/src/styles/AutomaticStylesSplitter.php 2006-04-05 15:52:08 UTC (rev 47) @@ -0,0 +1,43 @@ +<?php +/** + * AutomaticStylesSplitter Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage styles + * @since 0.4.7 + */ + +class AutomaticStylesSplitter implements AutomaticStylesInterface { + private $FFD1; + private $FFD2; + /** + * + * @param DOMDocument $dom + * + * @access public + * + * @since 0.4.4 + */ + public function __construct( $f1, $f2 ) { + $this->FFD1 = $f1; + $this->FFD2 = $f2; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function commit() { + $this->isCommited = true; + } + +} +?> \ No newline at end of file Property changes on: poc/src/styles/AutomaticStylesSplitter.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/styles/FontFaceDeclInterface.php =================================================================== --- poc/src/styles/FontFaceDeclInterface.php (rev 0) +++ poc/src/styles/FontFaceDeclInterface.php 2006-04-05 15:52:08 UTC (rev 47) @@ -0,0 +1,35 @@ +<?php +/** + * FontFaceDeclaration Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage styles + * @since 0.4.7 + */ + +interface FontFaceDeclInterface { + + /** + * + * @access public + * + * @since 0.4.7 + */ + public function addFontFace( $name, $styleAttr=0, $SVGAttr=0 ); + + /** + * + * @access public + * + * @since 0.4.7 + */ + public function commit(); + +} +?> \ No newline at end of file Property changes on: poc/src/styles/FontFaceDeclInterface.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/styles/FontFaceDeclSplitter.php =================================================================== --- poc/src/styles/FontFaceDeclSplitter.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/FontFaceDeclSplitter.php 2006-04-05 15:52:08 UTC (rev 47) @@ -12,9 +12,9 @@ * @subpackage styles * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "styles/FontFaceDeclInterface.php" ); -class FontFaceDeclSplitter extends OpenDocumentObjectAbstract { +class FontFaceDeclSplitter implements FontFaceDeclInterface { private $FFD1; private $FFD2; /** @@ -26,8 +26,6 @@ * @since 0.4.4 */ public function __construct( $f1, $f2 ) { - parent::__construct(); - $this->FFD1 = $f1; $this->FFD2 = $f2; } Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/FontFaceDeclaration.php 2006-04-05 15:52:08 UTC (rev 47) @@ -4,23 +4,32 @@ * * $Id$ * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument * @subpackage styles - * @since 0.4.2 + * @since 0.4.2 */ -require_once( "OpenDocumentObjectAbstract.php" ); +require_once( "styles/FontFaceDeclInterface.php" ); require_once( "util/NameSpaces.php" ); -class FontFaceDeclaration extends OpenDocumentObjectAbstract { +class FontFaceDeclaration implements FontFaceDeclInterface { /** * - */ + * @access private + * @since 0.4.2 + */ private $FontFaceDecl; + + /** + * + * @access private + * @since 0.4.7 + */ + private $isCommited; /** * @@ -31,7 +40,6 @@ * @since 0.4.2 */ public function __construct( $dom, $root=0) { - parent::__construct(); $this->dom = $dom; $this->useDom2 = false; Modified: poc/src/styles/MasterStyles.php =================================================================== --- poc/src/styles/MasterStyles.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/MasterStyles.php 2006-04-05 15:52:08 UTC (rev 47) @@ -14,23 +14,31 @@ * @subpackage styles * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class MasterStyles extends OpenDocumentObjectAbstract { +class MasterStyles { /** * + * @since 0.4.4 */ private $style; /** * + * @since 0.4.4 */ private $root; /** * + * @since 0.4.7 + */ + private $dom; + + + /** + * * @param DOMDocument $dom * * @access public @@ -38,10 +46,6 @@ * @since 0.4.4 */ public function __construct( $dom, $root) { - parent::__construct(); - - $this->logger->debug( "Constructing styles/MasterStyles." ); - $this->dom = $dom; $this->style = $root; $this->root = $this->dom->createElementNS( NS::OFFICE, "office:master-styles" ); Modified: poc/src/styles/Style.php =================================================================== --- poc/src/styles/Style.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/Style.php 2006-04-05 15:52:08 UTC (rev 47) @@ -12,10 +12,9 @@ * @subpackage styles * @since 0.4.4 */ -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); -class Style extends OpenDocumentObjectAbstract { +class Style { /** * @@ -31,6 +30,12 @@ /** * + * @since 0.4.7 + */ + private $dom; + + /** + * * @since 0.4.4 */ private $Styles; @@ -43,6 +48,13 @@ /** * + * @access private + * @since 0.4.7 + */ + private $isCommited; + + /** + * * @param DOMDocument $dom * * @access public @@ -50,10 +62,6 @@ * @since 0.4.4 */ public function __construct( $dom, $root=0) { - parent::__construct(); - - $this->logger->debug( "Constructing style/Style." ); - $this->dom = $dom; $this->root = $this->dom->createElementNS( NS::OFFICE, "office:styles" ); Modified: poc/src/styles/Styles.php =================================================================== --- poc/src/styles/Styles.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/styles/Styles.php 2006-04-05 15:52:08 UTC (rev 47) @@ -18,14 +18,45 @@ require_once( "styles/MasterStyles.php" ); require_once( "util/NameSpaces.php" ); -class Styles extends OpenDocumentObjectAbstract { +class Styles { + + /** + * + * @since 0.4.7 + */ + private $dom; + /** + * + * @since 0.4.0 + */ private $root; + + /** + * + * @since 0.4.0 + */ private $styles; + /** + * + * @since 0.4.5 + */ private $FontFaceDecl; + /** + * + * @since 0.4.5 + */ private $Style; + /** + * + * @since 0.4.5 + */ private $AutomaticStyles; + /** + * + * @since 0.4.5 + */ private $MasterStyles; /** @@ -38,7 +69,6 @@ * @since 0.4.0 */ public function __construct( ) { - parent::__construct(); // this is part of a package document $this->dom = new DOMDocument( "1.0", "utf-8" ); Added: poc/src/util/AbstractDocument.php =================================================================== --- poc/src/util/AbstractDocument.php (rev 0) +++ poc/src/util/AbstractDocument.php 2006-04-05 15:52:08 UTC (rev 47) @@ -0,0 +1,256 @@ +<?php +/** + * AbstractDocument Class + * + * This class will include Meta, Settings, Scripts, FontFaceDeclarations, Styles, + * Automatic Styles, Master Styles, and Body classes in one single XML file. + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yaw...@us...> + * @version $Revision$ + * @package OpenDocument + * + * @since 0.3.0 + */ +require_once( "OpenDocument.php" ); + +abstract class AbstractDocument implements OpenDocument { + /** + * + * @access private + * @since 0.4.7 + */ + private $AutomaticStyle; + + /** + * + * @access private + * @since 0.4.7 + */ + private $Body; + + /** + * + * @access private + * @since 0.4.7 + */ + private $FontFaceDeclaration; + + /** + * + * @access private + * @since 0.4.7 + */ + private $MasterStyle; + + /** + * + * @access private + * @since 0.4.7 + */ + private $Meta; + + /** + * + * @access private + * @since 0.4.7 + */ + private $Scripts; + + /** + * + * @access private + * @since 0.4.7 + */ + private $Settings; + + /** + * + * @access private + * @since 0.4.7 + */ + private $Style; + + /** + * The mime type of the document + * + * @access protected + * @since 0.4.7 + */ + protected $mimetype; + + /** + * + * @access public + * @since 0.4.7 + */ + public function __construct( $mimetype = 0 ) { + $this->logger = &Log::factory( "null", "", "OpenDocument" ); + $this->logger->debug( "Constructing AbstractDocument." ); + + $this->mimetype = $mimetype; + } + + /** + * + * @access public + * @since 0.3.0 + */ + public function __destruct() { + $this->logger->debug( "AbstractDocument destructed." ); + $this->logger->close(); + } + + + /** + * + * @access public + * @since 0.4.7 + */ + public function getMeta() { + if ( empty($this->Meta)) { + $this->Meta = new Meta( $this->dom, $this->root ); + } + return $this->Meta; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getStyle() { + if ( empty($this->Style)) { + $this->Style = new Style( $this->dom, $this->root ); + } + return $this->Style; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getBody() { + if ( empty($this->Body)) { + $this->Body = new Body( $this->dom, $this->root ); + } + return $this->Body; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getFontFaceDeclaration(){ + if ( empty($this->FontFaceDeclaration)) { + $this->FontFaceDeclaration = new FontFaceDeclaration( $this->dom, $this->root ); + } + return $this->FontFaceDeclaration; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getSettings(){ + if ( empty($this->Settings)) { + $this->Settings = new Settings( $this->dom, $this->root ); + } + return $this->Settings; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getScripts(){ + if ( empty($this->Scripts)) { + $this->Scripts = new Scripts( $this->dom, $this->root ); + } + return $this->Scripts; + } + + + /** + * + * @access public + * @since 0.4.7 + */ + public function getAutomaticStyles(){ + if ( empty($this->AutomaticStyles)) { + $this->AutomaticStyles = new AutomaticStyles( $this->dom, $this->root ); + } + return $this->AutomaticStyles; + } + + /** + * + * @access public + * @since 0.4.7 + */ + public function getMasterStyles(){ + if ( empty($this->MasterStyles)) { + $this->MasterStyles = new MasterStyles( $this->dom, $this->root ); + } + return $this->MasterStyles; + } + + /** + * Returns the setted mime type of this document. + * + * @return string Current mime type of this document. + * @access public + * @final + * @since 0.4.0 + */ + final public function getMimeType() { + return $this->mimetype; + } + + /** + * Returns revision information + * + * @return string Revision information. + * @access public + * @final + * @since 0.4.0 + */ + final public function getRevision() { + $Revision = ""; + return "(".substr("$Revision$",-2).")".ReleaseInformation::Revision; + } + + /** + * Returns release and revision information. + * + * @return string Release and revision information. + * @access public + * @final + * @since 0.4.0 + */ + final public function getRelease() { + return ReleaseInformation::Release.".".ReleaseInformation::Revision; + } + + /** + * Returns some informations about this package, release and copyright. + * + * @return string Package name, release and copyright. + * @access public + * @final + * @since 0.4.0 + */ + final public function getPackageInformation() { + return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; + } + + +} \ No newline at end of file Property changes on: poc/src/util/AbstractDocument.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/util/MimeTypes.php =================================================================== --- poc/src/util/MimeTypes.php (rev 0) +++ poc/src/util/MimeTypes.php 2006-04-05 15:52:08 UTC (rev 47) @@ -0,0 +1,22 @@ +<?php +/** + * NameSpaces Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage util + * @since 0.4.7 + */ + +class MimeTypes { + const Text = "application/vnd.oasis.opendocument.text"; + const Calc = "application/vnd.oasis.opendocument.calc"; + const defaultMimeType = "application/vnd.oasis.opendocument.text"; +} + +?> \ No newline at end of file Property changes on: poc/src/util/MimeTypes.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/util/NameSpaces.php =================================================================== --- poc/src/util/NameSpaces.php 2006-03-30 14:12:08 UTC (rev 46) +++ poc/src/util/NameSpaces.php 2006-04-05 15:52:08 UTC (rev 47) @@ -10,7 +10,7 @@ * @version $Revision$ * @package OpenDocument * @subpackage util - * @since 0.5.0 + * @since 0.4.6 */ class NameSpaces { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-14 09:06:55
|
Revision: 58 Author: nmarkgraf Date: 2006-04-14 02:06:18 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=58&view=rev Log Message: ----------- MAJOR BUG FIX! We had a mojor bug in the Manifest class. This is fix now and a test case is written to check this from now on. Also: - Several tiny, minor and cosmetic changes to the other classes. - Added a new class DefaultSettings to hold some XML settings often used. - Added two new samples. Validator.php shows how to validate OpenDocument documents and SimpleDocument shows how to create a simple Document. Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentPackageTest.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/Content.php poc/src/manifest/Manifest.php poc/src/manifest/ManifestTest.php poc/src/meta/Meta.php poc/src/samples/TestOutput.php poc/src/settings/Settings.php poc/src/styles/Styles.php Added Paths: ----------- poc/src/samples/SimpleDocument.php poc/src/samples/Validator.php poc/src/util/DefaultSettings.php Property Changed: ---------------- poc/etc/ReleaseInformation.tpl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-05-01 12:52:41
|
Revision: 69 Author: nmarkgraf Date: 2006-05-01 05:51:31 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=69&view=rev Log Message: ----------- Minory changes: - Changed package name from OpenDocument to OpenDocumentPHP. - Added some informations to a new READ-ME.txt file Modified Paths: -------------- poc/etc/ReleaseInformation.tpl poc/src/OpenDocument.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentPackageTest.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php poc/src/content/Content.php poc/src/content/Scripts.php poc/src/manifest/Manifest.php poc/src/manifest/ManifestTest.php poc/src/meta/Meta.php poc/src/meta/MetaTest.php poc/src/others/ZipFile.php poc/src/samples/SimpleDocument.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php poc/src/samples/Validator.php poc/src/settings/Settings.php poc/src/settings/SettingsTest.php poc/src/styles/AutomaticStyles.php poc/src/styles/AutomaticStylesInterface.php poc/src/styles/AutomaticStylesSplitter.php poc/src/styles/FontFaceDeclInterface.php poc/src/styles/FontFaceDeclSplitter.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/MasterStyles.php poc/src/styles/Style.php poc/src/styles/StyleAbstract.php poc/src/styles/Styles.php poc/src/util/AbstractDocument.php poc/src/util/AbstractDocumentTest.php poc/src/util/DefaultSettings.php poc/src/util/MimeTypes.php poc/src/util/MimeTypesTest.php poc/src/util/NameSpaces.php poc/src/util/NameSpacesTest.php poc/src/util/ReleaseInformationTest.php Added Paths: ----------- poc/READ-ME.txt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-05-01 13:24:59
|
Revision: 70 Author: nmarkgraf Date: 2006-05-01 06:24:33 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=70&view=rev Log Message: ----------- Added a new class util/CheckPHP, this is the start of a project internal PHP checking. So we find out what files, libraries and so on developers and/or users have to install before they can use OpenDocumentPHP. Added Paths: ----------- poc/src/util/CheckPHP.php Property Changed: ---------------- poc/READ-ME.txt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-05-14 09:55:13
|
Revision: 84 Author: nmarkgraf Date: 2006-05-14 02:54:54 -0700 (Sun, 14 May 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=84&view=rev Log Message: ----------- Some tiny bug fixes. So the solid php file will run again. Modified Paths: -------------- poc/READ-ME.txt poc/build.xml poc/src/OpenDocument.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/samples/TestOutput.php poc/src/util/AbstractDocument.php poc/src/util/CheckPHP.php poc/src/util/DefaultSettings.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2007-01-16 14:44:00
|
Revision: 88 http://svn.sourceforge.net/opendocumentphp/?rev=88&view=rev Author: nmarkgraf Date: 2007-01-16 06:43:52 -0800 (Tue, 16 Jan 2007) Log Message: ----------- Move old stuff to codebase poc. New stuff will be in the new phase1 directory. Modified Paths: -------------- poc/build.properties poc/build.xml This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2007-01-19 15:22:59
|
Revision: 97 http://svn.sourceforge.net/opendocumentphp/?rev=97&view=rev Author: nmarkgraf Date: 2007-01-19 07:22:54 -0800 (Fri, 19 Jan 2007) Log Message: ----------- - First parts of two new classes added, Paragraph and Heading. Both classes are work in progress! - Added currently unused class Script to handle scripts in the ScriptsFragment class. Therefor moved ScriptsFragment out of the body into the conent directory. - Some tiny typos fixes in ContentDocument and ManifestDocument. Modified Paths: -------------- poc/build.properties poc/src/phase1/content/ContentDocument.php poc/src/phase1/manifest/ManifestDocument.php Added Paths: ----------- poc/src/phase1/content/body/text/Heading.php poc/src/phase1/content/body/text/Paragraph.php poc/src/phase1/content/script/ poc/src/phase1/content/script/Script.php Removed Paths: ------------- poc/src/phase1/content/body/ScriptsFragment.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |