ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_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 {
50 $this->buildHeader();
51 }
52 $this->xmlStartTag('Folder',array('Id' => $this->folder->getId()));
53 $this->xmlElement('Title',array(),$this->folder->getTitle());
54 $this->xmlElement('Description',array(),$this->folder->getDescription());
55 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
57 $this->xmlEndTag('Folder');
58 }
59
64 protected function buildHeader()
65 {
66 $this->xmlSetDtdDef("<!DOCTYPE WebLinks PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_fold_4_5.dtd\">");
67 $this->xmlSetGenCmt("Export of a ILIAS Folder");
68 $this->xmlHeader();
69
70 return true;
71 }
72
73
79 protected function init()
80 {
81 $this->xmlClear();
82
83 if(!$this->obj_id)
84 {
85 throw new UnexpectedValueException('No obj_id given: ');
86 }
87 include_once './Services/Object/classes/class.ilObjectFactory.php';
88 if(!$this->folder = ilObjectFactory::getInstanceByObjId($this->obj_id,false))
89 {
90 throw new UnexpectedValueException('Invalid obj_id given: '.$this->obj_id);
91 }
92 if($this->folder->getType() != 'fold')
93 {
94 throw new UnexpectedValueException('Invalid obj_id given. Object is not of type folder');
95 }
96 }
97}
98?>
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
XML writer for folders.
setObjId($a_obj_id)
Set obj_id of weblink object.
buildHeader()
Build XML header.
__construct($a_add_header)
Constructor.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlClear()
clears xmlStr @access public
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)