/** * 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; } } }
/** * Perform advanced meta data search * * @access private * @param obj result object * */ private function searchAdvancedMD($res) { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; foreach ($_POST as $key => $value) { if (!is_numeric($key)) { continue; } if (!$value) { continue; } $def = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($key); include_once 'Services/Search/classes/class.ilObjectSearchFactory.php'; include_once 'Services/Search/classes/class.ilQueryParser.php'; if ($def->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_SELECT) { $value = (int) $value; $options = $def->getFieldValues(); if (!isset($options[$value - 1])) { continue; } $value = $options[$value - 1]; } if ($def->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_DATE) { $start = $this->toUnixTime($_POST['date_start'][$key]['date']); $end = $this->toUnixTime($_POST['date_end'][$key]['date']); } if ($def->getFieldType() == ilAdvancedMDFieldDefinition::TYPE_DATETIME) { $start = $this->toUnixTime($_POST['date_start'][$key]['date'], $_POST['date_start'][$key]['time']); $end = $this->toUnixTime($_POST['date_end'][$key]['date'], $_POST['date_end'][$key]['time']); } $query_parser = new ilQueryParser(ilUtil::stripSlashes($value)); if ($_POST['boolean'][$key] == 1) { $query_parser->setCombination('and'); } else { $query_parser->setCombination('or'); } $query_parser->parse(); $adv_md_search = ilObjectSearchFactory::_getAdvancedMDSearchInstance($query_parser); $adv_md_search->setDefinition($def); $adv_md_search->setTimeRange($start, $end); $adv_md_search->setFilter($this->filter); $res_field = $adv_md_search->performSearch(); $this->__storeEntries($res, $res_field); } return $res; }
/** * Load values from post * * @access public * */ public function loadFromPost() { include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php'; include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php'; if (!isset($_POST['md'])) { return false; } foreach ($_POST['md'] as $field_id => $value) { $def = ilAdvancedMDFieldDefinition::_getInstanceByFieldId($field_id); switch ($def->getFieldType()) { case ilAdvancedMDFieldDefinition::TYPE_DATE: if (is_array($value) and $_POST['md_activated'][$field_id]) { $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); $value = $date->get(IL_CAL_UNIX); } else { $value = 0; } break; case ilAdvancedMDFieldDefinition::TYPE_DATETIME: if (is_array($value) and $_POST['md_activated'][$field_id]) { $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); $value = $date->get(IL_CAL_UNIX); } else { $value = 0; } break; default: $value = ilUtil::stripSlashes($value); break; } $val = ilAdvancedMDValue::_getInstance($this->obj_id, $field_id); $val->setValue($value); $this->values[] = $val; unset($value); } $this->loadECSDurationPost(); }
/** * 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; }