### Message display ###
static public $msgshow_headers = array('from', 'newsgroups', 'followup-to', 'to', 'cc', 'reply-to',
'organization', 'date', 'references', 'in-reply-to');
- static public $msgshow_mimeparts = array('text/html', 'text/plain', 'text/enriched', 'text', 'message');
+ static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 'text/html', 'text/plain', 'text/enriched', 'text', 'message');
static public $msgshow_xface = true;
static public $msgshow_wrap = 78;
/** Match an url
- * Should be included in a regexp delimited using /, !, , or @ (eg: "/$url_regexp/i")
+ * Should be included in a regexp delimited using /, !, , or @ (eg: "/$url_regexp/ui")
* If it matches, return 3 main parts :
* \\1 and \\3 are delimiters
* \\2 is the url
/** Global headers to use for messages
*/
static public $msgedit_headers = array('Mime-Version' => '1.0', 'User-Agent' => 'Banana @VERSION@');
-
+ /** Mime type order for quoting
+ */
+ static public $msgedit_mimeparts = array('multipart/report', 'multipart/mixed', 'text/plain', 'text/enriched', 'text/html', 'text', 'message');
+
### Protocole ###
/** News serveur to use
*/
$message = null;
return $message;
}
- return new BananaMessage($message[$id]['message']);
+ $message = new BananaMessage($message[$id]['message']);
+ return $message;
}
/** Return the sources of the given message
return banana_cleanHtml($text);
}
+function banana_quoteRichtText(BananaMimePart &$part)
+{
+ $text = $part->getText();
+ $text = banana_richtextToHtml($text);
+ $text = banana_htmlToPlainText($text);
+ return banana_wrap($text, 1);
+}
+
// }}}
// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
if (empty($parts)) {
continue;
}
- foreach ($parts as &$part) {
- list($type, $subtype) = $part->getType();
- switch ($subtype) {
- case 'html': return banana_formatHtml($part);
- case 'enriched': case 'richtext': return banana_formatRichText($part);
- default: return banana_formatPlainText($part);
- }
- }
+ return $parts[0]->toHtml();
}
return null;
}
public function quote()
{
- $part = $this->toPlainText();
- if (is_null($part)) {
- return banana_quoteHtml($this->toHtml());
+ foreach (Banana::$msgedit_mimeparts as $type) {
+ @list($type, $subtype) = explode('/', $type);
+ $parts = $this->getParts($type, $subtype);
+ if (empty($parts)) {
+ continue;
+ }
+ if ($parts[0] === $this) {
+ return parent::quote();
+ }
+ return $parts[0]->quote();
}
- return banana_quotePlainText($part);
+ return null;
}
public function canCancel()
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 '<img src="'
+ . banana_htmlentities(Banana::$page->makeUrl(array('group' => Banana::$group,
+ 'artid' => Banana::$artid,
+ 'part' => $part)))
+ . '" alt="' . banana_htmlentities($this->filename) . '" />';
+ } 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 '<hr />' . banana_formatPlainText($this);
+ }
+ return banana_formatPlainText($this);
+ }
+ }
+ return null;
+ }
+
+ public function quote()
+ {
+ list($type, $subtype) = $this->getType();
+ if (in_array($type, Banana::$msgedit_mimeparts) || in_array($this->content_type, Banana::$msgedit_mimeparts)) {
+ if ($type == 'multipart' && ($subtype == 'mixed' || $subtype == 'report')) {
+ $text = '';
+ foreach ($this->multipart as &$part) {
+ $qt = $part->quote();
+ $qt = rtrim($qt);
+ if (!empty($text)) {
+ $text .= "\n" . banana_quote("", 1) . "\n";
+ }
+ $text .= $qt;
+ }
+ return $text;
+ }
+ switch ($subtype) {
+ case 'html': return banana_quoteHtml($this);
+ case 'enriched': case 'richtext': return banana_quoteRichText($this);
+ default: return banana_quotePlainText($this);
+ }
+ }
+ }
+
protected function getType()
{
return explode('/', $this->content_type);
return $parts;
}
- public function toPlainText()
- {
- $parts = $this->getParts('text', 'plain');
- return (count($parts) ? $parts[0] : null);
- }
-
- public function toHtml()
- {
- $parts = $this->getParts('text', 'html');
- return (count($parts) ? $parts[0] : null);
- }
-
- public function toRichText()
- {
- $parts = $this->getParts('text', 'enriched');
- return (count($parts) ? $parts[0] : null);
- }
-
public function getFile($filename)
{
if ($this->filename == $filename) {
<td class="hdr">Fichiers joints</td>
<td colspan="2">
{foreach from=$files item=file name=attachs}
- {$file->getFilename()|htmlentities}
- {imglink img=save alt="Enregistrer" group=$group artid=$artid part=$file->getFilename()}{if !$smarty.foreach.attachs.last}, {/if}
+ {imglink img=save alt="Enregistrer" group=$group artid=$artid part=$file->getFilename() text=$file->getFilename()}{if !$smarty.foreach.attachs.last}, {/if}
{/foreach}
</td>
</tr>