ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCourseExporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
5include_once './Modules/Course/classes/class.ilCourseXMLWriter.php';
6include_once './Services/Export/classes/class.ilXmlExporter.php';
7
18{
19 const ENTITY_OBJECTIVE = 'objectives';
20 const ENTITY_MAIN = 'crs';
21
22 private $writer = null;
23
27 protected $logger = null;
28
32 public function __construct()
33 {
34 $this->logger = $GLOBALS['DIC']->logger()->crs();
35 }
36
41 public function init()
42 {
43 }
44
53 public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
54 {
55 if ($a_entity != self::ENTITY_MAIN) {
56 return array();
57 }
58
59 // always trigger container because of co-page(s)
60 return array(
61 array(
62 'component' => 'Services/Container',
63 'entity' => 'struct',
64 'ids' => $a_ids
65 )
66 );
67 }
68
69 // begin-patch optes_lok_export
70 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
71 {
72 $dependencies = array();
73 if ($a_entity == self::ENTITY_MAIN) {
74 $obj_id = 0;
75 foreach ($a_ids as $id) {
76 $obj_id = $id;
77 }
78
79 $dependencies[] = array(
80 'component' => 'Modules/Course',
81 'entity' => self::ENTITY_OBJECTIVE,
82 'ids' => $obj_id
83 );
84
85 include_once './Modules/Course/classes/Objectives/class.ilLOPage.php';
86 include_once './Modules/Course/classes/class.ilCourseObjective.php';
87 $page_ids = array();
88 foreach (ilCourseObjective::_getObjectiveIds($obj_id) as $objective_id) {
89 foreach (ilLOPage::getAllPages('lobj', $objective_id) as $page_id) {
90 $page_ids[] = ('lobj:' . $page_id['id']);
91 }
92 }
93
94 if ($page_ids) {
95 $dependencies[] = array(
96 'component' => 'Services/COPage',
97 'entity' => 'pg',
98 'ids' => $page_ids
99 );
100 }
101 }
102 return $dependencies;
103 }
104 // end-patch optes_lok_export
105
106
114 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
115 {
116 $course_ref_id = end(ilObject::_getAllReferences($a_id));
117 $course = ilObjectFactory::getInstanceByRefId($course_ref_id, false);
118
119 // begin-patch optes_lok_export
120 if ($a_entity == self::ENTITY_OBJECTIVE) {
121 try {
122 include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
123 $writer = new ilLOXmlWriter($course_ref_id);
124 $writer->write();
125 return $writer->getXml();
126 } catch (Exception $ex) {
127 $this->logger->error('Export failed with message: ' . $ex->getMessage());
128 // and throw
129 throw $ex;
130 }
131 }
132 // end-patch optes_lok_export
133
134 if (!$course instanceof ilObjCourse) {
135 $this->logger->warning($a_id . ' is not id of course instance.');
136 return '';
137 }
138
139 $this->writer = new ilCourseXMLWriter($course);
140 $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
141 $this->writer->start();
142 return $this->writer->xmlDumpMem(false);
143 }
144
152 public function getValidSchemaVersions($a_entity)
153 {
154 return array(
155 "4.1.0" => array(
156 "namespace" => "http://www.ilias.de/Modules/Course/crs/4_1",
157 "xsd_file" => "ilias_course_4_1.xsd",
158 "uses_dataset" => false,
159 "min" => "4.1.0",
160 "max" => "4.4.999"),
161 "5.0.0" => array(
162 "namespace" => "http://www.ilias.de/Modules/Course/crs/5_0",
163 "xsd_file" => "ilias_crs_5_0.xsd",
164 "uses_dataset" => false,
165 "min" => "5.0.0",
166 "max" => "")
167 );
168 }
169}
An exception for terminatinating execution or to throw for unit testing.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml.
getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
Get head dependencies.
static _getObjectiveIds($course_id, $a_activated_only=false)
Class ilLOXmlWriter.
Class ilObjCourse.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
static getAllPages($a_parent_type, $a_parent_id, $a_lang="-")
Get all pages for parent object.
Xml Exporter class.
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.