From: Jan Schneider Date: Wed, 30 Dec 2009 01:11:23 +0000 (+0100) Subject: Fix directory name. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=eb2eaaa5fd5d9ad7844fb3c89387046d9080eea8;p=horde.git Fix directory name. --- diff --git a/whups/lib/MIME/Viewer/Zip.php b/whups/lib/MIME/Viewer/Zip.php deleted file mode 100644 index 17825dff3..000000000 --- a/whups/lib/MIME/Viewer/Zip.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @author Michael Slusarz - * @author Jan Schneider - * @package Horde_MIME_Viewer - */ -class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip -{ - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * URL parameters used by this function: - *
-     * 'zip_attachment' - (integer) The ZIP attachment to download.
-     * 
- * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - if (!Horde_Util::getFormData('zip_attachment')) { - $this->_callback = array(&$this, '_WhupsCallback'); - return parent::_render(); - } - - /* Send the requested file. Its position in the zip archive is located - * in 'zip_attachment'. */ - $data = $this->_mimepart->getContents(); - $zip = Horde_Compress::factory('zip'); - $fileKey = Horde_Util::getFormData('zip_attachment') - 1; - $zipInfo = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_LIST)); - - /* Verify that the requested file exists. */ - if (isset($zipInfo[$fileKey])) { - $text = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => &$zipInfo, 'key' => $fileKey)); - if (!empty($text)) { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $text, - 'name' => basename($zipInfo[$fileKey]['name']), - 'status' => array(), - 'type' => 'application/octet-stream' - ) - ); - } - } - // TODO: Error reporting - return array(); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $this->_callback = array(&$this, '_WhupsCallback'); - return parent::_renderInline(); - } - - /** - * The function to use as a callback to _toHTML(). - * - * @param integer $key The position of the file in the zip archive. - * @param array $val The information array for the archived file. - * - * @return string The content-type of the output. - */ - protected function _WhupsCallback($key, $val) - { - $name = preg_replace('/( )+$/', '', $val['name']); - - if (!empty($val['size']) && (strstr($val['attr'], 'D') === false) && - ((($val['method'] == 0x8) && Horde_Util::extensionExists('zlib')) || - ($val['method'] == 0x0))) { - $mime_part = $this->_mimepart; - $mime_part->setName(basename($name)); - $val['name'] = str_replace($name, Horde::link(Horde_Util::addParameter(Horde::applicationUrl('view.php'), array('actionID' => 'view_file', 'type' => Horde_Util::getFormData('type'), 'file' => Horde_Util::getFormData('file'), 'ticket' => Horde_Util::getFormData('ticket'), 'zip_attachment' => $key + 1))) . $name . '', $val['name']); - } - - return $val; - } - -} diff --git a/whups/lib/Mime/Viewer/Zip.php b/whups/lib/Mime/Viewer/Zip.php new file mode 100644 index 000000000..17825dff3 --- /dev/null +++ b/whups/lib/Mime/Viewer/Zip.php @@ -0,0 +1,94 @@ + + * @author Michael Slusarz + * @author Jan Schneider + * @package Horde_MIME_Viewer + */ +class Whups_Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Zip +{ + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * URL parameters used by this function: + *
+     * 'zip_attachment' - (integer) The ZIP attachment to download.
+     * 
+ * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + if (!Horde_Util::getFormData('zip_attachment')) { + $this->_callback = array(&$this, '_WhupsCallback'); + return parent::_render(); + } + + /* Send the requested file. Its position in the zip archive is located + * in 'zip_attachment'. */ + $data = $this->_mimepart->getContents(); + $zip = Horde_Compress::factory('zip'); + $fileKey = Horde_Util::getFormData('zip_attachment') - 1; + $zipInfo = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_LIST)); + + /* Verify that the requested file exists. */ + if (isset($zipInfo[$fileKey])) { + $text = $zip->decompress($data, array('action' => Horde_Compress_Zip::ZIP_DATA, 'info' => &$zipInfo, 'key' => $fileKey)); + if (!empty($text)) { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $text, + 'name' => basename($zipInfo[$fileKey]['name']), + 'status' => array(), + 'type' => 'application/octet-stream' + ) + ); + } + } + // TODO: Error reporting + return array(); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $this->_callback = array(&$this, '_WhupsCallback'); + return parent::_renderInline(); + } + + /** + * The function to use as a callback to _toHTML(). + * + * @param integer $key The position of the file in the zip archive. + * @param array $val The information array for the archived file. + * + * @return string The content-type of the output. + */ + protected function _WhupsCallback($key, $val) + { + $name = preg_replace('/( )+$/', '', $val['name']); + + if (!empty($val['size']) && (strstr($val['attr'], 'D') === false) && + ((($val['method'] == 0x8) && Horde_Util::extensionExists('zlib')) || + ($val['method'] == 0x0))) { + $mime_part = $this->_mimepart; + $mime_part->setName(basename($name)); + $val['name'] = str_replace($name, Horde::link(Horde_Util::addParameter(Horde::applicationUrl('view.php'), array('actionID' => 'view_file', 'type' => Horde_Util::getFormData('type'), 'file' => Horde_Util::getFormData('file'), 'ticket' => Horde_Util::getFormData('ticket'), 'zip_attachment' => $key + 1))) . $name . '', $val['name']); + } + + return $val; + } + +}