ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilContainerXmlWriter.php
Go to the documentation of this file.
1<?php
2
25{
26 protected ilTree $tree;
27 protected ?ilExportOptions $exp_options = null;
28 private int $source = 0;
30
31 public function __construct(int $a_ref_id)
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 }
41
46 public function write(): void
47 {
48 $this->xmlStartTag('Items');
49 $this->writeSubitems($this->source);
50 $this->xmlEndTag('Items');
51 }
52
57 protected function writeSubitems(int $a_ref_id): 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 }
94
95
100 protected function writeCourseItemInformation(int $a_ref_id): 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 }
135
136 protected function buildHeader(): void
137 {
138 $this->xmlSetGenCmt("Container object");
139 $this->xmlHeader();
140 }
141}
const IL_CAL_UNIX
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
writeSubitems(int $a_ref_id)
Write tree childs Recursive method.
writeCourseItemInformation(int $a_ref_id)
Write course item information Starting time, ending time...
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupObjectStyle(int $a_obj_id)
Lookup object style.
static getItem(int $ref_id)
parses the objects.xml it handles the xml-description of all ilias objects
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.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26