ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilContainerXmlWriter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/Xml/classes/class.ilXmlWriter.php";
5include_once './Services/Export/classes/class.ilExportOptions.php';
6
16{
20 protected $tree;
21
22 protected $exp_options = null;
23 private $source = 0;
24
28 protected $objDefinition;
29
33 public function __construct($a_ref_id)
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 }
43
49 public function write()
50 {
51 $this->xmlStartTag('Items');
52 $this->writeSubitems($this->source);
53 $this->xmlEndTag('Items');
54 }
55
62 protected function writeSubitems($a_ref_id)
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 }
100
101
108 protected function writeCourseItemInformation($a_ref_id)
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 }
144
149 protected function buildHeader()
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 }
157}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
XML writer for container structure.
writeSubitems($a_ref_id)
Write tree childs Recursive method.
__construct($a_ref_id)
Constructor.
writeCourseItemInformation($a_ref_id)
Write course item information Starting time, ending time...
@classDescription Date and time handling
static getInstance()
Get singelton instance.
static lookupObjectStyle($a_obj_id)
Lookup object style.
static getItem($a_ref_id)
Get item data.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlHeader()
Writes xml header @access public.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc