Commit 6fa7e67d34349512d6535901f7b70f375b607d36
1 parent
e0f5b4c1
Line ending updates.
Showing
4 changed files
with
475 additions
and
475 deletions
docs/kt-phpdoc.ini
| 1 | -;; phpDocumentor parse configuration file | ||
| 2 | -;; | ||
| 3 | -;; This file is designed to cut down on repetitive typing on the command-line or web interface | ||
| 4 | -;; You can copy this file to create a number of configuration files that can be used with the | ||
| 5 | -;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web | ||
| 6 | -;; interface will automatically generate a list of .ini files that can be used. | ||
| 7 | -;; | ||
| 8 | -;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs | ||
| 9 | -;; | ||
| 10 | -;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini | ||
| 11 | -;; | ||
| 12 | -;; Copyright 2002, Greg Beaver <cellog@php.net> | ||
| 13 | -;; | ||
| 14 | -;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them | ||
| 15 | - | ||
| 16 | -[Parse Data] | ||
| 17 | -;; title of all the documentation | ||
| 18 | -;; legal values: any string | ||
| 19 | -title = KnowledgeTree ##VERSION## | ||
| 20 | - | ||
| 21 | -;; parse files that start with a . like .bash_profile | ||
| 22 | -;; legal values: true, false | ||
| 23 | -hidden = true | ||
| 24 | - | ||
| 25 | -;; show elements marked @access private in documentation by setting this to on | ||
| 26 | -;; legal values: on, off | ||
| 27 | -parseprivate = on | ||
| 28 | - | ||
| 29 | -;; parse with javadoc-like description (first sentence is always the short description) | ||
| 30 | -;; legal values: on, off | ||
| 31 | -javadocdesc = off | ||
| 32 | - | ||
| 33 | -;; add any custom @tags separated by commas here | ||
| 34 | -;; legal values: any legal tagname separated by commas. | ||
| 35 | -;customtags = mytag1,mytag2 | ||
| 36 | - | ||
| 37 | -;; This is only used by the XML:DocBook/peardoc2 converter | ||
| 38 | -defaultcategoryname = Documentation | ||
| 39 | - | ||
| 40 | -;; what is the main package? | ||
| 41 | -;; legal values: alphanumeric string plus - and _ | ||
| 42 | -defaultpackagename = KnowledgeTree | ||
| 43 | - | ||
| 44 | -;; output any parsing information? set to on for cron jobs | ||
| 45 | -;; legal values: on | ||
| 46 | -;quiet = on | ||
| 47 | - | ||
| 48 | -;; parse a PEAR-style repository. Do not turn this on if your project does | ||
| 49 | -;; not have a parent directory named "pear" | ||
| 50 | -;; legal values: on/off | ||
| 51 | -;pear = on | ||
| 52 | - | ||
| 53 | -;; where should the documentation be written? | ||
| 54 | -;; legal values: a legal path | ||
| 55 | -;target = /home/cellog/output | ||
| 56 | -target = phpdoc | ||
| 57 | - | ||
| 58 | -;; Which files should be parsed out as special documentation files, such as README, | ||
| 59 | -;; INSTALL and CHANGELOG? This overrides the default files found in | ||
| 60 | -;; phpDocumentor.ini (this file is not a user .ini file, but the global file) | ||
| 61 | -readmeinstallchangelog = README, INSTALL, FAQ, LICENSE, COPYING, CHANGELOG, LICENSE | ||
| 62 | - | ||
| 63 | -;; limit output to the specified packages, even if others are parsed | ||
| 64 | -;; legal values: package names separated by commas | ||
| 65 | -;packageoutput = package1,package2 | ||
| 66 | - | ||
| 67 | -;; comma-separated list of files to parse | ||
| 68 | -;; legal values: paths separated by commas | ||
| 69 | -;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory | ||
| 70 | - | ||
| 71 | -;; comma-separated list of directories to parse | ||
| 72 | -;; legal values: directory paths separated by commas | ||
| 73 | -;directory = /path1,/path2,.,..,subdirectory | ||
| 74 | -;directory = /home/jeichorn/cvs/pear | ||
| 75 | -;directory = /home/cellog/workspace/phpdoc | ||
| 76 | -directory = ../ | ||
| 77 | - | ||
| 78 | -;; template base directory (the equivalent directory of <installdir>/phpDocumentor) | ||
| 79 | -;templatebase = /path/to/my/templates | ||
| 80 | - | ||
| 81 | -;; directory to find any example files in through @example and {@example} tags | ||
| 82 | -;examplesdir = /path/to/my/templates | ||
| 83 | - | ||
| 84 | -;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore | ||
| 85 | -;; legal values: any wildcard strings separated by commas | ||
| 86 | -;; remember, this pathing is RELATIVE to the top-most directory in your "directory" value | ||
| 87 | -;ignore = path/to/ignore*,*list.php,myfile.php,subdirectory/ | ||
| 88 | -ignore = thirdparty/ | ||
| 89 | - | ||
| 90 | -;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format | ||
| 91 | -;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, | ||
| 92 | -;; HTML:frames:earthli, | ||
| 93 | -;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, | ||
| 94 | -;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli | ||
| 95 | -;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS | ||
| 96 | -;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default | ||
| 97 | -;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 | ||
| 98 | -output=HTML:frames:DOM/earthli | ||
| 99 | - | ||
| 100 | -;; turn this option on if you want highlighted source code for every file | ||
| 101 | -;; legal values: on/off | ||
| 102 | -sourcecode = on | 1 | +;; phpDocumentor parse configuration file |
| 2 | +;; | ||
| 3 | +;; This file is designed to cut down on repetitive typing on the command-line or web interface | ||
| 4 | +;; You can copy this file to create a number of configuration files that can be used with the | ||
| 5 | +;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web | ||
| 6 | +;; interface will automatically generate a list of .ini files that can be used. | ||
| 7 | +;; | ||
| 8 | +;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs | ||
| 9 | +;; | ||
| 10 | +;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini | ||
| 11 | +;; | ||
| 12 | +;; Copyright 2002, Greg Beaver <cellog@php.net> | ||
| 13 | +;; | ||
| 14 | +;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them | ||
| 15 | + | ||
| 16 | +[Parse Data] | ||
| 17 | +;; title of all the documentation | ||
| 18 | +;; legal values: any string | ||
| 19 | +title = KnowledgeTree ##VERSION## | ||
| 20 | + | ||
| 21 | +;; parse files that start with a . like .bash_profile | ||
| 22 | +;; legal values: true, false | ||
| 23 | +hidden = true | ||
| 24 | + | ||
| 25 | +;; show elements marked @access private in documentation by setting this to on | ||
| 26 | +;; legal values: on, off | ||
| 27 | +parseprivate = on | ||
| 28 | + | ||
| 29 | +;; parse with javadoc-like description (first sentence is always the short description) | ||
| 30 | +;; legal values: on, off | ||
| 31 | +javadocdesc = off | ||
| 32 | + | ||
| 33 | +;; add any custom @tags separated by commas here | ||
| 34 | +;; legal values: any legal tagname separated by commas. | ||
| 35 | +;customtags = mytag1,mytag2 | ||
| 36 | + | ||
| 37 | +;; This is only used by the XML:DocBook/peardoc2 converter | ||
| 38 | +defaultcategoryname = Documentation | ||
| 39 | + | ||
| 40 | +;; what is the main package? | ||
| 41 | +;; legal values: alphanumeric string plus - and _ | ||
| 42 | +defaultpackagename = KnowledgeTree | ||
| 43 | + | ||
| 44 | +;; output any parsing information? set to on for cron jobs | ||
| 45 | +;; legal values: on | ||
| 46 | +;quiet = on | ||
| 47 | + | ||
| 48 | +;; parse a PEAR-style repository. Do not turn this on if your project does | ||
| 49 | +;; not have a parent directory named "pear" | ||
| 50 | +;; legal values: on/off | ||
| 51 | +;pear = on | ||
| 52 | + | ||
| 53 | +;; where should the documentation be written? | ||
| 54 | +;; legal values: a legal path | ||
| 55 | +;target = /home/cellog/output | ||
| 56 | +target = phpdoc | ||
| 57 | + | ||
| 58 | +;; Which files should be parsed out as special documentation files, such as README, | ||
| 59 | +;; INSTALL and CHANGELOG? This overrides the default files found in | ||
| 60 | +;; phpDocumentor.ini (this file is not a user .ini file, but the global file) | ||
| 61 | +readmeinstallchangelog = README, INSTALL, FAQ, LICENSE, COPYING, CHANGELOG, LICENSE | ||
| 62 | + | ||
| 63 | +;; limit output to the specified packages, even if others are parsed | ||
| 64 | +;; legal values: package names separated by commas | ||
| 65 | +;packageoutput = package1,package2 | ||
| 66 | + | ||
| 67 | +;; comma-separated list of files to parse | ||
| 68 | +;; legal values: paths separated by commas | ||
| 69 | +;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory | ||
| 70 | + | ||
| 71 | +;; comma-separated list of directories to parse | ||
| 72 | +;; legal values: directory paths separated by commas | ||
| 73 | +;directory = /path1,/path2,.,..,subdirectory | ||
| 74 | +;directory = /home/jeichorn/cvs/pear | ||
| 75 | +;directory = /home/cellog/workspace/phpdoc | ||
| 76 | +directory = ../ | ||
| 77 | + | ||
| 78 | +;; template base directory (the equivalent directory of <installdir>/phpDocumentor) | ||
| 79 | +;templatebase = /path/to/my/templates | ||
| 80 | + | ||
| 81 | +;; directory to find any example files in through @example and {@example} tags | ||
| 82 | +;examplesdir = /path/to/my/templates | ||
| 83 | + | ||
| 84 | +;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore | ||
| 85 | +;; legal values: any wildcard strings separated by commas | ||
| 86 | +;; remember, this pathing is RELATIVE to the top-most directory in your "directory" value | ||
| 87 | +;ignore = path/to/ignore*,*list.php,myfile.php,subdirectory/ | ||
| 88 | +ignore = thirdparty/ | ||
| 89 | + | ||
| 90 | +;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format | ||
| 91 | +;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, | ||
| 92 | +;; HTML:frames:earthli, | ||
| 93 | +;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, | ||
| 94 | +;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli | ||
| 95 | +;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS | ||
| 96 | +;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default | ||
| 97 | +;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 | ||
| 98 | +output=HTML:frames:DOM/earthli | ||
| 99 | + | ||
| 100 | +;; turn this option on if you want highlighted source code for every file | ||
| 101 | +;; legal values: on/off | ||
| 102 | +sourcecode = on |
kthelp/ktcore/EN/welcomeCommercial.html
| 1 | -<html> | ||
| 2 | -<head> | ||
| 3 | -<title>Welcome to #APP_NAME#</title> | ||
| 4 | -</head> | ||
| 5 | -<body> | ||
| 6 | -<p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p> <br> | ||
| 7 | - | ||
| 8 | -<p class="descriptiveText">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.</p> <br> | ||
| 9 | - | ||
| 10 | -<p class="descriptiveText">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.</p> <br> | ||
| 11 | - | ||
| 12 | -</body> | 1 | +<html> |
| 2 | +<head> | ||
| 3 | +<title>Welcome to #APP_NAME#</title> | ||
| 4 | +</head> | ||
| 5 | +<body> | ||
| 6 | +<p class="descriptiveText"><b>#APP_NAME# is Document Management Made Simple.</b></p> <br> | ||
| 7 | + | ||
| 8 | +<p class="descriptiveText">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.</p> <br> | ||
| 9 | + | ||
| 10 | +<p class="descriptiveText">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.</p> <br> | ||
| 11 | + | ||
| 12 | +</body> | ||
| 13 | </html> | 13 | </html> |
| 14 | \ No newline at end of file | 14 | \ No newline at end of file |
lib/alert/EmailTemplate.inc.php
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 4 | - | ||
| 5 | -/** | ||
| 6 | - * Represents an email template | ||
| 7 | - * | ||
| 8 | - */ | ||
| 9 | -class EmailTemplate{ | ||
| 10 | - /** template */ | ||
| 11 | - var $sTemplate; | ||
| 12 | - /** template data */ | ||
| 13 | - var $aTemplateData; | ||
| 14 | - | ||
| 15 | - function EmailTemplate($sTemplate, $aTemplateData = array()){ | ||
| 16 | - $this->sTemplate = $sTemplate; | ||
| 17 | - $this->aTemplateData = $aTemplateData; | ||
| 18 | - } | ||
| 19 | - | ||
| 20 | - function getTemplate(){ | ||
| 21 | - return $this->sTemplate; | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | - function setTemplate($sTemplate){ | ||
| 25 | - $this->sTemplate = $sTemplate; | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - function getTemplateData(){ | ||
| 29 | - return $this->aTemplateData; | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - function setTemplateData($aTemplateData){ | ||
| 33 | - $this->aTemplateData = $aTemplateData; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * Renders template to a valid email body. | ||
| 38 | - * | ||
| 39 | - * @return HTML email body | ||
| 40 | - */ | ||
| 41 | - function getBody(){ | ||
| 42 | - $oTemplating =& KTTemplating::getSingleton(); | ||
| 43 | - $oTemplate = $oTemplating->loadTemplate($this->sTemplate); | ||
| 44 | - return "<html><body>".$oTemplate->render($this->aTemplateData)."</body></html>"; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | -} | ||
| 48 | - | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | 1 | +<?php |
| 2 | + | ||
| 3 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Represents an email template | ||
| 7 | + * | ||
| 8 | + */ | ||
| 9 | +class EmailTemplate{ | ||
| 10 | + /** template */ | ||
| 11 | + var $sTemplate; | ||
| 12 | + /** template data */ | ||
| 13 | + var $aTemplateData; | ||
| 14 | + | ||
| 15 | + function EmailTemplate($sTemplate, $aTemplateData = array()){ | ||
| 16 | + $this->sTemplate = $sTemplate; | ||
| 17 | + $this->aTemplateData = $aTemplateData; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + function getTemplate(){ | ||
| 21 | + return $this->sTemplate; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + function setTemplate($sTemplate){ | ||
| 25 | + $this->sTemplate = $sTemplate; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + function getTemplateData(){ | ||
| 29 | + return $this->aTemplateData; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + function setTemplateData($aTemplateData){ | ||
| 33 | + $this->aTemplateData = $aTemplateData; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Renders template to a valid email body. | ||
| 38 | + * | ||
| 39 | + * @return HTML email body | ||
| 40 | + */ | ||
| 41 | + function getBody(){ | ||
| 42 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 43 | + $oTemplate = $oTemplating->loadTemplate($this->sTemplate); | ||
| 44 | + return "<html><body>".$oTemplate->render($this->aTemplateData)."</body></html>"; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + | ||
| 58 | ?> | 58 | ?> |
| 59 | \ No newline at end of file | 59 | \ No newline at end of file |
lib/foldermanagement/compressionArchiveUtil.inc.php
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id: | ||
| 4 | - * | ||
| 5 | - * KnowledgeTree Community Edition | ||
| 6 | - * Document Management Made Simple | ||
| 7 | - * Copyright (C) 2008, 2009 KnowledgeTree Inc. | ||
| 8 | - * Portions copyright The Jam Warehouse Software (Pty) Limited | ||
| 9 | - * | ||
| 10 | - * This program is free software; you can redistribute it and/or modify it under | ||
| 11 | - * the terms of the GNU General Public License version 3 as published by the | ||
| 12 | - * Free Software Foundation. | ||
| 13 | - * | ||
| 14 | - * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | - * details. | ||
| 18 | - * | ||
| 19 | - * You should have received a copy of the GNU General Public License | ||
| 20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | - * California 94120-7775, or email info@knowledgetree.com. | ||
| 24 | - * | ||
| 25 | - * The interactive user interfaces in modified source and object code versions | ||
| 26 | - * of this program must display Appropriate Legal Notices, as required under | ||
| 27 | - * Section 5 of the GNU General Public License version 3. | ||
| 28 | - * | ||
| 29 | - * In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | - * these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | - * copyright notice. | ||
| 35 | - * Contributor( s): ______________________________________ | ||
| 36 | - * | ||
| 37 | - */ | ||
| 38 | - | ||
| 39 | -/** | ||
| 40 | -* Class to create and download a zip file | ||
| 41 | -*/ | ||
| 42 | -class ZipFolder { | ||
| 43 | - | ||
| 44 | - var $sTmpPath = ''; | ||
| 45 | - var $sZipFileName = ''; | ||
| 46 | - var $sZipFile = ''; | ||
| 47 | - var $sPattern = ''; | ||
| 48 | - var $sFolderPattern = ''; | ||
| 49 | - var $aPaths = array(); | ||
| 50 | - var $aReplaceKeys = array(); | ||
| 51 | - var $aReplaceValues = array(); | ||
| 52 | - var $sOutputEncoding = 'UTF-8'; | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * Constructor | ||
| 56 | - * | ||
| 57 | - * @param string $sZipFileName The name of the zip file - gets ignored at the moment. | ||
| 58 | - * @param string $exportCode The code to use if a zip file has already been created. | ||
| 59 | - */ | ||
| 60 | - function ZipFolder($sZipFileName, $exportCode = null) { | ||
| 61 | - $this->oKTConfig =& KTConfig::getSingleton(); | ||
| 62 | - $this->oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 63 | - | ||
| 64 | - $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); | ||
| 65 | - | ||
| 66 | - $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 67 | - $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 68 | - | ||
| 69 | - // If the export code exists then a temp zip directory has already been created | ||
| 70 | - if(!empty($exportCode)){ | ||
| 71 | - $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); | ||
| 72 | - | ||
| 73 | - if(!empty($aData)){ | ||
| 74 | - $sTmpPath = $aData['dir']; | ||
| 75 | - } | ||
| 76 | - }else { | ||
| 77 | - $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); | ||
| 78 | - $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); | ||
| 79 | - | ||
| 80 | - unlink($sTmpPath); | ||
| 81 | - mkdir($sTmpPath, 0755); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - // Hard coding the zip file name. | ||
| 85 | - // It normally uses the folder name but if there are special characters in the name then it doesn't download properly. | ||
| 86 | - $sZipFileName = 'kt_zip'; | ||
| 87 | - | ||
| 88 | - $this->sTmpPath = $sTmpPath; | ||
| 89 | - $this->sZipFileName = $sZipFileName; | ||
| 90 | - $this->aPaths = array(); | ||
| 91 | - | ||
| 92 | - $aReplace = array( | ||
| 93 | - "[" => "[[]", | ||
| 94 | - " " => "[ ]", | ||
| 95 | - "*" => "[*]", | ||
| 96 | - "?" => "[?]", | ||
| 97 | - ); | ||
| 98 | - | ||
| 99 | - $this->aReplaceKeys = array_keys($aReplace); | ||
| 100 | - $this->aReplaceValues = array_values($aReplace); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * Return the full path | ||
| 105 | - * | ||
| 106 | - * @param mixed $oFolderOrDocument May be a Folder or Document | ||
| 107 | - */ | ||
| 108 | - function getFullFolderPath($oFolder) | ||
| 109 | - { | ||
| 110 | - static $sRootFolder = null; | ||
| 111 | - | ||
| 112 | - if (is_null($sRootFolder)) | ||
| 113 | - { | ||
| 114 | - $oRootFolder = Folder::get(1); | ||
| 115 | - $sRootFolder = $oRootFolder->getName(); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - $sFullPath = $sRootFolder . '/'; | ||
| 119 | - $sFullPath .= $oFolder->getFullPath(); | ||
| 120 | - | ||
| 121 | - | ||
| 122 | - if (substr($sFullPath,-1) == '/') $sFullPath = substr($sFullPath,0,-1); | ||
| 123 | - return $sFullPath; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - /** | ||
| 128 | - * Add a document to the zip file | ||
| 129 | - */ | ||
| 130 | - function addDocumentToZip($oDocument, $oFolder = null) { | ||
| 131 | - if(empty($oFolder)){ | ||
| 132 | - $oFolder = Folder::get($oDocument->getFolderID()); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - $sDocPath = $this->getFullFolderPath($oFolder); | ||
| 136 | - $sDocPath = preg_replace($this->sFolderPattern, '-', $sDocPath); | ||
| 137 | - $sDocPath = $this->_convertEncoding($sDocPath, true); | ||
| 138 | - | ||
| 139 | - | ||
| 140 | - $sDocName = $oDocument->getFileName(); | ||
| 141 | - $sDocName = preg_replace($this->sPattern, '-', $sDocName); | ||
| 142 | - $sDocName = $this->_convertEncoding($sDocName, true); | ||
| 143 | - | ||
| 144 | - $sParentFolder = $this->sTmpPath.'/'.$sDocPath; | ||
| 145 | - $newDir = $this->sTmpPath; | ||
| 146 | - | ||
| 147 | - $aFullPath = split('/', $sDocPath); | ||
| 148 | - foreach ($aFullPath as $dirPart) { | ||
| 149 | - $newDir = sprintf("%s/%s", $newDir, $dirPart); | ||
| 150 | - if (!file_exists($newDir)) { | ||
| 151 | - mkdir($newDir, 0700); | ||
| 152 | - } | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - $sOrigFile = $this->oStorage->temporaryFile($oDocument); | ||
| 156 | - $sFilename = $sParentFolder.'/'.$sDocName; | ||
| 157 | - copy($sOrigFile, $sFilename); | ||
| 158 | - | ||
| 159 | - $this->aPaths[] = $sDocPath.'/'.$sDocName; | ||
| 160 | - return true; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - /** | ||
| 164 | - * Add a folder to the zip file | ||
| 165 | - */ | ||
| 166 | - function addFolderToZip($oFolder) { | ||
| 167 | - $sFolderPath = $this->getFullFolderPath($oFolder) .'/'; | ||
| 168 | - $sFolderPath = preg_replace($this->sFolderPattern, '-', $sFolderPath); | ||
| 169 | - $sFolderPath = $this->_convertEncoding($sFolderPath, true); | ||
| 170 | - | ||
| 171 | - $newDir = $this->sTmpPath; | ||
| 172 | - | ||
| 173 | - $aFullPath = split('/', $sFolderPath); | ||
| 174 | - foreach ($aFullPath as $dirPart) { | ||
| 175 | - $newDir = sprintf("%s/%s", $newDir, $dirPart); | ||
| 176 | - if (!file_exists($newDir)) { | ||
| 177 | - mkdir($newDir, 0700); | ||
| 178 | - } | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - $this->aPaths[] = $sFolderPath; | ||
| 182 | - return true; | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - /** | ||
| 186 | - * Zip the temp folder | ||
| 187 | - */ | ||
| 188 | - function createZipFile($bEchoStatus = FALSE) { | ||
| 189 | - if(empty($this->aPaths)){ | ||
| 190 | - return PEAR::raiseError(_kt("No folders or documents found to compress")); | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - // Set environment language to output character encoding | ||
| 194 | - $loc = $this->sOutputEncoding; | ||
| 195 | - putenv("LANG=$loc"); | ||
| 196 | - putenv("LANGUAGE=$loc"); | ||
| 197 | - $loc = setlocale(LC_ALL, $loc); | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - | ||
| 201 | - $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); | ||
| 202 | - file_put_contents($sManifest, join("\n", $this->aPaths)); | ||
| 203 | - $sZipFile = sprintf("%s/%s.zip", $this->sTmpPath, $this->sZipFileName); | ||
| 204 | - $sZipFile = str_replace('<', '', str_replace('</', '', str_replace('>', '', $sZipFile))); | ||
| 205 | - $sZipCommand = KTUtil::findCommand("export/zip", "zip"); | ||
| 206 | - $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); | ||
| 207 | - $sOldPath = getcwd(); | ||
| 208 | - chdir($this->sTmpPath); | ||
| 209 | - | ||
| 210 | - // Note that the popen means that pexec will return a file descriptor | ||
| 211 | - $aOptions = array('popen' => 'r'); | ||
| 212 | - $fh = KTUtil::pexec($aCmd, $aOptions); | ||
| 213 | - | ||
| 214 | - if($bEchoStatus){ | ||
| 215 | - $last_beat = time(); | ||
| 216 | - while(!feof($fh)) { | ||
| 217 | - if ($i % 1000 == 0) { | ||
| 218 | - $this_beat = time(); | ||
| 219 | - if ($last_beat + 1 < $this_beat) { | ||
| 220 | - $last_beat = $this_beat; | ||
| 221 | - print " "; | ||
| 222 | - } | ||
| 223 | - } | ||
| 224 | - $contents = fread($fh, 4096); | ||
| 225 | - if ($contents) { | ||
| 226 | - print nl2br($this->_convertEncoding($contents, false)); | ||
| 227 | - } | ||
| 228 | - $i++; | ||
| 229 | - } | ||
| 230 | - } | ||
| 231 | - pclose($fh); | ||
| 232 | - | ||
| 233 | - // Save the zip file and path into session | ||
| 234 | - $_SESSION['zipcompression'] = KTUtil::arrayGet($_SESSION, 'zipcompression', array()); | ||
| 235 | - $sExportCode = KTUtil::randomString(); | ||
| 236 | - $_SESSION['zipcompression'][$sExportCode] = array( | ||
| 237 | - 'file' => $sZipFile, | ||
| 238 | - 'dir' => $this->sTmpPath, | ||
| 239 | - ); | ||
| 240 | - $_SESSION['zipcompression']['exportcode'] = $sExportCode; | ||
| 241 | - | ||
| 242 | - $this->sZipFile = $sZipFile; | ||
| 243 | - return $sExportCode; | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - /** | ||
| 247 | - * Download the zip file | ||
| 248 | - */ | ||
| 249 | - function downloadZipFile($exportCode = NULL) { | ||
| 250 | - if(!(isset($exportCode) && !empty($exportCode))) { | ||
| 251 | - $exportCode = KTUtil::arrayGet($_SESSION['zipcompression'], 'exportcode'); | ||
| 252 | - } | ||
| 253 | - | ||
| 254 | - $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); | ||
| 255 | - | ||
| 256 | - if(!empty($aData)){ | ||
| 257 | - $sZipFile = $aData['file']; | ||
| 258 | - $sTmpPath = $aData['dir']; | ||
| 259 | - }else{ | ||
| 260 | - $sZipFile = $this->sZipFile; | ||
| 261 | - $sTmpPath = $this->sTmpPath; | ||
| 262 | - } | ||
| 263 | - | ||
| 264 | - if (!file_exists($sZipFile)) { | ||
| 265 | - return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - $mimeType = 'application/zip; charset=utf-8;'; | ||
| 269 | - $fileSize = filesize($sZipFile); | ||
| 270 | - $fileName = $this->sZipFileName . '.zip'; | ||
| 271 | - | ||
| 272 | - KTUtil::download($sZipFile, $mimeType, $fileSize, $fileName); | ||
| 273 | - KTUtil::deleteDirectory($sTmpPath); | ||
| 274 | - return true; | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | - /** | ||
| 278 | - * Check that iconv exists and that the selected encoding is supported. | ||
| 279 | - */ | ||
| 280 | - function checkConvertEncoding() { | ||
| 281 | - if(!function_exists("iconv")) { | ||
| 282 | - return PEAR::raiseError(_kt('IConv PHP extension not installed. The zip file compression could not handle output filename encoding conversion !')); | ||
| 283 | - } | ||
| 284 | - $oKTConfig = $this->oKTConfig; | ||
| 285 | - $this->sOutputEncoding = $oKTConfig->get('export/encoding', 'UTF-8'); | ||
| 286 | - | ||
| 287 | - // Test the specified encoding | ||
| 288 | - if(iconv("UTF-8", $this->sOutputEncoding, "") === FALSE) { | ||
| 289 | - return PEAR::raiseError(_kt('Specified output encoding for the zip files compression does not exists !')); | ||
| 290 | - } | ||
| 291 | - return true; | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | - function _convertEncoding($sMystring, $bEncode) { | ||
| 295 | - if (strcasecmp($this->sOutputEncoding, "UTF-8") === 0) { | ||
| 296 | - return $sMystring; | ||
| 297 | - } | ||
| 298 | - if ($bEncode) { | ||
| 299 | - return iconv("UTF-8", $this->sOutputEncoding, $sMystring); | ||
| 300 | - } else { | ||
| 301 | - return iconv($this->sOutputEncoding, "UTF-8", $sMystring); | ||
| 302 | - } | ||
| 303 | - } | ||
| 304 | -} | 1 | +<?php |
| 2 | +/** | ||
| 3 | + * $Id: | ||
| 4 | + * | ||
| 5 | + * KnowledgeTree Community Edition | ||
| 6 | + * Document Management Made Simple | ||
| 7 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | ||
| 8 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | ||
| 9 | + * | ||
| 10 | + * This program is free software; you can redistribute it and/or modify it under | ||
| 11 | + * the terms of the GNU General Public License version 3 as published by the | ||
| 12 | + * Free Software Foundation. | ||
| 13 | + * | ||
| 14 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | + * details. | ||
| 18 | + * | ||
| 19 | + * You should have received a copy of the GNU General Public License | ||
| 20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | + * | ||
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | + * California 94120-7775, or email info@knowledgetree.com. | ||
| 24 | + * | ||
| 25 | + * The interactive user interfaces in modified source and object code versions | ||
| 26 | + * of this program must display Appropriate Legal Notices, as required under | ||
| 27 | + * Section 5 of the GNU General Public License version 3. | ||
| 28 | + * | ||
| 29 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | + * these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | + * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | + * copyright notice. | ||
| 35 | + * Contributor( s): ______________________________________ | ||
| 36 | + * | ||
| 37 | + */ | ||
| 38 | + | ||
| 39 | +/** | ||
| 40 | +* Class to create and download a zip file | ||
| 41 | +*/ | ||
| 42 | +class ZipFolder { | ||
| 43 | + | ||
| 44 | + var $sTmpPath = ''; | ||
| 45 | + var $sZipFileName = ''; | ||
| 46 | + var $sZipFile = ''; | ||
| 47 | + var $sPattern = ''; | ||
| 48 | + var $sFolderPattern = ''; | ||
| 49 | + var $aPaths = array(); | ||
| 50 | + var $aReplaceKeys = array(); | ||
| 51 | + var $aReplaceValues = array(); | ||
| 52 | + var $sOutputEncoding = 'UTF-8'; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Constructor | ||
| 56 | + * | ||
| 57 | + * @param string $sZipFileName The name of the zip file - gets ignored at the moment. | ||
| 58 | + * @param string $exportCode The code to use if a zip file has already been created. | ||
| 59 | + */ | ||
| 60 | + function ZipFolder($sZipFileName, $exportCode = null) { | ||
| 61 | + $this->oKTConfig =& KTConfig::getSingleton(); | ||
| 62 | + $this->oStorage =& KTStorageManagerUtil::getSingleton(); | ||
| 63 | + | ||
| 64 | + $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); | ||
| 65 | + | ||
| 66 | + $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 67 | + $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 68 | + | ||
| 69 | + // If the export code exists then a temp zip directory has already been created | ||
| 70 | + if(!empty($exportCode)){ | ||
| 71 | + $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); | ||
| 72 | + | ||
| 73 | + if(!empty($aData)){ | ||
| 74 | + $sTmpPath = $aData['dir']; | ||
| 75 | + } | ||
| 76 | + }else { | ||
| 77 | + $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); | ||
| 78 | + $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); | ||
| 79 | + | ||
| 80 | + unlink($sTmpPath); | ||
| 81 | + mkdir($sTmpPath, 0755); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + // Hard coding the zip file name. | ||
| 85 | + // It normally uses the folder name but if there are special characters in the name then it doesn't download properly. | ||
| 86 | + $sZipFileName = 'kt_zip'; | ||
| 87 | + | ||
| 88 | + $this->sTmpPath = $sTmpPath; | ||
| 89 | + $this->sZipFileName = $sZipFileName; | ||
| 90 | + $this->aPaths = array(); | ||
| 91 | + | ||
| 92 | + $aReplace = array( | ||
| 93 | + "[" => "[[]", | ||
| 94 | + " " => "[ ]", | ||
| 95 | + "*" => "[*]", | ||
| 96 | + "?" => "[?]", | ||
| 97 | + ); | ||
| 98 | + | ||
| 99 | + $this->aReplaceKeys = array_keys($aReplace); | ||
| 100 | + $this->aReplaceValues = array_values($aReplace); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * Return the full path | ||
| 105 | + * | ||
| 106 | + * @param mixed $oFolderOrDocument May be a Folder or Document | ||
| 107 | + */ | ||
| 108 | + function getFullFolderPath($oFolder) | ||
| 109 | + { | ||
| 110 | + static $sRootFolder = null; | ||
| 111 | + | ||
| 112 | + if (is_null($sRootFolder)) | ||
| 113 | + { | ||
| 114 | + $oRootFolder = Folder::get(1); | ||
| 115 | + $sRootFolder = $oRootFolder->getName(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + $sFullPath = $sRootFolder . '/'; | ||
| 119 | + $sFullPath .= $oFolder->getFullPath(); | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + if (substr($sFullPath,-1) == '/') $sFullPath = substr($sFullPath,0,-1); | ||
| 123 | + return $sFullPath; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * Add a document to the zip file | ||
| 129 | + */ | ||
| 130 | + function addDocumentToZip($oDocument, $oFolder = null) { | ||
| 131 | + if(empty($oFolder)){ | ||
| 132 | + $oFolder = Folder::get($oDocument->getFolderID()); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + $sDocPath = $this->getFullFolderPath($oFolder); | ||
| 136 | + $sDocPath = preg_replace($this->sFolderPattern, '-', $sDocPath); | ||
| 137 | + $sDocPath = $this->_convertEncoding($sDocPath, true); | ||
| 138 | + | ||
| 139 | + | ||
| 140 | + $sDocName = $oDocument->getFileName(); | ||
| 141 | + $sDocName = preg_replace($this->sPattern, '-', $sDocName); | ||
| 142 | + $sDocName = $this->_convertEncoding($sDocName, true); | ||
| 143 | + | ||
| 144 | + $sParentFolder = $this->sTmpPath.'/'.$sDocPath; | ||
| 145 | + $newDir = $this->sTmpPath; | ||
| 146 | + | ||
| 147 | + $aFullPath = split('/', $sDocPath); | ||
| 148 | + foreach ($aFullPath as $dirPart) { | ||
| 149 | + $newDir = sprintf("%s/%s", $newDir, $dirPart); | ||
| 150 | + if (!file_exists($newDir)) { | ||
| 151 | + mkdir($newDir, 0700); | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + $sOrigFile = $this->oStorage->temporaryFile($oDocument); | ||
| 156 | + $sFilename = $sParentFolder.'/'.$sDocName; | ||
| 157 | + copy($sOrigFile, $sFilename); | ||
| 158 | + | ||
| 159 | + $this->aPaths[] = $sDocPath.'/'.$sDocName; | ||
| 160 | + return true; | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * Add a folder to the zip file | ||
| 165 | + */ | ||
| 166 | + function addFolderToZip($oFolder) { | ||
| 167 | + $sFolderPath = $this->getFullFolderPath($oFolder) .'/'; | ||
| 168 | + $sFolderPath = preg_replace($this->sFolderPattern, '-', $sFolderPath); | ||
| 169 | + $sFolderPath = $this->_convertEncoding($sFolderPath, true); | ||
| 170 | + | ||
| 171 | + $newDir = $this->sTmpPath; | ||
| 172 | + | ||
| 173 | + $aFullPath = split('/', $sFolderPath); | ||
| 174 | + foreach ($aFullPath as $dirPart) { | ||
| 175 | + $newDir = sprintf("%s/%s", $newDir, $dirPart); | ||
| 176 | + if (!file_exists($newDir)) { | ||
| 177 | + mkdir($newDir, 0700); | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + $this->aPaths[] = $sFolderPath; | ||
| 182 | + return true; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + /** | ||
| 186 | + * Zip the temp folder | ||
| 187 | + */ | ||
| 188 | + function createZipFile($bEchoStatus = FALSE) { | ||
| 189 | + if(empty($this->aPaths)){ | ||
| 190 | + return PEAR::raiseError(_kt("No folders or documents found to compress")); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + // Set environment language to output character encoding | ||
| 194 | + $loc = $this->sOutputEncoding; | ||
| 195 | + putenv("LANG=$loc"); | ||
| 196 | + putenv("LANGUAGE=$loc"); | ||
| 197 | + $loc = setlocale(LC_ALL, $loc); | ||
| 198 | + | ||
| 199 | + | ||
| 200 | + | ||
| 201 | + $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); | ||
| 202 | + file_put_contents($sManifest, join("\n", $this->aPaths)); | ||
| 203 | + $sZipFile = sprintf("%s/%s.zip", $this->sTmpPath, $this->sZipFileName); | ||
| 204 | + $sZipFile = str_replace('<', '', str_replace('</', '', str_replace('>', '', $sZipFile))); | ||
| 205 | + $sZipCommand = KTUtil::findCommand("export/zip", "zip"); | ||
| 206 | + $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); | ||
| 207 | + $sOldPath = getcwd(); | ||
| 208 | + chdir($this->sTmpPath); | ||
| 209 | + | ||
| 210 | + // Note that the popen means that pexec will return a file descriptor | ||
| 211 | + $aOptions = array('popen' => 'r'); | ||
| 212 | + $fh = KTUtil::pexec($aCmd, $aOptions); | ||
| 213 | + | ||
| 214 | + if($bEchoStatus){ | ||
| 215 | + $last_beat = time(); | ||
| 216 | + while(!feof($fh)) { | ||
| 217 | + if ($i % 1000 == 0) { | ||
| 218 | + $this_beat = time(); | ||
| 219 | + if ($last_beat + 1 < $this_beat) { | ||
| 220 | + $last_beat = $this_beat; | ||
| 221 | + print " "; | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + $contents = fread($fh, 4096); | ||
| 225 | + if ($contents) { | ||
| 226 | + print nl2br($this->_convertEncoding($contents, false)); | ||
| 227 | + } | ||
| 228 | + $i++; | ||
| 229 | + } | ||
| 230 | + } | ||
| 231 | + pclose($fh); | ||
| 232 | + | ||
| 233 | + // Save the zip file and path into session | ||
| 234 | + $_SESSION['zipcompression'] = KTUtil::arrayGet($_SESSION, 'zipcompression', array()); | ||
| 235 | + $sExportCode = KTUtil::randomString(); | ||
| 236 | + $_SESSION['zipcompression'][$sExportCode] = array( | ||
| 237 | + 'file' => $sZipFile, | ||
| 238 | + 'dir' => $this->sTmpPath, | ||
| 239 | + ); | ||
| 240 | + $_SESSION['zipcompression']['exportcode'] = $sExportCode; | ||
| 241 | + | ||
| 242 | + $this->sZipFile = $sZipFile; | ||
| 243 | + return $sExportCode; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + /** | ||
| 247 | + * Download the zip file | ||
| 248 | + */ | ||
| 249 | + function downloadZipFile($exportCode = NULL) { | ||
| 250 | + if(!(isset($exportCode) && !empty($exportCode))) { | ||
| 251 | + $exportCode = KTUtil::arrayGet($_SESSION['zipcompression'], 'exportcode'); | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + $aData = KTUtil::arrayGet($_SESSION['zipcompression'], $exportCode); | ||
| 255 | + | ||
| 256 | + if(!empty($aData)){ | ||
| 257 | + $sZipFile = $aData['file']; | ||
| 258 | + $sTmpPath = $aData['dir']; | ||
| 259 | + }else{ | ||
| 260 | + $sZipFile = $this->sZipFile; | ||
| 261 | + $sTmpPath = $this->sTmpPath; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + if (!file_exists($sZipFile)) { | ||
| 265 | + return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + $mimeType = 'application/zip; charset=utf-8;'; | ||
| 269 | + $fileSize = filesize($sZipFile); | ||
| 270 | + $fileName = $this->sZipFileName . '.zip'; | ||
| 271 | + | ||
| 272 | + KTUtil::download($sZipFile, $mimeType, $fileSize, $fileName); | ||
| 273 | + KTUtil::deleteDirectory($sTmpPath); | ||
| 274 | + return true; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + /** | ||
| 278 | + * Check that iconv exists and that the selected encoding is supported. | ||
| 279 | + */ | ||
| 280 | + function checkConvertEncoding() { | ||
| 281 | + if(!function_exists("iconv")) { | ||
| 282 | + return PEAR::raiseError(_kt('IConv PHP extension not installed. The zip file compression could not handle output filename encoding conversion !')); | ||
| 283 | + } | ||
| 284 | + $oKTConfig = $this->oKTConfig; | ||
| 285 | + $this->sOutputEncoding = $oKTConfig->get('export/encoding', 'UTF-8'); | ||
| 286 | + | ||
| 287 | + // Test the specified encoding | ||
| 288 | + if(iconv("UTF-8", $this->sOutputEncoding, "") === FALSE) { | ||
| 289 | + return PEAR::raiseError(_kt('Specified output encoding for the zip files compression does not exists !')); | ||
| 290 | + } | ||
| 291 | + return true; | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + function _convertEncoding($sMystring, $bEncode) { | ||
| 295 | + if (strcasecmp($this->sOutputEncoding, "UTF-8") === 0) { | ||
| 296 | + return $sMystring; | ||
| 297 | + } | ||
| 298 | + if ($bEncode) { | ||
| 299 | + return iconv("UTF-8", $this->sOutputEncoding, $sMystring); | ||
| 300 | + } else { | ||
| 301 | + return iconv($this->sOutputEncoding, "UTF-8", $sMystring); | ||
| 302 | + } | ||
| 303 | + } | ||
| 304 | +} | ||
| 305 | ?> | 305 | ?> |