/** * get options for field selection * @param array array of field objects * @access protected */ protected function prepareFieldSelection($fields) { include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; $options[0] = $this->lng->txt('ecs_ignore_field'); foreach ($fields as $field) { $field = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($field); $title = ilAdvancedMDRecord::_lookupTitle($field->getRecordId()); $options[$field->getFieldId()] = $title . ': ' . $field->getTitle(); } return $options; }
/** * 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::_getInstanceByFieldId($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; } } }
private function parseInfoPage() { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; include_once 'Services/ADT/classes/class.ilADTFactory.php'; foreach (ilAdvancedMDValues::getInstancesForObjectId($this->obj_id, $this->obj_type) as $record_id => $a_values) { // this correctly binds group and definitions $a_values->read(); $this->info->addSection(ilAdvancedMDRecord::_lookupTitle($record_id)); $defs = $a_values->getDefinitions(); foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) { if (!$element->isNull()) { $this->info->addProperty($defs[$element_id]->getTitle(), ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getHTML()); } } } }
/** * init form table 'substitutions' * * @access protected */ protected function initFormSubstitutions() { include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; if (!($visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType())) { return; } $this->form = new ilPropertyFormGUI(); $this->form->setFormAction($this->ctrl->getFormAction($this)); #$this->form->setTableWidth('100%'); // substitution foreach ($visible_records as $obj_type => $records) { $perm = null; // :TODO: hardwird ? if (in_array($obj_type, array("crs", "cat"))) { $perm = $this->getPermissions()->hasPermissions(ilAdvancedMDPermissionHelper::CONTEXT_SUBSTITUTION, $obj_type, array(ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_SHOW_DESCRIPTION, ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_SHOW_FIELDNAMES, ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_FIELD_POSITIONS)); } include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php'; $sub = ilAdvancedMDSubstitution::_getInstanceByObjectType($obj_type); // Show section $section = new ilFormSectionHeaderGUI(); $section->setTitle($this->lng->txt('objs_' . $obj_type)); $this->form->addItem($section); $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_desc_show')); $check->setChecked($sub->isDescriptionEnabled() ? true : false); $this->form->addItem($check); if ($perm && !$perm[ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_SHOW_DESCRIPTION]) { $check->setDisabled(true); } $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_fields_show')); $check->setChecked($sub->enabledFieldNames() ? true : false); $this->form->addItem($check); if ($perm && !$perm[ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_SHOW_FIELDNAMES]) { $check->setDisabled(true); } #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type); #$area->setUseRte(true); #$area->setRteTagSet('standard'); #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString())); #$area->setRows(5); #$area->setCols(80); #$this->form->addItem($area); if ($perm) { $perm_pos = $perm[ilAdvancedMDPermissionHelper::ACTION_SUBSTITUTION_FIELD_POSITIONS]; } $definitions = ilAdvancedMDFieldDefinition::getInstancesByObjType($obj_type); $definitions = $sub->sortDefinitions($definitions); $counter = 1; foreach ($definitions as $def) { $definition_id = $def->getFieldId(); $perm = $this->getSubstitutionFieldPermissions($obj_type, $definition_id); $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId()); $title = $def->getTitle() . ' (' . $title . ')'; $check = new ilCheckboxInputGUI($title, 'show[' . $obj_type . '][' . $definition_id . ']'); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_show')); $check->setChecked($sub->isSubstituted($definition_id)); if ($perm && !$perm["show"]) { $check->setDisabled(true); } $pos = new ilNumberInputGUI($this->lng->txt('position'), 'position[' . $obj_type . '][' . $definition_id . ']'); $pos->setSize(3); $pos->setMaxLength(4); $pos->allowDecimals(true); $pos->setValue(sprintf('%.1f', $counter++)); $check->addSubItem($pos); if ($perm && !$perm_pos) { $pos->setDisabled(true); } $bold = new ilCheckboxInputGUI($this->lng->txt('bold'), 'bold[' . $obj_type . '][' . $definition_id . ']'); $bold->setValue(1); $bold->setChecked($sub->isBold($definition_id)); $check->addSubItem($bold); if ($perm && !$perm["bold"]) { $bold->setDisabled(true); } $bold = new ilCheckboxInputGUI($this->lng->txt('newline'), 'newline[' . $obj_type . '][' . $definition_id . ']'); $bold->setValue(1); $bold->setChecked($sub->hasNewline($definition_id)); $check->addSubItem($bold); if ($perm && !$perm["newline"]) { $bold->setDisabled(true); } $this->form->addItem($check); } // placeholder /* $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders')); $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData'); foreach($records as $record) { foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition) { $tpl->setCurrentBlock('field'); $tpl->setVariable('FIELD_NAME',$definition->getTitle()); $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'. '[/IF_F_'.$definition->getFieldId().']'); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('record'); $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for')); $tpl->setVariable('TITLE',$record->getTitle()); $tpl->parseCurrentBlock(); } $custom->setHTML($tpl->get()); $this->form->addItem($custom); */ } $this->form->setTitle($this->lng->txt('md_adv_substitution_table')); $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save')); return true; }
/** * Add Advanced Meta Data Information to the Info Screen * * @param ilInfoScreenGUI $info */ protected function parseInfoScreen(ilInfoScreenGUI $info) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; include_once 'Services/ADT/classes/class.ilADTFactory.php'; $type = $this->object->getOrgUnitType(); if (!$type) { return; } $assigned_record_ids = $type->getAssignedAdvancedMDRecordIds(); foreach (ilAdvancedMDValues::getInstancesForObjectId($this->object->getId(), 'orgu') as $record_id => $a_values) { // Skip record ids not assigned to the type if (!in_array($record_id, $assigned_record_ids)) { continue; } // Note that we have to do this because with the instances above the sub-type and sub-id are missing... $a_values = new ilAdvancedMDValues($record_id, $this->object->getId(), 'orgu_type', $this->object->getOrgUnitTypeId()); // this correctly binds group and definitions $a_values->read(); $info->addSection(ilAdvancedMDRecord::_lookupTitle($record_id)); $defs = $a_values->getDefinitions(); foreach ($a_values->getADTGroup()->getElements() as $element_id => $element) { if (!$element->isNull()) { $info->addProperty($defs[$element_id]->getTitle(), ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getHTML()); } } } }
/** * init form table 'substitutions' * * @access protected */ protected function initFormSubstitutions() { include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; if (!($visible_records = ilAdvancedMDRecord::_getAllRecordsByObjectType())) { return true; } $this->form = new ilPropertyFormGUI(); $this->form->setFormAction($this->ctrl->getFormAction($this)); #$this->form->setTableWidth('100%'); // substitution foreach ($visible_records as $obj_type => $records) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDSubstitution.php'; $sub = ilAdvancedMDSubstitution::_getInstanceByObjectType($obj_type); // Show section $section = new ilFormSectionHeaderGUI(); $section->setSectionIcon(ilUtil::getImagePath('icon_' . $obj_type . '_s.png'), $this->lng->txt('objs_' . $obj_type)); $section->setTitle($this->lng->txt('objs_' . $obj_type)); $this->form->addItem($section); $check = new ilCheckboxInputGUI($this->lng->txt('description'), 'enabled_desc_' . $obj_type); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_desc_show')); $check->setChecked($sub->isDescriptionEnabled() ? true : false); $this->form->addItem($check); $check = new ilCheckboxInputGUI($this->lng->txt('md_adv_field_names'), 'enabled_field_names_' . $obj_type); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_fields_show')); $check->setChecked($sub->enabledFieldNames() ? true : false); $this->form->addItem($check); #$area = new ilTextAreaInputGUI($this->lng->txt('md_adv_substitution'),'substitution_'.$obj_type); #$area->setUseRte(true); #$area->setRteTagSet('standard'); #$area->setValue(ilUtil::prepareFormOutput($sub->getSubstitutionString())); #$area->setRows(5); #$area->setCols(80); #$this->form->addItem($area); $definitions = ilAdvancedMDFieldDefinition::_getActiveDefinitionsByObjType($obj_type); $definitions = $sub->sortDefinitions($definitions); $counter = 1; foreach ($definitions as $definition_id) { $def = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($definition_id); if ($def->isDeleted()) { continue; } $title = ilAdvancedMDRecord::_lookupTitle($def->getRecordId()); $title = $def->getTitle() . ' (' . $title . ')'; $check = new ilCheckboxInputGUI($title, 'show[' . $obj_type . '][' . $definition_id . ']'); $check->setValue(1); $check->setOptionTitle($this->lng->txt('md_adv_show')); $check->setChecked($sub->isSubstituted($definition_id)); $pos = new ilTextInputGUI($this->lng->txt('position'), 'position[' . $obj_type . '][' . $definition_id . ']'); $pos->setSize(3); $pos->setMaxLength(4); $pos->setValue(sprintf('%.1f', $counter++)); $check->addSubItem($pos); $bold = new ilCheckboxInputGUI($this->lng->txt('bold'), 'bold[' . $obj_type . '][' . $definition_id . ']'); $bold->setValue(1); $bold->setChecked($sub->isBold($definition_id)); $check->addSubItem($bold); $bold = new ilCheckboxInputGUI($this->lng->txt('newline'), 'newline[' . $obj_type . '][' . $definition_id . ']'); $bold->setValue(1); $bold->setChecked($sub->hasNewline($definition_id)); $check->addSubItem($bold); $this->form->addItem($check); } // placeholder /* $custom = new ilCustomInputGUI($this->lng->txt('md_adv_placeholders')); $tpl = new ilTemplate('tpl.placeholder_info.html',true,true,'Services/AdvancedMetaData'); foreach($records as $record) { foreach(ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record->getRecordId()) as $definition) { $tpl->setCurrentBlock('field'); $tpl->setVariable('FIELD_NAME',$definition->getTitle()); $tpl->setVariable('MODULE_VARS','[IF_F_'.$definition->getFieldId().']...[F_'.$definition->getFieldId().']'. '[/IF_F_'.$definition->getFieldId().']'); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock('record'); $tpl->setVariable('PLACEHOLDER_FOR',$this->lng->txt('md_adv_placeholder_for')); $tpl->setVariable('TITLE',$record->getTitle()); $tpl->parseCurrentBlock(); } $custom->setHTML($tpl->get()); $this->form->addItem($custom); */ } $this->form->setTitle($this->lng->txt('md_adv_substitution_table')); $this->form->addCommandButton('updateSubstitutions', $this->lng->txt('save')); return true; }