ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCategoryXmlWriter.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 $category;
25
33 public function __construct(ilObjCategory $cat = null)
34 {
35 global $DIC;
36
37 $this->settings = $DIC->settings();
39
40 $this->category = $cat;
41 }
42
47 public function setMode($a_mode)
48 {
49 $this->mode = $a_mode;
50 }
51
56 public function getMode()
57 {
58 return $this->mode;
59 }
60
65 public function getCategory()
66 {
67 return $this->category;
68 }
69
70
74 public function export($a_with_header = true)
75 {
76 if ($this->getMode() == self::MODE_EXPORT) {
77 if ($a_with_header) {
78 $this->buildHeader();
79 }
80 $this->buildCategory();
81 $this->buildTranslations();
82 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
84 include_once './Services/Container/classes/class.ilContainer.php';
85 ilContainer::_exportContainerSettings($this, $this->category->getId());
86 $this->buildFooter();
87 }
88 }
89
94 public function getXml()
95 {
96 return $this->xmlDumpMem(false);
97 }
98
104 protected function buildHeader()
105 {
107
108 $this->xmlSetDtdDef("<!DOCTYPE category PUBLIC \"-//ILIAS//DTD Group//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_cat_4_5.dtd\">");
109 $this->xmlSetGenCmt("Export of ILIAS category " . $this->getCategory()->getId() . " of installation " . $ilSetting->get('inst_id') . ".");
110 $this->xmlHeader();
111
112
113 return true;
114 }
115
119 protected function buildCategory()
120 {
121 $this->xmlStartTag('Category');
122 }
123
127 protected function buildFooter()
128 {
129 $this->xmlEndTag('Category');
130 }
131
135 protected function buildTranslations()
136 {
137 $this->xmlStartTag('Translations');
138
139 $translations = $this->getCategory()->getObjectTranslation()->getLanguages();
140 foreach ((array) $translations as $translation) {
141 $this->xmlStartTag(
142 'Translation',
143 array(
144 'default' => (int) $translation['lang_default'],
145 'language' => $translation['lang_code'])
146 );
147 $this->xmlElement('Title', array(), $translation['title']);
148 $this->xmlElement('Description', array(), $translation['description']);
149 $this->xmlEndTag('Translation');
150 }
151 $this->xmlEndTag('Translations');
152 }
153}
An exception for terminatinating execution or to throw for unit testing.
Class for category export.
buildFooter()
Add footer elements.
__construct(ilObjCategory $cat=null)
constructor
getCategory()
Get category object.
buildHeader()
Build xml header @global <type> $ilSetting.
setMode($a_mode)
Set export mode.
buildTranslations()
Add Translations.
export($a_with_header=true)
Start wrting xml.
buildCategory()
Build category xml.
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
Class ilObjCategory.
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