ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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();
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}
An exception for terminatinating execution or to throw for unit testing.
Class for container reference export.
__construct(ilContainerReference $ref=null)
constructor
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46