ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_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 
159  function getUsages($a_incl_hist = true)
160  {
161  return self::lookupUsages($this->getId(), $a_incl_hist);
162  }
163 
169  static function lookupUsages($a_id, $a_incl_hist = true)
170  {
171  global $ilDB;
172 
173  // get usages in pages
174  $q = "SELECT * FROM page_pc_usage WHERE pc_id = ".
175  $ilDB->quote($a_id, "integer").
176  " AND pc_type = ".$ilDB->quote("incl", "text");
177 
178  if (!$a_incl_hist)
179  {
180  $q.= " AND usage_hist_nr = ".$ilDB->quote(0, "integer");
181  }
182 
183  $us_set = $ilDB->query($q);
184  $ret = array();
185  while($us_rec = $ilDB->fetchAssoc($us_set))
186  {
187  $ut = "";
188  if(is_int(strpos($us_rec["usage_type"], ":")))
189  {
190  $us_arr = explode(":", $us_rec["usage_type"]);
191  $ut = $us_arr[1];
192  $ct = $us_arr[0];
193  }
194 
195  // check whether page exists
196  $skip = false;
197  if ($ut == "pg")
198  {
199  include_once("./Services/COPage/classes/class.ilPageObject.php");
200  if (!ilPageObject::_exists($ct, $us_rec["usage_id"]))
201  {
202  $skip = true;
203  }
204  }
205 
206  if (!$skip)
207  {
208  $ret[] = array("type" => $us_rec["usage_type"],
209  "id" => $us_rec["usage_id"],
210  "hist_nr" => $us_rec["usage_hist_nr"]);
211  }
212  }
213 
214  // get usages in media pools
215  $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.obj_id = ".
216  $ilDB->quote($a_id, "integer")." AND mep_item.type = ".$ilDB->quote("pg", "text");
217  $us_set = $ilDB->query($q);
218  while($us_rec = $ilDB->fetchAssoc($us_set))
219  {
220  $ret[] = array("type" => "mep",
221  "id" => $us_rec["mep_id"]);
222  }
223 
224  return $ret;
225  }
226 
227 }
228 ?>
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _mediaPoolPageExists($a_media_pool_id, $a_title)
Check whether page exists in media pool or not.
Class ilMediaPoolPage.
static lookupTitle($a_page_id)
Lookup title.
read()
Read media_pool data.
static deleteAllPagesOfMediaPool($a_media_pool_id)
delete media pool page and al related data
update($a_validate=true, $a_no_history=false)
update object data
Class ilPageObject.
getUsages($a_incl_hist=true)
get all usages of current media object
static lookupUsages($a_id, $a_incl_hist=true)
Lookup usages of media object.
Create styles array
The data for the language used.
getParentType()
Get parent type.
static lookupTitle($a_id)
Lookup title.
global $ilDB
$ret
Definition: parser.php:6
static exists($a_media_pool_id, $a_title)
Checks whether a page with given title exists.