Commit d2edab77 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Move search plugin selection into the application

parent 5c9f5afb
......@@ -31,6 +31,7 @@ define('SUBMENUITEM', 'siteoptions');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
require_once('searchlib.php');
define('TITLE', get_string('siteoptions', 'admin'));
$langoptions = get_languages();
......@@ -38,6 +39,8 @@ $themeoptions = get_themes();
$yesno = array(true => get_string('yes'),
false => get_string('no'));
$searchpluginoptions = get_search_plugins();
$siteoptionform = pieform(array(
'name' => 'siteoptions',
'jsform' => true,
......@@ -65,6 +68,14 @@ $siteoptionform = pieform(array(
'collapseifoneoption' => true,
'options' => $themeoptions,
),
'searchplugin' => array(
'type' => 'select',
'title' => get_string('searchplugin','admin'),
'description' => get_string('searchplugindescription','admin'),
'defaultvalue' => get_config('searchplugin'),
'collapseifoneoption' => true,
'options' => $searchpluginoptions,
),
'pathtofile' => array(
'type' => 'text',
'title' => get_string('pathtofile','admin'),
......@@ -116,7 +127,7 @@ function siteoptions_fail(Pieform $form, $field) {
function siteoptions_submit(Pieform $form, $values) {
$fields = array('sitename','language','theme','pathtofile', 'pathtoclam',
'allowpublicviews','artefactviewinactivitytime');
'allowpublicviews','artefactviewinactivitytime', 'searchplugin');
foreach ($fields as $field) {
if (!set_config($field, $values[$field])) {
siteoptions_fail($form, $field);
......
......@@ -36,9 +36,6 @@ $cfg->dbuser = 'mahara';
$cfg->dbpass = 'mahara';
$cfg->dbprefix = '';
// search plugin to use (currently only 'internal' exists)
$cfg->searchplugin = 'internal';
// wwwroot - the web-visible path to your Mahara installation
// Normally, this is automatically detected - if it doesn't work for you
// then try specifying it here
......
......@@ -197,4 +197,25 @@ function search_selfsearch($query_string, $limit, $offset, $type = 'all') {
return call_static_method(generate_class_name('search', $plugin), 'self_search', $query_string, $limit, $offset, $type);
}
function get_search_plugins() {
$searchpluginoptions = array();
if ($searchplugins = get_records_array('search_installed')) {
foreach ($searchplugins as $plugin) {
$searchpluginoptions[$plugin->name] = $plugin->name;
$config_path = get_config('docroot') . 'search/' . $plugin->name . '/version.php';
if (is_readable($config_path)) {
$config = new StdClass;
require_once($config_path);
if (isset($config->name)) {
$searchpluginoptions[$plugin->name] = $config->name;
}
}
}
}
return $searchpluginoptions;
}
?>
......@@ -421,6 +421,10 @@ function core_postinst() {
else {
$status = false;
}
// Set default search plugin
set_config('searchplugin', 'internal');
return $status;
}
......
......@@ -26,6 +26,7 @@
defined('INTERNAL') || die();
$config->name = 'Internal';
$config->version = 2006111600;
$config->release = '0.1';
......
......@@ -26,6 +26,7 @@
defined('INTERNAL') || die();
$config->name = 'Solr';
$config->version = 2007021900;
$config->release = '0.2';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment