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. |