1<?php
2  /*
3   +-----------------------------------------------------------------------------+
4   | ILIAS open source                                                           |
5   +-----------------------------------------------------------------------------+
6   | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
7   |                                                                             |
8   | This program is free software; you can redistribute it and/or               |
9   | modify it under the terms of the GNU General Public License                 |
10   | as published by the Free Software Foundation; either version 2              |
11   | of the License, or (at your option) any later version.                      |
12   |                                                                             |
13   | This program is distributed in the hope that it will be useful,             |
14   | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
15   | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
16   | GNU General Public License for more details.                                |
17   |                                                                             |
18   | You should have received a copy of the GNU General Public License           |
19   | along with this program; if not, write to the Free Software                 |
20   | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
21   +-----------------------------------------------------------------------------+
22  */
23
24
25 /**
26   * Abstract classs for soap structure objects
27   *
28   * @author Roland Kuestermann (rku@aifb.uni-karlsruhe.de)
29   * @version $Id: class.ilSoapStructureObject.php,v 1.5 2006/05/23 23:09:06 hschottm Exp $
30   *
31   * @package ilias
32   */
33
34class ilSoapStructureObject
35{
36    public $obj_id;
37    public $title;
38    public $type;
39    public $description;
40    public $parentRefId;
41
42    public $structureObjects = array();
43
44
45    public function __construct($objId, $type, $title, $description, $parentRefId = null)
46    {
47        $this->setObjId($objId);
48        $this->setType($type);
49        $this->setTitle($title);
50        $this->setDescription($description);
51        $this->parentRefId = $parentRefId;
52    }
53
54    /**
55    *	add structure object to its parent
56    *
57    */
58    public function addStructureObject($structureObject)
59    {
60        $this->structureObjects [$structureObject->getObjId()] =  $structureObject;
61    }
62
63    /**
64     * returns sub structure elements
65     *
66     */
67    public function getStructureObjects()
68    {
69        return $this->structureObjects;
70    }
71
72
73    /**
74    *	set current ObjId
75    *
76    */
77    public function setObjId($value)
78    {
79        $this->obj_id= $value;
80    }
81
82
83    /**
84    * return current object id
85    */
86    public function getObjId()
87    {
88        return $this->obj_id;
89    }
90
91
92
93    /**
94    *	set current title
95    *
96    */
97    public function setTitle($value)
98    {
99        $this->title= $value;
100    }
101
102
103    /**
104    *	return current title
105    *
106    */
107    public function getTitle()
108    {
109        return $this->title;
110    }
111
112    /**
113    *	set current description
114    *
115    */
116    public function setDescription($value)
117    {
118        $this->description = $value;
119    }
120
121
122    /**
123    *	return current description
124    *
125    */
126    public function getDescription()
127    {
128        return $this->description;
129    }
130
131
132    /**
133    *	set current type
134    *
135    */
136    public function setType($value)
137    {
138        $this->type = $value;
139    }
140
141
142    /**
143    *	return current type
144    *
145    */
146    public function getType()
147    {
148        return $this->type;
149    }
150
151
152    /**
153    *	return current goto_link
154    *
155    */
156    public function getGotoLink()
157    {
158        return ILIAS_HTTP_PATH . "/" . "goto.php?target=" . $this->getType() . "_" . $this->getObjId() . (is_numeric($this->getParentRefId())?"_" . $this->getParentRefId():"") . "&client_id=" . CLIENT_ID;
159    }
160
161    /**
162    *	return current internal_link
163    *
164    */
165    public function getInternalLink()
166    {
167        die("abstract");
168    }
169
170    /**
171     * get xml tag attributes
172     */
173
174    public function _getXMLAttributes()
175    {
176        return array(	'type' => $this->getType(),
177                        'obj_id' => $this->getObjId()
178        );
179    }
180
181    public function _getTagName()
182    {
183        return "StructureObject";
184    }
185
186    /**
187    * set ref id for parent object (used for permanent link if set)
188    */
189    public function setParentRefId($parentRefId)
190    {
191        $this->parentRefId = $parentRefId;
192    }
193
194
195    /**
196    * read access to parents ref id
197    */
198    public function getParentRefId()
199    {
200        return $this->parentRefId;
201    }
202
203
204    /**
205     * export to xml writer
206     */
207    public function exportXML($xml_writer)
208    {
209        $attrs = $this->_getXMLAttributes();
210
211        // open tag
212        $xml_writer->xmlStartTag($this->_getTagName(), $attrs);
213
214        $xml_writer->xmlElement('Title', null, $this->getTitle());
215        $xml_writer->xmlElement('Description', null, $this->getDescription());
216        $xml_writer->xmlElement('InternalLink', null, $this->getInternalLink());
217        $xml_writer->xmlElement('GotoLink', null, $this->getGotoLink());
218
219        $xml_writer->xmlStartTag("StructureObjects");
220
221        // handle sub elements
222        $structureObjects = $this->getStructureObjects();
223
224        foreach ($structureObjects as $structureObject) {
225            $structureObject->exportXML($xml_writer);
226        }
227
228        $xml_writer->xmlEndTag("StructureObjects");
229
230        $xml_writer->xmlEndTag($this->_getTagName());
231    }
232}
233