2011-06-02 00:48:29 +02:00
|
|
|
<?php
|
|
|
|
|
2011-12-26 18:28:57 +01:00
|
|
|
/**
|
|
|
|
* Liste der verfügbaren Themes
|
|
|
|
*/
|
2013-10-13 00:52:44 +02:00
|
|
|
$themes = array(
|
|
|
|
"1" => "30C3 light",
|
|
|
|
"2" => "30C3 dark"
|
2011-12-26 18:28:57 +01:00
|
|
|
);
|
|
|
|
|
2013-10-13 00:52:44 +02:00
|
|
|
/**
|
|
|
|
* Render a toolbar.
|
|
|
|
*
|
|
|
|
* @param array $items
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function toolbar($items = array()) {
|
|
|
|
return '<div class="toolbar">' . join("\n", $items) . '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a link for a toolbar.
|
|
|
|
* @param string $href
|
|
|
|
* @param string $class
|
|
|
|
* @param string $label
|
|
|
|
* @param bool $selected
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function toolbar_item_link($href, $class, $label, $selected = false) {
|
|
|
|
return '<a href="' . $href . '" class="' . ($selected ? 'selected ' : '') . '' . $class . '">' . $label . '</a>';
|
|
|
|
}
|
|
|
|
|
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) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = "<ul>";
|
|
|
|
foreach ($items as $key => $item) {
|
|
|
|
$id = $name . '_' . $key;
|
|
|
|
$sel = array_search($key, $selected) !== false ? ' checked="checked"' : "";
|
|
|
|
$html .= '<li><input type="checkbox" id="' . $id . '" name="' . $id . '" value="checked"' . $sel . ' /><label for="' . $id . '">' . $item . '</label></li>';
|
|
|
|
}
|
|
|
|
$html .= "</ul>";
|
|
|
|
return form_element($label, $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
|
|
|
*/
|
|
|
|
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = array()) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = "<table><thead><tr>";
|
|
|
|
foreach ($names as $title)
|
|
|
|
$html .= "<th>$title</th>";
|
|
|
|
$html .= "</tr></thead><tbody>";
|
|
|
|
foreach ($items as $key => $item) {
|
|
|
|
$html .= "<tr>";
|
|
|
|
foreach ($names as $name => $title) {
|
|
|
|
$id = $name . '_' . $key;
|
|
|
|
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
|
2013-10-13 00:52:44 +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"';
|
|
|
|
$html .= '<td style="text-align: center;"><input type="checkbox" id="' . $id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
|
|
|
|
}
|
|
|
|
$html .= '<td><label for="' . $id . '">' . $item . '</label></td></tr>';
|
|
|
|
}
|
|
|
|
$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') {
|
2013-09-18 01:38:36 +02:00
|
|
|
return form_element("", '<input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /><label for="' . $name . '">' . $label . '</label>');
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert einen Infotext in das Formular
|
|
|
|
*/
|
|
|
|
function form_info($label, $text) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return form_element($label, $text, "");
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert den Absenden-Button eines Formulars
|
|
|
|
*/
|
|
|
|
function form_submit($name, $label) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return form_element('<input class="button save ' . $name . '" 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"' : '';
|
|
|
|
return form_element($label, '<input id="form_' . $name . '" type="text" name="' . $name . '" value="' . $value . '" ' . $disabled . '/>', 'form_' . $name);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
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"' : '';
|
|
|
|
return form_element($label, '<input 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"' : '';
|
|
|
|
return form_element($label, '<textarea 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 = "") {
|
2013-09-18 01:38:36 +02:00
|
|
|
return '<div class="form_element">' . '<label for="' . $for . '" class="form_label">' . $label . '</label><div class="form_input">' . $input . '</div></div>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert ein Formular
|
|
|
|
*/
|
|
|
|
function form($elements, $action = "") {
|
2013-09-18 01:38:36 +02:00
|
|
|
return '<form action="' . $action . '" enctype="multipart/form-data" method="post"><div class="form">' . join($elements) . '</div></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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Datentabelle
|
|
|
|
*/
|
|
|
|
function table($columns, $rows, $data = true) {
|
2013-09-18 01:38:36 +02:00
|
|
|
if (count($rows) == 0)
|
|
|
|
return info("No data available.", true);
|
|
|
|
$html = "";
|
|
|
|
$html .= '<table' . ($data ? ' class="data"' : '') . '>';
|
|
|
|
$html .= '<thead><tr>';
|
|
|
|
foreach ($columns as $key => $column)
|
|
|
|
$html .= '<th class="' . $key . '">' . $column . '</th>';
|
|
|
|
$html .= '</tr></thead>';
|
|
|
|
$html .= '<tbody>';
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
$html .= '<tr>';
|
|
|
|
foreach ($columns as $key => $column)
|
2013-10-13 00:52:44 +02:00
|
|
|
if (isset($row[$key]))
|
|
|
|
$html .= '<td class="' . $key . '">' . $row[$key] . '</td>';
|
|
|
|
else
|
|
|
|
$html .= '<td class="' . $key . '"> </td>';
|
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 = "") {
|
2013-09-18 01:38:36 +02:00
|
|
|
return '<a href="' . $href . '" class="button ' . $class . '">' . $label . '</a>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Toolbar mit Knöpfen
|
|
|
|
*/
|
|
|
|
function buttons($buttons = array ()) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return '<div class="toolbar">' . 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);
|
|
|
|
if (is_array($data))
|
|
|
|
foreach ($data as $name => $content) {
|
2013-10-13 00:52:44 +02:00
|
|
|
$template = str_replace("%" . $name . "%", $content, $template);
|
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
return $template;
|
|
|
|
} else {
|
|
|
|
die('Cannot find template file «' . $file . '».');
|
|
|
|
}
|
2011-06-02 00:48:29 +02:00
|
|
|
}
|
2011-06-02 16:56:45 +02:00
|
|
|
|
2011-07-13 14:29:40 +02:00
|
|
|
function shorten($str) {
|
2013-09-18 01:38:36 +02:00
|
|
|
if (strlen($str) < 50)
|
|
|
|
return $str;
|
|
|
|
return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, 47) . '...</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)) {
|
|
|
|
foreach ($line as $td)
|
|
|
|
$html .= "<td>" . $td . "</td>";
|
|
|
|
} 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 = "";
|
|
|
|
foreach ($options as $value => $label)
|
|
|
|
$html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
|
2011-06-02 16:56:45 +02: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
|
|
|
|
2011-12-26 15:55:17 +01:00
|
|
|
function html_select_key($id, $name, $rows, $selected) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$html = '<select id="' . $id . '" name="' . $name . '">';
|
|
|
|
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
|
|
|
|
|
|
|
function img_button($link, $icon, $text, $extra_text = '') {
|
2013-11-25 21:04:58 +01:00
|
|
|
return '<a href="' . htmlspecialchars($link) . '"><img src="pic/icons/' . htmlspecialchars($icon) . '.png" alt="' . $text . '" ' . (empty($text) ? '' : 'title="' . $text . '"') . '>' . (empty($extra_text) ? '' : ' ' . $extra_text) . '</a>';
|
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);
|
|
|
|
|
|
|
|
return $neueckig;
|
2012-12-29 13:58:59 +01:00
|
|
|
}
|
2011-07-12 16:03:07 +02:00
|
|
|
?>
|