mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Custom filterQry added to admin_ui and more download work.
This commit is contained in:
@@ -2030,6 +2030,11 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
* @var additional SQL to be applied when auto-building the list query
|
||||
*/
|
||||
protected $listQrySql = array();
|
||||
|
||||
/**
|
||||
* @var Custom Filter SQL Query override.
|
||||
*/
|
||||
protected $filterQry = null;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
@@ -3098,6 +3103,12 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
$qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.(strtolower($orderDef) == 'desc' ? 'DESC' : 'ASC');
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($this->filterQry)) // custom query on filter. (see downloads plugin)
|
||||
{
|
||||
$qry = $this->filterQry;
|
||||
}
|
||||
|
||||
if($this->getPerPage() || false !== $forceTo)
|
||||
{
|
||||
$from = false === $forceFrom ? intval($request->getQuery('from', 0)) : intval($forceFrom);
|
||||
@@ -3106,7 +3117,9 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
}
|
||||
|
||||
// Debug Filter Query.
|
||||
// echo $qry;
|
||||
|
||||
// echo $qry.'<br />';
|
||||
// print_a($_GET);
|
||||
|
||||
return $qry;
|
||||
}
|
||||
|
@@ -88,24 +88,6 @@ require_once (e_HANDLER.'message_handler.php');
|
||||
$emessage = &eMessage::getInstance();
|
||||
|
||||
|
||||
if(isset($_POST['filter_list']))
|
||||
{
|
||||
//echo $adminDownload->show_existing_items($action, $subAction, $id, 0, 10);
|
||||
// exit;
|
||||
}
|
||||
|
||||
if(isset($_POST['execute_batch']))
|
||||
{
|
||||
// $adminDownload->_observe_processBatch();
|
||||
}
|
||||
|
||||
if (isset($_POST['delete']))
|
||||
{
|
||||
$tmp = array_keys($_POST['delete']);
|
||||
list($delete, $del_id) = explode("_", $tmp[0]);
|
||||
$del_id = intval($del_id);
|
||||
unset($_POST['searchquery']);
|
||||
}
|
||||
|
||||
$from = ($from ? $from : 0);
|
||||
$amount = varset($pref['download_view'], 50);
|
||||
@@ -115,10 +97,6 @@ if (isset($_POST))
|
||||
$e107cache->clear("download_cat");
|
||||
}
|
||||
|
||||
if (isset($_POST['add_category']))
|
||||
{
|
||||
// $adminDownload->create_category($subAction, $id);
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['submit_download']))
|
||||
@@ -311,7 +289,7 @@ if (!e_QUERY || $action == "main")
|
||||
|
||||
if ($action == "opt")
|
||||
{
|
||||
$adminDownload->show_download_options();
|
||||
// $adminDownload->show_download_options();
|
||||
}
|
||||
|
||||
|
||||
@@ -439,8 +417,10 @@ function showLimits()
|
||||
}
|
||||
|
||||
|
||||
function showMaint()
|
||||
function showMaint() // Deprecated.
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
$mes->addInfo("Deprecated Area - please use filter instead under 'Manage' ");
|
||||
|
||||
global $pref;
|
||||
$ns = e107::getRender();
|
||||
|
@@ -359,6 +359,7 @@ class download_main_admin_ui extends e_admin_ui
|
||||
|
||||
'download_visible' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'),
|
||||
// 'download_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => '5%', 'thclass' => 'left' ),
|
||||
'issue' => array('title'=> 'Issue', 'type' => 'method', 'data' => null, 'nolist'=>TRUE, 'noedit'=>TRUE, 'filter'=>TRUE),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
|
||||
);
|
||||
|
||||
@@ -429,47 +430,149 @@ $columnInfo = array(
|
||||
//$this->fields['fb_mode']['writeParms'] = array(FBLAN_13,FBLAN_14);
|
||||
|
||||
$this->fields['download_category']['readParms'] = $categories;
|
||||
|
||||
// Custom filter queries
|
||||
if($_GET['filter_options'])
|
||||
{
|
||||
list($filter,$mode) = explode("__",$_GET['filter_options']);
|
||||
|
||||
if($mode == 'missing')
|
||||
{
|
||||
$this->filterQry = $this->missingFiles();
|
||||
}
|
||||
|
||||
if($mode == 'nocategory')
|
||||
{
|
||||
$this->filterQry = "SELECT * FROM `#download` WHERE download_category=0";
|
||||
}
|
||||
|
||||
if($mode == 'duplicates')
|
||||
{
|
||||
$this->filterQry = "SELECT GROUP_CONCAT(d.download_id SEPARATOR ',') as gc, d.download_id, d.download_name, d.download_url, dc.download_category_name
|
||||
FROM #download as d
|
||||
LEFT JOIN #download_category AS dc ON dc.download_category_id=d.download_category
|
||||
GROUP BY d.download_url
|
||||
HAVING COUNT(d.download_id) > 1";
|
||||
}
|
||||
|
||||
if($mode == "filesize")
|
||||
{
|
||||
$this->filterQry = $this->missingFiles('filesize');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->create_download();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a query for Missing Files and Filesize mismatch
|
||||
*/
|
||||
public function missingFiles($mode='missing')
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
$count = array();
|
||||
|
||||
if ($sql->db_Select_gen("SELECT * FROM `#download` ORDER BY download_id"))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
if (!is_readable(e_DOWNLOAD.$row['download_url']))
|
||||
{
|
||||
$count[] = $row['download_id'];
|
||||
}
|
||||
elseif($mode == 'filesize')
|
||||
{
|
||||
$filesize = filesize(e_DOWNLOAD.$row['download_url']);
|
||||
if ($filesize <> $row['download_filesize'])
|
||||
{
|
||||
$count[] = $row['download_id'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($count > 0)
|
||||
{
|
||||
return "SELECT * FROM `#download` WHERE download_id IN (".implode(",",$count).")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function importPage()
|
||||
{
|
||||
$this->batchImportForm();
|
||||
}
|
||||
|
||||
|
||||
function orphanFiles() //TODO
|
||||
{
|
||||
|
||||
$files = e107::getFile()->get_files(e_DOWNLOAD);
|
||||
$foundSome = false;
|
||||
foreach($files as $file)
|
||||
{
|
||||
if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='".$file['fname']."'")) {
|
||||
if (!$foundSome) {
|
||||
// $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform");
|
||||
$text .= '<form method="post" action="'.e_SELF.'?'.e_QUERY.'" id="myform">
|
||||
<table class="adminlist">';
|
||||
$text .= '<tr>';
|
||||
$text .= '<th>'.DOWLAN_13.'</th>';
|
||||
$text .= '<th>'.DOWLAN_182.'</th>';
|
||||
$text .= '<th>'.DOWLAN_66.'</th>';
|
||||
$text .= '<th>'.LAN_OPTIONS.'</th>';
|
||||
$text .= '</tr>';
|
||||
$foundSome = true;
|
||||
}
|
||||
$filesize = (is_readable(e_DOWNLOAD.$row['download_url']) ? $e107->parseMemorySize(filesize(e_DOWNLOAD.$file['fname'])) : DOWLAN_181);
|
||||
$filets = (is_readable(e_DOWNLOAD.$row['download_url']) ? $gen->convert_date(filectime(e_DOWNLOAD.$file['fname']), "long") : DOWLAN_181);
|
||||
$text .= '<tr>';
|
||||
$text .= '<td>'.$tp->toHTML($file['fname']).'</td>';
|
||||
$text .= '<td>'.$filets.'</td>';
|
||||
$text .= '<td>'.$filesize.'</td>';
|
||||
|
||||
function settingsPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->show_download_options();
|
||||
}
|
||||
|
||||
function limitsPage()
|
||||
{
|
||||
showLimits();
|
||||
}
|
||||
|
||||
function maintPage()
|
||||
{
|
||||
showMaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mirrorPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->show_existing_mirrors();
|
||||
}
|
||||
function createPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->create_download();
|
||||
}
|
||||
|
||||
function importPage()
|
||||
{
|
||||
$this->batchImportForm();
|
||||
}
|
||||
|
||||
function settingsPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->show_download_options();
|
||||
}
|
||||
|
||||
function limitsPage()
|
||||
{
|
||||
showLimits();
|
||||
}
|
||||
|
||||
function maintPage()
|
||||
{
|
||||
showMaint();
|
||||
}
|
||||
|
||||
function mirrorPage()
|
||||
{
|
||||
global $adminDownload;
|
||||
$adminDownload->show_existing_mirrors();
|
||||
}
|
||||
}
|
||||
|
||||
class download_main_admin_form_ui extends e_admin_form_ui
|
||||
{
|
||||
|
||||
function download_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
|
||||
{
|
||||
if($mode == 'read')
|
||||
@@ -498,6 +601,7 @@ class download_main_admin_form_ui extends e_admin_form_ui
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
function download_active($curVal,$mode)
|
||||
{
|
||||
$download_status[0] = DOWLAN_122; // Inactive;
|
||||
@@ -518,6 +622,27 @@ class download_main_admin_form_ui extends e_admin_form_ui
|
||||
return " ";
|
||||
}
|
||||
|
||||
|
||||
// Filter List for 'Issues'
|
||||
function issue($curVal,$mode)
|
||||
{
|
||||
if($mode == 'filter')
|
||||
{
|
||||
return array(
|
||||
'duplicates' => DOWLAN_166,
|
||||
'orphans' => DOWLAN_167, // TODO
|
||||
'missing' => DOWLAN_168,
|
||||
'nocategory' => DOWLAN_178,
|
||||
'filesize' => DOWLAN_66,
|
||||
'log' => DOWLAN_171
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return " ";
|
||||
}
|
||||
|
||||
|
||||
function download_mirror_type($curVal,$mode)
|
||||
{
|
||||
switch ($curVal)
|
||||
|
Reference in New Issue
Block a user