ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 MediaObjects MediaType MediaTypeManager $media_types
 
ILIAS MediaCast InternalGUIService $gui
 
ILIAS MediaCast MediaCastManager $mc_manager
 
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 41 of file class.McstImageGalleryGUI.php.

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

45  {
46  global $DIC;
47 
48  $this->ui = $DIC->ui();
49  $this->rss_link = $rss_link;
50  $this->lng = $DIC->language();
51  $this->media_cast = $obj;
52  $this->tpl = $tpl;
53  $this->user = $DIC->user();
54  $this->ctrl = $DIC->ctrl();
55  $this->access = $DIC->access();
56  $this->toolbar = $DIC->toolbar();
57  $this->media_types = $DIC->mediaObjects()->internal()->domain()->mediaType();
58  $this->mc_manager = $DIC->mediaCast()->internal()->domain()->mediaCast($this->media_cast);
59  $this->gui = $DIC->mediaCast()->internal()->gui();
60  $this->domain = $DIC->mediaCast()->internal()->domain();
61  }
ilGlobalTemplateInterface $tpl
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ downloadAll()

McstImageGalleryGUI::downloadAll ( )
protected

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

References $user, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), and ILIAS\Repository\lng().

240  : void
241  {
242  if (!$this->media_cast->getDownloadable() ||
243  !$this->access->checkAccess('read', '', $this->media_cast->getRefId())) {
244  $this->tpl->setOnScreenMessage(
245  $this->tpl::MESSAGE_TYPE_FAILURE,
246  $this->lng->txt('permission_denied'),
247  true
248  );
249  $this->ctrl->redirectByClass(ilObjMediaCastGUI::class);
250  }
251 
252  $user = $this->user;
253  $download_task = new \ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask(
254  (int) $user->getId(),
255  (int) $this->media_cast->getRefId(),
256  (int) $this->media_cast->getId()
257  );
258 
259  if ($download_task->run()) {
260  $this->tpl->setOnScreenMessage(
261  'success',
262  $this->lng->txt('mcst_download_started_bg'),
263  true
264  );
265  }
266 
267  $this->ctrl->redirectByClass("ilobjmediacastgui", "showContent");
268  }
+ Here is the call graph for this function:

◆ executeCommand()

McstImageGalleryGUI::executeCommand ( )

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

References $ctrl, and ilCtrl\getNextClass().

63  : void
64  {
66 
67  $next_class = $ctrl->getNextClass($this);
68  $cmd = $ctrl->getCmd();
69 
70  switch ($next_class) {
71  default:
72  if (in_array($cmd, array("downloadAll"))) {
73  $this->$cmd();
74  }
75  }
76  }
getCmd(string $fallback_command=null)
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ getHTML()

McstImageGalleryGUI::getHTML ( )

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

References Vendor\Package\$b, $ctrl, Vendor\Package\$f, $id, $lng, $rss_link, $toolbar, ilObjMediaObject\_getURL(), ILIAS\Repository\int(), ilToolbarGUI\setFormAction(), ilWACSignedPath\signFile(), and ILIAS\Repository\ui().

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

◆ setCompletedCallback()

McstImageGalleryGUI::setCompletedCallback ( string  $completed_callback)

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

References $completed_callback.

270  : void
271  {
272  $this->completed_callback = $completed_callback;
273  }

Field Documentation

◆ $access

ilAccessHandler McstImageGalleryGUI::$access
protected

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

◆ $completed_callback

string McstImageGalleryGUI::$completed_callback
protected

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

Referenced by setCompletedCallback().

◆ $ctrl

ilCtrl McstImageGalleryGUI::$ctrl
protected

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

Referenced by executeCommand(), and getHTML().

◆ $domain

ILIAS MediaCast InternalDomainService McstImageGalleryGUI::$domain
protected

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

◆ $gui

ILIAS MediaCast InternalGUIService McstImageGalleryGUI::$gui
protected

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

◆ $lng

ilLanguage McstImageGalleryGUI::$lng
protected

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

Referenced by getHTML().

◆ $mc_manager

ILIAS MediaCast MediaCastManager McstImageGalleryGUI::$mc_manager
protected

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

◆ $media_cast

ilObjMediaCast McstImageGalleryGUI::$media_cast
protected

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

◆ $media_types

ILIAS MediaObjects MediaType MediaTypeManager McstImageGalleryGUI::$media_types
protected

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

◆ $rss_link

string McstImageGalleryGUI::$rss_link
protected

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

Referenced by __construct(), and getHTML().

◆ $toolbar

ilToolbarGUI McstImageGalleryGUI::$toolbar
protected

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

Referenced by getHTML().

◆ $tpl

ilGlobalTemplateInterface McstImageGalleryGUI::$tpl
protected

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

Referenced by __construct().

◆ $ui

ILIAS DI UIServices McstImageGalleryGUI::$ui
protected

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

◆ $user

ilObjUser McstImageGalleryGUI::$user
protected

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

Referenced by downloadAll().


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