DIRXML = $dir; $this->FILENAME = "META-INF/manifest.xml"; $this->xml = new DOMIT_Document(); $this->xml->setDocType(""); } function create($type){ $docManifestNode =& $this->xml->createElement("manifest:manifest"); $docManifestNode->setAttribute("xmlns:manifest", "http://openoffice.org/2001/manifest"); $fileEntryNode = &$this->xml->createElement("manifest:file-entry"); if (in_array($type, $this->XMLTYPE)) { $fileEntryNode->setAttribute("manifest:media-type", "application/".$this->MIME[$type]); } else { $this -> ErrorTracker(4, 'Le type '.$type." est inconnu", 'create', __FILE__, __LINE__); } $fileEntryNode->setAttribute("manifest:full-path", "/"); $docManifestNode->appendChild($fileEntryNode); $cdir = new CDir(); $cdir->Read( $this->DIRXML."/", "", true, 5 , true, true); $allFiles = array(); $sortFiles = $cdir->sort("'Path'", false, 4, "'File'", true, 0); reset( $sortFiles ); foreach ($sortFiles as $aFile) { $sFileName = $cdir->FileName($aFile); $sFilePath = $cdir->GetPath($aFile); $mediaType = ""; $sExtension = ""; $fileEntryNode = &$this->xml->createElement("manifest:file-entry"); $i = strrpos( $sFileName, "." ) + 1; if ( substr( $sFileName, $i - 1, 1 ) == "." ) { $sExtension = substr( $sFileName, $i ); } switch($sExtension){ case "": $mediaType = ""; break; case "png": case "gif": case "jpeg": $mediaType = "image/".$sExtension; break; default: $mediaType = "text/xml"; } // switch $dirname = dirname($this->DIRXML."/".$sFilePath.$sFileName); $filename = basename($this->DIRXML."/".$sFilePath.$sFileName); if ($dirname != $this->DIRXML) { $filename = str_replace($this->DIRXML."/", "", $dirname)."/".$filename; } else { if ($cdir->GetIsDirectory( $aFile )) $filename = $filename."/"; } $fileEntryNode->setAttribute("manifest:media-type", $mediaType); $fileEntryNode->setAttribute("manifest:full-path", $filename); $docManifestNode->appendChild($fileEntryNode); } $this->xml->setDocumentElement($docManifestNode); $this->xml->setXMLDeclaration(""); } function Main(){ $this->create("Writer"); mkdir (CACHE_PATH."/OOotmp"); mkdir (CACHE_PATH."/OOotmp/META-INF"); $this->save(CACHE_PATH."/OOotmp"); } }