Parašė tabux· 2008 Lap. 21 22:11:39
#8
Sutvarkiau, pakeisk news_cat.php turini suio ir viskas
<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
// begin of function makepagenav_cat
// original function makepagenav in maincore.php
function makepagenav_cat($start,$count,$total,$range=0,$link="",$cat_id){
global $locale;
if ($link == "") $link = fusion_romguard_SELF."?";
$res="";
$pg_cnt=ceil($total / $count);
if ($pg_cnt > 1) {
$idx_back = $start - $count;
$idx_next = $start + $count;
$cur_page=ceil(($start + 1) / $count);
$res.="<table cellspacing='1' cellpadding='1' border='0' class='tbl-border'>\n<tr>\n";
$res.="<td class='tbl2'><span class='small'>".$locale['052']."$cur_page".$locale['053']."$pg_cnt</span></td>\n";
if ($idx_back >= 0) {
if ($cur_page > ($range + 1)) $res.="<td class='tbl2'><a class='small' href='$link"."rowstart=0&cat_id".$cat_id."'><<</a></td>\n";
$res.="<td class='tbl2'><a class='small' href='$link"."rowstart=$idx_back&cat_id=".$cat_id."'><</a></td>\n";
}
$idx_fst=max($cur_page - $range, 1);
$idx_lst=min($cur_page + $range, $pg_cnt);
if ($range==0) {
$idx_fst = 1;
$idx_lst=$pg_cnt;
}
for($i=$idx_fst;$i<=$idx_lst;$i++) {
$offset_page=($i - 1) * $count;
if ($i==$cur_page) {
$res.="<td class='tbl1'><span class='small'><b>$i</b></span></td>\n";
} else {
$res.="<td class='tbl1'><a class='small' href='news_cats.php?"."rowstart=".$offset_page."&cat_id=".$cat_id."'>$i</a></td>\n";
}
}
if ($idx_next < $total) {
$res.="<td class='tbl2'><a class='small' href='$link"."rowstart=$idx_next&cat_id=".$cat_id."'>></a></td>\n";
if ($cur_page < ($pg_cnt - $range)) $res.="<td class='tbl2'><a class='small' href='$link"."rowstart=".($pg_cnt-1)*$count."&cat_id=".$cat_id."'>>></a></td>\n";
}
$res.="</tr>\n</table>\n";
}
return $res;
}
// end of function makepagenav_cat
// gets news category
$cat_id = $_GET['cat_id'];
// begin news output
if (!isset($readmore)) {
$items_per_page = 5; //your number of items per page here
$rows = dbcount("(news_id)", "news", "news_cat='".$data['news_cat_id']."' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().")");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$i = 1;
$result = dbquery(
"SELECT tn.*, user_id, user_name FROM ".$db_prefix."news tn
LEFT JOIN ".$db_prefix."users tu ON tn.news_name=tu.user_id
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND (news_cat=$cat_id)
ORDER BY news_datestamp DESC LIMIT $rowstart,$items_per_page"
);
$numrows = dbrows($result);
while ($data = dbarray($result)) {
$news_cat_image = "";
$news_subject = "<a name='news_".$data['news_id']."' id='news_".$data['news_id']."'></a>".stripslashes($data['news_subject']);
if ($data['news_cat'] != 0) {
$result2 = dbquery("SELECT * FROM ".$db_prefix."news_cats WHERE news_cat_id='".$data['news_cat']."'");
if (dbrows($result2)) {
$data2 = dbarray($result2);
}
}
$news_news = stripslashes($data['news_news']);
if ($data['news_breaks'] == "y") $news_news = nl2br($news_news);
if ($news_cat_image != "") $news_news = $news_cat_image.$news_news;
$news_info = array(
"news_id" => $data['news_id'],
"kategorija" => $data['news_cat_name'],
"kategorija" => $data2['news_cat_name'],
"kat_id" => $data['news_cat_id'],
"kat_id" => $data2['news_cat_id'],
"user_id" => $data['user_id'],
"user_name" => $data['user_name'],
"news_date" => $data['news_datestamp'],
"news_ext" => $data['news_extended'] ? "y" : "n",
"news_reads" => $data['news_reads'],
"news_comments" => dbcount("(comment_id)", "comments", "comment_type='N' AND comment_item_id='".$data['news_id']."'"),
"news_allow_comments" => $data['news_allow_comments']
);
render_news($news_subject, $news_news, $news_info);
if ($i != $numrows) { tablebreak(); } $i++;
}
if ($rows > $items_per_page) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav_cat($rowstart,$items_per_page,$rows,6,"",$cat_id)."\n</div>\n";
} else {
opentable($locale['046']);
echo "<center><br>\n".$locale['047']."<br><br>\n</center>\n";
closetable();
}
}
// end news output
require_once "side_right.php";
require_once "footer.php";
?>