/** * Show special form for ecs start * * @access private * @param object ilAdvMDFieldDefinition */ private function showECSStart($def) { global $ilUser; $this->lng->loadLanguageModule('ecs'); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; $value_start = ilAdvancedMDValue::_getInstance($this->obj_id, $def->getFieldId()); $unixtime = $value_start->getValue() ? $value_start->getValue() : mktime(8, 0, 0, date('m'), date('d'), date('Y')); $time = new ilDateTimeInputGUI($this->lng->txt('ecs_event_appointment'), 'md[' . $def->getFieldId() . ']'); $time->setShowTime(true); $time->setDate(new ilDateTime($unixtime, IL_CAL_UNIX)); $time->enableDateActivation($this->lng->txt('enabled'), 'md_activated[' . $def->getFieldId() . ']', $value_start->getValue() ? true : false); $time->setDisabled($value_start->isDisabled()); $mapping = ilECSDataMappingSettings::_getInstance(); if ($field_id = $mapping->getMappingByECSName('end')) { $value_end = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); list($hours, $minutes) = $this->parseDuration($value_start->getValue(), $value_end->getValue()); $duration = new ilDurationInputGUI($this->lng->txt('ecs_duration'), 'ecs_duration'); $duration->setHours($hours); $duration->setMinutes($minutes); #$duration->setInfo($this->lng->txt('ecs_duration_info')); $duration->setShowHours(true); $duration->setShowMinutes(true); $time->addSubItem($duration); } if ($field_id = $mapping->getMappingByECSName('cycle')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $cycle_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($cycle_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($cycle_def->getTitle(), 'md[' . $cycle_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } if ($field_id = $mapping->getMappingByECSName('room')) { $value = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $room_def = ilAdvancedMDFieldDefinition::getInstance($field_id); switch ($room_def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(20); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $time->addSubItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($room_def->getTitle(), 'md[' . $room_def->getFieldId() . ']'); $select->setOptions($cycle_def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $time->addSubItem($select); break; } } $this->form->addItem($time); }
/** * Perform advanced meta data search * * @access private * @param obj result object * */ private function searchAdvancedMD($res) { $this->initFormSearch(); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach (array_keys($this->options) as $key) { if (substr($key, 0, 3) != 'adv') { continue; } // :TODO: ? if (!$key) { continue; } $field_id = substr($key, 4); $field = ilAdvancedMDFieldDefinition::getInstance($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); include_once 'Services/Search/classes/class.ilQueryParser.php'; include_once 'Services/Search/classes/class.ilObjectSearchFactory.php'; $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(); if ($res_field instanceof ilSearchResult) { $this->__storeEntries($res, $res_field); } } }
/** * create field * * @access public */ public function saveField() { global $ilErr; if (!$_REQUEST["record_id"] || !$_REQUEST["ftype"]) { return $this->editFields(); } $this->ctrl->saveParameter($this, 'record_id'); $this->ctrl->saveParameter($this, 'ftype'); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $field_definition = ilAdvancedMDFieldDefinition::getInstance(null, $_REQUEST["ftype"]); $field_definition->setRecordId($_REQUEST["record_id"]); $form = $this->initFieldForm($field_definition); if ($form->checkInput()) { $field_definition->importDefinitionFormPostValues($form, $this->getPermissions()); $field_definition->save(); ilUtil::sendSuccess($this->lng->txt('save_settings'), true); $this->ctrl->redirect($this, "editFields"); } $form->setValuesByPost(); $this->createField($form); }
/** * Read active sections */ protected function readSections() { 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 // 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 // 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 // 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 // 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 // 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 // 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); include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; $field = ilAdvancedMDFieldDefinition::getInstance($field_id); $record_id = $field->getRecordId(); $this->active_sections['adv_record_' . $record_id]['fields'][] = $field_name; $this->active_sections['adv_record_' . $record_id]['name'] = ilAdvancedMDRecord::_lookupTitle($record_id); break; } } }