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");
251 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
291 if ($a_node_id==
$_GET[
"ref_id"])
293 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
294 $parent_type = $parent_obj->getType();
295 if($parent_type == $this->
getType())
297 $a_node_id = (int) $tree->getParentId($a_node_id);
301 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
315 $obj_id = $this->tree->getRootId();
318 if ($a_type ==
"fold" || $a_type ==
"")
320 $objs = $this->tree->getChildsByType($obj_id,
"fold");
322 if ($a_type ==
"mob" || $a_type ==
"")
324 $mobs = $this->tree->getChildsByType($obj_id,
"mob");
326 foreach(
$mobs as $key => $mob)
330 if ($a_type ==
"pg" || $a_type ==
"")
332 $pgs = $this->tree->getChildsByType($obj_id,
"pg");
334 foreach($pgs as $key => $pg)
351 $obj_id = $this->tree->getRootId();
354 $objs = $this->tree->getFilteredChilds(array(
"fold",
"dummy"), $obj_id);
361 function getMediaObjects($a_title_filter =
"", $a_format_filter =
"", $a_keyword_filter =
'', $a_caption_filter)
365 $query =
"SELECT DISTINCT mep_tree.*, object_data.* ".
366 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
367 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
369 if ($a_format_filter !=
"" or $a_caption_filter !=
'')
371 $query.=
" JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
375 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
376 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
379 if (trim($a_title_filter) !=
"")
381 $query.=
" AND ".$ilDB->like(
"object_data.title",
"text",
"%".trim($a_title_filter).
"%");
383 if ($a_format_filter !=
"")
385 $filter = ($a_format_filter ==
"unknown")
388 $query.=
" AND ".$ilDB->equals(
"media_item.format", $filter,
"text",
true);
390 if(trim($a_caption_filter))
392 $query .=
'AND '.$ilDB->like(
'media_item.caption',
'text',
'%'.trim($a_caption_filter).
'%');
396 " ORDER BY object_data.title";
399 $set = $ilDB->query(
$query);
400 while ($rec = $ilDB->fetchAssoc($set))
402 $rec[
"foreign_id"] = $rec[
"obj_id"];
408 if($a_keyword_filter)
410 include_once
'./Services/MetaData/classes/class.ilMDKeyword.php';
413 foreach($objs as $obj)
415 if(in_array($obj[
'foreign_id'],
$res))
420 return (array) $filtered;
432 $query =
"SELECT foreign_id as id FROM ".
433 " mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
434 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
435 " WHERE mep_tree.mep_id = ".$ilDB->quote($a_id,
"integer").
436 " AND mep_item.type = ".$ilDB->quote(
"mob",
"text").
437 " AND object_data.type = ".$ilDB->quote(
"mob",
"text");
438 $set = $ilDB->query(
$query);
440 while ($rec = $ilDB->fetchAssoc($set))
454 $query =
"SELECT DISTINCT media_item.format f FROM mep_tree ".
455 " JOIN mep_item ON (mep_item.obj_id = mep_tree.child) ".
456 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
457 " JOIN media_item ON (media_item.mob_id = object_data.obj_id) ".
458 " WHERE mep_tree.mep_id = ".$ilDB->quote($this->
getId(),
"integer").
459 " AND object_data.type = ".$ilDB->quote(
"mob",
"text").
462 $set = $ilDB->query(
$query);
463 while ($rec = $ilDB->fetchAssoc($set))
467 $formats[$rec[
"f"]] = $rec[
"f"];
471 $formats[
"unknown"] = $lng->txt(
"mep_unknown");
484 if ($obj_id == $this->tree->getRootId())
489 return $this->tree->getParentId($obj_id);
499 if (!$this->tree->isInTree($a_obj_id))
501 $parent = ($a_parent ==
"")
502 ? $this->tree->getRootId()
504 $this->tree->insertNode($a_obj_id, $parent);
524 $node_data = $this->tree->getNodeData($obj_id);
525 $subtree = $this->tree->getSubtree($node_data);
528 if($this->tree->isInTree($obj_id))
530 $this->tree->deleteTree($node_data);
534 foreach ($subtree as $node)
537 if ($node[
"type"] ==
"mob")
546 if ($node[
"type"] ==
"fold")
555 if ($node[
"type"] ==
"pg")
557 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
565 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
581 $set = $ilDB->query(
"SELECT * FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE ".
582 " foreign_id = ".$ilDB->quote($a_foreign_id,
"integer").
583 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer")
585 if ($rec = $ilDB->fetchAssoc($set))
599 $set = $ilDB->query(
"SELECT * FROM mep_tree WHERE child = ".
600 $ilDB->quote($a_item_id,
"integer").
601 " AND mep_id = ".$ilDB->quote($a_pool_id,
"integer"));
602 if ($rec = $ilDB->fetchAssoc($set))
619 $mep_item->setTitle($a_title);
620 $mep_item->setType(
"fold");
622 if ($mep_item->getId() > 0)
625 $parent = $a_parent > 0
627 :
$tree->getRootId();
629 return $mep_item->getId();
646 $new_obj->setTitle($this->
getTitle());
654 $this->
getTree()->readRootId());
667 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
668 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
669 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
672 $nodes = $this->
getTree()->getChilds($a_source_parent);
673 foreach ($nodes as $node)
676 $item->setType($node[
"type"]);
677 switch ($node[
"type"])
682 $new_mob = $mob->duplicate();
683 $item->setForeignId($new_mob->getId());
684 $item->setTitle($new_mob->getTitle());
689 $item->setTitle($node[
"title"]);
693 $new_page->setId($item->getId());
697 $page->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(),
true);
704 $item->setTitle($node[
"title"]);
710 $a_new_obj->insertInTree($item->getId(), $a_target_parent);