mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Issue #28 Basic filter by datestamp added to admin-ui
This commit is contained in:
parent
0b85300d8e
commit
a5d9c17116
@ -300,16 +300,16 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_sef' => array('title' => 'SEF URL', 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
|
||||
'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y', 'filter'=>true),
|
||||
'news_category' => array('title' => NWSLAN_6, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
|
||||
'news_start' => array('title' => "Start", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
|
||||
'news_end' => array('title' => "End", 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
|
||||
|
||||
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclasses', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclasses', 'data' => 'int', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_render_type' => array('title' => LAN_TEMPLATE, 'type' => 'dropdown', 'data' => 'comma', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'reverse=1'),
|
||||
'news_sticky' => array('title' => LAN_NEWS_28, 'type' => 'boolean', 'data' => 'int' , 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'batch'=>true, 'filter'=>true),
|
||||
'news_allow_comments' => array('title' => NWSLAN_15, 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'thclass' => 'center', 'class' => 'center', 'nosort' => false,'batch'=>true, 'filter'=>true,'readParms'=>'reverse=1','writeParms'=>'reverse=1'),
|
||||
'news_comment_total' => array('title' => LAN_NEWS_60, 'type' => 'number', 'width' => '10%', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'options' => array('title' => LAN_OPTIONS, 'type' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center', 'nosort' => true, 'forced' => TRUE)
|
||||
|
||||
|
@ -2816,6 +2816,24 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
// direct query
|
||||
$res = array($filter[1], $filter[2]);
|
||||
break;
|
||||
|
||||
case 'datestamp':
|
||||
|
||||
$dateConvert = array(
|
||||
"hour" => "1 hour ago",
|
||||
"day" => "24 hours ago",
|
||||
"week" => "1 week ago",
|
||||
"month" => "1 month ago",
|
||||
"year" => "1 year ago"
|
||||
);
|
||||
|
||||
$ky = $filter[2];
|
||||
$time = vartrue($dateConvert[$ky]);
|
||||
$timeStamp = strtotime($time);
|
||||
|
||||
$res = array($filter[1], $timeStamp);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
//something like handleListUrlTypeFilter(); for custom handling of 'url_type' field name filters
|
||||
@ -2836,6 +2854,10 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//print_a($res);
|
||||
//exit;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -3238,16 +3260,34 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
|
||||
if($filterField && $filterValue !== '' && isset($this->fields[$filterField]))
|
||||
{
|
||||
if($this->fields[$filterField]['data'] == 'comma')
|
||||
switch ($this->fields[$filterField]['data'])
|
||||
{
|
||||
$searchQry[] = "FIND_IN_SET('".$tp->toDB($filterValue)."',".$this->fields[$filterField]['__tableField'].")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$searchQry[] = $this->fields[$filterField]['__tableField']." = '".$tp->toDB($filterValue)."'";
|
||||
case 'comma':
|
||||
$searchQry[] = "FIND_IN_SET('".$tp->toDB($filterValue)."',".$this->fields[$filterField]['__tableField'].")";
|
||||
break;
|
||||
|
||||
case 'int':
|
||||
case 'integer':
|
||||
if($this->fields[$filterField]['type'] == 'datestamp') // Past Month, Past Year etc.
|
||||
{
|
||||
$searchQry[] = $this->fields[$filterField]['__tableField']." > ".intval($filterValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$searchQry[] = $this->fields[$filterField]['__tableField']." = ".intval($filterValue);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
$searchQry[] = $this->fields[$filterField]['__tableField']." = '".$tp->toDB($filterValue)."'";
|
||||
//exit;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
//echo 'type= '. $this->fields[$filterField]['data'];
|
||||
// print_a($this->fields[$filterField]);
|
||||
}
|
||||
elseif($searchFilter && is_string($searchFilter))
|
||||
{
|
||||
@ -3451,7 +3491,7 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
|
||||
// Debug Filter Query.
|
||||
|
||||
// echo $qry.'<br />';
|
||||
// echo $qry.'<br />';
|
||||
// print_a($_GET);
|
||||
|
||||
return $qry;
|
||||
@ -4705,12 +4745,23 @@ class e_admin_form_ui extends e_form
|
||||
}
|
||||
break;
|
||||
|
||||
case 'datestamp': // use $parm to determine unix-style or YYYY-MM-DD
|
||||
//TODO last hour, today, yesterday, this-month, last-month etc.
|
||||
/* foreach($val['parm'] as $k=>$name)
|
||||
case 'datestamp':
|
||||
//TODO today, yesterday, this-month, last-month .
|
||||
|
||||
$dateFilters = array (
|
||||
'hour' => "Past Hour",
|
||||
"day" => "Past 24 hours",
|
||||
"week" => "Past Week",
|
||||
"month" => "Past Month",
|
||||
"year" => "Past Year"
|
||||
);
|
||||
|
||||
foreach($dateFilters as $k => $name)
|
||||
{
|
||||
$text .= $frm->option($name, $type.'__'.$key."__".$k);
|
||||
}*/
|
||||
$option['datestamp__'.$key.'__'.$k] = $name;
|
||||
// $option['bool__'.$key.'__0'] = LAN_NO;
|
||||
// $option[$key.'__'.$k] = $name;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'userclass':
|
||||
|
@ -539,9 +539,9 @@ class e_media
|
||||
// $text .= "<input type='button' value='Go' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' /> "; // Manual filter, if onkeyup ajax fails for some reason.
|
||||
$text .= "<button type='button' value='Go' class='btn btn-primary e-media-nav' data-target='media-select-container' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' >Go</button>"; // Manual filter, if onkeyup ajax fails for some reason.
|
||||
|
||||
$text .= " <button type='button' title='previous page' class='btn button e-nav e-media-nav e-tip' data-target='media-select-container' data-nav-total='".$total."' data-nav-dir='down' data-nav-inc='".$limit."' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' >«</button>"; // see next page of images.
|
||||
$text .= " <button type='button' title='previous page' class='btn e-nav e-media-nav e-tip' data-target='media-select-container' data-nav-total='".$total."' data-nav-dir='down' data-nav-inc='".$limit."' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' >«</button>"; // see next page of images.
|
||||
|
||||
$text .= "<button type='button' title='next page' class='btn button e-nav e-media-nav e-tip' style='text-align:center' data-target='media-select-container' data-nav-total='".$total."' data-nav-dir='up' data-nav-inc='".$limit."' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' >»</button>"; // see next page of images.
|
||||
$text .= "<button type='button' title='next page' class='btn e-nav e-media-nav e-tip' style='text-align:center' data-target='media-select-container' data-nav-total='".$total."' data-nav-dir='up' data-nav-inc='".$limit."' data-src='".$this->mediaSelectNav($category,"tagid=".$tagid."&bbcode=".$bbcode)."&from=0' >»</button>"; // see next page of images.
|
||||
$text .= "</div>
|
||||
<div id='media-select-container'>";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user