mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Bugtracker #4166 - newspost sorting for admin
This commit is contained in:
@@ -11,9 +11,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
||||||
| $Revision: 1.9 $
|
| $Revision: 1.10 $
|
||||||
| $Date: 2007-10-07 20:30:54 $
|
| $Date: 2007-10-26 21:51:05 $
|
||||||
| $Author: mcfly_e107 $
|
| $Author: e107steved $
|
||||||
+---------------------------------------------------------------+
|
+---------------------------------------------------------------+
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@@ -57,10 +57,14 @@ $rs = new form;
|
|||||||
$ix = new news;
|
$ix = new news;
|
||||||
|
|
||||||
|
|
||||||
if (e_QUERY) {
|
if (e_QUERY)
|
||||||
list($action, $sub_action, $id, $from) = explode(".", e_QUERY);
|
{
|
||||||
$id = intval($id);
|
$tmp = explode(".", e_QUERY);
|
||||||
$from = intval($from);
|
$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);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +221,9 @@ if (isset($_POST['save_prefs'])) {
|
|||||||
$newspost->show_message(NWSLAN_119);
|
$newspost->show_message(NWSLAN_119);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e_QUERY || $action == "main") {
|
if (!e_QUERY || $action == "main")
|
||||||
$newspost->show_existing_items($action, $sub_action, $id, $from, $amount);
|
{
|
||||||
|
$newspost->show_existing_items($action, $sub_action, $sort_order, $from, $amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "create") {
|
if ($action == "create") {
|
||||||
@@ -272,30 +277,37 @@ function fclear() {
|
|||||||
require_once("footer.php");
|
require_once("footer.php");
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
class newspost {
|
class newspost
|
||||||
|
{
|
||||||
|
|
||||||
|
function show_existing_items($action, $sub_action, $sort_order, $from, $amount)
|
||||||
function show_existing_items($action, $sub_action, $id, $from, $amount) {
|
{
|
||||||
// ##### Display scrolling list of existing news items ---------------------------------------------------------------------------------------------------------
|
// ##### Display scrolling list of existing news items ---------------------------------------------------------------------------------------------------------
|
||||||
global $sql, $rs, $ns, $tp, $imode;
|
global $sql, $ns, $tp, $imode;
|
||||||
$text = "<div style='text-align:center'>";
|
$text = "<div style='text-align:center'>";
|
||||||
|
|
||||||
if (isset($_POST['searchquery'])) {
|
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";
|
$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";
|
else
|
||||||
|
{
|
||||||
|
$query = "ORDER BY ".($sub_action ? $sub_action : "news_datestamp")." ".strtoupper($sort_order)." LIMIT {$from}, {$amount}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sql->db_Select("news", "*", $query, ($_POST['searchquery'] ? 0 : "nowhere")))
|
if ($sql->db_Select("news", "*", $query, ($_POST['searchquery'] ? 0 : "nowhere")))
|
||||||
{
|
{
|
||||||
|
|
||||||
$newsarray = $sql -> db_getList();
|
$newsarray = $sql -> db_getList();
|
||||||
$text .= "
|
$text .= "
|
||||||
<form action='".e_SELF."' id='newsform' method='post'>
|
<form action='".e_SELF."' id='newsform' method='post'>
|
||||||
<table class='fborder' style='".ADMIN_WIDTH."'>
|
<table class='fborder' style='".ADMIN_WIDTH."'>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='width:5%' class='fcaption'><a href='".e_SELF."?main.news_id.".($id == "desc" ? "asc" : "desc").".$from'>".LAN_NEWS_45."</a></td>
|
<td style='width:5%' class='fcaption'><a href='".e_SELF."?main.news_id.{$sort_link}.{$from}'>".LAN_NEWS_45."</a></td>
|
||||||
<td style='width:55%' class='fcaption'><a href='".e_SELF."?main.news_title.".($id == "desc" ? "asc" : "desc").".$from'>".NWSLAN_40."</a></td>
|
<td style='width:55%' class='fcaption'><a href='".e_SELF."?main.news_title.{$sort_link}.{$from}'>".NWSLAN_40."</a></td>
|
||||||
<td style='width:15%' class='fcaption'>".LAN_NEWS_49."</td>
|
<td style='width:15%' class='fcaption'>".LAN_NEWS_49."</td>
|
||||||
<td style='width:15%' class='fcaption'>".LAN_OPTIONS."</td>
|
<td style='width:15%' class='fcaption'>".LAN_OPTIONS."</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
@@ -306,10 +318,9 @@ class newspost {
|
|||||||
|
|
||||||
// Note: To fix the alignment bug. Put both buttons inside the Form.
|
// Note: To fix the alignment bug. Put both buttons inside the Form.
|
||||||
// But make EDIT a 'button' and DELETE 'submit'
|
// But make EDIT a 'button' and DELETE 'submit'
|
||||||
|
|
||||||
$text .= "<tr>
|
$text .= "<tr>
|
||||||
<td style='width:5%' class='forumheader3'>$news_id</td>
|
<td style='width:5%' class='forumheader3'>{$news_id}</td>
|
||||||
<td style='width:55%' class='forumheader3'><a href='".e_BASE."news.php?item.$news_id.$news_category'>".($news_title ? $tp->toHTML($news_title,"","no_hook,emotes_off,no_make_clickable") : "[".NWSLAN_42."]")."</a></td>
|
<td style='width:55%' class='forumheader3'><a href='".e_BASE."news.php?item.{$news_id}.{$news_category}'>".($news_title ? $tp->toHTML($news_title,"","no_hook,emotes_off,no_make_clickable") : "[".NWSLAN_42."]")."</a></td>
|
||||||
<td style='20%' class='forumheader3'>";
|
<td style='20%' class='forumheader3'>";
|
||||||
$text .= $ren_type[$news_render_type];
|
$text .= $ren_type[$news_render_type];
|
||||||
if($news_sticky)
|
if($news_sticky)
|
||||||
@@ -327,14 +338,17 @@ class newspost {
|
|||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
$text .= "</table></form>";
|
$text .= "</table></form>";
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$text .= "<div style='text-align:center'>".NWSLAN_43."</div>";
|
$text .= "<div style='text-align:center'>".NWSLAN_43."</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$newsposts = $sql->db_Count("news");
|
$newsposts = $sql->db_Count("news");
|
||||||
|
|
||||||
if (!$_POST['searchquery']) {
|
if (!$_POST['searchquery'])
|
||||||
$parms = $newsposts.",".$amount.",".$from.",".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.news_datestamp.desc.")."[FROM]";
|
{
|
||||||
|
$parms = $newsposts.",".$amount.",".$from.",".e_SELF."?".(e_QUERY ? "$action.$sub_action.$sort_order." : "main.news_datestamp.desc.")."[FROM]";
|
||||||
$text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}");
|
$text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -346,6 +360,7 @@ class newspost {
|
|||||||
$ns->tablerender(NWSLAN_4, $text);
|
$ns->tablerender(NWSLAN_4, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_options($action) {
|
function show_options($action) {
|
||||||
global $sql;
|
global $sql;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user