summaryrefslogtreecommitdiff
path: root/includes/sys_template.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/sys_template.php')
-rw-r--r--includes/sys_template.php459
1 files changed, 301 insertions, 158 deletions
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 3679328b..7aa458b8 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -4,116 +4,192 @@
* Liste der verfügbaren Themes
*/
$themes = [
- '4' => "Engelsystem 33c3 (2016)",
- '3' => "Engelsystem 32c3 (2015)",
- "2" => "Engelsystem cccamp15",
- "0" => "Engelsystem light",
- "1" => "Engelsystem dark"
+ '4' => 'Engelsystem 33c3 (2016)',
+ '3' => 'Engelsystem 32c3 (2015)',
+ '2' => 'Engelsystem cccamp15',
+ '0' => 'Engelsystem light',
+ '1' => 'Engelsystem dark'
];
/**
* Display muted (grey) text.
*
- * @param string $text
+ * @param string $text
+ * @return string
*/
-function mute($text) {
- return '<span class="text-muted">' . $text . '</span>';
+function mute($text)
+{
+ return '<span class="text-muted">' . $text . '</span>';
}
/**
* Renders a bootstrap label with given content and class.
*
- * @param string $content
- * The text
- * @param string $class
- * default, primary, info, success, warning, danger
+ * @param string $content The text
+ * @param string $class default, primary, info, success, warning, danger
+ * @return string
*/
-function label($content, $class = 'default') {
- return '<span class="label label-' . $class . '">' . $content . '</span>';
+function label($content, $class = 'default')
+{
+ return '<span class="label label-' . $class . '">' . $content . '</span>';
}
-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: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
+/**
+ * @param int $valuemin
+ * @param int $valuemax
+ * @param int $valuenow
+ * @param string $class
+ * @param string $content
+ * @return string
+ */
+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: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"'
+ . '>'
+ . $content . ''
+ . '</div>'
+ . '</div>';
}
/**
* Render glyphicon
*
- * @param string $glyph_name
+ * @param string $glyph_name
+ * @return string
*/
-function glyph($glyph_name) {
- return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
+function glyph($glyph_name)
+{
+ return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
}
/**
* Renders a tick or a cross by given boolean
*
- * @param boolean $boolean
+ * @param boolean $boolean
+ * @return string
*/
-function glyph_bool($boolean) {
- return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
+function glyph_bool($boolean)
+{
+ return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
}
-function div($class, $content = [], $dom_id = "") {
- if (is_array($content)) {
- $content = join("\n", $content);
- }
- $dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
- return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
+/**
+ * @param string $class
+ * @param array $content
+ * @param string $dom_id
+ * @return string
+ */
+function div($class, $content = [], $dom_id = '')
+{
+ if (is_array($content)) {
+ $content = join("\n", $content);
+ }
+ $dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
+ return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
}
-function heading($content, $number = 1) {
- return "<h" . $number . ">" . $content . "</h" . $number . ">";
+/**
+ * @param string $content
+ * @param int $number
+ * @return string
+ */
+function heading($content, $number = 1)
+{
+ return '<h' . $number . '>' . $content . '</h' . $number . '>';
}
/**
* Render a toolbar.
*
- * @param array $items
+ * @param array $items
+ * @param bool $right
* @return string
*/
-function toolbar($items = [], $right = false) {
- return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
+function toolbar($items = [], $right = false)
+{
+ return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
}
-function toolbar_pills($items) {
- return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
+/**
+ * @param string[] $items
+ * @return string
+ */
+function toolbar_pills($items)
+{
+ return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
}
/**
* Render a link for a toolbar.
*
- * @param string $href
- * @param string $glyphicon
- * @param string $label
- * @param bool $selected
+ * @param string $href
+ * @param string $glyphicon
+ * @param string $label
+ * @param bool $selected
* @return string
*/
-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>';
+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>';
}
-function toolbar_item_divider() {
- return '<li class="divider"></li>';
+/**
+ * @return string
+ */
+function toolbar_item_divider()
+{
+ return '<li class="divider"></li>';
}
-function toolbar_dropdown($glyphicon, $label, $submenu, $class = '') {
- return '<li class="dropdown ' . $class . '">
- <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>';
+/**
+ * @param string $glyphicon
+ * @param string $label
+ * @param array $submenu
+ * @param string $class
+ * @return string
+ */
+function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
+{
+ return '<li class="dropdown ' . $class . '">
+ <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>';
}
-function toolbar_popover($glyphicon, $label, $content, $class = '') {
- $dom_id = md5(microtime() . $glyphicon . $label);
- return '<li class="dropdown messages ' . $class . '">
- <a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
+/**
+ * @param string $glyphicon
+ * @param string $label
+ * @param string[] $content
+ * @param string $class
+ * @return string
+ */
+function toolbar_popover($glyphicon, $label, $content, $class = '')
+{
+ $dom_id = md5(microtime() . $glyphicon . $label);
+ return '<li class="dropdown messages ' . $class . '">
+ <a id="' . $dom_id . '" href="#" tabindex="0">'
+ . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
+ . $label
+ . ' <span class="caret"></span></a>
<script type="text/javascript">
$(function(){
$("#' . $dom_id . '").popover({
- trigger: "focus",
- html: true,
- content: "' . addslashes(join('', $content)) . '",
- placement: "bottom",
+ trigger: "focus",
+ html: true,
+ content: "' . addslashes(join('', $content)) . '",
+ placement: "bottom",
container: "#navbar-collapse-1"
})
});
@@ -124,155 +200,222 @@ function toolbar_popover($glyphicon, $label, $content, $class = '') {
/**
* Generiert HTML Code für eine "Seite".
* Fügt dazu die übergebenen Elemente zusammen.
+ *
+ * @param string[] $elements
+ * @return string
*/
-function page($elements) {
- return join($elements);
+function page($elements)
+{
+ return join($elements);
}
/**
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
* Fügt dazu die übergebenen Elemente zusammen.
+ *
+ * @param string $title
+ * @param string[] $elements
+ * @return string
*/
-function page_with_title($title, $elements) {
- return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
+function page_with_title($title, $elements)
+{
+ return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
}
/**
* Rendert eine Datentabelle
+ *
+ * @param array|string $columns
+ * @param array[] $rows_raw
+ * @param bool $data
+ * @return string
*/
-function table($columns, $rows_raw, $data = true) {
- // If only one column is given
- if (! is_array($columns)) {
- $rows = [];
- foreach ($rows_raw as $row) {
- $rows[] = [
- 'col' => $row
- ];
+function table($columns, $rows_raw, $data = true)
+{
+ // If only one column is given
+ if (!is_array($columns)) {
+ $rows = [];
+ foreach ($rows_raw as $row) {
+ $rows[] = [
+ 'col' => $row
+ ];
+ }
+ return render_table([
+ 'col' => $columns
+ ], $rows, $data);
}
- return render_table([
- 'col' => $columns
- ], $rows, $data);
- }
-
- return render_table($columns, $rows_raw, $data);
+
+ return render_table($columns, $rows_raw, $data);
}
/**
* Helper for rendering a html-table.
* use table()
+ *
+ * @param string[] $columns
+ * @param array[] $rows
+ * @param bool $data
+ * @return string
*/
-function render_table($columns, $rows, $data = true) {
- if (count($rows) == 0) {
- return info(_("No data found."), true);
- }
-
- $html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
- $html .= '<thead><tr>';
- foreach ($columns as $key => $column) {
- $html .= '<th class="column_' . $key . '">' . $column . '</th>';
- }
- $html .= '</tr></thead>';
- $html .= '<tbody>';
- foreach ($rows as $row) {
- $html .= '<tr>';
+function render_table($columns, $rows, $data = true)
+{
+ if (count($rows) == 0) {
+ return info(_('No data found.'), true);
+ }
+
+ $html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
+ $html .= '<thead><tr>';
foreach ($columns as $key => $column) {
- $value = "&nbsp;";
- if (isset($row[$key])) {
- $value = $row[$key];
- }
- $html .= '<td class="column_' . $key . '">' . $value . '</td>';
+ $html .= '<th class="column_' . $key . '">' . $column . '</th>';
}
- $html .= '</tr>';
- }
- $html .= '</tbody>';
- $html .= '</table>';
- return $html;
+ $html .= '</tr></thead>';
+ $html .= '<tbody>';
+ foreach ($rows as $row) {
+ $html .= '<tr>';
+ foreach ($columns as $key => $column) {
+ $value = "&nbsp;";
+ if (isset($row[$key])) {
+ $value = $row[$key];
+ }
+ $html .= '<td class="column_' . $key . '">' . $value . '</td>';
+ }
+ $html .= '</tr>';
+ }
+ $html .= '</tbody>';
+ $html .= '</table>';
+ return $html;
}
/**
* Rendert einen Knopf
+ *
+ * @param string $href
+ * @param string $label
+ * @param string $class
+ * @return string
*/
-function button($href, $label, $class = "") {
- return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
+function button($href, $label, $class = '')
+{
+ return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
}
/**
* Rendert einen Knopf mit Glyph
+ *
+ * @param string $href
+ * @param string $glyph
+ * @param string $class
+ * @return string
*/
-function button_glyph($href, $glyph, $class = "") {
- return button($href, glyph($glyph), $class);
+function button_glyph($href, $glyph, $class = '')
+{
+ return button($href, glyph($glyph), $class);
}
/**
* Rendert eine Toolbar mit Knöpfen
+ *
+ * @param array $buttons
+ * @return string
*/
-function buttons($buttons = []) {
- return '<div class="form-group">' . table_buttons($buttons) . '</div>';
+function buttons($buttons = [])
+{
+ return '<div class="form-group">' . table_buttons($buttons) . '</div>';
}
-function table_buttons($buttons = []) {
- return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
+/**
+ * @param array $buttons
+ * @return string
+ */
+function table_buttons($buttons = [])
+{
+ return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
}
-// Load and render template
-function template_render($file, $data) {
- if (file_exists($file)) {
- $template = file_get_contents($file);
- if (is_array($data)) {
- foreach ($data as $name => $content) {
- $template = str_replace("%" . $name . "%", $content, $template);
- }
+/**
+ * Load and render template
+ *
+ * @param string $file
+ * @param string $data
+ * @return string
+ */
+function template_render($file, $data)
+{
+ if (file_exists($file)) {
+ $template = file_get_contents($file);
+ if (is_array($data)) {
+ foreach ($data as $name => $content) {
+ $template = str_replace('%' . $name . '%', $content, $template);
+ }
+ }
+ return $template;
}
- return $template;
- }
- engelsystem_error("Cannot find template file &laquo;" . $file . "&raquo;.");
+ engelsystem_error('Cannot find template file &laquo;' . $file . '&raquo;.');
+ return '';
}
-function shorten($str, $length = 50) {
- if (strlen($str) < $length) {
- return $str;
- }
- return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
+/**
+ * @param string $str
+ * @param int $length
+ * @return string
+ */
+function shorten($str, $length = 50)
+{
+ if (strlen($str) < $length) {
+ return $str;
+ }
+ return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">'
+ . substr($str, 0, $length - 3)
+ . '...</span>';
}
-function table_body($array) {
- $html = "";
- foreach ($array as $line) {
- $html .= "<tr>";
- if (is_array($line)) {
- foreach ($line as $td) {
- $html .= "<td>" . $td . "</td>";
- }
- } else {
- $html .= "<td>" . $line . "</td>";
+/**
+ * @param array[] $array
+ * @return string
+ */
+function table_body($array)
+{
+ $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>';
}
- $html .= "</tr>";
- }
- return $html;
+ return $html;
}
-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;
+/**
+ * @param string $msg
+ * @return mixed
+ */
+function ReplaceSmilies($msg)
+{
+ $msg = str_replace(';o))', '<img src="pic/smiles/icon_redface.gif">', $msg);
+ $msg = str_replace(':-))', '<img src="pic/smiles/icon_redface.gif">', $msg);
+ $msg = str_replace(';o)', '<img src="pic/smiles/icon_wind.gif">', $msg);
+ $msg = str_replace(':)', '<img src="pic/smiles/icon_smile.gif">', $msg);
+ $msg = str_replace(':-)', '<img src="pic/smiles/icon_smile.gif">', $msg);
+ $msg = str_replace(':(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':-(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':o(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':o)', '<img src="pic/smiles/icon_lol.gif">', $msg);
+ $msg = str_replace(';o(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace(';(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace(';-(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace('8)', '<img src="pic/smiles/icon_rolleyes.gif">', $msg);
+ $msg = str_replace('8o)', '<img src="pic/smiles/icon_rolleyes.gif">', $msg);
+ $msg = str_replace(':P', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(':-P', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(':oP', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(';P', '<img src="pic/smiles/icon_mad.gif">', $msg);
+ $msg = str_replace(';oP', '<img src="pic/smiles/icon_mad.gif">', $msg);
+ $msg = str_replace('?)', '<img src="pic/smiles/icon_question.gif">', $msg);
+
+ return $msg;
}
-?>