/** * Get completion list */ static function getList($a_str) { global $ilDB; include_once './Services/Search/classes/class.ilSearchSettings.php'; if (ilSearchSettings::getInstance()->enabledLucene()) { return self::getLuceneList($a_str); } $a_str = str_replace('"', "", $a_str); $settings = new ilSearchSettings(); $object_types = array('cat', 'dbk', 'crs', 'fold', 'frm', 'grp', 'lm', 'sahs', 'glo', 'mep', 'htlm', 'exc', 'file', 'qpl', 'tst', 'svy', 'spl', 'chat', 'icrs', 'icla', 'webr', 'mcst', 'sess', 'pg', 'st', 'gdf', 'wiki'); $set = $ilDB->query("SELECT title, obj_id FROM object_data WHERE " . $ilDB->like('title', 'text', $a_str . "%") . " AND " . $ilDB->in('type', $object_types, false, 'text') . " ORDER BY title"); $max = $settings->getAutoCompleteLength() > 0 ? $settings->getAutoCompleteLength() : 10; $cnt = 0; $list = array(); $checked = array(); $lim = ""; while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) { if (strpos($rec["title"], " ") > 0 || strpos($rec["title"], "-") > 0) { $rec["title"] = '"' . $rec["title"] . '"'; } if (!in_array($rec["title"], $list) && !in_array($rec["obj_id"], $checked)) { if (ilSearchAutoComplete::checkObjectPermission($rec["obj_id"])) { $list[] = $lim . $rec["title"]; $cnt++; } $checked[] = $rec["obj_id"]; } } $set = $ilDB->query("SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE " . $ilDB->like('keyword', 'text', $a_str . "%") . " AND " . $ilDB->in('obj_type', $object_types, false, 'text') . " ORDER BY keyword"); while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max) { if (strpos($rec["keyword"], " ") > 0) { $rec["keyword"] = '"' . $rec["keyword"] . '"'; } if (!in_array($rec["keyword"], $list) && !in_array($rec["rbac_id"], $checked)) { if (ilSearchAutoComplete::checkObjectPermission($rec["rbac_id"])) { $list[] = $lim . $rec["keyword"]; $cnt++; } } $checked[] = $rec["rbac_id"]; } $i = 0; $result = array(); foreach ($list as $l) { $result[$i] = new stdClass(); $result[$i]->value = $l; $i++; } include_once './Services/JSON/classes/class.ilJsonUtil.php'; return ilJsonUtil::encode($result); }
/** * Init settings form * @return void */ protected function initFormSettings() { global $lng, $ilDB; include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; include_once './Services/Search/classes/class.ilSearchSettings.php'; $settings = new ilSearchSettings(); $this->form = new ilPropertyFormGUI(); $this->form->setFormAction($this->ctrl->getFormAction($this, 'updateSettings')); $this->form->addCommandButton('updateSettings', $this->lng->txt('save')); $this->form->setTitle($this->lng->txt('seas_settings')); // Max hits $hits = new ilSelectInputGUI($this->lng->txt('seas_max_hits'), 'max_hits'); $hits->setValue($settings->getMaxHits()); $hits->setRequired(true); for ($value = 5; $value <= 15; $value += 5) { $values[$value] = $value; } $hits->setOptions($values); $hits->setInfo($this->lng->txt('seas_max_hits_info')); $this->form->addItem($hits); // Search type $type = new ilRadioGroupInputGUI($this->lng->txt('search_type'), 'search_type'); if ($settings->enabledLucene()) { $type->setValue(ilSearchSettings::LUCENE_SEARCH); } elseif ($settings->enabledIndex()) { $type->setValue(ilSearchSettings::INDEX_SEARCH); } else { $type->setValue(ilSearchSettings::LIKE_SEARCH); } $type->setRequired(true); $this->form->addItem($type); // Default operator $operator = new ilRadioGroupInputGUI($this->lng->txt('lucene_default_operator'), 'operator'); $operator->setRequired(true); $operator->setInfo($this->lng->txt('lucene_default_operator_info')); $operator->setValue($settings->getDefaultOperator()); $and = new ilRadioOption($this->lng->txt('lucene_and'), ilSearchSettings::OPERATOR_AND); $operator->addOption($and); $or = new ilRadioOption($this->lng->txt('lucene_or'), ilSearchSettings::OPERATOR_OR); $operator->addOption($or); $this->form->addItem($operator); // Item filter $if = new ilCheckboxInputGUI($this->lng->txt('search_item_filter_form'), 'if'); $if->setValue(1); $if->setChecked($settings->isLuceneItemFilterEnabled()); $if->setInfo($this->lng->txt('search_item_filter_form_info')); $this->form->addItem($if); $filter = $settings->getLuceneItemFilter(); foreach (ilSearchSettings::getLuceneItemFilterDefinitions() as $obj => $def) { $ch = new ilCheckboxInputGUI($this->lng->txt($def['trans']), 'filter[' . $obj . ']'); if (isset($filter[$obj]) and $filter[$obj]) { $ch->setChecked(true); } $ch->setValue(1); $if->addSubItem($ch); } // hide advanced search $cb = new ilCheckboxInputGUI($lng->txt("search_hide_adv_search"), "hide_adv_search"); $cb->setChecked($settings->getHideAdvancedSearch()); $this->form->addItem($cb); // number of auto complete entries $options = array(5 => 5, 10 => 10, 20 => 20, 30 => 30); $si = new ilSelectInputGUI($lng->txt("search_auto_complete_length"), "auto_complete_length"); $si->setOptions($options); $val = $settings->getAutoCompleteLength() > 0 ? $settings->getAutoCompleteLength() : 10; $si->setValue($val); $this->form->addItem($si); $direct = new ilRadioOption($this->lng->txt('search_direct'), ilSearchSettings::LIKE_SEARCH, $this->lng->txt('search_like_info')); $type->addOption($direct); if ($ilDB->getDBType() == 'mysql') { $index = new ilRadioOption($this->lng->txt('search_index'), ilSearchSettings::INDEX_SEARCH, $this->lng->txt('search_full_info')); $type->addOption($index); } $lucene = new ilRadioOption($this->lng->txt('search_lucene'), ilSearchSettings::LUCENE_SEARCH, $this->lng->txt('java_server_info')); $type->addOption($lucene); }