Merge branch 'MDL-53247-master' of git://github.com/danpoltawski/moodle
This commit is contained in:
+17
-17
@@ -9538,22 +9538,10 @@ class admin_setting_searchsetupinfo extends admin_setting {
|
||||
|
||||
$return .= $brtag . get_string('searchsetupdescription', 'search') . $brtag . $brtag;
|
||||
|
||||
// Enable global search.
|
||||
$row = array();
|
||||
$url = new moodle_url("/admin/search.php?query=enableglobalsearch");
|
||||
$row[0] = '1. ' . html_writer::tag('a', get_string('enableglobalsearch', 'admin'),
|
||||
array('href' => $url));
|
||||
$status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
|
||||
if (\core_search\manager::is_global_search_enabled()) {
|
||||
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
|
||||
}
|
||||
$row[1] = $status;
|
||||
$table->data[] = $row;
|
||||
|
||||
// Select a search engine.
|
||||
$row = array();
|
||||
$url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
|
||||
$row[0] = '2. ' . html_writer::tag('a', get_string('selectsearchengine', 'admin'),
|
||||
$row[0] = '1. ' . html_writer::tag('a', get_string('selectsearchengine', 'admin'),
|
||||
array('href' => $url));
|
||||
|
||||
$status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
|
||||
@@ -9568,7 +9556,7 @@ class admin_setting_searchsetupinfo extends admin_setting {
|
||||
// Available areas.
|
||||
$row = array();
|
||||
$url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
|
||||
$row[0] = '3. ' . html_writer::tag('a', get_string('enablesearchareas', 'admin'),
|
||||
$row[0] = '2. ' . html_writer::tag('a', get_string('enablesearchareas', 'admin'),
|
||||
array('href' => $url));
|
||||
|
||||
$status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
|
||||
@@ -9582,11 +9570,11 @@ class admin_setting_searchsetupinfo extends admin_setting {
|
||||
// Setup search engine.
|
||||
$row = array();
|
||||
if (empty($CFG->searchengine)) {
|
||||
$row[0] = '4. ' . get_string('setupsearchengine', 'admin');
|
||||
$row[0] = '3. ' . get_string('setupsearchengine', 'admin');
|
||||
$row[1] = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
|
||||
} else {
|
||||
$url = new moodle_url('/admin/settings.php?section=search' . $CFG->searchengine);
|
||||
$row[0] = '4. ' . html_writer::tag('a', get_string('setupsearchengine', 'admin'),
|
||||
$row[0] = '3. ' . html_writer::tag('a', get_string('setupsearchengine', 'admin'),
|
||||
array('href' => $url));
|
||||
// Check the engine status.
|
||||
$searchengine = \core_search\manager::search_engine_instance();
|
||||
@@ -9603,7 +9591,7 @@ class admin_setting_searchsetupinfo extends admin_setting {
|
||||
// Indexed data.
|
||||
$row = array();
|
||||
$url = new moodle_url('/report/search/index.php#searchindexform');
|
||||
$row[0] = '5. ' . html_writer::tag('a', get_string('indexdata', 'admin'), array('href' => $url));
|
||||
$row[0] = '4. ' . html_writer::tag('a', get_string('indexdata', 'admin'), array('href' => $url));
|
||||
if ($anyindexed) {
|
||||
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
|
||||
} else {
|
||||
@@ -9612,6 +9600,18 @@ class admin_setting_searchsetupinfo extends admin_setting {
|
||||
$row[1] = $status;
|
||||
$table->data[] = $row;
|
||||
|
||||
// Enable global search.
|
||||
$row = array();
|
||||
$url = new moodle_url("/admin/search.php?query=enableglobalsearch");
|
||||
$row[0] = '5. ' . html_writer::tag('a', get_string('enableglobalsearch', 'admin'),
|
||||
array('href' => $url));
|
||||
$status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
|
||||
if (\core_search\manager::is_global_search_enabled()) {
|
||||
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
|
||||
}
|
||||
$row[1] = $status;
|
||||
$table->data[] = $row;
|
||||
|
||||
$return .= html_writer::table($table);
|
||||
|
||||
return highlight($query, $return);
|
||||
|
||||
@@ -37,8 +37,6 @@ echo $OUTPUT->heading($pagetitle);
|
||||
if (\core_search\manager::is_global_search_enabled() === false) {
|
||||
$renderer = $PAGE->get_renderer('core_search');
|
||||
echo $renderer->render_search_disabled();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('report_search');
|
||||
|
||||
@@ -99,10 +99,6 @@ class manager {
|
||||
/**
|
||||
* Returns an initialised \core_search instance.
|
||||
*
|
||||
* It requires global search to be enabled. Use \core_search\manager::is_global_search_enabled
|
||||
* to verify it is enabled.
|
||||
*
|
||||
* @throws \moodle_exception
|
||||
* @throws \core_search\engine_exception
|
||||
* @return \core_search\manager
|
||||
*/
|
||||
@@ -114,10 +110,6 @@ class manager {
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
if (!static::is_global_search_enabled()) {
|
||||
throw new \moodle_exception('globalsearchdisabled', 'search');
|
||||
}
|
||||
|
||||
if (!$engine = static::search_engine_instance()) {
|
||||
throw new \core_search\engine_exception('enginenotfound', 'search', '', $CFG->searchengine);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* CLI search indexer
|
||||
*
|
||||
* @package search
|
||||
* @copyright 2016 Dan Poltawski <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(array('help' => false, 'force' => false, 'reindex' => false),
|
||||
array('h' => 'help', 'f' => 'force', 'r' => 'reindex'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Index search data
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-r, --reindex Reindex data
|
||||
-f, --force Allow indexer to run, even if global search is disabled.
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php search/cli/indexer.php --reindex
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if (!\core_search\manager::is_global_search_enabled() && empty($options['force'])) {
|
||||
cli_error('Global search is disabled. Use --force if you want to force an index while disabled');
|
||||
}
|
||||
|
||||
$globalsearch = \core_search\manager::instance();
|
||||
|
||||
if (empty($options['reindex'])) {
|
||||
echo "Running full index of site\n";
|
||||
echo "==========================\n";
|
||||
$globalsearch->index();
|
||||
} else {
|
||||
echo "Running full reindex of site\n";
|
||||
echo "============================\n";
|
||||
$globalsearch->index(true);
|
||||
}
|
||||
|
||||
// Optimize index at last.
|
||||
$globalsearch->optimize_index();
|
||||
@@ -34,14 +34,6 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_login(null, false);
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
if (!\core_search\manager::is_global_search_enabled()) {
|
||||
throw new moodle_exception('globalsearchdisabled', 'search');
|
||||
}
|
||||
|
||||
if ($CFG->searchengine !== 'solr') {
|
||||
throw new moodle_exception('solrnotselected', 'search_solr');
|
||||
}
|
||||
|
||||
$schema = new \search_solr\schema();
|
||||
$schema->setup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user