Can configure spool root
[banana.git] / banana / mimepart.inc.php
index 9f039eb..cf1e94a 100644 (file)
@@ -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,7 +404,7 @@ class BananaMimePart
             }
             $content .= "\n--{$this->boundary}--";
         } else {
-            $content .= $this->body;
+            $content .= banana_wordwrap($this->body);
         }
         return $content;
     }
@@ -415,7 +420,7 @@ class BananaMimePart
         list($type, $subtype) = $this->getType();
         if ($type == 'image') {
             $part = $this->id ? $this->id : $this->filename;
-            return '<img src="'
+            return '<img class="multipart" src="'
                  . banana_htmlentities(Banana::$page->makeUrl(array('group' => Banana::$group,
                                                                     'artid' => Banana::$artid,
                                                                     'part'  => $part)))
@@ -539,6 +544,43 @@ class BananaMimePart
         return array();
     }
 
+    public function getAlternatives()
+    {
+        $types =& Banana::$msgshow_mimeparts;
+        $names =& Banana::$mimeparts;
+        $source = null;
+        if (in_array('source', $types)) {
+            $source = @$names['source'] ? $names['source'] : 'source';
+        }
+        if (!$this->isType('multipart', 'alternative') && !$this->isType('multipart', 'related')) {
+            if ($source) {
+                $parts = array($this);
+            } else {
+                return array();
+            }
+        } else {
+            $parts =& $this->multipart;
+        }
+        $alt = array();
+        foreach ($parts as &$part) {
+            list($type, $subtype) = $part->getType();
+            $ct = $type . '/' . $subtype;
+            if (in_array($ct, $types) || in_array($type, $types)) {
+                if (isset($names[$ct])) {
+                    $alt[$ct] = $names[$ct];
+                } elseif (isset($names[$type])) {
+                    $alt[$ct] = $names[$type];
+                } else {
+                    $alt[$ct] = $ct;
+                }
+            }
+        }
+        if ($source) {
+            $alt['source'] = $source;
+        }
+        return $alt;
+    }
+
     public function getPartById($id)
     {
         if ($this->id == $id) {