From 43541e251b1f0443708c856ca5286da830cc8ec8 Mon Sep 17 00:00:00 2001 From: e107steved Date: Fri, 26 Oct 2007 21:51:05 +0000 Subject: [PATCH] Bugtracker #4166 - newspost sorting for admin --- e107_admin/newspost.php | 123 ++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 54 deletions(-) diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 3e9f41f46..8277228d6 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ -| $Revision: 1.9 $ -| $Date: 2007-10-07 20:30:54 $ -| $Author: mcfly_e107 $ +| $Revision: 1.10 $ +| $Date: 2007-10-26 21:51:05 $ +| $Author: e107steved $ +---------------------------------------------------------------+ */ @@ -57,11 +57,15 @@ $rs = new form; $ix = new news; -if (e_QUERY) { - list($action, $sub_action, $id, $from) = explode(".", e_QUERY); - $id = intval($id); - $from = intval($from); - unset($tmp); +if (e_QUERY) +{ + $tmp = explode(".", e_QUERY); + $action = $tmp[0]; + $sub_action = varset($tmp[1],''); + $id = intval(varset($tmp[2],0)); + $sort_order = varset($tmp[2],'desc'); + $from = intval(varset($tmp[3],0)); + unset($tmp); } $from = ($from ? $from : 0); @@ -217,8 +221,9 @@ if (isset($_POST['save_prefs'])) { $newspost->show_message(NWSLAN_119); } -if (!e_QUERY || $action == "main") { - $newspost->show_existing_items($action, $sub_action, $id, $from, $amount); +if (!e_QUERY || $action == "main") +{ + $newspost->show_existing_items($action, $sub_action, $sort_order, $from, $amount); } if ($action == "create") { @@ -272,52 +277,58 @@ function fclear() { require_once("footer.php"); exit; -class newspost { +class newspost +{ + function show_existing_items($action, $sub_action, $sort_order, $from, $amount) + { + // ##### Display scrolling list of existing news items --------------------------------------------------------------------------------------------------------- + global $sql, $ns, $tp, $imode; + $text = "
"; - function show_existing_items($action, $sub_action, $id, $from, $amount) { - // ##### Display scrolling list of existing news items --------------------------------------------------------------------------------------------------------- - global $sql, $rs, $ns, $tp, $imode; - $text = "
"; + if (!$sort_order) $sort_order = 'desc'; + if ($sort_order != 'asc') $sort_order = 'desc'; + $sort_link = $sort_order == 'asc' ? 'desc' : 'asc'; // Effectively toggle setting for headings + + if (isset($_POST['searchquery'])) + { + $query = "news_title REGEXP('".$_POST['searchquery']."') OR news_body REGEXP('".$_POST['searchquery']."') OR news_extended REGEXP('".$_POST['searchquery']."') ORDER BY news_datestamp DESC"; + } + else + { + $query = "ORDER BY ".($sub_action ? $sub_action : "news_datestamp")." ".strtoupper($sort_order)." LIMIT {$from}, {$amount}"; + } - if (isset($_POST['searchquery'])) { - $query = "news_title REGEXP('".$_POST['searchquery']."') OR news_body REGEXP('".$_POST['searchquery']."') OR news_extended REGEXP('".$_POST['searchquery']."') ORDER BY news_datestamp DESC"; - } else { - $query = "ORDER BY ".($sub_action ? $sub_action : "news_datestamp")." ".($id ? $id : "DESC")." LIMIT $from, $amount"; - } - - if ($sql->db_Select("news", "*", $query, ($_POST['searchquery'] ? 0 : "nowhere"))) - { - - $newsarray = $sql -> db_getList(); - $text .= " + if ($sql->db_Select("news", "*", $query, ($_POST['searchquery'] ? 0 : "nowhere"))) + { + $newsarray = $sql -> db_getList(); + $text .= "
- - + + "; - $ren_type = array("default","title","other-news","other-news 2"); - foreach($newsarray as $row) - { - extract($row); + $ren_type = array("default","title","other-news","other-news 2"); + foreach($newsarray as $row) + { + extract($row); // Note: To fix the alignment bug. Put both buttons inside the Form. // But make EDIT a 'button' and DELETE 'submit' - - $text .= " - - + $text .= " + + "; - } - $text .= "
".LAN_NEWS_45."".NWSLAN_40."".LAN_NEWS_45."".NWSLAN_40." ".LAN_NEWS_49." ".LAN_OPTIONS."
$news_id".($news_title ? $tp->toHTML($news_title,"","no_hook,emotes_off,no_make_clickable") : "[".NWSLAN_42."]")."
{$news_id}".($news_title ? $tp->toHTML($news_title,"","no_hook,emotes_off,no_make_clickable") : "[".NWSLAN_42."]")." "; - $text .= $ren_type[$news_render_type]; - if($news_sticky) - { - $sicon = (file_exists(THEME."images/sticky.png") ? THEME."images/sticky.png" : e_IMAGE."packs/".$imode."/generic/sticky.png"); - $text .= " "; - } - $text .= " + $text .= $ren_type[$news_render_type]; + if($news_sticky) + { + $sicon = (file_exists(THEME."images/sticky.png") ? THEME."images/sticky.png" : e_IMAGE."packs/".$imode."/generic/sticky.png"); + $text .= " "; + } + $text .= " @@ -325,27 +336,31 @@ class newspost {
"; - } else { - $text .= "
".NWSLAN_43."
"; } + $text .= ""; + } + else + { + $text .= "
".NWSLAN_43."
"; + } - $newsposts = $sql->db_Count("news"); + $newsposts = $sql->db_Count("news"); - if (!$_POST['searchquery']) { - $parms = $newsposts.",".$amount.",".$from.",".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.news_datestamp.desc.")."[FROM]"; - $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}"); + if (!$_POST['searchquery']) + { + $parms = $newsposts.",".$amount.",".$from.",".e_SELF."?".(e_QUERY ? "$action.$sub_action.$sort_order." : "main.news_datestamp.desc.")."[FROM]"; + $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}"); - } + } - $text .= "
\n

\n\n\n

\n
\n
"; + $text .= "
\n

\n\n\n

\n
\n
"; - $ns->tablerender(NWSLAN_4, $text); + $ns->tablerender(NWSLAN_4, $text); } + function show_options($action) { global $sql;