summaryrefslogtreecommitdiff
path: root/includes/sys_template.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2013-09-18 01:38:36 +0200
committerPhilip Häusler <msquare@notrademark.de>2013-09-18 01:38:36 +0200
commitbfb0cacd541cc20129a3c0ac77130370741dca18 (patch)
tree0a0e86e1a53d712065664c12d06603bc044df9ec /includes/sys_template.php
parentd50cc21f50cb3ec3afdabb74a20d81bd1a53dfbd (diff)
mysql to mysqli and a lot of cleanup and mvc
Diffstat (limited to 'includes/sys_template.php')
-rw-r--r--includes/sys_template.php252
1 files changed, 139 insertions, 113 deletions
diff --git a/includes/sys_template.php b/includes/sys_template.php
index a120bb2d..e15af7f8 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -5,17 +5,17 @@
* Liste der verfügbaren Themes
*/
$themes = array (
- "1" => "Standard-Style",
- "2" => "ot/Gelber Style",
- "3" => "Club-Mate Style",
- "5" => "Debian Style",
- "6" => "c-base Style",
- "7" => "Blau/Gelber Style",
- "8" => "Pastel Style",
- "4" => "Test Style",
- "9" => "Test Style 21c3",
- "10" => "Engelsystem 2.0",
- "11" => "msquare (29c3)"
+ "1" => "Standard-Style",
+ "2" => "ot/Gelber Style",
+ "3" => "Club-Mate Style",
+ "5" => "Debian Style",
+ "6" => "c-base Style",
+ "7" => "Blau/Gelber Style",
+ "8" => "Pastel Style",
+ "4" => "Test Style",
+ "9" => "Test Style 21c3",
+ "10" => "Engelsystem 2.0",
+ "11" => "msquare (29c3)"
);
/**
@@ -26,14 +26,14 @@ $themes = array (
* @param selected Array mit den Keys, die ausgewählt sind
*/
function form_checkboxes($name, $label, $items, $selected) {
- $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);
+ $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);
}
/**
@@ -45,197 +45,223 @@ function form_checkboxes($name, $label, $items, $selected) {
* @param disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
*/
function form_multi_checkboxes($names, $label, $items, $selected, $disabled = array()) {
- $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"' : "";
- if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false)
- $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);
+ $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"' : "";
+ if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false)
+ $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);
}
/**
* Rendert eine Checkbox
*/
function form_checkbox($name, $label, $selected, $value = 'checked') {
- return form_element("", '<input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /><label for="' . $name . '">' . $label . '</label>');
+ return form_element("", '<input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /><label for="' . $name . '">' . $label . '</label>');
}
/**
* Rendert einen Infotext in das Formular
*/
function form_info($label, $text) {
- return form_element($label, $text, "");
+ return form_element($label, $text, "");
}
/**
* Rendert den Absenden-Button eines Formulars
*/
function form_submit($name, $label) {
- return form_element('<input class="button save ' . $name . '" type="submit" name="' . $name . '" value="' . $label . '" />', "");
+ return form_element('<input class="button save ' . $name . '" type="submit" name="' . $name . '" value="' . $label . '" />', "");
}
/**
* Rendert ein Formular-Textfeld
*/
function form_text($name, $label, $value, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<input id="form_' . $name . '" type="text" name="' . $name . '" value="' . $value . '" ' . $disabled . '/>', 'form_' . $name);
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ return form_element($label, '<input id="form_' . $name . '" type="text" name="' . $name . '" value="' . $value . '" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Rendert ein Formular-Passwortfeld
*/
function form_password($name, $label, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<input id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ return form_element($label, '<input id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Rendert ein Formular-Textfeld
*/
function form_textarea($name, $label, $value, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<textarea id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ return form_element($label, '<textarea id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
}
/**
* Rendert ein Formular-Auswahlfeld
*/
function form_select($name, $label, $values, $selected) {
- return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
+ return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
}
/**
* Rendert ein Formular-Element
*/
function form_element($label, $input, $for = "") {
- return '<div class="form_element">' . '<label for="' . $for . '" class="form_label">' . $label . '</label><div class="form_input">' . $input . '</div></div>';
+ return '<div class="form_element">' . '<label for="' . $for . '" class="form_label">' . $label . '</label><div class="form_input">' . $input . '</div></div>';
}
/**
* Rendert ein Formular
*/
function form($elements, $action = "") {
- return '<form action="' . $action . '" enctype="multipart/form-data" method="post"><div class="form">' . join($elements) . '</div></form>';
+ return '<form action="' . $action . '" enctype="multipart/form-data" method="post"><div class="form">' . join($elements) . '</div></form>';
}
/**
* Generiert HTML Code für eine "Seite". Fügt dazu die übergebenen Elemente zusammen.
*/
function page($elements) {
- return join($elements);
+ return join($elements);
}
/**
* Rendert eine Datentabelle
*/
function table($columns, $rows, $data = true) {
- 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)
- if (isset ($row[$key]))
- $html .= '<td class="' . $key . '">' . $row[$key] . '</td>';
- else
- $html .= '<td class="' . $key . '">&nbsp;</td>';
- $html .= '</tr>';
- }
- $html .= '</tbody>';
- $html .= '</table>';
- return $html;
+ 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)
+ if (isset ($row[$key]))
+ $html .= '<td class="' . $key . '">' . $row[$key] . '</td>';
+ else
+ $html .= '<td class="' . $key . '">&nbsp;</td>';
+ $html .= '</tr>';
+ }
+ $html .= '</tbody>';
+ $html .= '</table>';
+ return $html;
}
/**
* Rendert einen Knopf
*/
function button($href, $label, $class = "") {
- return '<a href="' . $href . '" class="button ' . $class . '">' . $label . '</a>';
+ return '<a href="' . $href . '" class="button ' . $class . '">' . $label . '</a>';
}
/**
* Rendert eine Toolbar mit Knöpfen
*/
function buttons($buttons = array ()) {
- return '<div class="toolbar">' . join(' ', $buttons) . '</div>';
+ return '<div class="toolbar">' . 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);
- }
- return $template;
- } else {
- die('Cannot find template file &laquo;' . $file . '&raquo;.');
- }
+ 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;
+ } else {
+ die('Cannot find template file &laquo;' . $file . '&raquo;.');
+ }
}
function shorten($str) {
- if (strlen($str) < 50)
- return $str;
- return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, 47) . '...</span>';
+ if (strlen($str) < 50)
+ return $str;
+ return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, 47) . '...</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>";
- }
- $html .= "</tr>";
- }
- return $html;
+ $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;
}
function html_options($name, $options, $selected = "") {
- $html = "";
- foreach ($options as $value => $label)
- $html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
+ $html = "";
+ foreach ($options as $value => $label)
+ $html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
- return $html;
+ return $html;
}
function html_select_key($id, $name, $rows, $selected) {
- $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;
+ $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;
}
function img_button($link, $icon, $text, $extra_text = '') {
- $translation = empty($text)? '' : Get_Text($text);
- return '<a href="' . htmlspecialchars($link) . '"><img src="pic/icons/' . htmlspecialchars($icon) . '.png" alt="' . $translation . '" ' . (empty($translation)? '' : 'title="' . $translation . '"') . '>' . (empty($extra_text)? '' : ' ' . $extra_text) . '</a>';
+ $translation = empty($text)? '' : Get_Text($text);
+ return '<a href="' . htmlspecialchars($link) . '"><img src="pic/icons/' . htmlspecialchars($icon) . '.png" alt="' . $translation . '" ' . (empty($translation)? '' : 'title="' . $translation . '"') . '>' . (empty($extra_text)? '' : ' ' . $extra_text) . '</a>';
+}
+
+
+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;
}
?>