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");
32 public function __construct($a_id = 0, $a_call_by_reference =
true)
36 $this->db = $DIC->database();
37 $this->lng = $DIC->language();
40 parent::__construct($a_id, $a_call_by_reference);
50 $this->default_width = $a_val;
60 return $this->default_width;
70 $this->default_height = $a_val;
80 return $this->default_height;
90 $this->for_translation = $a_val;
113 "SELECT * FROM mep_data " .
114 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
116 if ($rec =
$ilDB->fetchAssoc($set)) {
135 $tree->setTreeTablePK(
"mep_id");
136 $tree->setTableNames(
"mep_tree",
"mep_item");
148 return self::_getPoolTree($this->
getId());
161 $ilDB->manipulate(
"INSERT INTO mep_data " .
162 "(id, default_width, default_height, for_translation) VALUES (" .
163 $ilDB->quote($this->getId(),
"integer") .
", " .
164 $ilDB->quote($this->getDefaultWidth(),
"integer") .
", " .
165 $ilDB->quote($this->getDefaultHeight(),
"integer") .
", " .
166 $ilDB->quote($this->getForTranslation(),
"integer") .
182 $this->mep_tree->setTreeTablePK(
"mep_id");
183 $this->mep_tree->setTableNames(
'mep_tree',
'mep_item');
184 $this->mep_tree->addTree($this->
getId(), 1);
212 "UPDATE mep_data SET " .
213 " default_width = " .
$ilDB->quote($this->getDefaultWidth(),
"integer") .
"," .
214 " default_height = " .
$ilDB->quote($this->getDefaultHeight(),
"integer") .
"," .
215 " for_translation = " .
$ilDB->quote($this->getForTranslation(),
"integer") .
" " .
216 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
233 public function delete()
236 if (!parent::delete()) {
241 $childs = $this->mep_tree->getSubTree($this->mep_tree->getNodeData($this->mep_tree->readRootId()));
244 $this->mep_tree->removeTree($this->mep_tree->getTreeId());
247 foreach ($childs as $child) {
249 switch ($child[
"type"]) {
252 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
272 $obj_id = $this->mep_tree->getRootId();
276 $objs = $this->mep_tree->getChildsByType($obj_id,
"fold");
279 $mobs = $this->mep_tree->getChildsByType($obj_id,
"mob");
285 $pgs = $this->mep_tree->getChildsByType($obj_id,
"pg");
287 foreach ($pgs as
$key => $pg) {
300 $obj_id = $this->mep_tree->getRootId();
303 $objs = $this->mep_tree->getFilteredChilds(
array(
"fold",
"dummy"), $obj_id);
310 public function getMediaObjects($a_title_filter =
"", $a_format_filter =
"", $a_keyword_filter =
'', $a_caption_filter)
314 $query =
"SELECT DISTINCT mep_tree.*, object_data.* " .
315 "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) " .
316 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
318 if ($a_format_filter !=
"" or $a_caption_filter !=
'') {
319 $query.=
" JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
323 " WHERE mep_tree.mep_id = " .
$ilDB->quote($this->
getId(),
"integer") .
324 " AND object_data.type = " .
$ilDB->quote(
"mob",
"text");
327 if (trim($a_title_filter) !=
"") {
328 $query.=
" AND " .
$ilDB->like(
"object_data.title",
"text",
"%" . trim($a_title_filter) .
"%");
330 if ($a_format_filter !=
"") {
331 $filter = ($a_format_filter ==
"unknown")
334 $query.=
" AND " .
$ilDB->equals(
"media_item.format", $filter,
"text",
true);
336 if (trim($a_caption_filter)) {
337 $query .=
'AND ' .
$ilDB->like(
'media_item.caption',
'text',
'%' . trim($a_caption_filter) .
'%');
341 " ORDER BY object_data.title";
345 while ($rec =
$ilDB->fetchAssoc($set)) {
346 $rec[
"foreign_id"] = $rec[
"obj_id"];
352 if ($a_keyword_filter) {
353 include_once
'./Services/MetaData/classes/class.ilMDKeyword.php';
356 foreach ($objs as $obj) {
357 if (in_array($obj[
'foreign_id'],
$res)) {
361 return (
array) $filtered;
375 $ilDB = $DIC->database();
377 $query =
"SELECT foreign_id as id FROM " .
378 " mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) " .
379 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) " .
380 " WHERE mep_tree.mep_id = " .
$ilDB->quote($a_id,
"integer") .
381 " AND mep_item.type = " .
$ilDB->quote(
"mob",
"text") .
382 " AND object_data.type = " .
$ilDB->quote(
"mob",
"text");
385 while ($rec =
$ilDB->fetchAssoc($set)) {
399 $query =
"SELECT DISTINCT media_item.format f FROM mep_tree " .
400 " JOIN mep_item ON (mep_item.obj_id = mep_tree.child) " .
401 " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) " .
402 " JOIN media_item ON (media_item.mob_id = object_data.obj_id) " .
403 " WHERE mep_tree.mep_id = " .
$ilDB->quote($this->
getId(),
"integer") .
404 " AND object_data.type = " .
$ilDB->quote(
"mob",
"text") .
408 while ($rec =
$ilDB->fetchAssoc($set)) {
409 if ($rec[
"f"] !=
"") {
424 if ($obj_id == $this->mep_tree->getRootId()) {
428 return $this->mep_tree->getParentId($obj_id);
438 if (!$this->mep_tree->isInTree($a_obj_id)) {
439 $parent = ($a_parent ==
"")
440 ? $this->mep_tree->getRootId()
442 $this->mep_tree->insertNode($a_obj_id, $parent);
456 $node_data = $this->mep_tree->getNodeData($obj_id);
457 $subtree = $this->mep_tree->getSubtree($node_data);
460 if ($this->mep_tree->isInTree($obj_id)) {
461 $this->mep_tree->deleteTree($node_data);
465 foreach ($subtree as $node) {
467 if ($node[
"type"] ==
"mob") {
474 if ($node[
"type"] ==
"fold") {
481 if ($node[
"type"] ==
"pg") {
482 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
489 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
505 $ilDB = $DIC->database();
508 "SELECT * FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE " .
509 " foreign_id = " .
$ilDB->quote($a_foreign_id,
"integer") .
510 " AND mep_id = " .
$ilDB->quote($a_pool_id,
"integer")
512 if ($rec =
$ilDB->fetchAssoc($set)) {
525 $ilDB = $DIC->database();
527 $set =
$ilDB->query(
"SELECT * FROM mep_tree WHERE child = " .
528 $ilDB->quote($a_item_id,
"integer") .
529 " AND mep_id = " .
$ilDB->quote($a_pool_id,
"integer"));
530 if ($rec =
$ilDB->fetchAssoc($set)) {
546 $mep_item->setTitle($a_title);
547 $mep_item->setType(
"fold");
549 if ($mep_item->getId() > 0) {
551 $parent = $a_parent > 0
553 :
$tree->getRootId();
555 return $mep_item->getId();
566 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree =
false)
568 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
570 $new_obj->setTitle($this->
getTitle());
579 $new_obj->getTree()->readRootId(),
594 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
595 include_once(
"./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
596 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
599 $nodes = $this->
getTree()->getChilds($a_source_parent);
600 foreach ($nodes as $node) {
602 $item->setType($node[
"type"]);
603 switch ($node[
"type"]) {
607 $new_mob = $mob->duplicate();
608 $item->setForeignId($new_mob->getId());
609 $item->setTitle($new_mob->getTitle());
614 $item->setTitle($node[
"title"]);
618 $new_page->setParentId($a_new_obj->getId());
619 $new_page->setId($item->getId());
623 $page->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(),
true);
627 $item->setTitle($node[
"title"]);
633 $a_new_obj->insertInTree($item->getId(), $a_target_parent);
647 if (in_array($a_mode,
array(
"master",
"masternomedia"))) {
648 include_once(
"./Services/Export/classes/class.ilExport.php");
650 $conf = $exp->getConfig(
"Modules/MediaPool");
651 $conf->setMasterLanguageOnly(
true, ($a_mode ==
"master"));
652 $exp->exportObject($this->
getType(), $this->
getId(),
"4.4.0");
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static _searchKeywords($a_query, $a_type, $a_rbac_id=0)
Search for objects by keywords.
foreach($_POST as $key=> $value) $res
getId()
get object id public
getTitle()
get object title public
getDescription()
get object description
getType()
get object type public
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
update($pash, $contents, Config $config)