ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $tree
 
 $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 28 of file class.ilContainerXmlWriter.php.

References $DIC, and ilExportOptions\getInstance().

29  {
30  global $DIC;
31 
32  $this->tree = $DIC->repositoryTree();
33  parent::__construct();
34  $this->source = $a_ref_id;
35  $this->exp_options = ilExportOptions::getInstance();
36  }
global $DIC
Definition: saml.php:7
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 149 of file class.ilContainerXmlWriter.php.

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

150  {
151  $this->xmlSetDtdDef("<!DOCTYPE Container PUBLIC \"-//ILIAS//DTD Container//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_container_4_1.dtd\">");
152  $this->xmlSetGenCmt("Container object");
153  $this->xmlHeader();
154 
155  return true;
156  }
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 43 of file class.ilContainerXmlWriter.php.

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

44  {
45  $this->xmlStartTag('Items');
46  $this->writeSubitems($this->source);
47  $this->xmlEndTag('Items');
48  }
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 104 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().

105  {
106  include_once './Services/Object/classes/class.ilObjectActivation.php';
107  $item = ilObjectActivation::getItem($a_ref_id);
108 
109  $this->xmlStartTag(
110  'Timing',
111  array(
112  'Type' => $item['timing_type'],
113  'Visible' => $item['visible'],
114  'Changeable'=> $item['changeable'],
115  )
116  );
117  if ($item['timing_start']) {
118  $tmp_date = new ilDateTime($item['timing_start'], IL_CAL_UNIX);
119  $this->xmlElement('Start', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
120  }
121  if ($item['timing_end']) {
122  $tmp_date = new ilDateTime($item['timing_end'], IL_CAL_UNIX);
123  $this->xmlElement('End', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
124  }
125  if ($item['suggestion_start']) {
126  $tmp_date = new ilDateTime($item['suggestion_start'], IL_CAL_UNIX);
127  $this->xmlElement('SuggestionStart', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
128  }
129  if ($item['suggestion_end']) {
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  $tmp_date = new ilDateTime($item['earliest_start'], IL_CAL_UNIX);
135  $this->xmlElement('EarliestStart', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
136  }
137  if ($item['latest_end']) {
138  $tmp_date = new ilDateTime($item['latest_end'], IL_CAL_UNIX);
139  $this->xmlElement('LatestEnd', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
140  }
141 
142  $this->xmlEndTag('Timing');
143  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
const IL_CAL_DATETIME
static getItem($a_ref_id)
Get item data.
const IL_CAL_UNIX
xmlEndTag($tag)
Writes an endtag.
Date and time handling
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ 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 56 of file class.ilContainerXmlWriter.php.

References $tree, 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().

57  {
59 
60  // because of the co-page-stuff (incl. styles) we also need to process the container itself
61  if ($a_ref_id != $this->source) {
62  $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
63  if ($mode == null or $mode == ilExportOptions::EXPORT_OMIT) {
64  return false;
65  }
66  }
67 
68  $obj_id = ilObject::_lookupObjId($a_ref_id);
69 
70  include_once('./Services/Container/classes/class.ilContainerPage.php');
71  include_once('./Services/Container/classes/class.ilContainerStartObjectsPage.php');
72  include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php');
73 
74  $this->xmlStartTag(
75  'Item',
76  array(
77  'RefId' => $a_ref_id,
78  'Id' => $obj_id,
79  'Title' => ilObject::_lookupTitle($obj_id),
80  'Type' => ilObject::_lookupType($obj_id),
81  'Page' => ilContainerPage::_exists('cont', $obj_id),
82  'StartPage' => ilContainerStartObjectsPage::_exists('cstr', $obj_id),
83  'Style' => ilObjStyleSheet::lookupObjectStyle($obj_id)
84  )
85  );
86 
87  $this->writeCourseItemInformation($a_ref_id);
88 
89  foreach ($tree->getChilds($a_ref_id) as $node) {
90  $this->writeSubitems($node['child']);
91  }
92 
93  $this->xmlEndTag('Item');
94  return true;
95  }
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 22 of file class.ilContainerXmlWriter.php.

◆ $source

ilContainerXmlWriter::$source = 0
private

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

◆ $tree

ilContainerXmlWriter::$tree
protected

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

Referenced by writeSubitems().


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