ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilWebLinkXmlWriter.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 $weblink = 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->weblink->toXML($this);
53 }
54
59 protected function buildHeader()
60 {
61 $this->xmlSetDtdDef("<!DOCTYPE WebLinks PUBLIC \"-//ILIAS//DTD WebLinkAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_weblinks_5_1.dtd\">");
62 $this->xmlSetGenCmt("WebLink Object");
63 $this->xmlHeader();
64
65 return true;
66 }
67
68
74 protected function init()
75 {
76 $this->xmlClear();
77
78 if(!$this->obj_id)
79 {
80 throw new UnexpectedValueException('No obj_id given: ');
81 }
82 include_once './Services/Object/classes/class.ilObjectFactory.php';
83 if(!$this->weblink = ilObjectFactory::getInstanceByObjId($this->obj_id,false))
84 {
85 throw new UnexpectedValueException('Invalid obj_id given: '.$this->obj_id);
86 }
87 if($this->weblink->getType() != 'webr')
88 {
89 throw new UnexpectedValueException('Invalid obj_id given. Object is not of type webr');
90 }
91 }
92}
93?>
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
XML writer for weblinks.
buildHeader()
Build XML header.
setObjId($a_obj_id)
Set obj_id of weblink object.
__construct($a_add_header)
Constructor.
XML writer class.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlClear()
clears xmlStr @access public
xmlHeader()
Writes xml header @access public.
xmlSetDtdDef($dtdDef)
Sets dtd definition.