ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilCourseXMLWriter Class Reference

XML writer class. More...

+ Inheritance diagram for ilCourseXMLWriter:
+ Collaboration diagram for ilCourseXMLWriter:

Public Member Functions

 ilCourseXMLWriter (&$course_obj)
 constructor More...
 
 setMode ($a_mode)
 
 getMode ()
 
 start ()
 
 getXML ()
 
 modifyExportIdentifier ($a_tag, $a_param, $a_value)
 
 __buildHeader ()
 
 __buildCourseStart ()
 
 __buildMetaData ()
 
 __buildAdmin ()
 
 __buildTutor ()
 
 __buildMember ()
 
 __buildSubscriber ()
 
 __buildWaitingList ()
 
 __buildSetting ()
 
 __buildFooter ()
 
 setAttachUsers ($value)
 write access to attach user property, if set to false no users will be attached. More...
 
- Public Member Functions inherited from ilXmlWriter
 ilXmlWriter ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor @access public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header @access public. More...
 
 xmlStartTag ($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=TRUE, $escape=TRUE)
 Writes data. More...
 
 xmlElement ($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=TRUE)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=TRUE)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr @access public More...
 

Data Fields

const MODE_SOAP = 1
 
const MODE_EXPORT = 2
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Private Member Functions

 __buildAdvancedMetaData ()
 Build advanced meta data. More...
 

Private Attributes

 $mode = self::MODE_SOAP
 
 $ilias
 
 $xml
 
 $course_obj
 
 $attach_users = true
 

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

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

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

Member Function Documentation

◆ __buildAdmin()

ilCourseXMLWriter::__buildAdmin ( )

Definition at line 179 of file class.ilCourseXMLWriter.php.

180 {
181 foreach($this->course_obj->getMembersObject()->getAdmins() as $id)
182 {
183 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
184 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
185 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
186
187 $this->xmlStartTag('Admin',$attr);
188 $this->xmlEndTag('Admin');
189 }
190 return true;
191 }
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.

References ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildAdvancedMetaData()

ilCourseXMLWriter::__buildAdvancedMetaData ( )
private

Build advanced meta data.

@access private

Definition at line 173 of file class.ilCourseXMLWriter.php.

174 {
175 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
176 ilAdvancedMDValues::_appendXMLByObjId($this,$this->course_obj->getId());
177 }
static _appendXMLByObjId(ilXmlWriter $a_xml_writer, $a_obj_id)
Get xml of object values.

References ilAdvancedMDValues\_appendXMLByObjId().

Referenced by start().

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

◆ __buildCourseStart()

ilCourseXMLWriter::__buildCourseStart ( )

Definition at line 148 of file class.ilCourseXMLWriter.php.

149 {
150 $attrs["exportVersion"] = $this->EXPORT_VERSION;
151 $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_crs_'.$this->course_obj->getId();
152 $attrs['showMembers'] = ($this->course_obj->getShowMembers() ? 'Yes' : 'No');
153 $this->xmlStartTag("Course", $attrs);
154 }

References ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildFooter()

ilCourseXMLWriter::__buildFooter ( )

Definition at line 369 of file class.ilCourseXMLWriter.php.

370 {
371 $this->xmlEndTag('Course');
372 }

References ilXmlWriter\xmlEndTag().

Referenced by start().

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

◆ __buildHeader()

ilCourseXMLWriter::__buildHeader ( )

Definition at line 138 of file class.ilCourseXMLWriter.php.

139 {
140 $this->xmlSetDtdDef("<!DOCTYPE Course PUBLIC \"-//ILIAS//DTD Course//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_crs_5_0.dtd\">");
141 $this->xmlSetGenCmt("Export of ILIAS course ". $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
142 $this->xmlHeader();
143
144
145 return true;
146 }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), and ilXmlWriter\xmlSetGenCmt().

Referenced by start().

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

◆ __buildMember()

ilCourseXMLWriter::__buildMember ( )

Definition at line 206 of file class.ilCourseXMLWriter.php.

207 {
208 foreach($this->course_obj->getMembersObject()->getMembers() as $id)
209 {
210 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
211 $attr['blocked'] = ($this->course_obj->getMembersObject()->isBlocked($id)) ? 'Yes' : 'No';
212 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
213
214 $this->xmlStartTag('Member',$attr);
215 $this->xmlEndTag('Member');
216 }
217 return true;
218 }

References ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildMetaData()

ilCourseXMLWriter::__buildMetaData ( )

Definition at line 156 of file class.ilCourseXMLWriter.php.

157 {
158 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
159
160 $md2xml = new ilMD2XML($this->course_obj->getId(),$this->course_obj->getId(),'crs');
161 $md2xml->startExport();
162 $this->appendXML($md2xml->getXML());
163
164 return true;
165 }
appendXML($a_str)
append xml string to document

References ilXmlWriter\appendXML().

Referenced by start().

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

◆ __buildSetting()

ilCourseXMLWriter::__buildSetting ( )

Definition at line 254 of file class.ilCourseXMLWriter.php.

255 {
256 $this->xmlStartTag('Settings');
257
258 // Availability
259 $this->xmlStartTag('Availability');
260 if($this->course_obj->getOfflineStatus())
261 {
262 $this->xmlElement('NotAvailable');
263 }
264 elseif($this->course_obj->getActivationUnlimitedStatus())
265 {
266 $this->xmlElement('Unlimited');
267 }
268 else
269 {
270 $this->xmlStartTag('TemporarilyAvailable');
271 $this->xmlElement('Start',null,$this->course_obj->getActivationStart());
272 $this->xmlElement('End',null,$this->course_obj->getActivationEnd());
273 $this->xmlEndTag('TemporarilyAvailable');
274 }
275 $this->xmlEndTag('Availability');
276
277 // Syllabus
278 $this->xmlElement('Syllabus',null,$this->course_obj->getSyllabus());
279 $this->xmlElement('ImportantInformation',null,$this->course_obj->getImportantInformation());
280
281
282 // Contact
283 $this->xmlStartTag('Contact');
284 $this->xmlElement('Name',null,$this->course_obj->getContactName());
285 $this->xmlElement('Responsibility',null,$this->course_obj->getContactResponsibility());
286 $this->xmlElement('Phone',null,$this->course_obj->getContactPhone());
287 $this->xmlElement('Email',null,$this->course_obj->getContactEmail());
288 $this->xmlElement('Consultation',null,$this->course_obj->getContactConsultation());
289 $this->xmlEndTag('Contact');
290
291 // Registration
292 $attr = array();
293
294 if($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_CONFIRMATION)
295 {
296 $attr['registrationType'] = 'Confirmation';
297 }
298 elseif($this->course_obj->getSubscriptionType() == IL_CRS_SUBSCRIPTION_DIRECT)
299 {
300 $attr['registrationType'] = 'Direct';
301 }
302 else
303 {
304 $attr['registrationType'] = 'Password';
305 }
306
307 $attr['maxMembers'] = $this->course_obj->isSubscriptionMembershipLimited() ?
308 $this->course_obj->getSubscriptionMaxMembers() : 0;
309 $attr['notification'] = $this->course_obj->getSubscriptionNotify() ? 'Yes' : 'No';
310 $attr['waitingList'] = $this->course_obj->enabledWaitingList() ? 'Yes' : 'No';
311
312 $this->xmlStartTag('Registration',$attr);
313
314 if($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED)
315 {
316 $this->xmlElement('Disabled');
317 }
318 elseif($this->course_obj->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_UNLIMITED)
319 {
320 $this->xmlElement('Unlimited');
321 }
322 else
323 {
324 $this->xmlStartTag('TemporarilyAvailable');
325 $this->xmlElement('Start',null,$this->course_obj->getSubscriptionStart());
326 $this->xmlElement('End',null,$this->course_obj->getSubscriptionEnd());
327 $this->xmlEndTag('TemporarilyAvailable');
328 }
329 if(strlen($pwd = $this->course_obj->getSubscriptionPassword()))
330 {
331 $this->xmlElement('Password',null,$pwd);
332 }
333 $this->xmlEndTag('Registration');
334
335 // Archives
336 $attr = array();
337 if($this->course_obj->getViewMode() != IL_CRS_VIEW_ARCHIVE)
338 {
339 $attr['Access'] = 'Disabled';
340 }
341 elseif($this->course_obj->getViewMode() == IL_CRS_VIEW_ARCHIVE)
342 {
343 $attr['Access'] = 'Read';
344 }
345 if($this->course_obj->getArchiveType() == IL_CRS_ARCHIVE_DOWNLOAD)
346 {
347 $attr['Access'] = 'Download';
348 }
349 $this->xmlStartTag('Archive',$attr);
350
351 $this->xmlElement('Start',null,$this->course_obj->getArchiveStart());
352 $this->xmlElement('End',null,$this->course_obj->getArchiveEnd());
353
354 $this->xmlEndTag('Archive');
355
356 $this->xmlStartTag('Period');
357 $this->xmlElement('Start',null,($this->course_obj->getCourseStart() && !$this->course_obj->getCourseStart()->isNull()) ? $this->course_obj->getCourseStart()->get(IL_CAL_UNIX) : null);
358 $this->xmlElement('End',null,($this->course_obj->getCourseEnd() && !$this->course_obj->getCourseEnd()->isNull()) ? $this->course_obj->getCourseEnd()->get(IL_CAL_UNIX) : null);
359 $this->xmlEndTag('Period');
360 $this->xmlElement('WaitingListAutoFill',null,(int)$this->course_obj->hasWaitingListAutoFill());
361 $this->xmlElement('CancellationEnd',null,($this->course_obj->getCancellationEnd() && !$this->course_obj->getCancellationEnd()->isNull()) ? $this->course_obj->getCancellationEnd()->get(IL_CAL_UNIX) : null);
362 $this->xmlElement('MinMembers',null,(int)$this->course_obj->getSubscriptionMinMembers());
363
364 $this->xmlEndTag('Settings');
365
366 return true;
367 }
const IL_CRS_SUBSCRIPTION_CONFIRMATION
const IL_CRS_ARCHIVE_DOWNLOAD
const IL_CRS_VIEW_ARCHIVE
const IL_CRS_SUBSCRIPTION_UNLIMITED
const IL_CRS_SUBSCRIPTION_DEACTIVATED
const IL_CRS_SUBSCRIPTION_DIRECT
const IL_CAL_UNIX
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)

References IL_CAL_UNIX, IL_CRS_ARCHIVE_DOWNLOAD, IL_CRS_SUBSCRIPTION_CONFIRMATION, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_DIRECT, IL_CRS_SUBSCRIPTION_UNLIMITED, IL_CRS_VIEW_ARCHIVE, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildSubscriber()

ilCourseXMLWriter::__buildSubscriber ( )

Definition at line 220 of file class.ilCourseXMLWriter.php.

221 {
222 foreach($this->course_obj->getMembersObject()->getSubscribers() as $id)
223 {
224 $data = $this->course_obj->getMembersObject()->getSubscriberData($id);
225
226 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
227 $attr['subscriptionTime'] = $data['time'];
228
229 $this->xmlStartTag('Subscriber',$attr);
230 $this->xmlEndTag('Subscriber');
231 }
232 return true;
233 }
$data

References $data, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildTutor()

ilCourseXMLWriter::__buildTutor ( )

Definition at line 193 of file class.ilCourseXMLWriter.php.

194 {
195 foreach($this->course_obj->getMembersObject()->getTutors() as $id)
196 {
197 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
198 $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
199 $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
200
201 $this->xmlStartTag('Tutor',$attr);
202 $this->xmlEndTag('Tutor');
203 }
204 return true;
205 }

References ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ __buildWaitingList()

ilCourseXMLWriter::__buildWaitingList ( )

Definition at line 235 of file class.ilCourseXMLWriter.php.

236 {
237 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
238
239 $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
240
241 foreach($waiting_list->getAllUsers() as $data)
242 {
243 $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$data['usr_id'];
244 $attr['position'] = $data['position'];
245 $attr['subscriptionTime'] = $data['time'];
246
247 $this->xmlStartTag('WaitingList',$attr);
248 $this->xmlEndTag('WaitingList');
249 }
250 return true;
251 }

References $data, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by start().

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

◆ getMode()

ilCourseXMLWriter::getMode ( )

Definition at line 78 of file class.ilCourseXMLWriter.php.

References $mode.

Referenced by start().

+ Here is the caller graph for this function:

◆ getXML()

ilCourseXMLWriter::getXML ( )

Definition at line 120 of file class.ilCourseXMLWriter.php.

121 {
122 #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
123 return $this->xmlDumpMem(false);
124 }
xmlDumpMem($format=TRUE)
Returns xml document from memory.

