ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBTPopOverGUI Class Reference

Class ilBTPopOverGUI. More...

+ Collaboration diagram for ilBTPopOverGUI:

Public Member Functions

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

Protected Member Functions

 getAggregateItems ()
 

Private Member Functions

 getDefaultCardContent (Bucket $observer)
 
 getProgressbar (Bucket $observer)
 
 getCloseButtonAction (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 ( protected Container  $dic)

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

44 {
45 }

Member Function Documentation

◆ addFromUrlToNextRequest()

ilBTPopOverGUI::addFromUrlToNextRequest ( string  $redirect_uri)
private

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

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

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
Notification[]

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

69 : array
70 {
71 $persistence = $this->dic->backgroundTasks()->persistence();
72 $items = [];
73 $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC');
74 foreach ($persistence->loadBuckets($observer_ids) as $observer) {
75 $items[] = $this->getItemForObserver($observer);
76 }
77
78 return $items;
79 }
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 ( Option  $option,
string  $redirect_uri,
Bucket  $observer 
)
private

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

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

References addFromUrlToNextRequest(), ilBTControllerGUI\CMD_ABORT, ilBTControllerGUI\CMD_REMOVE, ilBTControllerGUI\CMD_USER_INTERACTION, ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue(), 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 145 of file class.ilBTPopOverGUI.php.

145 : Content
146 {
147 return $this->getProgressbar($observer);
148 }
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 82 of file class.ilBTPopOverGUI.php.

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

References Vendor\Package\$f, $id, $message, $redirect_uri, $url, getCloseButtonAction(), ILIAS\BackgroundTasks\Bucket\getCurrentTask(), getDefaultCardContent(), ILIAS\BackgroundTasks\Task\Job\getExpectedTimeOfTaskInSeconds(), 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 51 of file class.ilBTPopOverGUI.php.

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

References getAggregateItems(), txt(), and ILIAS\UI\Component\Item\Item\withDescription().

+ Here is the call graph for this function:

◆ getProgressbar()

ilBTPopOverGUI::getProgressbar ( Bucket  $observer)
private

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

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

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 251 of file class.ilBTPopOverGUI.php.

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

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 267 of file class.ilBTPopOverGUI.php.

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

References $id.

Referenced by getItemForObserver(), and getNotificationItem().

+ Here is the caller graph for this function:

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