ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjMediaPool Class Reference

Media pool object. More...

+ Inheritance diagram for ilObjMediaPool:
+ Collaboration diagram for ilObjMediaPool:

Public Member Functions

 ilObjMediaPool ($a_id=0, $a_call_by_reference=true)
 Constructor public. More...
 
 setDefaultWidth ($a_val)
 Set default width. More...
 
 getDefaultWidth ()
 Get default width. More...
 
 setDefaultHeight ($a_val)
 Set default height. More...
 
 getDefaultHeight ()
 Get default height. More...
 
 setForTranslation ($a_val)
 Set for translation. More...
 
 getForTranslation ()
 Get for translation. More...
 
 read ()
 Read pool data. More...
 
 create ()
 create new media pool More...
 
 createMepTree ()
 Create media pool tree. More...
 
getTree ()
 get media pool folder tree More...
 
 update ()
 update object data More...
 
 delete ()
 delete object and all related data More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts. More...
 
 getChilds ($obj_id="", $a_type="")
 get childs of node More...
 
 getChildsExceptFolders ($obj_id="")
 get childs of node More...
 
 getMediaObjects ($a_title_filter="", $a_format_filter="", $a_keyword_filter='', $a_caption_filter)
 Get media objects. More...
 
 getAllMobIds ($a_id)
 Get all media object ids. More...
 
 getUsedFormats ()
 Get used formats. More...
 
 getParentId ($obj_id="")
 
 insertInTree ($a_obj_id, $a_parent="")
 Insert into tree. More...
 
 deleteChild ($obj_id)
 Delete a child of media tree. More...
 
 createFolder ($a_title, $a_parent=0)
 Create a new folder. More...
 
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone media pool. More...
 
 copyTreeContent ($a_new_obj, $a_target_parent, $a_source_parent)
 Copy tree content. More...
 
 exportXML ($a_master_only=false)
 Export. More...
 
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 read object data from db into object More...
 
 getId ()
 get object id public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static getPoolTree ($a_obj_id)
 Get Pool Tree. More...
 
static isForeignIdInTree ($a_pool_id, $a_foreign_id)
 Check whether foreign id is in tree. More...
 
static isItemIdInTree ($a_pool_id, $a_item_id)
 Check wheter a mep item id is in the media pool. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $tree
 
 $for_translation = 0
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

Detailed Description

Media pool object.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

$Id$

Definition at line 21 of file class.ilObjMediaPool.php.

Member Function Documentation

◆ cloneObject()

ilObjMediaPool::cloneObject (   $a_target_id,
  $a_copy_id = 0 
)

Clone media pool.

Parameters
inttarget ref_id
intcopy id

Definition at line 664 of file class.ilObjMediaPool.php.

References $ilDB, ilObject\$ilias, $ilUser, copyTreeContent(), getDefaultHeight(), getDefaultWidth(), ilObject\getDescription(), ilObject\getTitle(), and getTree().

665  {
666  global $ilDB, $ilUser, $ilias;
667 
668  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
669 
670  $new_obj->setTitle($this->getTitle());
671  $new_obj->setDescription($this->getDescription());
672  $new_obj->setDefaultWidth($this->getDefaultWidth());
673  $new_obj->setDefaultHeight($this->getDefaultHeight());
674  $new_obj->update();
675 
676  // copy content
677  $this->copyTreeContent($new_obj, $new_obj->getTree()->readRootId(),
678  $this->getTree()->readRootId());
679 
680  return $new_obj;
681  }
getDefaultWidth()
Get default width.
getTitle()
get object title public
getDescription()
get object description
getDefaultHeight()
Get default height.
global $ilUser
Definition: imgupload.php:15
global $ilDB
& getTree()
get media pool folder tree
copyTreeContent($a_new_obj, $a_target_parent, $a_source_parent)
Copy tree content.
+ Here is the call graph for this function:

◆ copyTreeContent()

ilObjMediaPool::copyTreeContent (   $a_new_obj,
  $a_target_parent,
  $a_source_parent 
)

Copy tree content.

Parameters

Definition at line 689 of file class.ilObjMediaPool.php.

