ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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(), data, 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  $this->obj->addMember((int) $this->user->getId(), $this->obj->getDefaultAdminRole());
57  }
buildLSItems(array $ls_data, ilImportMapping $mapping)
user()
Definition: user.php:4
$this data['403_header']
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 125 of file class.ilLearningSequenceImporter.php.

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

Referenced by afterContainerImportProcessing().

126  {
127  $collection = ilLPCollection::getInstanceByMode($this->obj->getId(), (int) $lp_settings["lp_mode"]);
128 
129  $new_ref_ids = array_map(function ($old_ref_id) use ($mapping) {
130  return $mapping->getMapping("Services/Container", "refs", $old_ref_id);
131  }, $lp_settings["lp_item_ref_ids"]);
132 
133  if (!is_null($collection)) {
134  $collection->activateEntries($new_ref_ids);
135  }
136 
137  $settings = new ilLPObjSettings($this->obj->getId());
138  $settings->setMode((int) $lp_settings["lp_mode"]);
139  $settings->insert();
140  }
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 67 of file class.ilLearningSequenceImporter.php.

References $data, and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

68  {
69  $ls_items = array();
70  foreach ($ls_data as $data) {
71  $old_ref_id = $data["id"];
72  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
73 
74  $post_condition = new ilLSPostCondition(
75  (int) $new_ref_id,
76  $data["ls_item_pc_condition_type"],
77  $data["ls_item_pc_value"]
78  );
79 
80  $ls_items[] = new LSItem(
81  $data["ls_item_type"] ?? "",
82  $data["ls_item_title"] ?? "",
83  $data["ls_item_description"] ?? "",
84  $data["ls_item_icon_path"] ?? "",
85  (bool) $data["ls_item_is_online"],
86  (int) $data["ls_item_order_number"],
87  $post_condition,
88  (int) $new_ref_id
89  );
90  }
91 
92  $this->obj->storeLSItems($ls_items);
93  }
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 95 of file class.ilLearningSequenceImporter.php.

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

Referenced by finalProcessing().

96  {
97  $settings = $this->obj->getLSSettings();
98  $settings = $settings
99  ->withAbstract($ls_settings["abstract"])
100  ->withExtro($ls_settings["extro"])
101  ->withMembersGallery((bool) $ls_settings["members_gallery"])
102  ;
103 
104  if ($ls_settings["abstract_img"] != "") {
105  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_ABSTRACT, $ls_settings['abstract_img']);
106  $abstract_img_data = $this->decodeImageData($ls_settings["abstract_img_data"]);
107  $this->writeToFileSystem($abstract_img_data, $path);
108  $settings = $settings
109  ->withAbstractImage($path)
110  ;
111  }
112 
113  if ($ls_settings["extro_img"] != "") {
114  $path = $this->getNewImagePath(ilLearningSequenceFilesystem::IMG_EXTRO, $ls_settings['extro_img']);
115  $extro_img_data = $this->decodeImageData($ls_settings["extro_img_data"]);
116  $this->writeToFileSystem($extro_img_data, $path);
117  $settings = $settings
118  ->withExtroImage($path)
119  ;
120  }
121 
122  $this->obj->updateSettings($settings);
123  }
$path
Definition: aliased.php:25
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 142 of file class.ilLearningSequenceImporter.php.

Referenced by buildSettings().

143  {
144  return base64_decode($data);
145  }
+ Here is the caller graph for this function:

◆ finalProcessing()

ilLearningSequenceImporter::finalProcessing (   $mapping)

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

References buildSettings(), and data.

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

◆ getNewImagePath()

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

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

Referenced by buildSettings().

147  : string
148  {
149  $fs = $this->obj->getLSFileSystem();
150  return $fs->getStoragePathFor(
151  $type,
152  (int) $this->obj->getId(),
153  $fs->getSuffix($path)
154  );
155  }
$path
Definition: aliased.php:25
$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 $id, $parser, $xml, data, 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.
if(!array_key_exists('StateId', $_REQUEST)) $id
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$parser
Definition: BPMN2Parser.php:23
$this data['403_header']
+ 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  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ updateRefId()

ilLearningSequenceImporter::updateRefId ( ilImportMapping  $mapping)
protected

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

References data, and ilImportMapping\getMapping().

Referenced by afterContainerImportProcessing().

60  {
61  $old_ref_id = $this->data["object"]["ref_id"];
62  $new_ref_id = $mapping->getMapping("Services/Container", "refs", $old_ref_id);
63 
64  $this->obj->setRefId($new_ref_id);
65  }
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
$this data['403_header']
+ 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 157 of file class.ilLearningSequenceImporter.php.

References $data.

Referenced by buildSettings().

158  {
159  file_put_contents($path, $data);
160  }
$path
Definition: aliased.php:25
+ 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: