4 require_once
"classes/class.ilObject.php";
5 require_once
"./Services/MetaData/classes/class.ilMDLanguageItem.php";
6 require_once(
"./Modules/Folder/classes/class.ilObjFolder.php");
7 require_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
35 $this->
ilObject($a_id,$a_call_by_reference);
45 $this->default_width = $a_val;
55 return $this->default_width;
65 $this->default_height = $a_val;
75 return $this->default_height;
87 $set = $ilDB->query(
"SELECT * FROM mep_data ".
88 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
90 if ($rec = $ilDB->fetchAssoc($set))
109 $tree->setTreeTablePK(
"mep_id");
110 $tree->setTableNames(
"mep_tree",
"mep_item");
124 $ilDB->manipulate(
"INSERT INTO mep_data ".
125 "(id, default_width, default_height) VALUES (".
126 $ilDB->quote($this->getId(),
"integer").
", ".
127 $ilDB->quote($this->getDefaultWidth(),
"integer").
", ".
128 $ilDB->quote($this->getDefaultHeight(),
"integer").
133 $this->tree->setTreeTablePK(
"mep_id");
134 $this->tree->setTableNames(
'mep_tree',
'mep_item');
135 $this->tree->addTree($this->
getId(), 1);
157 if (!parent::update())
163 $ilDB->manipulate(
"UPDATE mep_data SET ".
164 " default_width = ".$ilDB->quote($this->getDefaultWidth(),
"integer").
",".
165 " default_height = ".$ilDB->quote($this->getDefaultHeight(),
"integer").
166 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
186 if (!parent::delete())
192 $childs = $this->tree->getSubTree($this->tree->getNodeData($this->tree->readRootId()));
195 $this->tree->removeTree($this->tree->getTreeId());
198 foreach ($childs as $child)
201 switch ($child[
"type"])
206 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
249 return $roles ? $roles : array();
265 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
305 if ($a_node_id==
$_GET[
"ref_id"])
307 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
308 $parent_type = $parent_obj->getType();
309 if($parent_type == $this->
getType())
311 $a_node_id = (int) $tree->getParentId($a_node_id);
315 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
329 $obj_id = $this->tree->getRootId();
332 if ($a_type ==
"fold" || $a_type ==
"")
334 $objs = $this->tree->getChildsByType($obj_id,
"fold");
336 if ($a_type ==
"mob" || $a_type ==
"")
338 $mobs = $this->tree->getChildsByType($obj_id,
"mob");
340 foreach(
$mobs as $key => $mob)
344 if ($a_type ==
"pg" || $a_type ==
"")
346 $pgs = $this->tree->getChildsByType($obj_id,
"pg");
348 foreach($pgs as $key => $pg)
365 $obj_id = $this->tree->getRootId();
368 $objs = $this->tree->getFilteredChilds(array(
"fold",
"dummy"), $obj_id);
375 function getMediaObjects($a_title_filter =
"", $a_format_filter =
"", $a_keyword_filter =
'', $a_caption_filter)
379 $query =
"SELECT DISTINCT mep_tree.*, object_data.* ".
380 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
381 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
383 if ($a_format_filter !=
"" or $a_caption_filter !=
'')
385 $query.=
" JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
389 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
390 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
393 if (trim($a_title_filter) !=
"")
395 $query.=
" AND ".$ilDB->like(
"object_data.title",
"text",
"%".trim($a_title_filter).
"%");
397 if ($a_format_filter !=
"")
399 $filter = ($a_format_filter ==
"unknown")
402 $query.=
" AND ".$ilDB->equals(
"media_item.format", $filter,
"text",
true);
404 if(trim($a_caption_filter))
406 $query .=
'AND '.$ilDB->like(
'media_item.caption',
'text',
'%'.trim($a_caption_filter).
'%');
410 " ORDER BY object_data.title";
413 $set = $ilDB->query(
$query);
414 while ($rec = $ilDB->fetchAssoc($set))
416 $rec[
"foreign_id"] = $rec[
"obj_id"];
422 if($a_keyword_filter)
424 include_once
'./Services/MetaData/classes/class.ilMDKeyword.php';
427 foreach($objs as $obj)
429 if(in_array($obj[
'foreign_id'],
$res))
434 return (array) $filtered;
446 $query =
"SELECT foreign_id as id FROM ".
447 " mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
448 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
449 " WHERE mep_tree.mep_id = ".$ilDB->quote($a_id,
"integer").
450 " AND mep_item.type = ".$ilDB->quote(
"mob",
"text").
451 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
452 $set = $ilDB->query(
$query);
454 while ($rec = $ilDB->fetchAssoc($set))
468 $query =
"SELECT DISTINCT media_item.format f FROM mep_tree ".
469 " JOIN mep_item ON (mep_item.obj_id = mep_tree.child) ".
470 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
471 " JOIN media_item ON (media_item.mob_id = object_data.obj_id) ".
472 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
473 " AND object_data.type = ".$ilDB->quote(
"mob",
"text").
476 $set = $ilDB->query(
$query);
477 while ($rec = $ilDB->fetchAssoc($set))
481 $formats[$rec[
"f"]] = $rec[
"f"];
485 $formats[
"unknown"] = $lng->txt(
"mep_unknown");
498 if ($obj_id == $this->tree->getRootId())
503 return $this->tree->getParentId($obj_id);
513 if (!$this->tree->isInTree($a_obj_id))
515 $parent = ($a_parent ==
"")
516 ? $this->tree->getRootId()
518 $this->tree->insertNode($a_obj_id, $parent);
538 $node_data = $this->tree->getNodeData($obj_id);
539 $subtree = $this->tree->getSubtree($node_data);
542 if($this->tree->isInTree($obj_id))
544 $this->tree->deleteTree($node_data);
548 foreach ($subtree as $node)
551 if ($node[
"type"] ==
"mob")
560 if ($node[
"type"] ==
"fold")
569 if ($node[
"type"] ==
"pg")
571 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
579 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
595 $set = $ilDB->query(
"SELECT * FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE ".
596 " foreign_id = ".$ilDB->quote($a_foreign_id,
"integer").
597 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer")
599 if ($rec = $ilDB->fetchAssoc($set))
613 $set = $ilDB->query(
"SELECT * FROM mep_tree WHERE child = ".
614 $ilDB->quote($a_item_id,
"integer").
615 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer"));
616 if ($rec = $ilDB->fetchAssoc($set))
633 $mep_item->setTitle($a_title);
634 $mep_item->setType(
"fold");
636 if ($mep_item->getId() > 0)
639 $parent = $a_parent > 0
641 :
$tree->getRootId();
643 return $mep_item->getId();