X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fnewsletter.inc.php;h=0ee1423d9989675f2038701f8678fade1236caf0;hb=4d61c1bbf33a48033b9f172645b6b7b179aaf9b9;hp=667099cdb4b948b2bb59841b5263fde35e1294f0;hpb=fec93430ae2ac9655fbfc8471456f3bae88caa20;p=platal.git diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 667099c..0ee1423 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -1124,7 +1124,8 @@ class NLIssue class NLArticle { // Maximum number of lines per article - const MAX_LINES_PER_ARTICLE = 9; + const MAX_LINES_PER_ARTICLE = 8; + const MAX_CHARACTERS_PER_LINE = 68; // {{{ properties @@ -1212,17 +1213,30 @@ class NLArticle public function check() { - $text = MiniWiki::WikiToText($this->body); - $arr = explode("\n",wordwrap($text,68)); - $c = 0; - foreach ($arr as $line) { - if (trim($line)) { - $c++; + $rest = $this->remain(); + + return $rest['remaining_lines'] >= 0; + } + + // }}} + // {{{ function remain() + + public function remain() + { + $text = MiniWiki::WikiToText($this->body); + $array = explode("\n", wordwrap($text, self::MAX_CHARACTERS_PER_LINE)); + $lines_count = 0; + foreach ($array as $line) { + if (trim($line) != '') { + ++$lines_count; } } - return $c < self::MAX_LINES_PER_ARTICLE; - } + return array( + 'remaining_lines' => self::MAX_LINES_PER_ARTICLE - $lines_count, + 'remaining_characters_for_last_line' => self::MAX_CHARACTERS_PER_LINE - strlen($array[count($array) - 1]) + ); + } // }}} // {{{ function parseUrlsFromArticle()