diff --git a/docs/kt-phpdoc.ini b/docs/kt-phpdoc.ini index 23adc27..69a8493 100644 --- a/docs/kt-phpdoc.ini +++ b/docs/kt-phpdoc.ini @@ -1,102 +1,102 @@ -;; phpDocumentor parse configuration file -;; -;; This file is designed to cut down on repetitive typing on the command-line or web interface -;; You can copy this file to create a number of configuration files that can be used with the -;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web -;; interface will automatically generate a list of .ini files that can be used. -;; -;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs -;; -;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini -;; -;; Copyright 2002, Greg Beaver -;; -;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them - -[Parse Data] -;; title of all the documentation -;; legal values: any string -title = KnowledgeTree ##VERSION## - -;; parse files that start with a . like .bash_profile -;; legal values: true, false -hidden = true - -;; show elements marked @access private in documentation by setting this to on -;; legal values: on, off -parseprivate = on - -;; parse with javadoc-like description (first sentence is always the short description) -;; legal values: on, off -javadocdesc = off - -;; add any custom @tags separated by commas here -;; legal values: any legal tagname separated by commas. -;customtags = mytag1,mytag2 - -;; This is only used by the XML:DocBook/peardoc2 converter -defaultcategoryname = Documentation - -;; what is the main package? -;; legal values: alphanumeric string plus - and _ -defaultpackagename = KnowledgeTree - -;; output any parsing information? set to on for cron jobs -;; legal values: on -;quiet = on - -;; parse a PEAR-style repository. Do not turn this on if your project does -;; not have a parent directory named "pear" -;; legal values: on/off -;pear = on - -;; where should the documentation be written? -;; legal values: a legal path -;target = /home/cellog/output -target = phpdoc - -;; Which files should be parsed out as special documentation files, such as README, -;; INSTALL and CHANGELOG? This overrides the default files found in -;; phpDocumentor.ini (this file is not a user .ini file, but the global file) -readmeinstallchangelog = README, INSTALL, FAQ, LICENSE, COPYING, CHANGELOG, LICENSE - -;; limit output to the specified packages, even if others are parsed -;; legal values: package names separated by commas -;packageoutput = package1,package2 - -;; comma-separated list of files to parse -;; legal values: paths separated by commas -;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory - -;; comma-separated list of directories to parse -;; legal values: directory paths separated by commas -;directory = /path1,/path2,.,..,subdirectory -;directory = /home/jeichorn/cvs/pear -;directory = /home/cellog/workspace/phpdoc -directory = ../ - -;; template base directory (the equivalent directory of /phpDocumentor) -;templatebase = /path/to/my/templates - -;; directory to find any example files in through @example and {@example} tags -;examplesdir = /path/to/my/templates - -;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore -;; legal values: any wildcard strings separated by commas -;; remember, this pathing is RELATIVE to the top-most directory in your "directory" value -;ignore = path/to/ignore*,*list.php,myfile.php,subdirectory/ -ignore = thirdparty/ - -;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format -;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, -;; HTML:frames:earthli, -;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, -;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli -;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS -;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default -;output=HTML:frames:earthli,HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib,HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de,HTML:frames:DOM/earthli,HTML:frames:DOM/phphtmllib,HTML:frames:phpedit,HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS -output=HTML:frames:DOM/earthli - -;; turn this option on if you want highlighted source code for every file -;; legal values: on/off -sourcecode = on +;; phpDocumentor parse configuration file +;; +;; This file is designed to cut down on repetitive typing on the command-line or web interface +;; You can copy this file to create a number of configuration files that can be used with the +;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web +;; interface will automatically generate a list of .ini files that can be used. +;; +;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs +;; +;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini +;; +;; Copyright 2002, Greg Beaver +;; +;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them + +[Parse Data] +;; title of all the documentation +;; legal values: any string +title = KnowledgeTree ##VERSION## + +;; parse files that start with a . like .bash_profile +;; legal values: true, false +hidden = true + +;; show elements marked @access private in documentation by setting this to on +;; legal values: on, off +parseprivate = on + +;; parse with javadoc-like description (first sentence is always the short description) +;; legal values: on, off +javadocdesc = off + +;; add any custom @tags separated by commas here +;; legal values: any legal tagname separated by commas. +;customtags = mytag1,mytag2 + +;; This is only used by the XML:DocBook/peardoc2 converter +defaultcategoryname = Documentation + +;; what is the main package? +;; legal values: alphanumeric string plus - and _ +defaultpackagename = KnowledgeTree + +;; output any parsing information? set to on for cron jobs +;; legal values: on +;quiet = on + +;; parse a PEAR-style repository. Do not turn this on if your project does +;; not have a parent directory named "pear" +;; legal values: on/off +;pear = on + +;; where should the documentation be written? +;; legal values: a legal path +;target = /home/cellog/output +target = phpdoc + +;; Which files should be parsed out as special documentation files, such as README, +;; INSTALL and CHANGELOG? This overrides the default files found in +;; phpDocumentor.ini (this file is not a user .ini file, but the global file) +readmeinstallchangelog = README, INSTALL, FAQ, LICENSE, COPYING, CHANGELOG, LICENSE + +;; limit output to the specified packages, even if others are parsed +;; legal values: package names separated by commas +;packageoutput = package1,package2 + +;; comma-separated list of files to parse +;; legal values: paths separated by commas +;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory + +;; comma-separated list of directories to parse +;; legal values: directory paths separated by commas +;directory = /path1,/path2,.,..,subdirectory +;directory = /home/jeichorn/cvs/pear +;directory = /home/cellog/workspace/phpdoc +directory = ../ + +;; template base directory (the equivalent directory of /phpDocumentor) +;templatebase = /path/to/my/templates + +;; directory to find any example files in through @example and {@example} tags +;examplesdir = /path/to/my/templates + +;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore +;; legal values: any wildcard strings separated by commas +;; remember, this pathing is RELATIVE to the top-most directory in your "directory" value +;ignore = path/to/ignore*,*list.php,myfile.php,subdirectory/ +ignore = thirdparty/ + +;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format +;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, +;; HTML:frames:earthli, +;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, +;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli +;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS +;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default +;output=HTML:frames:earthli,HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib,HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de,HTML:frames:DOM/earthli,HTML:frames:DOM/phphtmllib,HTML:frames:phpedit,HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS +output=HTML:frames:DOM/earthli + +;; turn this option on if you want highlighted source code for every file +;; legal values: on/off +sourcecode = on diff --git a/kthelp/ktcore/EN/welcomeCommercial.html b/kthelp/ktcore/EN/welcomeCommercial.html index 0d61265..bcc8551 100644 --- a/kthelp/ktcore/EN/welcomeCommercial.html +++ b/kthelp/ktcore/EN/welcomeCommercial.html @@ -1,13 +1,13 @@ - - -Welcome to #APP_NAME# - - -

