4 require_once
"./Services/Object/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").
144 $this->tree->setTreeTablePK(
"mep_id");
145 $this->tree->setTableNames(
'mep_tree',
'mep_item');
146 $this->tree->addTree($this->
getId(), 1);
168 if (!parent::update())
174 $ilDB->manipulate(
"UPDATE mep_data SET ".
175 " default_width = ".$ilDB->quote($this->getDefaultWidth(),
"integer").
",".
176 " default_height = ".$ilDB->quote($this->getDefaultHeight(),
"integer").
177 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
197 if (!parent::delete())
203 $childs = $this->tree->getSubTree($this->tree->getNodeData($this->tree->readRootId()));
206 $this->tree->removeTree($this->tree->getTreeId());
209 foreach ($childs as $child)
212 switch ($child[
"type"])
217 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
260 return $roles ? $roles : array();
276 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
316 if ($a_node_id==
$_GET[
"ref_id"])
318 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
319 $parent_type = $parent_obj->getType();
320 if($parent_type == $this->
getType())
322 $a_node_id = (int) $tree->getParentId($a_node_id);
326 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
340 $obj_id = $this->tree->getRootId();
343 if ($a_type ==
"fold" || $a_type ==
"")
345 $objs = $this->tree->getChildsByType($obj_id,
"fold");
347 if ($a_type ==
"mob" || $a_type ==
"")
349 $mobs = $this->tree->getChildsByType($obj_id,
"mob");
351 foreach(
$mobs as $key => $mob)
355 if ($a_type ==
"pg" || $a_type ==
"")
357 $pgs = $this->tree->getChildsByType($obj_id,
"pg");
359 foreach($pgs as $key => $pg)
376 $obj_id = $this->tree->getRootId();
379 $objs = $this->tree->getFilteredChilds(array(
"fold",
"dummy"), $obj_id);
386 function getMediaObjects($a_title_filter =
"", $a_format_filter =
"", $a_keyword_filter =
'', $a_caption_filter)
390 $query =
"SELECT DISTINCT mep_tree.*, object_data.* ".
391 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
392 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
394 if ($a_format_filter !=
"" or $a_caption_filter !=
'')
396 $query.=
" JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
400 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
401 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
404 if (trim($a_title_filter) !=
"")
406 $query.=
" AND ".$ilDB->like(
"object_data.title",
"text",
"%".trim($a_title_filter).
"%");
408 if ($a_format_filter !=
"")
410 $filter = ($a_format_filter ==
"unknown")
413 $query.=
" AND ".$ilDB->equals(
"media_item.format", $filter,
"text",
true);
415 if(trim($a_caption_filter))
417 $query .=
'AND '.$ilDB->like(
'media_item.caption',
'text',
'%'.trim($a_caption_filter).
'%');
421 " ORDER BY object_data.title";
424 $set = $ilDB->query(
$query);
425 while ($rec = $ilDB->fetchAssoc($set))
427 $rec[
"foreign_id"] = $rec[
"obj_id"];
433 if($a_keyword_filter)
435 include_once
'./Services/MetaData/classes/class.ilMDKeyword.php';
438 foreach($objs as $obj)
440 if(in_array($obj[
'foreign_id'],
$res))
445 return (array) $filtered;
457 $query =
"SELECT foreign_id as id FROM ".
458 " mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
459 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
460 " WHERE mep_tree.mep_id = ".$ilDB->quote($a_id,
"integer").
461 " AND mep_item.type = ".$ilDB->quote(
"mob",
"text").
462 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
463 $set = $ilDB->query(
$query);
465 while ($rec = $ilDB->fetchAssoc($set))
479 $query =
"SELECT DISTINCT media_item.format f FROM mep_tree ".
480 " JOIN mep_item ON (mep_item.obj_id = mep_tree.child) ".
481 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
482 " JOIN media_item ON (media_item.mob_id = object_data.obj_id) ".
483 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
484 " AND object_data.type = ".$ilDB->quote(
"mob",
"text").
487 $set = $ilDB->query(
$query);
488 while ($rec = $ilDB->fetchAssoc($set))
492 $formats[$rec[
"f"]] = $rec[
"f"];
496 $formats[
"unknown"] = $lng->txt(
"mep_unknown");
509 if ($obj_id == $this->tree->getRootId())
514 return $this->tree->getParentId($obj_id);
524 if (!$this->tree->isInTree($a_obj_id))
526 $parent = ($a_parent ==
"")
527 ? $this->tree->getRootId()
529 $this->tree->insertNode($a_obj_id, $parent);
549 $node_data = $this->tree->getNodeData($obj_id);
550 $subtree = $this->tree->getSubtree($node_data);
553 if($this->tree->isInTree($obj_id))
555 $this->tree->deleteTree($node_data);
559 foreach ($subtree as $node)
562 if ($node[
"type"] ==
"mob")
571 if ($node[
"type"] ==
"fold")
580 if ($node[
"type"] ==
"pg")
582 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
590 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
606 $set = $ilDB->query(
"SELECT * FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE ".
607 " foreign_id = ".$ilDB->quote($a_foreign_id,
"integer").
608 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer")
610 if ($rec = $ilDB->fetchAssoc($set))
624 $set = $ilDB->query(
"SELECT * FROM mep_tree WHERE child = ".
625 $ilDB->quote($a_item_id,
"integer").
626 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer"));
627 if ($rec = $ilDB->fetchAssoc($set))
644 $mep_item->setTitle($a_title);
645 $mep_item->setType(
"fold");
647 if ($mep_item->getId() > 0)
650 $parent = $a_parent > 0
652 :
$tree->getRootId();
654 return $mep_item->getId();
671 $new_obj->setTitle($this->
getTitle());
679 $this->
getTree()->readRootId());
692 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
693 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
694 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
697 $nodes = $this->
getTree()->getChilds($a_source_parent);
698 foreach ($nodes as $node)
701 $item->setType($node[
"type"]);
702 switch ($node[
"type"])
707 $new_mob = $mob->duplicate();
708 $item->setForeignId($new_mob->getId());
709 $item->setTitle($new_mob->getTitle());
714 $item->setTitle($node[
"title"]);
718 $new_page->setId($item->getId());
722 $new_page->setXMLContent($page->copyXMLContent(
true));
723 $new_page->buildDom();
728 $item->setTitle($node[
"title"]);
734 $a_new_obj->insertInTree($item->getId(), $a_target_parent);