ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCourseExporter Class Reference

Folder export. More...

+ Inheritance diagram for ilCourseExporter:
+ Collaboration diagram for ilCourseExporter:

Public Member Functions

 __construct ()
 
 init ()
 
 getXmlExportHeadDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get tail dependencies. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, string $a_id)
 
 getValidSchemaVersions (string $a_entity)
 Returns schema versions that the component can export to. More...
 
- Public Member Functions inherited from ilXmlExporter
 __construct ()
 
 setExport (ilExport $a_exp)
 
 getExport ()
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, string $a_id)
 
 init ()
 
 setExportDirectories (string $a_dir_relative, string $a_dir_absolute)
 
 getRelativeExportDirectory ()
 
 getAbsoluteExportDirectory ()
 
 getXmlExportHeadDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies (string $a_entity, string $a_target_release, array $a_ids)
 Get tail dependencies. More...
 
 getValidSchemaVersions (string $a_entity)
 Returns schema versions that the component can export to. More...
 
 determineSchemaVersion (string $a_entity, string $a_target_release)
 

Data Fields

const string ENTITY_OBJECTIVE = 'objectives'
 
const string ENTITY_MAIN = 'crs'
 

Protected Member Functions

 getActiveAdvMDRecords (int $a_id)
 

Protected Attributes

ilXmlWriter $writer
 
ilLogger $logger
 
- Protected Attributes inherited from ilXmlExporter
ilExport $exp
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlExporter
static lookupExportDirectory (string $a_obj_type, int $a_obj_id, string $a_export_type='xml', string $a_entity="")
 

Detailed Description

Folder export.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 25 of file class.ilCourseExporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseExporter::__construct ( )

Reimplemented from ilXmlExporter.

Definition at line 33 of file class.ilCourseExporter.php.

34 {
35 global $DIC;
36 $this->logger = $DIC->logger()->crs();
37 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Member Function Documentation

◆ getActiveAdvMDRecords()

ilCourseExporter::getActiveAdvMDRecords ( int  $a_id)
protected

Definition at line 62 of file class.ilCourseExporter.php.

62 : array
63 {
64 $active = [];
65 foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType('crs') as $record_obj) {
66 foreach ($record_obj->getAssignedObjectTypes() as $obj_info) {
67 if ($obj_info['obj_type'] == 'crs' && $obj_info['optional'] == 0) {
68 $active[] = $record_obj->getRecordId();
69 }
70 // local activation
71 if (
72 $obj_info['obj_type'] == 'crs' &&
73 $obj_info['optional'] == 1 &&
74 $a_id == $record_obj->getParentObject()
75 ) {
76 $active[] = $record_obj->getRecordId();
77 }
78 }
79 }
80 return $active;
81 }
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.

References ilAdvancedMDRecord\_getActivatedRecordsByObjectType().

Referenced by getXmlExportTailDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidSchemaVersions()

ilCourseExporter::getValidSchemaVersions ( string  $a_entity)

Returns schema versions that the component can export to.

ILIAS chooses the first one, that has min/max constraints which fit to the target release. Please put the newest on top. Example: return array ( "4.1.0" => array( "namespace" => "http://www.ilias.de/Services/MetaData/md/4_1", "xsd_file" => "ilias_md_4_1.xsd", "min" => "4.1.0", "max" => "") );

Reimplemented from ilXmlExporter.

Definition at line 178 of file class.ilCourseExporter.php.

178 : array
179 {
180 return [
181 "11.0" => [
182 "namespace" => 'http://www.ilias.de/Modules/Course/crs/11',
183 "xsd_file" => 'ilias_crs_11_0.xsd',
184 "uses_dataset" => false,
185 "min" => "11.0",
186 "max" => ""
187 ],
188 "10.0" => [
189 "namespace" => 'http://www.ilias.de/Modules/Course/crs/10',
190 "xsd_file" => 'ilias_crs_10_0.xsd',
191 "uses_dataset" => false,
192 "min" => "10.0",
193 "max" => "10.999"
194 ],
195 "9.0" => [
196 "namespace" => 'http://www.ilias.de/Modules/Course/crs/9',
197 "xsd_file" => 'ilias_crs_9_0.xsd',
198 "uses_dataset" => false,
199 "min" => "9.0",
200 "max" => "9.999"
201 ],
202 "4.1.0" => [
203 "namespace" => "http://www.ilias.de/Modules/Course/crs/4_1",
204 "xsd_file" => "ilias_course_4_1.xsd",
205 "uses_dataset" => false,
206 "min" => "4.1.0",
207 "max" => "4.4.999"
208 ],
209 "5.0.0" => [
210 "namespace" => "http://www.ilias.de/Modules/Course/crs/5_0",
211 "xsd_file" => "ilias_crs_5_0.xsd",
212 "uses_dataset" => false,
213 "min" => "5.0.0",
214 "max" => "8.999"
215 ]
216 ];
217 }

◆ getXmlExportHeadDependencies()

ilCourseExporter::getXmlExportHeadDependencies ( string  $a_entity,
string  $a_target_release,
array  $a_ids 
)

Get head dependencies.

Reimplemented from ilXmlExporter.

Definition at line 46 of file class.ilCourseExporter.php.

