X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fmimepart.inc.php;h=26cb31af6b2e4c636428b05ca2fb55c17acdaa2e;hb=fd57a15cace088016b5eb49f87fb972a51a1c400;hp=d90a22b998d16cf3aba648fe225043a44b5a3182;hpb=e9360b112e17413c5d74a8dbb33ee8c6d5111dc4;p=banana.git
diff --git a/banana/mimepart.inc.php b/banana/mimepart.inc.php
index d90a22b..26cb31a 100644
--- a/banana/mimepart.inc.php
+++ b/banana/mimepart.inc.php
@@ -388,8 +388,13 @@ class BananaMimePart
$content = "";
if ($with_headers) {
foreach ($this->getHeaders() as $key => $value) {
- $content .= "$key: $value\n";
- }
+ $line = "$key: $value";
+ $line = explode("\n", wordwrap($line, Banana::$msgshow_wrap));
+ for ($i = 1 ; $i < count($line) ; $i++) {
+ $line[$i] = "\t" . $line[$i];
+ }
+ $content .= implode("\n", $line) . "\n";
+ }
$content .= "\n";
}
if ($this->isType('multipart')) {
@@ -399,20 +404,83 @@ class BananaMimePart
}
$content .= "\n--{$this->boundary}--";
} else {
- $content .= $this->body;
+ $content .= banana_wordwrap($this->body);
}
return $content;
}
public function getText()
{
- if (!$this->isType('text')) {
- return null;
- }
$this->decodeContent();
return $this->body;
}
+ public function toHtml()
+ {
+ list($type, $subtype) = $this->getType();
+ if ($type == 'image') {
+ $part = $this->id ? $this->id : $this->filename;
+ return '';
+ } elseif (!in_array($type, Banana::$msgshow_mimeparts)
+ && !in_array($this->content_type, Banana::$msgshow_mimeparts)) {
+ $part = $this->id ? $this->id : $this->filename;
+ if (!$part) {
+ $part = $this->content_type;
+ }
+ return '[' . Banana::$page->makeImgLink(array('group' => Banana::$group,
+ 'artid' => Banana::$artid,
+ 'part' => $part,
+ 'text' => $this->filename ? $this->filename : $this->content_type,
+ 'img' => 'save')) . ']';
+ } else {
+ if ($type == 'multipart' && ($subtype == 'mixed' || $subtype == 'report')) {
+ $text = '';
+ foreach ($this->multipart as &$part) {
+ $text .= $part->toHtml();
+ }
+ return $text;
+ }
+ switch ($subtype) {
+ case 'html': return banana_formatHtml($this);
+ case 'enriched': case 'richtext': return banana_formatRichText($this);
+ default:
+ if ($type == 'message') {
+ return '