ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 }
45
54 public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
55 {
56 if($a_entity != self::ENTITY_MAIN)
57 {
58 return array();
59 }
60
61 // always trigger container because of co-page(s)
62 return array(
63 array(
64 'component' => 'Services/Container',
65 'entity' => 'struct',
66 'ids' => $a_ids
67 )
68 );
69 }
70
71 // begin-patch optes_lok_export
72 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
73 {
74 $dependencies = array();
75 if($a_entity == self::ENTITY_MAIN)
76 {
77 $obj_id = 0;
78 foreach($a_ids as $id)
79 {
80 $obj_id = $id;
81 }
82
83 $dependencies[] = array(
84 'component' => 'Modules/Course',
85 'entity' => self::ENTITY_OBJECTIVE,
86 'ids' => $obj_id
87 );
88
89 include_once './Modules/Course/classes/Objectives/class.ilLOPage.php';
90 include_once './Modules/Course/classes/class.ilCourseObjective.php';
91 $page_ids = array();
92 foreach(ilCourseObjective::_getObjectiveIds($obj_id) as $objective_id)
93 {
94 foreach(ilLOPage::getAllPages('lobj', $objective_id) as $page_id)
95 {
96 $page_ids[] = ('lobj:'.$page_id['id']);
97 }
98 }
99
100 if($page_ids)
101 {
102 $dependencies[] = array(
103 'component' => 'Services/COPage',
104 'entity' => 'pg',
105 'ids' => $page_ids
106 );
107 }
108
109
110
111 }
112 return $dependencies;
113 }
114 // end-patch optes_lok_export
115
116
124 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
125 {
126 $course_ref_id = end(ilObject::_getAllReferences($a_id));
127 $course = ilObjectFactory::getInstanceByRefId($course_ref_id,false);
128
129 // begin-patch optes_lok_export
130 if($a_entity == self::ENTITY_OBJECTIVE)
131 {
132 try {
133 include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
134 $writer = new ilLOXmlWriter($course_ref_id);
135 $writer->write();
136 return $writer->getXml();
137 }
138 catch (Exception $ex) {
139 $this->logger->error('Export failed with message: ' . $ex->getMessage());
140 // and throw
141 throw $ex;
142 }
143 }
144 // end-patch optes_lok_export
145
146 if(!$course instanceof ilObjCourse)
147 {
148 $this->logger->warning($a_id .' is not id of course instance.');
149 return '';
150 }
151
152 $this->writer = new ilCourseXMLWriter($course);
153 $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
154 $this->writer->start();
155 return $this->writer->xmlDumpMem(false);
156 }
157
165 public function getValidSchemaVersions($a_entity)
166 {
167 return array (
168 "4.1.0" => array(
169 "namespace" => "http://www.ilias.de/Modules/Course/crs/4_1",
170 "xsd_file" => "ilias_course_4_1.xsd",
171 "uses_dataset" => false,
172 "min" => "4.1.0",
173 "max" => "4.4.999"),
174 "5.0.0" => array(
175 "namespace" => "http://www.ilias.de/Modules/Course/crs/5_0",
176 "xsd_file" => "ilias_crs_5_0.xsd",
177 "uses_dataset" => false,
178 "min" => "5.0.0",
179 "max" => "")
180 );
181 }
182}
183?>
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.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.