ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLearningSequenceImporter Class Reference
+ Inheritance diagram for ilLearningSequenceImporter:
+ Collaboration diagram for ilLearningSequenceImporter:

Public Member Functions

 init ()
 
 importXmlRepresentation ($entity, $id, $xml, $mapping)
 
 finalProcessing ($mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 setImport ($a_val)
 Set import. More...
 
 getImport ()
 Get import. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 exportedFromSameInstallation ()
 Is exporting and importing installation identical? More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 Called after all container objects have been implemented. More...
 

Protected Member Functions

 updateRefId (ilImportMapping $mapping)
 
 buildLSItems (array $ls_data, ilImportMapping $mapping)
 
 buildSettings (array $ls_settings)
 
 buildLPSettings (array $lp_settings, ilImportMapping $mapping)
 
 decodeImageData (string $data)
 
 getNewImagePath (string $type, string $path)
 
 writeToFileSystem ($data, string $path)
 

Protected Attributes

 $obj
 
 $data
 
- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 
 $imp
 

Detailed Description

Member Function Documentation

◆ afterContainerImportProcessing()

ilLearningSequenceImporter::afterContainerImportProcessing ( ilImportMapping  $mapping)

Definition at line 50 of file class.ilLearningSequenceImporter.php.

References buildLPSettings(), buildLSItems(), updateRefId(), and user().

51  {
52  $this->updateRefId($mapping);
53  $this->buildLSItems($this->data["item_data"], $mapping);
54  $this->buildLPSettings($this->data["lp_settings"], $mapping);
55 
56  $roles = $this->obj->getLSRoles();
57  $roles->addLSMember(
58  (int) $this->user->getId(),
59  $roles->getDefaultAdminRole()
60  );
61  }
buildLSItems(array $ls_data, ilImportMapping $mapping)
user()
Definition: user.php:4
buildLPSettings(array $lp_settings, ilImportMapping $mapping)
+ Here is the call graph for this function:

◆ buildLPSettings()

ilLearningSequenceImporter::buildLPSettings ( array  $lp_settings,
ilImportMapping  $mapping 
)
protected

Definition at line 129 of file class.ilLearningSequenceImporter.php.

References ilLPCollection\getInstanceByMode(), ilImportMapping\getMapping(), and ilLPObjSettings\setMode().

Referenced by afterContainerImportProcessing().

130  {
131  $collection = ilLPCollection::getInstanceByMode($this->obj->getId(), (int) $lp_settings["lp_mode"]);
132 
133  $new_ref_ids = array_map(function ($old_ref_id) use ($mapping) {
134  return $mapping->getMapping("Services/Container", "refs", $old_ref_id);
135  }, $lp_settings["lp_item_ref_ids"]);
136 
137  if (!is_null($collection)) {
138  $collection->activateEntries($new_ref_ids);
139  }
140 
141  $settings = new ilLPObjSettings($this->obj->getId());
142  $settings->setMode((int) $lp_settings["lp_mode"]);
143  $settings->insert();
144  }
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
static getInstanceByMode($a_obj_id, $a_mode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildLSItems()

ilLearningSequenceImporter::buildLSItems ( array  $ls_data,
ilImportMapping  $mapping 
)
protected

Definition at line 71 of file class.ilLearningSequenceImporter.php.

References $data, and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

72  {
73  $ls_items = array();
74  foreach ($ls_data as $data) {
75  $old_ref_id = $data["id"];
76  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
77 
78  $post_condition = new ilLSPostCondition(
79  (int) $new_ref_id,
80  $data["ls_item_pc_condition_type"],
81  $data["ls_item_pc_value"]
82  );
83 
84  $ls_items[] = new LSItem(
85  $data["ls_item_type"] ?? "",
86  $data["ls_item_title"] ?? "",
87  $data["ls_item_description"] ?? "",
88  $data["ls_item_icon_path"] ?? "",
89  (bool) $data["ls_item_is_online"],
90  (int) $data["ls_item_order_number"],
91  $post_condition,
92  (int) $new_ref_id
93  );
94  }
95 
96  $this->obj->storeLSItems($ls_items);
97  }
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
Data holding class LSItem .
Definition: LSItem.php:11
A PostCondition does restrict the progression of a user through the learning sequence.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSettings()

ilLearningSequenceImporter::buildSettings ( array  $ls_settings)
protected

Definition at line 99 of file class.ilLearningSequenceImporter.php.

References decodeImageData(), getNewImagePath(), ilLearningSequenceFilesystem\IMG_ABSTRACT, ilLearningSequenceFilesystem\IMG_EXTRO, and writeToFileSystem().

Referenced by finalProcessing().

100  {
101  $settings = $this->obj->getLSSettings();
103  ->withAbstract($ls_settings["abstract"])
104  ->withExtro($ls_settings["extro"])
105  ->withMembersGallery((bool) $ls_settings["members_gallery"])
106  ;
107 
108  if ($ls_settings["abstract_img"] != "") {
109  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_ABSTRACT, $ls_settings['abstract_img']);
110  $abstract_img_data = $this->decodeImageData($ls_settings["abstract_img_data"]);
111  $this->writeToFileSystem($abstract_img_data, $path);
113  ->withAbstractImage($path)
114  ;
115  }
116 
117  if ($ls_settings["extro_img"] != "") {
118  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_EXTRO, $ls_settings['extro_img']);
119  $extro_img_data = $this->decodeImageData($ls_settings["extro_img_data"]);
120  $this->writeToFileSystem($extro_img_data, $path);
122  ->withExtroImage($path)
123  ;
124  }
125 
126  $this->obj->updateSettings($settings);
127  }
getNewImagePath(string $type, string $path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ decodeImageData()

ilLearningSequenceImporter::decodeImageData ( string  $data)
protected

Definition at line 146 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

147  {
148  return base64_decode($data);
149  }
+ Here is the caller graph for this function:

◆ finalProcessing()

ilLearningSequenceImporter::finalProcessing (   $mapping)

Definition at line 43 of file class.ilLearningSequenceImporter.php.

References buildSettings().

44  {
45  $this->buildSettings($this->data["settings"]);
46 
47  $this->obj->update();
48  }
+ Here is the call graph for this function:

◆ getNewImagePath()

ilLearningSequenceImporter::getNewImagePath ( string  $type,
string  $path 
)
protected

Definition at line 151 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

151  : string
152  {
153  $fs = $this->obj->getDI()['db.filesystem'];
154  return $fs->getStoragePathFor(
155  $type,
156  (int) $this->obj->getId(),
157  $fs->getSuffix($path)
158  );
159  }
$type
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

ilLearningSequenceImporter::importXmlRepresentation (   $entity,
  $id,
  $xml,
  $mapping 
)

Definition at line 28 of file class.ilLearningSequenceImporter.php.

References $xml, and ilObjectFactory\getInstanceByObjId().

29  {
30  if ($new_id = $mapping->getMapping("Services/Container", "objs", $id)) {
31  $this->obj = ilObjectFactory::getInstanceByObjId($new_id, false);
32  } else {
33  $this->obj = new ilObjLearningSequence();
34  $this->obj->create();
35  }
36 
37  $parser = new ilLearningSequenceXMLParser($this->obj, $xml);
38  $this->data = $parser->start();
39 
40  $mapping->addMapping("Modules/LearningSequence", "lso", $id, $this->obj->getId());
41  }
Class ilObjLearningSequence.
$xml
Definition: metadata.php:332
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ init()

ilLearningSequenceImporter::init ( )

Definition at line 20 of file class.ilLearningSequenceImporter.php.

References $DIC, and user().

21  {
22  global $DIC;
23  $this->user = $DIC["ilUser"];
24  $this->rbac_admin = $DIC["rbacadmin"];
25  $this->log = $DIC["ilLoggerFactory"]->getRootLogger();
26  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

◆ updateRefId()

ilLearningSequenceImporter::updateRefId ( ilImportMapping  $mapping)
protected

Definition at line 63 of file class.ilLearningSequenceImporter.php.

References ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

64  {
65  $old_ref_id = $this->data["object"]["ref_id"];
66  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
67 
68  $this->obj->setRefId($new_ref_id);
69  }
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeToFileSystem()

ilLearningSequenceImporter::writeToFileSystem (   $data,
string  $path 
)
protected

Definition at line 161 of file class.ilLearningSequenceImporter.php.

References $data.

Referenced by buildSettings().

162  {
163  file_put_contents($path, $data);
164  }
+ Here is the caller graph for this function:

Field Documentation

◆ $data

ilLearningSequenceImporter::$data
protected

Definition at line 18 of file class.ilLearningSequenceImporter.php.

Referenced by buildLSItems(), and writeToFileSystem().

◆ $obj

ilLearningSequenceImporter::$obj
protected

Definition at line 13 of file class.ilLearningSequenceImporter.php.


The documentation for this class was generated from the following file: