ILIAS  Release_4_4_x_branch Revision 61816
 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 "./Services/Object/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 './Services/LinkChecker/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  // append copy info weblink title
181  if(ilLinkResourceItems::_isSingular($new_obj->getId()))
182  {
183  $first = ilLinkResourceItems::_getFirstLink($new_obj->getId());
184  ilLinkResourceItems::updateTitle($first['link_id'], $new_obj->getTitle());
185  }
186 
187  return $new_obj;
188  }
189 
195  public function toXML(ilXmlWriter $writer)
196  {
197  $attribs = array("obj_id" => "il_".IL_INST_ID."_webr_".$this->getId());
198 
199  $writer->xmlStartTag('WebLinks',$attribs);
200 
201  // LOM MetaData
202  include_once 'Services/MetaData/classes/class.ilMD2XML.php';
203  $md2xml = new ilMD2XML($this->getId(),$this->getId(),'webr');
204  $md2xml->startExport();
205  $writer->appendXML($md2xml->getXML());
206 
207  // Sorting
208  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
210  {
212  $writer->xmlElement(
213  'Sorting',
214  array('type' => 'Manual')
215  );
216  break;
217 
219  default:
220  $writer->xmlElement(
221  'Sorting',
222  array('type' => 'Title')
223  );
224  break;
225  }
226 
227  // All links
228  include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
229  $links = new ilLinkResourceItems($this->getId());
230  $links->toXML($writer);
231 
232 
233  $writer->xmlEndTag('WebLinks');
234  return true;
235  }
236 
237 
238  // PRIVATE
239 
240 
241 } // END class.ilObjLinkResource
242 ?>