ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMediaPoolPage.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/COPage/classes/class.ilPageObject.php");
5
15{
21 function getParentType()
22 {
23 return "mep";
24 }
25
32 function update($a_validate = true, $a_no_history = false)
33 {
34 global $ilDB;
35 parent::update($a_validate, $a_no_history);
36
37 return true;
38 }
39
43 function read()
44 {
45 global $ilDB;
46
47 // get co page
48 parent::read();
49 }
50
51
57 function delete()
58 {
59 global $ilDB;
60
61
62 // delete internal links information to this page
63// include_once("./Services/Link/classes/class.ilInternalLink.php");
64// ilInternalLink::_deleteAllLinksToTarget("mep", $this->getId());
65
66
67 // delete co page
68 parent::delete();
69
70 return true;
71 }
72
78 static function deleteAllPagesOfMediaPool($a_media_pool_id)
79 {
80 global $ilDB;
81
82// todo
83/*
84 $query = "SELECT * FROM il_media_pool_page".
85 " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer");
86 $set = $ilDB->query($query);
87
88 while($rec = $ilDB->fetchAssoc($set))
89 {
90 $mp_page = new ilMediaPoolPage($rec["id"]);
91 $mp_page->delete();
92 }
93*/
94 }
95
99 static function exists($a_media_pool_id, $a_title)
100 {
101 global $ilDB;
102
103// todo
104/*
105
106 $query = "SELECT * FROM il_media_pool_page".
107 " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer").
108 " AND title = ".$ilDB->quote($a_title, "text");
109 $set = $ilDB->query($query);
110 if($rec = $ilDB->fetchAssoc($set))
111 {
112 return true;
113 }
114*/
115 return false;
116 }
117
121 static function lookupTitle($a_page_id)
122 {
123 global $ilDB;
124
125 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
126 return ilMediaPoolItem::lookupTitle($a_page_id);
127 }
128
129
137 static function _mediaPoolPageExists($a_media_pool_id, $a_title)
138 {
139 global $ilDB;
140// todo
141/*
142 $query = "SELECT id FROM il_media_pool_page".
143 " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer").
144 " AND title = ".$ilDB->quote($a_title, "text");
145 $set = $ilDB->query($query);
146
147 $pages = array();
148 if ($rec = $ilDB->fetchAssoc($set))
149 {
150 return true;
151 }
152*/
153 return false;
154 }
155
162 static function _exists($a_id)
163 {
164 return ilPageObject::_exists("mep", $a_id);
165 }
166
170 function getUsages($a_incl_hist = true)
171 {
172 return $this->lookupUsages($this->getId(), $a_incl_hist);
173 }
174
180 function lookupUsages($a_id, $a_incl_hist = true)
181 {
182 global $ilDB;
183
184 // get usages in pages
185 $q = "SELECT * FROM page_pc_usage WHERE pc_id = ".
186 $ilDB->quote($a_id, "integer").
187 " AND pc_type = ".$ilDB->quote("incl", "text");
188
189 if (!$a_incl_hist)
190 {
191 $q.= " AND usage_hist_nr = ".$ilDB->quote(0, "integer");
192 }
193
194 $us_set = $ilDB->query($q);
195 $ret = array();
196 while($us_rec = $ilDB->fetchAssoc($us_set))
197 {
198 $ut = "";
199 if(is_int(strpos($us_rec["usage_type"], ":")))
200 {
201 $us_arr = explode(":", $us_rec["usage_type"]);
202 $ut = $us_arr[1];
203 $ct = $us_arr[0];
204 }
205
206 // check whether page exists
207 $skip = false;
208 if ($ut == "pg")
209 {
210 include_once("./Services/COPage/classes/class.ilPageObject.php");
211 if (!ilPageObject::_exists($ct, $us_rec["usage_id"]))
212 {
213 $skip = true;
214 }
215 }
216
217 if (!$skip)
218 {
219 $ret[] = array("type" => $us_rec["usage_type"],
220 "id" => $us_rec["usage_id"],
221 "hist_nr" => $us_rec["usage_hist_nr"]);
222 }
223 }
224
225 // get usages in media pools
226 $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.obj_id = ".
227 $ilDB->quote($a_id, "integer")." AND mep_item.type = ".$ilDB->quote("pg", "text");
228 $us_set = $ilDB->query($q);
229 while($us_rec = $ilDB->fetchAssoc($us_set))
230 {
231 $ret[] = array("type" => "mep",
232 "id" => $us_rec["mep_id"]);
233 }
234
235 return $ret;
236 }
237
238}
239?>
static lookupTitle($a_id)
Lookup title.
Class ilMediaPoolPage.
update($a_validate=true, $a_no_history=false)
update object data
static lookupTitle($a_page_id)
Lookup title.
getParentType()
Get parent type.
static _exists($a_id)
Check whether meida pool page exists.
getUsages($a_incl_hist=true)
get all usages of current media object
static deleteAllPagesOfMediaPool($a_media_pool_id)
delete media pool page and al related data
static _mediaPoolPageExists($a_media_pool_id, $a_title)
Check whether page exists in media pool or not
static exists($a_media_pool_id, $a_title)
Checks whether a page with given title exists.
read()
Read media_pool data.
lookupUsages($a_id, $a_incl_hist=true)
Lookup usages of media object.
Class ilPageObject.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
global $ilDB