mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 01:34:31 +02:00
Various improvements to ProcessPageSearch module, including support for search selectors that don't pass through user input, opening more search options (see next commit with autocomplete improvements, which uses it)
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* For more details about how Process modules work, please see:
|
||||
* /wire/core/Process.php
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2021 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @method string findReady($selector)
|
||||
@@ -31,7 +31,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
return array(
|
||||
'title' => 'Page Search',
|
||||
'summary' => 'Provides a page search engine for admin use.',
|
||||
'version' => 107,
|
||||
'version' => 108,
|
||||
'permanent' => true,
|
||||
'permission' => 'page-edit',
|
||||
);
|
||||
@@ -66,7 +66,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
'modifiedUser',
|
||||
'sort',
|
||||
'sortfield',
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* Names of all Field objects in PW
|
||||
@@ -172,9 +172,11 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
protected function fullSetup() {
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
$input = $this->wire()->input;
|
||||
$headline = $this->_x('Search', 'headline'); // Headline for search page
|
||||
if($this->input->get('processHeadline')) {
|
||||
$headline = $this->sanitizer->entities($this->sanitizer->text($this->input->get('processHeadline')));
|
||||
if($input->get('processHeadline')) {
|
||||
$headline = $sanitizer->entities($sanitizer->text($input->get('processHeadline')));
|
||||
$this->input->whitelist('processHeadline', $headline);
|
||||
}
|
||||
$this->wire('processHeadline', $headline);
|
||||
@@ -203,10 +205,11 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
protected function getLister() {
|
||||
$modules = $this->wire()->modules;
|
||||
if($this->lister) return $this->lister;
|
||||
if($this->wire('user')->hasPermission('page-lister')) {
|
||||
if($this->wire('modules')->isInstalled('ProcessPageLister')) {
|
||||
$this->lister = $this->wire('modules')->get('ProcessPageLister');
|
||||
if($this->wire()->user->hasPermission('page-lister')) {
|
||||
if($modules->isInstalled('ProcessPageLister')) {
|
||||
$this->lister = $modules->get('ProcessPageLister');
|
||||
}
|
||||
}
|
||||
return $this->lister;
|
||||
@@ -219,8 +222,8 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
public function ___execute() {
|
||||
|
||||
$lister = $this->getLister();
|
||||
$ajax = $this->wire('config')->ajax;
|
||||
$bookmark = (int) $this->wire('input')->get('bookmark');
|
||||
$ajax = $this->wire()->config->ajax;
|
||||
$bookmark = (int) $this->wire()->input->get('bookmark');
|
||||
|
||||
if($lister && ($ajax || $bookmark)) {
|
||||
// we will just let Lister do it's thing, since it remembers settings in session
|
||||
@@ -267,14 +270,10 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*/
|
||||
public function ___executeFor() {
|
||||
|
||||
/** @var Languages $languages */
|
||||
$languages = $this->wire('languages');
|
||||
/** @var User $user */
|
||||
$user = $this->wire('user');
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$languages = $this->wire()->languages;
|
||||
$user = $this->wire()->user;
|
||||
$input = $this->wire()->input;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
if($input->get('admin_search')) return $this->executeLive();
|
||||
|
||||
@@ -288,12 +287,20 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$superuser = $user->isSuperuser();
|
||||
$checkEditAccess = false;
|
||||
$hasInclude = '';
|
||||
$n = 0;
|
||||
|
||||
$selectorName = $input->get('for_selector_name');
|
||||
if($selectorName) {
|
||||
$selector = $this->getForSelector($selectorName);
|
||||
if(strlen($selector)) $selectors['for'] = $selector;
|
||||
}
|
||||
|
||||
// names to skip (must be lowercase)
|
||||
$skipNames = array(
|
||||
'get',
|
||||
'display',
|
||||
'format_name',
|
||||
'for_selector_name',
|
||||
'admin_search'
|
||||
);
|
||||
|
||||
@@ -425,20 +432,21 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$input->whitelist($name . rtrim($operator, '='), trim($value, '"\''));
|
||||
|
||||
foreach($valuesAND as $val) {
|
||||
$selectors[] = "$name$operator$val";
|
||||
$n++;
|
||||
$selectors["input-$n"] = "$name$operator$val";
|
||||
}
|
||||
|
||||
$names[] = $name;
|
||||
|
||||
} // foreach input
|
||||
|
||||
if($start) $selectors[] = "start=$start";
|
||||
$selectors[] = "limit=$limit";
|
||||
if($start) $selectors['start'] = "start=$start";
|
||||
$selectors['limit'] = "limit=$limit";
|
||||
$displaySelector = implode(',', $selectors);
|
||||
|
||||
if(!$status && !$hasInclude && $superuser) {
|
||||
// superuser only
|
||||
$selectors[] = "include=all, status<" . Page::statusTrash;
|
||||
$selectors['superuser'] = "include=all, status<" . Page::statusTrash;
|
||||
}
|
||||
|
||||
$selector = implode(', ', $selectors);
|
||||
@@ -470,7 +478,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$liveSearch->setSearchTypesOrder($this->searchTypesOrder);
|
||||
$liveSearch->setNoSearchTypes($this->noSearchTypes);
|
||||
$liveSearch->setDefaultOperators($this->operator, $this->operator2);
|
||||
if($this->wire('config')->ajax) {
|
||||
if($this->wire()->config->ajax) {
|
||||
header('Content-type: application/json');
|
||||
return $liveSearch->execute();
|
||||
} else {
|
||||
@@ -485,13 +493,12 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
public function getRepeatersPageID() {
|
||||
/** @var Session $session */
|
||||
$session = $this->wire('session');
|
||||
$session = $this->wire()->session;
|
||||
$repeaterID = $session->getFor($this, 'repeaterID');
|
||||
if(is_int($repeaterID)) return $repeaterID;
|
||||
if($this->wire('modules')->isInstalled('FieldtypeRepeater')) {
|
||||
$repeaterPage = $this->wire('pages')->get(
|
||||
"parent_id=" . $this->wire('config')->adminRootPageID . ", " .
|
||||
if($this->wire()->modules->isInstalled('FieldtypeRepeater')) {
|
||||
$repeaterPage = $this->wire()->pages->get(
|
||||
"parent_id=" . $this->wire()->config->adminRootPageID . ", " .
|
||||
"name=repeaters, " .
|
||||
"include=all"
|
||||
);
|
||||
@@ -508,10 +515,12 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
protected function getDisplayFields() {
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
$input = $this->wire()->input;
|
||||
|
||||
$display = (string) $this->input->get('display');
|
||||
$display = (string) $input->get('display');
|
||||
|
||||
if(!strlen($display)) $display = (string) $this->input->get('get'); // as required by ProcessPageSearch API
|
||||
if(!strlen($display)) $display = (string) $input->get('get'); // as required by ProcessPageSearch API
|
||||
if(!strlen($display)) $display = (string) $this->displayField;
|
||||
if(!strlen($display)) $display = 'title path';
|
||||
|
||||
@@ -519,7 +528,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$display = explode(' ', $display); // convert to array
|
||||
|
||||
foreach($display as $key => $name) {
|
||||
$name = $this->sanitizer->fieldName($name);
|
||||
$name = $sanitizer->fieldName($name);
|
||||
$display[$key] = $name;
|
||||
if($this->isSelectableFieldName($name)) continue;
|
||||
if(in_array($name, array('url', 'path', 'httpUrl'))) continue;
|
||||
@@ -537,13 +546,13 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
* The name the session variable must be provided as a GET var: format_name=[name]
|
||||
*
|
||||
* @return mixed|string
|
||||
* @return array|string
|
||||
*
|
||||
*/
|
||||
protected function getDisplayFormat() {
|
||||
$name = $this->input->get('format_name');
|
||||
$name = $this->wire()->input->get('format_name');
|
||||
if(empty($name)) return '';
|
||||
$data = $this->wire('session')->getFor($this, "format_" . $name);
|
||||
$data = $this->wire()->session->getFor($this, "format_" . $name);
|
||||
if(empty($data)) return '';
|
||||
return array(
|
||||
'name' => $name,
|
||||
@@ -561,12 +570,49 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
public function setDisplayFormat($name, $format, $textOnly = false) {
|
||||
$this->wire('session')->setFor($this, "format_" . $name, array(
|
||||
$this->wire()->session->setFor($this, "format_" . $name, array(
|
||||
'format' => $format,
|
||||
'textOnly' => $textOnly
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a selector to use when $_GET['for_selector_name'] matches given $name
|
||||
*
|
||||
* This is for cases where you don't want the selector to pass through user input,
|
||||
* and you instead just want to pass the name of it via user input. This enables
|
||||
* use of some features that may not be available through user selectors passing
|
||||
* only through user input.
|
||||
*
|
||||
* Used in executeFor() mode only.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $selector
|
||||
* @return string Returns URL needed to use this selector
|
||||
* @since 3.0.223
|
||||
*
|
||||
*/
|
||||
public function setForSelector($name, $selector) {
|
||||
$this->wire()->session->setFor($this, "for_selector_$name", $selector);
|
||||
return $this->config->urls->admin . 'page/search/for?for_selector_name=' . urlencode($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selector identified by $name that was previously set with setForSelector()
|
||||
*
|
||||
* For executeFor() mode only.
|
||||
*
|
||||
* #pw-internal
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
* @since 3.0.223
|
||||
*
|
||||
*/
|
||||
public function getForSelector($name) {
|
||||
return (string) $this->wire()->session->getFor($this, "for_selector_$name");
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the search results
|
||||
*
|
||||
@@ -577,6 +623,9 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*/
|
||||
protected function render(PageArray $matches, $displaySelector = '') {
|
||||
|
||||
$input = $this->wire()->input;
|
||||
$ajax = $this->wire()->config->ajax;
|
||||
|
||||
$out = '';
|
||||
|
||||
if($displaySelector) {
|
||||
@@ -591,13 +640,13 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
// determine what fields will be displayed
|
||||
$display = array();
|
||||
if($this->config->ajax) $display = $this->getDisplayFormat();
|
||||
if($ajax) $display = $this->getDisplayFormat();
|
||||
if(empty($display)) {
|
||||
$display = $this->getDisplayFields();
|
||||
$this->input->whitelist('display', implode(',', $display));
|
||||
$input->whitelist('display', implode(',', $display));
|
||||
}
|
||||
|
||||
if($this->config->ajax) {
|
||||
if($ajax) {
|
||||
// ajax json output
|
||||
header("Content-type: application/json");
|
||||
$out = $this->renderMatchesAjax($matches, $display, $displaySelector);
|
||||
@@ -605,7 +654,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
} else {
|
||||
// html output
|
||||
$class = '';
|
||||
if((int) $this->input->get('show_options') !== 0 && $this->input->urlSegment1 != 'find') {
|
||||
if((int) $input->get('show_options') !== 0 && $input->urlSegment1 != 'find') {
|
||||
$out = "\n<div id='ProcessPageSearchOptions'>" . $this->renderFullSearchForm() . "</div>";
|
||||
$class = 'show_options';
|
||||
}
|
||||
@@ -636,8 +685,14 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
protected function buildSelector() {
|
||||
|
||||
$input = $this->wire()->input;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
$user = $this->wire()->user;
|
||||
$pages = $this->wire()->pages;
|
||||
$config = $this->wire()->config;
|
||||
|
||||
$selector = ''; // for regular ProcessPageSearch
|
||||
$input = $this->wire('input');
|
||||
|
||||
// search query text
|
||||
$q = $input->whitelist('q');
|
||||
@@ -652,10 +707,10 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
if(is_string($searchFields)) $searchFields = explode(' ', $searchFields);
|
||||
}
|
||||
foreach($searchFields as $fieldName) {
|
||||
$fieldName = $this->sanitizer->fieldName($fieldName);
|
||||
$fieldName = $sanitizer->fieldName($fieldName);
|
||||
$selector .= "$fieldName|";
|
||||
}
|
||||
$selector = rtrim($selector, '|') . $this->operator . $this->wire('sanitizer')->selectorValue($q);
|
||||
$selector = rtrim($selector, '|') . $this->operator . $sanitizer->selectorValue($q);
|
||||
}
|
||||
|
||||
// determine if results are sorted by something other than relevance
|
||||
@@ -680,7 +735,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
|
||||
$trash = $input->whitelist('trash');
|
||||
if($trash !== null && $this->wire('user')->isSuperuser()) {
|
||||
if($trash !== null && $user->isSuperuser()) {
|
||||
if($trash === 0) {
|
||||
$selector .= ", status!=trash";
|
||||
} else if($trash === 1) {
|
||||
@@ -701,27 +756,27 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$s = ''; // anything added to this will be populated to both $selector and $initSelector below
|
||||
|
||||
// limit results for pagination
|
||||
$s .= ", limit={$this->resultLimit}";
|
||||
$s .= ", limit=$this->resultLimit";
|
||||
|
||||
$adminRootPage = $this->wire('pages')->get($this->wire('config')->adminRootPageID);
|
||||
$adminRootPage = $pages->get($config->adminRootPageID);
|
||||
|
||||
// exclude admin repeater pages unless the admin template is chosen
|
||||
if(!$input->whitelist('template')) {
|
||||
// but only for superuser, as we're excluding all admin pages for non-superusers
|
||||
if($this->user->isSuperuser()) {
|
||||
$repeaters = $adminRootPage->child('name=repeaters, include=all');
|
||||
if($repeaters->id) $s .= ", has_parent!={$repeaters->id}";
|
||||
if($repeaters->id) $s .= ", has_parent!=$repeaters->id";
|
||||
}
|
||||
}
|
||||
|
||||
// include hidden pages
|
||||
if($this->user->isSuperuser()) {
|
||||
if($user->isSuperuser()) {
|
||||
$s .= ", include=all";
|
||||
} else {
|
||||
// non superuser doesn't get any admin pages in their results
|
||||
$s .= ", has_parent!=$adminRootPage";
|
||||
// if user has any kind of edit access, allow unpublished pages to be included
|
||||
if($this->user->hasPermission('page-edit')) $s .= ", include=unpublished";
|
||||
if($user->hasPermission('page-edit')) $s .= ", include=unpublished";
|
||||
}
|
||||
|
||||
$selector .= $s;
|
||||
@@ -736,10 +791,9 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*/
|
||||
protected function processInput() {
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$user = $this->wire()->user;
|
||||
$input = $this->wire()->input;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
// search query
|
||||
$q = $input->get('q');
|
||||
@@ -797,15 +851,15 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$template = $input->get('template');
|
||||
if($template) {
|
||||
$template = $sanitizer->templateName($template);
|
||||
$template = $this->wire('templates')->get($template);
|
||||
if($template && $this->wire('user')->hasPermission('page-view', $template)) {
|
||||
$template = $this->wire()->templates->get($template);
|
||||
if($template && $user->hasPermission('page-view', $template)) {
|
||||
$input->whitelist('template', $template->name);
|
||||
}
|
||||
}
|
||||
|
||||
// trash (liveSearch)
|
||||
$trash = $input->get('trash');
|
||||
if($trash !== null && $this->wire('user')->isSuperuser()) {
|
||||
if($trash !== null && $user->isSuperuser()) {
|
||||
$trash = (int) $trash;
|
||||
if($trash === 0 || $trash === 1) {
|
||||
$input->whitelist('trash', $trash);
|
||||
@@ -833,14 +887,11 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*/
|
||||
protected function processInputQuery($q) {
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$input = $this->wire()->input;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
$q = trim($sanitizer->text($q));
|
||||
$redirectUrl = '';
|
||||
$operator = '';
|
||||
$operators = $this->operators;
|
||||
$type = '';
|
||||
|
||||
@@ -873,7 +924,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
if(strpos($type, '.')) {
|
||||
// type with property/field
|
||||
list($type, $field) = explode('.', $type, 2);
|
||||
$field = $this->wire('sanitizer')->fieldName(trim($field));
|
||||
$field = $sanitizer->fieldName(trim($field));
|
||||
$input->get->set('field', $field);
|
||||
} else {
|
||||
$field = '';
|
||||
@@ -884,13 +935,13 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
} else if($type == 'trash') {
|
||||
$input->get->set('trash', 1);
|
||||
} else if($type) {
|
||||
$template = $type ? $this->wire('templates')->get($type) : '';
|
||||
$template = $this->wire()->templates->get($type);
|
||||
if($template) {
|
||||
// defined template
|
||||
$input->get->set('template', $template->name);
|
||||
} else {
|
||||
// some other non-page type
|
||||
$redirectUrl = $this->wire('page')->url . 'live/' .
|
||||
$redirectUrl = $this->wire()->page->url . 'live/' .
|
||||
'?q=' . urlencode($q) .
|
||||
'&type=' . urlencode($type) .
|
||||
'&property=' . urlencode($field) .
|
||||
@@ -898,7 +949,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
}
|
||||
|
||||
if($redirectUrl) $this->wire('session')->redirect($redirectUrl);
|
||||
if($redirectUrl) $this->wire()->session->redirect($redirectUrl);
|
||||
|
||||
$input->whitelist('q', $q);
|
||||
}
|
||||
@@ -1038,6 +1089,9 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
protected function renderFullSearchForm() {
|
||||
|
||||
$input = $this->wire()->input;
|
||||
$modules = $this->wire()->modules;
|
||||
|
||||
// Search options
|
||||
|
||||
$out = "\n\t<p id='wrap_search_query'>";
|
||||
@@ -1065,7 +1119,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
$out .=
|
||||
"\n\t<label class='ui-priority-primary' for='search_query'>" . $this->_('Search for:') . "</label>" .
|
||||
"\n\t<input id='search_query' type='text' name='q' value='" . htmlentities($this->input->whitelist('q'), ENT_QUOTES, "UTF-8") . "' />" .
|
||||
"\n\t<input id='search_query' type='text' name='q' value='" . htmlentities($input->whitelist('q'), ENT_QUOTES, "UTF-8") . "' />" .
|
||||
"\n\t<input type='hidden' name='show_options' value='1' />" .
|
||||
"\n\t</p>";
|
||||
|
||||
@@ -1080,11 +1134,11 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
"\n\t<select id='search_template' name='template'>" .
|
||||
"\n\t\t<option></option>";
|
||||
|
||||
$templateName = $this->input->whitelist('template');
|
||||
$templateName = $input->whitelist('template');
|
||||
if($templateName) $advCollapsed = false;
|
||||
foreach($this->templates as $template) {
|
||||
foreach($this->wire()->templates as $template) {
|
||||
$attrs = $template->name === $templateName ? " selected='selected'" : '';
|
||||
$out2 .= "\n\t<option$attrs>{$template->name}</option>";
|
||||
$out2 .= "\n\t<option$attrs>$template->name</option>";
|
||||
}
|
||||
|
||||
$out2 .=
|
||||
@@ -1099,7 +1153,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
$sorts = $this->nativeSorts + $this->fieldOptions;
|
||||
|
||||
$sort = $this->input->whitelist('sort');
|
||||
$sort = $input->whitelist('sort');
|
||||
if($sort && $sort != 'relevance') $advCollapsed = false;
|
||||
foreach($sorts as $s) {
|
||||
if(strpos($s, ' ')) continue; // skip over multi fields
|
||||
@@ -1113,7 +1167,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
"\n\t</p>";
|
||||
|
||||
if($sort != 'relevance') {
|
||||
$reverse = $this->input->whitelist('reverse');
|
||||
$reverse = $input->whitelist('reverse');
|
||||
$out2 .=
|
||||
"\n\t<p id='wrap_search_options'>" .
|
||||
"\n\t<label><input type='checkbox' name='reverse' value='1' " . ($reverse ? "checked='checked' " : '') . "/> " . $this->_('Reverse sort?') . "</label>" .
|
||||
@@ -1121,7 +1175,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
if($reverse) $advCollapsed = false;
|
||||
}
|
||||
|
||||
$display = $this->input->whitelist('display');
|
||||
$display = $input->whitelist('display');
|
||||
$out2 .=
|
||||
"\n\t<p id='wrap_search_display'>" .
|
||||
"\n\t<label for='search_display'>" . $this->_('Display field(s):') . "</label>" .
|
||||
@@ -1131,41 +1185,32 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
|
||||
/** @var InputfieldSubmit $submit */
|
||||
$submit = $this->modules->get("InputfieldSubmit");
|
||||
$submit = $modules->get("InputfieldSubmit");
|
||||
$submit->attr('name', 'submit');
|
||||
$submit->attr('value', $this->_x('Search', 'submit')); // Search submit button for advanced search
|
||||
$out .= "<p>" . $submit->render() . "</p>";
|
||||
|
||||
/** @var InputfieldForm $form */
|
||||
$form = $this->modules->get("InputfieldForm");
|
||||
$form = $modules->get("InputfieldForm");
|
||||
$form->attr('id', 'ProcessPageSearchOptionsForm');
|
||||
$form->method = 'get';
|
||||
$form->action = './';
|
||||
|
||||
/** @var InputfieldMarkup $field */
|
||||
$field = $this->modules->get("InputfieldMarkup");
|
||||
$field = $modules->get("InputfieldMarkup");
|
||||
$field->label = $this->_("Search Options");
|
||||
$field->value = $out;
|
||||
|
||||
$form->add($field);
|
||||
|
||||
$field = $this->modules->get("InputfieldMarkup");
|
||||
/** @var InputfieldMarkup $field */
|
||||
$field = $modules->get("InputfieldMarkup");
|
||||
if($advCollapsed) $field->collapsed = Inputfield::collapsedYes;
|
||||
$field->label = $this->_("Advanced");
|
||||
$field->value = $out2;
|
||||
|
||||
$form->add($field);
|
||||
|
||||
/* no longer in use
|
||||
$field = $this->modules->get("InputfieldMarkup");
|
||||
$field->id = 'ProcessPageSearchShortcuts';
|
||||
$field->collapsed = true;
|
||||
$field->label = $this->_("Shortcuts");
|
||||
$field->value = $this->renderShortcuts();
|
||||
*/
|
||||
|
||||
$form->add($field);
|
||||
|
||||
return $form->render();
|
||||
}
|
||||
|
||||
@@ -1180,12 +1225,15 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*/
|
||||
protected function renderMatchesTable(PageArray $matches, array $display) {
|
||||
|
||||
if(!count($display)) $display = array('path');
|
||||
$out = '';
|
||||
$input = $this->wire()->input;
|
||||
$config = $this->wire()->config;
|
||||
$modules = $this->wire()->modules;
|
||||
|
||||
if(!count($matches)) return '';
|
||||
if(!count($display)) $display = array('path');
|
||||
|
||||
if(!count($matches)) return $out;
|
||||
/** @var MarkupAdminDataTable $table */
|
||||
$table = $this->modules->get("MarkupAdminDataTable");
|
||||
$table = $modules->get("MarkupAdminDataTable");
|
||||
$table->setSortable(false);
|
||||
$table->setEncodeEntities(false);
|
||||
$header = $display;
|
||||
@@ -1194,16 +1242,15 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
foreach($matches as $match) {
|
||||
$match->setOutputFormatting(true);
|
||||
$editUrl = "{$this->config->urls->admin}page/edit/?id={$match->id}";
|
||||
$editUrl = "{$config->urls->admin}page/edit/?id={$match->id}";
|
||||
$viewUrl = $match->url();
|
||||
$row = array();
|
||||
foreach($display as $name) {
|
||||
$value = $match->get($name);
|
||||
if(is_object($value)) {
|
||||
if($value instanceof Page) $value = $value->name;
|
||||
}
|
||||
if($value instanceof Page) $value = $value->name;
|
||||
$value = strip_tags($value);
|
||||
if($name == 'created' || $name == 'modified' || $name == 'published') $value = date(DATE_ISO8601, $value);
|
||||
if($name == 'created' || $name == 'modified' || $name == 'published') $value = date('Y-m-d H:i:s', $value);
|
||||
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
|
||||
$row[] = "<a href='$viewUrl'>$value</a>";
|
||||
}
|
||||
$row[] = $match->editable() ? "<a class='action' href='$editUrl'>" . $this->_('edit') . "</a>" : ' ';
|
||||
@@ -1212,8 +1259,9 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
|
||||
if($matches->getTotal() > count($matches)) {
|
||||
$pager = $this->wire('modules')->get('MarkupPagerNav');
|
||||
if($this->input->urlSegment1 == 'for') $pager->setBaseUrl($this->page->url . "for/");
|
||||
/** @var MarkupPagerNav $pager */
|
||||
$pager = $modules->get('MarkupPagerNav');
|
||||
if($input->urlSegment1 == 'for') $pager->setBaseUrl($this->wire()->page->url . "for/");
|
||||
$pager = $pager->render($matches);
|
||||
} else {
|
||||
$pager = '';
|
||||
@@ -1241,12 +1289,12 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
'limit' => $matches->getLimit(),
|
||||
'start' => $matches->getStart(),
|
||||
'matches' => array(),
|
||||
);
|
||||
);
|
||||
|
||||
// determine which template label we'll be asking for (for multi-language support)
|
||||
$templateLabel = 'label';
|
||||
if($this->wire('languages')) {
|
||||
$language = $this->user->language;
|
||||
if($this->wire()->languages) {
|
||||
$language = $this->wire()->user->language;
|
||||
if($language && !$language->isDefault()) $templateLabel = "label$language";
|
||||
}
|
||||
|
||||
@@ -1259,7 +1307,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
'template' => $page->template->name,
|
||||
'path' => $page->path,
|
||||
'name' => $page->name,
|
||||
);
|
||||
);
|
||||
|
||||
if($this->adminSearchMode) {
|
||||
// don't include non-editable pages in admin search mode
|
||||
@@ -1269,7 +1317,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
// include the type of match and URL to edit, when in adminSearchMode
|
||||
$p['type'] = $this->_x('Pages', 'match-type');
|
||||
$p['editUrl'] = $page->editable() ? $this->config->urls->admin . 'page/edit/?id=' . $page->id : '';
|
||||
$p['editUrl'] = $page->editable() ? $page->editUrl() : '';
|
||||
}
|
||||
|
||||
if(isset($display['name']) && isset($display['format'])) {
|
||||
@@ -1283,7 +1331,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
} else {
|
||||
// use display fields
|
||||
foreach($display as $k => $key) {
|
||||
foreach($display as $key) {
|
||||
|
||||
if($key == 'template_label') {
|
||||
$p['template_label'] = $page->template->$templateLabel ? $page->template->$templateLabel : $page->template->label;
|
||||
@@ -1358,13 +1406,14 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
*
|
||||
*/
|
||||
public function renderSearchForm($placeholder = '') {
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
$q = substr((string) $this->input->get('q'), 0, 128);
|
||||
$q = $this->wire('sanitizer')->entities($q);
|
||||
$adminURL = $this->wire('config')->urls->admin;
|
||||
$q = substr((string) $this->wire()->input->get('q'), 0, 128);
|
||||
$q = $sanitizer->entities($q);
|
||||
$adminURL = $this->wire()->config->urls->admin;
|
||||
|
||||
if($placeholder) {
|
||||
$placeholder = $this->wire('sanitizer')->entities1($placeholder);
|
||||
$placeholder = $sanitizer->entities1($placeholder);
|
||||
$placeholder = " placeholder='$placeholder'";
|
||||
} else {
|
||||
$placeholder = '';
|
||||
@@ -1376,7 +1425,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
"\n<form id='ProcessPageSearchForm' data-action='$action' action='$action' method='get'>" .
|
||||
"\n\t<label for='ProcessPageSearchQuery'><i class='fa fa-search'></i></label>" .
|
||||
"\n\t<input type='text' id='ProcessPageSearchQuery' name='q' value='$q' $placeholder />" .
|
||||
"\n\t<input type='submit' id='ProcessPageSearchSubmit' name='search' value='Search' />" . //" . $this->_x('Search', 'input') . "' />" . // Text that appears as the placeholder text in the top search submit input
|
||||
"\n\t<input type='submit' id='ProcessPageSearchSubmit' name='search' value='Search' />" .
|
||||
"\n\t<input type='hidden' name='show_options' value='1' />" .
|
||||
"\n\t<span id='ProcessPageSearchStatus'></span>" .
|
||||
"\n</form>";
|
||||
@@ -1387,12 +1436,12 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
public function getModuleConfigInputfields(array $data) {
|
||||
|
||||
$modules = $this->wire()->modules;
|
||||
|
||||
$adminLiveSearchLabel = $this->_('Admin live search');
|
||||
$inputfields = $this->wire(new InputfieldWrapper());
|
||||
$modules = $this->wire('modules');
|
||||
$textFields = array();
|
||||
$allSearchTypes = array('pages', 'trash', 'modules');
|
||||
// $textOperators = array('%=', '~=', '*=', '~*=', '~~=', '~%=', '~|=', '~|*=', '^=', '=');
|
||||
$textOperators = Selectors::getOperators(array(
|
||||
'compareType' => Selector::compareTypeFind,
|
||||
'getIndexType' => 'operator',
|
||||
@@ -1403,11 +1452,12 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
if(!isset($data['searchTypesOrder'])) $data['searchTypesOrder'] = array();
|
||||
if(!isset($data['noSearchTypes'])) $data['noSearchTypes'] = array();
|
||||
|
||||
$searchTypesOrder = &$data['searchTypesOrder'];
|
||||
$noSearchTypes = &$data['noSearchTypes'];
|
||||
|
||||
// find all text fields
|
||||
foreach($this->wire('fields') as $field) {
|
||||
foreach($this->wire()->fields as $field) {
|
||||
if(!$field->type instanceof FieldtypeText) continue;
|
||||
$textFields[$field->name] = $field;
|
||||
}
|
||||
@@ -1418,8 +1468,8 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
|
||||
// find searchable modules
|
||||
foreach($this->wire('modules') as $module) {
|
||||
$info = $this->wire('modules')->getModuleInfoVerbose($module);
|
||||
foreach($modules as $module) {
|
||||
$info = $modules->getModuleInfoVerbose($module);
|
||||
if(empty($info['searchable'])) continue;
|
||||
$name = $info['searchable'];
|
||||
if(is_bool($name) || ctype_digit($name)) $name = $info['name'];
|
||||
@@ -1433,6 +1483,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$fieldset->icon = 'search';
|
||||
$inputfields->add($fieldset);
|
||||
|
||||
/** @var InputfieldAsmSelect $f */
|
||||
$f = $modules->get('InputfieldAsmSelect');
|
||||
$f->attr('name', 'searchTypesOrder');
|
||||
$f->label = $this->_('Search order');
|
||||
@@ -1449,6 +1500,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$f->setAsmSelectOption('addable', false);
|
||||
$fieldset->add($f);
|
||||
|
||||
/** @var InputfieldAsmSelect $f */
|
||||
$f = $modules->get('InputfieldAsmSelect');
|
||||
$f->attr('name', 'noSearchTypes');
|
||||
$f->label = $this->_('Exclude search types');
|
||||
@@ -1470,6 +1522,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$fieldset->themeOffset = 'm';
|
||||
$inputfields->add($fieldset);
|
||||
|
||||
/** @var InputfieldAsmSelect $f */
|
||||
$f = $modules->get('InputfieldAsmSelect');
|
||||
$f->attr('name', 'searchFields2');
|
||||
$f->label = $this->_('Page fields to search');
|
||||
@@ -1482,6 +1535,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$f->value = $value;
|
||||
$fieldset->add($f);
|
||||
|
||||
/** @var InputfieldAsmSelect $f */
|
||||
$f = $modules->get('InputfieldAsmSelect');
|
||||
$f->attr('name', 'searchFields');
|
||||
$f->label = $this->_('Page fields to search if user hits “enter” in the search box');
|
||||
@@ -1494,6 +1548,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$f->value = $value;
|
||||
$fieldset->append($f);
|
||||
|
||||
/** @var InputfieldSelect $f */
|
||||
$f = $modules->get("InputfieldSelect");
|
||||
$f->attr('name', 'operator');
|
||||
$f->attr('value', isset($data['operator']) ? $data['operator'] : self::defaultOperator);
|
||||
@@ -1504,6 +1559,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
}
|
||||
$fieldset->append($f);
|
||||
|
||||
/** @var InputfieldSelect $f */
|
||||
$f = $modules->get("InputfieldSelect");
|
||||
$f->attr('name', 'operator2');
|
||||
$f->attr('value', isset($data['operator2']) ? $data['operator2'] : '~=');
|
||||
@@ -1515,6 +1571,7 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
$fieldset->append($f);
|
||||
|
||||
// displayField: no longer used, except if user lacks page-lister permission
|
||||
/** @var InputfieldHidden $f */
|
||||
$f = $modules->get("InputfieldHidden");
|
||||
$f->attr('name', 'displayField');
|
||||
$f->attr('value', isset($data['displayField']) ? $data['displayField'] : 'name');
|
||||
@@ -1524,7 +1581,4 @@ class ProcessPageSearch extends Process implements ConfigurableModule {
|
||||
|
||||
return $inputfields;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -231,19 +231,12 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
protected function init(array $presets = array()) {
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
/** @var Fields $fields */
|
||||
$fields = $this->wire('fields');
|
||||
/** @var Templates $templates */
|
||||
$templates = $this->wire('templates');
|
||||
/** @var User $user */
|
||||
$user = $this->wire('user');
|
||||
/** @var Languages $languages */
|
||||
$languages = $this->wire('languages');
|
||||
/** @var AdminTheme|AdminThemeFramework $adminTheme */
|
||||
$input = $this->wire()->input;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
$fields = $this->wire()->fields;
|
||||
$templates = $this->wire()->templates;
|
||||
$user = $this->wire()->user;
|
||||
$languages = $this->wire()->languages;
|
||||
$adminTheme = $this->wire()->adminTheme;
|
||||
|
||||
$type = isset($presets['type']) ? $presets['type'] : '';
|
||||
@@ -354,7 +347,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
$template = $templates->get($type);
|
||||
}
|
||||
|
||||
if($template && $template instanceof Template) {
|
||||
if($template instanceof Template) {
|
||||
// does search type match the name of a template?
|
||||
$selectors[] = "template=$template->name";
|
||||
$type = '';
|
||||
@@ -386,7 +379,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
'q' => $q,
|
||||
'selectors' => $selectors,
|
||||
'template' => $template,
|
||||
'multilang' => $this->wire('languages') ? true : false,
|
||||
'multilang' => $languages ? true : false,
|
||||
'language' => $language,
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
@@ -414,8 +407,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
public function ___execute($getJSON = true) {
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
$input = $this->wire()->input;
|
||||
|
||||
$liveSearch = $this->init();
|
||||
|
||||
@@ -449,8 +441,8 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
public function executeViewAll() {
|
||||
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
$input = $this->wire()->input;
|
||||
|
||||
$this->isViewAll = true;
|
||||
|
||||
$type = $input->get->pageName('type');
|
||||
@@ -532,8 +524,11 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
protected function find(array &$liveSearch) {
|
||||
|
||||
$user = $this->wire()->user;
|
||||
$modules = $this->wire()->modules;
|
||||
$languages = $this->wire()->languages;
|
||||
|
||||
$items = array();
|
||||
$user = $this->wire('user');
|
||||
$userLanguage = null;
|
||||
$q = $liveSearch['q'];
|
||||
$type = $liveSearch['type'];
|
||||
@@ -541,12 +536,6 @@ class ProcessPageSearchLive extends Wire {
|
||||
$modulesInfo = array();
|
||||
$help = $liveSearch['help'];
|
||||
|
||||
/** @var Modules $modules */
|
||||
$modules = $this->wire('modules');
|
||||
|
||||
/** @var Languages $languages */
|
||||
$languages = $this->wire('languages');
|
||||
|
||||
if($languages && $liveSearch['language']) {
|
||||
// change current user to have requested language, temporarily
|
||||
$language = $languages->get($liveSearch['language']);
|
||||
@@ -575,7 +564,6 @@ class ProcessPageSearchLive extends Wire {
|
||||
$foundTypes[] = $thisType;
|
||||
$module = null;
|
||||
$result = array();
|
||||
$timer = null;
|
||||
|
||||
try {
|
||||
/** @var SearchableModule $module */
|
||||
@@ -629,7 +617,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
}
|
||||
|
||||
if($type && !$help && !count($foundTypes) && !in_array($type, array('pages', 'trash', 'modules'))) {
|
||||
if(empty($liveSearch['template']) && !count($foundTypes)) {
|
||||
if(empty($liveSearch['template'])) {
|
||||
// if no types matched, and it’s going to skip pages, assume type is a property, and do a pages search
|
||||
$liveSearch = $this->init(array(
|
||||
'q' => $liveSearch['q'],
|
||||
@@ -651,7 +639,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
}
|
||||
|
||||
// use built-in modules search when appropriate
|
||||
if($this->useType('modules', $type) && $this->wire('user')->isSuperuser()) {
|
||||
if($this->useType('modules', $type) && $this->wire()->user->isSuperuser()) {
|
||||
if(!in_array('modules', $this->searchTypesOrder)) $this->searchTypesOrder[] = 'modules';
|
||||
$order = array_search('modules', $this->searchTypesOrder) * 100;
|
||||
foreach($this->findModules($liveSearch, $modulesInfo) as $item) {
|
||||
@@ -686,14 +674,14 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
protected function findPages(array &$liveSearch) {
|
||||
|
||||
$user = $this->wire('user');
|
||||
$pages = $this->wire()->pages;
|
||||
$config = $this->wire()->config;
|
||||
$user = $this->wire()->user;
|
||||
$superuser = $user->isSuperuser();
|
||||
$pages = $this->wire('pages');
|
||||
$config = $this->wire('config');
|
||||
|
||||
if(!empty($liveSearch['help'])) {
|
||||
$result = array('title' => 'pages', 'items' => array(), 'properties' => array('name', 'title'));
|
||||
if($this->wire('fields')->get('body')) $result['properties'][] = 'body';
|
||||
if($this->wire()->fields->get('body')) $result['properties'][] = 'body';
|
||||
$result['properties'][] = $this->_('or any field name');
|
||||
return $this->makeHelpItems($result, 'pages');
|
||||
}
|
||||
@@ -820,13 +808,16 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
protected function findModules(array &$liveSearch, array &$modulesInfo) {
|
||||
|
||||
$modules = $this->wire()->modules;
|
||||
$adminUrl = $this->wire()->config->urls->admin;
|
||||
|
||||
$q = $liveSearch['q'];
|
||||
$groupLabel = $this->labels['modules'];
|
||||
$items = array();
|
||||
$forceMatch = false;
|
||||
|
||||
if(!empty($liveSearch['help'])) {
|
||||
$info = $this->wire('modules')->getModuleInfoVerbose('ProcessPageSearch');
|
||||
$info = $modules->getModuleInfoVerbose('ProcessPageSearch');
|
||||
$properties = array();
|
||||
foreach(array_keys($info) as $property) {
|
||||
$value = $info[$property];
|
||||
@@ -846,9 +837,9 @@ class ProcessPageSearchLive extends Wire {
|
||||
if($liveSearch['type'] === 'modules' && !empty($liveSearch['property'])) {
|
||||
// searching for custom module property
|
||||
$forceMatch = true;
|
||||
$infos = $this->wire('modules')->findByInfo(
|
||||
$infos = $modules->findByInfo(
|
||||
$liveSearch['property'] . $liveSearch['operator'] .
|
||||
$this->wire('sanitizer')->selectorValue($q), 2
|
||||
$this->wire()->sanitizer->selectorValue($q), 2
|
||||
);
|
||||
} else {
|
||||
// text-matching for all modules
|
||||
@@ -870,7 +861,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
'title' => $title,
|
||||
'subtitle' => $name,
|
||||
'summary' => $summary,
|
||||
'url' => $this->wire('config')->urls->admin . "module/edit?name=$name",
|
||||
'url' => $adminUrl . "module/edit?name=$name",
|
||||
'group' => $groupLabel,
|
||||
);
|
||||
$item = array_merge($this->itemTemplate, $item);
|
||||
@@ -899,7 +890,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
protected function convertItemsFormat(array $items) {
|
||||
|
||||
$converted = array();
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
foreach($items as $item) {
|
||||
$a = array(
|
||||
@@ -933,7 +924,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
*
|
||||
*/
|
||||
protected function makeDebugItem($liveSearch) {
|
||||
$liveSearch['user_language'] = $this->wire('user')->language->name;
|
||||
$liveSearch['user_language'] = $this->wire()->user->language->name;
|
||||
$summary = print_r($liveSearch, true);
|
||||
return array_merge($this->itemTemplate, array(
|
||||
'id' => 0,
|
||||
@@ -955,11 +946,12 @@ class ProcessPageSearchLive extends Wire {
|
||||
*
|
||||
*/
|
||||
protected function makeHelpItems(array $result, $type) {
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
$items = array();
|
||||
$helloLabel = $this->_('test');
|
||||
$usage1desc = $this->wire('sanitizer')->unentities($this->_('Searches %1$s for: %2$s'));
|
||||
$usage2desc = $this->wire('sanitizer')->unentities($this->_('Searches “%1$s” property of %2$s for: %3$s'));
|
||||
$usage1desc = $sanitizer->unentities($this->_('Searches %1$s for: %2$s'));
|
||||
$usage2desc = $sanitizer->unentities($this->_('Searches “%1$s” property of %2$s for: %3$s'));
|
||||
|
||||
if($type === 'help') {
|
||||
$operators = ProcessPageSearch::getOperators();
|
||||
@@ -976,11 +968,11 @@ class ProcessPageSearchLive extends Wire {
|
||||
'group' => 'help',
|
||||
'url' => 'https://processwire.com/api/selectors/#operators'
|
||||
);
|
||||
if($this->wire('user')->isSuperuser() && $this->process) {
|
||||
if($this->wire()->user->isSuperuser() && $this->process) {
|
||||
$items[] = array(
|
||||
'title' => $this->_('configure'),
|
||||
'subtitle' => $this->_('Click here to configure search settings'),
|
||||
'url' => $url = $this->wire('modules')->getModuleEditUrl('ProcessPageSearch'),
|
||||
'url' => $this->wire()->modules->getModuleEditUrl('ProcessPageSearch'),
|
||||
'group' => 'help',
|
||||
);
|
||||
}
|
||||
@@ -1044,7 +1036,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
$properties = implode(', ', $result['properties']);
|
||||
|
||||
if(strlen($properties) > 50) {
|
||||
$properties = $this->wire('sanitizer')->truncate($properties, 50) . ' ' . $this->_('(hover for more)');
|
||||
$properties = $this->wire()->sanitizer->truncate($properties, 50) . ' ' . $this->_('(hover for more)');
|
||||
}
|
||||
|
||||
$summary =
|
||||
@@ -1086,7 +1078,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
if(!empty($url)) {
|
||||
// use provided url
|
||||
} else if($type == 'pages' || $type == 'trash' || !empty($liveSearch['template'])) {
|
||||
$url = $this->wire('page')->url();
|
||||
$url = $this->wire()->page->url();
|
||||
$url .= "?q=" . urlencode($liveSearch['q']) . "&live=1";
|
||||
if($type == 'trash') $url .= "&trash=1";
|
||||
if(!empty($liveSearch['template'])) {
|
||||
@@ -1133,7 +1125,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
$groups = array();
|
||||
$totals = array();
|
||||
$counts = array();
|
||||
$btn = $this->modules->get('InputfieldButton'); /** @var InputfieldButton $btn */
|
||||
$btn = $this->wire()->modules->get('InputfieldButton'); /** @var InputfieldButton $btn */
|
||||
$btn->aclass = "$prefix-view-all";
|
||||
|
||||
foreach($items as $item) {
|
||||
@@ -1163,7 +1155,8 @@ class ProcessPageSearchLive extends Wire {
|
||||
unset($groups[$group]);
|
||||
}
|
||||
|
||||
$wireTabs = $this->wire('modules')->get('JqueryWireTabs');
|
||||
/** @var JqueryWireTabs $wireTabs */
|
||||
$wireTabs = $this->wire()->modules->get('JqueryWireTabs');
|
||||
|
||||
return
|
||||
"<div class='pw-search-$class'>" .
|
||||
@@ -1183,8 +1176,7 @@ class ProcessPageSearchLive extends Wire {
|
||||
*/
|
||||
protected function ___renderItem(array $item, $prefix = 'pw-search', $class = 'item') {
|
||||
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
foreach(array('title', 'subtitle', 'summary', 'url') as $key) {
|
||||
if(isset($item[$key])) {
|
||||
|
Reference in New Issue
Block a user