ILIAS  release_8 Revision v8.24
McstImageGalleryGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for McstImageGalleryGUI:

Public Member Functions

 __construct (\ilObjMediaCast $obj, $tpl=null, string $rss_link="")
 
 executeCommand ()
 
 getHTML ()
 
 setCompletedCallback (string $completed_callback)
 

Protected Member Functions

 downloadAll ()
 

Protected Attributes

ILIAS MediaCast InternalDomainService $domain
 
string $completed_callback
 
string $rss_link
 
ilObjMediaCast $media_cast
 
ilGlobalTemplateInterface $tpl
 
ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilObjUser $user
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilAccessHandler $access
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Image gallery GUI for mediacasts

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

McstImageGalleryGUI::__construct ( \ilObjMediaCast  $obj,
  $tpl = null,
string  $rss_link = "" 
)

Definition at line 38 of file class.McstImageGalleryGUI.php.

42 {
43 global $DIC;
44
45 $this->ui = $DIC->ui();
46 $this->rss_link = $rss_link;
47 $this->lng = $DIC->language();
48 $this->media_cast = $obj;
49 $this->tpl = $tpl;
50 $this->user = $DIC->user();
51 $this->ctrl = $DIC->ctrl();
52 $this->access = $DIC->access();
53 $this->toolbar = $DIC->toolbar();
54 $this->domain = $DIC->mediaCast()->internal()->domain();
55 }
ilGlobalTemplateInterface $tpl
global $DIC
Definition: feed.php:28

References $DIC, $rss_link, $tpl, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ downloadAll()

McstImageGalleryGUI::downloadAll ( )
protected

Definition at line 226 of file class.McstImageGalleryGUI.php.

226 : void
227 {
228 if (!$this->media_cast->getDownloadable() ||
229 !$this->access->checkAccess('read', '', $this->media_cast->getRefId())) {
230 $this->tpl->setOnScreenMessage(
231 $this->tpl::MESSAGE_TYPE_FAILURE,
232 $this->lng->txt('permission_denied'),
233 true
234 );
235 $this->ctrl->redirectByClass(ilObjMediaCastGUI::class);
236 }
237
239 $download_task = new \ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask(
240 (int) $user->getId(),
241 (int) $this->media_cast->getRefId(),
242 (int) $this->media_cast->getId()
243 );
244
245 if ($download_task->run()) {
246 $this->tpl->setOnScreenMessage(
247 'success',
248 $this->lng->txt('mcst_download_started_bg'),
249 true
250 );
251 }
252
253 $this->ctrl->redirectByClass("ilobjmediacastgui", "showContent");
254 }

References $user, ILIAS\Repository\ctrl(), ilObject\getId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ executeCommand()

McstImageGalleryGUI::executeCommand ( )

Definition at line 57 of file class.McstImageGalleryGUI.php.

57 : void
58 {
60
61 $next_class = $ctrl->getNextClass($this);
62 $cmd = $ctrl->getCmd();
63
64 switch ($next_class) {
65 default:
66 if (in_array($cmd, array("downloadAll"))) {
67 $this->$cmd();
68 }
69 }
70 }
getNextClass($a_gui_class=null)
@inheritDoc
getCmd(string $fallback_command=null)
@inheritDoc

References $ctrl, ilCtrl\getCmd(), and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ getHTML()

McstImageGalleryGUI::getHTML ( )

Definition at line 72 of file class.McstImageGalleryGUI.php.

72 : string
73 {
74 $f = $this->ui->factory();
75 $renderer = $this->ui->renderer();
79
80 // toolbar
82 if ($this->media_cast->getDownloadable()) {
83 $toolbar->addFormButton($lng->txt("mcst_download_all"), "downloadAll");
84 }
85
86 if ($this->rss_link !== "") {
87 $b = $f->link()->standard(
88 $lng->txt("mcst_webfeed"),
89 $this->rss_link
90 )->withOpenInNewViewport(true);
92 }
93
94 // cards and modals
95 $cards = [];
96 $modals = [];
97
98 $pages = [];
99
100 $lp_collection_mode = $this->domain->learningProgress($this->media_cast)->isCollectionMode();
101
102 $mob_modals = [];
103 foreach ($this->media_cast->getSortedItemsArray() as $item) {
104 $mob = new \ilObjMediaObject($item["mob_id"]);
105 $med = $mob->getMediaItem("Standard");
106
107 if (!in_array($med->getFormat(), ["image/png","image/jpeg","image/gif"])) {
108 continue;
109 }
110
111 if (strcasecmp("Reference", $med->getLocationType()) == 0) {
112 $resource = $med->getLocation();
113 } else {
114 $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
115 $resource = ilWACSignedPath::signFile($path_to_file);
116 }
117
118 $image = $f->image()->responsive(
119 $resource,
120 $mob->getTitle()
121 );
122
123 $pages[] = $f->modal()->lightboxImagePage($image, $mob->getTitle());
124 if ($lp_collection_mode) {
125 $mob_modals[$mob->getId()] = $f->modal()->lightbox($pages);
126 $pages = [];
127 }
128 }
129 $main_modal = null;
130 if (!$lp_collection_mode) {
131 $main_modal = $f->modal()->lightbox($pages);
132 }
133
134 $cnt = 0;
135 foreach ($this->media_cast->getSortedItemsArray() as $item) {
136 $mob = new \ilObjMediaObject($item["mob_id"]);
137 $med = $mob->getMediaItem("Standard");
138
139 if (!in_array($med->getFormat(), ["image/png","image/jpeg","image/gif"])) {
140 continue;
141 }
142
143 if (strcasecmp("Reference", $med->getLocationType()) == 0) {
144 $resource = $med->getLocation();
145 } else {
146 $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
147 $resource = ilWACSignedPath::signFile($path_to_file);
148 }
149 $preview_resource = $resource;
150 if ($mob->getVideoPreviewPic() != "") {
151 $preview_resource = ilWACSignedPath::signFile($mob->getVideoPreviewPic());
152 }
153
154
155 $preview_image = $f->image()->responsive(
156 $preview_resource,
157 $mob->getTitle()
158 );
159
160 $image = $f->image()->responsive(
161 $resource,
162 $mob->getTitle()
163 );
164
165 if (!$lp_collection_mode) {
166 $modal = $main_modal;
167 } else {
168 $modal = $mob_modals[$mob->getId()];
169 }
170
171 $card_image = $preview_image->withAction($modal->getShowSignal());
172 $slide_to = "";
173 $completed_cb = "";
174 if (!$lp_collection_mode) {
175 $slide_to = "document.querySelector('.modal-body .carousel [data-slide-to=\"" . $cnt . "\"]').click();";
176 } else {
177 $completed_cb = $this->completed_callback . '&mob_id=' . $mob->getId();
178 $completed_cb = "$.ajax({type:'GET', url: '$completed_cb'});";
179 }
180
181 $card_image = $card_image->withAdditionalOnLoadCode(function ($id) use ($slide_to, $completed_cb) {
182 return "$('#$id').click(function(e) { $slide_to $completed_cb });";
183 });
184 if (!$lp_collection_mode) {
185 $cnt++;
186 }
187
188 $sections = ($mob->getDescription())
189 ? [$f->legacy($mob->getDescription())]
190 : [];
191
192 if ($this->media_cast->getDownloadable()) {
193 $ctrl->setParameterByClass("ilobjmediacastgui", "item_id", $item["id"]);
194 $ctrl->setParameterByClass("ilobjmediacastgui", "purpose", "Standard");
195 $download = $ctrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem");
196 $sections[] = $f->button()->standard($lng->txt("download"), $download);
197 }
198
199 //$title_button = $f->button()->shy($mob->getTitle(), $modal->getShowSignal());
200 $title = $mob->getTitle();
201
202 $card = $f->card()->standard(
203 $title,
204 $card_image
205 )->withSections(
206 $sections
207 )->withTitleAction($modal->getShowSignal());
208
209 $cards[] = $card;
210 $modals[] = $modal;
211 }
212
213 $deck = $f->deck($cards);
214
215 if (count($pages) === 0 && count($mob_modals) === 0) {
216 return "";
217 }
218 if (!$lp_collection_mode) {
219 $modals = [$main_modal];
220 } else {
221 $modals = $mob_modals;
222 }
223 return "<div id='il-mcst-img-gallery'>" . $renderer->render(array_merge([$deck], $modals)) . "</div>";
224 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
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 _getURL(int $a_mob_id)
get directory for files of media object
setFormAction(string $a_val, bool $a_multipart=false, string $a_target="")
Set form action (if form action is set, toolbar is wrapped into form tags)
addComponent(\ILIAS\UI\Component\Component $a_comp)
addFormButton(string $a_txt, string $a_cmd, ?int $a_acc_key=null, bool $a_primary=false, ?string $a_class=null)
static signFile(string $path_to_file)

References Vendor\Package\$b, $ctrl, Vendor\Package\$f, $id, $lng, $toolbar, ilObjMediaObject\_getURL(), ilToolbarGUI\addComponent(), ilToolbarGUI\addFormButton(), ilCtrl\getFormAction(), ilCtrl\getLinkTargetByClass(), ilToolbarGUI\setFormAction(), ilCtrl\setParameterByClass(), ilWACSignedPath\signFile(), ilLanguage\txt(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ setCompletedCallback()

McstImageGalleryGUI::setCompletedCallback ( string  $completed_callback)

Definition at line 256 of file class.McstImageGalleryGUI.php.

256 : void
257 {
258 $this->completed_callback = $completed_callback;
259 }

References $completed_callback.

Field Documentation

◆ $access

ilAccessHandler McstImageGalleryGUI::$access
protected

Definition at line 36 of file class.McstImageGalleryGUI.php.

◆ $completed_callback

string McstImageGalleryGUI::$completed_callback
protected

Definition at line 27 of file class.McstImageGalleryGUI.php.

Referenced by setCompletedCallback().

◆ $ctrl

ilCtrl McstImageGalleryGUI::$ctrl
protected

Definition at line 34 of file class.McstImageGalleryGUI.php.

Referenced by executeCommand(), and getHTML().

◆ $domain

ILIAS MediaCast InternalDomainService McstImageGalleryGUI::$domain
protected

Definition at line 26 of file class.McstImageGalleryGUI.php.

◆ $lng

ilLanguage McstImageGalleryGUI::$lng
protected

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

Referenced by getHTML().

◆ $media_cast

ilObjMediaCast McstImageGalleryGUI::$media_cast
protected

Definition at line 29 of file class.McstImageGalleryGUI.php.

◆ $rss_link

string McstImageGalleryGUI::$rss_link
protected

Definition at line 28 of file class.McstImageGalleryGUI.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI McstImageGalleryGUI::$toolbar
protected

Definition at line 35 of file class.McstImageGalleryGUI.php.

Referenced by getHTML().

◆ $tpl

ilGlobalTemplateInterface McstImageGalleryGUI::$tpl
protected

Definition at line 30 of file class.McstImageGalleryGUI.php.

Referenced by __construct().

◆ $ui

ILIAS DI UIServices McstImageGalleryGUI::$ui
protected

Definition at line 31 of file class.McstImageGalleryGUI.php.

◆ $user

ilObjUser McstImageGalleryGUI::$user
protected

Definition at line 33 of file class.McstImageGalleryGUI.php.

Referenced by downloadAll().


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