ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules 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 {
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 }
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.
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 lookupOfflineStatus($a_obj_id)
Lookup offline status using objectDataCache.
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
xmlHeader()
Writes xml header public.
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.
__construct(Container $dic, ilPlugin $plugin)
XML writer for container structure.