ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilContainerXmlWriter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_ref_id)
 
 write ()
 Write XML. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Protected Member Functions

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

Protected Attributes

ilTree $tree
 
ilExportOptions $exp_options = null
 
ilObjectDefinition $objDefinition
 

Private Attributes

int $source = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning XML writer for container structure

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

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerXmlWriter::__construct ( int  $a_ref_id)

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

32 {
33 global $DIC;
34
35 $this->tree = $DIC->repositoryTree();
37 $this->source = $a_ref_id;
38 $this->exp_options = ilExportOptions::getInstance();
39 $this->objDefinition = $DIC['objDefinition'];
40 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildHeader()

ilContainerXmlWriter::buildHeader ( )
protected

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

136 : void
137 {
138 $this->xmlSetGenCmt("Container object");
139 $this->xmlHeader();
140 }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlHeader()
Writes xml header.

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

+ Here is the call graph for this function:

◆ write()

ilContainerXmlWriter::write ( )

Write XML.

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

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

46 : void
47 {
48 $this->xmlStartTag('Items');
49 $this->writeSubitems($this->source);
50 $this->xmlEndTag('Items');
51 }
writeSubitems(int $a_ref_id)
Write tree childs Recursive method.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.

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

+ Here is the call graph for this function:

◆ writeCourseItemInformation()

ilContainerXmlWriter::writeCourseItemInformation ( int  $a_ref_id)
protected

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

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

100 : void
101 {
102 $item = ilObjectActivation::getItem($a_ref_id);
103
104 $this->xmlStartTag(
105 'Timing',
106 [
107 'Type' => $item['timing_type'],
108 'Visible' => $item['visible'],
109 'Changeable' => $item['changeable'],
110 ]
111 );
112 if ($item['timing_start']) {
113 $tmp_date = new ilDateTime($item['timing_start'], IL_CAL_UNIX);
114 $this->xmlElement('Start', [], $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
115 }
116 if ($item['timing_end']) {
117 $tmp_date = new ilDateTime($item['timing_end'], IL_CAL_UNIX);
118 $this->xmlElement('End', [], $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
119 }
120 if ($item['suggestion_start']) {
121 $tmp_date = new ilDateTime($item['suggestion_start'], IL_CAL_UNIX);
122 $this->xmlElement('SuggestionStart', [], $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
123 }
124 if ($item['suggestion_end']) {
125 $tmp_date = new ilDateTime($item['suggestion_end'], IL_CAL_UNIX);
126 $this->xmlElement('SuggestionEnd', [], $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
127 }
128 if ($item['earliest_start'] ?? false) {
129 $tmp_date = new ilDateTime($item['earliest_start'], IL_CAL_UNIX);
130 $this->xmlElement('EarliestStart', [], $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
131 }
132
133 $this->xmlEndTag('Timing');
134 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
static getItem(int $ref_id)
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

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

Referenced by writeSubitems().

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

◆ writeSubitems()

ilContainerXmlWriter::writeSubitems ( int  $a_ref_id)
protected

Write tree childs Recursive method.

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

57 : void
58 {
60
61 // because of the co-page-stuff (incl. styles) we also need to process the container itself
62 if ($a_ref_id != $this->source) {
63 $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
64 if ($mode == null || $mode == ilExportOptions::EXPORT_OMIT) {
65 return;
66 }
67 }
68
69 $obj_id = ilObject::_lookupObjId($a_ref_id);
70
71 $atts = [];
72 $atts['RefId'] = $a_ref_id;
73 $atts['Id'] = $obj_id;
74 $atts['Title'] = ilObject::_lookupTitle($obj_id);
75 $atts['Type'] = ilObject::_lookupType($obj_id);
76 $atts['Page'] = ilContainerPage::_exists('cont', $obj_id);
77 $atts['StartPage'] = ilContainerStartObjectsPage::_exists('cstr', $obj_id);
78 $atts['Style'] = ilObjStyleSheet::lookupObjectStyle($obj_id);
79 if ($this->objDefinition->supportsOfflineHandling($atts['Type'])) {
80 $atts['Offline'] = ilObject::lookupOfflineStatus($obj_id) ? '1' : '0';
81 }
82 $this->xmlStartTag(
83 'Item',
84 $atts
85 );
86 $this->writeCourseItemInformation($a_ref_id);
87
88 foreach ($tree->getChilds($a_ref_id) as $node) {
89 $this->writeSubitems($node['child']);
90 }
91
92 $this->xmlEndTag('Item');
93 }
writeCourseItemInformation(int $a_ref_id)
Write course item information Starting time, ending time...
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node

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

Referenced by write(), and writeSubitems().

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

Field Documentation

◆ $exp_options

ilExportOptions ilContainerXmlWriter::$exp_options = null
protected

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

◆ $objDefinition

ilObjectDefinition ilContainerXmlWriter::$objDefinition
protected

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

◆ $source

int ilContainerXmlWriter::$source = 0
private

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

◆ $tree

ilTree ilContainerXmlWriter::$tree
protected

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

Referenced by writeSubitems().


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