ILIAS  release_8 Revision v8.24
class.ilObjMediaPoolSubItemListGUI.php
Go to the documentation of this file.
1<?php
2
24{
25 public function getHTML(): string
26 {
28
29 $lng->loadLanguageModule('content');
30 foreach ($this->getSubItemIds(true) as $sub_item) {
31 if (
32 is_object($this->getHighlighter()) &&
33 $this->getHighlighter()->getContent($this->getObjId(), $sub_item) !== ''
34 ) {
35 $this->tpl->setCurrentBlock('sea_fragment');
36 $this->tpl->setVariable('TXT_FRAGMENT', $this->getHighlighter()->getContent($this->getObjId(), $sub_item));
37 $this->tpl->parseCurrentBlock();
38 }
39 $this->tpl->setCurrentBlock('subitem');
40 $this->tpl->setVariable('SEPERATOR', ': ');
41
42 switch (ilMediaPoolItem::lookupType($sub_item)) {
43 case 'fold':
44 $this->tpl->setVariable('LINK', ilLink::_getLink($this->getRefId(), 'mep', array(), '_' . $sub_item));
45 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame(''));
46 break;
47
48 case 'mob':
49 $this->tpl->setVariable(
50 'LINK',
51 $this->getItemListGUI()->getCommandLink('allMedia') .
52 '&force_filter=' . $sub_item
53 );
54 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame(''));
55 break;
56
57 case 'pg':
58 $pool = new ilObjMediaPool($this->getRefId());
59 $parent_id = $pool->getParentId($sub_item);
60 if ($parent_id !== null) {
61 $this->tpl->setVariable('LINK', ilLink::_getLink($this->getRefId(), 'mep', [], '_' . $parent_id));
62 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame(''));
63 } else {
64 $this->tpl->setVariable('LINK', ilLink::_getLink($this->getRefId(), 'mep', []));
65 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame(''));
66 }
67 break;
68 }
69
70
71 $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('obj_' . ilMediaPoolItem::lookupType($sub_item)));
72 $this->tpl->setVariable('TITLE', ilMediaPoolItem::lookupTitle($sub_item));
73 #$this->getItemListGUI()->setChildId($sub_item);
74
75 // begin-patch mime_filter
76
77 if (!$this->parseImage($sub_item)) {
78 $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('obj_' . ilMediaPoolItem::lookupType($sub_item)));
79 $this->tpl->setVariable('SEPERATOR', ':');
80 }
81
82
83 if (count($this->getSubItemIds(true)) > 1) {
84 $this->parseRelevance($sub_item);
85 }
86
87 $this->tpl->parseCurrentBlock();
88 }
89
90 $this->showDetailsLink();
91
92 return $this->tpl->get();
93 }
94
95 protected function parseImage(int $a_sub_id): bool
96 {
97 $sub_id = ilMediaPoolItem::lookupForeignId($a_sub_id);
98 // output thumbnail (or mob icon)
99 if (ilObject::_lookupType($sub_id) === "mob") {
100 $mob = new ilObjMediaObject($sub_id);
101 $med = $mob->getMediaItem("Standard");
102 $target = $med->getThumbnailTarget();
103
104 if ($target != "") {
105 // begin-patch mime_filter
106 $this->tpl->setVariable(
107 'LINKED_LINK',
109 $this->getRefId(),
110 'mep',
111 array('action' => 'showMedia', 'mob_id' => $sub_id,'mepitem_id' => $a_sub_id)
112 )
113 );
114 $this->tpl->setVariable('LINKED_TARGET', '_blank');
115 $this->tpl->setVariable("LINKED_IMAGE", ilUtil::img($target));
116 // end-patch mime_filter
117 } else {
118 $this->tpl->setVariable("SUB_ITEM_IMAGE", ilUtil::img(ilUtil::getImagePath("icon_" . "mob" . ".gif")));
119 }
120 if (ilUtil::deducibleSize($med->getFormat()) && $med->getLocationType() === "Reference") {
121 $size = getimagesize($med->getLocation());
122 if ($size[0] > 0 && $size[1] > 0) {
123 $wr = $size[0] / 80;
124 $hr = $size[1] / 80;
125 $r = max($wr, $hr);
126 $w = (int) ($size[0] / $r);
127 $h = (int) ($size[1] / $r);
128 $this->tpl->setVariable("SUB_ITEM_IMAGE", ilUtil::img($med->getLocation(), "", $w, $h));
129 return true;
130 }
131 }
132 }
133 return false;
134 }
135}
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static lookupTitle(int $a_id)
static lookupForeignId(int $a_id)
static lookupType(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSubItemIds(bool $limited=false)
parseRelevance(int $sub_item)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static deducibleSize(string $a_mime)
checks if mime type is provided by getimagesize()
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.