ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
5 
13 {
17  protected $settings;
18 
19  const MODE_SOAP = 1;
20  const MODE_EXPORT = 2;
21 
22  private $mode = self::MODE_SOAP;
23  private $xml;
24  private $category;
25 
33  public function __construct(ilObjCategory $cat = null)
34  {
35  global $DIC;
36 
37  $this->settings = $DIC->settings();
38  parent::__construct();
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()->getTranslations();
140 
141 
142  $first = true;
143  foreach ((array) $translations['Fobject'] as $translation) {
144  $this->xmlStartTag('Translation', array('default' => (int) $first, 'language' => $translation['lang']));
145  $this->xmlElement('Title', array(), $translation['title']);
146  $this->xmlElement('Description', array(), $translation['desc']);
147  $this->xmlEndTag('Translation');
148 
149  $first = false;
150  }
151  $this->xmlEndTag('Translations');
152  }
153 }
buildCategory()
Build category xml.
static _exportContainerSettings(ilXmlWriter $a_xml, $a_obj_id)
buildTranslations()
Add Translations.
Class for category export.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetGenCmt($genCmt)
Sets generated comment.
__construct(ilObjCategory $cat=null)
constructor
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $DIC
Definition: saml.php:7
xmlDumpMem($format=true)
Returns xml document from memory.
XML writer class.
buildHeader()
Build xml header <type> $ilSetting.
xmlEndTag($tag)
Writes an endtag.
setMode($a_mode)
Set export mode.
xmlHeader()
Writes xml header public.
getCategory()
Get category object.
Create styles array
The data for the language used.
Class ilObjCategory.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
settings()
Definition: settings.php:2
buildFooter()
Add footer elements.
global $ilSetting
Definition: privfeed.php:17
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
export($a_with_header=true)
Start wrting xml.