References getTree(), and ilMediaPoolItem\lookupForeignId().

Referenced by cloneObject().

690  {
691  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
692  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
693  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
694 
695  // get all chapters of root lm
696  $nodes = $this->getTree()->getChilds($a_source_parent);
697  foreach ($nodes as $node)
698  {
699  $item = new ilMediaPoolItem();
700  $item->setType($node["type"]);
701  switch ($node["type"])
702  {
703  case "mob":
704  $mob_id = ilMediaPoolItem::lookupForeignId($node["child"]);
705  $mob = new ilObjMediaObject($mob_id);
706  $new_mob = $mob->duplicate();
707  $item->setForeignId($new_mob->getId());
708  $item->setTitle($new_mob->getTitle());
709  $item->create();
710  break;
711 
712  case "pg":
713  $item->setTitle($node["title"]);
714  $item->create();
715  $page = new ilMediaPoolPage($node["child"]);
716  $new_page = new ilMediaPoolPage();
717  $new_page->setParentId($a_new_obj->getId());
718  $new_page->setId($item->getId());
719  $new_page->create();
720 
721  // copy page
722  $page->copy($new_page->getId(), $new_page->getParentType(), $new_page->getParentId(), true);
723  //$new_page->setXMLContent($page->copyXMLContent(true));
724  //$new_page->buildDom();
725  //$new_page->update();
726  break;
727 
728  case "fold":
729  $item->setTitle($node["title"]);
730  $item->create();
731  break;
732  }
733 
734  // insert item into tree
735  $a_new_obj->insertInTree($item->getId(), $a_target_parent);
736 
737  // handle childs
738  $this->copyTreeContent($a_new_obj, $item->getId(), $node["child"]);
739  }
740  }
Class ilMediaPoolPage.
static lookupForeignId($a_id)
Lookup Foreign Id.
Class ilObjMediaObject.
Media Pool Item.
& getTree()
get media pool folder tree
copyTreeContent($a_new_obj, $a_target_parent, $a_source_parent)
Copy tree content.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilObjMediaPool::create ( )

create new media pool

Definition at line 140 of file class.ilObjMediaPool.php.

References $ilDB, and createMepTree().

141  {
142  global $ilDB;
143 
144  parent::create();
145 
146  $ilDB->manipulate("INSERT INTO mep_data ".
147  "(id, default_width, default_height, for_translation) VALUES (".
148  $ilDB->quote($this->getId(), "integer").", ".
149  $ilDB->quote($this->getDefaultWidth(), "integer").", ".
150  $ilDB->quote($this->getDefaultHeight(), "integer").", ".
151  $ilDB->quote($this->getForTranslation(), "integer").
152  ")");
153 
154  $this->createMepTree();
155  }
createMepTree()
Create media pool tree.
global $ilDB
+ Here is the call graph for this function:

◆ createFolder()

ilObjMediaPool::createFolder (   $a_title,
  $a_parent = 0 
)

Create a new folder.

Parameters

Definition at line 639 of file class.ilObjMediaPool.php.

References getTree(), and insertInTree().

640  {
641  // perform save
642  $mep_item = new ilMediaPoolItem();
643  $mep_item->setTitle($a_title);
644  $mep_item->setType("fold");
645  $mep_item->create();
646  if ($mep_item->getId() > 0)
647  {
648  $tree = $this->getTree();
649  $parent = $a_parent > 0
650  ? $a_parent
651  : $tree->getRootId();
652  $this->insertInTree($mep_item->getId(), $parent);
653  return $mep_item->getId();
654  }
655  return false;
656  }
insertInTree($a_obj_id, $a_parent="")
Insert into tree.
Media Pool Item.
& getTree()
get media pool folder tree
+ Here is the call graph for this function:

◆ createMepTree()

ilObjMediaPool::createMepTree ( )

Create media pool tree.

Parameters

Definition at line 163 of file class.ilObjMediaPool.php.

References ilObject\getId().

Referenced by create().

164  {
165  // create media pool tree
166  $this->tree = new ilTree($this->getId());
167  $this->tree->setTreeTablePK("mep_id");
168  $this->tree->setTableNames('mep_tree','mep_item');
169  $this->tree->addTree($this->getId(), 1);
170  }
getId()
get object id public
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilObjMediaPool::delete ( )

delete object and all related data

this method has been tested on may 9th 2004 media pool tree, media objects and folders have been deleted correctly as desired

public

Returns
boolean true if all object data were removed; false if only a references were removed

Definition at line 218 of file class.ilObjMediaPool.php.

References ilObject\_lookupType(), and ilMediaPoolItem\lookupForeignId().

219  {
220  // always call parent delete function first!!
221  if (!parent::delete())
222  {
223  return false;
224  }
225 
226  // get childs
227  $childs = $this->tree->getSubTree($this->tree->getNodeData($this->tree->readRootId()));
228 
229  // delete tree
230  $this->tree->removeTree($this->tree->getTreeId());
231 
232  // delete childs
233  foreach ($childs as $child)
234  {
235  $fid = ilMediaPoolItem::lookupForeignId($child["obj_id"]);
236  switch ($child["type"])
237  {
238  case "mob":
239  if (ilObject::_lookupType($fid) == "mob")
240  {
241  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
242  $mob = new ilObjMediaObject($fid);
243  $mob->delete();
244  }
245  break;
246 
247 /* case "fold":
248  if (ilObject::_lookupType($fid) == "fold")
249  {
250  include_once("./Modules/Folder/classes/class.ilObjFolder.php");
251  $fold = new ilObjFolder($fid, false);
252  $fold->delete();
253  }
254  break;*/
255  }
256  }
257 
258  return true;
259  }
static lookupForeignId($a_id)
Lookup Foreign Id.
Class ilObjMediaObject.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ deleteChild()

ilObjMediaPool::deleteChild (   $obj_id)

Delete a child of media tree.

Parameters
intmep_item id

Definition at line 542 of file class.ilObjMediaPool.php.

References ilObject\$title, ilObject\$type, ilMediaPoolPage\_exists(), ilObject\_lookupType(), ilMediaPoolItem\lookupForeignId(), ilMediaPoolItem\lookupTitle(), and ilMediaPoolItem\lookupType().

543  {
544  $fid = ilMediaPoolItem::lookupForeignId($obj_id);
547 
548  $node_data = $this->tree->getNodeData($obj_id);
549  $subtree = $this->tree->getSubtree($node_data);
550 
551  // delete tree
552  if($this->tree->isInTree($obj_id))
553  {
554  $this->tree->deleteTree($node_data);
555  }
556 
557  // delete objects
558  foreach ($subtree as $node)
559  {
560  $fid = ilMediaPoolItem::lookupForeignId($node["child"]);
561  if ($node["type"] == "mob")
562  {
563  if (ilObject::_lookupType($fid) == "mob")
564  {
565  $obj =& new ilObjMediaObject($fid);
566  $obj->delete();
567  }
568  }
569 
570  if ($node["type"] == "fold")
571  {
572  if ($fid > 0 && ilObject::_lookupType($fid) == "fold")
573  {
574  $obj = new ilObjFolder($fid, false);
575  $obj->delete();
576  }
577  }
578 
579  if ($node["type"] == "pg")
580  {
581  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
582  if (ilMediaPoolPage::_exists($node["child"]))
583  {
584  $pg = new ilMediaPoolPage($node["child"]);
585  $pg->delete();
586  }
587  }
588 
589  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
590  $item = new ilMediaPoolItem($node["child"]);
591  $item->delete();
592  }
593  }
static lookupType($a_id)
Lookup type.
Class ilObjFolder.
Class ilMediaPoolPage.
static lookupForeignId($a_id)
Lookup Foreign Id.
Class ilObjMediaObject.
static _lookupType($a_id, $a_reference=false)
lookup object type
Media Pool Item.
static lookupTitle($a_id)
Lookup title.
static _exists($a_id)
Check whether meida pool page exists.
+ Here is the call graph for this function:

◆ exportXML()

ilObjMediaPool::exportXML (   $a_master_only = false)

Export.

Parameters

Definition at line 747 of file class.ilObjMediaPool.php.

References ilObject\getId(), and ilObject\getType().

748  {
749  if ($a_master_only)
750  {
751  include_once("./Services/Export/classes/class.ilExport.php");
752  $exp = new ilExport();
753  $conf = $exp->getConfig("Modules/MediaPool");
754  $conf->setMasterLanguageOnly(true);
755  $exp->exportObject($this->getType(),$this->getId(), "4.4.0");
756  }
757  }
getId()
get object id public
getType()
get object type public
+ Here is the call graph for this function:

◆ getAllMobIds()

ilObjMediaPool::getAllMobIds (   $a_id)

Get all media object ids.

Definition at line 452 of file class.ilObjMediaPool.php.

References $ilDB, and $query.

Referenced by ilMediaPoolExporter\getXmlExportHeadDependencies(), and ilDataCollectionExporter\getXmlExportHeadDependencies().

453  {
454  global $ilDB;
455 
456  $query = "SELECT foreign_id as id FROM ".
457  " mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
458  " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
459  " WHERE mep_tree.mep_id = ".$ilDB->quote($a_id, "integer").
460  " AND mep_item.type = ".$ilDB->quote("mob", "text").
461  " AND object_data.type = ".$ilDB->quote("mob", "text");
462  $set = $ilDB->query($query);
463  $ids = array();
464  while ($rec = $ilDB->fetchAssoc($set))
465  {
466  $ids[] = $rec["id"];
467  }
468  return $ids;
469  }
global $ilDB
+ Here is the caller graph for this function:

◆ getChilds()

ilObjMediaPool::getChilds (   $obj_id = "",
  $a_type = "" 
)

get childs of node

Definition at line 332 of file class.ilObjMediaPool.php.

References $mobs.

333  {
334  $objs = array();
335  $mobs = array();
336  $pgs = array();
337  if ($obj_id == "")
338  {
339  $obj_id = $this->tree->getRootId();
340  }
341 
342  if ($a_type == "fold" || $a_type == "")
343  {
344  $objs = $this->tree->getChildsByType($obj_id, "fold");
345  }
346  if ($a_type == "mob" || $a_type == "")
347  {
348  $mobs = $this->tree->getChildsByType($obj_id, "mob");
349  }
350  foreach($mobs as $key => $mob)
351  {
352  $objs[] = $mob;
353  }
354  if ($a_type == "pg" || $a_type == "")
355  {
356  $pgs = $this->tree->getChildsByType($obj_id, "pg");
357  }
358  foreach($pgs as $key => $pg)
359  {
360  $objs[] = $pg;
361  }
362 
363  return $objs;
364  }
$mobs

◆ getChildsExceptFolders()

ilObjMediaPool::getChildsExceptFolders (   $obj_id = "")

get childs of node

Definition at line 369 of file class.ilObjMediaPool.php.

References $mobs.

370  {
371  $objs = array();
372  $mobs = array();
373  if ($obj_id == "")
374  {
375  $obj_id = $this->tree->getRootId();
376  }
377 
378  $objs = $this->tree->getFilteredChilds(array("fold", "dummy"), $obj_id);
379  return $objs;
380  }
$mobs

◆ getDefaultHeight()

ilObjMediaPool::getDefaultHeight ( )

Get default height.

Returns
int default height

Definition at line 74 of file class.ilObjMediaPool.php.

Referenced by cloneObject().

75  {
76  return $this->default_height;
77  }
+ Here is the caller graph for this function:

◆ getDefaultWidth()

ilObjMediaPool::getDefaultWidth ( )

Get default width.

Returns
int default width

Definition at line 54 of file class.ilObjMediaPool.php.

Referenced by cloneObject().

55  {
56  return $this->default_width;
57  }
+ Here is the caller graph for this function:

◆ getForTranslation()

ilObjMediaPool::getForTranslation ( )

Get for translation.

Returns
bool lm has been imported for translation purposes

Definition at line 94 of file class.ilObjMediaPool.php.

References $for_translation.

95  {
97  }

◆ getMediaObjects()

