ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
14  const MODE_SOAP = 1;
15  const MODE_EXPORT = 2;
16 
18  private $xml;
19  private $ref;
20 
28  public function __construct(ilContainerReference $ref = null)
29  {
31  $this->ref = $ref;
32  }
33 
38  public function setMode($a_mode)
39  {
40  $this->mode = $a_mode;
41  }
42 
47  public function getMode()
48  {
49  return $this->mode;
50  }
51 
56  public function getReference()
57  {
58  return $this->ref;
59  }
60 
61 
65  public function export($a_with_header = true)
66  {
67  if($this->getMode() == self::MODE_EXPORT)
68  {
69  if($a_with_header)
70  {
71  $this->buildHeader();
72  }
73  $this->buildReference();
74  $this->buildTarget();
75  $this->buildTitle();
76  $this->buildFooter();
77  }
78  }
79 
84  public function getXml()
85  {
86  return $this->xmlDumpMem(false);
87  }
88 
94  protected function buildHeader()
95  {
96  global $ilSetting;
97 
98  $this->xmlSetDtdDef("<!DOCTYPE container reference PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_container_reference_4_3.dtd\">");
99  $this->xmlSetGenCmt("Export of ILIAS container reference ". $this->getReference()->getId()." of installation ".$ilSetting->get('inst_id').".");
100  $this->xmlHeader();
101 
102  return true;
103  }
104 
108  protected function buildTarget()
109  {
110  $this->xmlElement('Target', array('id' => $this->getReference()->getTargetId()));
111  }
112 
116  protected function buildTitle()
117  {
118  $title = '';
119  if($this->getReference()->getTitleType() == ilContainerReference::TITLE_TYPE_CUSTOM)
120  {
121  $title = $this->getReference()->getTitle();
122  }
123 
124  $this->xmlElement(
125  'Title',
126  array(
127  'type' => $this->getReference()->getTitleType()
128  ),
129  $title
130  );
131  }
132 
136  protected function buildReference()
137  {
138  $this->xmlStartTag('ContainerReference');
139  }
140 
144  protected function buildFooter()
145  {
146  $this->xmlEndTag('ContainerReference');
147  }
148 }
149 ?>