public function addToForm() { if ($this->getTitle()) { $section = new ilFormSectionHeaderGUI(); $section->setTitle($this->getTitle()); if ($this->getInfo()) { $section->setInfo($this->getInfo()); } $this->getForm()->addItem($section); } $this->prepareElements(); foreach ($this->elements as $element) { $element->addToForm(); } }
/** * Parse search */ private function parseSearch() { // this is NOT used for the global search, see ilLuceneAdvancedSearchFields::getFormElement() // (so searchable flag is NOT relevant) // // current usage: wiki page element "[amd] page list" $this->lng->loadLanguageModule('search'); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; if ($this->getSelectedOnly()) { $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject($this->obj_type, $this->obj_id, $this->sub_type); } else { $recs = ilAdvancedMDRecord::_getActivatedRecordsByObjectType($this->obj_type, $this->sub_type); } $this->search_form = array(); foreach ($recs as $record) { $section = new ilFormSectionHeaderGUI(); $section->setTitle($record->getTitle()); $section->setInfo($record->getDescription()); $this->form->addItem($section); foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field) { $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false); $field_form->setForm($this->form); $field_form->setElementId("advmd[" . $field->getFieldId() . "]"); $field_form->setTitle($field->getTitle()); if (is_array($this->search_form_values) && isset($this->search_form_values[$field->getFieldId()])) { $field->setSearchValueSerialized($field_form, $this->search_form_values[$field->getFieldId()]); } $field->prepareElementForSearch($field_form); $field_form->addToForm(); $this->search_form[$field->getFieldId()] = array("def" => $field, "value" => $field_form); } } }
/** * Parse property form in editor mode * * @access private * */ private function parseEditor() { global $ilUser; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType($this->obj_type) as $record_obj) { $section = new ilFormSectionHeaderGUI(); $section->setTitle($record_obj->getTitle()); $section->setInfo($record_obj->getDescription()); $this->form->addItem($section); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record_obj->getRecordId()) as $def) { if ($this->handleECSDefinitions($def)) { continue; } include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; $value = ilAdvancedMDValue::_getInstance($this->obj_id, $def->getFieldId()); switch ($def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_TEXT: $text = new ilTextInputGUI($def->getTitle(), 'md[' . $def->getFieldId() . ']'); $text->setValue($value->getValue()); $text->setSize(40); $text->setMaxLength(512); $text->setDisabled($value->isDisabled()); $text->setInfo($def->getDescription()); $this->form->addItem($text); break; case ilAdvancedMDFieldDefinition::TYPE_SELECT: $select = new ilSelectInputGUI($def->getTitle(), 'md[' . $def->getFieldId() . ']'); $select->setOptions($def->getFieldValuesForSelect()); $select->setValue($value->getValue()); $select->setDisabled($value->isDisabled()); $select->setInfo($def->getDescription()); $this->form->addItem($select); break; case ilAdvancedMDFieldDefinition::TYPE_DATE: $unixtime = $value->getValue() ? $value->getValue() : mktime(8, 0, 0, date('m'), date('d'), date('Y')); $time = new ilDateTimeInputGUI($def->getTitle(), 'md[' . $def->getFieldId() . ']'); $time->setShowTime(false); $time->setDate(new ilDate($unixtime, IL_CAL_UNIX)); $time->enableDateActivation($this->lng->txt('enabled'), 'md_activated[' . $def->getFieldId() . ']', $value->getValue() ? true : false); $time->setDisabled($value->isDisabled()); $time->setInfo($def->getDescription()); $this->form->addItem($time); break; case ilAdvancedMDFieldDefinition::TYPE_DATETIME: $unixtime = $value->getValue() ? $value->getValue() : mktime(8, 0, 0, date('m'), date('d'), date('Y')); $time = new ilDateTimeInputGUI($def->getTitle(), 'md[' . $def->getFieldId() . ']'); $time->setShowTime(true); $time->setDate(new ilDateTime($unixtime, IL_CAL_UNIX, $ilUser->getTimeZone())); $time->enableDateActivation($this->lng->txt('enabled'), 'md_activated[' . $def->getFieldId() . ']', $value->getValue() ? true : false); $time->setDisabled($value->isDisabled()); $this->form->addItem($time); break; } } } }