ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
20  protected $tree;
21 
22  protected $exp_options = null;
23  private $source = 0;
24 
28  public function __construct($a_ref_id)
29  {
30  global $DIC;
31 
32  $this->tree = $DIC->repositoryTree();
33  parent::__construct();
34  $this->source = $a_ref_id;
35  $this->exp_options = ilExportOptions::getInstance();
36  }
37 
43  public function write()
44  {
45  $this->xmlStartTag('Items');
46  $this->writeSubitems($this->source);
47  $this->xmlEndTag('Items');
48  }
49 
56  protected function writeSubitems($a_ref_id)
57  {
59 
60  // because of the co-page-stuff (incl. styles) we also need to process the container itself
61  if ($a_ref_id != $this->source) {
62  $mode = $this->exp_options->getOptionByRefId($a_ref_id, ilExportOptions::KEY_ITEM_MODE);
63  if ($mode == null or $mode == ilExportOptions::EXPORT_OMIT) {
64  return false;
65  }
66  }
67 
68  $obj_id = ilObject::_lookupObjId($a_ref_id);
69 
70  include_once('./Services/Container/classes/class.ilContainerPage.php');
71  include_once('./Services/Container/classes/class.ilContainerStartObjectsPage.php');
72  include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php');
73 
74  $this->xmlStartTag(
75  'Item',
76  array(
77  'RefId' => $a_ref_id,
78  'Id' => $obj_id,
79  'Title' => ilObject::_lookupTitle($obj_id),
80  'Type' => ilObject::_lookupType($obj_id),
81  'Page' => ilContainerPage::_exists('cont', $obj_id),
82  'StartPage' => ilContainerStartObjectsPage::_exists('cstr', $obj_id),
83  'Style' => ilObjStyleSheet::lookupObjectStyle($obj_id)
84  )
85  );
86 
87  $this->writeCourseItemInformation($a_ref_id);
88 
89  foreach ($tree->getChilds($a_ref_id) as $node) {
90  $this->writeSubitems($node['child']);
91  }
92 
93  $this->xmlEndTag('Item');
94  return true;
95  }
96 
97 
104  protected function writeCourseItemInformation($a_ref_id)
105  {
106  include_once './Services/Object/classes/class.ilObjectActivation.php';
107  $item = ilObjectActivation::getItem($a_ref_id);
108 
109  $this->xmlStartTag(
110  'Timing',
111  array(
112  'Type' => $item['timing_type'],
113  'Visible' => $item['visible'],
114  'Changeable'=> $item['changeable'],
115  )
116  );
117  if ($item['timing_start']) {
118  $tmp_date = new ilDateTime($item['timing_start'], IL_CAL_UNIX);
119  $this->xmlElement('Start', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
120  }
121  if ($item['timing_end']) {
122  $tmp_date = new ilDateTime($item['timing_end'], IL_CAL_UNIX);
123  $this->xmlElement('End', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
124  }
125  if ($item['suggestion_start']) {
126  $tmp_date = new ilDateTime($item['suggestion_start'], IL_CAL_UNIX);
127  $this->xmlElement('SuggestionStart', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
128  }
129  if ($item['suggestion_end']) {
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  $tmp_date = new ilDateTime($item['earliest_start'], IL_CAL_UNIX);
135  $this->xmlElement('EarliestStart', array(), $tmp_date->get(IL_CAL_DATETIME, '', ilTimeZone::UTC));
136  }
137  if ($item['latest_end']) {
138  $tmp_date = new ilDateTime($item['latest_end'], IL_CAL_UNIX);
139  $this->xmlElement('LatestEnd', 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 }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetGenCmt($genCmt)
Sets generated comment.
const IL_CAL_DATETIME
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $DIC
Definition: saml.php:7
static getInstance()
Get singelton instance.
static getItem($a_ref_id)
Get item data.
writeSubitems($a_ref_id)
Write tree childs Recursive method.
XML writer class.
static _lookupTitle($a_id)
lookup object title
const IL_CAL_UNIX
static lookupObjectStyle($a_obj_id)
Lookup object style.
xmlEndTag($tag)
Writes an endtag.
writeCourseItemInformation($a_ref_id)
Write course item information Starting time, ending time...
static _lookupObjId($a_id)
Date and time handling
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
__construct($a_ref_id)
Constructor.
XML writer for container structure.