var $pj;
/** poster name */
var $name;
+ /** test validity */
+ var $valid = true;
/** constructor
* @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
$this->pj = array();
$this->messages = array();
if (!$this->_header()) {
+ $this->valid = false;
return null;
}
if ($body = $banana->nntp->body($_id)) {
$this->body = join("\n", $body);
} else {
+ $this->valid = false;
return null;
}
} else {
$this->_split_multipart($mpart_type[1], $mpart_boundary[1]);
$this->_find_uuencode();
- if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
- $this->body = iconv($matches[1], 'utf-8', $this->body);
- } else {
- $this->body = utf8_encode($this->body);
- }
+ $this->_fix_charset();
}
}
return true;
}
+ /** Fix body charset (convert body to utf8)
+ * @return false if failed
+ */
+ function _fix_charset()
+ {
+ if (preg_match('!charset="?([^;"]*)"?\s*(;|$)?!', $this->headers['content-type'], $matches)) {
+ $body = iconv($matches[1], 'utf-8', $this->body);
+ if (strlen($body) == 0) {
+ return false;
+ }
+ $this->body = $body;
+ } else {
+ $this->body = utf8_encode($this->body);
+ }
+ return true;
+ }
+
/** return body in plain text (useful for messages without a text/plain part)
*/
function get_body()
}
}
- if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
- $this->body = iconv($matches[1], 'utf-8', $this->body);
- } else {
- $this->body = utf8_encode($this->body);
- }
+ $this->_fix_charset();
return true;
}
preg_match("@text/([^;]+);@", $this->messages[$i]['headers']['content-type'], $format);
$format = textFormat_translate($format[1]);
if ($i != $partid) {
- $res .= '<a href="?group='.$banana->state['group'].'&artid='.$this->id.'&part='.$i.'">'.$format.'</a>';
+ $res .= makeHREF(Array('group' => $banana->state['group'],
+ 'artid' => $this->id,
+ 'part' => $i),
+ $format);
} else {
$res .= $format;
}
$i = 0;
foreach ($this->pj as $file) {
$res .= $file['filename'].' ('.$file['MIME'].') : ';
- $res .= '<a href="?group='.$banana->state['group'].'&artid='.$this->id.'&pj='.$i.'">télécharger</a>';
- $res .= ' . <a href="?group='.$banana->state['group'].'&artid='.$this->id.'&pj='.$i.'&action=view" target="_blank">aperçu</a>';
+ $res .= makeHREF(Array('group' => $banana->state['group'],
+ 'artid' => $this->id,
+ 'pj' => $i),
+ _b_('télécharger'));
+ $res .= ' . ';
+ $res .= makeHREF(Array('group' => $banana->state['group'],
+ 'artid' => $this->id,
+ 'pj' => $i,
+ 'action'=> 'view'),
+ _b_('aperçu'));
$res .= '<br/>';
$i++;
}
$res .= '</td></tr>';
}
- $res .= '<tr><th colspan="2">'._b_('Apercu').'</th></tr>';
+ $res .= '<tr><th colspan="2">' . _b_('Apercu de ')
+ . makeHREF(Array('group' => $banana->state['group']),
+ $banana->state['group'])
+ . '</th></tr>';
$ndx = $banana->spool->getndx($this->id);
- $res .= '<tr><td class="thrd" colspan="2">'.$banana->spool->to_html($ndx-$banana->tbefore, $ndx+$banana->tafter, $ndx).'</td></tr>';
-
+ $res .= '<tr><td class="thrd" colspan="2">'
+ . $banana->spool->to_html($ndx-$banana->tbefore, $ndx+$banana->tafter, $ndx)
+ . '</td></tr>';
return $res.'</table>';
}
}
+// vim:set et sw=4 sts=4 ts=4
?>