ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilFolderXmlWriter.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 
15 {
16  private $add_header = true;
17 
18  private $obj_id = 0;
19  private $folder = null;
20 
24  public function __construct($a_add_header)
25  {
26  $this->add_header = $a_add_header;
27  parent::__construct();
28  }
29 
35  public function setObjId($a_obj_id)
36  {
37  $this->obj_id = $a_obj_id;
38  }
39 
45  public function write()
46  {
47  $this->init();
48  if ($this->add_header) {
49  $this->buildHeader();
50  }
51  $this->xmlStartTag('Folder', array('Id' => $this->folder->getId()));
52  $this->xmlElement('Title', array(), $this->folder->getTitle());
53  $this->xmlElement('Description', array(), $this->folder->getDescription());
54  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
56  $this->xmlEndTag('Folder');
57  }
58 
63  protected function buildHeader()
64  {
65  $this->xmlSetDtdDef("<!DOCTYPE WebLinks PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_fold_4_5.dtd\">");
66  $this->xmlSetGenCmt("Export of a ILIAS Folder");
67  $this->xmlHeader();
68 
69  return true;
70  }
71 
72 
78  protected function init()
79  {
80  $this->xmlClear();
81 
82  if (!$this->obj_id) {
83  throw new UnexpectedValueException('No obj_id given: ');
84  }
85  include_once './Services/Object/classes/class.ilObjectFactory.php';
86  if (!$this->folder = ilObjectFactory::getInstanceByObjId($this->obj_id, false)) {
87  throw new UnexpectedValueException('Invalid obj_id given: ' . $this->obj_id);
88  }
89  if ($this->folder->getType() != 'fold') {
90  throw new UnexpectedValueException('Invalid obj_id given. Object is not of type folder');
91  }
92  }
93 }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
setObjId($a_obj_id)
Set obj_id of weblink object.
XML writer class.
__construct($a_add_header)
Constructor.
xmlEndTag($tag)
Writes an endtag.
init()
Init xml writer.
XML writer for folders.
xmlHeader()
Writes xml header public.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
buildHeader()
Build XML header.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
xmlClear()
clears xmlStr public