ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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();
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
132 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
134
135
136 // Delete notify entries
137 include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
139
140 // delete meta data
141 $this->deleteMetaData();
142
143 return true;
144 }
145
147 {
148 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
149
150 $this->items_obj = new ilLinkResourceItems($this->getId());
151
152 return true;
153 }
154
163 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
164 {
165 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
166 $this->cloneMetaData($new_obj);
167
168 // object created now copy other settings
169 include_once('Modules/WebResource/classes/class.ilLinkResourceItems.php');
170 $links = new ilLinkResourceItems($this->getId());
171 $links->cloneItems($new_obj->getId());
172
173 // append copy info weblink title
174 if (ilLinkResourceItems::_isSingular($new_obj->getId())) {
175 $first = ilLinkResourceItems::_getFirstLink($new_obj->getId());
176 ilLinkResourceItems::updateTitle($first['link_id'], $new_obj->getTitle());
177 }
178
179 return $new_obj;
180 }
181
187 public function toXML(ilXmlWriter $writer)
188 {
189 $attribs = array("obj_id" => "il_" . IL_INST_ID . "_webr_" . $this->getId());
190
191 $writer->xmlStartTag('WebLinks', $attribs);
192
193 // LOM MetaData
194 include_once 'Services/MetaData/classes/class.ilMD2XML.php';
195 $md2xml = new ilMD2XML($this->getId(), $this->getId(), 'webr');
196 $md2xml->startExport();
197 $writer->appendXML($md2xml->getXML());
198
199 // Sorting
200 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
203 $writer->xmlElement(
204 'Sorting',
205 array('type' => 'Manual')
206 );
207 break;
208
210 default:
211 $writer->xmlElement(
212 'Sorting',
213 array('type' => 'Title')
214 );
215 break;
216 }
217
218 // All links
219 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
220 $links = new ilLinkResourceItems($this->getId());
221 $links->toXML($writer);
222
223
224 $writer->xmlEndTag('WebLinks');
225 return true;
226 }
227
228
229 // PRIVATE
230} // 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 ilObjLinkResourceGUI.
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 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.
$links
update($pash, $contents, Config $config)
global $DIC
Definition: saml.php:7