From 507a5e6947f5c85c59746c639f90fb9d48fd6d62 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Tue, 15 Apr 2025 15:46:31 +0200 Subject: [PATCH] Search: abandon advanced search --- .../Record/class.ilAdvancedMDRecordGUI.php | 2 +- components/ILIAS/Search/ROADMAP.md | 11 + .../class.ilLuceneAdvancedQueryParser.php | 81 -- ...LuceneAdvancedSearchActivationTableGUI.php | 80 -- .../class.ilLuceneAdvancedSearchFields.php | 808 -------------- .../class.ilLuceneAdvancedSearchGUI.php | 387 ------- .../class.ilLuceneAdvancedSearchSettings.php | 76 -- .../Lucene/class.ilLuceneSearchGUI.php | 40 +- .../Lucene/class.ilLuceneUserSearchGUI.php | 19 +- .../class.ilObjSearchSettingsFormGUI.php | 8 +- .../ObjGUI/class.ilObjSearchSettingsGUI.php | 48 +- .../classes/class.ilAdvancedSearchGUI.php | 991 ------------------ .../classes/class.ilSearchControllerGUI.php | 24 +- .../Search/classes/class.ilSearchGUI.php | 89 +- .../Search/classes/class.ilSearchResult.php | 91 +- .../Search/classes/class.ilSearchSettings.php | 39 +- .../classes/class.ilUserSearchCache.php | 85 +- .../default/tpl.lucene_activation_row.html | 16 - .../default/tpl.lucene_adv_search.html | 3 - .../templates/default/tpl.range_search.html | 1 - lang/ilias_de.lang | 12 - lang/ilias_en.lang | 12 - 22 files changed, 97 insertions(+), 2826 deletions(-) delete mode 100755 components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php delete mode 100755 components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchActivationTableGUI.php delete mode 100755 components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php delete mode 100755 components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php delete mode 100755 components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchSettings.php delete mode 100755 components/ILIAS/Search/classes/class.ilAdvancedSearchGUI.php delete mode 100755 components/ILIAS/Search/templates/default/tpl.lucene_activation_row.html delete mode 100755 components/ILIAS/Search/templates/default/tpl.lucene_adv_search.html delete mode 100755 components/ILIAS/Search/templates/default/tpl.range_search.html diff --git a/components/ILIAS/AdvancedMetaData/classes/Record/class.ilAdvancedMDRecordGUI.php b/components/ILIAS/AdvancedMetaData/classes/Record/class.ilAdvancedMDRecordGUI.php index 7339db61158b..e9fdf9a2ed08 100755 --- a/components/ILIAS/AdvancedMetaData/classes/Record/class.ilAdvancedMDRecordGUI.php +++ b/components/ILIAS/AdvancedMetaData/classes/Record/class.ilAdvancedMDRecordGUI.php @@ -341,7 +341,7 @@ public function writeEditForm(?int $a_obj_id = null, ?int $a_sub_id = null): boo */ private function parseSearch(): void { - // this is NOT used for the global search, see ilLuceneAdvancedSearchFields::getFormElement() + // this is NOT used for the global search // (so searchable flag is NOT relevant) // // current usage: wiki page element "[amd] page list" diff --git a/components/ILIAS/Search/ROADMAP.md b/components/ILIAS/Search/ROADMAP.md index 655b56fe7c65..8605e30710b2 100755 --- a/components/ILIAS/Search/ROADMAP.md +++ b/components/ILIAS/Search/ROADMAP.md @@ -10,8 +10,19 @@ blocks without a functional ListGUI [2]. ## Short Term +### Clean up Abandon Advanced Search + +The following settings can be deleted: + +- module: `common`, keyword: `hide_adv_search` +- everything in module `lucene_adv_search` + +The following rows from database tables can be deleted: + +- in `usr_search` where `search_type` is 1, 4, or 6 ## Mid Term + - Add subtypes to lucene index and extend the search result xml accordingly. ## Long Term diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php deleted file mode 100755 index 5af3d17ccfa8..000000000000 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedQueryParser.php +++ /dev/null @@ -1,81 +0,0 @@ - -* -* -* @ingroup ServicesSearch -*/ -class ilLuceneAdvancedQueryParser extends ilLuceneQueryParser -{ - protected ilLuceneAdvancedSearchFields $field_definition; - /** - * @var array|string - */ - protected $query_data; - - /** - * Constructor - */ - public function __construct($a_query_data) - { - parent::__construct(''); - - $this->field_definition = ilLuceneAdvancedSearchFields::getInstance(); - $this->query_data = $a_query_data; - } - - /** - * Get field definition settings - */ - public function getFieldDefinition(): ilLuceneAdvancedSearchFields - { - return $this->field_definition; - } - - /** - * @return array|string - */ - public function getQueryData() - { - if (is_array($this->query_data)) { - return $this->query_data; - } - return $this->query_data ?? ''; - } - - public function parse(): void - { - foreach ((array) $this->getQueryData() as $field => $query) { - if (!is_array($query) && !trim((string) $query)) { - continue; - } - $parsed = $this->getFieldDefinition()->parseFieldQuery((string) $field, $query); - if (strlen($parsed)) { - $this->parsed_query .= " +("; - $this->parsed_query .= $parsed; - $this->parsed_query .= ") "; - } - } - } -} diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchActivationTableGUI.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchActivationTableGUI.php deleted file mode 100755 index 9bbd5bf60430..000000000000 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchActivationTableGUI.php +++ /dev/null @@ -1,80 +0,0 @@ - -* -* -* @ingroup -*/ -class ilLuceneAdvancedSearchActivationTableGUI extends ilTable2GUI -{ - protected ilAccess $access; - - public function __construct($a_parent_obj, $a_parent_cmd = '') - { - global $DIC; - - $this->access = $DIC->access(); - - parent::__construct($a_parent_obj, $a_parent_cmd); - $this->addColumn('', 'id', '0px'); - $this->addColumn($this->lng->txt('title'), 'title', '60%'); - $this->addColumn($this->lng->txt('type'), 'type', '40%'); - $this->setRowTemplate('tpl.lucene_activation_row.html', 'components/ILIAS/Search'); - $this->disable('sort'); - $this->setLimit(100); - $this->setSelectAllCheckbox('fid'); - $this->setFormAction($this->ctrl->getFormAction($a_parent_obj)); - - if ($this->access->checkAccess('write', '', $this->getParentObject()->getObject()->getRefId())) { - $this->addMultiCommand('saveAdvancedLuceneSettings', $this->lng->txt('lucene_activate_field')); - } - } - - /** - * Fill template row - */ - protected function fillRow(array $a_set): void - { - $this->tpl->setVariable('VAL_ID', $a_set['id']); - $this->tpl->setVariable('VAL_CHECKED', $a_set['active'] ? 'checked="checked"' : ''); - $this->tpl->setVariable('VAL_TITLE', $a_set['title']); - $this->tpl->setVariable('VAL_TYPE', $a_set['type']); - } - - public function parse(ilLuceneAdvancedSearchSettings $settings): void - { - $content = []; - foreach (ilLuceneAdvancedSearchFields::getFields() as $field => $translation) { - $tmp_arr['id'] = $field; - $tmp_arr['active'] = $settings->isActive($field); - $tmp_arr['title'] = $translation; - - $tmp_arr['type'] = (substr($field, 0, 3) == 'lom') ? - $this->lng->txt('search_lom') : - $this->lng->txt('search_adv_md'); - - $content[] = $tmp_arr; - } - $this->setData($content); - } -} diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php deleted file mode 100755 index aaff05464320..000000000000 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchFields.php +++ /dev/null @@ -1,808 +0,0 @@ - -* -* -* @ingroup ServicesSearch -*/ -class ilLuceneAdvancedSearchFields -{ - public const ONLINE_QUERY = 1; - public const OFFLINE_QUERY = 2; - - private static ?ilLuceneAdvancedSearchFields $instance = null; - private ilLuceneAdvancedSearchSettings $settings; - - protected ilLanguage $lng; - protected ilObjUser $user; - - private static array $fields = []; - private array $active_fields = []; - - private static array $sections = []; - private array $active_sections = []; - - - protected function __construct() - { - global $DIC; - - $this->lng = $DIC->language(); - $this->lng->loadLanguageModule('meta'); - $this->user = $DIC->user(); - - $this->settings = ilLuceneAdvancedSearchSettings::getInstance(); - - $this->readFields(); - $this->readSections(); - } - - public static function getInstance(): ilLuceneAdvancedSearchFields - { - if (self::$instance instanceof ilLuceneAdvancedSearchFields) { - return self::$instance; - } - return self::$instance = new ilLuceneAdvancedSearchFields(); - } - - /** - * Return an array of all meta data fields - * @return array - */ - public static function getFields(): array - { - global $DIC; - - $lng = $DIC->language(); - - $lng->loadLanguageModule('meta'); - - $fields['lom_content'] = $lng->txt('content'); - - if (ilSearchSettings::getInstance()->enabledLucene()) { - $fields['general_offline'] = $lng->txt('lucene_offline_filter'); - } - //'lom_type' = $lng->txt('type'); - $fields['lom_language'] = $lng->txt('language'); - $fields['lom_keyword'] = $lng->txt('meta_keyword'); - $fields['lom_coverage'] = $lng->txt('meta_coverage'); - $fields['lom_structure'] = $lng->txt('meta_structure'); - $fields['lom_status'] = $lng->txt('meta_status'); - $fields['lom_version'] = $lng->txt('meta_version'); - $fields['lom_contribute'] = $lng->txt('meta_contribute'); - $fields['lom_format'] = $lng->txt('meta_format'); - $fields['lom_operating_system'] = $lng->txt('meta_operating_system'); - $fields['lom_browser'] = $lng->txt('meta_browser'); - $fields['lom_interactivity'] = $lng->txt('meta_interactivity_type'); - $fields['lom_resource'] = $lng->txt('meta_learning_resource_type'); - $fields['lom_level'] = $lng->txt('meta_interactivity_level'); - $fields['lom_density'] = $lng->txt('meta_semantic_density'); - $fields['lom_user_role'] = $lng->txt('meta_intended_end_user_role'); - $fields['lom_context'] = $lng->txt('meta_context'); - $fields['lom_difficulty'] = $lng->txt('meta_difficulty'); - $fields['lom_costs'] = $lng->txt('meta_cost'); - $fields['lom_copyright'] = $lng->txt('meta_copyright_and_other_restrictions'); - $fields['lom_purpose'] = $lng->txt('meta_purpose'); - $fields['lom_taxon'] = $lng->txt('meta_taxon'); - - // Append all advanced meta data fields - foreach (ilAdvancedMDRecord::_getRecords() as $record) { - if ($record->getParentObject() > 0) { - if (!ilObject::_hasUntrashedReference($record->getParentObject())) { - continue; - } - } - - foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $def) { - $field_translations = ilAdvancedMDFieldTranslations::getInstanceByRecordId($record->getRecordId()); - $fields['adv_' . $def->getFieldId()] = $field_translations->getTitleForLanguage($def->getFieldId(), $lng->getLangKey()); - } - } - - return $fields; - } - - /** - * Get all active fields - * @return array - */ - public function getActiveFields(): array - { - return $this->active_fields; - } - - public function getActiveSections(): array - { - return $this->active_sections; - } - - /** - * @param string | array $a_query - */ - public function getFormElement($a_query, string $a_field_name, ilPropertyFormGUI $a_form): ?ilFormPropertyGUI - { - $a_post_name = 'query[' . $a_field_name . ']'; - - if (!is_array($a_query)) { - $a_query = array(); - } - - switch ($a_field_name) { - case 'general_offline': - $offline_options = array( - '0' => $this->lng->txt('search_any'), - self::ONLINE_QUERY => $this->lng->txt('search_option_online'), - self::OFFLINE_QUERY => $this->lng->txt('search_option_offline') - ); - $offline = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $offline->setOptions($offline_options); - $offline->setValue($a_query['general_offline'] ?? ''); - return $offline; - - case 'lom_content': - $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name); - $text->setSubmitFormOnEnter(true); - $text->setValue($a_query['lom_content'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - return $text; - - // General - case 'lom_language': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_language'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getLanguageSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_keyword': - $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name); - $text->setSubmitFormOnEnter(true); - $text->setValue($a_query['lom_keyword'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - return $text; - - case 'lom_coverage': - $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name); - $text->setSubmitFormOnEnter(true); - $text->setValue($a_query['lom_coverage'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - return $text; - - case 'lom_structure': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_structure'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getStructureSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - // Lifecycle - case 'lom_status': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_status'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getStatusSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_version': - $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name); - $text->setSubmitFormOnEnter(true); - $text->setValue($a_query['lom_version'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - return $text; - - case 'lom_contribute': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], 'query[' . 'lom_role' . ']'); - $select->setValue($a_query['lom_role'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getRoleSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - - $text = new ilTextInputGUI($this->lng->txt('meta_entry'), 'query[' . 'lom_role_entry' . ']'); - $text->setValue($a_query['lom_role_entry'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - - $select->addSubItem($text); - return $select; - - // Technical - case 'lom_format': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_format'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getFormatSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_operating_system': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_operating_system'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getOperatingSystemSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_browser': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_browser'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getBrowserSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - // Education - case 'lom_interactivity': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_interactivity'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getInteractivityTypeSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_resource': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_resource'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getLearningResourceTypeSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_level': - $range = new ilCustomInputGUI($this->active_fields[$a_field_name]); - $html = $this->getRangeSelect( - $this->lng->txt('from'), - (string) ilMDUtilSelect::_getInteractivityLevelSelect( - $a_query['lom_level_start'] ?? '', - 'query[' . 'lom_level_start' . ']', - array(0 => $this->lng->txt('search_any')) - ), - $this->lng->txt('until'), - (string) ilMDUtilSelect::_getInteractivityLevelSelect( - $a_query['lom_level_end'] ?? '', - 'query[' . 'lom_level_end' . ']', - array(0 => $this->lng->txt('search_any')) - ) - ); - $range->setHtml($html); - return $range; - - case 'lom_density': - $range = new ilCustomInputGUI($this->active_fields[$a_field_name]); - $html = $this->getRangeSelect( - $this->lng->txt('from'), - (string) ilMDUtilSelect::_getSemanticDensitySelect( - $a_query['lom_density_start'] ?? '', - 'query[' . 'lom_density_start' . ']', - array(0 => $this->lng->txt('search_any')) - ), - $this->lng->txt('until'), - (string) ilMDUtilSelect::_getSemanticDensitySelect( - $a_query['lom_density_end'] ?? '', - 'query[' . 'lom_density_end' . ']', - array(0 => $this->lng->txt('search_any')) - ) - ); - $range->setHtml($html); - return $range; - - - case 'lom_user_role': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_user_role'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getIntendedEndUserRoleSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_context': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_context'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getContextSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_difficulty': - $range = new ilCustomInputGUI($this->active_fields[$a_field_name]); - $html = $this->getRangeSelect( - $this->lng->txt('from'), - (string) ilMDUtilSelect::_getDifficultySelect( - $a_query['lom_difficulty_start'] ?? '', - 'query[' . 'lom_difficulty_start' . ']', - array(0 => $this->lng->txt('search_any')) - ), - $this->lng->txt('until'), - (string) ilMDUtilSelect::_getDifficultySelect( - $a_query['lom_difficulty_end'] ?? '', - 'query[' . 'lom_difficulty_end' . ']', - array(0 => $this->lng->txt('search_any')) - ) - ); - $range->setHtml($html); - return $range; - - // Rights - case 'lom_costs': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_costs'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getCostsSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_copyright': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_copyright'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - - - // Classification - case 'lom_purpose': - $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name); - $select->setValue($a_query['lom_purpose'] ?? ''); - $select->setOptions((array) ilMDUtilSelect::_getPurposeSelect( - '', - $a_field_name, - array(0 => $this->lng->txt('search_any')), - true - )); - return $select; - - case 'lom_taxon': - $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name); - $text->setSubmitFormOnEnter(true); - $text->setValue($a_query['lom_taxon'] ?? ''); - $text->setSize(30); - $text->setMaxLength(255); - return $text; - - default: - if (substr($a_field_name, 0, 3) != 'adv') { - break; - } - - // Advanced meta data - $field_id = substr($a_field_name, 4); - $field = ilAdvancedMDFieldDefinition::getInstance((int) $field_id); - - $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false); - $field_form->setForm($a_form); - $field_form->setElementId($a_post_name); - $field_form->setTitle($this->active_fields[$a_field_name]); - $field_form->addToForm(); - - // #17071 - reload search values - if (is_array($a_query) && - array_key_exists($a_field_name, $a_query)) { - $field_form->importFromPost((array) $a_query); - $field_form->validate(); - } - return null; - } - return null; - } - - - /** - * Called from ilLuceneAdvancedQueryParser - * Parse a field specific query - * @param string $a_field - * @param string | array $a_query - */ - public function parseFieldQuery(string $a_field, $a_query): string - { - switch ($a_field) { - case 'lom_content': - return $a_query; - - case 'general_offline': - - switch ($a_query) { - case self::OFFLINE_QUERY: - return 'offline:1'; - - default: - return '-offline:1'; - } - - // General - // no break - case 'lom_language': - return 'lomLanguage:' . $a_query; - - case 'lom_keyword': - return 'lomKeyword:' . $a_query; - - case 'lom_coverage': - return 'lomCoverage:' . $a_query; - - case 'lom_structure': - return 'lomStructure:' . $a_query; - - // Lifecycle - case 'lom_status': - return 'lomStatus:' . $a_query; - - case 'lom_version': - return 'lomVersion:' . $a_query; - - // Begin Contribute - case 'lom_role': - return 'lomRole:' . $a_query; - - case 'lom_role_entry': - return 'lomRoleEntity:' . $a_query; - // End contribute - - // Technical - case 'lom_format': - return 'lomFormat:' . $a_query; - - case 'lom_operating_system': - return 'lomOS:' . $a_query; - - case 'lom_browser': - return 'lomBrowser:' . $a_query; - - // Educational - case 'lom_interactivity': - return 'lomInteractivity:' . $a_query; - - case 'lom_resource': - return 'lomResource:' . $a_query; - - case 'lom_level_start': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getInteractivityLevelSelect(0, 'lom_level', array(), true); - for ($i = $a_query; $i <= count($options); $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomLevel:"' . $options[$i] . '" '); - } - return $q_string; - - case 'lom_level_end': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getInteractivityLevelSelect(0, 'lom_level', array(), true); - for ($i = 1; $i <= $a_query; $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomLevel:"' . $options[$i] . '" '); - } - return $q_string; - - case 'lom_density_start': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getSemanticDensitySelect(0, 'lom_density', array(), true); - for ($i = $a_query; $i <= count($options); $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomDensity:"' . $options[$i] . '" '); - } - return $q_string; - - case 'lom_density_end': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getSemanticDensitySelect(0, 'lom_density', array(), true); - for ($i = 1; $i <= $a_query; $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomDensity:"' . $options[$i] . '" '); - } - return $q_string; - - case 'lom_user_role': - return 'lomUserRole:' . $a_query; - - case 'lom_context': - return 'lomContext:' . $a_query; - - case 'lom_difficulty_start': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getDifficultySelect(0, 'lom_difficulty', array(), true); - for ($i = $a_query; $i <= count($options); $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomDifficulty:"' . $options[$i] . '" '); - } - return $q_string; - - case 'lom_difficulty_end': - $q_string = ''; - $options = (array) ilMDUtilSelect::_getDifficultySelect(0, 'lom_difficulty', array(), true); - for ($i = 1; $i <= $a_query; $i++) { - if (strlen($q_string)) { - $q_string .= 'OR '; - } - $q_string .= ('lomDifficulty:"' . $options[$i] . '" '); - } - return $q_string; - - // Rights - case 'lom_costs': - return 'lomCosts:' . $a_query; - - case 'lom_copyright': - return 'lomCopyright:' . $a_query; - - // Classification - case 'lom_purpose': - return 'lomPurpose:' . $a_query; - - case 'lom_taxon': - return 'lomTaxon:' . $a_query; - - default: - if (substr($a_field, 0, 3) != 'adv') { - break; - } - - // Advanced meta data - $field_id = substr($a_field, 4); - try { - // field might be invalid (cached query) - $field = ilAdvancedMDFieldDefinition::getInstance((int) $field_id); - } catch (Exception $ex) { - return ''; - } - - $adv_query = $field->getLuceneSearchString($a_query); - if ($adv_query) { - // #17558 - if (!is_array($adv_query)) { - return 'advancedMetaData_' . $field_id . ': ' . $adv_query; - } else { - $res = array(); - foreach ($adv_query as $adv_query_item) { - $res[] = 'advancedMetaData_' . $field_id . ': ' . $adv_query_item; - } - return '(' . implode(' OR ', $res) . ')'; - } - } - } - return ''; - } - - - /** - * Read active fields - */ - protected function readFields(): void - { - foreach (self::getFields() as $name => $translation) { - if ($this->settings->isActive($name)) { - $this->active_fields[$name] = $translation; - } - } - } - - /** - * Read active sections - */ - protected function readSections(): void - { - foreach ($this->getActiveFields() as $field_name => $translation) { - switch ($field_name) { - // Default section - case 'lom_content': - $this->active_sections['default']['fields'][] = 'lom_content'; - $this->active_sections['default']['name'] = ''; - break; - - case 'general_offline': - $this->active_sections['default']['fields'][] = 'general_offline'; - $this->active_sections['default']['name'] = ''; - break; - - case 'lom_type': - $this->active_sections['default']['fields'][] = 'lom_type'; - $this->active_sections['default']['name'] = ''; - break; - - // General - case 'lom_language': - $this->active_sections['general']['fields'][] = 'lom_language'; - $this->active_sections['general']['name'] = $this->lng->txt('meta_general'); - break; - case 'lom_keyword': - $this->active_sections['general']['fields'][] = 'lom_keyword'; - $this->active_sections['general']['name'] = $this->lng->txt('meta_general'); - break; - case 'lom_coverage': - $this->active_sections['general']['fields'][] = 'lom_coverage'; - $this->active_sections['general']['name'] = $this->lng->txt('meta_general'); - break; - case 'lom_structure': - $this->active_sections['general']['fields'][] = 'lom_structure'; - $this->active_sections['general']['name'] = $this->lng->txt('meta_general'); - break; - - // Lifecycle - case 'lom_status': - $this->active_sections['lifecycle']['fields'][] = 'lom_status'; - $this->active_sections['lifecycle']['name'] = $this->lng->txt('meta_lifecycle'); - break; - case 'lom_version': - $this->active_sections['lifecycle']['fields'][] = 'lom_version'; - $this->active_sections['lifecycle']['name'] = $this->lng->txt('meta_lifecycle'); - break; - case 'lom_contribute': - $this->active_sections['lifecycle']['fields'][] = 'lom_contribute'; - $this->active_sections['lifecycle']['name'] = $this->lng->txt('meta_lifecycle'); - break; - - // Technical - case 'lom_format': - $this->active_sections['technical']['fields'][] = 'lom_format'; - $this->active_sections['technical']['name'] = $this->lng->txt('meta_technical'); - break; - case 'lom_operating_system': - $this->active_sections['technical']['fields'][] = 'lom_operating_system'; - $this->active_sections['technical']['name'] = $this->lng->txt('meta_technical'); - break; - case 'lom_browser': - $this->active_sections['technical']['fields'][] = 'lom_browser'; - $this->active_sections['technical']['name'] = $this->lng->txt('meta_technical'); - break; - - // Education - case 'lom_interactivity': - $this->active_sections['education']['fields'][] = 'lom_interactivity'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_resource': - $this->active_sections['education']['fields'][] = 'lom_resource'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_level': - $this->active_sections['education']['fields'][] = 'lom_level'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_density': - $this->active_sections['education']['fields'][] = 'lom_density'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_user_role': - $this->active_sections['education']['fields'][] = 'lom_user_role'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_context': - $this->active_sections['education']['fields'][] = 'lom_context'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - case 'lom_difficulty': - $this->active_sections['education']['fields'][] = 'lom_difficulty'; - $this->active_sections['education']['name'] = $this->lng->txt('meta_education'); - break; - - // Rights - case 'lom_costs': - $this->active_sections['rights']['fields'][] = 'lom_costs'; - $this->active_sections['rights']['name'] = $this->lng->txt('meta_rights'); - break; - case 'lom_copyright': - $this->active_sections['rights']['fields'][] = 'lom_copyright'; - $this->active_sections['rights']['name'] = $this->lng->txt('meta_rights'); - break; - - // Classification - case 'lom_purpose': - $this->active_sections['classification']['fields'][] = 'lom_purpose'; - $this->active_sections['classification']['name'] = $this->lng->txt('meta_classification'); - break; - case 'lom_taxon': - $this->active_sections['classification']['fields'][] = 'lom_taxon'; - $this->active_sections['classification']['name'] = $this->lng->txt('meta_classification'); - break; - - default: - if (substr($field_name, 0, 3) != 'adv') { - break; - } - - // Advanced meta data - $field_id = substr($field_name, 4); - $field = ilAdvancedMDFieldDefinition::getInstance((int) $field_id); - $record_id = $field->getRecordId(); - - $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($record_id); - $this->active_sections['adv_record_' . $record_id]['fields'][] = $field_name; - $this->active_sections['adv_record_' . $record_id]['name'] = $translations->getTitleForLanguage($this->user->getLanguage()); - break; - } - } - } - - /** - * get a range selection - */ - protected function getRangeSelect( - string $txt_from, - string $select_from, - string $txt_until, - string $select_until - ): string { - $tpl = new ilTemplate('tpl.range_search.html', true, true, 'components/ILIAS/Search'); - $tpl->setVariable('TXT_FROM', $txt_from); - $tpl->setVariable('FROM', $select_from); - $tpl->setVariable('TXT_UPTO', $txt_until); - $tpl->setVariable('UPTO', $select_until); - return $tpl->get(); - } -} diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php deleted file mode 100755 index a7631990fcbf..000000000000 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchGUI.php +++ /dev/null @@ -1,387 +0,0 @@ - -* -* @ilCtrl_IsCalledBy ilLuceneAdvancedSearchGUI: ilSearchControllerGUI -* @ilCtrl_Calls ilLuceneAdvancedSearchGUI: ilObjectGUI, ilContainerGUI -* @ilCtrl_Calls ilLuceneAdvancedSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI -* @ilCtrl_Calls ilLuceneAdvancedSearchGUI: ilObjStudyProgrammeGUI -* @ilCtrl_Calls ilLuceneAdvancedSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI -* -* @ingroup ServicesSearch -*/ -class ilLuceneAdvancedSearchGUI extends ilSearchBaseGUI -{ - protected ilTabsGUI $tabs_gui; - protected ilHelpGUI $help; - - protected ilLuceneAdvancedSearchFields $fields; - - protected ?array $admin_panel_commands; - protected ?array $admin_view_button; - protected ?array $creation_selector; - protected ?string $page_form_action; - - - /** - * Constructor - */ - public function __construct() - { - global $DIC; - - $this->tabs_gui = $DIC->tabs(); - $this->help = $DIC['ilHelp']; - parent::__construct(); - - $this->fields = ilLuceneAdvancedSearchFields::getInstance(); - $this->initUserSearchCache(); - } - - /** - * Execute Command - */ - public function executeCommand(): void - { - $next_class = $this->ctrl->getNextClass($this); - $cmd = $this->ctrl->getCmd(); - - $this->prepareOutput(); - switch ($next_class) { - case 'ilobjectcopygui': - $this->ctrl->setReturn($this); - $cp = new ilObjectCopyGUI($this); - $this->ctrl->forwardCommand($cp); - break; - - - default: - if (!$cmd) { - $cmd = "showSavedResults"; - } - $this->handleCommand($cmd); - break; - } - } - - - /** - * Show saved results - */ - public function showSavedResults(): void - { - $qp = new ilLuceneAdvancedQueryParser($this->search_cache->getQuery()); - $qp->parse(); - $searcher = ilLuceneSearcher::getInstance($qp); - $searcher->search(); - - // Load saved results - $filter = ilLuceneSearchResultFilter::getInstance($this->user->getId()); - $filter->loadFromDb(); - - // Highlight - if ($filter->getResultObjIds()) { - $searcher->highlight($filter->getResultObjIds()); - } - - $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_adv_search.html', 'components/ILIAS/Search'); - $presentation = new ilSearchResultPresentation($this); - $presentation->setResults($filter->getResultIds()); - $presentation->setSearcher($searcher); - - - // TODO: other handling required - $this->addPager($filter, 'max_page'); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML()); - } elseif (strlen(trim($qp->getQuery()))) { - $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match')); - } - - // and finally add search form - $this->initFormSearch(); - $this->tpl->setVariable('SEARCH_TABLE', $this->form->getHTML()); - - if ($filter->getResultIds()) { - $this->fillAdminPanel(); - } - } - - /** - * Show search form - */ - protected function initFormSearch(): void - { - $this->form = new ilPropertyFormGUI(); - $this->form->setFormAction($this->ctrl->getFormAction($this, 'search')); - $this->form->setTitle($this->lng->txt('search_advanced')); - $this->form->addCommandButton('search', $this->lng->txt('search')); - $this->form->addCommandButton('reset', $this->lng->txt('reset')); - - foreach ($this->fields->getActiveSections() as $definition) { - if ($definition['name'] != 'default') { - $section = new ilFormSectionHeaderGUI(); - $section->setTitle($definition['name']); - $this->form->addItem($section); - } - - foreach ($definition['fields'] as $field_name) { - if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) { - $this->form->addItem($element); - } - } - } - } - - /** - * Search from main menu - */ - protected function remoteSearch(): void - { - $root_id = 0; - if ($this->http->wrapper()->post()->has('root_id')) { - $root_id = $this->http->wrapper()->post()->retrieve( - 'root_id', - $this->refinery->kindlyTo()->int() - ); - } - $queryString = ''; - if ($this->http->wrapper()->post()->has('queryString')) { - $queryString = $this->http->wrapper()->post()->retrieve( - 'queryString', - $this->refinery->kindlyTo()->string() - ); - } - $this->search_cache->setRoot($root_id); - $this->search_cache->setQuery(['lom_content' => $queryString]); - $this->search_cache->save(); - $this->search(); - } - - protected function search(): void - { - if (!is_array($this->search_cache->getQuery())) { - // TOD: handle empty advances search - $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_no_search_string')); - $this->showSavedResults(); - return; - } - ilSession::clear('max_page'); - $this->search_cache->deleteCachedEntries(); - - // Reset details - ilSubItemListGUI::resetDetails(); - - $this->performSearch(); - } - - /** - * Reset search form - */ - protected function reset(): void - { - $this->search_cache->setQuery(array()); - $this->search_cache->save(); - $this->showSavedResults(); - } - - /** - * Perform search - */ - protected function performSearch(): void - { - ilSession::clear('vis_references'); - $qp = new ilLuceneAdvancedQueryParser($this->search_cache->getQuery()); - $qp->parse(); - if (!strlen(trim($qp->getQuery()))) { - $this->tpl->setOnScreenMessage('info', $this->lng->txt('msg_no_search_string')); - $this->showSavedResults(); - return; - } - - $searcher = ilLuceneSearcher::getInstance($qp); - $searcher->search(); - - // Filter results - $filter = ilLuceneSearchResultFilter::getInstance($this->user->getId()); - $filter->addFilter(new ilLucenePathFilter($this->search_cache->getRoot())); - $filter->setCandidates($searcher->getResult()); - $filter->filter(); - - if ($filter->getResultObjIds()) { - $searcher->highlight($filter->getResultObjIds()); - } - - // Show results - $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lucene_adv_search.html', 'components/ILIAS/Search'); - $presentation = new ilSearchResultPresentation($this); - $presentation->setResults($filter->getResultIds()); - $presentation->setSearcher($searcher); - - // TODO: other handling required - $this->addPager($filter, 'max_page'); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('SEARCH_RESULTS', $presentation->getHTML()); - } else { - $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match')); - } - - // and finally add search form - $this->initFormSearch(); - $this->tpl->setVariable('SEARCH_TABLE', $this->form->getHTML()); - - if ($filter->getResultIds()) { - $this->fillAdminPanel(); - } - } - - /** - * Add admin panel command - */ - public function prepareOutput(): void - { - parent::prepareOutput(); - $this->getTabs(); - } - - /** - * get tabs - */ - protected function getTabs(): void - { - $this->help->setScreenIdComponent("src_luc"); - - $this->tabs_gui->addTarget('search', $this->ctrl->getLinkTargetByClass('illucenesearchgui')); - - if (ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) { - $this->tabs_gui->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui')); - } - - if ( - !ilSearchSettings::getInstance()->getHideAdvancedSearch() and - $this->fields->getActiveFields()) { - $this->tabs_gui->addTarget('search_advanced', $this->ctrl->getLinkTarget($this)); - } - - $this->tabs_gui->setTabActive('search_advanced'); - } - - /** - * Init user search cache - * - * @access private - * - */ - protected function initUserSearchCache(): void - { - $this->search_cache = ilUserSearchCache::_getInstance($this->user->getId()); - $this->search_cache->switchSearchType(ilUserSearchCache::LUCENE_ADVANCED); - $page_number = $this->initPageNumberFromQuery(); - if ($page_number) { - $this->search_cache->setResultPageNumber($page_number); - } - if ($this->http->wrapper()->post()->has('query')) { - $this->search_cache->setQuery($this->http->request()->getParsedBody()['query'] ?? []); - } - } - - /** - * @todo Couldn't find any of these template variables anywhere. Is this still currently used? - */ - protected function fillAdminPanel(): void - { - $adm_view_cmp = $adm_cmds = $creation_selector = $adm_view = false; - - // admin panel commands - if (isset($this->admin_panel_commands) && (count((array) $this->admin_panel_commands) > 0)) { - foreach ($this->admin_panel_commands as $cmd) { - $this->tpl->setCurrentBlock("lucene_admin_panel_cmd"); - $this->tpl->setVariable("LUCENE_PANEL_CMD", $cmd["cmd"]); - $this->tpl->setVariable("LUCENE_TXT_PANEL_CMD", $cmd["txt"]); - $this->tpl->parseCurrentBlock(); - } - - $adm_cmds = true; - } - if ($adm_cmds) { - $this->tpl->setCurrentBlock("lucene_adm_view_components"); - $this->tpl->setVariable("LUCENE_ADM_IMG_ARROW", ilUtil::getImagePath("nav/arrow_upright.svg")); - $this->tpl->setVariable("LUCENE_ADM_ALT_ARROW", $this->lng->txt("actions")); - $this->tpl->parseCurrentBlock(); - $adm_view_cmp = true; - } - - // admin view button - if (isset($this->admin_view_button) && is_array($this->admin_view_button)) { - if (is_array($this->admin_view_button)) { - $this->tpl->setCurrentBlock("lucene_admin_button"); - $this->tpl->setVariable( - "LUCENE_ADMIN_MODE_LINK", - $this->admin_view_button["link"] - ); - $this->tpl->setVariable( - "LUCENE_TXT_ADMIN_MODE", - $this->admin_view_button["txt"] - ); - $this->tpl->parseCurrentBlock(); - } - $this->tpl->setCurrentBlock("lucene_admin_view"); - $this->tpl->parseCurrentBlock(); - $adm_view = true; - } - - // creation selector - if (isset($this->creation_selector) && is_array($this->creation_selector)) { - $this->tpl->setCurrentBlock("lucene_add_commands"); - if ($adm_cmds) { - $this->tpl->setVariable("LUCENE_ADD_COM_WIDTH", 'width="1"'); - } - $this->tpl->setVariable( - "LUCENE_SELECT_OBJTYPE_REPOS", - $this->creation_selector["options"] - ); - $this->tpl->setVariable( - "LUCENE_BTN_NAME_REPOS", - $this->creation_selector["command"] - ); - $this->tpl->setVariable( - "LUCENE_TXT_ADD_REPOS", - $this->creation_selector["txt"] - ); - $this->tpl->parseCurrentBlock(); - $creation_selector = true; - } - if ($adm_view || $creation_selector) { - $this->tpl->setCurrentBlock("lucene_adm_panel"); - if ($adm_view_cmp) { - $this->tpl->setVariable("LUCENE_ADM_TBL_WIDTH", 'width:"100%";'); - } - $this->tpl->parseCurrentBlock(); - } - } -} diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchSettings.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchSettings.php deleted file mode 100755 index 6ea230edcfd4..000000000000 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneAdvancedSearchSettings.php +++ /dev/null @@ -1,76 +0,0 @@ - -* @ingroup ServicesSearch -*/ -class ilLuceneAdvancedSearchSettings -{ - private static ?ilLuceneAdvancedSearchSettings $instance = null; - private array $fields = []; - - protected ilSetting $storage; - - /** - * Constructor - */ - private function __construct() - { - $this->storage = new ilSetting('lucene_adv_search'); - $this->read(); - } - - public static function getInstance(): ilLuceneAdvancedSearchSettings - { - if (self::$instance instanceof ilLuceneAdvancedSearchSettings) { - return self::$instance; - } - return self::$instance = new ilLuceneAdvancedSearchSettings(); - } - - /** - * check if field is active - */ - public function isActive(string $a_field): bool - { - return $this->fields[$a_field] ?: false; - } - - public function setActive(string $a_field, bool $a_status): void - { - $this->fields[$a_field] = $a_status; - } - - public function save(): void - { - foreach ($this->fields as $name => $status) { - $this->storage->set($name, $status ? "1" : "0"); - } - } - - private function read(): void - { - foreach (ilLuceneAdvancedSearchFields::getFields() as $name => $translation) { - $this->fields[$name] = (bool) $this->storage->get($name, 'true'); - } - } -} diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneSearchGUI.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneSearchGUI.php index ec0cd642a649..4247fbb1fede 100755 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneSearchGUI.php +++ b/components/ILIAS/Search/classes/Lucene/class.ilLuceneSearchGUI.php @@ -22,18 +22,14 @@ use ILIAS\UI\Renderer as UIRenderer; /** -* @classDescription GUI for simple Lucene search -* -* @author Stefan Meyer -* -* @ilCtrl_IsCalledBy ilLuceneSearchGUI: ilSearchControllerGUI -* @ilCtrl_Calls ilLuceneSearchGUI: ilObjectGUI, ilContainerGUI -* @ilCtrl_Calls ilLuceneSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI -* @ilCtrl_Calls ilLuceneSearchGUI: ilObjStudyProgrammeGUI -* @ilCtrl_Calls ilLuceneSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI -* -* @ingroup ServicesSearch -*/ + * @author Stefan Meyer + * + * @ilCtrl_IsCalledBy ilLuceneSearchGUI: ilSearchControllerGUI + * @ilCtrl_Calls ilLuceneSearchGUI: ilObjectGUI, ilContainerGUI + * @ilCtrl_Calls ilLuceneSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI + * @ilCtrl_Calls ilLuceneSearchGUI: ilObjStudyProgrammeGUI + * @ilCtrl_Calls ilLuceneSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI + */ class ilLuceneSearchGUI extends ilSearchBaseGUI { protected ilTabsGUI $tabs; @@ -41,8 +37,6 @@ class ilLuceneSearchGUI extends ilSearchBaseGUI protected UIFactory $ui_factory; protected UIRenderer $ui_renderer; - protected ilLuceneAdvancedSearchFields $fields; - protected ?int $root_node; protected array $admin_panel_commands = []; protected array $admin_view_button = []; @@ -64,7 +58,6 @@ public function __construct() $this->ui_factory = $DIC->ui()->factory(); $this->ui_renderer = $DIC->ui()->renderer(); - $this->fields = ilLuceneAdvancedSearchFields::getInstance(); $this->initFilter(self::SEARCH_FORM_LUCENE); $this->initUserSearchCache(); } @@ -207,7 +200,6 @@ protected function showSavedResults(): bool /** * Search (button pressed) - * @return void */ protected function search(): void { @@ -323,19 +315,9 @@ protected function getTabs(): void $this->tabs->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui')); } - if ($this->fields->getActiveFields() && !ilSearchSettings::getInstance()->getHideAdvancedSearch()) { - $this->tabs->addTarget('search_advanced', $this->ctrl->getLinkTargetByClass('illuceneAdvancedSearchgui')); - } - $this->tabs->setTabActive('search'); } - /** - * Init user search cache - * - * @access private - * - */ protected function initUserSearchCache(): void { $this->search_cache = ilUserSearchCache::_getInstance($this->user->getId()); @@ -520,17 +502,12 @@ protected function setPageFormAction(string $a_action): void $this->page_form_action = $a_action; } - /** - * Show search form - * @return void - */ protected function showSearchForm(): void { $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.search.html', 'components/ILIAS/Search'); $this->renderSearch($this->search_cache->getQuery(), $this->search_cache->getRoot()); } - /** * Parse creation date */ @@ -562,5 +539,4 @@ protected function parseCreationFilter(): string return ''; } - // end-patch creation_date } diff --git a/components/ILIAS/Search/classes/Lucene/class.ilLuceneUserSearchGUI.php b/components/ILIAS/Search/classes/Lucene/class.ilLuceneUserSearchGUI.php index 0198fccc9dc3..9ed33b56648a 100755 --- a/components/ILIAS/Search/classes/Lucene/class.ilLuceneUserSearchGUI.php +++ b/components/ILIAS/Search/classes/Lucene/class.ilLuceneUserSearchGUI.php @@ -17,15 +17,12 @@ *********************************************************************/ declare(strict_types=1); + /** - * @classDescription GUI for Lucene user search - * * @author Stefan Meyer * * @ilCtrl_Calls ilLuceneUserSearchGUI: ilPublicUserProfileGUI * @ilCtrl_IsCalledBy ilLuceneUserSearchGUI: ilSearchControllerGUI - * - * @ingroup ServicesSearch */ class ilLuceneUserSearchGUI extends ilSearchBaseGUI { @@ -134,10 +131,6 @@ protected function remoteSearch(): void $this->search(); } - /** - * Show saved results - * @return void - */ protected function showSavedResults(): void { if (strlen($this->search_cache->getQuery())) { @@ -150,7 +143,6 @@ protected function showSavedResults(): void /** * Search (button pressed) - * @return void */ protected function search(): void { @@ -207,14 +199,6 @@ protected function getTabs(): void $this->tabs->addTarget('search_user', $this->ctrl->getLinkTargetByClass('illuceneusersearchgui')); } - $fields = ilLuceneAdvancedSearchFields::getInstance(); - - if ( - !ilSearchSettings::getInstance()->getHideAdvancedSearch() and - $fields->getActiveFields()) { - $this->tabs->addTarget('search_advanced', $this->ctrl->getLinkTargetByClass('illuceneadvancedsearchgui')); - } - $this->tabs->setTabActive('search_user'); } @@ -246,7 +230,6 @@ protected function initUserSearchCache(): void /** * Show search form - * @return boolean */ protected function showSearchForm() { diff --git a/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsFormGUI.php b/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsFormGUI.php index adb9163961b2..7a75aec7f008 100755 --- a/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsFormGUI.php +++ b/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsFormGUI.php @@ -17,6 +17,7 @@ *********************************************************************/ declare(strict_types=1); + use ILIAS\HTTP\GlobalHttpState; use ILIAS\DI\UIServices; use ILIAS\UI\Factory; @@ -123,7 +124,6 @@ protected function update(): void if (!is_null($main_data['filter'])) { $settings->setLuceneItemFilter((array) $main_data['filter']); } - $settings->setHideAdvancedSearch((bool) $main_data['hide_adv_search']); $settings->enableDateFilter((bool) $main_data['cdate']); $settings->setAutoCompleteLength((int) $user_data['auto_complete_length']); $settings->showInactiveUser((bool) $user_data['inactive_user']); @@ -222,11 +222,6 @@ protected function initForm(bool $read_only): StandardForm $this->lng->txt('search_cdate_filter_info') )->withValue($settings->isDateFilterEnabled()); - // hide advanced search - $hide_adv = $field_factory->checkbox( - $this->lng->txt('search_hide_adv_search') - )->withValue($settings->getHideAdvancedSearch()); - // number of auto complete entries $options = [ 5 => 5, @@ -262,7 +257,6 @@ protected function initForm(bool $read_only): StandardForm 'max_hits' => $hits, 'search_type' => $type, 'operator' => $operator, - 'hide_adv_search' => $hide_adv, 'filter' => $item_filter, 'cdate' => $cdate ], diff --git a/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsGUI.php b/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsGUI.php index d795c51905f5..a3e29b87a8fd 100755 --- a/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsGUI.php +++ b/components/ILIAS/Search/classes/ObjGUI/class.ilObjSearchSettingsGUI.php @@ -17,6 +17,7 @@ *********************************************************************/ declare(strict_types=1); + use ILIAS\HTTP\GlobalHttpState; use ILIAS\Refinery\Factory; use ILIAS\DI\UIServices; @@ -108,10 +109,6 @@ public function executeCommand(): void $this->redirectToLuceneSettings(); break; - case 'advancedLuceneSettings': - $this->advancedLuceneSettingsObject(); - break; - default: $cmd .= "Object"; $this->$cmd(); @@ -175,14 +172,6 @@ protected function getTabs(): void ); } - if ($this->rbac_system->checkAccess('read', $this->object->getRefId())) { - $this->tabs_gui->addTab( - 'lucene_advanced_settings', - $this->lng->txt('lucene_advanced_settings'), - $this->ctrl->getLinkTarget($this, 'advancedLuceneSettings') - ); - } - if ($this->rbac_system->checkAccess('read', $this->object->getRefId())) { $this->tabs_gui->addTab( 'lucene_settings_tab', @@ -202,39 +191,4 @@ protected function getTabs(): void ); } } - - protected function advancedLuceneSettingsObject(): void - { - $this->tabs_gui->setTabActive('lucene_advanced_settings'); - - $table = new ilLuceneAdvancedSearchActivationTableGUI($this, 'advancedLuceneSettings'); - $table->setTitle($this->lng->txt('lucene_advanced_settings_table')); - $table->parse(ilLuceneAdvancedSearchSettings::getInstance()); - - $this->tpl->setContent($table->getHTML()); - } - - protected function saveAdvancedLuceneSettingsObject(): void - { - if (!$this->access->checkAccess('write', '', $this->object->getRefId())) { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true); - $this->ctrl->redirect($this, 'settings'); - } - - $enabled_md_ids = new SplFixedArray(0); - if ($this->http->wrapper()->post()->has('fid')) { - $enabled_md_ids = $this->http->wrapper()->post()->retrieve( - 'fid', - $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()) - ); - } - - $settings = ilLuceneAdvancedSearchSettings::getInstance(); - foreach (ilLuceneAdvancedSearchFields::getFields() as $field => $translation) { - $settings->setActive($field, in_array($field, (array) $enabled_md_ids)); - } - $settings->save(); - $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true); - $this->ctrl->redirect($this, 'advancedLuceneSettings'); - } } diff --git a/components/ILIAS/Search/classes/class.ilAdvancedSearchGUI.php b/components/ILIAS/Search/classes/class.ilAdvancedSearchGUI.php deleted file mode 100755 index f22a0f58b79e..000000000000 --- a/components/ILIAS/Search/classes/class.ilAdvancedSearchGUI.php +++ /dev/null @@ -1,991 +0,0 @@ - -* -* @ilCtrl_Calls ilAdvancedSearchGUI: ilObjectGUI, ilContainerGUI -* @ilCtrl_Calls ilAdvancedSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI -* @ilCtrl_Calls ilAdvancedSearchGUI: ilObjStudyProgrammeGUI -* @ilCtrl_Calls ilAdvancedSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI, ilPropertyFormGUI -* -* @package ilias-search -* -*/ -class ilAdvancedSearchGUI extends ilSearchBaseGUI -{ - public const TYPE_LOM = 1; - public const TYPE_ADV_MD = 2; - - protected string $last_section = 'adv_search'; - - protected ilLuceneAdvancedSearchFields $fields; - - - - - private bool $stored = false; - private array $options = array(); - protected array $filter = array(); - - protected ilTabsGUI $tabs_gui; - protected ilHelpGUI $help_gui; - - public function __construct() - { - global $DIC; - - $this->tabs_gui = $DIC->tabs(); - $this->help_gui = $DIC->help(); - - - parent::__construct(); - - $this->lng->loadLanguageModule('meta'); - $this->fields = ilLuceneAdvancedSearchFields::getInstance(); - - $this->__setSearchOptions(); - } - - public function getRootNode(): int - { - return ROOT_FOLDER_ID; - } - - - public function executeCommand(): bool - { - $next_class = $this->ctrl->getNextClass($this); - $cmd = $this->ctrl->getCmd(); - - switch ($next_class) { - case "ilpropertyformgui": - - - case 'ilobjectcopygui': - $this->prepareOutput(); - $this->ctrl->setReturn($this, ''); - - $cp = new ilObjectCopyGUI($this); - $this->ctrl->forwardCommand($cp); - break; - - default: - $this->initUserSearchCache(); - if (!$cmd) { - $last_sub_section = (int) ilSession::get('search_last_sub_section'); - switch ($last_sub_section) { - case self::TYPE_ADV_MD: - $cmd = "showSavedAdvMDResults"; - break; - - default: - $cmd = "showSavedResults"; - break; - } - } - $this->prepareOutput(); - $this->handleCommand($cmd); - break; - } - return true; - } - public function reset(): void - { - $this->initSearchType(self::TYPE_LOM); - $this->options = array(); - $this->search_cache->setQuery(array()); - $this->search_cache->save(); - $this->showSearch(); - } - - public function searchInResults(): bool - { - $this->initSearchType(self::TYPE_LOM); - $this->search_mode = 'in_results'; - $this->search_cache->setResultPageNumber(1); - ilSession::clear('adv_max_page'); - $this->performSearch(); - - return true; - } - - protected function remoteSearch(): void - { - $root_id = 0; - if ($this->http->wrapper()->post()->has('root_id')) { - $root_id = $this->http->wrapper()->post()->retrieve( - 'root_id', - $this->refinery->kindlyTo()->int() - ); - } - $queryString = ''; - if ($this->http->wrapper()->post()->has('queryString')) { - $queryString = $this->http->wrapper()->post()->retrieve( - 'queryString', - $this->refinery->kindlyTo()->string() - ); - } - $this->search_cache->setRoot($root_id); - $this->search_cache->setResultPageNumber(1); - $this->search_cache->setQuery(array('lom_content' => $queryString)); - $this->search_cache->save(); - - $this->options = $this->search_cache->getQuery(); - $this->options['type'] = 'all'; - - $this->performSearch(); - } - - - - public function performSearch(): bool - { - global $DIC; - $this->initSearchType(self::TYPE_LOM); - $page_number = $this->initPageNumberFromQuery(); - if (!$page_number and $this->search_mode != 'in_results') { - ilSession::clear('adv_max_page'); - $this->search_cache->deleteCachedEntries(); - } - - if ($this->http->wrapper()->post()->has('query')) { - $this->search_cache->setQuery( - $this->getQueryFromPost() - ); - } - $res = new ilSearchResult(); - if ($res_con = $this->__performContentSearch()) { - $this->__storeEntries($res, $res_con); - } - if ($res_lan = $this->__performLanguageSearch()) { - $this->__storeEntries($res, $res_lan); - } - if ($res_gen = $this->__performGeneralSearch()) { - $this->__storeEntries($res, $res_gen); - } - if ($res_lif = $this->__performLifecycleSearch()) { - $this->__storeEntries($res, $res_lif); - } - if ($res_con = $this->__performContributeSearch()) { - $this->__storeEntries($res, $res_con); - } - if ($res_ent = $this->__performEntitySearch()) { - $this->__storeEntries($res, $res_ent); - } - if ($res_req = $this->__performRequirementSearch()) { - $this->__storeEntries($res, $res_req); - } - if ($res_for = $this->__performFormatSearch()) { - $this->__storeEntries($res, $res_for); - } - if ($res_edu = $this->__performEducationalSearch()) { - $this->__storeEntries($res, $res_edu); - } - if ($res_typ = $this->__performTypicalAgeRangeSearch()) { - $this->__storeEntries($res, $res_typ); - } - if ($res_rig = $this->__performRightsSearch()) { - $this->__storeEntries($res, $res_rig); - } - if ($res_cla = $this->__performClassificationSearch()) { - $this->__storeEntries($res, $res_cla); - } - if ($res_tax = $this->__performTaxonSearch()) { - $this->__storeEntries($res, $res_tax); - } - if ($res_key = $this->__performKeywordSearch()) { - $this->__storeEntries($res, $res_key); - } - - $this->searchAdvancedMD($res); - - if ($this->search_mode == 'in_results') { - $old_result_obj = new ilSearchResult($this->user->getId()); - $old_result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH); - - $res->diffEntriesFromResult(); - } - - $res->filter($this->getRootNode(), (ilSearchSettings::getInstance()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND)); - $res->save(); - $this->showSearch(); - - if (!count($res->getResults())) { - $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match')); - } - - if ($res->isLimitReached()) { - #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits()); - #ilUtil::sendInfo($message); - } - - $this->addPager($res, 'adv_max_page'); - - $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD); - $presentation->setResults($res->getResultsForPresentation()); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('RESULTS', $presentation->getHTML()); - } - return true; - } - - - protected function initAdvancedMetaDataForm(): ?ilPropertyFormGUI - { - if (is_object($this->form)) { - return $this->form; - } - $this->form = new ilPropertyFormGUI(); - $this->form->setFormAction($this->ctrl->getFormAction($this, 'performAdvMDSearch')); - $this->form->setTitle($this->lng->txt('adv_md_search_title')); - $this->form->addCommandButton('performAdvMDSearch', $this->lng->txt('search')); - #$this->form->setSubformMode('right'); - - $content = new ilTextInputGUI($this->lng->txt('meta_title') . '/' . - $this->lng->txt('meta_keyword') . '/' . - $this->lng->txt('meta_description'), 'title'); - $content->setValue($this->options['title']); - $content->setSize(30); - $content->setMaxLength(255); - // $content->setSubformMode('right'); - $group = new ilRadioGroupInputGUI('', 'title_ao'); - $group->setValue($this->options['title_ao']); - $radio_option = new ilRadioOption($this->lng->txt("search_any_word"), '0'); - $group->addOption($radio_option); - $radio_option = new ilRadioOption($this->lng->txt("search_all_words"), '1'); - $group->addOption($radio_option); - $content->addSubItem($group); - $this->form->addItem($content); - - $type = new ilSelectInputGUI($this->lng->txt('type'), 'type'); - $options['adv_all'] = $this->lng->txt('search_any'); - foreach (ilAdvancedMDRecord::_getActivatedObjTypes() as $obj_type) { - $options[$obj_type] = $this->lng->txt('objs_' . $obj_type); - } - $type->setOptions($options); - $type->setValue($this->options['type']); - $this->form->addItem($type); - - $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_SEARCH); - $record_gui->setPropertyForm($this->form); - $record_gui->setSearchValues($this->options); - $record_gui->parse(); - return null; - } - - - protected function performAdvMDSearch(): bool - { - $this->initSearchType(self::TYPE_ADV_MD); - $page_number = $this->initPageNumberFromQuery(); - if (!$page_number and $this->search_mode != 'in_results') { - ilSession::clear('adv_max_page'); - $this->search_cache->delete(); - } - $res = new ilSearchResult(); - if ($res_tit = $this->__performTitleSearch()) { - $this->__storeEntries($res, $res_tit); - } - $this->searchAdvancedMD($res); - if ($this->search_mode == 'in_results') { - $old_result_obj = new ilSearchResult($this->user->getId()); - $old_result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH); - - $res->diffEntriesFromResult(); - } - $res->filter($this->getRootNode(), true); - $res->save(); - $this->showAdvMDSearch(); - - if (!count($res->getResults())) { - $this->tpl->setOnScreenMessage('info', $this->lng->txt('search_no_match')); - } - - if ($res->isLimitReached()) { - #$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits()); - #ilUtil::sendInfo($message); - } - - $this->addPager($res, 'adv_max_page'); - - $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD); - $presentation->setResults($res->getResultsForPresentation()); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('RESULTS', $presentation->getHTML()); - } - return true; - } - - - public function showAdvMDSearch(): bool - { - $session_options = ilSession::get('search_adv_md'); - if ($session_options !== null) { - $this->options = $session_options; - } - $this->setSubTabs(); - $this->tabs_gui->setSubTabActive('search_adv_md'); - - $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_adv_search.html', 'components/ILIAS/Search'); - - $this->initAdvancedMetaDataForm(); - $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML()); - return true; - } - - - protected function initFormSearch(): bool - { - $this->form = new ilPropertyFormGUI(); - $this->form->setFormAction($this->ctrl->getFormAction($this, 'performSearch')); - $this->form->setTitle($this->lng->txt('search_advanced')); - $this->form->addCommandButton('performSearch', $this->lng->txt('search')); - $this->form->addCommandButton('reset', $this->lng->txt('reset')); - foreach ($this->fields->getActiveSections() as $definition) { - if ($definition['name'] != 'default') { - $section = new ilFormSectionHeaderGUI(); - $section->setTitle($definition['name']); - $this->form->addItem($section); - } - - foreach ($definition['fields'] as $field_name) { - if (is_object($element = $this->fields->getFormElement($this->search_cache->getQuery(), $field_name, $this->form))) { - $this->form->addItem($element); - } - } - } - return true; - } - - - - public function showSearch(): bool - { - $this->setSubTabs(); - $this->tabs_gui->setSubTabActive('search_lom'); - - $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.advanced_search.html', 'components/ILIAS/Search'); - - $this->initFormSearch(); - $this->tpl->setVariable('SEARCH_FORM', $this->form->getHTML()); - return true; - } - - public function prepareOutput(): void - { - parent::prepareOutput(); - - $this->help_gui->setScreenIdComponent("src"); - - $this->tabs_gui->addTab( - "search", - $this->lng->txt("search"), - $this->ctrl->getLinkTargetByClass('ilsearchgui') - ); - $this->tabs_gui->addTab( - "adv_search", - $this->lng->txt("search_advanced"), - $this->ctrl->getLinkTarget($this) - ); - $this->tabs_gui->activateTab("adv_search"); - } - - - private function showSavedAdvMDResults(): bool - { - $this->initSearchType(self::TYPE_ADV_MD); - $result_obj = new ilSearchResult($this->user->getId()); - $result_obj->read(ilUserSearchCache::ADVANCED_MD_SEARCH); - - $this->showAdvMDSearch(); - - // Show them - if (count($result_obj->getResults())) { - $this->addPager($result_obj, 'adv_max_page'); - - $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD); - $presentation->setResults($result_obj->getResultsForPresentation()); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('RESULTS', $presentation->getHTML()); - } - } - - return true; - } - - - public function showSavedResults(): bool - { - $this->initSearchType(self::TYPE_LOM); - $result_obj = new ilSearchResult($this->user->getId()); - $result_obj->read(ilUserSearchCache::ADVANCED_SEARCH); - - $this->showSearch(); - - // Show them - if (count($result_obj->getResults())) { - $this->addPager($result_obj, 'adv_max_page'); - - $presentation = new ilSearchResultPresentation($this, ilSearchResultPresentation::MODE_STANDARD); - $presentation->setResults($result_obj->getResultsForPresentation()); - $presentation->setPreviousNext($this->prev_link, $this->next_link); - - if ($presentation->render()) { - $this->tpl->setVariable('RESULTS', $presentation->getHTML()); - } - } - - return true; - } - - public function __performContentSearch(): ?ilSearchResult - { - if (!($this->options['lom_content'] ?? null)) { - return null; - } - - $res = new ilSearchResult(); - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content'])); - #$query_parser->setCombination($this->options['content_ao']); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - - if (!isset($this->options['type'])) { - if ($tit_res = $this->__performTitleSearch()) { - $res->mergeEntries($tit_res); - } - - return $res; - } - - if ($this->options['type'] == 'all' or $this->options['type'] == 'lms') { - // LM content search - $lm_search = ilObjectSearchFactory::_getLMContentSearchInstance($query_parser); - $res_cont = $lm_search->performSearch(); - $res->mergeEntries($res_cont); - } - if ($this->options['type'] == 'all' or $this->options['type'] == 'tst') { - $tst_search = ilObjectSearchFactory::_getTestSearchInstance($query_parser); - $res_tes = $tst_search->performSearch(); - $res->mergeEntries($res_tes); - } - if ($this->options['type'] == 'all' or $this->options['type'] == 'mep') { - $med_search = ilObjectSearchFactory::_getMediaPoolSearchInstance($query_parser); - $res_med = $med_search->performSearch(); - $res->mergeEntries($res_med); - } - if ($this->options['type'] == 'all' or $this->options['type'] == 'glo') { - $glo_search = ilObjectSearchFactory::_getGlossaryDefinitionSearchInstance($query_parser); - $res_glo = $glo_search->performSearch(); - $res->mergeEntries($res_glo); - } - if ($this->options['type'] == 'all' or $this->options['type'] == 'webr') { - $web_search = ilObjectSearchFactory::_getWebresourceSearchInstance($query_parser); - $res_web = $web_search->performSearch(); - $res->mergeEntries($res_web); - } - if ($tit_res = $this->__performTitleSearch()) { - $res->mergeEntries($tit_res); - } - - return $res; - } - - - public function __performTitleSearch(): ?ilSearchResult - { - if (!($this->options['lom_content'] ?? null)) { - return null; - } - - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_content'])); - #$query_parser->setCombination($this->options['title_ao']); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - - $meta_search->setFilter($this->filter); - $meta_search->setMode('title_description'); - $meta_search->setOptions($this->options); - $res_tit = $meta_search->performSearch(); - - $meta_search->setMode('keyword_all'); - $res_key = $meta_search->performSearch(); - - // merge them - $res_tit->mergeEntries($res_key); - - - return $res_tit; - } - - - - public function __performGeneralSearch(): ?ilSearchResult - { - if ( - !($this->options['lom_coverage'] ?? null) and - !($this->options['lom_structure'] ?? null) - ) { - return null; - } - - - if (($this->options['lom_coverage'] ?? null)) { - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_coverage'])); - #$query_parser->setCombination($this->options['coverage_ao']); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - } else { - $query_parser = new ilQueryParser(''); - } - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - $meta_search->setFilter($this->filter); - $meta_search->setMode('general'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - - public function __performLifecycleSearch(): ?ilSearchResult - { - // Return if 'any' - if ( - !($this->options['lom_status'] ?? null) and - !($this->options['lom_version'] ?? null) - ) { - return null; - } - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_version'])); - #$query_parser->setCombination($this->options['version_ao']); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - $meta_search->setFilter($this->filter); - $meta_search->setMode('lifecycle'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performLanguageSearch(): ?ilSearchResult - { - if (!($this->options['lom_language'] ?? null)) { - return null; - } - - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('language'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performContributeSearch(): ?ilSearchResult - { - if (!strlen($this->options['lom_role'] ?? '')) { - return null; - } - - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('contribute'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performEntitySearch(): ?ilSearchResult - { - // Return if 'any' - if (!($this->options['lom_role_entry'] ?? null)) { - return null; - } - - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_role_entry'])); - #$query_parser->setCombination($this->options['entity_ao']); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - $meta_search->setFilter($this->filter); - $meta_search->setMode('entity'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - - - public function __performRequirementSearch(): ?ilSearchResult - { - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('requirement'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performFormatSearch(): ?ilSearchResult - { - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('format'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performEducationalSearch(): ?ilSearchResult - { - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('educational'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performTypicalAgeRangeSearch(): ?ilSearchResult - { - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('typical_age_range'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - public function __performRightsSearch(): ?ilSearchResult - { - if ( - !($this->options['lom_copyright'] ?? null) and - !($this->options['lom_costs'] ?? null) - ) { - return null; - } - - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('rights'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - - public function __performClassificationSearch(): ?ilSearchResult - { - // Return if 'any' - if (!($this->options['lom_purpose'] ?? null)) { - return null; - } - - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance(new ilQueryParser('')); - $meta_search->setFilter($this->filter); - $meta_search->setMode('classification'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - - public function __performTaxonSearch(): ?ilSearchResult - { - // Return if 'any' - if (!($this->options['lom_taxon'] ?? null)) { - return null; - } - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_taxon'])); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - $meta_search->setFilter($this->filter); - $meta_search->setMode('taxon'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - - return $res; - } - - private function searchAdvancedMD(ilSearchResult $res): void - { - $this->initFormSearch(); - - foreach (array_keys($this->options) as $key) { - if (substr((string) $key, 0, 3) != 'adv') { - continue; - } - - // :TODO: ? - if (!$key) { - continue; - } - - $field_id = substr($key, 4); - $field = ilAdvancedMDFieldDefinition::getInstance((int) $field_id); - - $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false); - $field_form->setElementId("query[" . $key . "]"); - $field_form->setForm($this->form); - - // reload search values - $field_form->importFromPost($this->options); - $field_form->validate(); - - $parser_value = $field->getSearchQueryParserValue($field_form); - if (!strlen($parser_value)) { - continue; - } - $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance(new ilQueryParser($parser_value)); - $adv_md_search->setFilter($this->filter); - $adv_md_search->setDefinition($field); - $adv_md_search->setSearchElement($field_form); - $res_field = $adv_md_search->performSearch(); - $this->__storeEntries($res, $res_field); - } - } - - public function __performKeywordSearch(): ?ilSearchResult - { - // Return if 'any' - if (!($this->options['lom_keyword'] ?? null)) { - return null; - } - - $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->options['lom_keyword'])); - $query_parser->setCombination(ilQueryParser::QP_COMBINATION_OR); - $query_parser->parse(); - - $meta_search = ilObjectSearchFactory::_getAdvancedSearchInstance($query_parser); - $meta_search->setFilter($this->filter); - $meta_search->setMode('keyword'); - $meta_search->setOptions($this->options); - $res = $meta_search->performSearch(); - return $res; - } - - public function __setSearchOptions(): bool - { - $query = $this->getQueryFromPost(); - - $post_cmd = (array) ($this->http->request()->getParsedBody()['cmd'] ?? []); - - if (isset($post_cmd['performSearch'])) { - $this->options = $query; - ilSession::set('search_adv', $this->options); - } elseif (isset($post_cmd['performAdvMDSearch'])) { - $this->options = (array) $this->http->request()->getParsedBody(); - ilSession::set('search_adv_md', $this->options); - } else { - $this->options = ilSession::get('search_adv') ?? []; - } - $this->filter = array(); - - $this->options['type'] = 'all'; - switch ($this->options['type']) { - case 'cat': - $this->filter[] = 'cat'; - break; - - case 'webr': - $this->filter[] = 'webr'; - break; - - case 'lms': - $this->filter[] = 'lm'; - $this->filter[] = 'dbk'; - $this->filter[] = 'pg'; - $this->filter[] = 'st'; - $this->filter[] = 'sahs'; - $this->filter[] = 'htlm'; - break; - - case 'glo': - $this->filter[] = 'glo'; - break; - - case 'tst': - $this->filter[] = 'tst'; - $this->filter[] = 'svy'; - $this->filter[] = 'qpl'; - $this->filter[] = 'spl'; - break; - - case 'mep': - $this->filter[] = 'mep'; - $this->filter[] = 'mob'; - $this->filter[] = 'mpg'; - break; - - case 'crs': - $this->filter[] = 'crs'; - break; - - case 'file': - $this->filter[] = 'file'; - break; - - case 'adv_all': - $this->filter = ilAdvancedMDRecord::_getActivatedObjTypes(); - break; - - case 'all': - default: - $this->filter[] = 'cat'; - $this->filter[] = 'sess'; - $this->filter[] = 'webr'; - $this->filter[] = 'crs'; - $this->filter[] = 'mep'; - $this->filter[] = 'tst'; - $this->filter[] = 'svy'; - $this->filter[] = 'qpl'; - $this->filter[] = 'spl'; - $this->filter[] = 'glo'; - $this->filter[] = 'lm'; - $this->filter[] = 'dbk'; - $this->filter[] = 'pg'; - $this->filter[] = 'st'; - $this->filter[] = 'sahs'; - $this->filter[] = 'htlm'; - $this->filter[] = 'file'; - $this->filter[] = 'mob'; - $this->filter[] = 'mpg'; - } - return true; - } - - public function __getFilterSelect(): string - { - $options = array('all' => $this->lng->txt('search_any'), - 'crs' => $this->lng->txt('objs_crs'), - 'lms' => $this->lng->txt('obj_lrss'), - 'glo' => $this->lng->txt('objs_glo'), - 'mep' => $this->lng->txt('objs_mep'), - 'tst' => $this->lng->txt('search_tst_svy'), - 'file' => $this->lng->txt('objs_file'), - 'webr' => $this->lng->txt('objs_webr'), - 'sess' => $this->lng->txt('objs_sess') - ); - - - return ilLegacyFormElementsUtil::formSelect($this->options['type'], 'search_adv[type]', $options, false, true); - } - - - public function __storeEntries(ilSearchResult $res, ilSearchResult $new_res): bool - { - if (!$this->stored) { - $res->mergeEntries($new_res); - $this->stored = true; - return true; - } else { - $res->intersectEntries($new_res); - return true; - } - } - - private function initUserSearchCache(): void - { - $this->search_cache = ilUserSearchCache::_getInstance($this->user->getId()); - $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH); - $page_number = $this->initPageNumberFromQuery(); - if ($page_number) { - $this->search_cache->setResultPageNumber($page_number); - } - $post_cmd = (array) ($this->http->request()->getParsedBody()['cmd'] ?? []); - $post_query = (array) ($this->http->request()->getParsedBody()['query'] ?? []); - if ($post_cmd['performSearch'] ?? null) { - $this->search_cache->setQuery($post_query['lomContent'] ?? ''); - $this->search_cache->save(); - } - } - - public function setSubTabs(): bool - { - if (!count(ilAdvancedMDFieldDefinition::getSearchableDefinitionIds())) { - return true; - } - $this->tabs_gui->addSubTabTarget('search_lom', $this->ctrl->getLinkTarget($this, 'showSavedResults')); - return true; - } - - - private function toUnixTime(array $date, array $time = array()): int - { - return mktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']); - } - - - private function initSearchType(int $type): void - { - if ($type == self::TYPE_LOM) { - ilSession::set('search_last_sub_section', self::TYPE_LOM); - $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_SEARCH); - } else { - ilSession::set('search_last_sub_section', self::TYPE_ADV_MD); - $this->search_cache->switchSearchType(ilUserSearchCache::ADVANCED_MD_SEARCH); - } - } - - private function getQueryFromPost(): array - { - $query = []; - if ($this->http->wrapper()->post()->has('query')) { - $query = $this->http->wrapper()->post()->retrieve( - 'query', - $this->refinery->kindlyTo()->dictOf( - $this->refinery->byTrying([ - $this->refinery->kindlyTo()->string(), - $this->refinery->kindlyTo()->dictOf( - $this->refinery->kindlyTo()->string() - ) - ]) - ) - ); - } - return $query; - } -} diff --git a/components/ILIAS/Search/classes/class.ilSearchControllerGUI.php b/components/ILIAS/Search/classes/class.ilSearchControllerGUI.php index 8221a106ad27..41f0ff8498ba 100755 --- a/components/ILIAS/Search/classes/class.ilSearchControllerGUI.php +++ b/components/ILIAS/Search/classes/class.ilSearchControllerGUI.php @@ -22,19 +22,14 @@ use ILIAS\Refinery\Factory; /** - * Class ilObjSearchController - * * @author Stefan Meyer * - * @package ilias-search - * - * @ilCtrl_Calls ilSearchControllerGUI: ilSearchGUI, ilAdvancedSearchGUI - * @ilCtrl_Calls ilSearchControllerGUI: ilLuceneSearchGUI, ilLuceneAdvancedSearchGUI, ilLuceneUserSearchGUI - * + * @ilCtrl_Calls ilSearchControllerGUI: ilSearchGUI + * @ilCtrl_Calls ilSearchControllerGUI: ilLuceneSearchGUI ilLuceneUserSearchGUI */ class ilSearchControllerGUI implements ilCtrlBaseClassInterface { - public const TYPE_USER_SEARCH = -1; + public const int TYPE_USER_SEARCH = -1; protected ilObjUser $user; protected ilCtrl $ctrl; @@ -45,11 +40,6 @@ class ilSearchControllerGUI implements ilCtrlBaseClassInterface protected GlobalHttpState $http; protected Factory $refinery; - - /** - * Constructor - * @access public - */ public function __construct() { global $DIC; @@ -76,10 +66,6 @@ public function executeCommand(): void $this->ctrl->forwardCommand(new ilLuceneSearchGUI()); break; - case 'illuceneadvancedsearchgui': - $this->ctrl->forwardCommand(new ilLuceneAdvancedSearchGUI()); - break; - case 'illuceneusersearchgui': if ($this->user->getId() === ANONYMOUS_USER_ID) { $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); @@ -87,10 +73,6 @@ public function executeCommand(): void $this->ctrl->forwardCommand(new ilLuceneUserSearchGUI()); break; - case 'iladvancedsearchgui': - $this->ctrl->forwardCommand(new ilAdvancedSearchGUI()); - break; - case 'ilsearchgui': default: $search_gui = new ilSearchGUI(); diff --git a/components/ILIAS/Search/classes/class.ilSearchGUI.php b/components/ILIAS/Search/classes/class.ilSearchGUI.php index e453a198338f..bca5894c1b53 100755 --- a/components/ILIAS/Search/classes/class.ilSearchGUI.php +++ b/components/ILIAS/Search/classes/class.ilSearchGUI.php @@ -22,18 +22,14 @@ use ILIAS\UI\Renderer as UIRenderer; /** -* Class ilSearchGUI -* -* GUI class for 'simple' search -* -* @author Stefan Meyer -* @ilCtrl_Calls ilSearchGUI: ilObjectGUI, ilContainerGUI -* @ilCtrl_Calls ilSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI -* @ilCtrl_Calls ilSearchGUI: ilObjStudyProgrammeGUI -* @ilCtrl_Calls ilSearchGUI: ilObjRootFolderGUI, ilObjectCopyGUI -* -* @ingroup ServicesSearch -*/ + * GUI class for 'simple' search + * + * @author Stefan Meyer + * + * @ilCtrl_Calls ilSearchGUI: ilObjectGUI, ilContainerGUI + * @ilCtrl_Calls ilSearchGUI: ilObjCategoryGUI, ilObjCourseGUI, ilObjFolderGUI, ilObjGroupGUI + * @ilCtrl_Calls ilSearchGUI: ilObjStudyProgrammeGUI + */ class ilSearchGUI extends ilSearchBaseGUI { private array $details; @@ -47,10 +43,6 @@ class ilSearchGUI extends ilSearchBaseGUI protected UIFactory $ui_factory; protected UIRenderer $ui_renderer; - /** - * Constructor - * @access public - */ public function __construct() { global $DIC; @@ -138,11 +130,6 @@ public function __construct() } } - - /** - * Control - * @access public - */ public function executeCommand(): void { $next_class = $this->ctrl->getNextClass($this); @@ -167,9 +154,8 @@ public function executeCommand(): void } /** - * Set/get type of search (detail or 'fast' search) - * @access public - */ + * Set/get type of search (detail or 'fast' search) + */ public function setType(int $a_type): void { $session_search = ilSession::get('search'); @@ -181,10 +167,10 @@ public function getType(): int { return $this->type ?? self::SEARCH_FAST; } + /** - * Set/get combination of search ('and' or 'or') - * @access public - */ + * Set/get combination of search ('and' or 'or') + */ public function setCombination(string $a_combination): void { $session_search = ilSession::get('search') ?? []; @@ -195,36 +181,34 @@ public function getCombination(): string { return $this->combination ?: self::SEARCH_OR; } - /** - * Set/get search string - * @access public - */ + public function setString(string $a_str): void { $session_search = ilSession::get('search') ?? []; $session_search['string'] = $this->string = $a_str; ilSession::set('search', $session_search); } + public function getString(): string { return $this->string; } + /** - * Set/get details (object types for details search) - * @access public - */ + * Set/get details (object types for details search) + */ public function setDetails(array $a_details): void { $session_search = ilSession::get('search') ?? []; $session_search['details'] = $this->details = $a_details; ilSession::set('search', $session_search); } + public function getDetails(): array { return $this->details ?? []; } - public function getRootNode(): int { return $this->root_node ?: ROOT_FOLDER_ID; @@ -235,7 +219,6 @@ public function setRootNode(int $a_node_id): void ilSession::set('search_root', $this->root_node = $a_node_id); } - public function remoteSearch(): void { $root_id = 0; @@ -258,8 +241,8 @@ public function remoteSearch(): void } /** - * Data resource for autoComplete - */ + * Data resource for autoComplete + */ public function autoComplete(): void { $query = ''; @@ -350,9 +333,6 @@ public function performSearchFilter(): void $this->performSearch(); } - /** - * Perform search - */ public function performSearch(): void { $page_number = $this->initPageNumberFromQuery(); @@ -435,8 +415,6 @@ public function performSearch(): void } } - - public function prepareOutput(): void { parent::prepareOutput(); @@ -449,14 +427,6 @@ public function prepareOutput(): void $this->ctrl->getLinkTarget($this) ); - if (!$this->settings->getHideAdvancedSearch()) { - $this->tabs_gui->addTab( - "adv_search", - $this->lng->txt("search_advanced"), - $this->ctrl->getLinkTargetByClass('iladvancedsearchgui') - ); - } - $this->tabs_gui->activateTab("search"); } @@ -547,10 +517,9 @@ protected function __performDetailsSearch(ilQueryParser $query_parser, ilSearchR } /** - * parse query string, using query parser instance - * @return ilQueryParser | string + * parse query string, using query parser instance */ - public function __parseQueryString() + public function __parseQueryString(): ilQueryParser|string { $query_parser = new ilQueryParser(ilUtil::stripSlashes($this->getString())); $query_parser->setCombination($this->getCombination()); @@ -561,6 +530,7 @@ public function __parseQueryString() } return $query_parser; } + /** * Search in obect title,desctiption */ @@ -607,10 +577,8 @@ protected function parseEndDateFromCreationFilter(): ?ilDate } /** - * Search in object meta data (keyword) - * @return ilSearchResult result object - * @access public - */ + * Search in object meta data (keyword) + */ public function __searchMeta(ilQueryParser $query_parser, string $a_type): ilSearchResult { $meta_search = ilObjectSearchFactory::_getMetaDataSearchInstance($query_parser); @@ -636,10 +604,11 @@ public function __searchMeta(ilQueryParser $query_parser, string $a_type): ilSea } return $meta_search->performSearch(); } + /** - * Get object type for filter (If detail search is enabled) + * Get object type for filter (If detail search is enabled) * @return string[] - */ + */ public function __getFilter(): array { if ($this->getType() != self::SEARCH_DETAILS) { diff --git a/components/ILIAS/Search/classes/class.ilSearchResult.php b/components/ILIAS/Search/classes/class.ilSearchResult.php index bcf70a549716..01ded1beb414 100755 --- a/components/ILIAS/Search/classes/class.ilSearchResult.php +++ b/components/ILIAS/Search/classes/class.ilSearchResult.php @@ -17,14 +17,12 @@ *********************************************************************/ /** -* searchResult stores all result of a search query. -* Offers methods like mergeResults. To merge result sets of different queries. -* -* -* @author Stefan Meyer -* -* @package ilias-search -*/ + * searchResult stores all result of a search query. + * Offers methods like mergeResults. To merge result sets of different queries. + * + * + * @author Stefan Meyer + */ class ilSearchResult { private string $permission = 'visible'; @@ -52,12 +50,6 @@ class ilSearchResult protected ilLogger $logger; - - - /** - * Constructor - * @access public - */ public function __construct(int $a_user_id = 0) { global $DIC; @@ -78,8 +70,8 @@ public function __construct(int $a_user_id = 0) } /** - * Set the required permission for the rbac checks in function 'filter()' - */ + * Set the required permission for the rbac checks in function 'filter()' + */ public function setRequiredPermission(string $a_permission): void { $this->permission = $a_permission; @@ -90,7 +82,6 @@ public function getRequiredPermission(): string return $this->permission; } - public function setUserId(int $a_user_id): void { $this->user_id = $a_user_id; @@ -131,10 +122,10 @@ public function isOffsetReached(int $a_counter): bool * * add search result entry * Entries are stored with 'obj_id'. This method is typically called to store db query results. - * @param int object object_id - * @param string obj_type 'lm' or 'crs' ... - * @param array value position of query parser words in query string - * @param int child id e.g id of page or chapter + * @param int $a_obj_id object object_id + * @param string $a_type obj_type 'lm' or 'crs' ... + * @param array $found value position of query parser words in query string + * @param int $a_child_id child id e.g id of page or chapter * @return void */ public function addEntry(int $a_obj_id, string $a_type, array $found, int $a_child_id = 0): void @@ -164,11 +155,6 @@ public function addEntry(int $a_obj_id, string $a_type, array $found, int $a_chi } } - /** - * - * Check number of entries - * @access public - */ public function numEntries(): int { return count($this->getEntries()); @@ -177,8 +163,6 @@ public function numEntries(): int /** * * merge entries of this instance and another result object - * @param object result_obj - * @access public */ public function mergeEntries(ilSearchResult $result_obj): void { @@ -250,8 +234,7 @@ public function getResults(): array } /** - * get result ids - * @return int[] result ids + * @return int[] */ public function getResultIds(): array { @@ -271,7 +254,6 @@ public function getResultsByObjId(): array return $tmp_res; } - /** * Get unique results. Return an array of obj_id (No multiple results for references) * Results are stored with 'ref_id'. This method is typically called after checking access of entries. @@ -312,8 +294,6 @@ public function getSubitemIds(): array return $res; } - - /** * Filter search result. * Do RBAC checks. @@ -374,10 +354,8 @@ public function filter( if (!ilDate::_before($creation_date, $creation_filter_date_end)) { continue; } - } else { - if (!ilDate::_within($creation_date, $creation_filter_date_start, $creation_filter_date_end)) { - continue; - } + } elseif (!ilDate::_within($creation_date, $creation_filter_date_start, $creation_filter_date_end)) { + continue; } } @@ -438,9 +416,7 @@ public function filter( } /** - * * Filter search area of result set - * @access public */ public function filterResults(int $a_root_node): void { @@ -454,34 +430,20 @@ public function filterResults(int $a_root_node): void } } - - /** - * - * Save search results - * @param int DEFAULT_SEARCH or ADVANCED_SEARCH - */ public function save(int $a_type = ilUserSearchCache::DEFAULT_SEARCH): void { $this->search_cache->save(); } - /** - * - * read search results - * @param int DEFAULT_SEARCH or ADVANCED_SEARCH - * @access public - */ + public function read(int $a_type = ilUserSearchCache::DEFAULT_SEARCH): void { $this->results = $this->search_cache->getResults(); } - // PRIVATE /** - * - * Update childs for a specific entry - * @param int object object_id - * @param array array of child ids. E.g 'pg', 'st' - * @access private + * @param int $a_obj_id + * @param array $a_childs array of child ids. E.g 'pg', 'st' + * @return bool */ public function __updateEntryChilds(int $a_obj_id, array $a_childs): bool { @@ -495,6 +457,7 @@ public function __updateEntryChilds(int $a_obj_id, array $a_childs): bool } return false; } + /** * Update child ids for a specific result */ @@ -509,8 +472,6 @@ public function __updateResultChilds(int $a_ref_id, array $a_childs): bool return false; } - - public function __initSearchSettingsObject(): void { $this->search_settings = new ilSearchSettings(); @@ -519,12 +480,6 @@ public function __initSearchSettingsObject(): void } } - /** - * Init user search cache - * - * @access private - * - */ protected function initUserSearchCache(): void { $this->search_cache = ilUserSearchCache::_getInstance($this->getUserId()); @@ -554,8 +509,8 @@ public function preventOverwritingMaxhits(?bool $a_flag = null) * Every callback function should support the following parameters: * array of ids. E.g: ref_id = 5,array(obj_id = 1,type = 'crs'), * The function should return true or false. - * @param object class of callback function - * @param string name of callback method + * @param object $a_class class of callback function + * @param string $a_method name of callback method */ public function addObserver(object $a_class, string $a_method): bool { @@ -577,4 +532,4 @@ public function callListeners(int $a_ref_id, array $a_data): bool } return true; } -} // END class.Search +} diff --git a/components/ILIAS/Search/classes/class.ilSearchSettings.php b/components/ILIAS/Search/classes/class.ilSearchSettings.php index d44e3eeb27ec..330f669a4efc 100755 --- a/components/ILIAS/Search/classes/class.ilSearchSettings.php +++ b/components/ILIAS/Search/classes/class.ilSearchSettings.php @@ -19,21 +19,15 @@ declare(strict_types=1); /** -* Class ilObjSearchSettingsGUI -* -* @author Stefan Meyer -* -* @extends ilObjectGUI -* @package ilias-core -*/ - + * @author Stefan Meyer + */ class ilSearchSettings { - public const LIKE_SEARCH = 0; - public const LUCENE_SEARCH = 2; + public const int LIKE_SEARCH = 0; + public const int LUCENE_SEARCH = 2; - public const OPERATOR_AND = 1; - public const OPERATOR_OR = 2; + public const int OPERATOR_AND = 1; + public const int OPERATOR_OR = 2; protected static ?ilSearchSettings $instance = null; @@ -50,7 +44,6 @@ class ilSearchSettings protected bool $show_limited_user = true; protected bool $lucene = false; - protected bool $hide_adv_search = false; protected bool $lucene_mime_filter_enabled = false; protected array $lucene_mime_filter = array(); protected bool $prefix_wildcard = false; @@ -131,7 +124,6 @@ public function getEnabledLuceneItemFilterDefinitions(): array return $enabled; } - // begin-patch mime_filter public function getEnabledLuceneMimeFilterDefinitions(): array { if (!$this->isLuceneItemFilterEnabled()) { @@ -227,14 +219,6 @@ public function setFragmentCount(int $a_count): void $this->fragmentCount = $a_count; } - public function getHideAdvancedSearch(): bool - { - return $this->hide_adv_search; - } - public function setHideAdvancedSearch(bool $a_status): void - { - $this->hide_adv_search = $a_status; - } public function getAutoCompleteLength(): int { return $this->auto_complete_length; @@ -334,10 +318,6 @@ public function isLuceneUserSearchEnabled(): bool return $this->user_search; } - /** - * Enable lucene user search - * @param bool $a_status - */ public function enableLuceneUserSearch(bool $a_status): void { $this->user_search = $a_status; @@ -351,10 +331,6 @@ public function showInactiveUser(bool $a_visible): void $this->show_inactiv_user = $a_visible; } - /** - * are inactive user visible in user search - * @return bool - */ public function isInactiveUserVisible(): bool { return $this->show_inactiv_user; @@ -394,7 +370,6 @@ public function update(): void $this->setting->set('lucene_fragment_count', (string) $this->getFragmentCount()); $this->setting->set('lucene_max_subitems', (string) $this->getMaxSubitems()); $this->setting->set('lucene_last_index_time', (string) $this->getLastIndexTime()->get(IL_CAL_UNIX)); - $this->setting->set('hide_adv_search', (string) $this->getHideAdvancedSearch()); $this->setting->set('auto_complete_length', (string) $this->getAutoCompleteLength()); $this->setting->set('lucene_item_filter_enabled', (string) $this->isLuceneItemFilterEnabled()); $this->setting->set('lucene_item_filter', serialize($this->getLuceneItemFilter())); @@ -408,7 +383,6 @@ public function update(): void $this->setting->set('search_date_filter', (string) $this->isDateFilterEnabled()); } - // PRIVATE protected function __read() { $this->setMaxHits((int) $this->setting->get('search_max_hits', '10')); @@ -422,7 +396,6 @@ protected function __read() } else { $this->setLastIndexTime(null); } - $this->setHideAdvancedSearch((bool) $this->setting->get('hide_adv_search', '0')); $this->setAutoCompleteLength((int) $this->setting->get('auto_complete_length', (string) $this->getAutoCompleteLength())); $this->enableLuceneItemFilter((bool) $this->setting->get('lucene_item_filter_enabled', (string) $this->isLuceneItemFilterEnabled())); $filter = (string) $this->setting->get('lucene_item_filter', serialize($this->getLuceneItemFilter())); diff --git a/components/ILIAS/Search/classes/class.ilUserSearchCache.php b/components/ILIAS/Search/classes/class.ilUserSearchCache.php index fd1cd72dedcc..1b9be37a6fc5 100755 --- a/components/ILIAS/Search/classes/class.ilUserSearchCache.php +++ b/components/ILIAS/Search/classes/class.ilUserSearchCache.php @@ -17,27 +17,20 @@ *********************************************************************/ declare(strict_types=1); + /** -* Class for storing search result. Allows paging of result sets -* -* -* @author Stefan Meyer -* -* -* @ilCtrl_Calls -* @ingroup ServicesSearch -*/ + * Class for storing search result. Allows paging of result sets + * + * @author Stefan Meyer + */ class ilUserSearchCache { - public const DEFAULT_SEARCH = 0; - public const ADVANCED_SEARCH = 1; - public const ADVANCED_MD_SEARCH = 4; - public const LUCENE_DEFAULT = 5; - public const LUCENE_ADVANCED = 6; + public const int DEFAULT_SEARCH = 0; + public const int LUCENE_DEFAULT = 5; - public const LAST_QUERY = 7; + public const int LAST_QUERY = 7; - public const LUCENE_USER_SEARCH = 8; + public const int LUCENE_USER_SEARCH = 8; private static ?ilUserSearchCache $instance = null; protected ilDBInterface $db; @@ -127,7 +120,7 @@ public function getResults(): array * Set results * * @access public - * @param array(int => array(int,int,string)) array(ref_id => array(ref_id,obj_id,type)) + * @param array $a_results (int => array(int,int,string)) array(ref_id => array(ref_id,obj_id,type)) * */ public function setResults(array $a_results): void @@ -139,7 +132,7 @@ public function setResults(array $a_results): void * Append result * * @access public - * @param array(int,int,string) array(ref_id,obj_id,type) + * @param array $a_result_item (int,int,string) array(ref_id,obj_id,type) * */ public function addResult(array $a_result_item): bool @@ -166,26 +159,11 @@ public function isFailed(int $a_ref_id): bool return in_array($a_ref_id, $this->failed); } - /** - * Append checked id - * - * @access public - * @param int checked reference id - * @param int checked obj_id - * - */ public function appendToChecked(int $a_ref_id, int $a_obj_id): void { $this->checked[$a_ref_id] = $a_obj_id; } - /** - * Check if reference was already checked - * - * @access public - * @param int ref_id - * - */ public function isChecked(int $a_ref_id): bool { return array_key_exists($a_ref_id, $this->checked) and $this->checked[$a_ref_id]; @@ -222,24 +200,13 @@ public function getResultPageNumber(): int return $this->page_number ?: 1; } - /** - * set query - * @param mixed query string or array (for advanced search) - * @return void - */ - public function setQuery($a_query): void + public function setQuery(string $a_query): void { $this->query = $a_query; } - /** - * @return string|array query string or array (for advanced search) - */ - public function getQuery() + public function getQuery(): string { - if (is_array($this->query)) { - return $this->query; - } return $this->query ?? ''; } @@ -248,11 +215,6 @@ public function getQuery() */ public function getUrlEncodedQuery(): string { - if (is_array($this->getQuery())) { - $query = $this->getQuery(); - - return urlencode(str_replace('"', '.', $query['lom_content'])); - } return urlencode(str_replace('"', '.', $this->getQuery())); } @@ -264,10 +226,6 @@ public function setRoot(int $a_root): void $this->root = $a_root; } - /** - * get root node - * @return int - */ public function getRoot(): int { return $this->root ?: ROOT_FOLDER_ID; @@ -303,10 +261,6 @@ public function getCreationFilter(): array return $this->creation_filter; } - - /** - * delete cached entries - */ public function deleteCachedEntries(): void { if ($this->isAnonymous()) { @@ -353,10 +307,6 @@ public function deleteCachedEntries(): void $this->failed = array(); } - /** - * Delete cached entries for anonymous user - * @return bool - */ public function deleteCachedEntriesAnonymous(): bool { $this->setResultPageNumber(1); @@ -367,8 +317,6 @@ public function deleteCachedEntriesAnonymous(): bool return true; } - - public function delete(): bool { $query = "DELETE FROM usr_search " . @@ -436,13 +384,6 @@ public function saveForAnonymous(): void ilSession::set('usr_search_cache', $session_usr_search); } - - /** - * Read user entries - * - * @access private - * - */ private function read(): void { $this->failed = array(); diff --git a/components/ILIAS/Search/templates/default/tpl.lucene_activation_row.html b/components/ILIAS/Search/templates/default/tpl.lucene_activation_row.html deleted file mode 100755 index 402911eef181..000000000000 --- a/components/ILIAS/Search/templates/default/tpl.lucene_activation_row.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - {VAL_TITLE} - - - {TXT_MD_TYPE}: {VAL_TYPE} - - - - - {VAL_TYPE} - - diff --git a/components/ILIAS/Search/templates/default/tpl.lucene_adv_search.html b/components/ILIAS/Search/templates/default/tpl.lucene_adv_search.html deleted file mode 100755 index cd03ee993c84..000000000000 --- a/components/ILIAS/Search/templates/default/tpl.lucene_adv_search.html +++ /dev/null @@ -1,3 +0,0 @@ -{SEARCH_TABLE} -
-{SEARCH_RESULTS} diff --git a/components/ILIAS/Search/templates/default/tpl.range_search.html b/components/ILIAS/Search/templates/default/tpl.range_search.html deleted file mode 100755 index 895f4e24b5b8..000000000000 --- a/components/ILIAS/Search/templates/default/tpl.range_search.html +++ /dev/null @@ -1 +0,0 @@ -{TXT_FROM} {FROM} {TXT_UPTO} {UPTO} \ No newline at end of file diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index cdd60ddfb89c..a1414be631fa 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -15346,13 +15346,9 @@ scov#:#crsv_create_info#:#Wählen Sie ein absolviertes Lernmodul aus, um dafür scov#:#scov_create#:#SCORM-Zertifikat erstellen scov#:#scov_create_info#:#Wählen Sie ein SCORM-Modul, für das Sie ein Zertifikat benötigen search#:#add_members_header#:#Benutzer hinzufügen -search#:#adv_md_search_title#:#Suche in den erweiterten Metadaten search#:#append_results#:#Ergebnisse anhängen search#:#btn_search#:#Suchen search#:#last_search_result#:#Letztes Suchergebnis -search#:#lucene_activate_field#:#Suche aktivieren -search#:#lucene_advanced_settings#:#Erweiterte Suche -search#:#lucene_advanced_settings_table#:#Einstellungen zur erweiterten Suche search#:#lucene_all_occurrences#:#... %s weitere(s) Vorkommen search#:#lucene_and#:#UND search#:#lucene_cpu#:#Anzahl Threads @@ -15401,11 +15397,7 @@ search#:#lucene_size_fragments#:#Länge der Textabschnitte search#:#lucene_tbl_create_ini#:#Java-Server Konfigurationsdatei erstellen search#:#search_add_members_from_container_crs#:#Benutzer aus aktuellem Kurs hinzufügen search#:#search_add_members_from_container_grp#:#Benutzer aus aktueller Gruppe hinzufügen -search#:#search_adv_md#:#Benutzerdefinierte Metadaten -search#:#search_advanced#:#Erweiterte Suche -search#:#search_all_words#:#Alle Begriffe (UND) search#:#search_any#:#-- Beliebig -- -search#:#search_any_word#:#Einen der Begriffe (ODER) search#:#search_area#:#Suchbereich search#:#search_area_info#:#Bitte wählen Sie einen Bereich aus, innerhalb dem die Suche starten soll. search#:#search_auto_complete_length#:#Anzahl der Einträge in Auto-Complete-Liste @@ -15432,12 +15424,10 @@ search#:#search_for_orgu_members_recursive#:#Darunterliegende einbeziehen? search#:#search_for_role_members#:#Nach Rollen suchen search#:#search_for_users#:#Nach Benutzern suchen search#:#search_grp_title#:#Gruppenname -search#:#search_hide_adv_search#:#Erweiterte Suche ausblenden search#:#search_item_filter_form#:#Suche nach Typ search#:#search_item_filter_form_info#:#Suche wird auf die ausgewählten Objekttypen beschränkt. search#:#search_like_info#:#Erlaubt die Suche in der ILIAS-Datenbank ohne Zusatzsoftware. Der Inhalt von Dateien (z. B. PDFs oder HTML-Lernmodule) wird nicht erfasst und deshalb auch nicht als Suchergebnis angezeigt. search#:#search_limit_reached#:#Ihre Suche ergab mehr als %s Treffer. Sie können die Abfrage weiter einschränken, um detailliertere Treffer zu erhalten. -search#:#search_lom#:#LOM Metadaten search#:#search_lucene#:#Lucene-Suche search#:#search_mime_excel#:#Excel-Dateien search#:#search_mime_filter_form#:#Dateitypen-Filter @@ -15454,8 +15444,6 @@ search#:#search_no_match#:#Ihre Suche ergab keine Treffer. search#:#search_no_match_hint#:#Es wurden keine Treffer für Ihre Suchanfrage nach %s gefunden.
Vorschläge:

• Vergewissern Sie sich, dass alle Wörter richtig geschrieben sind.
• Probieren Sie andere Suchbegriffe.
• Probieren Sie allgemeinere Suchbegriffe.
• Probieren Sie weniger Suchbegriffe. search#:#search_no_selection#:#Sie haben keine Auswahl getroffen. search#:#search_off#:#Aus -search#:#search_option_offline#:#Offline -search#:#search_option_online#:#Online search#:#search_role_title#:#Rollenname search#:#search_select_search_area#:#Suchbereich ändern search#:#search_show_inactive_user#:#Inaktive Benutzer anzeigen diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 5182e7b8dbfb..8cfbde3745ce 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -15345,13 +15345,9 @@ scov#:#crsv_create_info#:#Select a completed learning module to generate a certi scov#:#scov_create#:#Create SCORM Certificate scov#:#scov_create_info#:#Select a completed SCORM module to generate a certificate for it search#:#add_members_header#:#Add Members -search#:#adv_md_search_title#:#Search in Custom Metadata search#:#append_results#:#Append results search#:#btn_search#:#Search search#:#last_search_result#:#Last Search Result -search#:#lucene_activate_field#:#Activate Search -search#:#lucene_advanced_settings#:#Advanced Search -search#:#lucene_advanced_settings_table#:#Search Settings search#:#lucene_all_occurrences#:#... %s other occurrence(s) search#:#lucene_and#:#AND search#:#lucene_cpu#:#Maximum Number of Threads @@ -15400,11 +15396,7 @@ search#:#lucene_size_fragments#:#Size of Text Fragments search#:#lucene_tbl_create_ini#:#Create Java-Server Ini-File search#:#search_add_members_from_container_crs#:#Add Users From Current Course search#:#search_add_members_from_container_grp#:#Add Users From Current Group -search#:#search_adv_md#:#Custom Metadata -search#:#search_advanced#:#Advanced Search -search#:#search_all_words#:#All words (AND) search#:#search_any#:#-- Any -- -search#:#search_any_word#:#Any word (OR) search#:#search_area#:#Search Area search#:#search_area_info#:#Please select an area where the search should start. search#:#search_auto_complete_length#:#Number of Auto Complete List Entries @@ -15431,12 +15423,10 @@ search#:#search_for_orgu_members_recursive#:#Include Subunits? search#:#search_for_role_members#:#Search for Roles search#:#search_for_users#:#Search for Users search#:#search_grp_title#:#Group Name -search#:#search_hide_adv_search#:#Hide Advanced Search search#:#search_item_filter_form#:#Search by Type search#:#search_item_filter_form_info#:#Search can be restricted to the chosen object types. search#:#search_like_info#:#Choose this option to get best results.###Needs to be adapted to new content of German lang file. search#:#search_limit_reached#:#Your search produced more than %s hits. You can restrict the search terms to receive more detailed results. -search#:#search_lom#:#LOM Metadata search#:#search_lucene#:#Lucene search search#:#search_mime_excel#:#Excel Files search#:#search_mime_filter_form#:#Mime Type Filter @@ -15453,8 +15443,6 @@ search#:#search_no_match#:#Your search did not match any results. search#:#search_no_match_hint#:#Your search for %s did not match any documents.

Suggestions:
• Make sure all words are spelled correctly.
• Try different keywords.
• Try more general keywords.
• Try fewer keywords. search#:#search_no_selection#:#You made no selection. search#:#search_off#:#Off -search#:#search_option_offline#:#Offline -search#:#search_option_online#:#Online search#:#search_role_title#:#Role Name search#:#search_select_search_area#:#Select Search Area search#:#search_show_inactive_user#:#Show Inactive Users