ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
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 
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  $this->buildSorting();
79  $this->buildFooter();
80  }
81  }
82 
87  public function getXml()
88  {
89  return $this->xmlDumpMem(false);
90  }
91 
97  protected function buildHeader()
98  {
99  global $ilSetting;
100 
101  $this->xmlSetDtdDef("<!DOCTYPE category PUBLIC \"-//ILIAS//DTD Group//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_category_4_3.dtd\">");
102  $this->xmlSetGenCmt("Export of ILIAS category ". $this->getCategory()->getId()." of installation ".$ilSetting->get('inst_id').".");
103  $this->xmlHeader();
104 
105 
106  return true;
107  }
108 
112  protected function buildCategory()
113  {
114  $this->xmlStartTag('Category');
115  }
116 
120  protected function buildFooter()
121  {
122  $this->xmlEndTag('Category');
123  }
124 
128  protected function buildTranslations()
129  {
130  $this->xmlStartTag('Translations');
131 
132  $translations = $this->getCategory()->getTranslations();
133 
134 
135  $first = true;
136  foreach((array) $translations['Fobject'] as $translation)
137  {
138  $this->xmlStartTag('Translation', array('default' => (int) $first, 'language' => $translation['lang']));
139  $this->xmlElement('Title', array(),$translation['title']);
140  $this->xmlElement('Description',array(),$translation['desc']);
141  $this->xmlEndTag('Translation');
142 
143  $first = false;
144  }
145  $this->xmlEndTag('Translations');
146  }
147 
151  protected function buildSorting()
152  {
153  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
154  include_once './Services/Container/classes/class.ilContainer.php';
155 
156  $sorting = new ilContainerSortingSettings($this->getCategory()->getId());
157  switch($sorting->getSortMode())
158  {
160  $type = 'Manual';
161  break;
162 
163  default:
164  $type = 'Title';
165  break;
166 
167  }
168  $this->xmlElement('Sorting', array('type' => $type));
169  }
170 
171 
172 }
173 ?>