#APP_NAME# is Document Management Made Simple.


- -

Easily and securely manage your company's document creation, editing, versioning, and sharing - all from a powerful Web interface and Microsoft® Office® and Windows® Explorer® tools.


- -

A subscription to #APP_NAME# provides your organization with product updates, enhanced document management features, and commercial support. Please view your welcome mailer for information on accessing these services.


- - + + +Welcome to #APP_NAME# + + +

#APP_NAME# is Document Management Made Simple.


+ +

Easily and securely manage your company's document creation, editing, versioning, and sharing - all from a powerful Web interface and Microsoft® Office® and Windows® Explorer® tools.


+ +

A subscription to #APP_NAME# provides your organization with product updates, enhanced document management features, and commercial support. Please view your welcome mailer for information on accessing these services.


+ + \ No newline at end of file diff --git a/lib/alert/EmailTemplate.inc.php b/lib/alert/EmailTemplate.inc.php index a23ec35..a976943 100755 --- a/lib/alert/EmailTemplate.inc.php +++ b/lib/alert/EmailTemplate.inc.php @@ -1,58 +1,58 @@ -sTemplate = $sTemplate; - $this->aTemplateData = $aTemplateData; - } - - function getTemplate(){ - return $this->sTemplate; - } - - function setTemplate($sTemplate){ - $this->sTemplate = $sTemplate; - } - - function getTemplateData(){ - return $this->aTemplateData; - } - - function setTemplateData($aTemplateData){ - $this->aTemplateData = $aTemplateData; - } - - /** - * Renders template to a valid email body. - * - * @return HTML email body - */ - function getBody(){ - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate($this->sTemplate); - return "".$oTemplate->render($this->aTemplateData).""; - } - -} - - - - - - - - - - +sTemplate = $sTemplate; + $this->aTemplateData = $aTemplateData; + } + + function getTemplate(){ + return $this->sTemplate; + } + + function setTemplate($sTemplate){ + $this->sTemplate = $sTemplate; + } + + function getTemplateData(){ + return $this->aTemplateData; + } + + function setTemplateData($aTemplateData){ + $this->aTemplateData = $aTemplateData; + } + + /** + * Renders template to a valid email body. + * + * @return HTML email body + */ + function getBody(){ + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate($this->sTemplate); + return "".$oTemplate->render($this->aTemplateData).""; + } + +} + + + + + + + + + + ?> \ No newline at end of file diff --git a/lib/foldermanagement/compressionArchiveUtil.inc.php b/lib/foldermanagement/compressionArchiveUtil.inc.php index eb3c367..d38aaa3 100644 --- a/lib/foldermanagement/compressionArchiveUtil.inc.php +++ b/lib/foldermanagement/compressionArchiveUtil.inc.php @@ -1,305 +1,305 @@ -. - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, - * California 94120-7775, or email info@knowledgetree.com. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU General Public License version 3. - * - * In accordance with Section 7(b) of the GNU General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. - * Contributor( s): ______________________________________ - * - */ - -/** -* Class to create and download a zip file -*/ -class ZipFolder { - - var $sTmpPath = ''; - var $sZipFileName = ''; - var $sZipFile = ''; - var $sPattern = ''; - var $sFolderPattern = ''; - var $aPaths = array(); - var $aReplaceKeys = array(); - var $aReplaceValues = array(); - var $sOutputEncoding = 'UTF-8'; - - /** - * Constructor - * - * @param string $sZipFileName The name of the zip file - gets ignored at the moment. - * @param string $exportCode The code to use if a zip file has already been created. - */ - function ZipFolder($sZipFileName, $exportCode = null) { - $this->oKTConfig =& KTConfig::getSingleton(); - $this->oStorage =& KTStorageManagerUtil::getSingleton(); - - $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); - - $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; - $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; - - // If the export code exists then a temp zip directory has already been created - if(!empty($exportCode)){ - $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); - - if(!empty($aData)){ - $sTmpPath = $aData['dir']; - } - }else { - $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); - $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); - - unlink($sTmpPath); - mkdir($sTmpPath, 0755); - } - - // Hard coding the zip file name. - // It normally uses the folder name but if there are special characters in the name then it doesn't download properly. - $sZipFileName = 'kt_zip'; - - $this->sTmpPath = $sTmpPath; - $this->sZipFileName = $sZipFileName; - $this->aPaths = array(); - - $aReplace = array( - "[" => "[[]", - " " => "[ ]", - "*" => "[*]", - "?" => "[?]", - ); - - $this->aReplaceKeys = array_keys($aReplace); - $this->aReplaceValues = array_values($aReplace); - } - - /** - * Return the full path - * - * @param mixed $oFolderOrDocument May be a Folder or Document - */ - function getFullFolderPath($oFolder) - { - static $sRootFolder = null; - - if (is_null($sRootFolder)) - { - $oRootFolder = Folder::get(1); - $sRootFolder = $oRootFolder->getName(); - } - - $sFullPath = $sRootFolder . '/'; - $sFullPath .= $oFolder->getFullPath(); - - - if (substr($sFullPath,-1) == '/') $sFullPath = substr($sFullPath,0,-1); - return $sFullPath; - } - - - /** - * Add a document to the zip file - */ - function addDocumentToZip($oDocument, $oFolder = null) { - if(empty($oFolder)){ - $oFolder = Folder::get($oDocument->getFolderID()); - } - - $sDocPath = $this->getFullFolderPath($oFolder); - $sDocPath = preg_replace($this->sFolderPattern, '-', $sDocPath); - $sDocPath = $this->_convertEncoding($sDocPath, true); - - - $sDocName = $oDocument->getFileName(); - $sDocName = preg_replace($this->sPattern, '-', $sDocName); - $sDocName = $this->_convertEncoding($sDocName, true); - - $sParentFolder = $this->sTmpPath.'/'.$sDocPath; - $newDir = $this->sTmpPath; - - $aFullPath = split('/', $sDocPath); - foreach ($aFullPath as $dirPart) { - $newDir = sprintf("%s/%s", $newDir, $dirPart); - if (!file_exists($newDir)) { - mkdir($newDir, 0700); - } - } - - $sOrigFile = $this->oStorage->temporaryFile($oDocument); - $sFilename = $sParentFolder.'/'.$sDocName; - copy($sOrigFile, $sFilename); - - $this->aPaths[] = $sDocPath.'/'.$sDocName; - return true; - } - - /** - * Add a folder to the zip file - */ - function addFolderToZip($oFolder) { - $sFolderPath = $this->getFullFolderPath($oFolder) .'/'; - $sFolderPath = preg_replace($this->sFolderPattern, '-', $sFolderPath); - $sFolderPath = $this->_convertEncoding($sFolderPath, true); - - $newDir = $this->sTmpPath; - - $aFullPath = split('/', $sFolderPath); - foreach ($aFullPath as $dirPart) { - $newDir = sprintf("%s/%s", $newDir, $dirPart); - if (!file_exists($newDir)) { - mkdir($newDir, 0700); - } - } - - $this->aPaths[] = $sFolderPath; - return true; - } - - /** - * Zip the temp folder - */ - function createZipFile($bEchoStatus = FALSE) { - if(empty($this->aPaths)){ - return PEAR::raiseError(_kt("No folders or documents found to compress")); - } - - // Set environment language to output character encoding - $loc = $this->sOutputEncoding; - putenv("LANG=$loc"); - putenv("LANGUAGE=$loc"); - $loc = setlocale(LC_ALL, $loc); - - - - $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); - file_put_contents($sManifest, join("\n", $this->aPaths)); - $sZipFile = sprintf("%s/%s.zip", $this->sTmpPath, $this->sZipFileName); - $sZipFile = str_replace('<', '', str_replace('', '', $sZipFile))); - $sZipCommand = KTUtil::findCommand("export/zip", "zip"); - $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); - $sOldPath = getcwd(); - chdir($this->sTmpPath); - - // Note that the popen means that pexec will return a file descriptor - $aOptions = array('popen' => 'r'); - $fh = KTUtil::pexec($aCmd, $aOptions); - - if($bEchoStatus){ - $last_beat = time(); - while(!feof($fh)) { - if ($i % 1000 == 0) { - $this_beat = time(); - if ($last_beat + 1 < $this_beat) { - $last_beat = $this_beat; - print " "; - } - } - $contents = fread($fh, 4096); - if ($contents) { - print nl2br($this->_convertEncoding($contents, false)); - } - $i++; - } - } - pclose($fh); - - // Save the zip file and path into session - $_SESSION['zipcompression'] = KTUtil::arrayGet($_SESSION, 'zipcompression', array()); - $sExportCode = KTUtil::randomString(); - $_SESSION['zipcompression'][$sExportCode] = array( - 'file' => $sZipFile, - 'dir' => $this->sTmpPath, - ); - $_SESSION['zipcompression']['exportcode'] = $sExportCode; - - $this->sZipFile = $sZipFile; - return $sExportCode; - } - - /** - * Download the zip file - */ - function downloadZipFile($exportCode = NULL) { - if(!(isset($exportCode) && !empty($exportCode))) { - $exportCode = KTUtil::arrayGet($_SESSION['zipcompression'], 'exportcode'); - } - - $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); - - if(!empty($aData)){ - $sZipFile = $aData['file']; - $sTmpPath = $aData['dir']; - }else{ - $sZipFile = $this->sZipFile; - $sTmpPath = $this->sTmpPath; - } - - if (!file_exists($sZipFile)) { - return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); - } - - $mimeType = 'application/zip; charset=utf-8;'; - $fileSize = filesize($sZipFile); - $fileName = $this->sZipFileName . '.zip'; - - KTUtil::download($sZipFile, $mimeType, $fileSize, $fileName); - KTUtil::deleteDirectory($sTmpPath); - return true; - } - - /** - * Check that iconv exists and that the selected encoding is supported. - */ - function checkConvertEncoding() { - if(!function_exists("iconv")) { - return PEAR::raiseError(_kt('IConv PHP extension not installed. The zip file compression could not handle output filename encoding conversion !')); - } - $oKTConfig = $this->oKTConfig; - $this->sOutputEncoding = $oKTConfig->get('export/encoding', 'UTF-8'); - - // Test the specified encoding - if(iconv("UTF-8", $this->sOutputEncoding, "") === FALSE) { - return PEAR::raiseError(_kt('Specified output encoding for the zip files compression does not exists !')); - } - return true; - } - - function _convertEncoding($sMystring, $bEncode) { - if (strcasecmp($this->sOutputEncoding, "UTF-8") === 0) { - return $sMystring; - } - if ($bEncode) { - return iconv("UTF-8", $this->sOutputEncoding, $sMystring); - } else { - return iconv($this->sOutputEncoding, "UTF-8", $sMystring); - } - } -} +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +/** +* Class to create and download a zip file +*/ +class ZipFolder { + + var $sTmpPath = ''; + var $sZipFileName = ''; + var $sZipFile = ''; + var $sPattern = ''; + var $sFolderPattern = ''; + var $aPaths = array(); + var $aReplaceKeys = array(); + var $aReplaceValues = array(); + var $sOutputEncoding = 'UTF-8'; + + /** + * Constructor + * + * @param string $sZipFileName The name of the zip file - gets ignored at the moment. + * @param string $exportCode The code to use if a zip file has already been created. + */ + function ZipFolder($sZipFileName, $exportCode = null) { + $this->oKTConfig =& KTConfig::getSingleton(); + $this->oStorage =& KTStorageManagerUtil::getSingleton(); + + $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); + + $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; + $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; + + // If the export code exists then a temp zip directory has already been created + if(!empty($exportCode)){ + $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); + + if(!empty($aData)){ + $sTmpPath = $aData['dir']; + } + }else { + $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); + $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); + + unlink($sTmpPath); + mkdir($sTmpPath, 0755); + } + + // Hard coding the zip file name. + // It normally uses the folder name but if there are special characters in the name then it doesn't download properly. + $sZipFileName = 'kt_zip'; + + $this->sTmpPath = $sTmpPath; + $this->sZipFileName = $sZipFileName; + $this->aPaths = array(); + + $aReplace = array( + "[" => "[[]", + " " => "[ ]", + "*" => "[*]", + "?" => "[?]", + ); + + $this->aReplaceKeys = array_keys($aReplace); + $this->aReplaceValues = array_values($aReplace); + } + + /** + * Return the full path + * + * @param mixed $oFolderOrDocument May be a Folder or Document + */ + function getFullFolderPath($oFolder) + { + static $sRootFolder = null; + + if (is_null($sRootFolder)) + { + $oRootFolder = Folder::get(1); + $sRootFolder = $oRootFolder->getName(); + } + + $sFullPath = $sRootFolder . '/'; + $sFullPath .= $oFolder->getFullPath(); + + + if (substr($sFullPath,-1) == '/') $sFullPath = substr($sFullPath,0,-1); + return $sFullPath; + } + + + /** + * Add a document to the zip file + */ + function addDocumentToZip($oDocument, $oFolder = null) { + if(empty($oFolder)){ + $oFolder = Folder::get($oDocument->getFolderID()); + } + + $sDocPath = $this->getFullFolderPath($oFolder); + $sDocPath = preg_replace($this->sFolderPattern, '-', $sDocPath); + $sDocPath = $this->_convertEncoding($sDocPath, true); + + + $sDocName = $oDocument->getFileName(); + $sDocName = preg_replace($this->sPattern, '-', $sDocName); + $sDocName = $this->_convertEncoding($sDocName, true); + + $sParentFolder = $this->sTmpPath.'/'.$sDocPath; + $newDir = $this->sTmpPath; + + $aFullPath = split('/', $sDocPath); + foreach ($aFullPath as $dirPart) { + $newDir = sprintf("%s/%s", $newDir, $dirPart); + if (!file_exists($newDir)) { + mkdir($newDir, 0700); + } + } + + $sOrigFile = $this->oStorage->temporaryFile($oDocument); + $sFilename = $sParentFolder.'/'.$sDocName; + copy($sOrigFile, $sFilename); + + $this->aPaths[] = $sDocPath.'/'.$sDocName; + return true; + } + + /** + * Add a folder to the zip file + */ + function addFolderToZip($oFolder) { + $sFolderPath = $this->getFullFolderPath($oFolder) .'/'; + $sFolderPath = preg_replace($this->sFolderPattern, '-', $sFolderPath); + $sFolderPath = $this->_convertEncoding($sFolderPath, true); + + $newDir = $this->sTmpPath; + + $aFullPath = split('/', $sFolderPath); + foreach ($aFullPath as $dirPart) { + $newDir = sprintf("%s/%s", $newDir, $dirPart); + if (!file_exists($newDir)) { + mkdir($newDir, 0700); + } + } + + $this->aPaths[] = $sFolderPath; + return true; + } + + /** + * Zip the temp folder + */ + function createZipFile($bEchoStatus = FALSE) { + if(empty($this->aPaths)){ + return PEAR::raiseError(_kt("No folders or documents found to compress")); + } + + // Set environment language to output character encoding + $loc = $this->sOutputEncoding; + putenv("LANG=$loc"); + putenv("LANGUAGE=$loc"); + $loc = setlocale(LC_ALL, $loc); + + + + $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); + file_put_contents($sManifest, join("\n", $this->aPaths)); + $sZipFile = sprintf("%s/%s.zip", $this->sTmpPath, $this->sZipFileName); + $sZipFile = str_replace('<', '', str_replace('', '', $sZipFile))); + $sZipCommand = KTUtil::findCommand("export/zip", "zip"); + $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); + $sOldPath = getcwd(); + chdir($this->sTmpPath); + + // Note that the popen means that pexec will return a file descriptor + $aOptions = array('popen' => 'r'); + $fh = KTUtil::pexec($aCmd, $aOptions); + + if($bEchoStatus){ + $last_beat = time(); + while(!feof($fh)) { + if ($i % 1000 == 0) { + $this_beat = time(); + if ($last_beat + 1 < $this_beat) { + $last_beat = $this_beat; + print " "; + } + } + $contents = fread($fh, 4096); + if ($contents) { + print nl2br($this->_convertEncoding($contents, false)); + } + $i++; + } + } + pclose($fh); + + // Save the zip file and path into session + $_SESSION['zipcompression'] = KTUtil::arrayGet($_SESSION, 'zipcompression', array()); + $sExportCode = KTUtil::randomString(); + $_SESSION['zipcompression'][$sExportCode] = array( + 'file' => $sZipFile, + 'dir' => $this->sTmpPath, + ); + $_SESSION['zipcompression']['exportcode'] = $sExportCode; + + $this->sZipFile = $sZipFile; + return $sExportCode; + } + + /** + * Download the zip file + */ + function downloadZipFile($exportCode = NULL) { + if(!(isset($exportCode) && !empty($exportCode))) { + $exportCode = KTUtil::arrayGet($_SESSION['zipcompression'], 'exportcode'); + } + + $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); + + if(!empty($aData)){ + $sZipFile = $aData['file']; + $sTmpPath = $aData['dir']; + }else{ + $sZipFile = $this->sZipFile; + $sTmpPath = $this->sTmpPath; + } + + if (!file_exists($sZipFile)) { + return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); + } + + $mimeType = 'application/zip; charset=utf-8;'; + $fileSize = filesize($sZipFile); + $fileName = $this->sZipFileName . '.zip'; + + KTUtil::download($sZipFile, $mimeType, $fileSize, $fileName); + KTUtil::deleteDirectory($sTmpPath); + return true; + } + + /** + * Check that iconv exists and that the selected encoding is supported. + */ + function checkConvertEncoding() { + if(!function_exists("iconv")) { + return PEAR::raiseError(_kt('IConv PHP extension not installed. The zip file compression could not handle output filename encoding conversion !')); + } + $oKTConfig = $this->oKTConfig; + $this->sOutputEncoding = $oKTConfig->get('export/encoding', 'UTF-8'); + + // Test the specified encoding + if(iconv("UTF-8", $this->sOutputEncoding, "") === FALSE) { + return PEAR::raiseError(_kt('Specified output encoding for the zip files compression does not exists !')); + } + return true; + } + + function _convertEncoding($sMystring, $bEncode) { + if (strcasecmp($this->sOutputEncoding, "UTF-8") === 0) { + return $sMystring; + } + if ($bEncode) { + return iconv("UTF-8", $this->sOutputEncoding, $sMystring); + } else { + return iconv($this->sOutputEncoding, "UTF-8", $sMystring); + } + } +} ?>