ILIAS  release_8 Revision v8.24
ilBTPopOverGUI Class Reference

Class ilBTPopOverGUI. More...

+ Collaboration diagram for ilBTPopOverGUI:

Public Member Functions

 __construct (\ILIAS\DI\Container $dic)
 
 getNotificationItem (int $nr_buckets)
 Get the Notification Items. More...
 
 getItemForObserver (Bucket $observer)
 

Protected Member Functions

 getAggregateItems ()
 

Protected Attributes

ILIAS DI Container $dic
 

Private Member Functions

 getDefaultCardContent (Bucket $observer)
 
 getProgressbar (Bucket $observer)
 
 getCloseButtonAction (UserInteraction\Option $option, string $redirect_uri, Bucket $observer)
 
 getRefreshUrl (Bucket $observer)
 
 addFromUrlToNextRequest (string $redirect_uri)
 
 txt (string $id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBTPopOverGUI::__construct ( \ILIAS\DI\Container  $dic)

Definition at line 40 of file class.ilBTPopOverGUI.php.

41 {
42 $this->dic = $dic;
43 }
ILIAS DI Container $dic

References $dic.

Member Function Documentation

◆ addFromUrlToNextRequest()

ilBTPopOverGUI::addFromUrlToNextRequest ( string  $redirect_uri)
private

Definition at line 259 of file class.ilBTPopOverGUI.php.

259 : void
260 {
261 $this->dic->ctrl()->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::FROM_URL, ilBTControllerGUI::hash($redirect_uri));
262 }
$redirect_uri
Definition: ltiauth.php:69

References $redirect_uri, ilBTControllerGUI\FROM_URL, and ilBTControllerGUI\hash().

Referenced by getCloseButtonAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAggregateItems()

ilBTPopOverGUI::getAggregateItems ( )
protected
Returns
ILIAS\UI\Component\Item\Notification[]

Definition at line 67 of file class.ilBTPopOverGUI.php.

67 : array
68 {
69 $persistence = $this->dic->backgroundTasks()->persistence();
70 $items = [];
71 $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC');
72 foreach ($persistence->loadBuckets($observer_ids) as $observer) {
73 $items[] = $this->getItemForObserver($observer);
74 }
75
76 return $items;
77 }
getItemForObserver(Bucket $observer)

References getItemForObserver().

Referenced by getNotificationItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCloseButtonAction()

ilBTPopOverGUI::getCloseButtonAction ( UserInteraction\Option  $option,
string  $redirect_uri,
Bucket  $observer 
)
private

Definition at line 224 of file class.ilBTPopOverGUI.php.

224 : string
225 {
226 $ctrl = $this->dic->ctrl();
227 $persistence = $this->dic->backgroundTasks()->persistence();
228 $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
230 $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::IS_ASYNC, "true");
231
232 switch ($option->getValue()) {
233 case AbstractTask::MAIN_ABORT:
234 $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_ABORT);
235 break;
236 case AbstractTask::MAIN_REMOVE:
237 $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_REMOVE);
238 break;
239 default:
240 $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::SELECTED_OPTION, $option->getValue());
241 $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_USER_INTERACTION);
242 break;
243 }
244
245 return $action;
246 }
addFromUrlToNextRequest(string $redirect_uri)

References addFromUrlToNextRequest(), ilBTControllerGUI\CMD_ABORT, ilBTControllerGUI\CMD_REMOVE, ilBTControllerGUI\CMD_USER_INTERACTION, ilBTControllerGUI\IS_ASYNC, ilBTControllerGUI\OBSERVER_ID, and ilBTControllerGUI\SELECTED_OPTION.

Referenced by getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultCardContent()

ilBTPopOverGUI::getDefaultCardContent ( Bucket  $observer)
private

Definition at line 143 of file class.ilBTPopOverGUI.php.

143 : Legacy
144 {
145 return $this->getProgressbar($observer);
146 }
getProgressbar(Bucket $observer)

References getProgressbar().

Referenced by getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemForObserver()

ilBTPopOverGUI::getItemForObserver ( Bucket  $observer)

Definition at line 80 of file class.ilBTPopOverGUI.php.