46 : array
47 {
48 if ($a_entity != self::ENTITY_MAIN) {
49 return array();
50 }
51
52 // always trigger container because of co-page(s)
53 return array(
54 array(
55 'component' => 'components/ILIAS/Container',
56 'entity' => 'struct',
57 'ids' => $a_ids
58 )
59 );
60 }

◆ getXmlExportTailDependencies()

ilCourseExporter::getXmlExportTailDependencies ( string  $a_entity,
string  $a_target_release,
array  $a_ids 
)

Get tail dependencies.

Returns
array array of array with keys "component", entity", "ids"

Reimplemented from ilXmlExporter.

Definition at line 84 of file class.ilCourseExporter.php.

84 : array
85 {
86 if ($a_entity !== self::ENTITY_MAIN) {
87 return [];
88 }
89
90 $dependencies = [];
91 $obj_id = 0;
92 foreach ($a_ids as $id) {
93 $obj_id = $id;
94 }
95
96 $dependencies[] = [
97 'component' => 'components/ILIAS/Course',
98 'entity' => self::ENTITY_OBJECTIVE,
99 'ids' => $obj_id
100 ];
101
102 $page_ids = [];
103 foreach (ilCourseObjective::_getObjectiveIds($obj_id) as $objective_id) {
104 foreach (ilLOPage::getAllPages('lobj', $objective_id) as $page_id) {
105 $page_ids[] = ('lobj:' . $page_id['id']);
106 }
107 }
108
109 if ($page_ids !== []) {
110 $dependencies[] = [
111 'component' => 'components/ILIAS/COPage',
112 'entity' => 'pg',
113 'ids' => $page_ids
114 ];
115 }
116
117 $advmd_ids = [];
118 foreach ($a_ids as $id) {
119 $rec_ids = $this->getActiveAdvMDRecords($id);
120 foreach ($rec_ids as $rec_id) {
121 $advmd_ids[] = $id . ":" . $rec_id;
122 }
123 }
124
125 if ($advmd_ids !== []) {
126 $dependencies[] = [
127 "component" => "components/ILIAS/AdvancedMetaData",
128 "entity" => "advmd",
129 "ids" => $advmd_ids
130 ];
131 }
132
133 $md_ids = [];
134 foreach ($a_ids as $crs_id) {
135 $md_ids[] = $crs_id . ":0:crs";
136 }
137 if ($md_ids !== []) {
138 $dependencies[] = [
139 "component" => "components/ILIAS/MetaData",
140 "entity" => "md",
141 "ids" => $md_ids
142 ];
143 }
144 return $dependencies;
145 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static getAllPages(string $a_parent_type, int $a_parent_id, string $a_lang="-")
Get all pages for parent object.

References $id, ilCourseObjective\_getObjectiveIds(), ENTITY_OBJECTIVE, getActiveAdvMDRecords(), and ilPageObject\getAllPages().

+ Here is the call graph for this function:

◆ getXmlRepresentation()

ilCourseExporter::getXmlRepresentation ( string  $a_entity,
string  $a_schema_version,
string  $a_id 
)

Reimplemented from ilXmlExporter.

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

147 : string
148 {
149 $refs = ilObject::_getAllReferences((int) $a_id);
150 $course_ref_id = end($refs);
151 $course = ilObjectFactory::getInstanceByRefId($course_ref_id, false);
152
153 // begin-patch optes_lok_export
154 if ($a_entity == self::ENTITY_OBJECTIVE) {
155 try {
156 $writer = new ilLOXmlWriter($course_ref_id);
157 $writer->write();
158 return $writer->getXml();
159 } catch (Exception $ex) {
160 $this->logger->error('Export failed with message: ' . $ex->getMessage());
161 // and throw
162 throw $ex;
163 }
164 }
165 // end-patch optes_lok_export
166
167 if (!$course instanceof ilObjCourse) {
168 $this->logger->warning($a_id . ' is not id of course instance.');
169 return '';
170 }
171
172 $this->writer = new ilCourseXMLWriter($course);
173 $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
174 $this->writer->start();
175 return $this->writer->xmlDumpMem(false);
176 }
XML writer class Class to simplify manual writing of xml documents.
Class ilLOXmlWriter.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences(int $id)
get all reference ids for object ID

References $writer, ilObject\_getAllReferences(), ilObjectFactory\getInstanceByRefId(), ILIAS\Repository\logger(), and ilCourseXMLWriter\MODE_EXPORT.

+ Here is the call graph for this function:

◆ init()

ilCourseExporter::init ( )

Reimplemented from ilXmlExporter.

Definition at line 39 of file class.ilCourseExporter.php.

39 : void
40 {
41 }

Field Documentation

◆ $logger

ilLogger ilCourseExporter::$logger
protected

Definition at line 31 of file class.ilCourseExporter.php.

◆ $writer

ilXmlWriter ilCourseExporter::$writer
protected

Definition at line 30 of file class.ilCourseExporter.php.

Referenced by getXmlRepresentation().

◆ ENTITY_MAIN

const string ilCourseExporter::ENTITY_MAIN = 'crs'

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

◆ ENTITY_OBJECTIVE

const string ilCourseExporter::ENTITY_OBJECTIVE = 'objectives'

Definition at line 27 of file class.ilCourseExporter.php.

Referenced by getXmlExportTailDependencies().


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