ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilContainerReferenceXmlWriter.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 
13 {
17  protected $settings;
18 
19  const MODE_SOAP = 1;
20  const MODE_EXPORT = 2;
21 
22  private $mode = self::MODE_SOAP;
23  private $xml;
24  private $ref;
25 
33  public function __construct(ilContainerReference $ref = null)
34  {
35  global $DIC;
36 
37  $this->settings = $DIC->settings();
38  parent::__construct();
39  $this->ref = $ref;
40  }
41 
46  public function setMode($a_mode)
47  {
48  $this->mode = $a_mode;
49  }
50 
55  public function getMode()
56  {
57  return $this->mode;
58  }
59 
64  public function getReference()
65  {
66  return $this->ref;
67  }
68 
69 
73  public function export($a_with_header = true)
74  {
75  if ($this->getMode() == self::MODE_EXPORT) {
76  if ($a_with_header) {
77  $this->buildHeader();
78  }
79  $this->buildReference();
80  $this->buildTarget();
81  $this->buildTitle();
82  $this->buildFooter();
83  }
84  }
85 
90  public function getXml()
91  {
92  return $this->xmlDumpMem(false);
93  }
94 
99  protected function buildHeader()
100  {
102 
103  $this->xmlSetDtdDef("<!DOCTYPE container reference PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_container_reference_4_3.dtd\">");
104  $this->xmlSetGenCmt("Export of ILIAS container reference " . $this->getReference()->getId() . " of installation " . $ilSetting->get('inst_id') . ".");
105  $this->xmlHeader();
106 
107  return true;
108  }
109 
113  protected function buildTarget()
114  {
115  $this->xmlElement('Target', array('id' => $this->getReference()->getTargetId()));
116  }
117 
121  protected function buildTitle()
122  {
123  $title = '';
124  if ($this->getReference()->getTitleType() == ilContainerReference::TITLE_TYPE_CUSTOM) {
125  $title = $this->getReference()->getTitle();
126  }
127 
128  $this->xmlElement(
129  'Title',
130  array(
131  'type' => $this->getReference()->getTitleType()
132  ),
133  $title
134  );
135  }
136 
140  protected function buildReference()
141  {
142  $this->xmlStartTag('ContainerReference');
143  }
144 
148  protected function buildFooter()
149  {
150  $this->xmlEndTag('ContainerReference');
151  }
152 }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetGenCmt($genCmt)
Sets generated comment.
settings()
Definition: settings.php:2
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $DIC
Definition: saml.php:7
xmlDumpMem($format=true)
Returns xml document from memory.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlHeader()
Writes xml header public.
__construct(ilContainerReference $ref=null)
constructor
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilSetting
Definition: privfeed.php:17
export($a_with_header=true)
Start wrting xml.
Class for container reference export.