ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjLinkResource.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 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 include_once "./classes/class.ilObject.php";
25 
38 {
45  function ilObjLinkResource($a_id = 0,$a_call_by_reference = true)
46  {
47  //$this->type = "lnkr";
48  $this->type = "webr";
49  parent::__construct($a_id,$a_call_by_reference);
50  }
51 
57  function create($a_upload = false)
58  {
59  $new_id = parent::create();
60 
61  if(!$a_upload)
62  {
63  $this->createMetaData();
64  }
65 
66  return $new_id;
67  }
68 
72  function update()
73  {
74  $this->updateMetaData();
76  }
77 
84  public function MDUpdateListener($a_element)
85  {
86  global $ilLog;
87 
88  parent::MDUpdateListener($a_element);
89 
90  $md = new ilMD($this->getId(),0, $this->getType());
91  if(!is_object($md_gen = $md->getGeneral()))
92  {
93  return false;
94  }
95  $title = $md_gen->getTitle();
96  foreach($md_gen->getDescriptionIds() as $id)
97  {
98  $md_des = $md_gen->getDescription($id);
99  $description = $md_des->getDescription();
100  break;
101  }
102  switch($a_element)
103  {
104  case 'General':
105  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
107  {
108  $link_arr = ilLinkResourceItems::_getFirstLink($this->getId());
109  $link = new ilLinkResourceItems($this->getId());
110  $link->readItem($link_arr['link_id']);
111  $link->setTitle($title);
112  $link->setDescription($description);
113  $link->update();
114  }
115  break;
116  default:
117  return true;
118  }
119  return true;
120  }
121 
122 
123 
130  function delete()
131  {
132  // always call parent delete function first!!
133  if (!parent::delete())
134  {
135  return false;
136  }
137 
138  // delete items
139  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
141 
142 
143  // Delete notify entries
144  include_once './classes/class.ilLinkCheckNotify.php';
146 
147  // delete meta data
148  $this->deleteMetaData();
149 
150  return true;
151  }
152 
154  {
155  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
156 
157  $this->items_obj =& new ilLinkResourceItems($this->getId());
158 
159  return true;
160  }
161 
170  public function cloneObject($a_target_id,$a_copy_id = 0)
171  {
172  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
173  $this->cloneMetaData($new_obj);
174 
175  // object created now copy other settings
176  include_once('Modules/WebResource/classes/class.ilLinkResourceItems.php');
177  $links = new ilLinkResourceItems($this->getId());
178  $links->cloneItems($new_obj->getId());
179 
180  return $new_obj;
181  }
182 
188  public function toXML(ilXmlWriter $writer)
189  {
190  $attribs = array("obj_id" => "il_".IL_INST_ID."_webr_".$this->getId());
191 
192  $writer->xmlStartTag('WebLinks',$attribs);
193 
194  // LOM MetaData
195  include_once 'Services/MetaData/classes/class.ilMD2XML.php';
196  $md2xml = new ilMD2XML($this->getId(),$this->getId(),'webr');
197  $md2xml->startExport();
198  $writer->appendXML($md2xml->getXML());
199 
200  // Sorting
201  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
203  {
205  $writer->xmlElement(
206  'Sorting',
207  array('type' => 'Manual')
208  );
209  break;
210 
212  default:
213  $writer->xmlElement(
214  'Sorting',
215  array('type' => 'Title')
216  );
217  break;
218  }
219 
220  // All links
221  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
222  $links = new ilLinkResourceItems($this->getId());
223  $links->toXML($writer);
224 
225 
226  $writer->xmlEndTag('WebLinks');
227  return true;
228  }
229 
230 
231  // PRIVATE
232 
233 
234 } // END class.ilObjLinkResource
235 ?>