33 # Patch Start: Fix multilingualism replaces course title
36 # Patch End: Fix multilingualism replaces course title
38 public function init(): void
42 $this->translations_repository =
new TranslationsRepository(
$DIC->database());
44 $this->skill_profile_service =
$DIC->skills()->profile();
54 $this->structure_xml = $a_xml;
55 $this->cont_log->debug(
'Import xml: ' . $a_xml);
56 $this->cont_log->debug(
'Using id: ' . $a_id);
59 $parser->parse($a_id);
61 # Patch Start: Fix multilingualism replaces course title
62 $this->import_id = $a_id;
63 # Patch End: Fix multilingualism replaces course title
74 foreach ($page_map as $old_pg_id => $new_pg_id) {
75 $parts = explode(
':', $old_pg_id);
78 $parts = explode(
':', $new_pg_id);
79 $new_pg_id = array_pop(
$parts);
80 $new_obj_id = $a_mapping->
getMapping(
'components/ILIAS/Container',
'objs', $old_obj_id);
82 if ($new_obj_id > 0 && in_array($pg_type, [
"crs",
"grp",
"fold",
"cont"],
true)) {
84 $this->cont_log->debug(
'write parent id, type: ' . $pg_type .
", page id: " . $new_pg_id .
", parent id: " . $new_obj_id);
90 foreach ($sty_map as $old_sty_id => $new_sty_id) {
100 $new_crs_obj_id = end($crs_map);
102 $new_crs_ref_id = end($new_crs_ref_ids);
104 $skl_local_prof_map = $a_mapping->
getMappingsOfEntity(
'components/ILIAS/Skill',
'skl_local_prof');
105 foreach ($skl_local_prof_map as $old_prof_id => $new_prof_id) {
106 $this->skill_profile_service->updateProfileRefIdAfterImport((
int) $new_prof_id, (
int) $new_crs_ref_id);
107 $this->skill_profile_service->addRoleToProfile(
113 # Patch Start: Fix multilingualism replaces course title
114 $obj_id = (
int) $a_mapping->
getMapping(
'components/ILIAS/ILIASObject',
'obj', $this->import_id);
115 $translations = $this->translations_repository->getFor($obj_id);
116 $translations_new =
new Translations($translations->getObjId(), [], $translations->getDefaultLanguage(), $translations->getBaseLanguage());
117 $languages = $translations->getLanguages();
118 foreach ($languages as $language) {
119 $translations_new = $language->getTitle() ===
'NO TITLE'
121 : $translations_new->withLanguage($language);
123 $this->translations_repository->store($translations_new);
124 # Patch End: Fix multilingualism replaces course title
129 $use_internal_errors = libxml_use_internal_errors(
true);
130 $root = simplexml_load_string($xml);
131 libxml_use_internal_errors($use_internal_errors);
132 if ($root ===
false) {
134 foreach (libxml_get_errors() as $err) {
135 $errors .= $err->code .
'<br/>';
137 $this->cont_log->error($xml);
138 $this->cont_log->error(
'Cannot parse xml: ' . $errors);
140 foreach ($root->xpath(
'//Item') as $item) {
143 foreach ($item->attributes() as $name => $value) {
144 if ((
string) $name ===
'Offline') {
147 if ((
string) $name ===
'RefId') {
151 if (is_null($offline)) {
152 $this->cont_log->debug(
'No offline handling for ref_id: ' .
$ref_id);
155 $new_ref_id = $mapping->
getMapping(
'components/ILIAS/Container',
'refs',
$ref_id);
158 $this->cont_log->warning(
'Cannot create instance for ref_id: ' . $new_ref_id);
161 if ($obj->supportsOfflineHandling()) {
162 if ($this->
isRootNode($obj->getRefId(), $mapping)) {
163 $obj->setOfflineStatus(
true);
166 $obj->setOfflineStatus(!((
string) $offline ===
"0"));
177 $tree =
$DIC->repositoryTree();
178 $parent_id = $tree->getParentId(
$ref_id);
Class handles translation mode for an object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
finalProcessing(ilImportMapping $a_mapping)
ILIAS Skill Service SkillProfileService $skill_profile_service
isRootNode(int $ref_id, ilImportMapping $mapping)
handleOfflineStatus(string $xml, ilImportMapping $mapping)
TranslationsRepository $translations_repository
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
Import XML.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static writeStyleUsage(int $a_obj_id, int $a_style_id)
Write style usage.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
static _getAllReferences(int $id)
get all reference ids for object ID
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
static getDefaultMemberRole(int $a_ref_id)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts