ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 41 of file class.ilBTPopOverGUI.php.

References $dic.

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

Member Function Documentation

◆ addFromUrlToNextRequest()

ilBTPopOverGUI::addFromUrlToNextRequest ( string  $redirect_uri)
private

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

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

Referenced by getCloseButtonAction(), and getDefaultCardContent().

260  : void
261  {
262  $this->dic->ctrl()->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::FROM_URL, ilBTControllerGUI::hash($redirect_uri));
263  }
$redirect_uri
Definition: ltiauth.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAggregateItems()

ilBTPopOverGUI::getAggregateItems ( )
protected
Returns
ILIAS[]

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

References getItemForObserver().

Referenced by getNotificationItem().

68  : array
69  {
70  $persistence = $this->dic->backgroundTasks()->persistence();
71  $items = [];
72  $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC');
73  foreach ($persistence->loadBuckets($observer_ids) as $observer) {
74  $items[] = $this->getItemForObserver($observer);
75  }
76 
77  return $items;
78  }
getItemForObserver(Bucket $observer)
+ 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 225 of file class.ilBTPopOverGUI.php.

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().

225  : string
226  {
227  $ctrl = $this->dic->ctrl();
228  $persistence = $this->dic->backgroundTasks()->persistence();
229  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
231  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::IS_ASYNC, "true");
232 
233  switch ($option->getValue()) {
234  case AbstractTask::MAIN_ABORT:
235  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_ABORT);
236  break;
237  case AbstractTask::MAIN_REMOVE:
238  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_REMOVE);
239  break;
240  default:
241  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::SELECTED_OPTION, $option->getValue());
242  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_USER_INTERACTION);
243  break;
244  }
245 
246  return $action;
247  }
$redirect_uri
Definition: ltiauth.php:69
addFromUrlToNextRequest(string $redirect_uri)
+ 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 144 of file class.ilBTPopOverGUI.php.

References $redirect_uri, addFromUrlToNextRequest(), ilBTControllerGUI\CMD_USER_INTERACTION, ilBTControllerGUI\FROM_URL, ILIAS\BackgroundTasks\Bucket\getCurrentTask(), getProgressbar(), ilBTControllerGUI\hash(), ilBTControllerGUI\OBSERVER_ID, and ilBTControllerGUI\SELECTED_OPTION.

Referenced by getItemForObserver().

144  : Legacy
145  {
146  return $this->getProgressbar($observer);
147  }
getProgressbar(Bucket $observer)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemForObserver()

ilBTPopOverGUI::getItemForObserver ( Bucket  $observer)

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

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().

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

References getAggregateItems(), and txt().

51  {
52  $ui_factory = $this->dic->ui()->factory();
53 
54  $title = $ui_factory->link()->standard($this->txt('background_tasks'), '#');
55  $icon = $ui_factory->symbol()->icon()->standard('bgtk', $this->txt('background_tasks'));
56 
57  return $this->dic->ui()->factory()
58  ->item()
59  ->notification($title, $icon)
60  ->withDescription("$nr_buckets {$this->txt('background_tasks')}")
61  ->withAggregateNotifications($this->getAggregateItems());
62  }
+ Here is the call graph for this function:

◆ getProgressbar()

ilBTPopOverGUI::getProgressbar ( Bucket  $observer)
private

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

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

Referenced by getDefaultCardContent(), and getItemForObserver().

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

References ilBTControllerGUI\CMD_GET_REPLACEMENT_ITEM, and ilBTControllerGUI\OBSERVER_ID.

Referenced by getItemForObserver().

250  : string
251  {
252  $ctrl = $this->dic->ctrl();
253  $persistence = $this->dic->backgroundTasks()->persistence();
254  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
255 
256  return $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_GET_REPLACEMENT_ITEM);
257  }
+ Here is the caller graph for this function:

◆ txt()

ilBTPopOverGUI::txt ( string  $id)
private

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

Referenced by getItemForObserver(), and getNotificationItem().

266  : string
267  {
268  return $this->dic->language()->txt($id);
269  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

ILIAS DI Container ilBTPopOverGUI::$dic
protected

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

Referenced by __construct().


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