ILIAS  release_7 Revision v7.30-3-g800a261c036
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
24include_once "./Services/Object/classes/class.ilObject.php";
25
38{
45 public function __construct($a_id = 0, $a_call_by_reference = true)
46 {
47 $this->type = "webr";
48 parent::__construct($a_id, $a_call_by_reference);
49 }
50
56 public function create($a_upload = false)
57 {
58 $new_id = parent::create();
59
60 if (!$a_upload) {
61 $this->createMetaData();
62 }
63
64 return $new_id;
65 }
66
70 public function update()
71 {
72 $this->updateMetaData();
73 parent::update();
74 }
75
82 public function MDUpdateListener($a_element)
83 {
84 global $DIC;
85
86 parent::MDUpdateListener($a_element);
87
88 $md = new ilMD($this->getId(), 0, $this->getType());
89 if (!is_object($md_gen = $md->getGeneral())) {
90 return false;
91 }
92 $title = $md_gen->getTitle();
93 foreach ($md_gen->getDescriptionIds() as $id) {
94 $md_des = $md_gen->getDescription($id);
95 $description = $md_des->getDescription();
96 break;
97 }
98 switch ($a_element) {
99 case 'General':
100 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
102 $link_arr = ilLinkResourceItems::_getFirstLink($this->getId());
103 $link = new ilLinkResourceItems($this->getId());
104 $link->readItem($link_arr['link_id']);
105 $link->setTitle($title);
106 $link->setDescription($description);
107 $link->update();
108 }
109 break;
110 default:
111 return true;
112 }
113 return true;
114 }
115
116
117
124 public function delete()
125 {
126 // always call parent delete function first!!
127 if (!parent::delete()) {
128 return false;
129 }
130
131 // delete items and list
132 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
134 $list = new ilLinkResourceList($this->getId());
135 $list->delete();
136
137
138 // Delete notify entries
139 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
141
142 // delete meta data
143 $this->deleteMetaData();
144
145 return true;
146 }
147
149 {
150 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
151
152 $this->items_obj = new ilLinkResourceItems($this->getId());
153
154 return true;
155 }
156
165 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
166 {
167 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
168 $this->cloneMetaData($new_obj);
169
170 // object created now copy other settings
171 include_once('Modules/WebResource/classes/class.ilLinkResourceItems.php');
172 $links = new ilLinkResourceItems($this->getId());
173 $links->cloneItems($new_obj->getId());
174
175 // append copy info weblink title
176 if (ilLinkResourceItems::_isSingular($new_obj->getId())) {
177 $first = ilLinkResourceItems::_getFirstLink($new_obj->getId());
178 ilLinkResourceItems::updateTitle($first['link_id'], $new_obj->getTitle());
179 }
180
181 return $new_obj;
182 }
183
189 public function toXML(ilXmlWriter $writer)
190 {
191 $attribs = array("obj_id" => "il_" . IL_INST_ID . "_webr_" . $this->getId());
192
193 $writer->xmlStartTag('WebLinks', $attribs);
194
195 // LOM MetaData
196 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
197 $md2xml = new ilMD2XML($this->getId(), $this->getId(), 'webr');
198 $md2xml->startExport();
199 $writer->appendXML($md2xml->getXML());
200
201 // Sorting
202 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
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} // END class.ilObjLinkResource
An exception for terminatinating execution or to throw for unit testing.
static _lookupSortMode($a_obj_id)
lookup sort mode
static _deleteObject($a_obj_id)
Class ilLinkResourceItems.
static updateTitle($a_link_id, $a_title)
Update title.
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.
static _isSingular($a_webr_id)
Check whether there is only one active link in the web resource.
static lookupNumberOfLinks($a_webr_id)
Get number of assigned links.
Class ilLinkResourceList.
Class ilObjLinkResource.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
create($a_upload=false)
create object
MDUpdateListener($a_element)
Overwriten Metadata update listener for ECS functionalities.
toXML(ilXmlWriter $writer)
Write webresource xml.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
createMetaData()
create meta data entry
cloneMetaData($target_obj)
Copy meta data.
getId()
get object id @access public
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
appendXML($a_str)
append xml string to document
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc