"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" => "msquare (cccamp2011)",
"11" => "msquare (28c3)"
);
/**
* Rendert eine Liste von Checkboxen für ein Formular
* @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
*/
function form_checkboxes($name, $label, $items, $selected) {
$html = "
";
return form_element($label, $html);
}
/**
* Rendert eine Checkbox
*/
function form_checkbox($name, $label, $selected, $value = 'checked') {
return form_element("", '' . $label . ' ');
}
/**
* Rendert einen Infotext in das Formular
*/
function form_info($label, $text) {
return form_element($label, $text, "");
}
/**
* Rendert den Absenden-Button eines Formulars
*/
function form_submit($name, $label) {
return form_element(' ', "");
}
/**
* Rendert ein Formular-Textfeld
*/
function form_text($name, $label, $value, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element($label, ' ', 'form_' . $name);
}
/**
* Rendert ein Formular-Passwortfeld
*/
function form_password($name, $label, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element($label, ' ', 'form_' . $name);
}
/**
* Rendert ein Formular-Textfeld
*/
function form_textarea($name, $label, $value, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element($label, '', '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);
}
/**
* Rendert ein Formular-Element
*/
function form_element($label, $input, $for = "") {
return '';
}
/**
* Rendert ein Formular
*/
function form($elements, $action = "") {
return '';
}
/**
* Generiert HTML Code für eine "Seite". Fügt dazu die übergebenen Elemente zusammen.
*/
function page($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 .= '';
$html .= '';
foreach ($columns as $key => $column)
$html .= '' . $column . ' ';
$html .= ' ';
$html .= '';
foreach ($rows as $row) {
$html .= '';
foreach ($columns as $key => $column)
if (isset ($row[$key]))
$html .= '' . $row[$key] . ' ';
else
$html .= ' ';
$html .= ' ';
}
$html .= ' ';
$html .= '
';
return $html;
}
/**
* Rendert einen Knopf
*/
function button($href, $label, $class = "") {
return '' . $label . ' ';
}
/**
* Rendert eine Toolbar mit Knöpfen
*/
function buttons($buttons = array ()) {
return '' . join($buttons) . '
';
}
// 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 «' . $file . '».');
}
}
function shorten($str) {
if (strlen($str) < 50)
return $str;
return '' . substr($str, 0, 47) . '... ';
}
function table_body($array) {
$html = "";
foreach ($array as $line) {
$html .= "";
if (is_array($line)) {
foreach ($line as $td)
$html .= "" . $td . " ";
} else {
$html .= "" . $line . " ";
}
$html .= " ";
}
return $html;
}
function html_options($name, $options, $selected = "") {
$html = "";
foreach ($options as $value => $label)
$html .= ' ' . $label;
return $html;
}
function html_select_key($id, $name, $rows, $selected) {
$html = '';
foreach ($rows as $key => $row) {
if (($key == $selected) || ($row == $selected)) {
$html .= '' . $row . ' ';
} else {
$html .= '' . $row . ' ';
}
}
$html .= ' ';
return $html;
}
?>