ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 

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 37 of file class.McstImageGalleryGUI.php.

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

41  {
42  global $DIC;
43 
44  $this->ui = $DIC->ui();
45  $this->rss_link = $rss_link;
46  $this->lng = $DIC->language();
47  $this->media_cast = $obj;
48  $this->tpl = $tpl;
49  $this->user = $DIC->user();
50  $this->ctrl = $DIC->ctrl();
51  $this->toolbar = $DIC->toolbar();
52  $this->domain = $DIC->mediaCast()->internal()->domain();
53  }
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 224 of file class.McstImageGalleryGUI.php.

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

224  : void
225  {
226  $user = $this->user;
227  $download_task = new \ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask(
228  (int) $user->getId(),
229  (int) $this->media_cast->getRefId(),
230  (int) $this->media_cast->getId()
231  );
232 
233  if ($download_task->run()) {
234  $this->tpl->setOnScreenMessage(
235  'success',
236  $this->lng->txt('mcst_download_started_bg'),
237  true
238  );
239  }
240 
241  $this->ctrl->redirectByClass("ilobjmediacastgui", "showContent");
242  }
+ Here is the call graph for this function:

◆ executeCommand()

McstImageGalleryGUI::executeCommand ( )

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

References $ctrl, and ilCtrl\getNextClass().

55  : void
56  {
58 
59  $next_class = $ctrl->getNextClass($this);
60  $cmd = $ctrl->getCmd();
61 
62  switch ($next_class) {
63  default:
64  if (in_array($cmd, array("downloadAll"))) {
65  $this->$cmd();
66  }
67  }
68  }
getCmd(string $fallback_command=null)
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ getHTML()

McstImageGalleryGUI::getHTML ( )

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

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

70  : string
71  {
72  $f = $this->ui->factory();
73  $renderer = $this->ui->renderer();
75  $lng = $this->lng;
77 
78  // toolbar
80  if ($this->media_cast->getDownloadable()) {
81  $toolbar->addFormButton($lng->txt("mcst_download_all"), "downloadAll");
82  }
83 
84  if ($this->rss_link !== "") {
85  $b = $f->link()->standard(
86  $lng->txt("mcst_webfeed"),
88  )->withOpenInNewViewport(true);
90  }
91 
92  // cards and modals
93  $cards = [];
94  $modals = [];
95 
96  $pages = [];
97 
98  $lp_collection_mode = $this->domain->learningProgress($this->media_cast)->isCollectionMode();
99 
100  $mob_modals = [];
101  foreach ($this->media_cast->getSortedItemsArray() as $item) {
102  $mob = new \ilObjMediaObject($item["mob_id"]);
103  $med = $mob->getMediaItem("Standard");
104 
105  if (!in_array($med->getFormat(), ["image/png","image/jpeg","image/gif"])) {
106  continue;
107  }
108 
109  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
110  $resource = $med->getLocation();
111  } else {
112  $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
113  $resource = ilWACSignedPath::signFile($path_to_file);
114  }
115 
116  $image = $f->image()->responsive(
117  $resource,
118  $mob->getTitle()
119  );
120 
121  $pages[] = $f->modal()->lightboxImagePage($image, $mob->getTitle());
122  if ($lp_collection_mode) {
123  $mob_modals[$mob->getId()] = $f->modal()->lightbox($pages);
124  $pages = [];
125  }
126  }
127  $main_modal = null;
128  if (!$lp_collection_mode) {
129  $main_modal = $f->modal()->lightbox($pages);
130  }
131 
132  $cnt = 0;
133  foreach ($this->media_cast->getSortedItemsArray() as $item) {
134  $mob = new \ilObjMediaObject($item["mob_id"]);
135  $med = $mob->getMediaItem("Standard");
136 
137  if (!in_array($med->getFormat(), ["image/png","image/jpeg","image/gif"])) {
138  continue;
139  }
140 
141  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
142  $resource = $med->getLocation();
143  } else {
144  $path_to_file = \ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
145  $resource = ilWACSignedPath::signFile($path_to_file);
146  }
147  $preview_resource = $resource;
148  if ($mob->getVideoPreviewPic() != "") {
149  $preview_resource = ilWACSignedPath::signFile($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  $slide_to = "document.querySelector('.modal-body .carousel [data-slide-to=\"" . $cnt . "\"]').click();";
174  } else {
175  $completed_cb = $this->completed_callback . '&mob_id=' . $mob->getId();
176  $completed_cb = "$.ajax({type:'GET', url: '$completed_cb'});";
177  }
178 
179  $card_image = $card_image->withAdditionalOnLoadCode(function ($id) use ($slide_to, $completed_cb) {
180  return "$('#$id').click(function(e) { $slide_to $completed_cb });";
181  });
182  if (!$lp_collection_mode) {
183  $cnt++;
184  }
185 
186  $sections = ($mob->getDescription())
187  ? [$f->legacy($mob->getDescription())]
188  : [];
189 
190  if ($this->media_cast->getDownloadable()) {
191  $ctrl->setParameterByClass("ilobjmediacastgui", "item_id", $item["id"]);
192  $ctrl->setParameterByClass("ilobjmediacastgui", "purpose", "Standard");
193  $download = $ctrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem");
194  $sections[] = $f->button()->standard($lng->txt("download"), $download);
195  }
196 
197  //$title_button = $f->button()->shy($mob->getTitle(), $modal->getShowSignal());
198  $title = $mob->getTitle();
199 
200  $card = $f->card()->standard(
201  $title,
202  $card_image
203  )->withSections(
204  $sections
205  )->withTitleAction($modal->getShowSignal());
206 
207  $cards[] = $card;
208  $modals[] = $modal;
209  }
210 
211  $deck = $f->deck($cards);
212 
213  if (count($pages) === 0 && count($mob_modals) === 0) {
214  return "";
215  }
216  if (!$lp_collection_mode) {
217  $modals = [$main_modal];
218  } else {
219  $modals = $mob_modals;
220  }
221  return "<div id='il-mcst-img-gallery'>" . $renderer->render(array_merge([$deck], $modals)) . "</div>";
222  }
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 244 of file class.McstImageGalleryGUI.php.

References $completed_callback.

244  : void
245  {
246  $this->completed_callback = $completed_callback;
247  }

Field Documentation

◆ $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(), and getHTML().

◆ $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: