public function Show($full_text = false) { global $config, $user, $bd_names; if (!$this->Exist()) { return $this->ShowPage('news_not_found.html'); } $sql_text = $full_text ? ' `message_full`,' : ''; $sql_hits = ' `hits`,'; if ($full_text) { $this->countView(); $sql_hits = " LAST_INSERT_ID() AS hits,"; } $sql_likes = $this->vote ? ' `likes`, `dislikes`,' : ''; $line = getDB()->fetchRow("SELECT DATE_FORMAT(time,'%d.%m.%Y') AS `date`, DATE_FORMAT(time,'%H:%i') AS `time`, " . $sql_hits . $sql_likes . $sql_text . " `message` FROM `{$this->db}` WHERE `id`='" . $this->id . "'"); if (!$line) { return ''; } if ($full_text) { $line['message_full'] = TextBase::CutWordWrap($line['message_full']); } $line['message'] = TextBase::CutWordWrap($line['message']); $text = ($full_text and TextBase::StringLen($line['message_full'])) ? $line['message_full'] : $line['message']; $id = $this->id; $title = $this->title; $date = $line['date']; $time = $line['time']; $vote = $this->vote ? true : false; $likes = $this->vote ? $line['likes'] : '-'; $dlikes = $this->vote ? $line['dislikes'] : '-'; $hits = $line['hits']; $link = $this->link; $comments = $this->comments; $category_id = $this->category_id; $category = CategoryManager::GetNameByID($category_id); $category_link = Rewrite::GetURL(array('category', $category_id), array('', 'cid')); $admin_buttons = ''; if (!empty($user) and $user->getPermission('add_news')) { ob_start(); include $this->GetView('news_admin.html'); $admin_buttons = ob_get_clean(); } ob_start(); if ($full_text) { include $this->GetView('news_full.html'); } else { include $this->GetView('news.html'); } return ob_get_clean(); }
public static function Comment($text) { $text = trim($text); $text = TextBase::HTMLDestruct($text); $text = preg_replace('/(\\R{2})\\R++/Usi', '$1', $text); $text = nl2br($text); $text = TextBase::CutWordWrap($text); $text = TextBase::CutString($text); return $text; }