first commit
This commit is contained in:
73
php/html-components.php
Normal file
73
php/html-components.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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 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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user