public function getFormElement($a_query, $a_field_name)
 {
     include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
     $a_post_name = 'query[' . $a_field_name . ']';
     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
         // General
         case 'lom_language':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_language']);
             $select->setOptions(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(ilMDUtilSelect::_getStructureSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Lifecycle
         // Lifecycle
         case 'lom_status':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_status']);
             $select->setOptions(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(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
         // Technical
         case 'lom_format':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_format']);
             $select->setOptions(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(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(ilMDUtilSelect::_getBrowserSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Education
         // Education
         case 'lom_interactivity':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_interactivity']);
             $select->setOptions(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(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'), ilMDUtilSelect::_getInteractivityLevelSelect($a_query['lom_level_start'], 'query[' . 'lom_level_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), 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'), ilMDUtilSelect::_getSemanticDensitySelect($a_query['lom_density_start'], 'query[' . 'lom_density_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), 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(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(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'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_start'], 'query[' . 'lom_difficulty_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_end'], 'query[' . 'lom_difficulty_end' . ']', array(0 => $this->lng->txt('search_any'))));
             $range->setHTML($html);
             return $range;
             // Rights
         // Rights
         case 'lom_costs':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_costs']);
             $select->setOptions(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(ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Classification
         // Classification
         case 'lom_purpose':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_purpose']);
             $select->setOptions(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);
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
             $field = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($field_id);
             switch ($field->getFieldType()) {
                 case ilAdvancedMDFieldDefinition::TYPE_TEXT:
                     $text = new ilTextInputGUI($this->active_fields[$a_field_name], $a_post_name);
                     $text->setSubmitFormOnEnter(true);
                     $text->setValue($a_query[$a_field_name]);
                     $text->setSize(30);
                     $text->setMaxLength(255);
                     return $text;
                 case ilAdvancedMDFieldDefinition::TYPE_SELECT:
                     $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
                     $select->setValue($a_query[$a_field_name]);
                     $select->setOptions($field->getFieldValuesForSearch());
                     return $select;
                 case ilAdvancedMDFieldDefinition::TYPE_DATE:
                 case ilAdvancedMDFieldDefinition::TYPE_DATETIME:
                     $check = new ilCheckboxInputGUI($this->active_fields[$a_field_name], $a_post_name);
                     $check->setValue(1);
                     $check->setChecked($a_query[$a_field_name]);
                     $time = new ilDateTimeInputGUI($this->lng->txt('from'), $a_field_name . '_start');
                     $time->setShowTime($field->getFieldType() != ilAdvancedMDFieldDefinition::TYPE_DATE);
                     $time->setDate(new ilDateTime(mktime(8, 0, 0, date('m'), date('d'), date('Y')), IL_CAL_UNIX));
                     $check->addSubItem($time);
                     $time = new ilDateTimeInputGUI($this->lng->txt('until'), $a_field_name . '_end');
                     $time->setShowTime($field->getFieldType() != ilAdvancedMDFieldDefinition::TYPE_DATE);
                     $time->setDate(new ilDateTime(mktime(16, 0, 0, date('m'), date('d'), date('Y')), IL_CAL_UNIX));
                     $check->addSubItem($time);
                     return $check;
             }
     }
     return null;
 }
 public function getFormElement($a_query, $a_field_name, ilPropertyFormGUI $a_form)
 {
     include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
     $a_post_name = 'query[' . $a_field_name . ']';
     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
         // General
         case 'lom_language':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_language']);
             $select->setOptions(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(ilMDUtilSelect::_getStructureSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Lifecycle
         // Lifecycle
         case 'lom_status':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_status']);
             $select->setOptions(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(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
         // Technical
         case 'lom_format':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_format']);
             $select->setOptions(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(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(ilMDUtilSelect::_getBrowserSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Education
         // Education
         case 'lom_interactivity':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_interactivity']);
             $select->setOptions(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(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'), ilMDUtilSelect::_getInteractivityLevelSelect($a_query['lom_level_start'], 'query[' . 'lom_level_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), 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'), ilMDUtilSelect::_getSemanticDensitySelect($a_query['lom_density_start'], 'query[' . 'lom_density_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), 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(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(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'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_start'], 'query[' . 'lom_difficulty_start' . ']', array(0 => $this->lng->txt('search_any'))), $this->lng->txt('until'), ilMDUtilSelect::_getDifficultySelect($a_query['lom_difficulty_end'], 'query[' . 'lom_difficulty_end' . ']', array(0 => $this->lng->txt('search_any'))));
             $range->setHTML($html);
             return $range;
             // Rights
         // Rights
         case 'lom_costs':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_costs']);
             $select->setOptions(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(ilMDUtilSelect::_getCopyrightAndOtherRestrictionsSelect('', $a_field_name, array(0 => $this->lng->txt('search_any')), true));
             return $select;
             // Classification
         // Classification
         case 'lom_purpose':
             $select = new ilSelectInputGUI($this->active_fields[$a_field_name], $a_post_name);
             $select->setValue($a_query['lom_purpose']);
             $select->setOptions(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);
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
             $field = ilAdvancedMDFieldDefinition::getInstance($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();
             // reload search values
             if (isset($a_query[$a_field_name])) {
                 $field_form->importFromPost($a_query);
                 $field_form->validate();
             }
             return;
     }
     return null;
 }