Elgg  Version 5.0
cron.php
Go to the documentation of this file.
1 <?php
7 $periods = $cron_service->getConfiguredIntervals(true);
8 
10 foreach ($periods as $period) {
11  $row = [];
12 
13  // name
14  $row[] = elgg_format_element('td', [], elgg_echo("interval:$period"));
15 
16  // last completed (friendly) and full date
17  $ts = $cron_service->getLog('completion', $period);
18  if (!elgg_is_empty($ts)) {
19  $row[] = elgg_format_element('td', [], elgg_view_friendly_time((int) $ts));
20  $row[] = elgg_format_element('td', [], elgg_view('output/date', [
21  'value' => $ts,
22  'format' => DATE_RFC2822,
23  ]));
24  } else {
25  $row[] = elgg_format_element('td', [], elgg_echo('never'));
26  $row[] = elgg_format_element('td', [], '&nbsp;');
27  }
28 
29  // cron output
30  $msg = $cron_service->getLog('output', $period);
31  $msg_class = [];
32  if (!empty($msg)) {
33  $msg = nl2br($msg);
34 
35  if (elgg_in_context('widgets')) {
36  $msg = elgg_format_element('div', [], $msg);
37  $msg = elgg_view('output/url', [
38  'href' => false,
39  'text' => false,
40  'title' => elgg_echo('more_info'),
41  'icon' => 'info',
42  'class' => ['elgg-lightbox'],
43  'data-colorbox-opts' => json_encode(['html' => $msg]),
44  ]);
45 
46  $msg_class[] = 'center';
47  }
48  }
49 
50  $row[] = elgg_format_element('td', ['class' => $msg_class], $msg);
51 
52  $table_content .= elgg_format_element('tr', [], implode(PHP_EOL, $row));
53 }
54 
55 $header = elgg_format_element('th', [], elgg_echo('admin:cron:period'));
56 $header .= elgg_format_element('th', [], elgg_echo('admin:cron:friendly'));
57 $header .= elgg_format_element('th', [], elgg_echo('admin:cron:date'));
58 $header .= elgg_format_element('th', [], elgg_echo('admin:cron:msg'));
60 $header = elgg_format_element('thead', [], $header);
61 
63 
64 $table = elgg_format_element('table', ['class' => 'elgg-table'], $header . $table_content);
65 
66 echo elgg_view_module('info', elgg_echo('admin:cron:record'), $table);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:940
$periods
Definition: cron.php:7
elgg_in_context(string $context)
Check if this context exists anywhere in the stack.
Definition: context.php:78
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$table_content
Definition: cron.php:9
$cron_service
Cron statistics.
Definition: cron.php:6
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
elgg_view_friendly_time($time, $time_updated=null)
Displays a UNIX timestamp in a friendly way.
Definition: views.php:853
$ts
CSRF security token view for use with secure forms.
foreach($periods as $period) $header
Definition: cron.php:55
_elgg_services()
Get the global service provider.
Definition: elgglib.php:346
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$table
Definition: cron.php:64