255) { $news_search = substr($news_search, 0, 255); }
$xtpl->assign("SEARCH_VALUE", htmlspecialchars($news_search));
$news_search = addslashes($news_search);
$search_string = "";
if ($news_search != "") {
$search_string .= " AND (news.subject LIKE '%".$news_search."%' OR news.announce LIKE '%".$news_search."%' OR news.content LIKE '%".$news_search."%' ".($isShowAuthor ? "OR news_user.name LIKE '%".$news_search."%'" : "").")";
}
$sSQL_cnt = "SELECT count(*) As Total FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 ".$search_string;
$result_cnt = mysql_query($sSQL_cnt, $link);
$row = mysql_fetch_object($result_cnt);
$nrows = $row -> Total;
$navbar = pager($page, $pageSize, $nrows, $script_name, $news_search != "" ? "news_search=".urlencode(stripslashes($news_search)) : "");
$offset = (intval($page) - 1)*$pageSize;
$sSQL = "SELECT news.news_id, DATE_FORMAT(news.issuedate,\"%d-%m-%Y\") As fissuedate, news.subject, news.announce, news.importance, news.is_add_comment, news_user.name As user_name
FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 ".$search_string."
ORDER BY news.issuedate DESC, news.news_id DESC LIMIT $offset,$pageSize";
$result = mysql_query($sSQL, $link);
$nr = mysql_num_rows($result);
if ($nr == 0) {
$xtpl->parse("news.content.is_comments");
$xtpl->reset("news.content.is_comments");
$xtpl->parse("news.content");
$xtpl->reset("news.content");
}
while($row = mysql_fetch_array($result)) {
if ($row["importance"] == 1) { $style = "importance"; } else { $style = "base"; }
$rs_comments = mysql_query("SELECT count(*) FROM news_comment WHERE news_id = ".$row["news_id"], $link);
$row_comments = mysql_fetch_array($rs_comments);
if ($row["is_add_comment"] != 1 && $row_comments[0] == 0) {
$xtpl->parse("news.content.is_comments");
$xtpl->reset("news.content.is_comments");
} else {
$xtpl->assign("COMMENT_COUNT", $row_comments[0]);
$xtpl->parse("news.content.is_comments");
}
$xtpl->assign("SCRIPT_NAME", $script_name);
$xtpl->assign("NEWS_ID", $row["news_id"]);
$xtpl->assign("ISSUEDATE", $row["fissuedate"]);
$xtpl->assign("SUBJECT", $row["subject"]);
$xtpl->assign("AUTHOR", $isShowAuthor ? " | ".htmlspecialchars($row["user_name"])."" : "");
$xtpl->assign("ANNOUNCE", $row["announce"]);
$xtpl->assign("STYLE", $style);
$xtpl->parse("news.content");
}
if ($navbar != "") {
$xtpl->assign("NAVBAR", $navbar);
$xtpl->parse("news.pager");
} else {
$xtpl->parse("news.pager");
$xtpl->reset("news.pager");
}
$xtpl->assign("SCRIPT_NAME", $script_name);
$xtpl->parse("news");
$xtpl->out("news");
mysql_close($link);
}
function Detail() {
global $link, $id, $print, $isShowAuthor;
if ($print == "1")
$xtpl=new XTemplate ("./templates/printable.html");
else
$xtpl=new XTemplate ("./templates/news_detail.html");
$sSQL = "SELECT news.news_id, DATE_FORMAT(news.issuedate,\"%d-%m-%Y\") As fissuedate, news.subject, news.content, news.importance, news.img, news.img_description, news.is_add_comment, news_user.name As user_name
FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 AND news.news_id = " . $id;
$result = mysql_query($sSQL, $link);
$nr = mysql_num_rows($result);
$row = mysql_fetch_array($result);
if ($row["importance"] == 1) { $style = "importance"; } else { $style = "base"; }
if ($row["img"] != "")
$img = "