2011-06-02 00:48:29 +02:00
|
|
|
<?php
|
|
|
|
|
2011-12-26 18:28:57 +01:00
|
|
|
/**
|
|
|
|
* Liste der verfügbaren Themes
|
|
|
|
*/
|
2016-09-30 17:08:20 +02:00
|
|
|
$themes = [
|
2015-12-16 15:32:54 +01:00
|
|
|
'3' => "Engelsystem 32c3",
|
|
|
|
"2" => "Engelsystem cccamp15",
|
2014-08-22 22:34:13 +02:00
|
|
|
"0" => "Engelsystem light",
|
2016-08-22 19:32:54 +02:00
|
|
|
"1" => "Engelsystem dark"
|
2016-09-30 17:08:20 +02:00
|
|
|
];
|
2011-12-26 18:28:57 +01:00
|
|
|
|
2014-12-22 20:06:37 +01:00
|
|
|
/**
|
|
|
|
* Display muted (grey) text.
|
|
|
|
*
|
|
|
|
* @param string $text
|
|
|
|
*/
|
|
|
|
function mute($text) {
|
|
|
|
return '<span class="text-muted">' . $text . '</span>';
|
|
|
|
}
|
|
|
|
|
2014-12-19 22:41:55 +01:00
|
|
|
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') {
|
|
|
|
return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . (($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
|
|
|
|
}
|
|
|
|
|
2014-09-28 14:50:08 +02:00
|
|
|
/**
|
|
|
|
* Render glyphicon
|
|
|
|
*
|
2014-12-16 09:55:14 +01:00
|
|
|
* @param string $glyph_name
|
2014-09-28 14:50:08 +02:00
|
|
|
*/
|
|
|
|
function glyph($glyph_name) {
|
|
|
|
return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a tick or a cross by given boolean
|
|
|
|
*
|
2014-12-16 09:55:14 +01:00
|
|
|
* @param boolean $boolean
|
2014-09-28 14:50:08 +02:00
|
|
|
*/
|
|
|
|
function glyph_bool($boolean) {
|
|
|
|
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
|
|
|
|
}
|
|
|
|
|
2016-10-01 10:48:19 +02:00
|
|
|
function div($class, $content = [], $dom_id = "") {
|
2016-09-29 12:45:06 +02:00
|
|
|
$dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
|
|
|
|
return '<div' . $dom_id . ' class="' . $class . '">' . join("\n", $content) . '</div>';
|
2014-08-23 01:55:18 +02:00
|
|
|
}
|
|
|
|
|
2014-12-16 03:38:30 +01:00
|
|
|
function heading($content, $number = 1) {
|
|
|
|
return "<h" . $number . ">" . $content . "</h" . $number . ">";
|
|
|
|
}
|
|
|
|
|
2013-10-13 00:52:44 +02:00
|
|
|
/**
|
|
|
|
* Render a toolbar.
|
|
|
|
*
|
2014-12-16 09:55:14 +01:00
|
|
|
* @param array $items
|
2013-10-13 00:52:44 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
2016-09-30 17:08:20 +02:00
|
|
|
function toolbar($items = [], $right = false) {
|
2014-09-08 14:45:41 +02:00
|
|
|
return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
|
2013-10-13 00:52:44 +02:00
|
|
|
}
|
|
|
|
|
2016-10-05 18:56:50 +02:00
|
|
|
function toolbar_pills($items) {
|
|
|
|
return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
|
|
|
|
}
|
|
|
|
|
2013-10-13 00:52:44 +02:00
|
|
|
/**
|
|
|
|
* Render a link for a toolbar.
|
2014-03-26 20:04:11 +01:00
|
|
|
*
|
2014-12-16 09:55:14 +01:00
|
|
|
* @param string $href
|
|
|
|
* @param string $glyphicon
|
|
|
|
* @param string $label
|
|
|
|
* @param bool $selected
|
2013-10-13 00:52:44 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
2014-08-22 22:34:13 +02:00
|
|
|
function toolbar_item_link($href, $glyphicon, $label, $selected = false) {
|
|
|
|
return '<li class="' . ($selected ? 'active' : '') . '"><a href="' . $href . '">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . '</a></li>';
|
|
|
|
}
|
|
|
|
|
2014-09-24 15:11:50 +02:00
|
|
|
function toolbar_item_divider() {
|
|
|
|
return '<li class="divider"></li>';
|
|
|
|
}
|
|
|
|
|
2014-12-06 22:26:56 +01:00
|
|
|
function toolbar_dropdown($glyphicon, $label, $submenu, $class = '') {
|
|
|
|
return '<li class="dropdown ' . $class . '">
|
2014-08-23 02:16:12 +02:00
|
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
|
|
|
<ul class="dropdown-menu" role="menu">' . join("\n", $submenu) . '</ul></li>';
|
|
|
|
}
|
|
|
|
|
2014-12-06 22:26:56 +01:00
|
|
|
function toolbar_popover($glyphicon, $label, $content, $class = '') {
|
2016-09-29 12:45:06 +02:00
|
|
|
$dom_id = md5(microtime() . $glyphicon . $label);
|
2014-12-07 00:09:38 +01:00
|
|
|
return '<li class="dropdown messages ' . $class . '">
|
2016-09-29 12:45:06 +02:00
|
|
|
<a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
|
2014-12-06 22:26:56 +01:00
|
|
|
<script type="text/javascript">
|
2015-07-12 20:06:34 +02:00
|
|
|
$(function(){
|
2016-09-29 12:45:06 +02:00
|
|
|
$("#' . $dom_id . '").popover({
|
2015-07-12 20:06:34 +02:00
|
|
|
trigger: "focus",
|
|
|
|
html: true,
|
|
|
|
content: "' . addslashes(join('', $content)) . '",
|
|
|
|
placement: "bottom",
|
|
|
|
container: "#navbar-collapse-1"
|
|
|
|
})
|
|
|
|
});
|
2014-12-06 22:26:56 +01:00
|
|
|
</script></li>';
|
|
|
|
}
|
|
|
|
|
2014-08-23 19:15:10 +02:00
|
|
|
function form_hidden($name, $value) {
|
|
|
|
return '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
|
|
|
|
}
|
|
|
|
|
2014-08-22 22:34:13 +02:00
|
|
|
/**
|
|
|
|
* Rendert ein Zahlenfeld mit Buttons zum verstellen
|
|
|
|
*/
|
|
|
|
function form_spinner($name, $label, $value) {
|
|
|
|
return form_element($label, '
|
|
|
|
<div class="input-group">
|
|
|
|
<input id="spinner-' . $name . '" class="form-control" type="text" name="' . $name . '" value="' . $value . '" />
|
|
|
|
<div class="input-group-btn">
|
|
|
|
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
|
|
|
|
<span class="glyphicon glyphicon-minus"></span>
|
|
|
|
</button>
|
|
|
|
<button id="spinner-' . $name . '-up" class="btn btn-default" type="button">
|
|
|
|
<span class="glyphicon glyphicon-plus"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$("#spinner-' . $name . '-down").click(function(e) {
|
|
|
|
$("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) - 1);
|
|
|
|
});
|
|
|
|
$("#spinner-' . $name . '-up").click(function(e) {
|
|
|
|
$("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) + 1);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
');
|
2013-10-13 00:52:44 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 13:45:47 +02:00
|
|
|
/**
|
|
|
|
* Render a bootstrap datepicker
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* Name of the parameter
|
|
|
|
* @param string $label
|
|
|
|
* Label
|
|
|
|
* @param int $value
|
|
|
|
* Unix Timestamp
|
2015-07-12 14:45:58 +02:00
|
|
|
* @param int $min_date
|
|
|
|
* Earliest possible date
|
2015-07-12 13:45:47 +02:00
|
|
|
* @return HTML
|
|
|
|
*/
|
2015-07-12 14:45:58 +02:00
|
|
|
function form_date($name, $label, $value, $start_date = '') {
|
2016-09-29 12:45:06 +02:00
|
|
|
$dom_id = $name . '-date';
|
2015-07-12 13:45:47 +02:00
|
|
|
$value = is_numeric($value) ? date('Y-m-d', $value) : '';
|
2015-07-12 14:45:58 +02:00
|
|
|
$start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
|
2015-07-12 13:45:47 +02:00
|
|
|
return form_element($label, '
|
2016-09-29 12:45:06 +02:00
|
|
|
<div class="input-group date" id="' . $dom_id . '">
|
2015-07-12 14:45:58 +02:00
|
|
|
<input type="text" name="' . $name . '" class="form-control" value="' . $value . '"><span class="input-group-addon">' . glyph('th') . '</span>
|
2015-07-12 13:45:47 +02:00
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function(){
|
2016-09-29 12:45:06 +02:00
|
|
|
$("#' . $dom_id . '").datepicker({
|
2015-07-12 13:45:47 +02:00
|
|
|
language: "' . locale_short() . '",
|
2015-07-12 14:45:58 +02:00
|
|
|
todayBtn: "linked",
|
|
|
|
format: "yyyy-mm-dd",
|
|
|
|
startDate: "' . $start_date . '"
|
2015-07-12 13:45:47 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2016-09-29 12:45:06 +02:00
|
|
|
', $dom_id);
|
2015-07-12 13:45:47 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Liste von Checkboxen für ein Formular
|
2013-10-13 00:52:44 +02:00
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* name Die Namen der Checkboxen werden aus name_key gebildet
|
|
|
|
* @param
|
|
|
|
* label Die Beschriftung der Liste
|
|
|
|
* @param
|
|
|
|
* items Array mit den einzelnen Checkboxen
|
|
|
|
* @param
|
|
|
|
* selected Array mit den Keys, die ausgewählt sind
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
|
|
|
function form_checkboxes($name, $label, $items, $selected) {
|
2014-08-22 22:34:13 +02:00
|
|
|
$html = form_element($label, '');
|
2013-09-18 01:38:36 +02:00
|
|
|
foreach ($items as $key => $item) {
|
2016-09-29 11:28:42 +02:00
|
|
|
$html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
2016-09-29 11:28:42 +02:00
|
|
|
return $html;
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2012-12-26 16:58:09 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Tabelle von Checkboxen für ein Formular
|
2013-10-13 00:52:44 +02:00
|
|
|
*
|
|
|
|
* @param
|
|
|
|
* names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values
|
|
|
|
* @param
|
|
|
|
* label Die Beschriftung der gesamten Tabelle
|
|
|
|
* @param
|
|
|
|
* items Array mit den Beschriftungen der Zeilen
|
|
|
|
* @param
|
|
|
|
* selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten Checkboxen ist
|
|
|
|
* @param
|
|
|
|
* disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
|
2012-12-26 16:58:09 +01:00
|
|
|
*/
|
2016-09-30 17:08:20 +02:00
|
|
|
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = "<table><thead><tr>";
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($names as $title) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= "<th>$title</th>";
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= "</tr></thead><tbody>";
|
|
|
|
foreach ($items as $key => $item) {
|
|
|
|
$html .= "<tr>";
|
|
|
|
foreach ($names as $name => $title) {
|
2016-09-29 12:45:06 +02:00
|
|
|
$dom_id = $name . '_' . $key;
|
2013-09-18 01:38:36 +02:00
|
|
|
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
|
2016-09-29 11:28:42 +02:00
|
|
|
if (! empty($disabled) && ! empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$sel .= ' disabled="disabled"';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2016-09-29 12:45:06 +02:00
|
|
|
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
2016-09-29 12:45:06 +02:00
|
|
|
$html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>';
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
$html .= "</tbody></table>";
|
|
|
|
return form_element($label, $html);
|
2012-12-26 16:58:09 +01:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Checkbox
|
|
|
|
*/
|
|
|
|
function form_checkbox($name, $label, $selected, $value = 'checked') {
|
2014-08-22 22:34:13 +02:00
|
|
|
return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert einen Radio
|
|
|
|
*/
|
|
|
|
function form_radio($name, $label, $selected, $value) {
|
|
|
|
return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert einen Infotext in das Formular
|
|
|
|
*/
|
2014-08-23 14:30:45 +02:00
|
|
|
function form_info($label, $text = "") {
|
2016-09-29 11:28:42 +02:00
|
|
|
if ($label == "") {
|
2014-12-22 20:06:37 +01:00
|
|
|
return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
|
|
|
if ($text == "") {
|
2014-08-22 22:34:13 +02:00
|
|
|
return '<h4>' . $label . '</h4>';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2014-08-22 22:34:13 +02:00
|
|
|
return form_element($label, '<p class="form-control-static">' . $text . '</p>', '');
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert den Absenden-Button eines Formulars
|
|
|
|
*/
|
|
|
|
function form_submit($name, $label) {
|
2014-08-22 22:34:13 +02:00
|
|
|
return form_element('<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />', "");
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Textfeld
|
|
|
|
*/
|
|
|
|
function form_text($name, $label, $value, $disabled = false) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
2014-08-22 22:34:13 +02:00
|
|
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
2015-08-16 20:41:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Emailfeld
|
|
|
|
*/
|
2015-08-16 21:05:27 +02:00
|
|
|
function form_email($name, $label, $value, $disabled = false) {
|
2015-08-16 20:41:23 +02:00
|
|
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
|
|
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2014-03-26 20:04:11 +01:00
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Dateifeld
|
|
|
|
*/
|
|
|
|
function form_file($name, $label) {
|
|
|
|
return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
|
|
|
|
}
|
|
|
|
|
2011-12-26 15:55:17 +01:00
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Passwortfeld
|
|
|
|
*/
|
|
|
|
function form_password($name, $label, $disabled = false) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
2014-08-22 22:34:13 +02:00
|
|
|
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
|
2011-12-26 15:55:17 +01:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Textfeld
|
|
|
|
*/
|
|
|
|
function form_textarea($name, $label, $value, $disabled = false) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$disabled = $disabled ? ' disabled="disabled"' : '';
|
2014-08-22 22:34:13 +02:00
|
|
|
return form_element($label, '<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert ein Formular-Auswahlfeld
|
|
|
|
*/
|
|
|
|
function form_select($name, $label, $values, $selected) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2012-12-07 18:00:19 +01:00
|
|
|
/**
|
2011-12-21 22:20:06 +01:00
|
|
|
* Rendert ein Formular-Element
|
|
|
|
*/
|
|
|
|
function form_element($label, $input, $for = "") {
|
2014-12-06 20:01:47 +01:00
|
|
|
if ($label == '') {
|
|
|
|
return '<div class="form-group">' . $input . '</div>';
|
|
|
|
}
|
2016-09-29 11:28:42 +02:00
|
|
|
|
|
|
|
return '<div class="form-group">' . '<label for="' . $for . '">' . $label . '</label>' . $input . '</div>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert ein Formular
|
|
|
|
*/
|
|
|
|
function form($elements, $action = "") {
|
2014-08-22 22:34:13 +02:00
|
|
|
return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-10-13 00:52:44 +02:00
|
|
|
* Generiert HTML Code für eine "Seite".
|
|
|
|
* Fügt dazu die übergebenen Elemente zusammen.
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
|
|
|
function page($elements) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return join($elements);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2014-08-22 22:34:13 +02:00
|
|
|
/**
|
|
|
|
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
|
|
|
|
* Fügt dazu die übergebenen Elemente zusammen.
|
|
|
|
*/
|
|
|
|
function page_with_title($title, $elements) {
|
2014-09-08 14:45:41 +02:00
|
|
|
return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
|
2014-08-22 22:34:13 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Datentabelle
|
|
|
|
*/
|
2014-03-26 20:04:11 +01:00
|
|
|
function table($columns, $rows_raw, $data = true) {
|
|
|
|
// If only one column is given
|
|
|
|
if (! is_array($columns)) {
|
2016-09-29 11:28:42 +02:00
|
|
|
$rows = [];
|
2016-09-30 17:38:26 +02:00
|
|
|
foreach ($rows_raw as $row) {
|
2016-09-29 11:28:42 +02:00
|
|
|
$rows[] = [
|
2014-12-16 09:55:14 +01:00
|
|
|
'col' => $row
|
2016-09-29 11:28:42 +02:00
|
|
|
];
|
2016-09-30 17:38:26 +02:00
|
|
|
}
|
|
|
|
return render_table([
|
|
|
|
'col' => $columns
|
|
|
|
], $rows, $data);
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2014-12-16 09:55:14 +01:00
|
|
|
|
2016-09-30 17:38:26 +02:00
|
|
|
return render_table($columns, $rows_raw, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for rendering a html-table.
|
|
|
|
* use table()
|
|
|
|
*/
|
|
|
|
function render_table($columns, $rows, $data = true) {
|
2016-09-29 11:28:42 +02:00
|
|
|
if (count($rows) == 0) {
|
2013-11-28 22:00:49 +01:00
|
|
|
return info(_("No data found."), true);
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
|
|
|
|
2016-09-30 17:38:26 +02:00
|
|
|
$html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= '<thead><tr>';
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($columns as $key => $column) {
|
2014-08-23 02:47:06 +02:00
|
|
|
$html .= '<th class="column_' . $key . '">' . $column . '</th>';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= '</tr></thead>';
|
|
|
|
$html .= '<tbody>';
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
$html .= '<tr>';
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($columns as $key => $column) {
|
2016-10-04 18:11:26 +02:00
|
|
|
$value = " ";
|
2016-09-29 11:28:42 +02:00
|
|
|
if (isset($row[$key])) {
|
2016-10-04 18:11:26 +02:00
|
|
|
$value = $row[$key];
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2016-10-04 18:11:26 +02:00
|
|
|
$html .= '<td class="column_' . $key . '">' . $value . '</td>';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= '</tr>';
|
|
|
|
}
|
|
|
|
$html .= '</tbody>';
|
|
|
|
$html .= '</table>';
|
|
|
|
return $html;
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert einen Knopf
|
|
|
|
*/
|
|
|
|
function button($href, $label, $class = "") {
|
2014-08-22 22:34:13 +02:00
|
|
|
return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 17:41:16 +01:00
|
|
|
/**
|
|
|
|
* Rendert einen Knopf mit Glyph
|
|
|
|
*/
|
2014-12-06 22:26:56 +01:00
|
|
|
function button_glyph($href, $glyph, $class = "") {
|
|
|
|
return button($href, glyph($glyph), $class);
|
|
|
|
}
|
2014-12-06 17:41:16 +01:00
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Toolbar mit Knöpfen
|
|
|
|
*/
|
2016-09-30 17:08:20 +02:00
|
|
|
function buttons($buttons = []) {
|
2014-09-28 14:50:08 +02:00
|
|
|
return '<div class="form-group">' . table_buttons($buttons) . '</div>';
|
|
|
|
}
|
|
|
|
|
2016-09-30 17:08:20 +02:00
|
|
|
function table_buttons($buttons = []) {
|
2014-09-28 14:50:08 +02:00
|
|
|
return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2011-06-02 00:48:29 +02:00
|
|
|
// Load and render template
|
|
|
|
function template_render($file, $data) {
|
2013-09-18 01:38:36 +02:00
|
|
|
if (file_exists($file)) {
|
|
|
|
$template = file_get_contents($file);
|
2016-09-29 11:28:42 +02:00
|
|
|
if (is_array($data)) {
|
2013-09-18 01:38:36 +02:00
|
|
|
foreach ($data as $name => $content) {
|
2013-10-13 00:52:44 +02:00
|
|
|
$template = str_replace("%" . $name . "%", $content, $template);
|
|
|
|
}
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
return $template;
|
|
|
|
}
|
2016-08-22 19:32:54 +02:00
|
|
|
engelsystem_error("Cannot find template file «" . $file . "».");
|
2011-06-02 00:48:29 +02:00
|
|
|
}
|
2011-06-02 16:56:45 +02:00
|
|
|
|
2016-09-30 17:38:26 +02:00
|
|
|
function shorten($str, $length = 50) {
|
|
|
|
if (strlen($str) < $length) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return $str;
|
2016-09-30 17:38:26 +02:00
|
|
|
}
|
|
|
|
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
|
2011-07-13 14:29:40 +02:00
|
|
|
}
|
|
|
|
|
2011-07-11 20:40:27 +02:00
|
|
|
function table_body($array) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = "";
|
|
|
|
foreach ($array as $line) {
|
|
|
|
$html .= "<tr>";
|
|
|
|
if (is_array($line)) {
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($line as $td) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= "<td>" . $td . "</td>";
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
} else {
|
|
|
|
$html .= "<td>" . $line . "</td>";
|
|
|
|
}
|
|
|
|
$html .= "</tr>";
|
|
|
|
}
|
|
|
|
return $html;
|
2011-07-11 20:40:27 +02:00
|
|
|
}
|
|
|
|
|
2011-06-02 16:56:45 +02:00
|
|
|
function html_options($name, $options, $selected = "") {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = "";
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($options as $value => $label) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2014-12-16 09:55:14 +01:00
|
|
|
|
2013-09-18 01:38:36 +02:00
|
|
|
return $html;
|
2011-06-02 16:56:45 +02:00
|
|
|
}
|
2011-06-02 20:18:01 +02:00
|
|
|
|
2016-09-29 12:45:06 +02:00
|
|
|
function html_select_key($dom_id, $name, $rows, $selected) {
|
|
|
|
$html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';
|
2013-09-18 01:38:36 +02:00
|
|
|
foreach ($rows as $key => $row) {
|
|
|
|
if (($key == $selected) || ($row == $selected)) {
|
|
|
|
$html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
|
|
|
|
} else {
|
|
|
|
$html .= '<option value="' . $key . '">' . $row . '</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$html .= '</select>';
|
|
|
|
return $html;
|
2011-06-02 20:18:01 +02:00
|
|
|
}
|
2012-12-29 13:58:59 +01:00
|
|
|
|
2013-09-18 01:38:36 +02:00
|
|
|
function ReplaceSmilies($neueckig) {
|
|
|
|
$neueckig = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":-)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":-(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":o(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":o)", "<img src=\"pic/smiles/icon_lol.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";o(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";-(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace("8)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace("8o)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":-P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(":oP", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
|
|
|
|
$neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig);
|
2014-12-16 09:55:14 +01:00
|
|
|
|
2013-09-18 01:38:36 +02:00
|
|
|
return $neueckig;
|
2012-12-29 13:58:59 +01:00
|
|
|
}
|
2011-07-12 16:03:07 +02:00
|
|
|
?>
|