mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
New "Search in Field" filter option added for field-specific search of text fields and similar. (filter=>true required)
This commit is contained in:
@@ -447,13 +447,13 @@ class news_admin_ui extends e_admin_ui
|
||||
'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE),
|
||||
'news_id' => array('title' => LAN_ID, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'),
|
||||
'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'method', 'data'=>'str', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'readonly'=>false),
|
||||
'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'data'=>'safestr', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_summary' => array('title' => LAN_SUMMARY, 'type' => 'text', 'data'=>'safestr', 'tab'=>0, 'inline'=>true, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
||||
'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'data'=>'safestr', 'filter'=>true, 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_summary' => array('title' => LAN_SUMMARY, 'type' => 'text', 'data'=>'safestr', 'filter'=>true, 'tab'=>0, 'inline'=>true, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
||||
'news_body' => array('title' => "", 'type' => 'method', 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_extended' => array('title' => "", 'type' => null, 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
|
||||
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'data'=>'safestr', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge')),
|
||||
'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'data'=>'safestr', 'filter'=>true, 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr','filter'=>true, 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge')),
|
||||
'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'batch'=>1, 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')),
|
||||
'news_ping' => array('title' => LAN_PING, 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
|
||||
|
@@ -4087,8 +4087,10 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
|
||||
$this->listQry = $listQry;
|
||||
|
||||
$filterOptions = $request->getQuery('filter_options', '');
|
||||
|
||||
$searchQuery = $this->fixSearchWildcards($tp->toDB($request->getQuery('searchquery', '')));
|
||||
$searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', ''));
|
||||
$searchFilter = $this->_parseFilterRequest($filterOptions);
|
||||
|
||||
$listQry = $this->listQry; // check for modification during parseFilterRequest();
|
||||
|
||||
@@ -4265,6 +4267,12 @@ class e_admin_controller_ui extends e_admin_controller
|
||||
}
|
||||
}
|
||||
|
||||
if(strpos($filterOptions,'searchfield__') === 0) // search in specific field, so remove the above filters.
|
||||
{
|
||||
$filter = array(); // reset filter.
|
||||
}
|
||||
|
||||
|
||||
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
||||
{
|
||||
// e107::getDebug()->log(print_a($filter,true));
|
||||
@@ -5448,6 +5456,24 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
$this->getTreeModel()->setMessages();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to generate "Search in Field" query.
|
||||
* @param $selected
|
||||
* @return string
|
||||
*/
|
||||
protected function handleListSearchfieldFilter($selected)
|
||||
{
|
||||
$string = $this->getQuery('searchquery');
|
||||
|
||||
if(empty($string))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $selected. " LIKE '%".e107::getParser()->toDB($string)."%' "; // array($selected, $this->getQuery('searchquery'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch default (field) trigger
|
||||
* @param array $selected
|
||||
@@ -7310,9 +7336,15 @@ class e_admin_form_ui extends e_form
|
||||
$textsingle = '';
|
||||
|
||||
|
||||
foreach($this->getController()->getFields() as $key=>$val)
|
||||
$searchFieldOpts = array();
|
||||
|
||||
$fieldList = $this->getController()->getFields();
|
||||
|
||||
|
||||
|
||||
foreach($fieldList as $key=>$val)
|
||||
{
|
||||
if(!varset($val[$type]))
|
||||
if(empty($val[$type])) // ie. filter = false or batch = false.
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -7331,6 +7363,8 @@ class e_admin_form_ui extends e_form
|
||||
$option['sefgen__'.$key.'__'.$parms['sef']] = LAN_GENERATE;
|
||||
}
|
||||
|
||||
$searchFieldOpts["searchfield__".$key] = $val['title'];
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -7340,6 +7374,13 @@ class e_admin_form_ui extends e_form
|
||||
$option[$key.'___ISEMPTY_'] = LAN_UI_FILTER_IS_EMPTY;
|
||||
}
|
||||
|
||||
$searchFieldOpts["searchfield__".$key] = $val['title'];
|
||||
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
case 'tags':
|
||||
$searchFieldOpts["searchfield__".$key] = $val['title'];
|
||||
break;
|
||||
|
||||
case 'bool':
|
||||
@@ -7607,7 +7648,9 @@ class e_admin_form_ui extends e_form
|
||||
break;
|
||||
}
|
||||
|
||||
if(count($option) > 0)
|
||||
|
||||
|
||||
if(!empty($option))
|
||||
{
|
||||
$text .= "\t".$this->optgroup_open($optdiz[$type].defset($val['title'], $val['title']), varset($disabled))."\n";
|
||||
foreach($option as $okey=>$oval)
|
||||
@@ -7618,6 +7661,22 @@ class e_admin_form_ui extends e_form
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!empty($searchFieldOpts))
|
||||
{
|
||||
$text .= "\t".$this->optgroup_open(defset("LAN_UI_FILTER_SEARCH_IN_FIELD", "Search in Field"))."\n";
|
||||
|
||||
foreach($searchFieldOpts as $key=>$val)
|
||||
{
|
||||
$text .= $this->option($val, $key, $selected == $key)."\n";
|
||||
}
|
||||
|
||||
$text .= "\t".$this->optgroup_close()."\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $textsingle.$text;
|
||||
|
||||
}
|
||||
|
@@ -566,3 +566,7 @@ define("LAN_NO_RESULTS_FOUND", "No Results Found.");
|
||||
define("LAN_UI_DROPZONE_DROP_FILES", "Drop files here to upload");
|
||||
|
||||
define("LAN_DOWNLOAD_COMPLETE", "Download Complete!");
|
||||
|
||||
define("LAN_UI_FILTER_SEARCH_IN_FIELD", "Search in Field");
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user