ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
17 protected $exp_options = null;
18 private $source = 0;
19
23 public function __construct($a_ref_id)
24 {
25 parent::__construct();
26 $this->source = $a_ref_id;
27 $this->exp_options = ilExportOptions::getInstance();
28
29 }
30
36 public function write()
37 {
38 $this->xmlStartTag('Items');
39 $this->writeSubitems($this->source);
40 $this->xmlEndTag('Items');
41 }
42
49 protected function writeSubitems($a_ref_id)
50 {
51 global $tree;
52
53 // because of the co-page-stuff (incl. styles) we also need to process the container itself
54 if($a_ref_id != $this->source)
55 {
56 $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
57 if($mode == NULL or $mode == ilExportOptions::EXPORT_OMIT)
58 {
59 return false;
60 }
61 }
62
63 $obj_id = ilObject::_lookupObjId($a_ref_id);
64
65 include_once('./Services/Container/classes/class.ilContainerPage.php');
66 include_once('./Services/Container/classes/class.ilContainerStartObjectsPage.php');
67 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
68
69 $this->xmlStartTag(
70 'Item',
71 array(
72 'RefId' => $a_ref_id,
73 'Id' => $obj_id,
74 'Title' => ilObject::_lookupTitle($obj_id),
75 'Type' => ilObject::_lookupType($obj_id),
76 'Page' => ilContainerPage::_exists('cont', $obj_id),
77 'StartPage' => ilContainerStartObjectsPage::_exists('cstr', $obj_id),
78 'Style' => ilObjStyleSheet::lookupObjectStyle($obj_id)
79 )
80 );
81
82 $this->writeCourseItemInformation($a_ref_id);
83
84 foreach($tree->getChilds($a_ref_id) as $node)
85 {
86 $this->writeSubitems($node['child']);
87 }
88
89 $this->xmlEndTag('Item');
90 return true;
91 }
92
93
100 protected function writeCourseItemInformation($a_ref_id)
101 {
102 include_once './Services/Object/classes/class.ilObjectActivation.php';
103 $item = ilObjectActivation::getItem($a_ref_id);
104
105 $this->xmlStartTag(
106 'Timing',
107 array(
108 'Type' => $item['timing_type'],
109 'Visible' => $item['visible'],
110 'Changeable'=> $item['changeable'],
111 )
112 );
113 if($item['timing_start'])
114 {
115 $tmp_date = new ilDateTime($item['timing_start'],IL_CAL_UNIX);
116 $this->xmlElement('Start',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
117 }
118 if($item['timing_end'])
119 {
120 $tmp_date = new ilDateTime($item['timing_end'],IL_CAL_UNIX);
121 $this->xmlElement('End',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
122 }
123 if($item['suggestion_start'])
124 {
125 $tmp_date = new ilDateTime($item['suggestion_start'],IL_CAL_UNIX);
126 $this->xmlElement('SuggestionStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
127 }
128 if($item['suggestion_end'])
129 {
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 {
135 $tmp_date = new ilDateTime($item['earliest_start'],IL_CAL_UNIX);
136 $this->xmlElement('EarliestStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
137 }
138 if($item['latest_end'])
139 {
140 $tmp_date = new ilDateTime($item['latest_end'],IL_CAL_UNIX);
141 $this->xmlElement('LatestEnd',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
142 }
143
144 $this->xmlEndTag('Timing');
145
146 }
147
152 protected function buildHeader()
153 {
154 $this->xmlSetDtdDef("<!DOCTYPE Container PUBLIC \"-//ILIAS//DTD Container//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_container_4_1.dtd\">");
155 $this->xmlSetGenCmt("Container object");
156 $this->xmlHeader();
157
158 return true;
159 }
160
161
162}
163?>
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 _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.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)