ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
5 include_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  {
26  $this->source = $a_ref_id;
27  $this->exp_options = ilExportOptions::getInstance();
28 
29  }
30 
36  public function write()
37  {
38  global $tree;
39 
40  $this->xmlStartTag('Items');
41  $this->writeSubitems($this->source);
42  $this->xmlEndTag('Items');
43  }
44 
51  protected function writeSubitems($a_ref_id)
52  {
53  global $tree;
54 
55  $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
56  if($mode == NULL or $mode == ilExportOptions::EXPORT_OMIT)
57  {
58  return false;
59  }
60 
61  $obj_id = ilObject::_lookupObjId($a_ref_id);
62 
63  $this->xmlStartTag(
64  'Item',
65  array(
66  'RefId' => $a_ref_id,
67  'Id' => $obj_id,
68  'Title' => ilObject::_lookupTitle($obj_id),
69  'Type' => ilObject::_lookupType($obj_id)
70  )
71  );
72 
73  $this->writeCourseItemInformation($a_ref_id);
74 
75  foreach($tree->getChilds($a_ref_id) as $node)
76  {
77  $this->writeSubitems($node['child']);
78  }
79 
80  $this->xmlEndTag('Item');
81  return true;
82  }
83 
84 
91  protected function writeCourseItemInformation($a_ref_id)
92  {
93  include_once './Modules/Course/classes/class.ilCourseItems.php';
94  $item = ilCourseItems::_getItem($a_ref_id);
95 
96  $this->xmlStartTag(
97  'Timing',
98  array(
99  'Type' => $item['timing_type'],
100  'Visible' => $item['visible'],
101  'Changeable'=> $item['changeable'],
102  )
103  );
104  if($item['timing_start'])
105  {
106  $tmp_date = new ilDateTime($item['timing_start'],IL_CAL_UNIX);
107  $this->xmlElement('Start',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
108  }
109  if($item['timing_end'])
110  {
111  $tmp_date = new ilDateTime($item['timing_end'],IL_CAL_UNIX);
112  $this->xmlElement('End',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
113  }
114  if($item['suggestion_start'])
115  {
116  $tmp_date = new ilDateTime($item['suggestion_start'],IL_CAL_UNIX);
117  $this->xmlElement('SuggestionStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
118  }
119  if($item['suggestion_end'])
120  {
121  $tmp_date = new ilDateTime($item['suggestion_end'],IL_CAL_UNIX);
122  $this->xmlElement('SuggestionEnd',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
123  }
124  if($item['earliest_start'])
125  {
126  $tmp_date = new ilDateTime($item['earliest_start'],IL_CAL_UNIX);
127  $this->xmlElement('EarliestStart',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
128  }
129  if($item['latest_end'])
130  {
131  $tmp_date = new ilDateTime($item['latest_end'],IL_CAL_UNIX);
132  $this->xmlElement('LatestEnd',array(),$tmp_date->get(IL_CAL_DATETIME,'',ilTimeZone::UTC));
133  }
134 
135  $this->xmlEndTag('Timing');
136 
137  }
138 
143  protected function buildHeader()
144  {
145  $this->xmlSetDtdDef("<!DOCTYPE Container PUBLIC \"-//ILIAS//DTD Container//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_container_4_1.dtd\">");
146  $this->xmlSetGenCmt("Container object");
147  $this->xmlHeader();
148 
149  return true;
150  }
151 
152 
153 }
154 ?>