ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
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  $this->xmlEndTag('Folder');
56  }
57 
62  protected function buildHeader()
63  {
64  $this->xmlSetDtdDef("<!DOCTYPE WebLinks PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_weblinks_4_0.dtd\">");
65  $this->xmlSetGenCmt("WebLink Object");
66  $this->xmlHeader();
67 
68  return true;
69  }
70 
71 
77  protected function init()
78  {
79  $this->xmlClear();
80 
81  if(!$this->obj_id)
82  {
83  throw new UnexpectedValueException('No obj_id given: ');
84  }
85  include_once './classes/class.ilObjectFactory.php';
86  if(!$this->folder = ilObjectFactory::getInstanceByObjId($this->obj_id,false))
87  {
88  throw new UnexpectedValueException('Invalid obj_id given: '.$this->obj_id);
89  }
90  if($this->folder->getType() != 'fold')
91  {
92  throw new UnexpectedValueException('Invalid obj_id given. Object is not of type folder');
93  }
94  }
95 }
96 ?>