' . "\n";
# Safe mode
if ($safe_mode) {
echo
'
' . __('Safe mode') . '
' .
'
' . __('You are in safe mode. All plugins have been temporarily disabled. Remind to log out then log in again normally to get back all functionalities') . '
' .
'
';
}
// Display breadcrumb (if given) before any error messages
echo $breadcrumb;
// Display notices and errors
echo self::notices();
}
public static function notices()
{
$core = self::getCore();
static $error_displayed = false;
$res = '';
// return error messages if any
if ($core->error->flag() && !$error_displayed) {
# --BEHAVIOR-- adminPageNotificationError
$notice_error = $core->callBehavior('adminPageNotificationError', $core, $core->error);
if (isset($notice_error) && !empty($notice_error)) {
$res .= $notice_error;
} else {
$res .= '
' .
'' . (count($core->error->getErrors()) > 1 ? __('Errors:') : __('Error:')) . '' .
'
' . $core->error->toHTML() . '
';
}
$error_displayed = true;
}
// return notices if any
if (isset($_SESSION['notifications'])) {
foreach ($_SESSION['notifications'] as $notification) {
# --BEHAVIOR-- adminPageNotification
$notice = $core->callBehavior('adminPageNotification', $core, $notification);
$res .= (isset($notice) && !empty($notice) ? $notice : self::getNotification($notification));
}
unset($_SESSION['notifications']);
}
return $res;
}
public static function addNotice($type, $message, $options = [])
{
if (isset(self::$N_TYPES[$type])) {
$class = self::$N_TYPES[$type];
} else {
$class = $type;
}
if (isset($_SESSION['notifications']) && is_array($_SESSION['notifications'])) {
$notifications = $_SESSION['notifications'];
} else {
$notifications = [];
}
$n = array_merge($options, ['class' => $class, 'ts' => time(), 'text' => $message]);
if ($type != "static") {
$notifications[] = $n;
} else {
array_unshift($notifications, $n);
}
$_SESSION['notifications'] = $notifications;
}
public static function addSuccessNotice($message, $options = [])
{
self::addNotice("success", $message, $options);
}
public static function addWarningNotice($message, $options = [])
{
self::addNotice("warning", $message, $options);
}
public static function addErrorNotice($message, $options = [])
{
self::addNotice("error", $message, $options);
}
protected static function getNotification($n)
{
$core = self::getCore();
$tag = (isset($n['divtag']) && $n['divtag']) ? 'div' : 'p';
$ts = '';
if (!isset($n['with_ts']) || ($n['with_ts'] == true)) {
$ts = dt::str(__('[%H:%M:%S]'), $n['ts'], $core->auth->getInfo('user_tz')) . ' ';
}
$res = '<' . $tag . ' class="' . $n['class'] . '" role="alert">' . $ts . $n['text'] . '' . $tag . '>';
return $res;
}
public static function close()
{
$core = self::getCore();
if (!$GLOBALS['__resources']['ctxhelp']) {
if (!$core->auth->user_prefs->interface->hidehelpbutton) {
echo
'
' . __('Global help') . '
';
}
}
$menu = &$GLOBALS['_menu'];
echo
"
\n" . // End of #content
"