You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.5 KiB
PHP

<?php
$_ERRORS = [];
/**
* Adds an error to the $_ERROR array to be displayed at the end
* of a PHP script as HTML dialogs
*
* @param string $message Error message
*/
function showError ($message) {
if ($message == "") return;
$message = str_replace("\n", "<br>", $message);
$message = str_replace(" ", "&nbsp;", $message);
global $_ERRORS;
$_ERRORS[] = $message;
}
/**
* Write text into stderr
*
* @param string $text Text to log
*/
function debug ($text) {
error_log("\n> $text" . PHP_EOL);
}
/**
* Echoes HTML code to display all collected error messages
*/
function insertErrorsHtml() {
global $_ERRORS;
if (count ($_ERRORS) == 0) return;
// Dialog frame HTML
$base_html = '
<div class="dialog-parent">
<div class="dialog">
<div class="dialog-content">
<b>Fehler beim Laden der Seite:</b><br>
<br>
%s
</div>
<div class="dialog-buttons">
<button onclick="closeDialog(this)">OK</button>
</div>
</div>
</div>
';
$errors_html = "";
foreach ($_ERRORS as $error) {
$errors_html .= "{$error}<br>";
}
printf ($base_html, $errors_html);
}
/**
* Hides the dialog box asking for an ICS URL if one
* was already specified by the user
*/
function hideMissingIcsDialog () {
global $_GET;
if (isset ($_GET["ics_url"]) && $_GET["ics_url"] != "") {
echo "hidden";
}
}