ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 public function __construct()
28 {
29 }
30
35 public function init()
36 {
37
38 }
39
48 public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
49 {
50 if($a_entity != self::ENTITY_MAIN)
51 {
52 return array();
53 }
54
55 // always trigger container because of co-page(s)
56 return array(
57 array(
58 'component' => 'Services/Container',
59 'entity' => 'struct',
60 'ids' => $a_ids
61 )
62 );
63 }
64
65 // begin-patch optes_lok_export
66 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
67 {
68 $dependencies = array();
69 if($a_entity == self::ENTITY_MAIN)
70 {
71 $obj_id = 0;
72 foreach($a_ids as $id)
73 {
74 $obj_id = $id;
75 }
76
77 $dependencies[] = array(
78 'component' => 'Modules/Course',
79 'entity' => self::ENTITY_OBJECTIVE,
80 'ids' => $obj_id
81 );
82
83 include_once './Modules/Course/classes/Objectives/class.ilLOPage.php';
84 include_once './Modules/Course/classes/class.ilCourseObjective.php';
85 $page_ids = array();
86 foreach(ilCourseObjective::_getObjectiveIds($obj_id) as $objective_id)
87 {
88 foreach(ilLOPage::getAllPages('lobj', $objective_id) as $page_id)
89 {
90 $page_ids[] = ('lobj:'.$page_id['id']);
91 }
92 }
93
94 if($page_ids)
95 {
96 $dependencies[] = array(
97 'component' => 'Services/COPage',
98 'entity' => 'pg',
99 'ids' => $page_ids
100 );
101 }
102
103
104
105 }
106 return $dependencies;
107 }
108 // end-patch optes_lok_export
109
110
118 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
119 {
120 $course_ref_id = end(ilObject::_getAllReferences($a_id));
121 $course = ilObjectFactory::getInstanceByRefId($course_ref_id,false);
122
123 // begin-patch optes_lok_export
124 if($a_entity == self::ENTITY_OBJECTIVE)
125 {
126 try {
127 include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
128 $writer = new ilLOXmlWriter($course_ref_id);
129 $writer->write();
130 return $writer->getXml();
131 }
132 catch (Exception $ex) {
133 return '';
134 }
135 }
136 // end-patch optes_lok_export
137
138 if(!$course instanceof ilObjCourse)
139 {
140 $GLOBALS['ilLog']->write(__METHOD__. $a_id . ' is not instance of type course');
141 return '';
142 }
143
144 $this->writer = new ilCourseXMLWriter($course);
145 $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
146 $this->writer->start();
147 return $this->writer->xmlDumpMem(false);
148 }
149
157 public function getValidSchemaVersions($a_entity)
158 {
159 return array (
160 "4.1.0" => array(
161 "namespace" => "http://www.ilias.de/Modules/Course/crs/4_1",
162 "xsd_file" => "ilias_course_4_1.xsd",
163 "uses_dataset" => false,
164 "min" => "4.1.0",
165 "max" => "4.4.999"),
166 "5.0.0" => array(
167 "namespace" => "http://www.ilias.de/Modules/Course/crs/5_0",
168 "xsd_file" => "ilias_crs_5_0.xsd",
169 "uses_dataset" => false,
170 "min" => "5.0.0",
171 "max" => "")
172 );
173 }
174}
175?>
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.
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['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276