/** 
  * Called from ilLuceneAdvancedQueryParser
  * Parse a field specific query
  */
 public function parseFieldQuery($a_field, $a_query)
 {
     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';
             }
             return '';
             // General
         // General
         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
         // Lifecycle
         case 'lom_status':
             return 'lomStatus:' . $a_query;
         case 'lom_version':
             return 'lomVersion:' . $a_query;
             // Begin Contribute
         // Begin Contribute
         case 'lom_role':
             return 'lomRole:' . $a_query;
         case 'lom_role_entry':
             return 'lomRoleEntity:' . $a_query;
             // End contribute
             // Technical
         // 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
         // Educational
         case 'lom_interactivity':
             return 'lomInteractivity:' . $a_query;
         case 'lom_resource':
             return 'lomResource:' . $a_query;
         case 'lom_level_start':
             $q_string = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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
         // Rights
         case 'lom_costs':
             return 'lomCosts:' . $a_query;
         case 'lom_copyright':
             return 'lomCopyright:' . $a_query;
             // Classification
         // 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);
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
             $field = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($field_id);
             switch ($field->getFieldType()) {
                 case ilAdvancedMDFieldDefinition::TYPE_TEXT:
                 case ilAdvancedMDFieldDefinition::TYPE_SELECT:
                     return 'advancedMetaData_' . $field_id . ':' . $a_query;
                 case ilAdvancedMDFieldDefinition::TYPE_DATE:
                     $value = $_POST['adv_' . $field_id . '_start'];
                     $dt['year'] = (int) $value['date']['y'];
                     $dt['mon'] = (int) $value['date']['m'];
                     $dt['mday'] = (int) $value['date']['d'];
                     $dt['hours'] = (int) 0;
                     $dt['minutes'] = (int) 0;
                     $dt['seconds'] = (int) 0;
                     $date = new ilDate($dt, IL_CAL_FKT_GETDATE);
                     $ustart = $date->get(IL_CAL_UNIX);
                     $value = $_POST['adv_' . $field_id . '_end'];
                     $dt['year'] = (int) $value['date']['y'];
                     $dt['mon'] = (int) $value['date']['m'];
                     $dt['mday'] = (int) $value['date']['d'];
                     $dt['hours'] = (int) 0;
                     $dt['minutes'] = (int) 0;
                     $dt['seconds'] = (int) 0;
                     $date = new ilDate($dt, IL_CAL_FKT_GETDATE);
                     $uend = $date->get(IL_CAL_UNIX);
                     return 'advancedMetaData_' . $field_id . ':{' . $ustart . ' TO ' . $uend . '}';
                 case ilAdvancedMDFieldDefinition::TYPE_DATETIME:
                     $value = $_POST['adv_' . $field_id . '_start'];
                     $dt['year'] = (int) $value['date']['y'];
                     $dt['mon'] = (int) $value['date']['m'];
                     $dt['mday'] = (int) $value['date']['d'];
                     $dt['hours'] = (int) $value['time']['h'];
                     $dt['minutes'] = (int) $value['time']['m'];
                     $dt['seconds'] = (int) 0;
                     $date = new ilDateTime($dt, IL_CAL_FKT_GETDATE);
                     $ustart = $date->get(IL_CAL_UNIX);
                     $value = $_POST['adv_' . $field_id . '_end'];
                     $dt['year'] = (int) $value['date']['y'];
                     $dt['mon'] = (int) $value['date']['m'];
                     $dt['mday'] = (int) $value['date']['d'];
                     $dt['hours'] = (int) $value['time']['h'];
                     $dt['minutes'] = (int) $value['time']['m'];
                     $dt['seconds'] = (int) 0;
                     $date = new ilDateTime($dt, IL_CAL_FKT_GETDATE);
                     $uend = $date->get(IL_CAL_UNIX);
                     return 'advancedMetaData_' . $field_id . ':{' . $ustart . ' TO ' . $uend . '}';
             }
             break;
     }
 }
 /** 
  * Called from ilLuceneAdvancedQueryParser
  * Parse a field specific query
  */
 public function parseFieldQuery($a_field, $a_query)
 {
     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';
             }
             return '';
             // General
         // General
         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
         // Lifecycle
         case 'lom_status':
             return 'lomStatus:' . $a_query;
         case 'lom_version':
             return 'lomVersion:' . $a_query;
             // Begin Contribute
         // Begin Contribute
         case 'lom_role':
             return 'lomRole:' . $a_query;
         case 'lom_role_entry':
             return 'lomRoleEntity:' . $a_query;
             // End contribute
             // Technical
         // 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
         // Educational
         case 'lom_interactivity':
             return 'lomInteractivity:' . $a_query;
         case 'lom_resource':
             return 'lomResource:' . $a_query;
         case 'lom_level_start':
             $q_string = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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 = '';
             include_once './Services/MetaData/classes/class.ilMDUtilSelect.php';
             $options = 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
         // Rights
         case 'lom_costs':
             return 'lomCosts:' . $a_query;
         case 'lom_copyright':
             return 'lomCopyright:' . $a_query;
             // Classification
         // 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);
             include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php';
             $field = ilAdvancedMDFieldDefinition::getInstance($field_id);
             $adv_query = $field->getLuceneSearchString($a_query);
             if ($adv_query) {
                 return 'advancedMetaData_' . $field_id . ': ' . $adv_query;
             }
     }
 }