From: Michael M Slusarz Date: Tue, 10 Mar 2009 21:58:05 +0000 (-0600) Subject: Convert drivers to Horde 4 package format. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a4b998108570ae725f783cad48c955df39bf6155;p=horde.git Convert drivers to Horde 4 package format. Remove some unneeded require/include and remove unrequired packages from package.xml. --- diff --git a/framework/Mime/lib/Horde/Mime/Mail.php b/framework/Mime/lib/Horde/Mime/Mail.php index 9fa7f793d..129dda908 100644 --- a/framework/Mime/lib/Horde/Mime/Mail.php +++ b/framework/Mime/lib/Horde/Mime/Mail.php @@ -286,7 +286,6 @@ class Horde_Mime_Mail } if (empty($type)) { - require_once dirname(__FILE__) . '/Magic.php'; $type = Horde_Mime_Magic::filenameToMime($file, false); } diff --git a/framework/Mime/lib/Horde/Mime/Mdn.php b/framework/Mime/lib/Horde/Mime/Mdn.php index 54ecc9a22..fe8abc887 100644 --- a/framework/Mime/lib/Horde/Mime/Mdn.php +++ b/framework/Mime/lib/Horde/Mime/Mdn.php @@ -69,8 +69,6 @@ class Horde_Mime_Mdn return true; } - require_once dirname(__FILE__) . '/Address.php'; - /* RFC 3798 [2.1]: Explicit confirmation is needed if there is more * than one distinct address in the Disposition-Notification-To * header. */ @@ -145,8 +143,6 @@ class Horde_Mime_Mdn $mailparams = array(), $mod = array(), $err = array()) { - require_once dirname(__FILE__) . '/Headers.php'; - require_once dirname(__FILE__) . '/Part.php'; require_once 'Horde/Identity.php'; require_once 'Horde/Text.php'; diff --git a/framework/Mime/lib/Horde/Mime/Part.php b/framework/Mime/lib/Horde/Mime/Part.php index dc9c56acd..707cdacb0 100644 --- a/framework/Mime/lib/Horde/Mime/Part.php +++ b/framework/Mime/lib/Horde/Mime/Part.php @@ -1,7 +1,6 @@ applications[$app]['fileroot'] . '/lib/Mime/Viewer/' . $driver . '.php'; - require_once dirname(__FILE__) . '/Viewer/Driver.php'; - return require_once $file; } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Audio.php b/framework/Mime/lib/Horde/Mime/Viewer/Audio.php new file mode 100644 index 000000000..21ea21eb4 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Audio.php @@ -0,0 +1,44 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Audio extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_mimepart->getContents(), + 'status' => array(), + 'type' => $this->_mimepart->getType() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Css.php b/framework/Mime/lib/Horde/Mime/Viewer/Css.php new file mode 100644 index 000000000..782a429da --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Css.php @@ -0,0 +1,127 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Css extends Horde_Mime_Viewer_Source +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Attribute preg patterns. + * + * @var array + */ + protected $_attrPatterns = array( + // Attributes + '!([-\w]+\s*):!s' => '\\1:', + // Values + '!:(\s*)(.+?)(\s*;)!s' => ':\\1\\2\\3', + // URLs + '!(url\([\'"]?)(.*?)([\'"]?\))!s' => '\\1\\2\\3', + // Colors + '!(#[[:xdigit:]]{3,6})!s' => '\\1', + // Parentheses + '!({|})!s' => '\\1', + // Unity + '!(em|px|%)\b!s' => '\\1' + ); + + /** + * Handles preg patterns. + * + * @var array + */ + protected $_handlesPatterns = array( + // HTML Tags + '!\b(body|h\d|a|span|div|acronym|small|strong|em|pre|ul|ol|li|p)\b!s' => '\\1\\2', + // IDs + '!(#[-\w]+)!s' => '\\1', + // Class + '!(\.[-\w]+)\b!s' => '\\1', + // METAs + '!(:link|:visited|:hover|:active|:first-letter)!s' => '\\1' + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + + // Need Horde headers for CSS tags. + reset($ret); + $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . + $ret[key($ret)]['data'] . + Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); + + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $css = preg_replace_callback('!(}|\*/).*?({|/\*)!s', array($this, '_handles'), htmlspecialchars($this->_mimepart->getContents(), ENT_NOQUOTES)); + $css = preg_replace_callback('!{[^}]*}!s', array($this, '_attributes'), $css); + $css = preg_replace_callback('!/\*.*?\*/!s', array($this, '_comments'), $css); + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_lineNumber(trim($css)), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * TODO + */ + protected function _comments($matches) + { + return '' . + preg_replace('!(http://[/\w-.]+)!s', '\\1', $matches[0]) . + ''; + } + + /** + * TODO + */ + protected function _attributes($matches) + { + return preg_replace(array_keys($this->_attrPatterns), array_values($this->_attrPatterns), $matches[0]); + } + + /** + * TODO + */ + protected function _handles($matches) + { + return preg_replace(array_keys($this->_handlesPatterns), array_values($this->_handlesPatterns), $matches[0]); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Deb.php b/framework/Mime/lib/Horde/Mime/Viewer/Deb.php new file mode 100644 index 000000000..59b61d72b --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Deb.php @@ -0,0 +1,75 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + if (!empty($ret)) { + reset($ret); + $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; + } + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $tmp_deb = Horde::getTempFile('horde_deb'); + + file_put_contents($tmp_deb, $this->_mimepart->getContents()); + + $fh = popen($this->_conf['location'] . " -f $tmp_deb 2>&1", 'r'); + while (($rc = fgets($fh, 8192))) { + $data .= $rc; + } + pclose($fh); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => '
' . htmlspecialchars($data) . '
', + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Default.php b/framework/Mime/lib/Horde/Mime/Viewer/Default.php new file mode 100644 index 000000000..64b7421b9 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Default.php @@ -0,0 +1,15 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver {} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php new file mode 100644 index 000000000..aadc37077 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enriched.php @@ -0,0 +1,198 @@ + command and the next balancing + * removes all other formatting commands (all text enclosed + * in angle brackets), and outside of environments converts + * any series of n CRLFs to n-1 CRLFs, and converts any lone CRLF + * pairs to SPACE. + * + * We don't qualify as we don't currently track the + * environment, that is we do CRLF conversion even if is + * specified in the text, but we're close at least. + * + * Copyright 2001-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Eric Rostetter + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Driver +{ + /** + * This driver's capabilities. + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => '' . $this->_toHTML() . '', + 'status' => array(), + 'type' => 'text/html; charset=' . $this->_mimepart->getCharset() + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Convert the enriched text to HTML. + * + * @return string The HTML-ified version of the MIME part contents. + */ + protected function _toHTML() + { + $text = trim($this->_mimepart->getContents()); + if (!strlen($text)) { + return array(); + } + + // We add space at the beginning and end of the string as it will + // make some regular expression checks later much easier (so we + // don't have to worry about start/end of line characters) + $text = ' ' . $text . ' '; + + // We need to preserve << tags, so map them to ascii 1 or ascii 255 + // We make the assumption here that there would never be an ascii + // 1 in an email, which may not be valid, but seems reasonable... + // ascii 255 would work if for some reason you don't like ascii 1 + // ascii 0 does NOT seem to work for this, though I'm not sure why + $text = str_replace('<<', chr(1), $text); + + // Remove any unrecognized tags in the text (via RFC minimal specs) + // any tags we just don't want to implement can also be removed here + // Note that this will remove any html links, but this is intended + $implementedTags = '' . + '
' . + ''; + // $unImplementedTags = ''; + $text = strip_tags($text, $implementedTags); + + // restore the << tags as < tags now... + $text = str_replace(chr(1), '<<', $text); + // $text = str_replace(chr(255), '<', $text); + + $replace = array( + // Get color parameters into a more useable format. + '/([\da-fA-F]+),([\da-fA-F]+),([\da-fA-F]+)<\/param>/Uis' => '', + '/(red|blue|green|yellow|cyan|magenta|black|white)<\/param>/Uis' => '', + + // Get font family parameters into a more useable format. + '/(\w+)<\/param>/Uis' => '', + + /* Just remove any remaining parameters -- we won't use them. + * Any tags with parameters that we want to implement will have + * come before this. Someday we hope to use these tags (e.g. for + * tags). */ + '/.*<\/param>/Uis' => '', + + /* Single line breaks become spaces, double line breaks are a + * real break. This needs to do tracking to be compliant + * but we don't want to deal with state at this time, so we fake + * it some day we should rewrite this to handle + * correctly. */ + '/([^\n])\r\n([^\r])/' => '\1 \2', + '/(\r\n)\r\n/' => '\1' + ); + $text = preg_replace(array_keys($replace), array_values($replace), $text); + + // We try to protect against bad stuff here. + $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset()); + + // Now convert the known tags to html. Try to remove any tag + // parameters to stop people from trying to pull a fast one + $replace = array( + '/(? '\1', + '/(? '\1', + '/(? '\1' + ); + $text = preg_replace(array_keys($replace), array_values($replace), $text); + + $text = preg_replace_callback('/(? '\2', + '/(? '\1', + '/(? '\2', + '/(? '', + '/(? '', + '/(? '', + '/(? '', + '/(? '\1', + '/(? '
\1
', + '/(? '
\1
', + '/(? '
\1
', + '/(? '
\1
', + '/(? '
\1
', + '/(? '
\1
' + ); + $text = preg_replace(array_keys($replace), array_values($replace), $text); + + // Replace << with < now (from translated HTML form). + $text = str_replace('<<', '<', $text); + + // Now we remove the leading/trailing space we added at the + // start. + $text = preg_replace('/^ (.*) $/s', '\1', $text); + + // Make URLs clickable. + require_once 'Horde/Text/Filter.php'; + $text = Text_Filter::filter($text, 'linkurls', array('callback' => 'Horde::externalUrl')); + + /* Wordwrap -- note this could impact on our above RFC compliance *IF* + * we honored nofill tags (which we don't yet). */ + $text = str_replace(array("\t", ' ', "\n "), array(' ', '  ', "\n "), $text); + + if ($text[0] == ' ') { + $text = ' ' . substr($text, 1); + } + + return '

' . nl2br($text) . '

'; + } + + /** + * TODO + */ + public function colorize($colors) + { + for ($i = 1; $i < 4; $i++) { + $colors[$i] = sprintf('%02X', round(hexdec($colors[$i]) / 255)); + } + return '' . $colors[4] . ''; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php new file mode 100644 index 000000000..e8df9e2fc --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php @@ -0,0 +1,164 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_toHTML(false), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_toHTML(true), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Converts the code to HTML. + * + * @param boolean $inline Is this an inline display? + * + * @return string The HTML-ified version of the MIME part contents. + */ + protected function _toHTML($inline) + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + /* Create temporary files for input to Enscript. Note that we can't + * use a pipe, since enscript must have access to the whole file to + * determine its type for coloured syntax highlighting. */ + $tmpin = Horde::getTempFile('enscriptin'); + + /* Write the contents of our buffer to the temporary input file. */ + file_put_contents($tmpin, $this->_mimepart->getContents()); + + /* Execute the enscript command. */ + $lang = escapeshellarg($this->_typeToLang($this->_mimepart->getType())); + $results = shell_exec($this->_conf['location'] . " -E$lang --language=html --color --output=- < $tmpin"); + + /* Strip out the extraneous HTML from enscript. */ + if ($inline) { + $res_arr = preg_split('/\<\/?pre\>/i', $results); + if (count($res_arr) == 3) { + $results = trim($res_arr[1]); + } + } + + return $this->_lineNumber($results); + } + + /** + * Attempts to determine what language to use for the enscript program + * from a MIME type. + * + * @param string $type The MIME type. + * + * @return string The enscript 'language' parameter string. + */ + protected function _typeToLang($type) + { + $ext = Horde_Mime_Magic::MIMEToExt($type); + + switch ($ext) { + case 'cs': + return 'java'; + + case 'el': + return 'elisp'; + + case 'h': + return 'c'; + + case 'C': + case 'H': + case 'cc': + case 'hh': + case 'c++': + case 'cxx': + case 'cpp': + return 'cpp'; + + case 'htm': + case 'shtml': + case 'xml': + return 'html'; + + case 'js': + return 'javascript'; + + case 'pas': + return 'pascal'; + + case 'al': + case 'cgi': + case 'pl': + case 'pm': + return 'perl'; + + case 'ps': + return 'postscript'; + + case 'vb': + return 'vba'; + + case 'vhd': + return 'vhdl'; + + case 'patch': + case 'diff': + return 'diffu'; + + default: + return $ext; + } + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Html.php b/framework/Mime/lib/Horde/Mime/Viewer/Html.php new file mode 100644 index 000000000..acc3127aa --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Html.php @@ -0,0 +1,197 @@ + + * @author Jon Parise + * @author Michael Slusarz + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $html = $this->_cleanHTML($this->_mimepart->getContents(), false); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $html['html'], + 'status' => array(), + 'type' => $this->_mimepart->getType(true) + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $html = $this->_cleanHTML($this->_mimepart->getContents(), true); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => String::convertCharset($html['data'], $this->_mimepart->getCharset()), + 'status' => $html['status'], + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Filters active content, dereferences external links, detects phishing, + * etc. + * + * @todo Use IP checks from + * http://lxr.mozilla.org/mailnews/source/mail/base/content/phishingDetector.js. + * + * @param string $data The HTML data. + * @param boolean $inline Are we viewing inline? + * + * @return array Two elements: 'html' and 'status'. + */ + protected function _cleanHTML($data, $inline) + { + global $browser; + + $phish_warn = false; + + /* Deal with tags in the HTML, since they will screw up our own + * relative paths. */ + if (preg_match('/ ]*)"? ?\/?>/i', $data, $matches)) { + $base = $matches[1]; + if (substr($base, -1) != '/') { + $base .= '/'; + } + + /* Recursively call _cleanHTML() to prevent clever fiends from + * sneaking nasty things into the page via $base. */ + $base = $this->_cleanHTML($base, $inline); + + /* Attempt to fix paths that were relying on a tag. */ + if (!empty($base)) { + $pattern = array('|src=(["\'])([^:"\']+)\1|i', + '|src=([^: >"\']+)|i', + '|href= *(["\'])([^:"\']+)\1|i', + '|href=([^: >"\']+)|i'); + $replace = array('src=\1' . $base . '\2\1', + 'src=' . $base . '\1', + 'href=\1' . $base . '\2\1', + 'href=' . $base . '\1'); + $data = preg_replace($pattern, $replace, $data); + } + } + + require_once 'Horde/Text/Filter.php'; + $strip_style_attributes = (($browser->isBrowser('mozilla') && + $browser->getMajor() == 4) || + $browser->isBrowser('msie')); + $strip_styles = $inline || $strip_style_attributes; + $data = Text_Filter::filter($data, 'xss', + array('body_only' => $inline, + 'strip_styles' => $strip_styles, + 'strip_style_attributes' => $strip_style_attributes)); + + /* Check for phishing exploits. */ + if ($this->getConfigParam('phishing_check')) { + if (preg_match('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:[^>]*>\s*(?:\\1:\/\/)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[^<]*<\/a)?/i', $data, $m)) { + /* Check 1: Check for IP address links, but ignore if the link + * text has the same IP address. */ + if (!isset($m[3]) || ($m[2] != $m[3])) { + if (isset($m[3])) { + $data = preg_replace('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/' . preg_quote($m[2], '/') . '(?:[^>]*>\s*(?:$1:\/\/)?' . preg_quote($m[3], '/') . '[^<]*<\/a)?/i', 'class="mimeStatusWarning" $0', $data); + } + $phish_warn = true; + } + } elseif (preg_match_all('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/([^\s"\'>]+)["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?(.*?)<\/a/is', $data, $m)) { + /* $m[1] = Link; $m[2] = Target + * Check 2: Check for links that point to a different host than + * the target url; if target looks like a domain name, check it + * against the link. */ + for ($i = 0, $links = count($m[0]); $i < $links; ++$i) { + $link = strtolower(urldecode($m[1][$i])); + $target = strtolower(preg_replace('/^(http|https|ftp):\/\//', '', strip_tags($m[2][$i]))); + if (preg_match('/^[-._\da-z]+\.[a-z]{2,}/i', $target) && + (strpos($link, $target) !== 0) && + (strpos($target, $link) !== 0)) { + /* Don't consider the link a phishing link if the + * domain is the same on both links (e.g. + * adtracking.example.com & www.example.com). */ + preg_match('/\.?([^\.\/]+\.[^\.\/]+)[\/?]/', $link, $host1); + preg_match('/\.?([^\.\/]+\.[^\.\/ ]+)([\/ ].*)?$/', $target, $host2); + if (!(count($host1) && count($host2)) || + (strcasecmp($host1[1], $host2[1]) !== 0)) { + $data = preg_replace('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/' . preg_quote($m[1][$i], '/') . '["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?' . preg_quote($m[2][$i], '/') . '<\/a/is', 'class="mimeStatusWarning" $0', $data); + $phish_warn = true; + } + } + } + } + } + + /* Try to derefer all external references. */ + $data = preg_replace_callback('/href\s*=\s*(["\'])?((?(1)[^\1]*?|[^\s>]+))(?(1)\1|)/i', array($this, '_dereferCallback'), $data); + + /* Get phishing warning. */ + $status = array(); + if ($inline && $phish_warn) { + $warning = array( + sprintf(_("%s: This message may not be from whom it claims to be. Beware of following any links in it or of providing the sender with any personal information."), _("Warning")), + _("The links that caused this warning have this background color:") . ' ' . _("EXAMPLE") . '.' + ); + + if (!$inline) { + $temp = array(); + foreach ($phish_warning as $val) { + $temp[] = String::convertCharset($val, NLS::getCharset(), $this->_mimepart->getCharset()); + } + $warning = $temp; + } + + $status[] = array( + 'class' => 'mimestatuswarning', + 'text' => $warning + ); + } + + return array('html' => $data, 'status' => $status); + } + + /** + * TODO + * + * @param string $m TODO + * + * @return string TODO + */ + protected function _dereferCallback($m) + { + return 'href="' . Horde::externalUrl($m[2]) . '"'; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Images.php b/framework/Mime/lib/Horde/Mime/Viewer/Images.php new file mode 100644 index 000000000..085c2d4a6 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Images.php @@ -0,0 +1,67 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_mimepart->getContents(), + 'status' => array(), + 'type' => $this->_getType() + ) + ); + } + + /** + * Return the content-type to use for the image. + * + * @return string The content-type of the image. + */ + protected function _getType() + { + $type = $this->_mimepart->getType(); + + switch ($type) { + case 'image/pjpeg': + /* image/jpeg and image/pjpeg *appear* to be the same entity, but + * Mozilla (for one) don't seem to want to accept the latter. */ + return 'image/jpeg'; + + case 'image/x-png': + /* image/x-png == image/png. */ + return 'image/png'; + + default: + return $type; + } + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php b/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php new file mode 100644 index 000000000..6aab1e76b --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Msexcel.php @@ -0,0 +1,58 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $tmp_xls = Horde::getTempFile('horde_msexcel'); + $tmp_out = Horde::getTempFile('horde_msexcel'); + + file_put_contents($tmp_xls, $this->_mimepart->getContents()); + $args = ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_xls . ' ' . $tmp_out; + + exec($this->_conf['location'] . $args); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => file_get_contents($tmp_out), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php b/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php new file mode 100644 index 000000000..31144b621 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Mspowerpoint.php @@ -0,0 +1,61 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $data = ''; + $tmp_ppt = Horde::getTempFile('horde_mspowerpoint'); + + file_put_contents($tmp_ppt, $this->_mimepart->getContents()); + + $fh = popen($this->_conf['location'] . " $tmp_ppt 2>&1", 'r'); + while (($rc = fgets($fh, 8192))) { + $data .= $rc; + } + pclose($fh); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Msword.php b/framework/Mime/lib/Horde/Mime/Viewer/Msword.php new file mode 100644 index 000000000..5a17a714f --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Msword.php @@ -0,0 +1,67 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $tmp_word = Horde::getTempFile('msword'); + $tmp_output = Horde::getTempFile('msword'); + $tmp_file = str_replace(Horde::getTempDir() . '/', '', $tmp_output); + + file_put_contents($tmp_word, $this->_mimepart->getContents()); + $args = ' --to=html --to-name=' . $tmp_output . ' ' . $tmp_word; + + exec($this->_conf['location'] . $args); + + if (file_exists($tmp_output)) { + $data = file_get_contents($tmp_output); + $type = 'text/html'; + } else { + $data = _("Unable to translate this Word document"); + $type = 'text/plain'; + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => $type . '; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo.php b/framework/Mime/lib/Horde/Mime/Viewer/Ooo.php new file mode 100644 index 000000000..bd14885c7 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo.php @@ -0,0 +1,115 @@ + + * @author Jan Schneider + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $has_xslt = Util::extensionExists('xslt'); + $has_ssfile = function_exists('domxml_xslt_stylesheet_file'); + if (($use_xslt = $has_xslt || $has_ssfile)) { + $tmpdir = Util::createTempDir(true); + } + + $fnames = array('content.xml', 'styles.xml', 'meta.xml'); + $tags = array( + 'text:p' => 'p', + 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ', + 'table:table-row' => 'tr bgcolor="#cccccc"', + 'table:table-cell' => 'td', + 'table:number-columns-spanned=' => 'colspan=' + ); + + $zip = &Horde_Compress::singleton('zip'); + $list = $zip->decompress($this->_mimepart->getContents(), array('action' => HORDE_COMPRESS_ZIP_LIST)); + + foreach ($list as $key => $file) { + if (in_array($file['name'], $fnames)) { + $content = $zip->decompress($this->_mimepart->getContents(), array( + 'action' => HORDE_COMPRESS_ZIP_DATA, + 'info' => $list, + 'key' => $key + )); + + if ($use_xslt) { + file_put_contents($tmpdir . $file['name'], $content); + } elseif ($file['name'] == 'content.xml') { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => str_replace(array_keys($tags), array_values($tags), $content), + 'status' => array(), + 'type' => 'text/html; charset=UTF-8' + ) + ); + } + } + } + + if (!Util::extensionExists('xslt')) { + return array(); + } + + $xsl_file = dirname(__FILE__) . '/Ooo/main_html.xsl'; + + if ($has_ssfile) { + /* Use DOMXML */ + $xslt = domxml_xslt_stylesheet_file($xsl_file); + $dom = domxml_open_file($tmpdir . 'content.xml'); + $result = @$xslt->process($dom, array( + 'metaFileURL' => $tmpdir . 'meta.xml', + 'stylesFileURL' => $tmpdir . 'styles.xml', + 'disableJava' => true) + ); + $result = $xslt->result_dump_mem($result); + } else { + // Use XSLT + $xslt = xslt_create(); + $result = @xslt_process($xslt, $tmpdir . 'content.xml', $xsl_file, null, null, array( + 'metaFileURL' => $tmpdir . 'meta.xml', + 'stylesFileURL' => $tmpdir . 'styles.xml', + 'disableJava' => true) + ); + if (!$result) { + $result = xslt_error($xslt); + } + xslt_free($xslt); + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $result, + 'status' => array(), + 'type' => 'text/html; charset=UTF-8' + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/common.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/common.xsl new file mode 100644 index 000000000..943a5b995 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/common.xsl @@ -0,0 +1,1165 @@ + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + height: ; + + + width: ; + + + height: ; + width: ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + margin-left:; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +     + + + + + + + + + + + + + + + + + + + + + + + +     + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +     + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + * + + + + + + + + + + + + * + * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/global_document.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/global_document.xsl new file mode 100644 index 000000000..fc4579ef3 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/global_document.xsl @@ -0,0 +1,1674 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Matching child document header No. + absolute-chapter-level: + encodedTitle: + globalDocumentRefToCurrentFile: + *** + + + + + + + + + + + + + + + + + + + + + + + + + Matching global document header No. + absolute-chapter-level: + encodedTitle: + contentTableURL: + *** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creation of global document helper variable for the content table.... + + + + + + + + + + + + + + + + + Finished the Creation of global document helper variable for the content table! + + + + + Creation of global document helper variable for the child documents.... + + + + + + Finished the Creation of global document helper variable for the child documents! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # + level: + title: + encoded-title: + file-url: + header-no: + ** + + ** + ** + + + childrenHeadings/heading-count: + + # + title: + ** + + + + + + + + + + + + + + + + + + Creating global document variable for chapter relations.... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Finished global document variable for chapter relations! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *** new heading + currentChapterID: + currentChapterTitle: + currentChapterID: + currentHeadingNo: + headingTitle: + headingLevel: + headingNo: + newChildURL: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + only a heading, but not a chapter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + All child documents have been walked through without finding the chapter name! + childrenHeadings/heading-count: + currentHeadingNo: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Parsing the global document... + + + + + + + + Parsing the child documents... + + + + + + + + + + + + + Starting the child transformations... + + + + + + Contentable data exists as global data! + + + No Contentable global data exists! + + + + + + + + + + + + + Java method transformChildren to transform all children of a global document could not be found. Be sure to use the XT processor. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Previous document + + + | + + + + + + + + + + + + + + + + + + # + + + + + + Content Table + + + + + + | + + + + + + + + + + + + + + + + + + + + + Next document + + + ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + **** THE HEADING VARIABLE **** + content-table-url: + + + **** new heading: + content-table-id: + child-document-no: + file-url: + out-file-url: + level: + title: + encoded-title: + absolute-chapter-level: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + width: + + + + + + + + + + + + + + + + + + + + + + + + + + + + align: right + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/main_html.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/main_html.xsl new file mode 100644 index 000000000..443182a3e --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/main_html.xsl @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CSS helper variable will be created.... + + CSS variable ready, header will be created.... + + + CSS header creation finished! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + description + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Creating the inline styles.... + + + + + Time for instantiating style variable: ms + + + + + + Creating the inline styles.... + + + + + Time for instantiating style variable: ms + + + + + + + + + + + Parameter dpi: + Parameter metaFileURL: + Parameter stylesFileURL: + Parameter absoluteSourceDirRef: + Parameter precedingChapterLevel1 : + Parameter precedingChapterLevel2 : + Parameter precedingChapterLevel3 : + Parameter precedingChapterLevel4 : + Parameter precedingChapterLevel5 : + Parameter precedingChapterLevel6 : + Parameter precedingChapterLevel7 : + Parameter precedingChapterLevel8 : + Parameter precedingChapterLevel9 : + Parameter precedingChapterLevel10: + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/palm.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/palm.xsl new file mode 100644 index 000000000..212edb167 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/palm.xsl @@ -0,0 +1,404 @@ + + + + + + + + + + + + + PalmComputingPlatform + true + + + HandheldFriendly + true + + + HistoryListText + Dateimanager : &date &time + + + description + StarPortal + + + keywords + starportal, staroffice, software + + + Content-Type + text/html; charset=iso-8859-1 + + + + + + + + + + + + + + + + + left + + + right + + + center + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + left + + + right + + + center + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #000000 + + + #FFFFFF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #000000 + + + #FFFFFF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_header.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_header.xsl new file mode 100644 index 000000000..eeb0c204a --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_header.xsl @@ -0,0 +1,379 @@ + + + + + + + + + + + + + The CSS style header method for setting styles + + + text/css + + + + + + + + + + + + + + + + + + + + + + + + + + + // + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + + + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + *.OOo_defaults + + + , + + + + + , + + + + { + margin-top:0cm; margin-bottom:0cm; } + + + + + + + + + + + + + + + + + + + + + + , + + + + + , + + + + + + + + + + + + + + { + + + } + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_inlined.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_inlined.xsl new file mode 100644 index 000000000..19159958c --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_inlined.xsl @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_mapping.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_mapping.xsl new file mode 100644 index 000000000..a9a858dc0 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/style_mapping.xsl @@ -0,0 +1,660 @@ + + + + + + + + + + + + + + + + + + + + + + + + float: right; + + + float: left; + + + + + + + + align: left; + + + align: right; + + + align: center; + + + + + + + + padding: + + ; + + + + + + + + + border-width:; + border-style:; + border-color:; + + + border-width:; + border-style:; + border-color:; + + + border-width:; + border-style:; + border-color:; + + + + + border-top: ; + + + border-bottom: ; + + + border-left: ; + + + border-right: ; + + + + + + width:; + + + width:; + + + + + + + + height:; + + + height:; + + + + + + + + width:; + + + width:; + + + + + + :; + + + font-family: + + + ; + + font-style:italic; + + + font-weight:bold; + + + + :; + + + :; + + + :; + + + :; + + + :; + + + :; + + + :; + + + :; + + + :; + + + + + + text-align:left ! important; + + + text-align:right ! important; + + + text-align: ! important; + + + + + :; + + + background-color:; + + + background-color:; + + + background-image:url(); + + + background-repeat:repeat; + + + background-repeat:no-repeat; + + + + + + :; + + + + text-decoration:line-through; + + + + + text-decoration:underline; + + + + + vertical-align:sub; + + + vertical-align:sup; + + + + + + + + + + + + + + + + + + + italic, + + + + + + + bold, + + + + + + underline, + + + + + + + align:left, + + + align:right, + + + align:center, + + + + + + + strike, + + + + + size::size, + + + + + + + color:#FFFFFF, + + + color:#000000, + + + + + + + + size::size, + + + + + + width::width, + + + width::width; + + + + + + + + height::height; + + + height::height; + + + + + + + + width::width; + + + width::width; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table.xsl new file mode 100644 index 000000000..36339ed73 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table.xsl @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + left + + + right + + + center + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maxRowLength: + + numberOfHiddenColumns: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + #000000 + 2 + 0 + page-break-inside:avoid + + + + + + + + + + + + + + + + Time for checking BorderStyle: ms + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_cells.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_cells.xsl new file mode 100644 index 000000000..4671ea96f --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_cells.xsl @@ -0,0 +1,484 @@ + + + + + + + + + + + + + + + + + + +--------------> table:table-cell has been entered with node value: + table:number-columns-repeated: -- + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NEW VALUE: column-position: -- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++++++++ starting cell writing +++++++++ + number-columns-repeated: -- + maxRowLength: -- + column-position: -- + + + + + + + + + + + + +++++++++ cell repetition +++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WriteTest -> If nothing between '-' write cell -- + + + + + TABLE COLUMN is hidden! + + + + + + + + TABLE COLUMN is hidden! + + + + + + + + + + + th + + + td + + + + + + + + + + + +*****************************************'' element has been added! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text-align:right; + text-align:left; + + + + + + + + + + + + + + + + + + + + text-align:right; + + + text-align:left; + + + + + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text-align:right; + + + text-align:left; + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + ; + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_columns.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_columns.xsl new file mode 100644 index 000000000..a9a907ff8 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_columns.xsl @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out. + In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out. + + + + + column is hidden + + + + = + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_rows.xsl b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_rows.xsl new file mode 100644 index 000000000..6f7d17d62 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Ooo/table_rows.xsl @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +*************************'tr' element has been added! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Pdf.php b/framework/Mime/lib/Horde/Mime/Viewer/Pdf.php new file mode 100644 index 000000000..4305a1108 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Pdf.php @@ -0,0 +1,45 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_mimepart->getContents(), + 'status' => array(), + 'type' => 'application/pdf' + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Php.php b/framework/Mime/lib/Horde/Mime/Viewer/Php.php new file mode 100644 index 000000000..3fd275353 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Php.php @@ -0,0 +1,157 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_source +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + + // Need Horde headers for CSS tags. + reset($ret); + $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . + $ret[key($ret)]['data'] . + Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); + + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + ini_set('highlight.comment', 'comment'); + ini_set('highlight.default', 'default'); + ini_set('highlight.keyword', 'keyword'); + ini_set('highlight.string', 'string'); + ini_set('highlight.html', 'html'); + + $code = $this->_mimepart->getContents(); + $text = (strpos($code, '_lineNumber(str_replace('<?php ', '', highlight_string('_lineNumber(highlight_string($code, true)); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $text, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Add line numbers to a block of code. + * + * @param string $code The code to number. + * + * @return string The code with line numbers added. + */ + protected function _lineNumber($code, $linebreak = "\n") + { + // Clean up. + $code = preg_replace( + array( + '/\s*/', + '/\s*/', + '/\s*<\/span>\s*<\/span>\s*<\/code>/', + '/\s*<\/font>\s*<\/font>\s*<\/code>/' + ), '', $code); + + $code = str_replace( + array(' ', '&', '
', '',), + array(' ', '&', "\n", '',), + $code); + + $code = trim($code); + + // Normalize newlines. + $code = str_replace("\r", '', $code); + $code = preg_replace('/\n\n\n+/', "\n\n", $code); + + $results = array('
    '); + $previous = false; + + $lines = explode("\n", $code); + reset($lines); + while (list($lineno, $line) = each($lines)) { + if (substr($line, 0, 7) == '') { + $previous = false; + $line = substr($line, 7); + } + + if (empty($line)) { + $line = ' '; + } + + if ($previous) { + $line = "" . $line; + } + + // Save the previous style. + if (strpos($line, '') { + $previous = false; + } elseif ($previous) { + $line .= ''; + } + + $results[] = '
  1. ' . $line . '
  2. '; + } + + $results[] = '
'; + + return implode("\n", $results); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Plain.php b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php new file mode 100644 index 000000000..57ae876e3 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Plain.php @@ -0,0 +1,95 @@ + + * @author Michael Slusarz + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $text = $this->_mimepart->getContents(); + $charset = $this->_mimepart->getCharset(); + + /* Check for 'flowed' text data. */ + if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') { + $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); + } + + require_once 'Horde/Text/Filter.php'; + return array( + $this->_mimepart->getMimeId() => array( + 'data' => '' . Text_Filter::filter($text, 'text2html', array('parselevel' => TEXT_HTML_MICRO, 'charset' => $charset, 'class' => null)) . '', + 'status' => array(), + 'type' => 'text/html; charset=' . $charset + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $text = String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()); + + /* Check for 'flowed' text data. */ + $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed') + ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')) + : $text; + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Format flowed text for HTML output. + * + * @param string $text The text to format. + * @param boolean $delsp Was text created with DelSp formatting? + * + * @return string The formatted text. + */ + protected function _formatFlowed($text, $delsp = null) + { + $flowed = new Horde_Text_Flowed($this->_mimepart->replaceEOL($text, "\n"), $this->_mimepart->getCharset()); + $flowed->setMaxLength(0); + if (!is_null($delsp)) { + $flowed->setDelSp($delsp); + } + return $flowed->toFixed(); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rar.php b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php new file mode 100644 index 000000000..261c725a9 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php @@ -0,0 +1,108 @@ + + * @author Michael Cochrane + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + if (!empty($ret)) { + reset($ret); + $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; + } + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $contents = $this->_mimepart->getContents(); + + $rar = &Horde_Compress::singleton('rar'); + + $rarData = $rar->decompress($contents); + if (is_a($rarData, 'PEAR_Error')) { + return array(); + } + $fileCount = count($rarData); + + require_once 'Horde/Text.php'; + + $name = $this->_mimepart->getName(true); + if (empty($name)) { + $name = _("unnamed"); + } + + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + '
' . + Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . + Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . + Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . + "\n\n" . + Text::htmlAllSpaces( + String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) . + String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) . + String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) + ) . "\n" . + str_repeat('-', 109) . "\n"; + + foreach ($rarData as $val) { + $ratio = empty($val['size']) + ? 0 + : 100 * ($val['csize'] / $val['size']); + + $text .= Text::htmlAllSpaces( + String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) . + String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) . + String::pad($val['size'], 10, ' ', STR_PAD_LEFT) . + String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) . + String::pad($val['method'], 10, ' ', STR_PAD_LEFT) . + String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT) + ) . "\n"; + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Report.php b/framework/Mime/lib/Horde/Mime/Viewer/Report.php new file mode 100644 index 000000000..2b0200165 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Report.php @@ -0,0 +1,33 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Driver +{ + /** + * Return the underlying MIME Viewer for this part. + * + * @return mixed A Horde_Mime_Viewer object, or false if not found. + */ + protected function _getViewer() + { + if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) { + return false; + } + + $viewer = Horde_Mime_Viewer::factory($this->_mimepart, 'message/' . String::lower($type)); + if ($viewer) { + $viewer->setParams($this->_params); + } + return $viewer; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php new file mode 100644 index 000000000..57df4bc34 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rfc822.php @@ -0,0 +1,94 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => true, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_mimepart->getContents(), + 'status' => array(), + 'type' => 'text/plain; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Return the rendered information about the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInfo() + { + /* Get the text of the part. Since we need to look for the end of + * the headers by searching for the CRLFCRLF sequence, use + * getCanonicalContents() to make sure we are getting the text with + * CRLF's. */ + $text = $this->_mimepart->getCanonicalContents(); + if (empty($text)) { + return array(); + } + + /* Search for the end of the header text (CRLFCRLF). */ + $text = substr($text, 0, strpos($text, "\r\n\r\n")); + + /* Get the list of headers now. */ + $headers = Horde_Mime_Headers::parseHeaders($text); + + $header_array = array( + 'date' => _("Date"), + 'from' => _("From"), + 'to' => _("To"), + 'cc' => _("Cc"), + 'bcc' => _("Bcc"), + 'reply-to' => _("Reply-To"), + 'subject' => _("Subject") + ); + $header_output = array(); + + foreach ($header_array as $key => $val) { + $hdr = $headers->getValue($key); + if (!empty($hdr)) { + $header_output[] = '' . $val . ': ' . htmlspecialchars($hdr); + } + } + + require_once 'Horde/Text/Filter.php'; + return array( + $this->_mimepart->getMimeId() => array( + 'data' => empty($header_output) ? '' : ('
' . Text_Filter::filter(implode("
\n", $header_output), 'emails') . '
'), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php b/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php new file mode 100644 index 000000000..4aae86b77 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Richtext.php @@ -0,0 +1,152 @@ +" to + * "<", converts CRLFs to SPACE, converts to a newline according to + * local newline convention, removes everything between a command + * and the next balancing command, and removes all other + * formatting commands (all text enclosed in angle brackets). + * + * We implement the following tags: + * , , , , , ,
, + * , , , , , , + * , , , , + * + * The following tags are implemented differently than described in the RFC + * (due to limitations in HTML output): + * - Output as centered, bold text. + * - Output as centered, bold text. + * - Output as paragraph break. + * + * The following tags are NOT implemented: + * , , , , , + * , + * + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Michael Slusarz + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Richtext extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_toHTML(), + 'status' => array(), + 'type' => 'text/html; charset=' . $this->_mimepart->getCharset() + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Convert richtext to HTML. + * + * @return string The converted HTML string. + */ + protected function _toHTML() + { + $text = trim($this->_mimepart->getContents()); + if ($text == '') { + return array(); + } + + /* We add space at the beginning and end of the string as it will + * make some regular expression checks later much easier (so we + * don't have to worry about start/end of line characters). */ + $text = ' ' . $text . ' '; + + /* Remove everything between tags. */ + $text = preg_replace('/.*<\/comment>/Uis', '', $text); + + /* Remove any unrecognized tags in the text. We don't need + * in $tags since it doesn't do anything anyway. All tags + * have already been removed. */ + $tags = '
'; + $text = strip_tags($text, $tags); + + /* becomes a '<'. CRLF becomes a SPACE. */ + $text = str_ireplace(array('', "\r\n"), array('<', ' '), $text); + + /* We try to protect against bad stuff here. */ + $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset()); + + /* becomes a newline (
); + * becomes a paragraph break (

). */ + $text = str_ireplace(array('<nl>', '<np>'), array('
', '

'), $text); + + /* Now convert the known tags to html. Try to remove any tag + * parameters to stop people from trying to pull a fast one. */ + $replace = array( + '/(? '\1', + '/(? '\1', + '/(? '\1', + '/(? '\1', + '/(? '\1', + '/(? '\1', + '/(? '

\1
', + '/(? '
\1
', + '/(? '
\1
', + '/(? '
\1
', + '/(? '\1', + '/(? '\1', + '/(? '\1', + '/(? '
\1

', + '/(? '
\1

', + '/(? '

\1

', + '/(? '
\1
' + ); + $text = preg_replace(array_keys($replace), array_values($replace), $text); + + /* Now we remove the leading/trailing space we added at the start. */ + $text = substr($text, 1, -1); + + /* Wordwrap. */ + $text = str_replace(array("\t", ' ', "\n "), array(' ', '  ', "\n "), $text); + if ($text[0] == ' ') { + $text = ' ' . substr($text, 1); + } + + return '

' . nl2br($text) . '

'; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php b/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php new file mode 100644 index 000000000..698cde66b --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rpm.php @@ -0,0 +1,61 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $data = ''; + $tmp_rpm = Horde::getTempFile('horde_rpm'); + + file_put_contents($tmp_rpm, $this->_mimepart->getContents()); + + $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r'); + while (($rc = fgets($fh, 8192))) { + $data .= $rc; + } + pclose($fh); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => '
' . htmlentities($data) . '
', + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php b/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php new file mode 100644 index 000000000..c4573da6a --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rtf.php @@ -0,0 +1,65 @@ + + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Duck + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $tmp_rtf = Horde::getTempFile('rtf'); + $tmp_output = Horde::getTempFile('rtf'); + + file_put_contents($tmp_rtf, $this->_mimepart->getContents()); + + exec($this->_conf['location'] . " $tmp_rtf > $tmp_output"); + + if (file_exists($tmp_output)) { + $data = file_get_contents($tmp_output); + } else { + $data = _("Unable to translate this RTF document"); + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Security.php b/framework/Mime/lib/Horde/Mime/Viewer/Security.php new file mode 100644 index 000000000..2600ba547 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Security.php @@ -0,0 +1,34 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Security extends Horde_Mime_Viewer_Driver +{ + /** + * Return the underlying MIME Viewer for this part. + * + * @return mixed A Horde_Mime_Viewer object, or false if not found. + */ + protected function _getViewer() + { + if (!($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) { + return false; + } + + $viewer = Horde_Mime_Viewer::factory($this->_mimepart, $protocol); + if ($viewer) { + $viewer->setParams($this->_params); + } + return $viewer; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Simple.php b/framework/Mime/lib/Horde/Mime/Viewer/Simple.php new file mode 100644 index 000000000..aa4a15701 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Simple.php @@ -0,0 +1,60 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Simple extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_mimepart->getContents(), + 'status' => array(), + 'type' => 'text/plain; charset=' . $this->_mimepart->getCharset() + ) + ); + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + return array( + $this->_mimepart->getMimeId() => array( + 'data' => String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()), + 'status' => array(), + 'type' => 'text/plain; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Smil.php b/framework/Mime/lib/Horde/Mime/Viewer/Smil.php new file mode 100644 index 000000000..327059745 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Smil.php @@ -0,0 +1,109 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Driver +{ + /** + * Handle for the XML parser object. + * + * @var resource + */ + protected $_parser; + + /** + * String buffer to hold the generated content + * + * @var string + */ + protected $_content; + + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $this->_content = ''; + + /* Create a new parser and set its default properties. */ + $this->_parser = xml_parser_create(); + xml_set_object($this->_parser, $this); + xml_set_element_handler($this->_parser, '_startElement', '_endElement'); + xml_set_character_data_handler($this->_parser, '_defaultHandler'); + xml_parse($this->_parser, $this->_mimepart->getContents(), true); + xml_parser_free($this->_parser); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_content, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * User-defined function callback for start elements. + * + * @param object $parser Handle to the parser instance. + * @param string $name The name of this XML element. + * @param array $attrs List of this element's attributes. + */ + protected function _startElement($parser, $name, $attrs) + { + switch ($name) { + case 'IMG': + if (isset($attrs['SRC'])) { + $this->_content .= ''; + } + break; + } + } + + /** + * User-defined function callback for end elements. + * + * @param object $parser Handle to the parser instance. + * @param string $name The name of this XML element. + */ + protected function _endElement($parser, $name) + { + } + + /** + * User-defined function callback for character data. + * + * @param object $parser Handle to the parser instance. + * @param string $data String of character data. + */ + protected function _defaultHandler($parser, $data) + { + $data = trim($data); + if (!empty($data)) { + $this->_content .= ' ' . htmlspecialchars($data); + } + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Source.php b/framework/Mime/lib/Horde/Mime/Viewer/Source.php new file mode 100644 index 000000000..bddc95cad --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Source.php @@ -0,0 +1,31 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Source extends Horde_Mime_Viewer_Driver +{ + /** + * Add line numbers to a block of code. + * + * @param string $code The code to number. + * + * @return string The code with line numbers added. + */ + protected function _lineNumber($code, $linebreak = "\n") + { + $html = array('
'); + for ($l = 1, $lines = substr_count($code, $linebreak) + 1; $l <= $lines; ++$l) { + $html[] = sprintf('%s
', $l, $l, $l); + } + return implode("\n", $html) . '
' . $code . '
'; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php new file mode 100644 index 000000000..af4e77eca --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php @@ -0,0 +1,122 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + + // Need Horde headers for CSS tags. + reset($ret); + $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . + $ret[key($ret)]['data'] . + Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); + + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + /* Create temporary files for Webcpp. */ + $tmpin = Horde::getTempFile('SrcIn'); + $tmpout = Horde::getTempFile('SrcOut', false); + + /* Write the contents of our buffer to the temporary input file. */ + file_put_contents($tmpin, $this->_mimepart->getContents()); + + /* Determine the language from the mime type. */ + $lang = $this->_typeToLang($this->_mimepart->getType()); + + /* Execute Source-Highlite. */ + exec($this->_conf['location'] . " --src-lang $lang --out-format xhtml --input $tmpin --output $tmpout"); + $results = file_get_contents($tmpout); + unlink($tmpout); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $this->_lineNumber($results), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Attempts to determine what mode to use for the source-highlight + * program from a MIME type. + * + * @param string $type The MIME type. + * + * @return string The mode to use. + */ + protected function _typeToLang($type) + { + switch ($type) { + case 'text/x-java': + return 'java'; + + case 'text/x-csrc': + case 'text/x-c++src': + case 'text/cpp': + return 'cpp'; + + case 'application/x-perl': + return 'perl'; + + case 'application/x-php': + case 'x-extension/phps': + case 'x-extension/php3s': + case 'application/x-httpd-php': + case 'application/x-httpd-php3': + case 'application/x-httpd-phps': + return 'php3'; + + case 'application/x-python': + return 'python'; + + // TODO: 'prolog', 'flex', 'changelog', 'ruby' + } + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php new file mode 100644 index 000000000..cbfd711e0 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php @@ -0,0 +1,118 @@ + + * @author Michael Cochrane + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => false, + 'info' => true, + 'inline' => true + ); + + /** + * The list of compressed subtypes. + * + * @var array + */ + protected $_gzipSubtypes = array( + 'x-compressed-tar', 'tgz', 'x-tgz', 'gzip', 'x-gzip', + 'x-gzip-compressed', 'x-gtar' + ); + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + /* Currently, can't do anything without tar file. */ + $subtype = $this->_mimepart->getSubType(); + if (in_array($subtype, array('gzip', 'x-gzip', 'x-gzip-compressed'))) { + return array(); + } + + $contents = $this->_mimepart->getContents(); + + /* Decompress gzipped files. */ + if (in_array($subtype, $this->_gzipSubtypes)) { + $gzip = &Horde_Compress::singleton('gzip'); + $contents = $gzip->decompress($contents); + if (is_a($contents, 'PEAR_Error') || empty($contents)) { + return array(); + } + } + + /* Obtain the list of files/data in the tar file. */ + $tar = &Horde_Compress::singleton('tar'); + $tarData = $tar->decompress($contents); + if (is_a($tarData, 'PEAR_Error')) { + return array(); + } + $fileCount = count($tarData); + + require_once 'Horde/Text.php'; + + $name = $this->_mimepart->getName(true); + if (empty($name)) { + $name = _("unnamed"); + } + + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + '
' . + Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . + Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . + Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . + "\n\n" . + Text::htmlAllSpaces( + str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) . + str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) . + str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) . + str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) + ) . "\n" . + str_repeat('-', 106) . "\n"; + + foreach ($tarData as $val) { + $text .= Text::htmlAllSpaces( + str_pad($val['name'], 62, ' ', STR_PAD_RIGHT) . + str_pad($val['attr'], 15, ' ', STR_PAD_LEFT) . + str_pad($val['size'], 10, ' ', STR_PAD_LEFT) . + str_pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) + ) . "\n"; + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * Return the rendered information about the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInfo() + { + return $this->_renderInline(); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php b/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php new file mode 100644 index 000000000..373ee9157 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Tnef.php @@ -0,0 +1,74 @@ + + * @author Michael Slusarz + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + if (!empty($ret)) { + reset($ret); + $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; + } + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $tnef = &Horde_Compress::singleton('tnef'); + + $data = ''; + $info = $tnef->decompress($this->_mimepart->getContents()); + if (empty($info) || is_a($info, 'PEAR_Error')) { + $data .= ''; + } else { + $data .= ''; + foreach ($info as $part) { + $data .= ''; + } + } + $data .= '
' . _("MS-TNEF Attachment contained no data.") . '
' . _("Name") . '' . _("Mime Type") . '
' . $part['name'] . '' . $part['type'] . '/' . $part['subtype'] . '
'; + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php b/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php new file mode 100644 index 000000000..e7a7c3b84 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Vcard.php @@ -0,0 +1,403 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_renderInline(); + if (!empty($ret)) { + reset($ret); + $ret[key($ret)]['data'] = Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . + $ret[key($ret)]['data'] . + Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); + } + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + global $registry, $prefs, $notification; + + $app = false; + $data = $this->_mimepart->getContents(); + $html = ''; + $import_msg = null; + $title = _("vCard"); + + $iCal = new Horde_iCalendar(); + if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) { + $notification->push(_("There was an error reading the contact data."), 'horde.error'); + } + + if (Util::getFormData('import') && + Util::getFormData('source') && + $registry->hasMethod('contacts/import')) { + $source = Util::getFormData('source'); + $count = 0; + foreach ($iCal->getComponents() as $c) { + if (is_a($c, 'Horde_iCalendar_vcard')) { + $contacts = $registry->call('contacts/import', + array($c, null, $source)); + if (is_a($contacts, 'PEAR_Error')) { + $notification->push( + _("There was an error importing the contact data:") . ' ' + . $contacts->getMessage(), + 'horde.error'); + continue; + } + $count++; + } + } + $notification->push(sprintf(ngettext( + "%d contact was successfully added to your address book.", + "%d contacts were successfully added to your address book.", + $count), + $count), + 'horde.success'); + } + + $html .= ''; + + $i = 0; + foreach ($iCal->getComponents() as $vc) { + if ($i > 0) { + $html .= ''; + } + ++$i; + + $html .= ''; + + $n = $vc->printableName(); + if (!empty($n)) { + $html .= $this->_row(_("Name"), $n); + } + + $aliases = $vc->getAttributeValues('ALIAS'); + if (!is_a($aliases, 'PEAR_Error')) { + $html .= $this->_row(_("Alias"), implode("\n", $aliases)); + } + $birthdays = $vc->getAttributeValues('BDAY'); + if (!is_a($birthdays, 'PEAR_Error')) { + $birthday = new Horde_Date($birthdays[0]); + $html .= $this->_row( + _("Birthday"), + $birthday->strftime($prefs->getValue('date_format'))); + } + + $photos = $vc->getAllAttributes('PHOTO'); + foreach ($photos as $photo) { + if (!isset($photo['params']['VALUE']) || + String::upper($photo['params']['VALUE']) != 'URI') { + continue; + } + $html .= $this->_row(_("Photo"), + '', + false); + } + + $labels = $vc->getAllAttributes('LABEL'); + foreach ($labels as $label) { + if (isset($label['params']['TYPE'])) { + if (!is_array($label['params']['TYPE'])) { + $label['params']['TYPE'] = array($label['params']['TYPE']); + } + } else { + $label['params']['TYPE'] = array_keys($label['params']); + } + $types = array(); + foreach ($label['params']['TYPE'] as $type) { + switch(String::upper($type)) { + case 'HOME': + $types[] = _("Home Address"); + break; + + case 'WORK': + $types[] = _("Work Address"); + break; + + case 'DOM': + $types[] = _("Domestic Address"); + break; + + case 'INTL': + $types[] = _("International Address"); + break; + + case 'POSTAL': + $types[] = _("Postal Address"); + break; + + case 'PARCEL': + $types[] = _("Parcel Address"); + break; + + case 'PREF': + $types[] = _("Preferred Address"); + break; + } + } + if (!count($types)) { + $types = array(_("Address")); + } + $html .= $this->_row(implode('/', $types), $label['value']); + } + + $adrs = $vc->getAllAttributes('ADR'); + foreach ($adrs as $item) { + if (isset($item['params']['TYPE'])) { + if (!is_array($item['params']['TYPE'])) { + $item['params']['TYPE'] = array($item['params']['TYPE']); + } + } else { + $item['params']['TYPE'] = array_keys($item['params']); + } + $address = $item['values']; + $a = array(); + if (isset($address[VCARD_ADR_STREET])) { + $a[] = $address[VCARD_ADR_STREET]; + } + if (isset($address[VCARD_ADR_LOCALITY])) { + $a[] = $address[VCARD_ADR_LOCALITY]; + } + if (isset($address[VCARD_ADR_REGION])) { + $a[] = $address[VCARD_ADR_REGION]; + } + if (isset($address[VCARD_ADR_POSTCODE])) { + $a[] = $address[VCARD_ADR_POSTCODE]; + } + if (isset($address[VCARD_ADR_COUNTRY])) { + $a[] = $address[VCARD_ADR_COUNTRY]; + } + $types = array(); + foreach ($item['params']['TYPE'] as $type) { + switch(String::upper($type)) { + case 'HOME': + $types[] = _("Home Address"); + break; + + case 'WORK': + $types[] = _("Work Address"); + break; + + case 'DOM': + $types[] = _("Domestic Address"); + break; + + case 'INTL': + $types[] = _("International Address"); + break; + + case 'POSTAL': + $types[] = _("Postal Address"); + break; + + case 'PARCEL': + $types[] = _("Parcel Address"); + break; + + case 'PREF': + $types[] = _("Preferred Address"); + break; + } + } + if (!count($types)) { + $types = array(_("Address")); + } + $html .= $this->_row(implode('/', $types), implode("\n", $a)); + } + + $numbers = $vc->getAllAttributes('TEL'); + + foreach ($numbers as $number) { + if (isset($number['params']['TYPE'])) { + if (!is_array($number['params']['TYPE'])) { + $number['params']['TYPE'] = array($number['params']['TYPE']); + } + foreach ($number['params']['TYPE'] as $type) { + $number['params'][String::upper($type)] = true; + } + } + if (isset($number['params']['FAX'])) { + $html .= $this->_row(_("Fax"), $number['value']); + } else { + if (isset($number['params']['HOME'])) { + $html .= $this->_row(_("Home Phone"), + $number['value']); + } elseif (isset($number['params']['WORK'])) { + $html .= $this->_row(_("Work Phone"), + $number['value']); + } elseif (isset($number['params']['CELL'])) { + $html .= $this->_row(_("Cell Phone"), + $number['value']); + } else { + $html .= $this->_row(_("Phone"), + $number['value']); + } + } + } + + $addresses = $vc->getAllAttributes('EMAIL'); + $emails = array(); + foreach ($addresses as $address) { + if (isset($address['params']['TYPE'])) { + if (!is_array($address['params']['TYPE'])) { + $address['params']['TYPE'] = array($address['params']['TYPE']); + } + foreach ($address['params']['TYPE'] as $type) { + $address['params'][String::upper($type)] = true; + } + } + $email = '' . htmlspecialchars($address['value']) . ''; + if (isset($address['params']['PREF'])) { + array_unshift($emails, $email); + } else { + $emails[] = $email; + } + } + + if (count($emails)) { + $html .= $this->_row(_("Email"), implode("\n", $emails), false); + } + + $title = $vc->getAttributeValues('TITLE'); + if (!is_a($title, 'PEAR_Error')) { + $html .= $this->_row(_("Title"), $title[0]); + } + + $role = $vc->getAttributeValues('ROLE'); + if (!is_a($role, 'PEAR_Error')) { + $html .= $this->_row(_("Role"), $role[0]); + } + + $org = $vc->getAttributeValues('ORG'); + if (!is_a($org, 'PEAR_Error')) { + $html .= $this->_row(_("Company"), $org[0]); + if (isset($org[1])) { + $html .= $this->_row(_("Department"), $org[1]); + } + } + + $notes = $vc->getAttributeValues('NOTE'); + if (!is_a($notes, 'PEAR_Error')) { + $html .= $this->_row(_("Notes"), $notes[0]); + } + + $url = $vc->getAttributeValues('URL'); + if (!is_a($url, 'PEAR_Error')) { + $html .= $this->_row( + _("URL"), + '' . htmlspecialchars($url[0]) + . '', + false); + } + } + + if ($registry->hasMethod('contacts/import') && + $registry->hasMethod('contacts/sources')) { + $html .= ''; + } + + $html .= '
 
'; + $fullname = $vc->getAttributeDefault('FN', false); + if ($fullname !== false) { + $html .= $fullname; + } + $html .= '
' + . Util::formInput(); + foreach ($_GET as $key => $val) { + $html .= ''; + } + + $sources = $registry->call('contacts/sources', array(true)); + if (count($sources) > 1) { + $html .= + '' + . '' + . '' + . ''; + } + + $html .= '
 
'; + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } + + /** + * TODO + */ + protected function _row($label, $value, $encode = true) + { + if ($encode) { + $label = htmlspecialchars($label); + $value = htmlspecialchars($value); + } + return '' . $label . + '' . nl2br($value) . + "\n"; + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php b/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php new file mode 100644 index 000000000..b59e6bb1d --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Webcpp.php @@ -0,0 +1,110 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Webcpp extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_toHTML(); + + /* The first 2 lines are the Content-Type line and a blank line so + * remove them before outputting. */ + reset($ret); + $ret[key($ret)]['data'] = preg_replace("/.*\n.*\n/", '', $ret[key($ret)]['data'], 1); + + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $ret = $this->_toHTML(); + reset($ret); + $data = $ret[key($ret)]['data']; + + /* Extract the style sheet, removing any global body formatting + * if we're displaying inline. */ + $res = preg_split(';()|(
' . $body . '
'; + + return $ret; + } + + /** + * Converts the code to HTML. + * + * @return string The HTML-ified version of the MIME part contents. + */ + protected function _toHTML() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + /* Create temporary files for Webcpp. */ + $tmpin = Horde::getTempFile('WebcppIn'); + $tmpout = Horde::getTempFile('WebcppOut'); + + /* Write the contents of our buffer to the temporary input file. */ + file_put_contents($tmpin, $this->_mimepart->getContents()); + + /* Get the extension for the mime type. */ + $ext = Horde_Mime_Magic::MIMEToExt($this->_mimepart->getType()); + + /* Execute Web C Plus Plus. Specifying the in and out files didn't + * work for me but pipes did. */ + exec($this->_conf['location'] . " --pipe --pipe -x=$ext -l -a -t < $tmpin > $tmpout"); + $results = file_get_contents($tmpout); + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $results, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php b/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php new file mode 100644 index 000000000..8027e23a4 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Wordperfect.php @@ -0,0 +1,65 @@ + + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => false, + 'inline' => false + ); + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + /* Check to make sure the viewer program exists. */ + if (!isset($this->_conf['location']) || + !file_exists($this->_conf['location'])) { + return array(); + } + + $tmp_wpd = Horde::getTempFile('wpd'); + $tmp_output = Horde::getTempFile('wpd'); + + file_put_contents($tmp_wpd, $this->_mimepart->getContents()); + + exec($this->_conf['location'] . " $tmp_wpd > $tmp_output"); + + if (file_exists($tmp_output)) { + $data = file_get_contents($tmp_output); + } else { + $data = _("Unable to translate this WordPerfect document"); + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Zip.php b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php new file mode 100644 index 000000000..3dac1c8f5 --- /dev/null +++ b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php @@ -0,0 +1,147 @@ + + * @author Michael Cochrane + * @package Horde_Mime_Viewer + */ +class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver +{ + /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => true, + 'full' => true, + 'info' => false, + 'inline' => true + ); + + /** + * A callback function to use in _toHTML(). + * + * @var callback + */ + protected $_callback = null; + + /** + * Return the full rendered version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _render() + { + $ret = $this->_toHTML(); + if (!empty($ret)) { + reset($ret); + $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; + } + return $ret; + } + + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + return $this->_toHTML(); + } + + /** + * Converts the ZIP file to an HTML display. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _toHTML() + { + $contents = $this->_mimepart->getContents(); + + $zip = &Horde_Compress::singleton('zip'); + + /* Make sure this is a valid zip file. */ + if ($zip->checkZipData($contents) === false) { + return array(); + } + + $zipInfo = $zip->decompress($contents, array('action' => HORDE_COMPRESS_ZIP_LIST)); + if (is_a($zipInfo, 'PEAR_Error')) { + return array(); + } + $fileCount = count($zipInfo); + + /* Determine maximum file name length. */ + $max_array = array(); + foreach ($zipInfo as $val) { + $max_array[] = strlen($val['name']); + } + $maxlen = empty($max_array) ? 0 : max($max_array); + + require_once 'Horde/Text.php'; + + $name = $this->_mimepart->getName(true); + if (empty($name)) { + $name = _("unnamed"); + } + + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + '
' . + Text::htmlAllSpaces( + _("Archive Name") . ': ' . $name . "\n" . + _("Archive File Size") . ': ' . strlen($contents) . + ' bytes' . "\n" . + sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) . + "\n\n" . + String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) . + String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) . + String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("CRC"), 10, ' ', STR_PAD_LEFT) . + String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) . + "\n" + ) . str_repeat('-', 69 + $maxlen) . "\n"; + + foreach ($zipInfo as $key => $val) { + $ratio = (empty($val['size'])) + ? 0 + : 100 * ($val['csize'] / $val['size']); + + $val['name'] = String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT); + $val['attr'] = String::pad($val['attr'], 10,' ', STR_PAD_LEFT); + $val['size'] = String::pad($val['size'], 10, ' ', STR_PAD_LEFT); + $val['date'] = String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT); + $val['method'] = String::pad($val['method'], 10, ' ', STR_PAD_LEFT); + $val['crc'] = String::pad($val['crc'], 10, ' ', STR_PAD_LEFT); + $val['ratio'] = String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT); + + $val = array_map(array('Text', 'htmlAllSpaces'), $val); + if (!is_null($this->_callback)) { + $val = call_user_func($this->_callback, $key, $val); + } + + $text .= $val['name'] . $val['attr'] . $val['size'] . + $val['date'] . $val['method'] . $val['crc'] . $val['ratio'] . + "\n"; + } + + return array( + $this->_mimepart->getMimeId() => array( + 'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '
'), + 'status' => array(), + 'type' => 'text/html; charset=' . NLS::getCharset() + ) + ); + } +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/audio.php b/framework/Mime/lib/Horde/Mime/Viewer/audio.php deleted file mode 100644 index 317c93679..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/audio.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_audio extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_mimepart->getContents(), - 'status' => array(), - 'type' => $this->_mimepart->getType() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/css.php b/framework/Mime/lib/Horde/Mime/Viewer/css.php deleted file mode 100644 index de16c9dc6..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/css.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_css extends Horde_Mime_Viewer_source -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Attribute preg patterns. - * - * @var array - */ - protected $_attrPatterns = array( - // Attributes - '!([-\w]+\s*):!s' => '\\1:', - // Values - '!:(\s*)(.+?)(\s*;)!s' => ':\\1\\2\\3', - // URLs - '!(url\([\'"]?)(.*?)([\'"]?\))!s' => '\\1\\2\\3', - // Colors - '!(#[[:xdigit:]]{3,6})!s' => '\\1', - // Parentheses - '!({|})!s' => '\\1', - // Unity - '!(em|px|%)\b!s' => '\\1' - ); - - /** - * Handles preg patterns. - * - * @var array - */ - protected $_handlesPatterns = array( - // HTML Tags - '!\b(body|h\d|a|span|div|acronym|small|strong|em|pre|ul|ol|li|p)\b!s' => '\\1\\2', - // IDs - '!(#[-\w]+)!s' => '\\1', - // Class - '!(\.[-\w]+)\b!s' => '\\1', - // METAs - '!(:link|:visited|:hover|:active|:first-letter)!s' => '\\1' - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - - // Need Horde headers for CSS tags. - reset($ret); - $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . - $ret[key($ret)]['data'] . - Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); - - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $css = preg_replace_callback('!(}|\*/).*?({|/\*)!s', array($this, '_handles'), htmlspecialchars($this->_mimepart->getContents(), ENT_NOQUOTES)); - $css = preg_replace_callback('!{[^}]*}!s', array($this, '_attributes'), $css); - $css = preg_replace_callback('!/\*.*?\*/!s', array($this, '_comments'), $css); - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_lineNumber(trim($css)), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * TODO - */ - protected function _comments($matches) - { - return '' . - preg_replace('!(http://[/\w-.]+)!s', '\\1', $matches[0]) . - ''; - } - - /** - * TODO - */ - protected function _attributes($matches) - { - return preg_replace(array_keys($this->_attrPatterns), array_values($this->_attrPatterns), $matches[0]); - } - - /** - * TODO - */ - protected function _handles($matches) - { - return preg_replace(array_keys($this->_handlesPatterns), array_values($this->_handlesPatterns), $matches[0]); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/deb.php b/framework/Mime/lib/Horde/Mime/Viewer/deb.php deleted file mode 100644 index a942f3832..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/deb.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_deb extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - if (!empty($ret)) { - reset($ret); - $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; - } - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $tmp_deb = Horde::getTempFile('horde_deb'); - - file_put_contents($tmp_deb, $this->_mimepart->getContents()); - - $fh = popen($this->_conf['location'] . " -f $tmp_deb 2>&1", 'r'); - while (($rc = fgets($fh, 8192))) { - $data .= $rc; - } - pclose($fh); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => '
' . htmlspecialchars($data) . '
', - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/default.php b/framework/Mime/lib/Horde/Mime/Viewer/default.php deleted file mode 100644 index 35f06ccb1..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/default.php +++ /dev/null @@ -1,17 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_default extends Horde_Mime_Viewer_Driver -{ -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/enriched.php b/framework/Mime/lib/Horde/Mime/Viewer/enriched.php deleted file mode 100644 index cea2e472b..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/enriched.php +++ /dev/null @@ -1,198 +0,0 @@ - command and the next balancing - * removes all other formatting commands (all text enclosed - * in angle brackets), and outside of environments converts - * any series of n CRLFs to n-1 CRLFs, and converts any lone CRLF - * pairs to SPACE. - * - * We don't qualify as we don't currently track the - * environment, that is we do CRLF conversion even if is - * specified in the text, but we're close at least. - * - * Copyright 2001-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Eric Rostetter - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_enriched extends Horde_Mime_Viewer_Driver -{ - /** - * This driver's capabilities. - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => '' . $this->_toHTML() . '', - 'status' => array(), - 'type' => 'text/html; charset=' . $this->_mimepart->getCharset() - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Convert the enriched text to HTML. - * - * @return string The HTML-ified version of the MIME part contents. - */ - protected function _toHTML() - { - $text = trim($this->_mimepart->getContents()); - if (!strlen($text)) { - return array(); - } - - // We add space at the beginning and end of the string as it will - // make some regular expression checks later much easier (so we - // don't have to worry about start/end of line characters) - $text = ' ' . $text . ' '; - - // We need to preserve << tags, so map them to ascii 1 or ascii 255 - // We make the assumption here that there would never be an ascii - // 1 in an email, which may not be valid, but seems reasonable... - // ascii 255 would work if for some reason you don't like ascii 1 - // ascii 0 does NOT seem to work for this, though I'm not sure why - $text = str_replace('<<', chr(1), $text); - - // Remove any unrecognized tags in the text (via RFC minimal specs) - // any tags we just don't want to implement can also be removed here - // Note that this will remove any html links, but this is intended - $implementedTags = '' . - '
' . - ''; - // $unImplementedTags = ''; - $text = strip_tags($text, $implementedTags); - - // restore the << tags as < tags now... - $text = str_replace(chr(1), '<<', $text); - // $text = str_replace(chr(255), '<', $text); - - $replace = array( - // Get color parameters into a more useable format. - '/([\da-fA-F]+),([\da-fA-F]+),([\da-fA-F]+)<\/param>/Uis' => '', - '/(red|blue|green|yellow|cyan|magenta|black|white)<\/param>/Uis' => '', - - // Get font family parameters into a more useable format. - '/(\w+)<\/param>/Uis' => '', - - /* Just remove any remaining parameters -- we won't use them. - * Any tags with parameters that we want to implement will have - * come before this. Someday we hope to use these tags (e.g. for - * tags). */ - '/.*<\/param>/Uis' => '', - - /* Single line breaks become spaces, double line breaks are a - * real break. This needs to do tracking to be compliant - * but we don't want to deal with state at this time, so we fake - * it some day we should rewrite this to handle - * correctly. */ - '/([^\n])\r\n([^\r])/' => '\1 \2', - '/(\r\n)\r\n/' => '\1' - ); - $text = preg_replace(array_keys($replace), array_values($replace), $text); - - // We try to protect against bad stuff here. - $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset()); - - // Now convert the known tags to html. Try to remove any tag - // parameters to stop people from trying to pull a fast one - $replace = array( - '/(? '\1', - '/(? '\1', - '/(? '\1' - ); - $text = preg_replace(array_keys($replace), array_values($replace), $text); - - $text = preg_replace_callback('/(? '\2', - '/(? '\1', - '/(? '\2', - '/(? '', - '/(? '', - '/(? '', - '/(? '', - '/(? '\1', - '/(? '
\1
', - '/(? '
\1
', - '/(? '
\1
', - '/(? '
\1
', - '/(? '
\1
', - '/(? '
\1
' - ); - $text = preg_replace(array_keys($replace), array_values($replace), $text); - - // Replace << with < now (from translated HTML form). - $text = str_replace('<<', '<', $text); - - // Now we remove the leading/trailing space we added at the - // start. - $text = preg_replace('/^ (.*) $/s', '\1', $text); - - // Make URLs clickable. - require_once 'Horde/Text/Filter.php'; - $text = Text_Filter::filter($text, 'linkurls', array('callback' => 'Horde::externalUrl')); - - /* Wordwrap -- note this could impact on our above RFC compliance *IF* - * we honored nofill tags (which we don't yet). */ - $text = str_replace(array("\t", ' ', "\n "), array(' ', '  ', "\n "), $text); - - if ($text[0] == ' ') { - $text = ' ' . substr($text, 1); - } - - return '

' . nl2br($text) . '

'; - } - - /** - * TODO - */ - public function colorize($colors) - { - for ($i = 1; $i < 4; $i++) { - $colors[$i] = sprintf('%02X', round(hexdec($colors[$i]) / 255)); - } - return '' . $colors[4] . ''; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/enscript.php b/framework/Mime/lib/Horde/Mime/Viewer/enscript.php deleted file mode 100644 index 6f1b10d67..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/enscript.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_enscript extends Horde_Mime_Viewer_source -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_toHTML(false), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_toHTML(true), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Converts the code to HTML. - * - * @param boolean $inline Is this an inline display? - * - * @return string The HTML-ified version of the MIME part contents. - */ - protected function _toHTML($inline) - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - /* Create temporary files for input to Enscript. Note that we can't - * use a pipe, since enscript must have access to the whole file to - * determine its type for coloured syntax highlighting. */ - $tmpin = Horde::getTempFile('enscriptin'); - - /* Write the contents of our buffer to the temporary input file. */ - file_put_contents($tmpin, $this->_mimepart->getContents()); - - /* Execute the enscript command. */ - $lang = escapeshellarg($this->_typeToLang($this->_mimepart->getType())); - $results = shell_exec($this->_conf['location'] . " -E$lang --language=html --color --output=- < $tmpin"); - - /* Strip out the extraneous HTML from enscript. */ - if ($inline) { - $res_arr = preg_split('/\<\/?pre\>/i', $results); - if (count($res_arr) == 3) { - $results = trim($res_arr[1]); - } - } - - return $this->_lineNumber($results); - } - - /** - * Attempts to determine what language to use for the enscript program - * from a MIME type. - * - * @param string $type The MIME type. - * - * @return string The enscript 'language' parameter string. - */ - protected function _typeToLang($type) - { - include_once dirname(__FILE__) . '/../Magic.php'; - $ext = Horde_Mime_Magic::MIMEToExt($type); - - switch ($ext) { - case 'cs': - return 'java'; - - case 'el': - return 'elisp'; - - case 'h': - return 'c'; - - case 'C': - case 'H': - case 'cc': - case 'hh': - case 'c++': - case 'cxx': - case 'cpp': - return 'cpp'; - - case 'htm': - case 'shtml': - case 'xml': - return 'html'; - - case 'js': - return 'javascript'; - - case 'pas': - return 'pascal'; - - case 'al': - case 'cgi': - case 'pl': - case 'pm': - return 'perl'; - - case 'ps': - return 'postscript'; - - case 'vb': - return 'vba'; - - case 'vhd': - return 'vhdl'; - - case 'patch': - case 'diff': - return 'diffu'; - - default: - return $ext; - } - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/html.php b/framework/Mime/lib/Horde/Mime/Viewer/html.php deleted file mode 100644 index 0008b4de3..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/html.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @author Jon Parise - * @author Michael Slusarz - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $html = $this->_cleanHTML($this->_mimepart->getContents(), false); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $html['html'], - 'status' => array(), - 'type' => $this->_mimepart->getType(true) - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $html = $this->_cleanHTML($this->_mimepart->getContents(), true); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => String::convertCharset($html['data'], $this->_mimepart->getCharset()), - 'status' => $html['status'], - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Filters active content, dereferences external links, detects phishing, - * etc. - * - * @todo Use IP checks from - * http://lxr.mozilla.org/mailnews/source/mail/base/content/phishingDetector.js. - * - * @param string $data The HTML data. - * @param boolean $inline Are we viewing inline? - * - * @return array Two elements: 'html' and 'status'. - */ - protected function _cleanHTML($data, $inline) - { - global $browser, $prefs; - - $phish_warn = false; - - /* Deal with tags in the HTML, since they will screw up our own - * relative paths. */ - if (preg_match('/ ]*)"? ?\/?>/i', $data, $matches)) { - $base = $matches[1]; - if (substr($base, -1) != '/') { - $base .= '/'; - } - - /* Recursively call _cleanHTML() to prevent clever fiends from - * sneaking nasty things into the page via $base. */ - $base = $this->_cleanHTML($base, $inline); - - /* Attempt to fix paths that were relying on a tag. */ - if (!empty($base)) { - $pattern = array('|src=(["\'])([^:"\']+)\1|i', - '|src=([^: >"\']+)|i', - '|href= *(["\'])([^:"\']+)\1|i', - '|href=([^: >"\']+)|i'); - $replace = array('src=\1' . $base . '\2\1', - 'src=' . $base . '\1', - 'href=\1' . $base . '\2\1', - 'href=' . $base . '\1'); - $data = preg_replace($pattern, $replace, $data); - } - } - - require_once 'Horde/Text/Filter.php'; - $strip_style_attributes = (($browser->isBrowser('mozilla') && - $browser->getMajor() == 4) || - $browser->isBrowser('msie')); - $strip_styles = $inline || $strip_style_attributes; - $data = Text_Filter::filter($data, 'xss', - array('body_only' => $inline, - 'strip_styles' => $strip_styles, - 'strip_style_attributes' => $strip_style_attributes)); - - /* Check for phishing exploits. */ - if ($this->getConfigParam('phishing_check')) { - if (preg_match('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:[^>]*>\s*(?:\\1:\/\/)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[^<]*<\/a)?/i', $data, $m)) { - /* Check 1: Check for IP address links, but ignore if the link - * text has the same IP address. */ - if (!isset($m[3]) || ($m[2] != $m[3])) { - if (isset($m[3])) { - $data = preg_replace('/href\s*=\s*["\']?\s*(http|https|ftp):\/\/' . preg_quote($m[2], '/') . '(?:[^>]*>\s*(?:$1:\/\/)?' . preg_quote($m[3], '/') . '[^<]*<\/a)?/i', 'class="mimeStatusWarning" $0', $data); - } - $phish_warn = true; - } - } elseif (preg_match_all('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/([^\s"\'>]+)["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?(.*?)<\/a/is', $data, $m)) { - /* $m[1] = Link; $m[2] = Target - * Check 2: Check for links that point to a different host than - * the target url; if target looks like a domain name, check it - * against the link. */ - for ($i = 0, $links = count($m[0]); $i < $links; ++$i) { - $link = strtolower(urldecode($m[1][$i])); - $target = strtolower(preg_replace('/^(http|https|ftp):\/\//', '', strip_tags($m[2][$i]))); - if (preg_match('/^[-._\da-z]+\.[a-z]{2,}/i', $target) && - (strpos($link, $target) !== 0) && - (strpos($target, $link) !== 0)) { - /* Don't consider the link a phishing link if the - * domain is the same on both links (e.g. - * adtracking.example.com & www.example.com). */ - preg_match('/\.?([^\.\/]+\.[^\.\/]+)[\/?]/', $link, $host1); - preg_match('/\.?([^\.\/]+\.[^\.\/ ]+)([\/ ].*)?$/', $target, $host2); - if (!(count($host1) && count($host2)) || - (strcasecmp($host1[1], $host2[1]) !== 0)) { - $data = preg_replace('/href\s*=\s*["\']?\s*(?:http|https|ftp):\/\/' . preg_quote($m[1][$i], '/') . '["\']?[^>]*>\s*(?:(?:http|https|ftp):\/\/)?' . preg_quote($m[2][$i], '/') . '<\/a/is', 'class="mimeStatusWarning" $0', $data); - $phish_warn = true; - } - } - } - } - } - - /* Try to derefer all external references. */ - $data = preg_replace_callback('/href\s*=\s*(["\'])?((?(1)[^\1]*?|[^\s>]+))(?(1)\1|)/i', array($this, '_dereferCallback'), $data); - - /* Get phishing warning. */ - $status = array(); - if ($inline && $phish_warn) { - $warning = array( - sprintf(_("%s: This message may not be from whom it claims to be. Beware of following any links in it or of providing the sender with any personal information."), _("Warning")), - _("The links that caused this warning have this background color:") . ' ' . _("EXAMPLE") . '.' - ); - - if (!$inline) { - $temp = array(); - foreach ($phish_warning as $val) { - $temp[] = String::convertCharset($val, NLS::getCharset(), $this->_mimepart->getCharset()); - } - $warning = $temp; - } - - $status[] = array( - 'class' => 'mimestatuswarning', - 'text' => $warning - ); - } - - return array('html' => $data, 'status' => $status); - } - - /** - * TODO - * - * @param string $m TODO - * - * @return string TODO - */ - protected function _dereferCallback($m) - { - return 'href="' . Horde::externalUrl($m[2]) . '"'; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/images.php b/framework/Mime/lib/Horde/Mime/Viewer/images.php deleted file mode 100644 index 2dcde0e24..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/images.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_images extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_mimepart->getContents(), - 'status' => array(), - 'type' => $this->_getType() - ) - ); - } - - /** - * Return the content-type to use for the image. - * - * @return string The content-type of the image. - */ - protected function _getType() - { - $type = $this->_mimepart->getType(); - - switch ($type) { - case 'image/pjpeg': - /* image/jpeg and image/pjpeg *appear* to be the same entity, but - * Mozilla (for one) don't seem to want to accept the latter. */ - return 'image/jpeg'; - - case 'image/x-png': - /* image/x-png == image/png. */ - return 'image/png'; - - default: - return $type; - } - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/msexcel.php b/framework/Mime/lib/Horde/Mime/Viewer/msexcel.php deleted file mode 100644 index 56b8f344f..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/msexcel.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_msexcel extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $tmp_xls = Horde::getTempFile('horde_msexcel'); - $tmp_out = Horde::getTempFile('horde_msexcel'); - - file_put_contents($tmp_xls, $this->_mimepart->getContents()); - $args = ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_xls . ' ' . $tmp_out; - - exec($this->_conf['location'] . $args); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => file_get_contents($tmp_out), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/mspowerpoint.php b/framework/Mime/lib/Horde/Mime/Viewer/mspowerpoint.php deleted file mode 100644 index f72c455d4..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/mspowerpoint.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_mspowerpoint extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $data = ''; - $tmp_ppt = Horde::getTempFile('horde_mspowerpoint'); - - file_put_contents($tmp_ppt, $this->_mimepart->getContents()); - - $fh = popen($this->_conf['location'] . " $tmp_ppt 2>&1", 'r'); - while (($rc = fgets($fh, 8192))) { - $data .= $rc; - } - pclose($fh); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/msword.php b/framework/Mime/lib/Horde/Mime/Viewer/msword.php deleted file mode 100644 index 945ee9b62..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/msword.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_msword extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $tmp_word = Horde::getTempFile('msword'); - $tmp_output = Horde::getTempFile('msword'); - $tmp_file = str_replace(Horde::getTempDir() . '/', '', $tmp_output); - - file_put_contents($tmp_word, $this->_mimepart->getContents()); - $args = ' --to=html --to-name=' . $tmp_output . ' ' . $tmp_word; - - exec($this->_conf['location'] . $args); - - if (file_exists($tmp_output)) { - $data = file_get_contents($tmp_output); - $type = 'text/html'; - } else { - $data = _("Unable to translate this Word document"); - $type = 'text/plain'; - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => $type . '; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo.php b/framework/Mime/lib/Horde/Mime/Viewer/ooo.php deleted file mode 100644 index 8554b3824..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @author Jan Schneider - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_ooo extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $has_xslt = Util::extensionExists('xslt'); - $has_ssfile = function_exists('domxml_xslt_stylesheet_file'); - if (($use_xslt = $has_xslt || $has_ssfile)) { - $tmpdir = Util::createTempDir(true); - } - - $fnames = array('content.xml', 'styles.xml', 'meta.xml'); - $tags = array( - 'text:p' => 'p', - 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ', - 'table:table-row' => 'tr bgcolor="#cccccc"', - 'table:table-cell' => 'td', - 'table:number-columns-spanned=' => 'colspan=' - ); - - require_once 'Horde/Compress.php'; - $zip = &Horde_Compress::singleton('zip'); - $list = $zip->decompress($this->_mimepart->getContents(), array('action' => HORDE_COMPRESS_ZIP_LIST)); - - foreach ($list as $key => $file) { - if (in_array($file['name'], $fnames)) { - $content = $zip->decompress($this->_mimepart->getContents(), array( - 'action' => HORDE_COMPRESS_ZIP_DATA, - 'info' => $list, - 'key' => $key - )); - - if ($use_xslt) { - file_put_contents($tmpdir . $file['name'], $content); - } elseif ($file['name'] == 'content.xml') { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => str_replace(array_keys($tags), array_values($tags), $content), - 'status' => array(), - 'type' => 'text/html; charset=UTF-8' - ) - ); - } - } - } - - if (!Util::extensionExists('xslt')) { - return array(); - } - - $xsl_file = dirname(__FILE__) . '/ooo/main_html.xsl'; - - if ($has_ssfile) { - /* Use DOMXML */ - $xslt = domxml_xslt_stylesheet_file($xsl_file); - $dom = domxml_open_file($tmpdir . 'content.xml'); - $result = @$xslt->process($dom, array( - 'metaFileURL' => $tmpdir . 'meta.xml', - 'stylesFileURL' => $tmpdir . 'styles.xml', - 'disableJava' => true) - ); - $result = $xslt->result_dump_mem($result); - } else { - // Use XSLT - $xslt = xslt_create(); - $result = @xslt_process($xslt, $tmpdir . 'content.xml', $xsl_file, null, null, array( - 'metaFileURL' => $tmpdir . 'meta.xml', - 'stylesFileURL' => $tmpdir . 'styles.xml', - 'disableJava' => true) - ); - if (!$result) { - $result = xslt_error($xslt); - } - xslt_free($xslt); - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $result, - 'status' => array(), - 'type' => 'text/html; charset=UTF-8' - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/common.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/common.xsl deleted file mode 100644 index 943a5b995..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/common.xsl +++ /dev/null @@ -1,1165 +0,0 @@ - - - - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - height: ; - - - width: ; - - - height: ; - width: ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - margin-left:; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -     - - - - - - - - - - - - - - - - - - - - - - - -     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * - * - - - - - - - - - - - - * - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/global_document.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/global_document.xsl deleted file mode 100644 index fc4579ef3..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/global_document.xsl +++ /dev/null @@ -1,1674 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Matching child document header No. - absolute-chapter-level: - encodedTitle: - globalDocumentRefToCurrentFile: - *** - - - - - - + - - - - - - - - - - - - - - - - - - Matching global document header No. - absolute-chapter-level: - encodedTitle: - contentTableURL: - *** - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - Creation of global document helper variable for the content table.... - - - - - - - - - - - - - - - - - Finished the Creation of global document helper variable for the content table! - - - - - Creation of global document helper variable for the child documents.... - - - - - - Finished the Creation of global document helper variable for the child documents! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - level: - title: - encoded-title: - file-url: - header-no: - ** - - ** - ** - - - childrenHeadings/heading-count: - - # - title: - ** - - - - - - - - - - - - - - - - - - Creating global document variable for chapter relations.... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Finished global document variable for chapter relations! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *** new heading - currentChapterID: - currentChapterTitle: - currentChapterID: - currentHeadingNo: - headingTitle: - headingLevel: - headingNo: - newChildURL: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - only a heading, but not a chapter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - All child documents have been walked through without finding the chapter name! - childrenHeadings/heading-count: - currentHeadingNo: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Parsing the global document... - - - - - - - - Parsing the child documents... - - - - - - - - - - - - - Starting the child transformations... - - - - - - Contentable data exists as global data! - - - No Contentable global data exists! - - - - - - - - - - - - - Java method transformChildren to transform all children of a global document could not be found. Be sure to use the XT processor. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Previous document - - - | - - - - - - - - - - - - - - - - - - # - - - - - - Content Table - - - - - - | - - - - - - - - - - - - - - - - - - - - - Next document - - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - **** THE HEADING VARIABLE **** - content-table-url: - - - **** new heading: - content-table-id: - child-document-no: - file-url: - out-file-url: - level: - title: - encoded-title: - absolute-chapter-level: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - width: - - - - - - - - - - - - - - - - - - - - - - - - - - - - align: right - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/main_html.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/main_html.xsl deleted file mode 100644 index 443182a3e..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/main_html.xsl +++ /dev/null @@ -1,462 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CSS helper variable will be created.... - - CSS variable ready, header will be created.... - - - CSS header creation finished! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Creating the inline styles.... - - - - - Time for instantiating style variable: ms - - - - - - Creating the inline styles.... - - - - - Time for instantiating style variable: ms - - - - - - - - - - - Parameter dpi: - Parameter metaFileURL: - Parameter stylesFileURL: - Parameter absoluteSourceDirRef: - Parameter precedingChapterLevel1 : - Parameter precedingChapterLevel2 : - Parameter precedingChapterLevel3 : - Parameter precedingChapterLevel4 : - Parameter precedingChapterLevel5 : - Parameter precedingChapterLevel6 : - Parameter precedingChapterLevel7 : - Parameter precedingChapterLevel8 : - Parameter precedingChapterLevel9 : - Parameter precedingChapterLevel10: - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/palm.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/palm.xsl deleted file mode 100644 index 212edb167..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/palm.xsl +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - - PalmComputingPlatform - true - - - HandheldFriendly - true - - - HistoryListText - Dateimanager : &date &time - - - description - StarPortal - - - keywords - starportal, staroffice, software - - - Content-Type - text/html; charset=iso-8859-1 - - - - - - - - - - - - - - - - - left - - - right - - - center - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - left - - - right - - - center - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #000000 - - - #FFFFFF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #000000 - - - #FFFFFF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_header.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_header.xsl deleted file mode 100644 index eeb0c204a..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_header.xsl +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - - The CSS style header method for setting styles - - - text/css - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *.OOo_defaults - - - , - - - - - , - - - - { - margin-top:0cm; margin-bottom:0cm; } - - - - - - - - - - - - - - - - - - - - - - , - - - - - , - - - - - - - - - - - - - - { - - - } - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_inlined.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_inlined.xsl deleted file mode 100644 index 19159958c..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_inlined.xsl +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_mapping.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_mapping.xsl deleted file mode 100644 index a9a858dc0..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/style_mapping.xsl +++ /dev/null @@ -1,660 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - float: right; - - - float: left; - - - - - - - - align: left; - - - align: right; - - - align: center; - - - - - - - - padding: - - ; - - - - - - - - - border-width:; - border-style:; - border-color:; - - - border-width:; - border-style:; - border-color:; - - - border-width:; - border-style:; - border-color:; - - - - - border-top: ; - - - border-bottom: ; - - - border-left: ; - - - border-right: ; - - - - - - width:; - - - width:; - - - - - - - - height:; - - - height:; - - - - - - - - width:; - - - width:; - - - - - - :; - - - font-family: - - - ; - - font-style:italic; - - - font-weight:bold; - - - - :; - - - :; - - - :; - - - :; - - - :; - - - :; - - - :; - - - :; - - - :; - - - - - - text-align:left ! important; - - - text-align:right ! important; - - - text-align: ! important; - - - - - :; - - - background-color:; - - - background-color:; - - - background-image:url(); - - - background-repeat:repeat; - - - background-repeat:no-repeat; - - - - - - :; - - - - text-decoration:line-through; - - - - - text-decoration:underline; - - - - - vertical-align:sub; - - - vertical-align:sup; - - - - - - - - - - - - - - - - - - - italic, - - - - - - - bold, - - - - - - underline, - - - - - - - align:left, - - - align:right, - - - align:center, - - - - - - - strike, - - - - - size::size, - - - - - - - color:#FFFFFF, - - - color:#000000, - - - - - - - - size::size, - - - - - - width::width, - - - width::width; - - - - - - - - height::height; - - - height::height; - - - - - - - - width::width; - - - width::width; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/table.xsl deleted file mode 100644 index 36339ed73..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table.xsl +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - left - - - right - - - center - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - maxRowLength: - - numberOfHiddenColumns: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - #000000 - 2 - 0 - page-break-inside:avoid - - - - - - - - - - - - - - - - Time for checking BorderStyle: ms - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_cells.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_cells.xsl deleted file mode 100644 index 4671ea96f..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_cells.xsl +++ /dev/null @@ -1,484 +0,0 @@ - - - - - - - - - - - - - - - - - - ---------------> table:table-cell has been entered with node value: - table:number-columns-repeated: -- - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NEW VALUE: column-position: -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +++++++++ starting cell writing +++++++++ - number-columns-repeated: -- - maxRowLength: -- - column-position: -- - - - - - - - - - - - - +++++++++ cell repetition +++++++++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WriteTest -> If nothing between '-' write cell -- - - - - - TABLE COLUMN is hidden! - - - - - - - - TABLE COLUMN is hidden! - - - - - - - - - - - th - - - td - - - - - - - - - - - -*****************************************'' element has been added! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text-align:right; - text-align:left; - - - - - - - - - - - - - - - - - - - - text-align:right; - - - text-align:left; - - - - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text-align:right; - - - text-align:left; - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - ; - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_columns.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_columns.xsl deleted file mode 100644 index a9a907ff8..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_columns.xsl +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out. - In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out. - - - - - column is hidden - - - - = - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_rows.xsl b/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_rows.xsl deleted file mode 100644 index 6f7d17d62..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/ooo/table_rows.xsl +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*************************'tr' element has been added! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/Mime/lib/Horde/Mime/Viewer/pdf.php b/framework/Mime/lib/Horde/Mime/Viewer/pdf.php deleted file mode 100644 index 1260a2a9e..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/pdf.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_pdf extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_mimepart->getContents(), - 'status' => array(), - 'type' => 'application/pdf' - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/php.php b/framework/Mime/lib/Horde/Mime/Viewer/php.php deleted file mode 100644 index b9b620e0a..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/php.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_php extends Horde_Mime_Viewer_source -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - - // Need Horde headers for CSS tags. - reset($ret); - $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . - $ret[key($ret)]['data'] . - Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); - - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - ini_set('highlight.comment', 'comment'); - ini_set('highlight.default', 'default'); - ini_set('highlight.keyword', 'keyword'); - ini_set('highlight.string', 'string'); - ini_set('highlight.html', 'html'); - - $code = $this->_mimepart->getContents(); - $text = (strpos($code, '_lineNumber(str_replace('<?php ', '', highlight_string('_lineNumber(highlight_string($code, true)); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $text, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Add line numbers to a block of code. - * - * @param string $code The code to number. - * - * @return string The code with line numbers added. - */ - protected function _lineNumber($code, $linebreak = "\n") - { - // Clean up. - $code = preg_replace( - array( - '/\s*/', - '/\s*/', - '/\s*<\/span>\s*<\/span>\s*<\/code>/', - '/\s*<\/font>\s*<\/font>\s*<\/code>/' - ), '', $code); - - $code = str_replace( - array(' ', '&', '
', '',), - array(' ', '&', "\n", '',), - $code); - - $code = trim($code); - - // Normalize newlines. - $code = str_replace("\r", '', $code); - $code = preg_replace('/\n\n\n+/', "\n\n", $code); - - $results = array('
    '); - $previous = false; - - $lines = explode("\n", $code); - reset($lines); - while (list($lineno, $line) = each($lines)) { - if (substr($line, 0, 7) == '') { - $previous = false; - $line = substr($line, 7); - } - - if (empty($line)) { - $line = ' '; - } - - if ($previous) { - $line = "" . $line; - } - - // Save the previous style. - if (strpos($line, '') { - $previous = false; - } elseif ($previous) { - $line .= ''; - } - - $results[] = '
  1. ' . $line . '
  2. '; - } - - $results[] = '
'; - - return implode("\n", $results); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/plain.php b/framework/Mime/lib/Horde/Mime/Viewer/plain.php deleted file mode 100644 index 138e92baf..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/plain.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @author Michael Slusarz - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_plain extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $text = $this->_mimepart->getContents(); - $charset = $this->_mimepart->getCharset(); - - /* Check for 'flowed' text data. */ - if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') { - $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); - } - - require_once 'Horde/Text/Filter.php'; - return array( - $this->_mimepart->getMimeId() => array( - 'data' => '' . Text_Filter::filter($text, 'text2html', array('parselevel' => TEXT_HTML_MICRO, 'charset' => $charset, 'class' => null)) . '', - 'status' => array(), - 'type' => 'text/html; charset=' . $charset - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $text = String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()); - - /* Check for 'flowed' text data. */ - $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed') - ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')) - : $text; - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Format flowed text for HTML output. - * - * @param string $text The text to format. - * @param boolean $delsp Was text created with DelSp formatting? - * - * @return string The formatted text. - */ - protected function _formatFlowed($text, $delsp = null) - { - $flowed = new Horde_Text_Flowed($this->_mimepart->replaceEOL($text, "\n"), $this->_mimepart->getCharset()); - $flowed->setMaxLength(0); - if (!is_null($delsp)) { - $flowed->setDelSp($delsp); - } - return $flowed->toFixed(); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rar.php b/framework/Mime/lib/Horde/Mime/Viewer/rar.php deleted file mode 100644 index c85f8d35a..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/rar.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @author Michael Cochrane - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_rar extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - if (!empty($ret)) { - reset($ret); - $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; - } - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $contents = $this->_mimepart->getContents(); - - require_once 'Horde/Compress.php'; - $rar = &Horde_Compress::singleton('rar'); - - $rarData = $rar->decompress($contents); - if (is_a($rarData, 'PEAR_Error')) { - return array(); - } - $fileCount = count($rarData); - - require_once 'Horde/Text.php'; - - $name = $this->_mimepart->getName(true); - if (empty($name)) { - $name = _("unnamed"); - } - - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . - '
' . - Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . - Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . - Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . - "\n\n" . - Text::htmlAllSpaces( - String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) . - String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) . - String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) - ) . "\n" . - str_repeat('-', 109) . "\n"; - - foreach ($rarData as $val) { - $ratio = empty($val['size']) - ? 0 - : 100 * ($val['csize'] / $val['size']); - - $text .= Text::htmlAllSpaces( - String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) . - String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) . - String::pad($val['size'], 10, ' ', STR_PAD_LEFT) . - String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) . - String::pad($val['method'], 10, ' ', STR_PAD_LEFT) . - String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT) - ) . "\n"; - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/report.php b/framework/Mime/lib/Horde/Mime/Viewer/report.php deleted file mode 100644 index 11010c8bc..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/report.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_report extends Horde_Mime_Viewer_Driver -{ - /** - * Return the underlying MIME Viewer for this part. - * - * @return mixed A Horde_Mime_Viewer object, or false if not found. - */ - protected function _getViewer() - { - if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) { - return false; - } - - $viewer = Horde_Mime_Viewer::factory($this->_mimepart, 'message/' . String::lower($type)); - if ($viewer) { - $viewer->setParams($this->_params); - } - return $viewer; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rfc822.php b/framework/Mime/lib/Horde/Mime/Viewer/rfc822.php deleted file mode 100644 index 97a2c5ed8..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/rfc822.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_rfc822 extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => true, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_mimepart->getContents(), - 'status' => array(), - 'type' => 'text/plain; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Return the rendered information about the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInfo() - { - /* Get the text of the part. Since we need to look for the end of - * the headers by searching for the CRLFCRLF sequence, use - * getCanonicalContents() to make sure we are getting the text with - * CRLF's. */ - $text = $this->_mimepart->getCanonicalContents(); - if (empty($text)) { - return array(); - } - - /* Search for the end of the header text (CRLFCRLF). */ - $text = substr($text, 0, strpos($text, "\r\n\r\n")); - - /* Get the list of headers now. */ - $headers = Horde_Mime_Headers::parseHeaders($text); - - $header_array = array( - 'date' => _("Date"), - 'from' => _("From"), - 'to' => _("To"), - 'cc' => _("Cc"), - 'bcc' => _("Bcc"), - 'reply-to' => _("Reply-To"), - 'subject' => _("Subject") - ); - $header_output = array(); - - foreach ($header_array as $key => $val) { - $hdr = $headers->getValue($key); - if (!empty($hdr)) { - $header_output[] = '' . $val . ': ' . htmlspecialchars($hdr); - } - } - - require_once 'Horde/Text/Filter.php'; - return array( - $this->_mimepart->getMimeId() => array( - 'data' => empty($header_output) ? '' : ('
' . Text_Filter::filter(implode("
\n", $header_output), 'emails') . '
'), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/richtext.php b/framework/Mime/lib/Horde/Mime/Viewer/richtext.php deleted file mode 100644 index 5f14e4721..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/richtext.php +++ /dev/null @@ -1,152 +0,0 @@ -" to - * "<", converts CRLFs to SPACE, converts to a newline according to - * local newline convention, removes everything between a command - * and the next balancing command, and removes all other - * formatting commands (all text enclosed in angle brackets). - * - * We implement the following tags: - * , , , , , ,
, - * , , , , , , - * , , , , - * - * The following tags are implemented differently than described in the RFC - * (due to limitations in HTML output): - * - Output as centered, bold text. - * - Output as centered, bold text. - * - Output as paragraph break. - * - * The following tags are NOT implemented: - * , , , , , - * , - * - * Copyright 2004-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Michael Slusarz - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_richtext extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_toHTML(), - 'status' => array(), - 'type' => 'text/html; charset=' . $this->_mimepart->getCharset() - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Convert richtext to HTML. - * - * @return string The converted HTML string. - */ - protected function _toHTML() - { - $text = trim($this->_mimepart->getContents()); - if ($text == '') { - return array(); - } - - /* We add space at the beginning and end of the string as it will - * make some regular expression checks later much easier (so we - * don't have to worry about start/end of line characters). */ - $text = ' ' . $text . ' '; - - /* Remove everything between tags. */ - $text = preg_replace('/.*<\/comment>/Uis', '', $text); - - /* Remove any unrecognized tags in the text. We don't need - * in $tags since it doesn't do anything anyway. All tags - * have already been removed. */ - $tags = '
'; - $text = strip_tags($text, $tags); - - /* becomes a '<'. CRLF becomes a SPACE. */ - $text = str_ireplace(array('', "\r\n"), array('<', ' '), $text); - - /* We try to protect against bad stuff here. */ - $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset()); - - /* becomes a newline (
); - * becomes a paragraph break (

). */ - $text = str_ireplace(array('<nl>', '<np>'), array('
', '

'), $text); - - /* Now convert the known tags to html. Try to remove any tag - * parameters to stop people from trying to pull a fast one. */ - $replace = array( - '/(? '\1', - '/(? '\1', - '/(? '\1', - '/(? '\1', - '/(? '\1', - '/(? '\1', - '/(? '

\1
', - '/(? '
\1
', - '/(? '
\1
', - '/(? '
\1
', - '/(? '\1', - '/(? '\1', - '/(? '\1', - '/(? '
\1

', - '/(? '
\1

', - '/(? '

\1

', - '/(? '
\1
' - ); - $text = preg_replace(array_keys($replace), array_values($replace), $text); - - /* Now we remove the leading/trailing space we added at the start. */ - $text = substr($text, 1, -1); - - /* Wordwrap. */ - $text = str_replace(array("\t", ' ', "\n "), array(' ', '  ', "\n "), $text); - if ($text[0] == ' ') { - $text = ' ' . substr($text, 1); - } - - return '

' . nl2br($text) . '

'; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rpm.php b/framework/Mime/lib/Horde/Mime/Viewer/rpm.php deleted file mode 100644 index 4c15c4555..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/rpm.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_rpm extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $data = ''; - $tmp_rpm = Horde::getTempFile('horde_rpm'); - - file_put_contents($tmp_rpm, $this->_mimepart->getContents()); - - $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r'); - while (($rc = fgets($fh, 8192))) { - $data .= $rc; - } - pclose($fh); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => '
' . htmlentities($data) . '
', - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/rtf.php b/framework/Mime/lib/Horde/Mime/Viewer/rtf.php deleted file mode 100644 index 2da5d1feb..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/rtf.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Duck - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_rtf extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $tmp_rtf = Horde::getTempFile('rtf'); - $tmp_output = Horde::getTempFile('rtf'); - - file_put_contents($tmp_rtf, $this->_mimepart->getContents()); - - exec($this->_conf['location'] . " $tmp_rtf > $tmp_output"); - - if (file_exists($tmp_output)) { - $data = file_get_contents($tmp_output); - } else { - $data = _("Unable to translate this RTF document"); - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/security.php b/framework/Mime/lib/Horde/Mime/Viewer/security.php deleted file mode 100644 index f66851f30..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/security.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_security extends Horde_Mime_Viewer_Driver -{ - /** - * Return the underlying MIME Viewer for this part. - * - * @return mixed A Horde_Mime_Viewer object, or false if not found. - */ - protected function _getViewer() - { - if (!($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) { - return false; - } - - $viewer = Horde_Mime_Viewer::factory($this->_mimepart, $protocol); - if ($viewer) { - $viewer->setParams($this->_params); - } - return $viewer; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/simple.php b/framework/Mime/lib/Horde/Mime/Viewer/simple.php deleted file mode 100644 index c42ae5652..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/simple.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_simple extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_mimepart->getContents(), - 'status' => array(), - 'type' => 'text/plain; charset=' . $this->_mimepart->getCharset() - ) - ); - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - return array( - $this->_mimepart->getMimeId() => array( - 'data' => String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset()), - 'status' => array(), - 'type' => 'text/plain; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/smil.php b/framework/Mime/lib/Horde/Mime/Viewer/smil.php deleted file mode 100644 index 1df1f213a..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/smil.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_smil extends Horde_Mime_Viewer_Driver -{ - /** - * Handle for the XML parser object. - * - * @var resource - */ - protected $_parser; - - /** - * String buffer to hold the generated content - * - * @var string - */ - protected $_content; - - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $this->_content = ''; - - /* Create a new parser and set its default properties. */ - $this->_parser = xml_parser_create(); - xml_set_object($this->_parser, $this); - xml_set_element_handler($this->_parser, '_startElement', '_endElement'); - xml_set_character_data_handler($this->_parser, '_defaultHandler'); - xml_parse($this->_parser, $this->_mimepart->getContents(), true); - xml_parser_free($this->_parser); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_content, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * User-defined function callback for start elements. - * - * @param object $parser Handle to the parser instance. - * @param string $name The name of this XML element. - * @param array $attrs List of this element's attributes. - */ - protected function _startElement($parser, $name, $attrs) - { - switch ($name) { - case 'IMG': - if (isset($attrs['SRC'])) { - $this->_content .= ''; - } - break; - } - } - - /** - * User-defined function callback for end elements. - * - * @param object $parser Handle to the parser instance. - * @param string $name The name of this XML element. - */ - protected function _endElement($parser, $name) - { - } - - /** - * User-defined function callback for character data. - * - * @param object $parser Handle to the parser instance. - * @param string $data String of character data. - */ - protected function _defaultHandler($parser, $data) - { - $data = trim($data); - if (!empty($data)) { - $this->_content .= ' ' . htmlspecialchars($data); - } - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/source.php b/framework/Mime/lib/Horde/Mime/Viewer/source.php deleted file mode 100644 index c1c16a0a4..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/source.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_source extends Horde_Mime_Viewer_Driver -{ - /** - * Add line numbers to a block of code. - * - * @param string $code The code to number. - * - * @return string The code with line numbers added. - */ - protected function _lineNumber($code, $linebreak = "\n") - { - $html = array('
'); - for ($l = 1, $lines = substr_count($code, $linebreak) + 1; $l <= $lines; ++$l) { - $html[] = sprintf('%s
', $l, $l, $l); - } - return implode("\n", $html) . '
' . $code . '
'; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/srchighlite.php b/framework/Mime/lib/Horde/Mime/Viewer/srchighlite.php deleted file mode 100644 index bbcc5d200..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/srchighlite.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_srchighlite extends Horde_Mime_Viewer_source -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - - // Need Horde headers for CSS tags. - reset($ret); - $ret[key($ret)]['data'] = Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . - $ret[key($ret)]['data'] . - Util::bufferOutput('require', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); - - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - /* Create temporary files for Webcpp. */ - $tmpin = Horde::getTempFile('SrcIn'); - $tmpout = Horde::getTempFile('SrcOut', false); - - /* Write the contents of our buffer to the temporary input file. */ - file_put_contents($tmpin, $this->_mimepart->getContents()); - - /* Determine the language from the mime type. */ - $lang = $this->_typeToLang($this->_mimepart->getType()); - - /* Execute Source-Highlite. */ - exec($this->_conf['location'] . " --src-lang $lang --out-format xhtml --input $tmpin --output $tmpout"); - $results = file_get_contents($tmpout); - unlink($tmpout); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $this->_lineNumber($results), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Attempts to determine what mode to use for the source-highlight - * program from a MIME type. - * - * @param string $type The MIME type. - * - * @return string The mode to use. - */ - protected function _typeToLang($type) - { - switch ($type) { - case 'text/x-java': - return 'java'; - - case 'text/x-csrc': - case 'text/x-c++src': - case 'text/cpp': - return 'cpp'; - - case 'application/x-perl': - return 'perl'; - - case 'application/x-php': - case 'x-extension/phps': - case 'x-extension/php3s': - case 'application/x-httpd-php': - case 'application/x-httpd-php3': - case 'application/x-httpd-phps': - return 'php3'; - - case 'application/x-python': - return 'python'; - - // TODO: 'prolog', 'flex', 'changelog', 'ruby' - } - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/tgz.php b/framework/Mime/lib/Horde/Mime/Viewer/tgz.php deleted file mode 100644 index d12822763..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/tgz.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @author Michael Cochrane - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_tgz extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => false, - 'info' => true, - 'inline' => true - ); - - /** - * The list of compressed subtypes. - * - * @var array - */ - protected $_gzipSubtypes = array( - 'x-compressed-tar', 'tgz', 'x-tgz', 'gzip', 'x-gzip', - 'x-gzip-compressed', 'x-gtar' - ); - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - /* Currently, can't do anything without tar file. */ - $subtype = $this->_mimepart->getSubType(); - if (in_array($subtype, array('gzip', 'x-gzip', 'x-gzip-compressed'))) { - return array(); - } - - $contents = $this->_mimepart->getContents(); - - /* Decompress gzipped files. */ - if (in_array($subtype, $this->_gzipSubtypes)) { - $gzip = &Horde_Compress::singleton('gzip'); - $contents = $gzip->decompress($contents); - if (is_a($contents, 'PEAR_Error') || empty($contents)) { - return array(); - } - } - - /* Obtain the list of files/data in the tar file. */ - $tar = &Horde_Compress::singleton('tar'); - $tarData = $tar->decompress($contents); - if (is_a($tarData, 'PEAR_Error')) { - return array(); - } - $fileCount = count($tarData); - - require_once 'Horde/Text.php'; - - $name = $this->_mimepart->getName(true); - if (empty($name)) { - $name = _("unnamed"); - } - - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . - '
' . - Text::htmlAllSpaces(_("Archive Name") . ': ' . $name) . "\n" . - Text::htmlAllSpaces(_("Archive File Size") . ': ' . strlen($contents) . ' bytes') . "\n" . - Text::htmlAllSpaces(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount)) . - "\n\n" . - Text::htmlAllSpaces( - str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) . - str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) . - str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) . - str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) - ) . "\n" . - str_repeat('-', 106) . "\n"; - - foreach ($tarData as $val) { - $text .= Text::htmlAllSpaces( - str_pad($val['name'], 62, ' ', STR_PAD_RIGHT) . - str_pad($val['attr'], 15, ' ', STR_PAD_LEFT) . - str_pad($val['size'], 10, ' ', STR_PAD_LEFT) . - str_pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) - ) . "\n"; - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * Return the rendered information about the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInfo() - { - return $this->_renderInline(); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/tnef.php b/framework/Mime/lib/Horde/Mime/Viewer/tnef.php deleted file mode 100644 index 81ac09c73..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/tnef.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @author Michael Slusarz - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_tnef extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - if (!empty($ret)) { - reset($ret); - $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; - } - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - require_once 'Horde/Compress.php'; - $tnef = &Horde_Compress::singleton('tnef'); - - $data = ''; - $info = $tnef->decompress($this->_mimepart->getContents()); - if (empty($info) || is_a($info, 'PEAR_Error')) { - $data .= ''; - } else { - $data .= ''; - foreach ($info as $part) { - $data .= ''; - } - } - $data .= '
' . _("MS-TNEF Attachment contained no data.") . '
' . _("Name") . '' . _("Mime Type") . '
' . $part['name'] . '' . $part['type'] . '/' . $part['subtype'] . '
'; - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/vcard.php b/framework/Mime/lib/Horde/Mime/Viewer/vcard.php deleted file mode 100644 index 2932b9508..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/vcard.php +++ /dev/null @@ -1,404 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_vcard extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_renderInline(); - if (!empty($ret)) { - reset($ret); - $ret[key($ret)]['data'] = Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc') . - $ret[key($ret)]['data'] . - Util::bufferOutput('include', $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'); - } - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - global $registry, $prefs, $notification; - - $app = false; - $data = $this->_mimepart->getContents(); - $html = ''; - $import_msg = null; - $title = _("vCard"); - - require_once 'Horde/iCalendar.php'; - $iCal = new Horde_iCalendar(); - if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) { - $notification->push(_("There was an error reading the contact data."), 'horde.error'); - } - - if (Util::getFormData('import') && - Util::getFormData('source') && - $registry->hasMethod('contacts/import')) { - $source = Util::getFormData('source'); - $count = 0; - foreach ($iCal->getComponents() as $c) { - if (is_a($c, 'Horde_iCalendar_vcard')) { - $contacts = $registry->call('contacts/import', - array($c, null, $source)); - if (is_a($contacts, 'PEAR_Error')) { - $notification->push( - _("There was an error importing the contact data:") . ' ' - . $contacts->getMessage(), - 'horde.error'); - continue; - } - $count++; - } - } - $notification->push(sprintf(ngettext( - "%d contact was successfully added to your address book.", - "%d contacts were successfully added to your address book.", - $count), - $count), - 'horde.success'); - } - - $html .= ''; - - $i = 0; - foreach ($iCal->getComponents() as $vc) { - if ($i > 0) { - $html .= ''; - } - ++$i; - - $html .= ''; - - $n = $vc->printableName(); - if (!empty($n)) { - $html .= $this->_row(_("Name"), $n); - } - - $aliases = $vc->getAttributeValues('ALIAS'); - if (!is_a($aliases, 'PEAR_Error')) { - $html .= $this->_row(_("Alias"), implode("\n", $aliases)); - } - $birthdays = $vc->getAttributeValues('BDAY'); - if (!is_a($birthdays, 'PEAR_Error')) { - $birthday = new Horde_Date($birthdays[0]); - $html .= $this->_row( - _("Birthday"), - $birthday->strftime($prefs->getValue('date_format'))); - } - - $photos = $vc->getAllAttributes('PHOTO'); - foreach ($photos as $photo) { - if (!isset($photo['params']['VALUE']) || - String::upper($photo['params']['VALUE']) != 'URI') { - continue; - } - $html .= $this->_row(_("Photo"), - '', - false); - } - - $labels = $vc->getAllAttributes('LABEL'); - foreach ($labels as $label) { - if (isset($label['params']['TYPE'])) { - if (!is_array($label['params']['TYPE'])) { - $label['params']['TYPE'] = array($label['params']['TYPE']); - } - } else { - $label['params']['TYPE'] = array_keys($label['params']); - } - $types = array(); - foreach ($label['params']['TYPE'] as $type) { - switch(String::upper($type)) { - case 'HOME': - $types[] = _("Home Address"); - break; - - case 'WORK': - $types[] = _("Work Address"); - break; - - case 'DOM': - $types[] = _("Domestic Address"); - break; - - case 'INTL': - $types[] = _("International Address"); - break; - - case 'POSTAL': - $types[] = _("Postal Address"); - break; - - case 'PARCEL': - $types[] = _("Parcel Address"); - break; - - case 'PREF': - $types[] = _("Preferred Address"); - break; - } - } - if (!count($types)) { - $types = array(_("Address")); - } - $html .= $this->_row(implode('/', $types), $label['value']); - } - - $adrs = $vc->getAllAttributes('ADR'); - foreach ($adrs as $item) { - if (isset($item['params']['TYPE'])) { - if (!is_array($item['params']['TYPE'])) { - $item['params']['TYPE'] = array($item['params']['TYPE']); - } - } else { - $item['params']['TYPE'] = array_keys($item['params']); - } - $address = $item['values']; - $a = array(); - if (isset($address[VCARD_ADR_STREET])) { - $a[] = $address[VCARD_ADR_STREET]; - } - if (isset($address[VCARD_ADR_LOCALITY])) { - $a[] = $address[VCARD_ADR_LOCALITY]; - } - if (isset($address[VCARD_ADR_REGION])) { - $a[] = $address[VCARD_ADR_REGION]; - } - if (isset($address[VCARD_ADR_POSTCODE])) { - $a[] = $address[VCARD_ADR_POSTCODE]; - } - if (isset($address[VCARD_ADR_COUNTRY])) { - $a[] = $address[VCARD_ADR_COUNTRY]; - } - $types = array(); - foreach ($item['params']['TYPE'] as $type) { - switch(String::upper($type)) { - case 'HOME': - $types[] = _("Home Address"); - break; - - case 'WORK': - $types[] = _("Work Address"); - break; - - case 'DOM': - $types[] = _("Domestic Address"); - break; - - case 'INTL': - $types[] = _("International Address"); - break; - - case 'POSTAL': - $types[] = _("Postal Address"); - break; - - case 'PARCEL': - $types[] = _("Parcel Address"); - break; - - case 'PREF': - $types[] = _("Preferred Address"); - break; - } - } - if (!count($types)) { - $types = array(_("Address")); - } - $html .= $this->_row(implode('/', $types), implode("\n", $a)); - } - - $numbers = $vc->getAllAttributes('TEL'); - - foreach ($numbers as $number) { - if (isset($number['params']['TYPE'])) { - if (!is_array($number['params']['TYPE'])) { - $number['params']['TYPE'] = array($number['params']['TYPE']); - } - foreach ($number['params']['TYPE'] as $type) { - $number['params'][String::upper($type)] = true; - } - } - if (isset($number['params']['FAX'])) { - $html .= $this->_row(_("Fax"), $number['value']); - } else { - if (isset($number['params']['HOME'])) { - $html .= $this->_row(_("Home Phone"), - $number['value']); - } elseif (isset($number['params']['WORK'])) { - $html .= $this->_row(_("Work Phone"), - $number['value']); - } elseif (isset($number['params']['CELL'])) { - $html .= $this->_row(_("Cell Phone"), - $number['value']); - } else { - $html .= $this->_row(_("Phone"), - $number['value']); - } - } - } - - $addresses = $vc->getAllAttributes('EMAIL'); - $emails = array(); - foreach ($addresses as $address) { - if (isset($address['params']['TYPE'])) { - if (!is_array($address['params']['TYPE'])) { - $address['params']['TYPE'] = array($address['params']['TYPE']); - } - foreach ($address['params']['TYPE'] as $type) { - $address['params'][String::upper($type)] = true; - } - } - $email = '' . htmlspecialchars($address['value']) . ''; - if (isset($address['params']['PREF'])) { - array_unshift($emails, $email); - } else { - $emails[] = $email; - } - } - - if (count($emails)) { - $html .= $this->_row(_("Email"), implode("\n", $emails), false); - } - - $title = $vc->getAttributeValues('TITLE'); - if (!is_a($title, 'PEAR_Error')) { - $html .= $this->_row(_("Title"), $title[0]); - } - - $role = $vc->getAttributeValues('ROLE'); - if (!is_a($role, 'PEAR_Error')) { - $html .= $this->_row(_("Role"), $role[0]); - } - - $org = $vc->getAttributeValues('ORG'); - if (!is_a($org, 'PEAR_Error')) { - $html .= $this->_row(_("Company"), $org[0]); - if (isset($org[1])) { - $html .= $this->_row(_("Department"), $org[1]); - } - } - - $notes = $vc->getAttributeValues('NOTE'); - if (!is_a($notes, 'PEAR_Error')) { - $html .= $this->_row(_("Notes"), $notes[0]); - } - - $url = $vc->getAttributeValues('URL'); - if (!is_a($url, 'PEAR_Error')) { - $html .= $this->_row( - _("URL"), - '' . htmlspecialchars($url[0]) - . '', - false); - } - } - - if ($registry->hasMethod('contacts/import') && - $registry->hasMethod('contacts/sources')) { - $html .= ''; - } - - $html .= '
 
'; - $fullname = $vc->getAttributeDefault('FN', false); - if ($fullname !== false) { - $html .= $fullname; - } - $html .= '
' - . Util::formInput(); - foreach ($_GET as $key => $val) { - $html .= ''; - } - - $sources = $registry->call('contacts/sources', array(true)); - if (count($sources) > 1) { - $html .= - '' - . '' - . '' - . ''; - } - - $html .= '
 
'; - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status')) . $html, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } - - /** - * TODO - */ - protected function _row($label, $value, $encode = true) - { - if ($encode) { - $label = htmlspecialchars($label); - $value = htmlspecialchars($value); - } - return '' . $label . - '' . nl2br($value) . - "\n"; - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/webcpp.php b/framework/Mime/lib/Horde/Mime/Viewer/webcpp.php deleted file mode 100644 index 3d0f99597..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/webcpp.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_webcpp extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_toHTML(); - - /* The first 2 lines are the Content-Type line and a blank line so - * remove them before outputting. */ - reset($ret); - $ret[key($ret)]['data'] = preg_replace("/.*\n.*\n/", '', $ret[key($ret)]['data'], 1); - - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - $ret = $this->_toHTML(); - reset($ret); - $data = $ret[key($ret)]['data']; - - /* Extract the style sheet, removing any global body formatting - * if we're displaying inline. */ - $res = preg_split(';()|(
' . $body . '
'; - - return $ret; - } - - /** - * Converts the code to HTML. - * - * @return string The HTML-ified version of the MIME part contents. - */ - protected function _toHTML() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - /* Create temporary files for Webcpp. */ - $tmpin = Horde::getTempFile('WebcppIn'); - $tmpout = Horde::getTempFile('WebcppOut'); - - /* Write the contents of our buffer to the temporary input file. */ - file_put_contents($tmpin, $this->_mimepart->getContents()); - - /* Get the extension for the mime type. */ - include_once dirname(__FILE__) . '/../Magic.php'; - $ext = Horde_Mime_Magic::MIMEToExt($this->_mimepart->getType()); - - /* Execute Web C Plus Plus. Specifying the in and out files didn't - * work for me but pipes did. */ - exec($this->_conf['location'] . " --pipe --pipe -x=$ext -l -a -t < $tmpin > $tmpout"); - $results = file_get_contents($tmpout); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $results, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php b/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php deleted file mode 100644 index 7cf749610..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/wordperfect.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_wordperfect extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => false, - 'full' => true, - 'info' => false, - 'inline' => false - ); - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - /* Check to make sure the viewer program exists. */ - if (!isset($this->_conf['location']) || - !file_exists($this->_conf['location'])) { - return array(); - } - - $tmp_wpd = Horde::getTempFile('wpd'); - $tmp_output = Horde::getTempFile('wpd'); - - file_put_contents($tmp_wpd, $this->_mimepart->getContents()); - - exec($this->_conf['location'] . " $tmp_wpd > $tmp_output"); - - if (file_exists($tmp_output)) { - $data = file_get_contents($tmp_output); - } else { - $data = _("Unable to translate this WordPerfect document"); - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $data, - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/zip.php b/framework/Mime/lib/Horde/Mime/Viewer/zip.php deleted file mode 100644 index 5399e2a9e..000000000 --- a/framework/Mime/lib/Horde/Mime/Viewer/zip.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @author Michael Cochrane - * @package Horde_Mime_Viewer - */ -class Horde_Mime_Viewer_zip extends Horde_Mime_Viewer_Driver -{ - /** - * Can this driver render various views? - * - * @var boolean - */ - protected $_capability = array( - 'embedded' => false, - 'forceinline' => true, - 'full' => true, - 'info' => false, - 'inline' => true - ); - - /** - * A callback function to use in _toHTML(). - * - * @var callback - */ - protected $_callback = null; - - /** - * Return the full rendered version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _render() - { - $ret = $this->_toHTML(); - if (!empty($ret)) { - reset($ret); - $ret[key($ret)]['data'] = '' . $ret[key($ret)]['data'] . ''; - } - return $ret; - } - - /** - * Return the rendered inline version of the Horde_Mime_Part object. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _renderInline() - { - return $this->_toHTML(); - } - - /** - * Converts the ZIP file to an HTML display. - * - * @return array See Horde_Mime_Viewer_Driver::render(). - */ - protected function _toHTML() - { - $contents = $this->_mimepart->getContents(); - - require_once 'Horde/Compress.php'; - $zip = &Horde_Compress::singleton('zip'); - - /* Make sure this is a valid zip file. */ - if ($zip->checkZipData($contents) === false) { - return array(); - } - - $zipInfo = $zip->decompress($contents, array('action' => HORDE_COMPRESS_ZIP_LIST)); - if (is_a($zipInfo, 'PEAR_Error')) { - return array(); - } - $fileCount = count($zipInfo); - - /* Determine maximum file name length. */ - $max_array = array(); - foreach ($zipInfo as $val) { - $max_array[] = strlen($val['name']); - } - $maxlen = empty($max_array) ? 0 : max($max_array); - - require_once 'Horde/Text.php'; - - $name = $this->_mimepart->getName(true); - if (empty($name)) { - $name = _("unnamed"); - } - - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . - '
' . - Text::htmlAllSpaces( - _("Archive Name") . ': ' . $name . "\n" . - _("Archive File Size") . ': ' . strlen($contents) . - ' bytes' . "\n" . - sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) . - "\n\n" . - String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) . - String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) . - String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("CRC"), 10, ' ', STR_PAD_LEFT) . - String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) . - "\n" - ) . str_repeat('-', 69 + $maxlen) . "\n"; - - foreach ($zipInfo as $key => $val) { - $ratio = (empty($val['size'])) - ? 0 - : 100 * ($val['csize'] / $val['size']); - - $val['name'] = String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT); - $val['attr'] = String::pad($val['attr'], 10,' ', STR_PAD_LEFT); - $val['size'] = String::pad($val['size'], 10, ' ', STR_PAD_LEFT); - $val['date'] = String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT); - $val['method'] = String::pad($val['method'], 10, ' ', STR_PAD_LEFT); - $val['crc'] = String::pad($val['crc'], 10, ' ', STR_PAD_LEFT); - $val['ratio'] = String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT); - - $val = array_map(array('Text', 'htmlAllSpaces'), $val); - if (!is_null($this->_callback)) { - $val = call_user_func($this->_callback, $key, $val); - } - - $text .= $val['name'] . $val['attr'] . $val['size'] . - $val['date'] . $val['method'] . $val['crc'] . $val['ratio'] . - "\n"; - } - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '
'), - 'status' => array(), - 'type' => 'text/html; charset=' . NLS::getCharset() - ) - ); - } -} diff --git a/framework/Mime/package.xml b/framework/Mime/package.xml index a75808545..8a86bca8e 100644 --- a/framework/Mime/package.xml +++ b/framework/Mime/package.xml @@ -41,7 +41,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + @@ -53,40 +53,40 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -147,10 +147,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> pecl.php.net - Auth - pear.horde.org - - Horde_Browser pear.horde.org @@ -167,10 +163,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> pear.horde.org - Horde_SessionObjects - pear.horde.org - - Horde_Text_Filter pear.horde.org @@ -189,39 +181,39 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +