/** * Fill row * * @access public * @param * */ public function fillRow($a_set) { foreach (ilAdvancedMDRecord::_getAssignableObjectTypes(true) as $obj_type) { $this->tpl->setCurrentBlock('ass_obj_types'); $this->tpl->setVariable('VAL_OBJ_TYPE', $obj_type["text"]); $this->tpl->setVariable('ASS_ID', $a_set['id']); $this->tpl->setVariable('ASS_NAME', $obj_type["obj_type"] . ":" . $obj_type["sub_type"]); foreach ($a_set['obj_types'] as $t) { if ($obj_type["obj_type"] == $t["obj_type"] && $obj_type["sub_type"] == $t["sub_type"]) { $this->tpl->setVariable('ASS_CHECKED', 'checked="checked"'); } } $this->tpl->parseCurrentBlock(); } $this->tpl->setVariable('VAL_ID', $a_set['id']); $this->tpl->setVariable('VAL_TITLE', $a_set['title']); if (strlen($a_set['description'])) { $this->tpl->setVariable('VAL_DESCRIPTION', $a_set['description']); } $defs = ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($a_set['id']); if (!count($defs)) { $this->tpl->setVariable('TXT_FIELDS', $this->lng->txt('md_adv_no_fields')); } foreach ($defs as $definition_obj) { $this->tpl->setCurrentBlock('field_entry'); $this->tpl->setVariable('FIELD_NAME', $definition_obj->getTitle()); $this->tpl->parseCurrentBlock(); } $this->tpl->setVariable('ACTIVE_CHECKED', $a_set['active'] ? ' checked="checked" ' : ''); $this->tpl->setVariable('ACTIVE_ID', $a_set['id']); $this->ctrl->setParameter($this->parent_obj, 'record_id', $a_set['id']); $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->parent_obj, 'editRecord')); $this->tpl->setVariable('TXT_EDIT_RECORD', $this->lng->txt('edit')); }
/** * Get all advanced metadata fields */ function getAllFields() { $fields = array(); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php'; $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("glo", $this->glo_id, "term"); foreach ($recs as $record_obj) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record_obj->getRecordId()) as $def) { $fields[$def->getFieldId()] = array("id" => $def->getFieldId(), "title" => $def->getTitle(), "type" => $def->getFieldType()); } } return $fields; }
/** * Clone Advanced Meta Data * * @access public * @static * * @param int source obj_id * @param int target obj_id */ public static function _cloneValues($a_source_id, $a_target_id) { global $ilLog; include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; if (!count($defs = ilAdvancedMDFieldDefinition::_getActiveDefinitionsByObjType(ilObject::_lookupType($a_source_id)))) { $ilLog->write(__METHOD__ . ': No advanced meta data found.'); return true; } $ilLog->write(__METHOD__ . ': Start cloning advanced meta data.'); foreach (self::_getValuesByObjId($a_source_id) as $field_id => $value) { if (!in_array($field_id, $defs)) { continue; } $new_value = new ilAdvancedMDValue($field_id, $a_target_id); $new_value->setValue($value); $new_value->save(); } return true; }
protected function initValue($a_import_id, $a_sub_type = "", $a_sub_id = 0) { $this->current_value = null; if ($field = ilAdvancedMDFieldDefinition::getInstanceByImportId($a_import_id)) { $rec_id = $field->getRecordId(); $new_parent_id = $this->mapping->getMapping("Services/AdvancedMetaData", "parent", $this->obj_id); if (!$new_parent_id) { return; } if ($a_sub_type) { $new_sub_id = $this->mapping->getMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:" . $a_sub_type . ":" . $a_sub_id); if (!$new_sub_id) { return; } $rec_idx = $rec_id . ";" . $a_sub_type . ";" . $new_sub_id; if (!array_key_exists($rec_idx, $this->value_records)) { $this->value_records[$rec_idx] = new ilAdvancedMDValues($rec_id, $new_parent_id, $a_sub_type, $new_sub_id); } } else { $rec_idx = $rec_id . ";;"; if (!array_key_exists($rec_idx, $this->value_records)) { $this->value_records[$rec_idx] = new ilAdvancedMDValues($rec_id, $new_parent_id); } } // init ADTGroup before definitions to bind definitions to group $this->value_records[$rec_idx]->getADTGroup(); foreach ($this->value_records[$rec_idx]->getDefinitions() as $def) { if ($a_import_id == $def->getImportId()) { $this->current_value = $def; break; } } // valid field found, record will be imported if ($this->current_value) { $this->record_ids[$new_parent_id][$a_sub_type][] = $rec_id; } } }
public function update() { parent::update(); if (sizeof($this->confirmed_objects)) { ilADTFactory::initActiveRecordByType(); foreach ($this->confirmed_objects as $old_option => $item_ids) { foreach ($item_ids as $item => $new_option) { $item = explode("_", $item); $obj_id = $item[0]; $sub_type = $item[1]; $sub_id = $item[2]; if (!$new_option) { // remove existing value $primary = array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $sub_type), "sub_id" => array("integer", $sub_id), "field_id" => array("integer", $this->getFieldId())); ilADTActiveRecordByType::deleteByPrimary("adv_md_values", $primary, "Enum"); } else { // update existing value $primary = array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $sub_type), "sub_id" => array("integer", $sub_id), "field_id" => array("integer", $this->getFieldId())); ilADTActiveRecordByType::writeByPrimary("adv_md_values", $primary, "Enum", $new_option); } if ($sub_type == "wpg") { // #15763 - adapt advmd page lists include_once "Modules/Wiki/classes/class.ilPCAMDPageList.php"; ilPCAMDPageList::migrateField($obj_id, $this->getFieldId(), $old_option, $new_option); } } } } }
/** * Add advanced metadata to json (export) * * @param object $a_json * @param ilECSSetting $a_server * @param array $a_definition * @param int $a_mapping_mode */ protected function importMetadataFromJson($a_json, ilECSSetting $a_server, array $a_definition, $a_mapping_mode) { global $ilLog; $ilLog->write("importing metadata from json: " . print_r($a_definition, true)); include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php'; include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'; include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $mappings = ilECSDataMappingSettings::getInstanceByServerId($a_server->getServerId()); foreach ($a_definition as $id => $type) { if (is_array($type)) { $target = $type[1]; $type = $type[0]; } else { $target = $id; } $timePlace = null; if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) { switch ($type) { case ilECSUtils::TYPE_ARRAY: $value = implode(',', (array) $a_json->{$target}); break; case ilECSUtils::TYPE_INT: $value = (int) $a_json->{$target}; break; case ilECSUtils::TYPE_STRING: $value = (string) $a_json->{$target}; break; case ilECSUtils::TYPE_TIMEPLACE: if (!is_object($timePlace)) { include_once './Services/WebServices/ECS/classes/class.ilECSTimePlace.php'; if (is_object($a_json->{$target})) { $timePlace = new ilECSTimePlace(); $timePlace->loadFromJSON($a_json->{$target}); } else { $timePlace = new ilECSTimePlace(); } } switch ($id) { case 'begin': case 'end': $field_type = ilAdvancedMDFieldDefinition::_lookupFieldType($field); if ($field_type == ilAdvancedMDFieldDefinition::TYPE_DATE || $field_type == ilAdvancedMDFieldDefinition::TYPE_DATETIME) { $value = $timePlace->{'getUT' . ucfirst($id)}(); break; } // fallthrough // fallthrough case 'room': case 'cycle': $value = $timePlace->{'get' . ucfirst($id)}(); break; } break; } include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; $mdv = ilAdvancedMDValue::_getInstance($this->getId(), $field); $mdv->toggleDisabledStatus(true); $mdv->setValue($value); $mdv->save(); } } }
/** * init mapping form * * @param int $a_server_id * @return ilPropertyFormGUI $form * * @access protected */ protected function initMappingsForm($a_server_id, $mapping_type) { include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSettings.php'; $mapping_settings = ilECSDataMappingSettings::getInstanceByServerId($a_server_id); $form = new ilPropertyFormGUI(); if ($mapping_type == self::MAPPING_IMPORT) { $form->setTitle($this->lng->txt('ecs_mapping_tbl')); $form->addCommandButton('saveImportMappings', $this->lng->txt('save')); $form->addCommandButton('importMappings', $this->lng->txt('cancel')); } else { $form->setTitle($this->lng->txt('ecs_mapping_exp_tbl')); $form->addCommandButton('saveExportMappings', $this->lng->txt('save')); $form->addCommandButton('exportMappings', $this->lng->txt('cancel')); } $form->setFormAction($this->ctrl->getFormAction($this, 'saveMappings')); if ($mapping_type == self::MAPPING_IMPORT) { $assignments = new ilCustomInputGUI($this->lng->txt('ecs_mapping_crs')); $form->addItem($assignments); } include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $fields = ilAdvancedMDFieldDefinition::getInstancesByObjType('crs'); $options = $this->prepareFieldSelection($fields); // get all optional ecourse fields include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $optional = ilECSUtils::_getOptionalECourseFields(); foreach ($optional as $field_name) { if ($mapping_type == self::MAPPING_IMPORT) { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping' . '[' . ilECSDataMappingSetting::MAPPING_IMPORT_CRS . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_CRS, $field_name)); $select->setOptions($options); $assignments->addSubItem($select); } else { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping' . '[' . ilECSDataMappingSetting::MAPPING_EXPORT . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_EXPORT, $field_name)); $select->setOptions($options); $form->addItem($select); } } $server = new ilHiddenInputGUI('ecs_mapping_server'); $server->setValue($a_server_id); $form->addItem($server); // Remote courses // no remote course settings for export if ($mapping_type == self::MAPPING_EXPORT) { return $form; } $rcrs = new ilCustomInputGUI($this->lng->txt('ecs_mapping_rcrs')); $form->addItem($rcrs); include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $fields = ilAdvancedMDFieldDefinition::getInstancesByObjType('rcrs'); $options = $this->prepareFieldSelection($fields); // get all optional econtent fields include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $optional = ilECSUtils::_getOptionalEContentFields(); foreach ($optional as $field_name) { $select = new ilSelectInputGUI($this->lng->txt('ecs_field_' . $field_name), 'mapping[' . ilECSDataMappingSetting::MAPPING_IMPORT_RCRS . '][' . $field_name . ']'); $select->setValue($mapping_settings->getMappingByECSName(ilECSDataMappingSetting::MAPPING_IMPORT_RCRS, $field_name)); $select->setOptions($options); $rcrs->addSubItem($select); } return $form; }
/** * Query data for given object records * * @param * @return */ public static function queryForRecords($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter = null) { $result = array(); if (!is_array($a_obj_id)) { $a_obj_id = array($a_obj_id); } $sub_obj_ids = array(); foreach ($a_records as $rec) { $sub_obj_ids[] = $rec[$a_obj_subid_key]; } // preload adv data for object id(s) ilADTFactory::getInstance()->initActiveRecordByType(); ilADTActiveRecordByType::preloadByPrimary("adv_md_values", array("obj_id" => array("integer", $a_obj_id), "sub_type" => array("text", $a_subtype), "sub_id" => array("integer", $sub_obj_ids))); $record_groups = array(); foreach ($a_records as $rec) { $obj_id = $rec[$a_obj_id_key]; $sub_id = $rec[$a_obj_subid_key]; // only active amet records for glossary foreach (ilAdvancedMDRecord::_getSelectedRecordsByObject(ilObject::_lookupType($obj_id), $obj_id, $a_subtype) as $adv_record) { $record_id = $adv_record->getRecordId(); if (!isset($record_groups[$record_id])) { $defs = ilAdvancedMDFieldDefinition::getInstancesByRecordId($record_id); $record_groups[$record_id] = ilAdvancedMDFieldDefinition::getADTGroupForDefinitions($defs); $record_groups[$record_id] = ilADTFactory::getInstance()->getDBBridgeForInstance($record_groups[$record_id]); $record_groups[$record_id]->setTable("adv_md_values"); } // prepare ADT group for record id $record_groups[$record_id]->setPrimary(array("obj_id" => array("integer", $obj_id), "sub_type" => array("text", $a_subtype), "sub_id" => array("integer", $sub_id))); // multi-enum fakes single in adv md foreach ($record_groups[$record_id]->getElements() as $element) { if ($element->getADT()->getType() == "MultiEnum") { $element->setFakeSingle(true); } } // read (preloaded) data $active_record = new ilADTActiveRecordByType($record_groups[$record_id]); $active_record->setElementIdColumn("field_id", "integer"); $active_record->read(); $adt_group = $record_groups[$record_id]->getADT(); // filter against amet values if ($a_amet_filter) { foreach ($a_amet_filter as $field_id => $element) { if ($adt_group->hasElement($field_id)) { if (!$element->isInCondition($adt_group->getElement($field_id))) { continue 3; } } } } // add amet values to glossary term record foreach ($adt_group->getElements() as $element_id => $element) { if (!$element->isNull()) { // we are reusing the ADT group for all $a_records, so we need to clone $pb = ilADTFactory::getInstance()->getPresentationBridgeForInstance(clone $element); $rec["md_" . $element_id] = $pb->getSortable(); $rec["md_" . $element_id . "_presentation"] = $pb; } else { $rec["md_" . $element_id] = null; } } } $results[] = $rec; } return $results; }
/** * 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; } } }
/** * init new value object * * @access private * @param string import id * */ private function initValue($a_import_id) { if ($field_id = ilAdvancedMDFieldDefinition::_lookupFieldId($a_import_id)) { $this->current_value = new ilAdvancedMDValue($field_id, $this->obj_id); $this->values[] = $this->current_value; } else { $this->current_value = null; } }
/** * 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; }
/** * 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; }
/** * Init field definition object * * @access private * @param string import id * */ private function initFieldObject($a_id, $a_type) { switch ($this->getMode()) { case self::MODE_INSERT: case self::MODE_INSERT_VALIDATION: $this->current_field = ilAdvancedMDFieldDefinition::getInstanceByTypeString($a_type); $this->fields[] = $this->current_field; return true; default: // ??? nonsense $this->current_field = ilAdvancedMDRecord::_getInstanceByFieldId($this->extractFieldId($a_id)); return true; break; } }
/** * 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 = new ilAdvancedMDFieldDefinition($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 = new ilAdvancedMDFieldDefinition($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); }
/** * set sub tabs * * @access public * */ public function setSubTabs() { global $ilTabs; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; if (!count(ilAdvancedMDFieldDefinition::_getSearchableDefinitionIds())) { return true; } $ilTabs->addSubTabTarget('search_lom', $this->ctrl->getLinkTarget($this, 'showSavedResults')); #$ilTabs->addSubTabTarget('search_adv_md',$this->ctrl->getLinkTarget($this,'showSavedAdvMDResults')); }
public function update() { parent::update(); if (sizeof($this->confirmed_objects)) { ilADTFactory::initActiveRecordByType(); foreach ($this->confirmed_objects as $old_option => $obj_ids) { foreach ($obj_ids as $obj_id => $new_option) { if (!$new_option) { // remove existing value $primary = array("obj_id" => array("integer", $obj_id), "field_id" => array("integer", $this->getFieldId())); ilADTActiveRecordByType::deleteByPrimary("adv_md_values", $primary, "Enum"); } else { // update existing value $primary = array("obj_id" => array("integer", $obj_id), "field_id" => array("integer", $this->getFieldId())); ilADTActiveRecordByType::writeByPrimary("adv_md_values", $primary, "Enum", $new_option); } } } } }
protected function findPages($a_list_id) { global $ilDB; $list_values = $this->getFieldValues($a_list_id); $wiki_id = $this->getPage()->getWikiId(); $found_result = array(); // only search in active fields $found_ids = null; $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $wiki_id, "wpg"); foreach ($recs as $record) { foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record->getRecordId(), true) as $field) { if (isset($list_values[$field->getFieldId()])) { $field_form = ilADTFactory::getInstance()->getSearchBridgeForDefinitionInstance($field->getADTDefinition(), true, false); $field->setSearchValueSerialized($field_form, $list_values[$field->getFieldId()]); $found_pages = $field->searchSubObjects($field_form, $wiki_id, "wpg"); if (is_array($found_ids)) { $found_ids = array_intersect($found_ids, $found_pages); } else { $found_ids = $found_pages; } } } } if (sizeof($found_ids)) { $sql = "SELECT id,title FROM il_wiki_page" . " WHERE " . $ilDB->in("id", $found_ids, "", "integer") . " ORDER BY title"; $set = $ilDB->query($sql); while ($row = $ilDB->fetchAssoc($set)) { $found_result[$row["id"]] = $row["title"]; } } return $found_result; }
/** * Read db entries * * @access private * */ private function read() { global $ilDB; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $this->date_fields = ilAdvancedMDFieldDefinition::_lookupDateFields(); $this->datetime_fields = ilAdvancedMDFieldDefinition::_lookupDatetimeFields(); // Check active status $query = "SELECT active,field_id,amfd.title FROM adv_md_record amr " . "JOIN adv_md_record_objs amro ON amr.record_id = amro.record_id " . "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " . "WHERE active = 1 " . "AND obj_type = " . $this->db->quote($this->type, 'text') . " "; $res = $this->db->query($query); $this->active = $res->numRows() ? true : false; while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->active_fields[$row->field_id] = $row->title; } $query = "SELECT * FROM adv_md_substitutions " . "WHERE obj_type = " . $this->db->quote($this->type, 'text') . " "; $res = $this->db->query($query); $this->substitutions = array(); $this->bold = array(); $this->newline = array(); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $tmp_substitutions = unserialize($row->substitution); if (is_array($tmp_substitutions)) { foreach ($tmp_substitutions as $substitution) { if ($substitution['field_id']) { $this->substitutions[] = $substitution['field_id']; } if ($substitution['bold']) { $this->bold[] = $substitution['field_id']; } if ($substitution['newline']) { $this->newline[] = $substitution['field_id']; } } } $this->enabled_desc = !$row->hide_description; $this->enabled_field_names = !$row->hide_field_names; } if ($this->type == 'crs' or $this->type == 'rcrs') { // Handle ECS substitutions /* if($begin = self::$mappings->getMappingByECSName('begin') and $end = self::$mappings->getMappingByECSName('end')) { // Show something like 'Monday, 30.12.2008 9:00 - 12:00' unset($this->active_fields[$end]); } */ } }
/** * 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; }
/** * Parse table cells */ private function parseTableCells() { global $ilUser; $data = $this->getRowData(); $html = ""; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.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); } foreach ($recs as $record_obj) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($record_obj->getRecordId()) as $def) { if ($this->handleECSDefinitions($def)) { continue; } $html .= "<td class='std'>" . $data['md_' . $def->getFieldId()] . "</td>"; } } return $html; }
/** * To Xml. * This method writes only the subset Record (including all fields) * Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation. * * @access public * @param object ilXmlWriter * */ public function toXML(ilXmlWriter $writer) { $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0, 'id' => $this->generateImportId())); $writer->xmlElement('Title', null, $this->getTitle()); $writer->xmlElement('Description', null, $this->getDescription()); foreach ($this->getAssignedObjectTypes() as $obj_type) { $writer->xmlElement('ObjectType', null, $obj_type); } include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach (ilAdvancedMDFieldDefinition::_getDefinitionsByRecordId($this->getRecordId()) as $definition) { $definition->toXML($writer); } $writer->xmlEndTag('Record'); }
/** * append value xml * * @access public * @param object instance of ilXmlWriter * */ public function appendXML($xml_writer) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; $xml_writer->xmlElement('Value', array('id' => ilAdvancedMDFieldDefinition::_lookupImportId($this->field_id)), $this->getValue()); }