ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
 $objDefinition
 

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 33 of file class.ilContainerXmlWriter.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ilExportOptions\getInstance().

34  {
35  global $DIC;
36 
37  $this->tree = $DIC->repositoryTree();
39  $this->source = $a_ref_id;
40  $this->exp_options = ilExportOptions::getInstance();
41  $this->objDefinition = $DIC['objDefinition'];
42  }
static getInstance()
Get singelton instance.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
+ 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 49 of file class.ilContainerXmlWriter.php.

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

50  {
51  $this->xmlStartTag('Items');
52  $this->writeSubitems($this->source);
53  $this->xmlEndTag('Items');
54  }
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 108 of file class.ilContainerXmlWriter.php.

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

Referenced by writeSubitems().

109  {
110  include_once './Services/Object/classes/class.ilObjectActivation.php';
111  $item = ilObjectActivation::getItem($a_ref_id);
112 
113  $this->xmlStartTag(
114  'Timing',
115  array(
116  'Type' => $item['timing_type'],
117  'Visible' => $item['visible'],
118  'Changeable' => $item['changeable'],
119  )
120  );
121  if ($item['timing_start']) {
122  $tmp_date = new ilDateTime($item['timing_start'], IL_CAL_UNIX);
123  $this->xmlElement('Start', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
124  }
125  if ($item['timing_end']) {
126  $tmp_date = new ilDateTime($item['timing_end'], IL_CAL_UNIX);
127  $this->xmlElement('End', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
128  }
129  if ($item['suggestion_start']) {
130  $tmp_date = new ilDateTime($item['suggestion_start'], IL_CAL_UNIX);
131  $this->xmlElement('SuggestionStart', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
132  }
133  if ($item['suggestion_end']) {
134  $tmp_date = new ilDateTime($item['suggestion_end'], IL_CAL_UNIX);
135  $this->xmlElement('SuggestionEnd', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
136  }
137  if ($item['earliest_start']) {
138  $tmp_date = new ilDateTime($item['earliest_start'], IL_CAL_UNIX);
139  $this->xmlElement('EarliestStart', 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.
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 62 of file class.ilContainerXmlWriter.php.

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

Referenced by write().

63  {
65 
66  // because of the co-page-stuff (incl. styles) we also need to process the container itself
67  if ($a_ref_id != $this->source) {
68  $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
69  if ($mode == null or $mode == ilExportOptions::EXPORT_OMIT) {
70  return false;
71  }
72  }
73 
74  $obj_id = ilObject::_lookupObjId($a_ref_id);
75 
76  $atts = [];
77  $atts['RefId'] = $a_ref_id;
78  $atts['Id'] = $obj_id;
79  $atts['Title'] = ilObject::_lookupTitle($obj_id);
80  $atts['Type'] = ilObject::_lookupType($obj_id);
81  $atts['Page'] = ilContainerPage::_exists('cont', $obj_id);
82  $atts['StartPage'] = ilContainerStartObjectsPage::_exists('cstr', $obj_id);
83  $atts['Style'] = ilObjStyleSheet::lookupObjectStyle($obj_id);
84  if ($this->objDefinition->supportsOfflineHandling($atts['Type'])) {
85  $atts['Offline'] = ilObject::lookupOfflineStatus($obj_id) ? '1' : '0';
86  }
87  $this->xmlStartTag(
88  'Item',
89  $atts
90  );
91  $this->writeCourseItemInformation($a_ref_id);
92 
93  foreach ($tree->getChilds($a_ref_id) as $node) {
94  $this->writeSubitems($node['child']);
95  }
96 
97  $this->xmlEndTag('Item');
98  return true;
99  }
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 lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _lookupObjId($a_id)
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.

◆ $objDefinition

ilContainerXmlWriter::$objDefinition
protected

Definition at line 28 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: