ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilContainerXmlWriter Class Reference

XML writer for container structure. More...

+ Inheritance diagram for ilContainerXmlWriter:
+ Collaboration diagram for ilContainerXmlWriter:

Public Member Functions

 __construct ($a_ref_id)
 Constructor. More...
 
 write ()
 Write XML. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($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...
 
 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...
 

Protected Member Functions

 writeSubitems ($a_ref_id)
 Write tree childs Recursive method. More...
 
 writeCourseItemInformation ($a_ref_id)
 Write course item information Starting time, ending time... More...
 
 buildHeader ()
 Build XML header. More...
 

Protected Attributes

 $exp_options = null
 

Private Attributes

 $source = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Detailed Description

XML writer for container structure.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 15 of file class.ilContainerXmlWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerXmlWriter::__construct (   $a_ref_id)

Constructor.

Definition at line 23 of file class.ilContainerXmlWriter.php.

References ilExportOptions\getInstance().

24  {
25  parent::__construct();
26  $this->source = $a_ref_id;
27  $this->exp_options = ilExportOptions::getInstance();
28 
29  }
static getInstance()
Get singelton instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ buildHeader()

ilContainerXmlWriter::buildHeader ( )
protected

Build XML header.

Returns

Definition at line 152 of file class.ilContainerXmlWriter.php.

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

153  {
154  $this->xmlSetDtdDef("<!DOCTYPE Container PUBLIC \"-//ILIAS//DTD Container//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_container_4_1.dtd\">");
155  $this->xmlSetGenCmt("Container object");
156  $this->xmlHeader();
157 
158  return true;
159  }
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlHeader()
Writes xml header public.
+ Here is the call graph for this function:

◆ write()

ilContainerXmlWriter::write ( )

Write XML.

Returns
Exceptions
UnexpectedValueExceptionThrown if obj_id is not of type webr or no obj_id is given

Definition at line 36 of file class.ilContainerXmlWriter.php.

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

37  {
38  $this->xmlStartTag('Items');
39  $this->writeSubitems($this->source);
40  $this->xmlEndTag('Items');
41  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
writeSubitems($a_ref_id)
Write tree childs Recursive method.
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:

◆ writeCourseItemInformation()

ilContainerXmlWriter::writeCourseItemInformation (   $a_ref_id)
protected

Write course item information Starting time, ending time...

Parameters
int$a_ref_id
Returns

Definition at line 100 of file class.ilContainerXmlWriter.php.

References array, ilObjectActivation\getItem(), IL_CAL_DATETIME, IL_CAL_UNIX, ilTimeZone\UTC, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by writeSubitems().

101  {
102  include_once './Services/Object/classes/class.ilObjectActivation.php';
103  $item = ilObjectActivation::getItem($a_ref_id);
104 
105  $this->xmlStartTag(
106  'Timing',
107  array(
108  'Type' => $item['timing_type'],
109  'Visible' => $item['visible'],
110  'Changeable'=> $item['changeable'],
111  )
112  );
113  if($item['timing_start'])
114  {
115  $tmp_date = new ilDateTime($item['timing_start'],IL_CAL_UNIX);
116  $this->xmlElement('Start',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
117  }
118  if($item['timing_end'])
119  {
120  $tmp_date = new ilDateTime($item['timing_end'],IL_CAL_UNIX);
121  $this->xmlElement('End',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
122  }
123  if($item['suggestion_start'])
124  {
125  $tmp_date = new ilDateTime($item['suggestion_start'],IL_CAL_UNIX);
126  $this->xmlElement('SuggestionStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
127  }
128  if($item['suggestion_end'])
129  {
130  $tmp_date = new ilDateTime($item['suggestion_end'],IL_CAL_UNIX);
131  $this->xmlElement('SuggestionEnd',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
132  }
133  if($item['earliest_start'])
134  {
135  $tmp_date = new ilDateTime($item['earliest_start'],IL_CAL_UNIX);
136  $this->xmlElement('EarliestStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
137  }
138  if($item['latest_end'])
139  {
140  $tmp_date = new ilDateTime($item['latest_end'],IL_CAL_UNIX);
141  $this->xmlElement('LatestEnd',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
142  }
143 
144  $this->xmlEndTag('Timing');
145 
146  }
const IL_CAL_DATETIME
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
static getItem($a_ref_id)
Get item data.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
const IL_CAL_UNIX
xmlEndTag($tag)
Writes an endtag.
Date and time handling
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeSubitems()

ilContainerXmlWriter::writeSubitems (   $a_ref_id)
protected

Write tree childs Recursive method.

Parameters
object$a_ref_id
Returns

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

References ilPageObject\_exists(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), array, ilExportOptions\EXPORT_OMIT, ilExportOptions\KEY_ITEM_MODE, ilObjStyleSheet\lookupObjectStyle(), writeCourseItemInformation(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by write().

50  {
51  global $tree;
52 
53  // because of the co-page-stuff (incl. styles) we also need to process the container itself
54  if($a_ref_id != $this->source)
55  {
56  $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
57  if($mode == NULL or $mode == ilExportOptions::EXPORT_OMIT)
58  {
59  return false;
60  }
61  }
62 
63  $obj_id = ilObject::_lookupObjId($a_ref_id);
64 
65  include_once('./Services/Container/classes/class.ilContainerPage.php');
66  include_once('./Services/Container/classes/class.ilContainerStartObjectsPage.php');
67  include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php');
68 
69  $this->xmlStartTag(
70  'Item',
71  array(
72  'RefId' => $a_ref_id,
73  'Id' => $obj_id,
74  'Title' => ilObject::_lookupTitle($obj_id),
75  'Type' => ilObject::_lookupType($obj_id),
76  'Page' => ilContainerPage::_exists('cont', $obj_id),
77  'StartPage' => ilContainerStartObjectsPage::_exists('cstr', $obj_id),
78  'Style' => ilObjStyleSheet::lookupObjectStyle($obj_id)
79  )
80  );
81 
82  $this->writeCourseItemInformation($a_ref_id);
83 
84  foreach($tree->getChilds($a_ref_id) as $node)
85  {
86  $this->writeSubitems($node['child']);
87  }
88 
89  $this->xmlEndTag('Item');
90  return true;
91  }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
writeSubitems($a_ref_id)
Write tree childs Recursive method.
static _lookupTitle($a_id)
lookup object title
static lookupObjectStyle($a_obj_id)
Lookup object style.
xmlEndTag($tag)
Writes an endtag.
writeCourseItemInformation($a_ref_id)
Write course item information Starting time, ending time...
static _lookupObjId($a_id)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $exp_options

ilContainerXmlWriter::$exp_options = null
protected

Definition at line 17 of file class.ilContainerXmlWriter.php.

◆ $source

ilContainerXmlWriter::$source = 0
private

Definition at line 18 of file class.ilContainerXmlWriter.php.


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