References ilXmlWriter\xmlDumpMem().

+ Here is the call graph for this function:

◆ ilCourseXMLWriter()

ilCourseXMLWriter::ilCourseXMLWriter ( $course_obj)

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding @access public

Definition at line 61 of file class.ilCourseXMLWriter.php.

62 {
63 global $ilias;
64
65 parent::ilXmlWriter();
66
67 $this->EXPORT_VERSION = "2";
68
69 $this->ilias =& $ilias;
70 $this->course_obj =& $course_obj;
71 }
redirection script todo: (a better solution should control the processing via a xml file)

References $course_obj, and $ilias.

◆ modifyExportIdentifier()

ilCourseXMLWriter::modifyExportIdentifier (   $a_tag,
  $a_param,
  $a_value 
)

Definition at line 127 of file class.ilCourseXMLWriter.php.

128 {
129 if ($a_tag == "Identifier" && $a_param == "Entry")
130 {
131 $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
132 }
133
134 return $a_value;
135 }

◆ setAttachUsers()

ilCourseXMLWriter::setAttachUsers (   $value)

write access to attach user property, if set to false no users will be attached.

Parameters
unknown_type$value

Definition at line 379 of file class.ilCourseXMLWriter.php.

379 {
380 $this->attach_users = $value ? true : false;
381 }

◆ setMode()

ilCourseXMLWriter::setMode (   $a_mode)

Definition at line 73 of file class.ilCourseXMLWriter.php.

74 {
75 $this->mode = $a_mode;
76 }

◆ start()

ilCourseXMLWriter::start ( )

Definition at line 83 of file class.ilCourseXMLWriter.php.

84 {
85 if($this->getMode() == self::MODE_SOAP)
86 {
87
88 $this->__buildHeader();
89 $this->__buildCourseStart();
90 $this->__buildMetaData();
92 if ($this->attach_users)
93 {
94 $this->__buildAdmin();
95 $this->__buildTutor();
96 $this->__buildMember();
97 }
98 $this->__buildSubscriber();
99 $this->__buildWaitingList();
100
101 $this->__buildSetting();
102 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
103 ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->course_obj->getId());
104 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
105 $this->__buildFooter();
106 }
107 elseif($this->getMode() == self::MODE_EXPORT)
108 {
109 $this->__buildCourseStart();
110 $this->__buildMetaData();
112 $this->__buildSetting();
113 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
114 ilContainerSortingSettings::_exportContainerSortingSettings($this,$this->course_obj->getId());
115 ilContainer::_exportContainerSettings($this, $this->course_obj->getId());
116 $this->__buildFooter();
117 }
118 }
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
__buildAdvancedMetaData()
Build advanced meta data.

References __buildAdmin(), __buildAdvancedMetaData(), __buildCourseStart(), __buildFooter(), __buildHeader(), __buildMember(), __buildMetaData(), __buildSetting(), __buildSubscriber(), __buildTutor(), __buildWaitingList(), ilContainer\_exportContainerSettings(), ilContainerSortingSettings\_exportContainerSortingSettings(), and getMode().

+ Here is the call graph for this function:

Field Documentation

◆ $attach_users

ilCourseXMLWriter::$attach_users = true
private

Definition at line 51 of file class.ilCourseXMLWriter.php.

◆ $course_obj

ilCourseXMLWriter::$course_obj
private

Definition at line 50 of file class.ilCourseXMLWriter.php.

Referenced by ilCourseXMLWriter().

◆ $ilias

ilCourseXMLWriter::$ilias
private

Definition at line 47 of file class.ilCourseXMLWriter.php.

Referenced by ilCourseXMLWriter().

◆ $mode

ilCourseXMLWriter::$mode = self::MODE_SOAP
private

Definition at line 44 of file class.ilCourseXMLWriter.php.

Referenced by getMode().

◆ $xml

ilCourseXMLWriter::$xml
private

Definition at line 49 of file class.ilCourseXMLWriter.php.

◆ MODE_EXPORT

const ilCourseXMLWriter::MODE_EXPORT = 2

Definition at line 42 of file class.ilCourseXMLWriter.php.

Referenced by ilCourseExporter\getXmlRepresentation().

◆ MODE_SOAP

const ilCourseXMLWriter::MODE_SOAP = 1

Definition at line 41 of file class.ilCourseXMLWriter.php.


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