--- inc/pgLifestyle.php 2001/08/07 13:55:51 1.2 +++ inc/pgLifestyle.php 2001/08/08 12:58:08 1.3 @@ -10,33 +10,60 @@ newsDelete($del_id); unset($top_edit, $wn_edit, $pn_edit); } - $empty = array("category" => "l", "limit" => 1, "npar" => 1); - $arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["npar"]); - $art = array_shift($arts); - $ed = ""; - if ($top_edit && ($art["id"] == $ed_id || $ed_id <= 0)) { + # ---KLUDGE-BEGIN--- + $cat = ""; + if ($section == "conditions") $cat = "c"; + if ($section == "lifestyle") $cat = "l"; + # ---KLUDGE-END--- + if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); + if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); + if (!$offset) $offset = 0; + $empty = array("category" => $cat, "limit" => 11, "offset" => $offset, "npar" => 1); + if ($top_edit && $ed_id <= 0) { include_once("inc/newsEdit.php"); - $ed = newsEdit(($ed_id > 0) ? $art : $empty, "top_edit"); + $ed = newsEdit($empty, "top_edit"); + if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); + else $top_edit = false; } - if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); - else { - if ($ed && $ed["category"] == "l") $art = $ed; - $tpl->assign("top_id", $art["id"]); - $tpl->assign("top_title", MyEscape($art["title"])); - $tpl->assign("top_lead", MyEscape($art["lead"])); - $tpl->assign("top_titlepic_url", MyEscape($art["pic_url"])); - $tpl->assign("top_titlepic_alt", MyEscape($art["pic_alt"])); - $tpl->assign("top_titlepic_type", $art["pic_pos"]); - $tpl->assign("top_titlepic_width", $art["pic_w"]); - $tpl->assign("top_titlepic_height", $art["pic_h"]); - for ($j = 0; $j < count($art["text"]); $j++) - $art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"])); - $tpl->assign("top_text", $art["text"]); - include_once("inc/links.php"); - $tpl->assign("top_links", GetLinks($art["read"] && $art["id"], - MyEscape($art["more"]), $art["id"], $empty["category"], "top")); + $arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); + $a2 = array(); + $lm = count($arts); + if ($lm > $empty["limit"]) $lm = $empty["limit"]; + for ($i = 0; $i < $lm; $i++) { + $art = $arts[$i]; + $ed = ""; + if ($top_edit && ($art["id"] == $ed_id)) { + include_once("inc/newsEdit.php"); + $ed = newsEdit($art, "top_edit"); + } + if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); + else { + if ($ed && $ed["category"] == $cat) $art = $ed; + for ($j = 0; $j < count($art["text"]); $j++) + $art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"])); + include_once("inc/links.php"); + array_push($a2, array( + "id" => $art["id"], + "title" => MyEscape($art["title"]), + "lead" => MyEscape($art["lead"]), + "titlepic_url" => MyEscape($art["pic_url"]), + "titlepic_alt" => MyEscape($art["pic_alt"]), + "titlepic_type" => $art["pic_pos"], + "titlepic_width" => $art["pic_w"], + "titlepic_height" => $art["pic_h"], + "text" => $art["text"], + "links" => GetLinks($art["read"] && $art["id"], + MyEscape($art["more"]), $art["id"], + $empty["category"], "top", isEdit(), true, + ($i > 0), ($i < count($arts) - 1)) + )); + } } - $tpl->assign("top_edit", $top_edit); + $tpl->assign("top", $a2); + $tpl->assign("cat", $cat); + $tpl->assign("isedit", isEdit()); + $tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); + $tpl->assign("prev", ($offset > 0) ? ($offset - 10) : false); } $dbh->disconnect(); ?>