ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once "./Services/Xml/classes/class.ilXmlWriter.php";
5
13{
17 protected $settings;
18
19 const MODE_SOAP = 1;
20 const MODE_EXPORT = 2;
21
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
100 protected function buildHeader()
101 {
103
104 $this->xmlSetDtdDef("<!DOCTYPE container reference PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_container_reference_4_3.dtd\">");
105 $this->xmlSetGenCmt("Export of ILIAS container reference " . $this->getReference()->getId() . " of installation " . $ilSetting->get('inst_id') . ".");
106 $this->xmlHeader();
107
108 return true;
109 }
110
114 protected function buildTarget()
115 {
116 $this->xmlElement('Target', array('id' => $this->getReference()->getTargetId()));
117 }
118
122 protected function buildTitle()
123 {
124 $title = '';
125 if ($this->getReference()->getTitleType() == ilContainerReference::TITLE_TYPE_CUSTOM) {
126 $title = $this->getReference()->getTitle();
127 }
128
129 $this->xmlElement(
130 'Title',
131 array(
132 'type' => $this->getReference()->getTitleType()
133 ),
134 $title
135 );
136 }
137
141 protected function buildReference()
142 {
143 $this->xmlStartTag('ContainerReference');
144 }
145
149 protected function buildFooter()
150 {
151 $this->xmlEndTag('ContainerReference');
152 }
153}
An exception for terminatinating execution or to throw for unit testing.
Class for container reference export.
__construct(ilContainerReference $ref=null)
constructor
buildHeader()
Build xml header @global <type> $ilSetting.
export($a_with_header=true)
Start wrting xml.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlDumpMem($format=true)
Returns xml document from memory.
xmlHeader()
Writes xml header @access public.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2