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 .= "
";
- } 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
";
+ $text .= "
\n
";
- $ns->tablerender(NWSLAN_4, $text);
+ $ns->tablerender(NWSLAN_4, $text);
}
+
function show_options($action) {
global $sql;