Elgg
Version 6.1
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
views
default
admin
cron.php
Go to the documentation of this file.
1
<?php
6
use
Elgg\Values
;
7
8
$cron_service
=
_elgg_services
()->cron;
9
$periods
=
$cron_service
->getConfiguredIntervals(
true
);
10
11
$in_widget
=
elgg_in_context
(
'widgets'
);
12
13
$table_content
=
''
;
14
foreach
(
$periods
as $period) {
15
$row = [];
16
17
// name
18
$row[] =
elgg_format_element
(
'td'
, [],
elgg_echo
(
"interval:{$period}"
));
19
20
// last completed (friendly) and full date
21
$date =
$cron_service
->getLastCompletion($period);
22
if
(!
elgg_is_empty
($date)) {
23
$row[] =
elgg_format_element
(
'td'
, [],
elgg_view_friendly_time
($date));
24
$row[] =
elgg_format_element
(
'td'
, [],
elgg_view
(
'output/date'
, [
25
'value'
=> $date,
26
'format'
=> DATE_RFC2822,
27
]));
28
}
else
{
29
$row[] =
elgg_format_element
(
'td'
, [],
elgg_echo
(
'never'
));
30
$row[] =
elgg_format_element
(
'td'
, [],
' '
);
31
}
32
33
// cron output
34
$logs =
$cron_service
->getLogs($period);
35
$msg_class = [];
36
$log_output =
' '
;
37
if
(!empty($logs)) {
38
$log_output =
''
;
39
40
foreach
($logs as
$filename
=>
$contents
) {
41
$matches = [];
42
preg_match
(
'/(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})T(?<hour>[0-9]{2})-(?<minute>[0-9]{2})-(?<second>[0-9]{2})(?<offset>[-p])(?<offset_hour>[0-9]{2})-(?<offset_minute>[0-9]{2})\S+/'
,
$filename
, $matches);
43
if
($matches[
'offset'
] ===
'p'
) {
44
$matches[
'offset'
] =
'+'
;
45
}
46
47
$date_string =
"{$matches['year']}-{$matches['month']}-{$matches['day']}T{$matches['hour']}:{$matches['minute']}:{$matches['second']}{$matches['offset']}{$matches['offset_hour']}:{$matches['offset_minute']}"
;
48
$date = Values::normalizeTime($date_string);
49
50
$contents
= nl2br(
$contents
);
51
$contents
=
elgg_format_element
(
'div'
, [],
$contents
);
52
53
$log_output .=
elgg_view
(
'output/url'
, [
54
'icon'
=>
'info'
,
55
'text'
=> !
$in_widget
? $date->format(DATE_RFC2822) :
false
,
56
'title'
=>
elgg_echo
(
'more_info'
),
57
'href'
=>
"#{$period}-{$date->getTimestamp()}"
,
58
'class'
=> [
'elgg-lightbox'
],
59
'data-colorbox-opts'
=> json_encode([
'html'
=>
$contents
]),
60
]);
61
62
if
(
$in_widget
) {
63
$msg_class[] =
'center'
;
64
break
;
65
}
66
67
$log_output .=
'<br />'
;
68
}
69
}
70
71
$row[] =
elgg_format_element
(
'td'
, [
'class'
=> $msg_class], $log_output);
72
73
$table_content
.=
elgg_format_element
(
'tr'
, [],
implode
(PHP_EOL, $row));
74
}
75
76
$header
=
elgg_format_element
(
'th'
, [],
elgg_echo
(
'admin:cron:period'
));
77
$header
.=
elgg_format_element
(
'th'
, [],
elgg_echo
(
'admin:cron:friendly'
));
78
$header
.=
elgg_format_element
(
'th'
, [],
elgg_echo
(
'admin:cron:date'
));
79
$header
.=
elgg_format_element
(
'th'
, [],
elgg_echo
(
'admin:cron:msg'
));
80
$header
=
elgg_format_element
(
'tr'
, [],
$header
);
81
$header
=
elgg_format_element
(
'thead'
, [],
$header
);
82
83
$table_content
=
elgg_format_element
(
'tbody'
, [],
$table_content
);
84
85
echo
elgg_format_element
(
'table'
, [
'class'
=>
'elgg-table'
],
$header
.
$table_content
);
implode
Values
Saves user notification settings.
$periods
$periods
Definition:
cron.php:9
elgg_in_context
elgg_in_context(string $context)
Check if this context exists anywhere in the stack.
Definition:
context.php:78
elgg_echo
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition:
languages.php:17
$table_content
$table_content
Definition:
cron.php:13
$cron_service
$cron_service
Definition:
cron.php:8
elgg_is_empty
elgg_is_empty($value)
Check if a value isn't empty, but allow 0 and '0'.
Definition:
input.php:176
elgg_view
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition:
views.php:156
elgg_view_friendly_time
elgg_view_friendly_time($time, $time_updated=null)
Displays a UNIX timestamp in a friendly way.
Definition:
views.php:832
$in_widget
$in_widget
Definition:
cron.php:11
$header
foreach($periods as $period) $header
Definition:
cron.php:76
$filename
$filename
Definition:
plugin_text_file.php:10
_elgg_services
_elgg_services()
Get the global service provider.
Definition:
elgglib.php:353
elgg_format_element
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition:
output.php:145
preg_match
$contents
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents
Definition:
message.php:73
Generated on Wed Dec 4 2024 00:00:22 for Elgg by
1.8.11