ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ downloadAll()

McstImageGalleryGUI::downloadAll ( )
protected

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

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

236  : void
237  {
238  if (!$this->media_cast->getDownloadable() ||
239  !$this->access->checkAccess('read', '', $this->media_cast->getRefId())) {
240  $this->tpl->setOnScreenMessage(
241  $this->tpl::MESSAGE_TYPE_FAILURE,
242  $this->lng->txt('permission_denied'),
243  true
244  );
245  $this->ctrl->redirectByClass(ilObjMediaCastGUI::class);
246  }
247 
248  $user = $this->user;
249  $download_task = new \ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask(
250  (int) $user->getId(),
251  (int) $this->media_cast->getRefId(),
252  (int) $this->media_cast->getId()
253  );
254 
255  if ($download_task->run()) {
256  $this->tpl->setOnScreenMessage(
257  'success',
258  $this->lng->txt('mcst_download_started_bg'),
259  true
260  );
261  }
262 
263  $this->ctrl->redirectByClass("ilobjmediacastgui", "showContent");
264  }
+ 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, $renderer, $rss_link, $toolbar, ILIAS\Repository\int(), null, ilToolbarGUI\setFormAction(), ILIAS\Repository\ui(), and ILIAS\GlobalScreen\Scope\Footer\Factory\withOpenInNewViewport().

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  $resource = $mob->getStandardSrc();
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  $items = $this->media_cast->getSortedItemsArray();
136  $total = count($items);
137  foreach ($items as $item) {
138  $mob = new \ilObjMediaObject($item["mob_id"]);
139  $med = $mob->getMediaItem("Standard");
140 
141  if (!in_array($med->getFormat(), iterator_to_array($this->media_types->getAllowedImageMimeTypes()), true)) {
142  continue;
143  }
144 
145  $resource = $mob->getStandardSrc();
146 
147  $preview_resource = $resource;
148  if ($mob->getVideoPreviewPic() != "") {
149  // $preview_resource = $mob->getVideoPreviewPic();
150  }
151 
152 
153  $preview_image = $f->image()->responsive(
154  $preview_resource,
155  $mob->getTitle()
156  );
157 
158  $image = $f->image()->responsive(
159  $resource,
160  $mob->getTitle()
161  );
162 
163  if (!$lp_collection_mode) {
164  $modal = $main_modal;
165  } else {
166  $modal = $mob_modals[$mob->getId()];
167  }
168 
169  $card_image = $preview_image->withAction($modal->getShowSignal());
170  $slide_to = "";
171  $completed_cb = "";
172  if (!$lp_collection_mode) {
173  if ($total > 1) {
174  $slide_to = "document.querySelector('.modal-body .carousel [data-slide-to=\"" . $cnt . "\"]').click();";
175  }
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()->content($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  // comments
200  if ($this->mc_manager->commentsActive()) {
201  $comments_gui = $this->gui->comments()->commentGUI(
202  $this->media_cast->getRefId(),
203  (int) $item["id"]
204  );
205  $sections[] = $f->legacy()->content($comments_gui->getGlyph());
206  }
207 
208  //$title_button = $f->button()->shy($mob->getTitle(), $modal->getShowSignal());
209  $title = $mob->getTitle();
210 
211  $card = $f->card()->standard(
212  $title,
213  $card_image
214  )->withSections(
215  $sections
216  )->withTitleAction($modal->getShowSignal());
217 
218 
219  $cards[] = $card;
220  $modals[] = $modal;
221  }
222 
223  $deck = $f->deck($cards);
224 
225  if (count($pages) === 0 && count($mob_modals) === 0) {
226  return "";
227  }
228  if (!$lp_collection_mode) {
229  $modals = [$main_modal];
230  } else {
231  $modals = $mob_modals;
232  }
233  return "<div id='il-mcst-img-gallery'>" . $renderer->render(array_merge([$deck], $modals)) . "</div>";
234  }
getFormAction(object $a_gui_obj, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
$renderer
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
addFormButton(string $a_txt, string $a_cmd, ?int $a_acc_key=null, bool $a_primary=false, ?string $a_class=null)
getLinkTargetByClass( $a_class, ?string $a_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 266 of file class.McstImageGalleryGUI.php.

References $completed_callback.

266  : void
267  {
268  $this->completed_callback = $completed_callback;
269  }

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: