diff --git a/main/admin/settings.php b/main/admin/settings.php
index e62bbf96b0..2ee6899f98 100644
--- a/main/admin/settings.php
+++ b/main/admin/settings.php
@@ -1,4 +1,4 @@
- 'index.php', "name" => get_lang('PlatformAd
$tool_name = get_lang('DokeosConfigSettings');
// Build the form
-if (!empty($_GET['category']) and $_GET['category'] <> "Plugins" and $_GET['category'] <> "stylesheets" )
+if (!empty($_GET['category']) and !in_array($_GET['category'], array('Plugins', 'stylesheets', 'Search')))
{
$form = new FormValidator('settings', 'post', 'settings.php?category='.$_GET['category']);
$renderer = & $form->defaultRenderer();
@@ -291,12 +291,13 @@ $action_images['tuning'] = 'tuning.gif';
$action_images['plugins'] = 'plugin.gif';
$action_images['stylesheets'] = 'theme.gif';
$action_images['templates'] = 'template.gif';
+$action_images['search'] = 'search.gif';
// grabbing the categories
//$selectcategories = "SELECT DISTINCT category FROM ".$table_settings_current." WHERE category NOT IN ('stylesheets','Plugins')";
//$resultcategories = api_sql_query($selectcategories, __FILE__, __LINE__);
-$resultcategories = api_get_settings_categories(array('stylesheets','Plugins', 'Templates'));
+$resultcategories = api_get_settings_categories(array('stylesheets','Plugins', 'Templates', 'Search'));
echo "\n
";
if (isset ($_GET['category']))
@@ -321,6 +323,9 @@ if (isset ($_GET['category']))
case 'stylesheets' :
handle_stylesheets();
break;
+ case 'Search' :
+ handle_search();
+ break;
default :
$form->display();
}
@@ -757,4 +762,73 @@ function is_style($style)
}
return false;
}
+
+/**
+ * Search options
+ * TODO: support for multiple site. aka $_configuration['access_url'] == 1
+ * @author Marco Villegas
+ */
+function handle_search() {
+ global $SettingsStored, $_configuration;
+
+ $search_enabled = api_get_setting('search_enabled');
+ $settings = api_get_settings('Search');
+
+ if ($search_enabled !== 'true' || count($settings) < 1) {
+ Display::display_error_message(get_lang('SearchFeatureNotEnabledComment'));
+ return;
+ }
+
+ require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
+
+ $form = new FormValidator('search-options', 'post', api_get_self().'?category=Search');
+ $renderer = & $form->defaultRenderer();
+ $renderer->setHeaderTemplate('{header}
'."\n");
+ $renderer->setElementTemplate(''."\n".'{element}
'."\n");
+
+ //search_show_unlinked_results
+ $form->addElement('header', null, get_lang('SearchShowUnlinkedResultsTitle'));
+ $form->addElement('label', null, get_lang('SearchShowUnlinkedResultsComment'));
+ $values = get_settings_options('search_show_unlinked_results');
+ $group = array ();
+ foreach ($values as $key => $value) {
+ $element = & $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
+ $group[] = $element;
+ }
+ $form->addGroup($group, 'search_show_unlinked_results', get_lang('SearchShowUnlinkedResultsComment'), '
', false);
+ $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
+
+ //search_prefilter_prefix
+ $form->addElement('header', null, get_lang('SearchPrefilterPrefix'));
+ $form->addElement('label', null, get_lang('SearchPrefilterPrefixComment'));
+ $specific_fields = get_specific_field_list();
+ $sf_values = array();
+ foreach ($specific_fields as $sf) {
+ $sf_values[$sf['code']] = $sf['name'];
+ }
+ $group = array ();
+ $form->addElement('select', 'search_prefilter_prefix', get_lang('SearchPrefilterPrefix'), $sf_values, '');
+ $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
+
+ //$form->addRule('search_show_unlinked_results', get_lang('ThisFieldIsRequired'), 'required');
+ $form->addElement('submit', 'search-options-save', get_lang('Ok'));
+ $form->setDefaults($default_values);
+
+ if( $form->validate()) {
+ $formvalues = $form->exportValues();
+ $r = api_set_settings_category('Search','false',$_configuration['access_url']);
+ // Save the settings
+ foreach ($formvalues as $key => $value)
+ {
+ $result = api_set_setting($key,$value,null,null);
+ }
+
+ Display :: display_normal_message($SettingsStored);
+ } else {
+ echo '';
+ $form->display();
+ echo '
';
+ }
+}
+
?>
diff --git a/main/inc/lib/search/search_widget.css b/main/inc/lib/search/search_widget.css
index fb4d5ff1f5..c8432212fd 100644
--- a/main/inc/lib/search/search_widget.css
+++ b/main/inc/lib/search/search_widget.css
@@ -13,7 +13,7 @@
font-size: 130%;
}
#submit {
- background-image: url(\'../img/search-lense.gif\');
+ background-image: url('/main/img/search-lense.gif');
background-repeat: no-repeat;
background-position: 0px -1px;
padding-left:18px;
diff --git a/main/inc/lib/search/search_widget.php b/main/inc/lib/search/search_widget.php
index 43a5a154c5..0f8feec2db 100644
--- a/main/inc/lib/search/search_widget.php
+++ b/main/inc/lib/search/search_widget.php
@@ -251,7 +251,7 @@ function display_search_form($action, $show_thesaurus, $sf_terms, $op) {
$type = (!empty($_REQUEST['type'])? htmlentities($_REQUEST['type']): 'normal');
switch ($type) {
case 'prefilter':
- $prefilter_prefix = 'E'; //TODO: should be api_get_setting('search_prefilter_prefix')
+ $prefilter_prefix = api_get_setting('search_prefilter_prefix');
$form = search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op, $prefilter_prefix);
break;
case 'normal':
diff --git a/main/inc/lib/specific_fields_manager.lib.php b/main/inc/lib/specific_fields_manager.lib.php
index 43336dbfcf..bafb264c7e 100644
--- a/main/inc/lib/specific_fields_manager.lib.php
+++ b/main/inc/lib/specific_fields_manager.lib.php
@@ -201,7 +201,9 @@ function delete_all_values_for_item($course_id, $tool_id, $ref_id) {
* @return string One-letter code, upper-case
*/
function get_specific_field_code_from_name($name) {
- $list = array('A','B','D','E','F','G','H','I','J','K','L','M','N','P','Q','R','S','U','V','W','X','Y'); //Z is used internally by Xapian and we already use C,T & O for tool_id, course_id and normal tags
+ // Z is used internally by Xapian
+ // O & C already used by tool_id and course_id
+ $list = array('A','B','D','E','F','G','H','I','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y');
$table_sf = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$sql = "SELECT code FROM $table_sf ORDER BY code";
$res = api_sql_query($sql,__FILE__,__LINE__);
diff --git a/main/install/dokeos_main_corp.sql b/main/install/dokeos_main_corp.sql
index e717050a44..0420146038 100644
--- a/main/install/dokeos_main_corp.sql
+++ b/main/install/dokeos_main_corp.sql
@@ -2,7 +2,8 @@ INSERT INTO settings_current
(variable, subkey, type, category, selected_value, title, comment, scope, subkeytext)
VALUES
('search_enabled',NULL,'radio','Tools','false','EnableSearchTitle','EnableSearchComment',NULL,NULL),
-('search_show_unlinked_results',NULL,'radio','Tools','true','SearchShowUnlinkedResultsTitle','SearchShowUnlinkedResultsComment',NULL,NULL);
+('search_prefilter_prefix',NULL, NULL,'Search','','SearchPrefilterPrefix','SearchPrefilterPrefixComment',NULL,NULL),
+('search_show_unlinked_results',NULL,'radio','Search','true','SearchShowUnlinkedResultsTitle','SearchShowUnlinkedResultsComment',NULL,NULL);
INSERT INTO settings_options
(variable, value, display_text)