ilObjMediaPool::getMediaObjects (   $a_title_filter = "",
  $a_format_filter = "",
  $a_keyword_filter = '',
  $a_caption_filter 
)

Get media objects.

Definition at line 385 of file class.ilObjMediaPool.php.

References $ilDB, $query, $res, ilMDKeyword\_searchKeywords(), and ilObject\getId().

386  {
387  global $ilDB;
388 
389  $query = "SELECT DISTINCT mep_tree.*, object_data.* ".
390  "FROM mep_tree JOIN mep_item ON (mep_tree.child = mep_item.obj_id) ".
391  " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ";
392 
393  if ($a_format_filter != "" or $a_caption_filter != '')
394  {
395  $query.= " JOIN media_item ON (media_item.mob_id = object_data.obj_id) ";
396  }
397 
398  $query .=
399  " WHERE mep_tree.mep_id = ".$ilDB->quote($this->getId(), "integer").
400  " AND object_data.type = ".$ilDB->quote("mob", "text");
401 
402  // filter
403  if (trim($a_title_filter) != "") // title
404  {
405  $query.= " AND ".$ilDB->like("object_data.title", "text", "%".trim($a_title_filter)."%");
406  }
407  if ($a_format_filter != "") // format
408  {
409  $filter = ($a_format_filter == "unknown")
410  ? ""
411  : $a_format_filter;
412  $query.= " AND ".$ilDB->equals("media_item.format", $filter, "text", true);
413  }
414  if(trim($a_caption_filter))
415  {
416  $query .= 'AND '.$ilDB->like('media_item.caption', 'text', '%'.trim($a_caption_filter).'%');
417  }
418 
419  $query.=
420  " ORDER BY object_data.title";
421 
422  $objs = array();
423  $set = $ilDB->query($query);
424  while ($rec = $ilDB->fetchAssoc($set))
425  {
426  $rec["foreign_id"] = $rec["obj_id"];
427  $rec["obj_id"] = "";
428  $objs[] = $rec;
429  }
430 
431  // Keyword filter
432  if($a_keyword_filter)
433  {
434  include_once './Services/MetaData/classes/class.ilMDKeyword.php';
435  $res = ilMDKeyword::_searchKeywords($a_keyword_filter,'mob',0);
436 
437  foreach($objs as $obj)
438  {
439  if(in_array($obj['foreign_id'],$res))
440  {
441  $filtered[] = $obj;
442  }
443  }
444  return (array) $filtered;
445  }
446  return $objs;
447  }
static _searchKeywords($a_query, $a_type, $a_rbac_id=0)
Search for objects by keywords.
getId()
get object id public
global $ilDB
+ Here is the call graph for this function:

◆ getParentId()

ilObjMediaPool::getParentId (   $obj_id = "")

Definition at line 502 of file class.ilObjMediaPool.php.

503  {
504  if ($obj_id == "")
505  {
506  return false;
507  }
508  if ($obj_id == $this->tree->getRootId())
509  {
510  return false;
511  }
512 
513  return $this->tree->getParentId($obj_id);
514  }

◆ getPoolTree()

static ilObjMediaPool::getPoolTree (   $a_obj_id)
static

Get Pool Tree.

Parameters
intMedia pool ID
Returns
object Tree object of media pool

Definition at line 128 of file class.ilObjMediaPool.php.

References $tree.

Referenced by ilMediaPoolTableGUI\__construct(), and read().

129  {
130  $tree = new ilTree($a_obj_id);
131  $tree->setTreeTablePK("mep_id");
132  $tree->setTableNames("mep_tree", "mep_item");
133 
134  return $tree;
135  }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ getTree()

& ilObjMediaPool::getTree ( )

get media pool folder tree

Definition at line 176 of file class.ilObjMediaPool.php.

References $tree.

Referenced by cloneObject(), copyTreeContent(), and createFolder().

177  {
178  return $this->tree;
179  }
+ Here is the caller graph for this function:

◆ getUsedFormats()

ilObjMediaPool::getUsedFormats ( )

Get used formats.

Definition at line 474 of file class.ilObjMediaPool.php.

