ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function getParentType()
22  {
23  return "mep";
24  }
25 
32  public function update($a_validate = true, $a_no_history = false)
33  {
34  $ilDB = $this->db;
35  parent::update($a_validate, $a_no_history);
36 
37  return true;
38  }
39 
43  public function read()
44  {
45  $ilDB = $this->db;
46 
47  // get co page
48  parent::read();
49  }
50 
51 
57  public function delete()
58  {
59  $ilDB = $this->db;
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  public static function deleteAllPagesOfMediaPool($a_media_pool_id)
79  {
80  global $DIC;
81 
82  $ilDB = $DIC->database();
83 
84  // todo
85 /*
86  $query = "SELECT * FROM il_media_pool_page".
87  " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer");
88  $set = $ilDB->query($query);
89 
90  while($rec = $ilDB->fetchAssoc($set))
91  {
92  $mp_page = new ilMediaPoolPage($rec["id"]);
93  $mp_page->delete();
94  }
95 */
96  }
97 
101  public static function exists($a_media_pool_id, $a_title)
102  {
103  global $DIC;
104 
105  $ilDB = $DIC->database();
106 
107  // todo
108  /*
109 
110  $query = "SELECT * FROM il_media_pool_page".
111  " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer").
112  " AND title = ".$ilDB->quote($a_title, "text");
113  $set = $ilDB->query($query);
114  if($rec = $ilDB->fetchAssoc($set))
115  {
116  return true;
117  }
118  */
119  return false;
120  }
121 
125  public static function lookupTitle($a_page_id)
126  {
127  global $DIC;
128 
129  $ilDB = $DIC->database();
130 
131  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
132  return ilMediaPoolItem::lookupTitle($a_page_id);
133  }
134 
135 
143  public static function _mediaPoolPageExists($a_media_pool_id, $a_title)
144  {
145  global $DIC;
146 
147  $ilDB = $DIC->database();
148  // todo
149  /*
150  $query = "SELECT id FROM il_media_pool_page".
151  " WHERE media_pool_id = ".$ilDB->quote($a_media_pool_id, "integer").
152  " AND title = ".$ilDB->quote($a_title, "text");
153  $set = $ilDB->query($query);
154 
155  $pages = array();
156  if ($rec = $ilDB->fetchAssoc($set))
157  {
158  return true;
159  }
160  */
161  return false;
162  }
163 
167  public function getUsages($a_incl_hist = true)
168  {
169  return self::lookupUsages($this->getId(), $a_incl_hist);
170  }
171 
177  public static function lookupUsages($a_id, $a_incl_hist = true)
178  {
179  global $DIC;
180 
181  $ilDB = $DIC->database();
182 
183  // get usages in pages
184  $q = "SELECT * FROM page_pc_usage WHERE pc_id = " .
185  $ilDB->quote($a_id, "integer") .
186  " AND pc_type = " . $ilDB->quote("incl", "text");
187 
188  if (!$a_incl_hist) {
189  $q .= " AND usage_hist_nr = " . $ilDB->quote(0, "integer");
190  }
191 
192  $us_set = $ilDB->query($q);
193  $ret = array();
194  while ($us_rec = $ilDB->fetchAssoc($us_set)) {
195  $ut = "";
196  if (is_int(strpos($us_rec["usage_type"], ":"))) {
197  $us_arr = explode(":", $us_rec["usage_type"]);
198  $ut = $us_arr[1];
199  $ct = $us_arr[0];
200  }
201 
202  // check whether page exists
203  $skip = false;
204  if ($ut == "pg") {
205  include_once("./Services/COPage/classes/class.ilPageObject.php");
206  if (!ilPageObject::_exists($ct, $us_rec["usage_id"])) {
207  $skip = true;
208  }
209  }
210 
211  if (!$skip) {
212  $ret[] = array("type" => $us_rec["usage_type"],
213  "id" => $us_rec["usage_id"],
214  "hist_nr" => $us_rec["usage_hist_nr"],
215  "lang" => $us_rec["usage_lang"]);
216  }
217  }
218 
219  // get usages in media pools
220  $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.obj_id = " .
221  $ilDB->quote($a_id, "integer") . " AND mep_item.type = " . $ilDB->quote("pg", "text");
222  $us_set = $ilDB->query($q);
223  while ($us_rec = $ilDB->fetchAssoc($us_set)) {
224  $ret[] = array("type" => "mep",
225  "id" => $us_rec["mep_id"]);
226  }
227 
228  return $ret;
229  }
230 }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: saml.php:7
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.
getParentType()
Get parent type.
update($pash, $contents, Config $config)
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.