X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=c58844e478cc7e09e5b16cc10f710f8d0d95072d;hb=ced003168bf3b75a29313c727fe28d65cb03057c;hp=07aac94d71263ef535829677b5cf6d4893fea838;hpb=dd9bac8f7903e9924525ad8db3e38650ff5ad1b6;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 07aac94..c58844e 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1,6 +1,6 @@ numRows() != 1) { + throw new MailNotFound(); + } $nl = $res->fetchOneAssoc(); $this->_id = $nl['id']; @@ -223,18 +226,24 @@ class NLArticle // }}} // {{{ function toText() - public function toText() + public function toText($hash = null, $login = null) { $title = '*'.$this->title().'*'; $body = MiniWiki::WikiToText($this->_body, true); $app = MiniWiki::WikiToText($this->_append,false,4); - return trim("$title\n\n$body\n\n$app")."\n"; + $text = trim("$title\n\n$body\n\n$app")."\n"; + if (!is_null($hash) && !is_null($login)) { + $text = str_replace('%HASH%', "$hash/$login", $text); + } else { + $text = str_replace('%HASH%', '', $text); + } + return $text; } // }}} // {{{ function toHtml() - public function toHtml() + public function toHtml($hash = null, $login = null) { $title = "

".pl_entities($this->title()).'

'; $body = MiniWiki::WikiToHTML($this->_body); @@ -246,6 +255,11 @@ class NLArticle $art .= "
$app
"; } $art .= "\n"; + if (!is_null($hash) && !is_null($login)) { + $art = str_replace('%HASH%', "$hash/$login", $art); + } else { + $art = str_replace('%HASH%', '', $art); + } return $art; }