References $ilDB, ilObject\$lng, $query, and ilObject\getId().

475  {
476  global $ilDB, $lng;
477 
478  $query = "SELECT DISTINCT media_item.format f FROM mep_tree ".
479  " JOIN mep_item ON (mep_item.obj_id = mep_tree.child) ".
480  " JOIN object_data ON (mep_item.foreign_id = object_data.obj_id) ".
481  " JOIN media_item ON (media_item.mob_id = object_data.obj_id) ".
482  " WHERE mep_tree.mep_id = ".$ilDB->quote($this->getId(), "integer").
483  " AND object_data.type = ".$ilDB->quote("mob", "text").
484  " ORDER BY f";
485  $formats = array();
486  $set = $ilDB->query($query);
487  while ($rec = $ilDB->fetchAssoc($set))
488  {
489  if ($rec["f"] != "")
490  {
491  $formats[$rec["f"]] = $rec["f"];
492  }
493  else
494  {
495  $formats["unknown"] = $lng->txt("mep_unknown");
496  }
497  }
498 
499  return $formats;
500  }
getId()
get object id public
global $ilDB
+ Here is the call graph for this function:

◆ ilObjMediaPool()

ilObjMediaPool::ilObjMediaPool (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 32 of file class.ilObjMediaPool.php.

References ilObject\ilObject().

33  {
34  // this also calls read() method! (if $a_id is set)
35  $this->type = "mep";
36  $this->ilObject($a_id,$a_call_by_reference);
37  }
ilObject($a_id=0, $a_reference=true)
Constructor public.
+ Here is the call graph for this function:

◆ insertInTree()

ilObjMediaPool::insertInTree (   $a_obj_id,
  $a_parent = "" 
)

Insert into tree.

Parameters
int$a_obj_id(mep_item obj_id)
int$a_parent

Definition at line 521 of file class.ilObjMediaPool.php.

Referenced by createFolder().

522  {
523  if (!$this->tree->isInTree($a_obj_id))
524  {
525  $parent = ($a_parent == "")
526  ? $this->tree->getRootId()
527  : $a_parent;
528  $this->tree->insertNode($a_obj_id, $parent);
529  return true;
530  }
531  else
532  {
533  return false;
534  }
535  }
+ Here is the caller graph for this function:

◆ isForeignIdInTree()

static ilObjMediaPool::isForeignIdInTree (   $a_pool_id,
  $a_foreign_id 
)
static

Check whether foreign id is in tree.

Parameters

Definition at line 601 of file class.ilObjMediaPool.php.

References $ilDB.

602  {
603  global $ilDB;
604 
605  $set = $ilDB->query("SELECT * FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE ".
606  " foreign_id = ".$ilDB->quote($a_foreign_id, "integer").
607  " AND mep_id = ".$ilDB->quote($a_pool_id, "integer")
608  );
609  if ($rec = $ilDB->fetchAssoc($set))
610  {
611  return true;
612  }
613  return false;
614  }
global $ilDB

◆ isItemIdInTree()

static ilObjMediaPool::isItemIdInTree (   $a_pool_id,
  $a_item_id 
)
static

Check wheter a mep item id is in the media pool.

Definition at line 619 of file class.ilObjMediaPool.php.

References $ilDB.

620  {
621  global $ilDB;
622 
623  $set = $ilDB->query("SELECT * FROM mep_tree WHERE child = ".
624  $ilDB->quote($a_item_id, "integer").
625  " AND mep_id = ".$ilDB->quote($a_pool_id, "integer"));
626  if ($rec = $ilDB->fetchAssoc($set))
627  {
628  return true;
629  }
630  return false;
631  }
global $ilDB

◆ notify()

ilObjMediaPool::notify (   $a_event,
  $a_ref_id,
  $a_parent_non_rbac_id,
  $a_node_id,
  $a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)

public

Parameters
stringevent
integerreference id of object where the event occured
arraypasses optional parameters if required
Returns
boolean

Definition at line 275 of file class.ilObjMediaPool.php.

References $_GET, $tree, and ilObject\getType().

276  {
277  global $tree;
278 
279  switch ($a_event)
280  {
281  case "link":
282 
283  //var_dump("<pre>",$a_params,"</pre>");
284  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
285  //exit;
286  break;
287 
288  case "cut":
289 
290  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
291  //exit;
292  break;
293 
294  case "copy":
295 
296  //var_dump("<pre>",$a_params,"</pre>");
297  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
298  //exit;
299  break;
300 
301  case "paste":
302 
303  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
304  //exit;
305  break;
306 
307  case "new":
308 
309  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
310  //exit;
311  break;
312  }
313 
314  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
315  if ($a_node_id==$_GET["ref_id"])
316  {
317  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
318  $parent_type = $parent_obj->getType();
319  if($parent_type == $this->getType())
320  {
321  $a_node_id = (int) $tree->getParentId($a_node_id);
322  }
323  }
324 
325  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
326  }
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
getType()
get object type public
+ Here is the call graph for this function:

◆ read()

ilObjMediaPool::read ( )

Read pool data.

Definition at line 102 of file class.ilObjMediaPool.php.

References $ilDB, ilObject\getId(), getPoolTree(), setDefaultHeight(), setDefaultWidth(), and setForTranslation().

103  {
104  global $ilDB;
105 
106  parent::read();
107 
108  $set = $ilDB->query("SELECT * FROM mep_data ".
109  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
110  );
111  if ($rec = $ilDB->fetchAssoc($set))
112  {
113  $this->setDefaultWidth($rec["default_width"]);
114  $this->setDefaultHeight($rec["default_height"]);
115  $this->setForTranslation($rec["for_translation"]);
116  }
117  $this->tree = ilObjMediaPool::getPoolTree($this->getId());
118  }
setForTranslation($a_val)
Set for translation.
getId()
get object id public
setDefaultWidth($a_val)
Set default width.
static getPoolTree($a_obj_id)
Get Pool Tree.
global $ilDB
setDefaultHeight($a_val)
Set default height.
+ Here is the call graph for this function:

◆ setDefaultHeight()

ilObjMediaPool::setDefaultHeight (   $a_val)

Set default height.

Parameters
intdefault height

Definition at line 64 of file class.ilObjMediaPool.php.

Referenced by read().

65  {
66  $this->default_height = $a_val;
67  }
+ Here is the caller graph for this function:

◆ setDefaultWidth()

ilObjMediaPool::setDefaultWidth (   $a_val)

Set default width.

Parameters
intdefault width

Definition at line 44 of file class.ilObjMediaPool.php.

Referenced by read().

45  {
46  $this->default_width = $a_val;
47  }
+ Here is the caller graph for this function:

◆ setForTranslation()

ilObjMediaPool::setForTranslation (   $a_val)

Set for translation.

Parameters
bool$a_vallm has been imported for translation purposes

Definition at line 84 of file class.ilObjMediaPool.php.

Referenced by read().

85  {
86  $this->for_translation = $a_val;
87  }
+ Here is the caller graph for this function:

◆ update()

ilObjMediaPool::update ( )

update object data

public

Returns
boolean

Definition at line 187 of file class.ilObjMediaPool.php.

References $ilDB.

188  {
189  global $ilDB;
190 
191  if (!parent::update())
192  {
193  return false;
194  }
195 
196  // put here object specific stuff
197  $ilDB->manipulate("UPDATE mep_data SET ".
198  " default_width = ".$ilDB->quote($this->getDefaultWidth(), "integer").",".
199  " default_height = ".$ilDB->quote($this->getDefaultHeight(), "integer").",".
200  " for_translation = ".$ilDB->quote($this->getForTranslation(), "integer")." ".
201  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
202  );
203 
204  return true;
205  }
global $ilDB

Field Documentation

◆ $for_translation

ilObjMediaPool::$for_translation = 0

Definition at line 24 of file class.ilObjMediaPool.php.

Referenced by getForTranslation().

◆ $tree

ilObjMediaPool::$tree

Definition at line 23 of file class.ilObjMediaPool.php.

Referenced by getPoolTree(), getTree(), and notify().


The documentation for this class was generated from the following file: