MDL-85518 admin: Assign search match types to improve result sorting

This commit is contained in:
David Woloszyn
2025-08-25 12:01:29 +10:00
parent 6509b43b4c
commit 399aaeca1f
11 changed files with 249 additions and 47 deletions
@@ -0,0 +1,10 @@
issueNumber: MDL-85518
notes:
core_admin:
- message: >
- Added `searchmatchtype` property to `admin_settings`
to track search match type.
- Plugins that extend either `admin_settings` or `admin_externalpage`
are encouraged to specify a search match type from the available
types in `admin_search`.
type: improved
@@ -19,6 +19,7 @@ namespace core_admin\admin;
use admin_setting;
use core_plugin_manager;
use core_text;
use core_admin\admin_search;
/**
* Admin setting plugin manager.
@@ -98,11 +99,13 @@ class admin_setting_plugin_manager extends admin_setting {
foreach (array_keys($plugins) as $plugin) {
$plugin = "{$this->plugintype}_{$plugin}";
if (str_contains($plugin, $query)) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
$pluginname = get_string('pluginname', $plugin);
if (strpos(core_text::strtolower($pluginname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_admin;
/**
* Process admin search results.
*
* @package core_admin
* @copyright 2025 David Woloszyn <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_search {
/** @var string Search match for a page title. */
const SEARCH_MATCH_PAGE_TITLE = 'title';
/** @var string Search match for a setting short name. */
const SEARCH_MATCH_SETTING_SHORT_NAME = 'shortname';
/** @var string Search match for a setting display name. */
const SEARCH_MATCH_SETTING_DISPLAY_NAME = 'displayname';
/** @var string Search match for a setting value. */
const SEARCH_MATCH_SETTING_VALUE = 'value';
/** @var string Search match for a setting helper. */
const SEARCH_MATCH_SETTING_HELPER = 'helper';
/**
* Get a prioritised list of search match types.
*
* The order will determine how results will be displayed.
* Items higher in the list will be displayed first.
*
* @return array The list of priorities.
*/
private static function get_search_match_priorities(): array {
return [
self::SEARCH_MATCH_PAGE_TITLE,
self::SEARCH_MATCH_SETTING_SHORT_NAME,
self::SEARCH_MATCH_SETTING_DISPLAY_NAME,
self::SEARCH_MATCH_SETTING_VALUE,
self::SEARCH_MATCH_SETTING_HELPER,
];
}
/**
* Sort search results according to a set of priorities.
*
* @param array $results The unsorted results.
* @return array The sorted results.
*/
public static function sort_search_results(array $results): array {
$priorities = self::get_search_match_priorities();
// If there is no searchmatchype property, use this priority.
$defaultpriority = count($priorities);
uasort($results, function ($a, $b) use ($priorities, $defaultpriority) {
$prioritya = array_search($a->searchmatchtype, $priorities);
$priorityb = array_search($b->searchmatchtype, $priorities);
$prioritya = ($prioritya === false) ? $defaultpriority : $prioritya;
$priorityb = ($priorityb === false) ? $defaultpriority : $priorityb;
return $prioritya <=> $priorityb;
});
return $results;
}
}
@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_admin\admin_search;
defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/adminlib.php");
@@ -79,10 +81,12 @@ class tool_log_setting_managestores extends admin_setting {
$plugins = \tool_log\log\manager::get_store_plugins();
foreach ($plugins as $plugin => $fulldir) {
if (strpos(core_text::strtolower($plugin), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
$localised = get_string('pluginname', $plugin);
if (strpos(core_text::strtolower($localised), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -23,6 +23,7 @@ use html_table;
use html_table_row;
use html_writer;
use moodle_url;
use core_admin\admin_search;
/**
* Communication providers manager. Allow enable/disable communication providers and jump to settings.
@@ -127,10 +128,12 @@ class manage_communication_providers_page extends admin_setting {
}
$types = core_plugin_manager::instance()->get_plugins_of_type('communication');
foreach ($types as $type) {
if (
strpos($type->component, $query) !== false ||
strpos(core_text::strtolower($type->displayname), $query) !== false
) {
if (strpos($type->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($type->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -16,6 +16,7 @@
namespace enrol_lti\local\ltiadvantage\admin;
use enrol_lti\local\ltiadvantage\repository\application_registration_repository;
use core_admin\admin_search;
/**
* The admin_setting_registeredplatforms class, for rendering a table of platforms which have been registered.
@@ -79,6 +80,7 @@ class admin_setting_registeredplatforms extends \admin_setting {
$registrations = $appregistrationrepo->find_all();
foreach ($registrations as $reg) {
if (stripos($reg->get_name(), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
+122 -41
View File
@@ -103,6 +103,7 @@
*/
use core_admin\local\settings\linkable_settings_page;
use core_admin\admin_search;
defined('MOODLE_INTERNAL') || die();
@@ -1233,6 +1234,9 @@ class admin_externalpage implements part_of_admin_tree, linkable_settings_page {
/** @var array list of visible names of page parents */
public $visiblepath;
/** @var string Capture the type of search matched from the query. */
public $searchmatchtype;
/**
* Constructor for adding an external page into the admin tree.
*
@@ -1304,18 +1308,21 @@ class admin_externalpage implements part_of_admin_tree, linkable_settings_page {
*/
public function search($query) {
$found = false;
if (strpos(strtolower($this->name), $query) !== false) {
if (
strpos(core_text::strtolower($this->visiblename), $query) !== false ||
strpos(strtolower($this->name), $query) !== false
) {
$type = admin_search::SEARCH_MATCH_PAGE_TITLE;
$found = true;
} else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
$found = true;
}
}
if ($found) {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
$result->page = $this;
$result->settings = [];
$result->searchmatchtype = $type;
return [$this->name => $result];
} else {
return array();
return [];
}
}
@@ -1530,35 +1537,43 @@ class admin_settingpage implements part_of_admin_tree, linkable_settings_page {
* @return array
*/
public function search($query) {
$found = array();
$found = false;
// Prioritise matching the page title.
if (
strpos(core_text::strtolower($this->visiblename), $query) !== false ||
strpos(strtolower($this->name), $query) !== false
) {
$type = admin_search::SEARCH_MATCH_PAGE_TITLE;
$found = true;
}
if ($found) {
$result = new stdClass();
$result->page = $this;
$result->settings = [];
$result->searchmatchtype = $type;
return [$this->name => $result];
}
// Search related settings.
$foundrelated = [];
foreach ($this->settings as $setting) {
if ($setting->is_related($query)) {
$found[] = $setting;
$foundrelated[] = $setting;
}
}
if ($found) {
if (!empty($foundrelated)) {
$sortedresults = admin_search::sort_search_results($foundrelated);
$result = new stdClass();
$result->page = $this;
$result->settings = $found;
return array($this->name => $result);
$result->page = $this;
$result->settings = $sortedresults;
// Multiple related matches may have been found. Get the highest priority one.
$result->searchmatchtype = reset($sortedresults)->searchmatchtype;
return [$this->name => $result];
}
$found = false;
if (strpos(strtolower($this->name), $query) !== false) {
$found = true;
} else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
$found = true;
}
if ($found) {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
return array($this->name => $result);
} else {
return array();
}
return [];
}
/**
@@ -1730,6 +1745,8 @@ abstract class admin_setting {
protected $customcontrol = false;
/** @var mixed int means PARAM_XXX type, string is a allowed format in regex */
public $paramtype;
/** @var string Capture the type of search matched from the query. */
public $searchmatchtype;
/**
* Constructor
@@ -2086,18 +2103,22 @@ abstract class admin_setting {
*/
public function is_related($query) {
if (strpos(strtolower($this->name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
if (strpos(core_text::strtolower($this->description), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_HELPER;
return true;
}
$current = $this->get_setting();
if (!is_null($current)) {
if (is_string($current)) {
if (strpos(core_text::strtolower($current), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_VALUE;
return true;
}
}
@@ -2106,6 +2127,7 @@ abstract class admin_setting {
if (!is_null($default)) {
if (is_string($default)) {
if (strpos(core_text::strtolower($default), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_HELPER;
return true;
}
}
@@ -3210,6 +3232,7 @@ class admin_setting_configmulticheckbox extends admin_setting {
foreach ($this->choices as $desc) {
if (strpos(core_text::strtolower($desc), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_VALUE;
return true;
}
}
@@ -3479,9 +3502,11 @@ class admin_setting_configselect extends admin_setting {
}
foreach ($this->choices as $key=>$value) {
if (strpos(core_text::strtolower($key), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_VALUE;
return true;
}
if (strpos(core_text::strtolower($value), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_VALUE;
return true;
}
}
@@ -3714,6 +3739,7 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
foreach ($this->choices as $desc) {
if (strpos(core_text::strtolower($desc), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_VALUE;
return true;
}
}
@@ -6669,11 +6695,13 @@ class admin_page_managemods extends admin_externalpage {
continue;
}
if (strpos($module->name, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
$strmodulename = get_string('modulename', $module->name);
if (strpos(core_text::strtolower($strmodulename), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -6683,6 +6711,7 @@ class admin_page_managemods extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -6750,9 +6779,11 @@ class admin_setting_manageenrols extends admin_setting {
foreach ($enrols as $name=>$enrol) {
$localised = get_string('pluginname', 'enrol_'.$name);
if (strpos(core_text::strtolower($name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($localised), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -6950,11 +6981,13 @@ class admin_page_manageblocks extends admin_externalpage {
continue;
}
if (strpos($block->name, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
$strblockname = get_string('pluginname', 'block_'.$block->name);
if (strpos(core_text::strtolower($strblockname), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -6964,6 +6997,7 @@ class admin_page_manageblocks extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7007,11 +7041,13 @@ class admin_page_managemessageoutputs extends admin_externalpage {
continue;
}
if (strpos($processor->name, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
$strprocessorname = get_string('pluginname', 'message_'.$processor->name);
if (strpos(core_text::strtolower($strprocessorname), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -7021,6 +7057,7 @@ class admin_page_managemessageoutputs extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7061,6 +7098,7 @@ class admin_page_manageqbehaviours extends admin_externalpage {
foreach (core_component::get_plugin_list('qbehaviour') as $behaviour => $notused) {
if (strpos(core_text::strtolower(question_engine::get_behaviour_name($behaviour)),
$query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -7069,6 +7107,7 @@ class admin_page_manageqbehaviours extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7108,6 +7147,7 @@ class admin_page_manageqtypes extends admin_externalpage {
require_once($CFG->dirroot . '/question/engine/bank.php');
foreach (question_bank::get_all_qtypes() as $qtype) {
if (strpos(core_text::strtolower($qtype->local_name()), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -7116,6 +7156,7 @@ class admin_page_manageqtypes extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7149,6 +7190,7 @@ class admin_page_manageportfolios extends admin_externalpage {
$portfolios = core_component::get_plugin_list('portfolio');
foreach ($portfolios as $p => $dir) {
if (strpos($p, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
@@ -7157,6 +7199,7 @@ class admin_page_manageportfolios extends admin_externalpage {
foreach (portfolio_instances(false, false) as $instance) {
$title = $instance->get('name');
if (strpos(core_text::strtolower($title), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -7167,6 +7210,7 @@ class admin_page_manageportfolios extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7200,6 +7244,7 @@ class admin_page_managerepositories extends admin_externalpage {
$repositories= core_component::get_plugin_list('repository');
foreach ($repositories as $p => $dir) {
if (strpos($p, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
@@ -7208,6 +7253,7 @@ class admin_page_managerepositories extends admin_externalpage {
foreach (repository::get_types() as $instance) {
$title = $instance->get_typename();
if (strpos(core_text::strtolower($title), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -7218,6 +7264,7 @@ class admin_page_managerepositories extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -7282,11 +7329,13 @@ class admin_setting_manageauths extends admin_setting {
$authsavailable = core_component::get_plugin_list('auth');
foreach ($authsavailable as $auth => $dir) {
if (strpos($auth, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
$authplugin = get_auth_plugin($auth);
$authtitle = $authplugin->get_title();
if (strpos(core_text::strtolower($authtitle), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -7510,9 +7559,11 @@ class admin_setting_manageantiviruses extends admin_setting {
$antivirusesavailable = \core\antivirus\manager::get_available();
foreach ($antivirusesavailable as $antivirus => $antivirusstr) {
if (strpos($antivirus, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($antivirusstr), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -7687,8 +7738,12 @@ class admin_setting_manageformats extends admin_setting {
}
$formats = core_plugin_manager::instance()->get_plugins_of_type('format');
foreach ($formats as $format) {
if (strpos($format->component, $query) !== false ||
strpos(core_text::strtolower($format->displayname), $query) !== false) {
if (strpos($format->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($format->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -7837,8 +7892,12 @@ class admin_setting_managecustomfields extends admin_setting {
}
$formats = core_plugin_manager::instance()->get_plugins_of_type('customfield');
foreach ($formats as $format) {
if (strpos($format->component, $query) !== false ||
strpos(core_text::strtolower($format->displayname), $query) !== false) {
if (strpos($format->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($format->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -7961,8 +8020,12 @@ class admin_setting_managedataformats extends admin_setting {
}
$formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
foreach ($formats as $format) {
if (strpos($format->component, $query) !== false ||
strpos(core_text::strtolower($format->displayname), $query) !== false) {
if (strpos($format->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($format->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -8092,11 +8155,13 @@ class admin_page_managefilters extends admin_externalpage {
$found = false;
$filternames = filter_get_all_installed();
foreach ($filternames as $path => $strfiltername) {
if (strpos(core_text::strtolower($strfiltername), $query) !== false) {
if (strpos($path, $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
$found = true;
break;
}
if (strpos($path, $query) !== false) {
if (strpos(core_text::strtolower($strfiltername), $query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -8106,6 +8171,7 @@ class admin_page_managefilters extends admin_externalpage {
$result = new stdClass;
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -8215,9 +8281,11 @@ abstract class admin_setting_manage_plugins extends admin_setting {
foreach ($plugins as $name => $plugin) {
$localised = $plugin->displayname;
if (strpos(core_text::strtolower($name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($localised), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -8399,9 +8467,11 @@ class admin_setting_managemediaplayers extends admin_setting {
foreach ($plugins as $name => $plugin) {
$localised = $plugin->displayname;
if (strpos(core_text::strtolower($name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($localised), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -8618,8 +8688,12 @@ class admin_setting_managecontentbankcontenttypes extends admin_setting {
}
$types = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
foreach ($types as $type) {
if (strpos($type->component, $query) !== false ||
strpos(core_text::strtolower($type->displayname), $query) !== false) {
if (strpos($type->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(core_text::strtolower($type->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -9086,9 +9160,11 @@ function admin_search_settings_html($query) {
'sesskey' => sesskey(),
];
foreach ($findings as $found) {
$page = $found->page;
$settings = $found->settings;
$sortedresults = admin_search::sort_search_results($findings);
foreach ($sortedresults as $result) {
$page = $result->page;
$settings = $result->settings;
if ($page->is_hidden()) {
// hidden pages are not displayed in search results
continue;
@@ -9488,12 +9564,14 @@ class admin_setting_managerepository extends admin_setting {
$repositories= core_component::get_plugin_list('repository');
foreach ($repositories as $p => $dir) {
if (strpos($p, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
}
foreach (repository::get_types() as $instance) {
$title = $instance->get_typename();
if (strpos(core_text::strtolower($title), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -9884,6 +9962,7 @@ class admin_setting_manageexternalservices extends admin_setting {
$services = $DB->get_records('external_services', array(), 'id, name');
foreach ($services as $service) {
if (strpos(core_text::strtolower($service->name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -10336,10 +10415,12 @@ class admin_setting_managewebserviceprotocols extends admin_setting {
$protocols = core_component::get_plugin_list('webservice');
foreach ($protocols as $protocol=>$location) {
if (strpos($protocol, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
$protocolstr = get_string('pluginname', 'webservice_'.$protocol);
if (strpos(core_text::strtolower($protocolstr), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
+4
View File
@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_admin\admin_search;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/adminlib.php');
@@ -67,6 +69,7 @@ class assign_admin_page_manage_assign_plugins extends admin_externalpage {
foreach (core_component::get_plugin_list($this->subtype) as $name => $notused) {
if (strpos(core_text::strtolower(get_string('pluginname', $this->subtype . '_' . $name)),
$query) !== false) {
$type = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
$found = true;
break;
}
@@ -75,6 +78,7 @@ class assign_admin_page_manage_assign_plugins extends admin_externalpage {
$result = new stdClass();
$result->page = $this;
$result->settings = array();
$result->searchmatchtype = $type;
return array($this->name => $result);
} else {
return array();
@@ -25,6 +25,7 @@ use core_component;
use core_text;
use mod_bigbluebuttonbn\extension;
use moodle_url;
use core_admin\admin_search;
/**
* Admin external page that displays a list of the installed extension plugins.
@@ -72,6 +73,7 @@ class admin_page_manage_extensions extends admin_externalpage {
$result = (object)[
'page' => $this,
'settings' => [],
'searchmatchtype' => admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME,
];
return [$this->name => $result];
}
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
use core_admin\admin_search;
defined('MOODLE_INTERNAL') || die();
/**
@@ -78,10 +80,12 @@ class mod_glossary_admin_setting_display_formats extends admin_setting {
$formats = $DB->get_records("glossary_formats");
foreach ($formats as $format) {
if (strpos(core_text::strtolower($format->name), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
$localised = get_string("displayformat$format->name", "glossary");
if (strpos(core_text::strtolower($localised), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}
@@ -25,6 +25,8 @@
namespace core_question\admin;
use core_admin\admin_search;
/**
* Class manage_qbank_plugins_page.
*
@@ -62,8 +64,12 @@ class manage_qbank_plugins_page extends \admin_setting {
}
$types = \core_plugin_manager::instance()->get_plugins_of_type('qbank');
foreach ($types as $type) {
if (strpos($type->component, $query) !== false ||
strpos(\core_text::strtolower($type->displayname), $query) !== false) {
if (strpos($type->component, $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_SHORT_NAME;
return true;
}
if (strpos(\core_text::strtolower($type->displayname), $query) !== false) {
$this->searchmatchtype = admin_search::SEARCH_MATCH_SETTING_DISPLAY_NAME;
return true;
}
}