ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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

 $dic
 

Private Member Functions

 getDefaultCardContent (Bucket $observer)
 
 getProgressbar (Bucket $observer)
 
 getCloseButtonAction (UserInteraction\Option $option, $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 27 of file class.ilBTPopOverGUI.php.

References $dic.

28  {
29  $this->dic = $dic;
30  }

Member Function Documentation

◆ addFromUrlToNextRequest()

ilBTPopOverGUI::addFromUrlToNextRequest ( string  $redirect_uri)
private

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

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

Referenced by getCloseButtonAction(), and getDefaultCardContent().

251  : void
252  {
253  $this->dic->ctrl()->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::FROM_URL, ilBTControllerGUI::hash($redirect_uri));
254  }
+ 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 54 of file class.ilBTPopOverGUI.php.

References getItemForObserver().

Referenced by getNotificationItem().

54  : array
55  {
56  $persistence = $this->dic->backgroundTasks()->persistence();
57  $items = [];
58  $observer_ids = $persistence->getBucketIdsOfUser($this->dic->user()->getId(), 'id', 'DESC');
59  foreach ($persistence->loadBuckets($observer_ids) as $observer) {
60  $items[] = $this->getItemForObserver($observer);
61  }
62 
63  return $items;
64  }
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,
  $redirect_uri,
Bucket  $observer 
)
private

Definition at line 216 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().

216  : string
217  {
218  $ctrl = $this->dic->ctrl();
219  $persistence = $this->dic->backgroundTasks()->persistence();
220  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
221  $this->addFromUrlToNextRequest($redirect_uri);
222  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::IS_ASYNC, "true");
223 
224  switch ($option->getValue()) {
225  case AbstractTask::MAIN_ABORT:
226  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_ABORT);
227  break;
228  case AbstractTask::MAIN_REMOVE:
229  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_REMOVE);
230  break;
231  default:
232  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::SELECTED_OPTION, $option->getValue());
233  $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_USER_INTERACTION);
234  break;
235  }
236 
237  return $action;
238  }
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 133 of file class.ilBTPopOverGUI.php.

References $factory, 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().

133  : Legacy
134  {
135  return $this->getProgressbar($observer);
136  }
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 67 of file class.ilBTPopOverGUI.php.

References Vendor\Package\$f, $message, $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().

68  {
69  $redirect_uri = "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
70 
71  $f = $this->dic->ui()->factory();
72 
73  $state = (int) $observer->getState();
74  $current_task = $observer->getCurrentTask();
75 
76  $icon = $f->symbol()->icon()->standard("bgtk", $this->txt("bg_task"));
77  $title = $observer->getTitle() . ($state === State::SCHEDULED ? " ({$this->txt('scheduled')})" : "");
78 
79  if ($state === State::USER_INTERACTION) {
80  $actions = $this->getUserInteractionContent($observer, $redirect_uri);
81  $primary_action = array_pop($actions);
82  if ($primary_action instanceof Button) {
83  $title = $primary_action->withLabel($title);
84  }
85  $item = $f->item()->notification($title, $icon);
86 
87 // $item = $item->withProperties([
88 // $this->dic->language()->txt('nc_mail_prop_time') => \ilDatePresentation::formatDate(
89 // new \ilDateTime(time(), IL_CAL_UNIX)
90 // )
91 // ]);
92 
93  $item = $item->withActions($f->dropdown()->standard($actions));
94  $input = $current_task->getInput();
95  $message = $current_task->getMessage($input);
96 
97  if ((!empty($message)) and ($message != null)) {
98  $item = $item->withDescription($message);
99  } else {
100  $item = $item->withAdditionalContent($this->getProgressbar($observer));
101  }
102 
103  return $item->withCloseAction(
104  $this->getCloseButtonAction($current_task->getRemoveOption(), $redirect_uri, $observer)
105  );
106  }
107 
108  $item = $f->item()->notification($title, $icon);
109 
110  if ($state === State::RUNNING) {
111  $url = $this->getRefreshUrl($observer);
112  //Running Items probably need to refresh themselves, right?
113  $item = $item->withAdditionalOnLoadCode(function ($id) use ($url) {
114  //Note this is only for demo purposes, adapt as needed.
115  return "var notification_item = il.UI.item.notification.getNotificationItemObject($('#$id'));
116  il.BGTask.refreshItem(notification_item,'$url');";
117  });
118 
119  $expected = $current_task->getExpectedTimeOfTaskInSeconds();
120  $possibly_failed = ($observer->getLastHeartbeat() < (time() - $expected));
121  if ($possibly_failed === true) {
122  $item = $item->withDescription($this->txt('task_might_be_failed'));
123  $item = $item->withCloseAction(
124  $this->getCloseButtonAction($current_task->getAbortOption(), $redirect_uri, $observer)
125  );
126  }
127  }
128 
129  return $item->withAdditionalContent($this->getDefaultCardContent($observer));
130  }
getDefaultCardContent(Bucket $observer)
getLastHeartbeat()
When was the last time that something happened on this bucket?
getProgressbar(Bucket $observer)
getRefreshUrl(Bucket $observer)
getCloseButtonAction(UserInteraction\Option $option, $redirect_uri, Bucket $observer)
$message
Definition: xapiexit.php:14
$url
+ 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 36 of file class.ilBTPopOverGUI.php.