81 {
82 $redirect_uri = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
83
84 $f = $this->dic->ui()->factory();
85
86 $state = $observer->getState();
87 $current_task = $observer->getCurrentTask();
88
89 $icon = $f->symbol()->icon()->standard("bgtk", $this->txt("bg_task"));
90 $title = $observer->getTitle() . ($state === State::SCHEDULED ? " ({$this->txt('scheduled')})" : "");
91
92 if ($state === State::USER_INTERACTION) {
93 $actions = $this->getUserInteractionContent($observer, $redirect_uri);
94 $primary_action = array_pop($actions);
95 if ($primary_action instanceof Button) {
96 $title = $primary_action->withLabel($title);
97 }
98 $item = $f->item()->notification($title, $icon);
99
100// $item = $item->withProperties([
101// $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate(
102// new \ilDateTime(time(), IL_CAL_UNIX)
103// )
104// ]);
105
106 $item = $item->withActions($f->dropdown()->standard($actions));
107 $input = $current_task->getInput();
108 $message = $current_task->getMessage($input);
109
110 if (!empty($message) && $message != null) {
111 $item = $item->withDescription($message);
112 } else {
113 $item = $item->withAdditionalContent($this->getProgressbar($observer));
114 }
115
116 return $item->withCloseAction(
117 $this->getCloseButtonAction($current_task->getRemoveOption(), $redirect_uri, $observer)
118 );
119 }
120
121 $item = $f->item()->notification($title, $icon);
122
123 if ($state === State::RUNNING) {
124 $url = $this->getRefreshUrl($observer);
125 //Running Items probably need to refresh themselves, right?
126 $item = $item->withAdditionalOnLoadCode(fn ($id) => "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id'));
127 il.BGTask.refreshItem(notification_item,'$url');");
128
129 $expected = $current_task->getExpectedTimeOfTaskInSeconds();
130 $possibly_failed = ($observer->getLastHeartbeat() < (time() - $expected));
131 if ($possibly_failed) {
132 $item = $item->withDescription($this->txt('task_might_be_failed'));
133 $item = $item->withCloseAction(
134 $this->getCloseButtonAction($current_task->getAbortOption(), $redirect_uri, $observer)
135 );
136 }
137 }
138
139 return $item->withAdditionalContent($this->getDefaultCardContent($observer));
140 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getCloseButtonAction(UserInteraction\Option $option, string $redirect_uri, Bucket $observer)
getRefreshUrl(Bucket $observer)
getDefaultCardContent(Bucket $observer)
getLastHeartbeat()
When was the last time that something happened on this bucket?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21
$url
$message
Definition: xapiexit.php:32

References Vendor\Package\$f, $id, $message, $redirect_uri, $url, getCloseButtonAction(), ILIAS\BackgroundTasks\Bucket\getCurrentTask(), getDefaultCardContent(), ILIAS\BackgroundTasks\Bucket\getLastHeartbeat(), getProgressbar(), getRefreshUrl(), ILIAS\BackgroundTasks\Bucket\getState(), ILIAS\BackgroundTasks\Bucket\getTitle(), and txt().

Referenced by getAggregateItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNotificationItem()

ilBTPopOverGUI::getNotificationItem ( int  $nr_buckets)

Get the Notification Items.

DOES NOT DO ANY PERMISSION CHECKS.

Definition at line 49 of file class.ilBTPopOverGUI.php.

50 {
51 $ui_factory = $this->dic->ui()->factory();
52
53 $title = $ui_factory->link()->standard($this->txt('background_tasks'), '#');
54 $icon = $ui_factory->symbol()->icon()->standard('bgtk', $this->txt('background_tasks'));
55
56 return $this->dic->ui()->factory()
57 ->item()
58 ->notification($title, $icon)
59 ->withDescription("$nr_buckets {$this->txt('background_tasks')}")
60 ->withAggregateNotifications($this->getAggregateItems());
61 }
withDescription(string $description)
Create a new item with an attached description.

References getAggregateItems(), and txt().

+ Here is the call graph for this function:

◆ getProgressbar()

ilBTPopOverGUI::getProgressbar ( Bucket  $observer)
private

Definition at line 196 of file class.ilBTPopOverGUI.php.

196 : Legacy
197 {
198 $percentage = $observer->getOverallPercentage();
199
200 switch (true) {
201 case ($percentage === 100):
202 $running = "";
203 $content = $this->dic->language()->txt("completed");
204 break;
205 case ($observer->getState() === State::USER_INTERACTION):
206 $running = "";
207 $content = $this->dic->language()->txt("waiting");
208 break;
209 default:
210 $running = "active";
211 $content = "{$percentage}%";
212 break;
213 }
214
215 return $this->dic->ui()->factory()->legacy(" <div class='progress'>
216 <div class='progress-bar progress-bar-striped {$running}' role='progressbar' aria-valuenow='{$percentage}'
217 aria-valuemin='0' aria-valuemax='100' style='width:{$percentage}%'>
218 {$content}
219 </div>
220 </div> ");
221 }

References ILIAS\BackgroundTasks\Bucket\getOverallPercentage(), and ILIAS\BackgroundTasks\Bucket\getState().

Referenced by getDefaultCardContent(), and getItemForObserver().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefreshUrl()

ilBTPopOverGUI::getRefreshUrl ( Bucket  $observer)
private

Definition at line 249 of file class.ilBTPopOverGUI.php.

249 : string
250 {
251 $ctrl = $this->dic->ctrl();
252 $persistence = $this->dic->backgroundTasks()->persistence();
253 $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
254
255 return $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_GET_REPLACEMENT_ITEM);
256 }

References ilBTControllerGUI\CMD_GET_REPLACEMENT_ITEM, and ilBTControllerGUI\OBSERVER_ID.

Referenced by getItemForObserver().

+ Here is the caller graph for this function:

◆ txt()

ilBTPopOverGUI::txt ( string  $id)
private

Definition at line 265 of file class.ilBTPopOverGUI.php.

265 : string
266 {
267 return $this->dic->language()->txt($id);
268 }

References $id.

Referenced by getItemForObserver(), and getNotificationItem().

+ Here is the caller graph for this function:

Field Documentation

◆ $dic

ILIAS DI Container ilBTPopOverGUI::$dic
protected

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

Referenced by __construct().


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