body = $body;
$this->title = $title;
$this->append = $append;
$this->aid = $aid;
$this->cid = $cid;
$this->pos = $pos;
}
// }}}
// {{{ function title()
public function title()
{ return trim($this->title); }
// }}}
// {{{ function body()
public function body()
{ return trim($this->body); }
// }}}
// {{{ function append()
public function append()
{ return trim($this->append); }
// }}}
// {{{ 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);
$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($hash = null, $login = null)
{
$title = "
".pl_entities($this->title()).'
';
$body = MiniWiki::WikiToHTML($this->body);
$app = MiniWiki::WikiToHTML($this->append);
$art = "$title\n";
$art .= "\n$body\n";
if ($app) {
$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;
}
// }}}
// {{{ function check()
public function check()
{
$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 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])
);
}
// }}}
}
// }}}
// vim:set et sw=4 sts=4 sws=4 fenc=utf-8:
?>