References getAggregateItems(), and txt().

37  {
38  $ui_factory = $this->dic->ui()->factory();
39 
40  $title = $ui_factory->link()->standard($this->txt('background_tasks'), '#');
41  $icon = $ui_factory->symbol()->icon()->standard('bgtk', $this->txt('background_tasks'));
42 
43  return $this->dic->ui()->factory()
44  ->item()
45  ->notification($title, $icon)
46  ->withDescription("$nr_buckets {$this->txt('background_tasks')}")
47  ->withAggregateNotifications($this->getAggregateItems());
48  }
+ Here is the call graph for this function:

◆ getProgressbar()

ilBTPopOverGUI::getProgressbar ( Bucket  $observer)
private

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

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

Referenced by getDefaultCardContent(), and getItemForObserver().

188  : Legacy
189  {
190  $percentage = $observer->getOverallPercentage();
191 
192  switch (true) {
193  case ((int) $percentage === 100):
194  $running = "";
195  $content = $this->dic->language()->txt("completed");
196  break;
197  case ((int) $observer->getState() === State::USER_INTERACTION):
198  $running = "";
199  $content = $this->dic->language()->txt("waiting");
200  break;
201  default:
202  $running = "active";
203  $content = "{$percentage}%";
204  break;
205  }
206 
207  return $this->dic->ui()->factory()->legacy(" <div class='progress'>
208  <div class='progress-bar progress-bar-striped {$running}' role='progressbar' aria-valuenow='{$percentage}'
209  aria-valuemin='0' aria-valuemax='100' style='width:{$percentage}%'>
210  {$content}
211  </div>
212  </div> ");
213  }
+ 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 241 of file class.ilBTPopOverGUI.php.

References ilBTControllerGUI\CMD_GET_REPLACEMENT_ITEM, and ilBTControllerGUI\OBSERVER_ID.

Referenced by getItemForObserver().

241  : string
242  {
243  $ctrl = $this->dic->ctrl();
244  $persistence = $this->dic->backgroundTasks()->persistence();
245  $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer));
246 
247  return $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_GET_REPLACEMENT_ITEM);
248  }
+ Here is the caller graph for this function:

◆ txt()

ilBTPopOverGUI::txt ( string  $id)
private

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

Referenced by getItemForObserver(), and getNotificationItem().

257  : string
258  {
259  return $this->dic->language()->txt($id);
260  }
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

ilBTPopOverGUI::$dic
protected

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

Referenced by __construct().


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