/** * get matching category * * @param object $econtent ilECSEcontent * @return * @static */ public static function getMatchingCategory($a_server_id, $a_matchable_content) { global $ilLog; if (is_null(self::$cached_active_rules)) { self::$cached_active_rules = self::getActiveRules(); } foreach (self::$cached_active_rules as $rule) { if ($rule->matches($a_matchable_content)) { $ilLog->write(__METHOD__ . ': Found assignment for field type: ' . $rule->getFieldName()); return $rule->getContainerId(); } $ilLog->write(__METHOD__ . ': Category assignment failed for field: ' . $rule->getFieldName()); } // Return default container $ilLog->write(__METHOD__ . ': Using default container'); return ilECSSetting::getInstanceByServerId($a_server_id)->getImportId(); }
/** * Init category mapping form * @return */ protected function initCategoryMappingForm($a_mode = 'add') { global $ilDB; if (is_object($this->form)) { return true; } include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; include_once './Services/WebServices/ECS/classes/class.ilECSCategoryMappingRule.php'; $this->form = new ilPropertyFormGUI(); if ($a_mode == 'add') { $this->form->setTitle($this->lng->txt('ecs_new_category_mapping')); $this->form->setFormAction($this->ctrl->getFormAction($this, 'categoryMapping')); $this->form->addCommandButton('addCategoryMapping', $this->lng->txt('save')); $this->form->addCommandButton('categoryMapping', $this->lng->txt('cancel')); } else { $this->form->setTitle($this->lng->txt('ecs_edit_category_mapping')); $this->form->setFormAction($this->ctrl->getFormAction($this, 'editCategoryMapping')); $this->form->addCommandButton('updateCategoryMapping', $this->lng->txt('save')); $this->form->addCommandButton('categoryMapping', $this->lng->txt('cancel')); } $imp = new ilCustomInputGUI($this->lng->txt('ecs_import_id'), 'import_id'); $imp->setRequired(true); $tpl = new ilTemplate('tpl.ecs_import_id_form.html', true, true, 'Services/WebServices/ECS'); $tpl->setVariable('SIZE', 5); $tpl->setVariable('MAXLENGTH', 11); $tpl->setVariable('POST_VAR', 'import_id'); $tpl->setVariable('PROPERTY_VALUE', $this->rule->getContainerId()); if ($this->settings->getImportId()) { $tpl->setVariable('COMPLETE_PATH', $this->buildPath($this->rule->getContainerId())); } $imp->setHTML($tpl->get()); $imp->setInfo($this->lng->txt('ecs_import_id_info')); $this->form->addItem($imp); include_once './Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php'; $select = new ilSelectInputGUI($this->lng->txt('ecs_attribute_name'), 'field'); $select->setValue($this->rule->getFieldName()); $select->setRequired(true); $select->setOptions(ilECSCategoryMapping::getPossibleFields()); $this->form->addItem($select); // Value $value = new ilRadioGroupInputGUI($this->lng->txt('ecs_cat_mapping_type'), 'type'); $value->setValue($this->rule->getMappingType()); $value->setRequired(true); $fixed = new ilRadioOption($this->lng->txt('ecs_cat_mapping_fixed'), ilECSCategoryMappingRule::TYPE_FIXED); $fixed->setInfo($this->lng->txt('ecs_cat_mapping_fixed_info')); $fixed_val = new ilTextInputGUI($this->lng->txt('ecs_cat_mapping_values'), 'mapping_value'); $fixed_val->setValue($this->rule->getMappingValue()); $fixed_val->setMaxLength(255); $fixed_val->setSize(40); $fixed_val->setRequired(true); $fixed->addSubItem($fixed_val); $value->addOption($fixed); $duration = new ilRadioOption($this->lng->txt('ecs_cat_mapping_duration'), ilECSCategoryMappingRule::TYPE_DURATION); $duration->setInfo($this->lng->txt('ecs_cat_mapping_duration_info')); $dur_start = new ilDateTimeInputGUI($this->lng->txt('from'), 'dur_begin'); $dur_start->setDate($this->rule->getDateRangeStart()); $duration->addSubItem($dur_start); $dur_end = new ilDateTimeInputGUI($this->lng->txt('to'), 'dur_end'); $dur_end->setDate($this->rule->getDateRangeEnd()); $duration->addSubItem($dur_end); $value->addOption($duration); $type = new ilRadioOption($this->lng->txt('ecs_cat_mapping_by_type'), ilECSCategoryMappingRule::TYPE_BY_TYPE); $type->setInfo($this->lng->txt('ecs_cat_mapping_by_type_info')); $options = ilECSUtils::getPossibleRemoteTypes(true); $types = new ilSelectInputGUI($this->lng->txt('type'), 'by_type'); $types->setOptions($options); $types->setValue($this->rule->getByType()); $types->setRequired(true); $type->addSubitem($types); $value->addOption($type); $this->form->addItem($value); }
/** * update remote object settings from ecs content * * @param ilECSSetting $a_server * @param object $a_ecs_content object with object settings * @param int $a_owner */ public function updateFromECSContent(ilECSSetting $a_server, $a_ecs_content, $a_owner) { global $ilLog; $ilLog->write('updateFromECSContent: ' . print_r($a_ecs_content, true)); // Get organisation for owner (ObjectListGUI performance) $organisation = null; if ($a_owner) { include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $organisation = ilECSUtils::lookupParticipantName($a_owner, $a_server->getServerId()); $ilLog->write('found organisation: ' . $organisation); } $this->setMID($a_owner); // obsolete? $this->setOrganization($organisation); $this->setTitle($a_ecs_content->title); $this->setDescription($a_ecs_content->abstract); $this->setRemoteLink($a_ecs_content->url); $ilLog->write('updateCustomFromECSContent'); $this->updateCustomFromECSContent($a_server, $a_ecs_content); // we are updating late so custom values can be set $ilLog->write('ilObject->update()'); $this->update(); include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php'; $matchable_content = ilECSUtils::getMatchableContent($this->getECSObjectType(), $a_server->getServerId(), $a_ecs_content, $a_owner); // rule-based category mapping include_once './Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php'; ilECSCategoryMapping::handleUpdate($this->getId(), $a_server->getServerId(), $matchable_content); }