case "references": case "in-reply-to":
$rsl = "";
- $parents = preg_grep('/^\d+$/', $this->getTranslatedReferences());
- $p = array_pop($parents);
-
- $parents = array();
- while (!is_null($p)) {
- array_unshift($parents, $p);
- $p = Banana::$spool->overview[$p]->parent;
- }
+ $parents = Banana::$spool->getReferences($this->headers);
$ndx = 1;
- foreach ($parents as $p) {
+ while (!empty($parents)) {
+ $p = array_shift($parents);
$rsl .= Banana::$page->makeLink(Array('group' => Banana::$spool->group,
- 'artid' => $p, 'text' => $ndx++)) . ' ';
+ 'artid' => $p->id, 'text' => $ndx++)) . ' ';
}
return $rsl;
return array_merge($headers, parent::getHeaders());
}
- static public function formatFrom($text, $subject = '')
+ static public function extractMail($text)
{
-# From: mark@cbosgd.ATT.COM
-# From: <mark@cbosgd.ATT.COM>
-# From: mark@cbosgd.ATT.COM (Mark Horton)
-# From: Mark Horton <mark@cbosgd.ATT.COM>
- $mailto = '<a href="mailto:';
-
- $result = banana_htmlentities($text);
- if ($subject) {
- $subject = '?subject=' . banana_htmlentities(_b_('Re: ') . $subject, ENT_QUOTES);
- }
- if (preg_match("/^<?([^< ]+@[^> ]+)>?$/", $text, $regs)) {
- $result = $mailto . $regs[1] . $subject . '">' . banana_htmlentities($regs[1]) . '</a>';
- }
- if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $text, $regs)) {
- $result = $mailto . $regs[1] . $subject . '">' . banana_htmlentities($regs[2]) . '</a>';
- }
if (preg_match("/^\"?([^<>\"]+)\"? +<(.+@.+)>$/", $text, $regs)) {
+ # From: Mark Horton <mark@cbosgd.ATT.COM>
$nom = preg_replace("/^'(.*)'$/", '\1', $regs[1]);
$nom = stripslashes($nom);
- $result = $mailto . $regs[2] . $subject . '">' . banana_htmlentities($nom) . '</a>';
+ return array($nom, strtolower($regs[2]));
+ } else if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $text, $regs)) {
+ # From: mark@cbosgd.ATT.COM (Mark Horton)
+ return array($regs[2], strtolower($regs[1]));
+ } else if (preg_match("/^<?([^< ]+@[^> ]+)>?$/", $text, $regs)) {
+ # From: <mark@cbosgd.ATT.COM>
+ return array($regs[1], strtolower($regs[1]));
+ } else {
+ # From: mark@cbosgd.ATT.COM
+ return array($text, strtolower($text));
+ }
+ }
+
+ static public function formatFrom($text, $subject = '')
+ {
+ list($name, $email) = self::extractMail($text);
+ if ($subject) {
+ $subject = '?subject=' . banana_htmlentities(_b_('Re: ') . $subject, ENT_QUOTES);
}
- return preg_replace("/\\\(\(|\))/","\\1",$result);
+ $result = '<a href="mailto:' . $email . $subject . '">' . banana_htmlentities($name) . '</a>';
+ return preg_replace("/\\\(\(|\))/","\\1", $result);
}
public function getAuthorName()
return preg_split('/\s/', $text);
}
- public function getTranslatedReferences()
- {
- return BananaMessage::formatReferences($this->headers);
- }
-
- static public function formatReferences(array &$refs)
- {
- if (isset($refs['references'])) {
- $text = preg_split('/\s/', str_replace('><', '> <', $refs['references']));
- $references = array();
- foreach ($text as $id=>&$value) {
- if (isset(Banana::$spool->ids[$value])) {
- $references[] = Banana::$spool->ids[$value];
- }
- }
- return $references;
- } elseif (isset($refs['in-reply-to']) && isset(Banana::$spool->ids[$refs['in-reply-to']])) {
- return array(Banana::$spool->ids[$refs['in-reply-to']]);
- } else {
- return array();
- }
- }
-
public function hasXFace()
{
- return Banana::$msgshow_xface &&
+ return Banana::$msgshow_xface &&
((function_exists('hook_hasxface') && hook_hasXFace($this->headers))
|| isset($this->headers['x-face']));
}