Elgg  Version 3.0
cron.php
Go to the documentation of this file.
1 <?php
6 $periods = elgg_get_config('elgg_cron_periods');
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  if ($msg) {
32  $msg = nl2br($msg);
33  }
34 
35  if (!empty($msg) && elgg_in_context('widgets')) {
36  $wrapped_message = elgg_format_element('div', [
37  'id' => "cron_{$period}",
38  'class' => 'hidden',
39  ], $msg);
40 
41  $msg = elgg_view('output/url', [
42  'href' => "#cron_{$period}",
43  'text' => elgg_echo('show'),
44  'rel' => 'toggle',
45  ]) . $wrapped_message;
46  }
47  $row[] = elgg_format_element('td', [], $msg);
48 
49  $table_content .= elgg_format_element('tr', [], implode(PHP_EOL, $row));
50 }
51 
52 $period_hd = elgg_echo('admin:cron:period');
53 $friendly_hd = elgg_echo('admin:cron:friendly');
54 $date_hd = elgg_echo('admin:cron:date');
55 $msg_hd = elgg_echo('admin:cron:msg');
56 
57 $table = <<<HTML
58 <table class="elgg-table">
59  <thead>
60  <tr>
61  <th>$period_hd</th>
62  <th>$friendly_hd</th>
63  <th>$date_hd</th>
64  <th>$msg_hd</th>
65  </tr>
66  </thead>
67  <tbody>
69  </tbody>
70 </table>
71 HTML;
72 
73 echo elgg_view_module('info', elgg_echo('admin:cron:record'), $table);
foreach($periods as $period) $period_hd
Definition: cron.php:52
$msg_hd
Definition: cron.php:55
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:206
$friendly_hd
Definition: cron.php:53
$date_hd
Definition: cron.php:54
$table_content
Definition: cron.php:9
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:238
elgg echo
Translates a string.
Definition: languages.js:43
$periods
Cron statistics.
Definition: cron.php:6
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
$table
Definition: cron.php:57
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
elgg_view_friendly_time($time)
Displays a UNIX timestamp in a friendly way.
Definition: views.php:1120
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
$cron_service
Definition: cron.php:7