ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
14 const MODE_SOAP = 1;
15 const MODE_EXPORT = 2;
16
18 private $xml;
19 private $category;
20
28 public function __construct(ilObjCategory $cat = null)
29 {
30 global $ilias;
31
32 parent::__construct();
33
34 $this->category = $cat;
35 }
36
41 public function setMode($a_mode)
42 {
43 $this->mode = $a_mode;
44 }
45
50 public function getMode()
51 {
52 return $this->mode;
53 }
54
59 public function getCategory()
60 {
61 return $this->category;
62 }
63
64
68 public function export($a_with_header = true)
69 {
70 if($this->getMode() == self::MODE_EXPORT)
71 {
72 if($a_with_header)
73 {
74 $this->buildHeader();
75 }
76 $this->buildCategory();
77 $this->buildTranslations();
78 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
80 include_once './Services/Container/classes/class.ilContainer.php';
81 ilContainer::_exportContainerSettings($this, $this->category->getId());
82 $this->buildFooter();
83 }
84 }
85
90 public function getXml()
91 {
92 return $this->xmlDumpMem(false);
93 }
94
100 protected function buildHeader()
101 {
102 global $ilSetting;
103
104 $this->xmlSetDtdDef("<!DOCTYPE category PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_cat_4_5.dtd\">");
105 $this->xmlSetGenCmt("Export of ILIAS category ". $this->getCategory()->getId()." of installation ".$ilSetting->get('inst_id').".");
106 $this->xmlHeader();
107
108
109 return true;
110 }
111
115 protected function buildCategory()
116 {
117 $this->xmlStartTag('Category');
118 }
119
123 protected function buildFooter()
124 {
125 $this->xmlEndTag('Category');
126 }
127
131 protected function buildTranslations()
132 {
133 $this->xmlStartTag('Translations');
134
135 $translations = $this->getCategory()->getTranslations();
136
137
138 $first = true;
139 foreach((array) $translations['Fobject'] as $translation)
140 {
141 $this->xmlStartTag('Translation', array('default' => (int) $first, 'language' => $translation['lang']));
142 $this->xmlElement('Title', array(),$translation['title']);
143 $this->xmlElement('Description',array(),$translation['desc']);
144 $this->xmlEndTag('Translation');
145
146 $first = false;
147 }
148 $this->xmlEndTag('Translations');
149 }
150}
151?>
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.
xmlDumpMem($format=TRUE)
Returns xml document from memory.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
global $ilSetting
Definition: privfeed.php:40