ILIAS  release_4-4 Revision
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 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 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 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 174 of file class.ilCourseXMLWriter.php.

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

Referenced by start().

175  {
176  foreach($this->course_obj->getMembersObject()->getAdmins() as $id)
177  {
178  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
179  $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
180  $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
181 
182  $this->xmlStartTag('Admin',$attr);
183  $this->xmlEndTag('Admin');
184  }
185  return true;
186  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildAdvancedMetaData()

ilCourseXMLWriter::__buildAdvancedMetaData ( )
private

Build advanced meta data.

private

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

References ilAdvancedMDValues\_appendXMLByObjId().

Referenced by start().

169  {
170  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
171  ilAdvancedMDValues::_appendXMLByObjId($this,$this->course_obj->getId());
172  }
static _appendXMLByObjId(ilXmlWriter $xml_writer, $a_obj_id)
Get xml of object values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildCourseStart()

ilCourseXMLWriter::__buildCourseStart ( )

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

References ilXmlWriter\xmlStartTag().

Referenced by start().

144  {
145  $attrs["exportVersion"] = $this->EXPORT_VERSION;
146  $attrs["id"] = "il_".$this->ilias->getSetting('inst_id').'_crs_'.$this->course_obj->getId();
147  $attrs['showMembers'] = ($this->course_obj->getShowMembers() ? 'Yes' : 'No');
148  $this->xmlStartTag("Course", $attrs);
149  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildFooter()

ilCourseXMLWriter::__buildFooter ( )

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

References ilXmlWriter\xmlEndTag().

Referenced by start().

373  {
374  $this->xmlEndTag('Course');
375  }
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildHeader()

ilCourseXMLWriter::__buildHeader ( )

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

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

Referenced by start().

134  {
135  $this->xmlSetDtdDef("<!DOCTYPE Course PUBLIC \"-//ILIAS//DTD Course//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_course_3_10.dtd\">");
136  $this->xmlSetGenCmt("Export of ILIAS course ". $this->course_obj->getId()." of installation ".$this->ilias->getSetting('inst_id').".");
137  $this->xmlHeader();
138 
139 
140  return true;
141  }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
redirection script todo: (a better solution should control the processing via a xml file) ...
xmlHeader()
Writes xml header public.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildMember()

ilCourseXMLWriter::__buildMember ( )

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

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

Referenced by start().

202  {
203  foreach($this->course_obj->getMembersObject()->getMembers() as $id)
204  {
205  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
206  $attr['blocked'] = ($this->course_obj->getMembersObject()->isBlocked($id)) ? 'Yes' : 'No';
207  $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
208 
209  $this->xmlStartTag('Member',$attr);
210  $this->xmlEndTag('Member');
211  }
212  return true;
213  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildMetaData()

ilCourseXMLWriter::__buildMetaData ( )

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

References ilXmlWriter\appendXML(), and ilMD2XML\startExport().

Referenced by start().

152  {
153  include_once 'Services/MetaData/classes/class.ilMD2XML.php';
154 
155  $md2xml = new ilMD2XML($this->course_obj->getId(),$this->course_obj->getId(),'crs');
156  $md2xml->startExport();
157  $this->appendXML($md2xml->getXML());
158 
159  return true;
160  }
appendXML($a_str)
append xml string to document
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildSetting()

ilCourseXMLWriter::__buildSetting ( )

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

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

Referenced by start().

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

◆ __buildSubscriber()

ilCourseXMLWriter::__buildSubscriber ( )

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

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

Referenced by start().

216  {
217  foreach($this->course_obj->getMembersObject()->getSubscribers() as $id)
218  {
219  $data = $this->course_obj->getMembersObject()->getSubscriberData($id);
220 
221  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
222  $attr['subscriptionTime'] = $data['time'];
223 
224  $this->xmlStartTag('Subscriber',$attr);
225  $this->xmlEndTag('Subscriber');
226  }
227  return true;
228  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildTutor()

ilCourseXMLWriter::__buildTutor ( )

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

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

Referenced by start().

189  {
190  foreach($this->course_obj->getMembersObject()->getTutors() as $id)
191  {
192  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$id;
193  $attr['notification'] = ($this->course_obj->getMembersObject()->isNotificationEnabled($id)) ? 'Yes' : 'No';
194  $attr['passed'] = $this->course_obj->getMembersObject()->hasPassed($id) ? 'Yes' : 'No';
195 
196  $this->xmlStartTag('Tutor',$attr);
197  $this->xmlEndTag('Tutor');
198  }
199  return true;
200  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildWaitingList()

ilCourseXMLWriter::__buildWaitingList ( )

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

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

Referenced by start().

231  {
232  include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
233 
234  $waiting_list = new ilCourseWaitingList($this->course_obj->getId());
235 
236  foreach($waiting_list->getAllUsers() as $data)
237  {
238  $attr['id'] = 'il_'.$this->ilias->getSetting('inst_id').'_usr_'.$data['usr_id'];
239  $attr['position'] = $data['position'];
240  $attr['subscriptionTime'] = $data['time'];
241 
242  $this->xmlStartTag('WaitingList',$attr);
243  $this->xmlEndTag('WaitingList');
244  }
245  return true;
246  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ 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().

79  {
80  return $this->mode;
81  }
+ Here is the caller graph for this function:

◆ getXML()

ilCourseXMLWriter::getXML ( )

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

References ilXmlWriter\xmlDumpMem().

116  {
117  #var_dump("<pre>", htmlentities($this->xmlDumpMem()),"<pre>");
118  return $this->xmlDumpMem(false);
119  }
xmlDumpMem($format=TRUE)
Returns xml document from memory.
+ Here is the call graph for this function:

◆ ilCourseXMLWriter()

ilCourseXMLWriter::ilCourseXMLWriter ( $course_obj)

constructor

Parameters
stringxml version
stringoutput encoding
stringinput encoding public

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

References $course_obj, and $ilias.

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) ...

◆ modifyExportIdentifier()

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

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

123  {
124  if ($a_tag == "Identifier" && $a_param == "Entry")
125  {
126  $a_value = "il_".$this->ilias->getSetting('inst_id')."_crs_".$this->course_obj->getId();
127  }
128 
129  return $a_value;
130  }

◆ 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 382 of file class.ilCourseXMLWriter.php.

382  {
383  $this->attach_users = $value ? true : false;
384  }

◆ 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.

References __buildAdmin(), __buildAdvancedMetaData(), __buildCourseStart(), __buildFooter(), __buildHeader(), __buildMember(), __buildMetaData(), __buildSetting(), __buildSubscriber(), __buildTutor(), __buildWaitingList(), and getMode().

84  {
85  if($this->getMode() == self::MODE_SOAP)
86  {
87 
88  $this->__buildHeader();
89  $this->__buildCourseStart();
90  $this->__buildMetaData();
91  $this->__buildAdvancedMetaData();
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 
103  $this->__buildFooter();
104  }
105  elseif($this->getMode() == self::MODE_EXPORT)
106  {
107  $this->__buildCourseStart();
108  $this->__buildMetaData();
109  $this->__buildAdvancedMetaData();
110  $this->__buildSetting();
111  $this->__buildFooter();
112  }
113  }
__buildAdvancedMetaData()
Build advanced meta data.
+ 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: