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.
89 lines
2.3 KiB
PHP
89 lines
2.3 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(" ", " ", $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 echoErrorsHtml() {
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* Shows a dialog box asking for an ICS URL if one
|
|
* was not specified by the user
|
|
*/
|
|
function echoIcsUrlDialog () {
|
|
global $_GET;
|
|
|
|
if (!isset ($_GET["ics_url"]) || $_GET["ics_url"] == "") {
|
|
echo '
|
|
<!-- Dialog to ask user for ICS URL if not specified through GET -->
|
|
<div class="dialog-parent <?php hideMissingIcsDialog(); ?>">
|
|
<div class="dialog">
|
|
<div class="dialog-content">
|
|
Es wurde keine ICS URL als GET Parameter übergeben.<br>
|
|
<br>
|
|
<label>Anzuzeigende ICS URL:</label>
|
|
<input type="text" form="dialog-form" name="ics_url" />
|
|
</div>
|
|
<div class="dialog-buttons">
|
|
<form id="dialog-form" method="get"></form>
|
|
<input type="submit" form="dialog-form" value="OK" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
';
|
|
}
|
|
} |