1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Sets up initial sort order on downloads table according to options

This commit is contained in:
e107steved
2008-05-25 14:51:07 +00:00
parent d3e27254f4
commit 3d8ac48c3e

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/download.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/download.php,v $
| $Revision: 1.9 $ | $Revision: 1.10 $
| $Date: 2008-03-09 20:33:03 $ | $Date: 2008-05-25 14:51:07 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -58,12 +58,14 @@ $pst->save_preset("admin_downloads"); // unique name for the preset
*/ */
$rs = new form; $rs = new form;
if (e_QUERY) { $sub_action = '';
if (e_QUERY)
{
$tmp = explode(".", e_QUERY); $tmp = explode(".", e_QUERY);
$action = $tmp[0]; $action = $tmp[0];
$sub_action = $tmp[1]; $sub_action = varset($tmp[1],'');
$id = $tmp[2]; $id = varset($tmp[2],'');
$from = ($tmp[3] ? $tmp[3] : 0); $from = varset($tmp[3], 0);
unset($tmp); unset($tmp);
} }
@@ -78,20 +80,26 @@ $from = ($from ? $from : 0);
$amount = 50; $amount = 50;
if($file_array = $fl->get_files(e_DOWNLOAD, "","standard",5)){ if($file_array = $fl->get_files(e_DOWNLOAD, "","standard",5))
{
sort($file_array); sort($file_array);
} }
if($public_array = $fl->get_files(e_FILE."public/")){
foreach($public_array as $key=>$val){ if($public_array = $fl->get_files(e_FILE."public/"))
{
foreach($public_array as $key=>$val)
{
$file_array[] = str_replace(e_FILE."public/","",$val); $file_array[] = str_replace(e_FILE."public/","",$val);
} }
} }
if ($sql->db_Select("rbinary")){ if ($sql->db_Select("rbinary"))
while ($row = $sql->db_Fetch()) { {
while ($row = $sql->db_Fetch())
{
extract($row); extract($row);
$file_array[] = "Binary ".$binary_id."/".$binary_name; $file_array[] = "Binary ".$binary_id."/".$binary_name;
} }
@@ -107,15 +115,20 @@ if($thumb_array = $fl->get_files(e_FILE."downloadthumbs/", ".gif|.jpg|.png|.GIF|
sort($thumb_array); sort($thumb_array);
} }
if(isset($_POST)){
if(isset($_POST))
{
$e107cache->clear("download_cat"); $e107cache->clear("download_cat");
} }
if (isset($_POST['add_category'])) { if (isset($_POST['add_category']))
{
$download->create_category($sub_action, $id); $download->create_category($sub_action, $id);
} }
if (isset($_POST['submit_download'])) { if (isset($_POST['submit_download']))
{
$download->submit_download($sub_action, $id); $download->submit_download($sub_action, $id);
$action = "main"; $action = "main";
unset($sub_action, $id); unset($sub_action, $id);
@@ -152,6 +165,7 @@ if (isset($_POST['updateoptions']))
$message = DOWLAN_65; $message = DOWLAN_65;
} }
if(isset($_POST['addlimit'])) if(isset($_POST['addlimit']))
{ {
if($sql->db_Select('generic','gen_id',"gen_type = 'download_limit' AND gen_datestamp = {$_POST['newlimit_class']}")) if($sql->db_Select('generic','gen_id',"gen_type = 'download_limit' AND gen_datestamp = {$_POST['newlimit_class']}"))
@@ -171,6 +185,7 @@ if(isset($_POST['addlimit']))
} }
} }
if(isset($_POST['updatelimits'])) if(isset($_POST['updatelimits']))
{ {
@@ -202,11 +217,13 @@ if(isset($_POST['updatelimits']))
} }
} }
if(isset($_POST['submit_mirror'])) if(isset($_POST['submit_mirror']))
{ {
$download->submit_mirror($sub_action, $id); $download->submit_mirror($sub_action, $id);
} }
if($action == "mirror") if($action == "mirror")
{ {
$download -> show_existing_mirrors(); $download -> show_existing_mirrors();
@@ -220,22 +237,30 @@ if ($action == "dlm")
$sub_action = "dlm"; $sub_action = "dlm";
} }
if ($action == "create") {
if ($action == "create")
{
$download->create_download($sub_action, $id); $download->create_download($sub_action, $id);
} }
if ($delete == 'category') {
if (admin_update($sql->db_Delete("download_category", "download_category_id='$del_id' "), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36)) { if ($delete == 'category')
{
if (admin_update($sql->db_Delete("download_category", "download_category_id='$del_id' "), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36))
{
$sql->db_Delete("download_category", "download_category_parent='{$del_id}' "); $sql->db_Delete("download_category", "download_category_parent='{$del_id}' ");
} }
} }
if ($action == "cat") {
if ($action == "cat")
{
$download->show_categories($sub_action, $id); $download->show_categories($sub_action, $id);
} }
if ($delete == 'main') {
if ($delete == 'main')
{
$result = admin_update($sql->db_Delete("download", "download_id='$del_id' "), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36); $result = admin_update($sql->db_Delete("download", "download_id='$del_id' "), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36);
if($result) if($result)
{ {
@@ -246,11 +271,15 @@ if ($delete == 'main') {
} }
if (isset($message)) { if (isset($message))
{
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>"); $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
} }
if (!e_QUERY || $action == "main") {
if (!e_QUERY || $action == "main")
{
$download->show_existing_items($action, $sub_action, $id, $from, $amount); $download->show_existing_items($action, $sub_action, $id, $from, $amount);
} }
@@ -458,39 +487,50 @@ if($action == 'limits')
exit; exit;
} }
//$download->show_options($action);
require_once("footer.php"); require_once("footer.php");
exit; exit;
class download {
function show_existing_items($action, $sub_action, $id, $from, $amount) {
class download
{
function show_existing_items($action, $sub_action, $id, $from, $amount)
{
global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref; global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref;
$text = "<div style='text-align:center'><div style='padding : 1px; ".ADMIN_WIDTH."; margin-left: auto; margin-right: auto;'>"; $text = "<div style='text-align:center'><div style='padding : 1px; ".ADMIN_WIDTH."; margin-left: auto; margin-right: auto;'>";
$sortorder = ($pref['download_order']) ? $pref['download_order'] : "download_datestamp"; $sortorder = ($pref['download_order']) ? $pref['download_order'] : "download_datestamp";
if(isset($_POST['searchdisp'])){ $sortdirection = ($pref['download_sort']) ? strtolower($pref['download_sort']) : "desc";
if ($sortdirection != 'desc') $sortdirection = 'asc';
if(isset($_POST['searchdisp']))
{
$pref['admin_download_disp'] = implode("|",$_POST['searchdisp']); $pref['admin_download_disp'] = implode("|",$_POST['searchdisp']);
save_prefs(); save_prefs();
} }
if(!$pref['admin_download_disp']){ if(!$pref['admin_download_disp'])
{
$search_display = array("download_name","download_class"); $search_display = array("download_name","download_class");
}else{ }
else
{
$search_display = explode("|",$pref['admin_download_disp']); $search_display = explode("|",$pref['admin_download_disp']);
} }
// $query = "SELECT d.*, dc.* FROM #download AS d LEFT JOIN #download_category AS dc ON dc. download_category_id = d.download_category";
$query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id = d.download_category"; $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id = d.download_category";
if (isset($_POST['searchquery']) && $_POST['searchquery'] != "") { if (isset($_POST['searchquery']) && $_POST['searchquery'] != "")
{
$query .= " WHERE download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description REGEXP('".$_POST['searchquery']."') "; $query .= " WHERE download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description REGEXP('".$_POST['searchquery']."') ";
foreach($search_display as $disp){ foreach($search_display as $disp)
{
$query .= " OR $disp REGEXP('".$_POST['searchquery']."') "; $query .= " OR $disp REGEXP('".$_POST['searchquery']."') ";
} }
$query .= " ORDER BY ".$sortorder." DESC"; $query .= " ORDER BY {$sortorder} {$sortdirection}";
} else { }
$query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : "DESC")." LIMIT $from, $amount"; else
{
$query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount";
} }
if ($dl_count = $sql->db_Select_gen($query)) if ($dl_count = $sql->db_Select_gen($query))
@@ -505,13 +545,13 @@ class download {
foreach($search_display as $disp) foreach($search_display as $disp)
{ {
if($disp == "download_name") if($disp == "download_name")
{ { // Toggle direction
$text .= "<td class='fcaption'><a href='".e_SELF."?main.download_name.".($id == "desc" ? "asc" : "desc").".$from'>".DOWLAN_27."</a></td>"; $text .= "<td class='fcaption'><a href='".e_SELF."?main.download_name.".($id == "desc" ? "asc" : "desc").".$from'>".DOWLAN_27."</a></td>";
} }
else else
{ {
$repl = array("download_","_"); $repl = array("download_","_");
$text .= "<td class='fcaption'><a href='".e_SELF."?main.$disp.".($id == "desc" ? "asc" : "desc").".$from'>".ucwords(str_replace($repl," ",$disp))."</a></td>"; $text .= "<td class='fcaption'><a href='".e_SELF."?main.{$disp}.".($id == "desc" ? "asc" : "desc").".$from'>".ucwords(str_replace($repl," ",$disp))."</a></td>";
} }
} }
@@ -596,7 +636,7 @@ class download {
$downloads = $sql->db_Count("download"); $downloads = $sql->db_Count("download");
if ($downloads > $amount && !$_POST['searchquery']) if ($downloads > $amount && !$_POST['searchquery'])
{ {
$parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.download_id.desc.")."[FROM]"; $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]";
$text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}"); $text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}");
} }
@@ -614,12 +654,14 @@ class download {
} }
$m = 0; $m = 0;
$replacechar = array("download_","_"); $replacechar = array("download_","_");
foreach($fname as $fcol){ foreach($fname as $fcol)
{
$checked = (in_array($fcol,$search_display)) ? "checked='checked'" : ""; $checked = (in_array($fcol,$search_display)) ? "checked='checked'" : "";
$text .= "<td style='text-align:left; padding:0px'>"; $text .= "<td style='text-align:left; padding:0px'>";
$text .= "<input type='checkbox' name='searchdisp[]' value='".$fcol."' $checked />".str_replace($replacechar," ",$fcol) . "</td>\n"; $text .= "<input type='checkbox' name='searchdisp[]' value='".$fcol."' $checked />".str_replace($replacechar," ",$fcol) . "</td>\n";
$m++; $m++;
if($m == 5){ if($m == 5)
{
$text .= "</tr><tr>"; $text .= "</tr><tr>";
$m = 0; $m = 0;
} }
@@ -628,7 +670,7 @@ class download {
$text .= "</table></div> $text .= "</table></div>
</form>\n </form>\n
</div>"; </div>";
// ======================
$ns->tablerender(DOWLAN_7, $text); $ns->tablerender(DOWLAN_7, $text);
} }