X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fmassmailer.inc.php;h=07d9ee6ca295791e6fb29ad9c201ca97b87ab37d;hb=08fa70684fd1332178cddb6b318151335fb4506c;hp=fce33ca73aab2349d456bfd4577773163ae6c6d1;hpb=fc9d9368a4c8781f26a34a8f28523073d645f508;p=platal.git diff --git a/include/massmailer.inc.php b/include/massmailer.inc.php index fce33ca..07d9ee6 100644 --- a/include/massmailer.inc.php +++ b/include/massmailer.inc.php @@ -1,6 +1,6 @@ _table} AS n WHERE n.bits != 'new' AND {$where} - LIMIT 1"); + LIMIT 1"); if ($res->numRows() != 1) { return null; } @@ -108,7 +108,7 @@ abstract class MassMailer public function head($prenom = null, $nom = null, $sexe = null, $type = 'text') { if (is_null($prenom)) { - return $this->_head; + return $this->_head; } else { $head = $this->_head; $head = str_replace('', $sexe ? 'Chère' : 'Cher', $head); @@ -133,7 +133,7 @@ abstract class MassMailer { $this->css($page); $page->assign('is_mail', false); - $page->assign('html_version', false); + $page->assign('mail_part', 'text'); $page->assign('prenom', $prenom); $page->assign('nom', $nom); $page->assign('sexe', $sexe); @@ -145,7 +145,7 @@ abstract class MassMailer $this->css($page); $page->assign('prefix', $this->_prefix . '/' . $this->id()); $page->assign('is_mail', false); - $page->assign('html_version', true); + $page->assign('mail_part', 'html'); $page->assign('prenom', $prenom); $page->assign('nom', $nom); $page->assign('sexe', $sexe); @@ -204,7 +204,7 @@ abstract class MassMailer XDB::execute("UPDATE {$this->_subscriptionTable} SET last = {?} WHERE " . implode(' OR ', $sent), $this->_id); - + sleep(60); } } @@ -218,93 +218,15 @@ abstract class MassMailer // }}} // {{{ Functions -function justify($text,$n) -{ - $arr = explode("\n",wordwrap($text,$n)); - $arr = array_map('trim',$arr); - $res = ''; - foreach ($arr as $key => $line) { - $nxl = isset($arr[$key+1]) ? trim($arr[$key+1]) : ''; - $nxl_split = preg_split('! +!',$nxl); - $nxw_len = count($nxl_split) ? strlen($nxl_split[0]) : 0; - $line = trim($line); - - if (strlen($line)+1+$nxw_len < $n) { - $res .= "$line\n"; - continue; - } - - if (preg_match('![.:;]$!',$line)) { - $res .= "$line\n"; - continue; - } - - $tmp = preg_split('! +!',trim($line)); - $words = count($tmp); - if ($words <= 1) { - $res .= "$line\n"; - continue; - } - - $len = array_sum(array_map('strlen',$tmp)); - $empty = $n - $len; - $sw = floatval($empty) / floatval($words-1); - - $cur = 0; - $l = ''; - foreach ($tmp as $word) { - $l .= $word; - $cur += $sw + strlen($word); - $l = str_pad($l,intval($cur+0.5)); - } - $res .= trim($l)."\n"; - } - return trim($res); -} - function format_text($input, $format, $indent = 0, $width = 68) { if ($format == 'text') { - return enriched_to_text($input, false, true, $indent, $width); + return MiniWiki::WikiToText($input, true, $indent, $width, "title"); } - return enriched_to_text($input, true); + return MiniWiki::WikiToHTML($input, "title"); } -function enriched_to_text($input,$html=false,$just=false,$indent=0,$width=68) -{ - $text = trim($input); - if ($html) { - $text = htmlspecialchars($text); - $text = str_replace('[b]','', $text); - $text = str_replace('[/b]','', $text); - $text = str_replace('[i]','', $text); - $text = str_replace('[/i]','', $text); - $text = str_replace('[u]','', $text); - $text = str_replace('[/u]','', $text); - $text = preg_replace("!(\\s*\n)*\[title\]!",'

',$text); - $text = preg_replace("!\[\/title\](\\s*\n)*!", '

',$text); - $text = preg_replace("!(\\s*\n)*\[subtitle\]!",'

',$text); - $text = preg_replace("!\[\/subtitle\](\\s*\n)*!",'

',$text); - - require_once('url_catcher.inc.php'); - $text = url_catcher($text); - return nl2br($text); - } else { - $text = preg_replace('!\[\/?b\]!','*',$text); - $text = preg_replace('!\[\/?u\]!','_',$text); - $text = preg_replace('!\[\/?i\]!','/',$text); - $text = preg_replace('!\[\/?title\]!','***', $text); - $text = preg_replace('!\[\/?subtitle\]!','**', $text); - $text = preg_replace('!(((https?|ftp)://|www\.)[^\r\n\t ]*)!','[\1]', $text); - $text = preg_replace('!(([a-zA-Z0-9\-_+.]*@[a-zA-Z0-9\-_+.]*)(?:\?[^\r\n\t ]*)?)!','[mailto:\1]', $text); - $text = $just ? justify($text,$width-$indent) : wordwrap($text,$width-$indent); - if($indent) { - $ind = str_pad('',$indent); - $text = $ind.str_replace("\n","\n$ind",$text); - } - return $text; - } -} +// function enriched_to_text($input,$html=false,$just=false,$indent=0,$width=68) // }}}