1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-23 23:02:58 +02:00

Fix issue processwire/processwire-issues#669 admin liveSearch noSearchTypes option not working for 'pages', 'trash' or 'modules'.

This commit is contained in:
Ryan Cramer
2018-09-12 12:35:49 -04:00
parent 8315776960
commit 313fee873c

View File

@@ -548,7 +548,7 @@ class ProcessPageSearchLive extends Wire {
$name = $info['name']; $name = $info['name'];
$thisType = $info['searchable']; $thisType = $info['searchable'];
if($type != $thisType && in_array($thisType, $this->noSearchTypes)) continue; if(!$this->useType($thisType, $type)) continue;
if($type && $this->isViewAll && $type != $thisType) continue; if($type && $this->isViewAll && $type != $thisType) continue;
if($type && stripos($thisType, $type) === false) continue; if($type && stripos($thisType, $type) === false) continue;
if(!empty($liveSearch['template']) && !empty($liveSearch['property'])) continue; if(!empty($liveSearch['template']) && !empty($liveSearch['property'])) continue;
@@ -631,7 +631,7 @@ class ProcessPageSearchLive extends Wire {
} }
// use built-in modules search when appropriate // use built-in modules search when appropriate
if((empty($type) || $type == 'modules') && $this->wire('user')->isSuperuser()) { if($this->useType('modules', $type) && $this->wire('user')->isSuperuser()) {
if(!in_array('modules', $this->searchTypesOrder)) $this->searchTypesOrder[] = 'modules'; if(!in_array('modules', $this->searchTypesOrder)) $this->searchTypesOrder[] = 'modules';
$order = array_search('modules', $this->searchTypesOrder) * 100; $order = array_search('modules', $this->searchTypesOrder) * 100;
foreach($this->findModules($liveSearch, $modulesInfo) as $item) { foreach($this->findModules($liveSearch, $modulesInfo) as $item) {
@@ -706,13 +706,13 @@ class ProcessPageSearchLive extends Wire {
$matches = array('pages' => array(), 'trash' => array()); $matches = array('pages' => array(), 'trash' => array());
try { try {
if(empty($liveSearch['type']) || $liveSearch['type'] == 'pages') { if($this->useType('pages', $liveSearch['type'])) {
$items['pages'] = $pages->find("$selector, status<" . Page::statusTrash); $items['pages'] = $pages->find("$selector, status<" . Page::statusTrash);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
} }
try { try {
if($superuser && (empty($liveSearch['type']) || $liveSearch['type'] == 'trash')) { if($superuser && $this->useType('trash', $liveSearch['type'])) {
$items['trash'] = $pages->find("$selector, status>=" . Page::statusTrash); $items['trash'] = $pages->find("$selector, status>=" . Page::statusTrash);
} }
} catch(\Exception $e) { } catch(\Exception $e) {
@@ -774,6 +774,19 @@ class ProcessPageSearchLive extends Wire {
return $matches; return $matches;
} }
/**
* Allow this search type?
*
* @param string $type Type to check
* @param string $requestType Type specifically requested by user
* @return bool
*
*/
protected function useType($type, $requestType = '') {
if($type === $requestType) return true;
return !in_array($type, $this->noSearchTypes);
}
/** /**
* Find modules matching query * Find modules matching query