#44 angeltypes recreated
This commit is contained in:
parent
23d82fecb4
commit
5e5443fad6
|
@ -13,3 +13,9 @@ NULL , 'ical', 'iCal shift export'
|
||||||
|
|
||||||
/* DECT Nummern können für GSM auch 5-stellig sein. */
|
/* DECT Nummern können für GSM auch 5-stellig sein. */
|
||||||
ALTER TABLE `User` CHANGE `DECT` `DECT` VARCHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
|
ALTER TABLE `User` CHANGE `DECT` `DECT` VARCHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
|
||||||
|
|
||||||
|
/* Neues Engeltypen-System */
|
||||||
|
ALTER TABLE `AngelTypes` DROP `Man`;
|
||||||
|
ALTER TABLE `AngelTypes` CHANGE `TID` `id` INT( 11 ) NOT NULL AUTO_INCREMENT;
|
||||||
|
ALTER TABLE `AngelTypes` CHANGE `Name` `name` VARCHAR( 25 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE `AngelTypes` ADD `restricted` INT( 1 ) NOT NULL;
|
||||||
|
|
|
@ -1,96 +1,105 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function admin_angel_types() {
|
function admin_angel_types() {
|
||||||
$html = "";
|
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
if (!isset ($_REQUEST['action'])) {
|
$angel_types = array ();
|
||||||
|
foreach ($angel_types_source as $angel_type) {
|
||||||
$table = "";
|
$angel_types[] = array (
|
||||||
$angel_types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `Name`");
|
'id' => $angel_type['id'],
|
||||||
|
'name' => $angel_type['name'],
|
||||||
foreach ($angel_types as $angel_type)
|
'restricted' => $angel_type['restricted'] == 1 ? '✓' : '',
|
||||||
$table .= sprintf(
|
'actions' => '<a class="action edit" href="' . page_link_to('admin_angel_types') . '&show=edit&id=' . $angel_type['id'] . '">edit</a> <a class="action delete" href="' . page_link_to('admin_angel_types') . '&show=delete&id=' . $angel_type['id'] . '">delete</a>'
|
||||||
'<tr><td>%s</td><td>%s</td><td>'
|
|
||||||
. '<a href="%s&action=edit&id=%s">Edit</a></td></tr>',
|
|
||||||
$angel_type['Name'], $angel_type['Man'],
|
|
||||||
page_link_to("admin_angel_types"),
|
|
||||||
$angel_type['TID']
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$html .= template_render('../templates/admin_angel_types.html', array (
|
if (isset ($_REQUEST['show'])) {
|
||||||
'link' => page_link_to("admin_angel_types"),
|
if (test_request_int('id')) {
|
||||||
'table' => $table
|
$angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($_REQUEST['id']));
|
||||||
));
|
if (count($angel_type) > 0) {
|
||||||
|
$id = $_REQUEST['id'];
|
||||||
|
$name = $angel_type[0]['name'];
|
||||||
|
$restricted = $angel_type[0]['restricted'];
|
||||||
|
} else
|
||||||
|
redirect(page_link_to('admin_angel_types'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_REQUEST['show'] == 'edit') {
|
||||||
|
$msg = "";
|
||||||
|
$name = "";
|
||||||
|
$restricted = 0;
|
||||||
|
|
||||||
|
if (isset ($_REQUEST['submit'])) {
|
||||||
|
$ok = true;
|
||||||
|
|
||||||
|
if (isset ($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
|
||||||
|
$name = strip_request_item('name');
|
||||||
|
if (sql_num_query("SELECT * FROM `AngelTypes` WHERE NOT `id`=" . sql_escape(isset ($id) ? $id : 0) . " AND `name`='" . sql_escape(strip_request_item('name')) . "' LIMIT 1") > 0) {
|
||||||
|
$ok = false;
|
||||||
|
$msg .= error("This angel type name is already given.", true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$ok = false;
|
||||||
|
$msg .= error("Please enter a name.", true);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($_REQUEST['action']) {
|
if (isset ($_REQUEST['restricted']))
|
||||||
|
$restricted = 1;
|
||||||
|
|
||||||
case 'create' :
|
if ($ok) {
|
||||||
$name = strip_request_item("name");
|
if (isset ($id))
|
||||||
$man = strip_request_item("man");
|
sql_query("UPDATE `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted) . " WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
|
||||||
sql_query("INSERT INTO `AngelTypes` SET `Name`='" . sql_escape($name) . "', `Man`='" . sql_escape($man) . "'");
|
|
||||||
|
|
||||||
header("Location: " . page_link_to("admin_angel_types"));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'edit' :
|
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
|
||||||
$id = $_REQUEST['id'];
|
|
||||||
else
|
else
|
||||||
return error("Incomplete call, missing AngelType ID.");
|
sql_query("INSERT INTO `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted));
|
||||||
|
|
||||||
$angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
success("Angel type saved.");
|
||||||
if (count($angel_type) > 0) {
|
redirect(page_link_to('admin_angel_types'));
|
||||||
list ($angel_type) = $angel_type;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$html .= template_render(
|
return page(array (
|
||||||
'../templates/admin_angel_types_edit_form.html', array (
|
buttons(array (
|
||||||
'link' => page_link_to("admin_angel_types"),
|
button(page_link_to('admin_angel_types'), "Back", 'back')
|
||||||
'id' => $id,
|
)),
|
||||||
'name' => $angel_type['Name'],
|
$msg,
|
||||||
'man' => $angel_type['Man']
|
form(array (
|
||||||
|
form_text('name', 'Name', $name),
|
||||||
|
form_checkbox('restricted', 'Restricted', $restricted),
|
||||||
|
form_info("", "Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in)."),
|
||||||
|
form_submit('submit', 'Save')
|
||||||
|
))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
elseif ($_REQUEST['show'] == 'delete') {
|
||||||
|
if (isset ($_REQUEST['ack'])) {
|
||||||
|
sql_query("DELETE FROM `NeededAngelTypes` WHERE `angel_type_id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
sql_query("DELETE FROM `ShiftEntry` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
sql_query("DELETE FROM `AngelTypes` WHERE `id`=" . sql_escape($id) . " LIMIT 1");
|
||||||
|
success(sprintf("Angel type %s deleted.", $name));
|
||||||
|
redirect(page_link_to('admin_angel_types'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return page(array (
|
||||||
|
buttons(array (
|
||||||
|
button(page_link_to('admin_angel_types'), "Back", 'back')
|
||||||
|
)),
|
||||||
|
sprintf("Do you want to delete angel type %s?", $name),
|
||||||
|
buttons(array (
|
||||||
|
button(page_link_to('admin_angel_types') . '&show=delete&id=' . $id . '&ack', "Delete", 'delete')
|
||||||
|
))
|
||||||
));
|
));
|
||||||
} else
|
} else
|
||||||
return error("No Angel Type found.");
|
redirect(page_link_to('admin_angel_types'));
|
||||||
break;
|
|
||||||
|
|
||||||
case 'save' :
|
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
|
||||||
$id = $_REQUEST['id'];
|
|
||||||
else
|
|
||||||
return error("Incomplete call, missing AngelType ID.");
|
|
||||||
|
|
||||||
$angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
|
||||||
if (count($angel_type) > 0) {
|
|
||||||
list ($angel_type) = $angel_type;
|
|
||||||
|
|
||||||
$name = strip_request_item("name");
|
|
||||||
$man = strip_request_item("man");
|
|
||||||
|
|
||||||
sql_query("UPDATE `AngelTypes` SET `Name`='" . sql_escape($name) . "', `Man`='" . sql_escape($man) . "' WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
|
||||||
header("Location: " . page_link_to("admin_angel_types"));
|
|
||||||
} else
|
|
||||||
return error("No Angel Type found.");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'delete' :
|
|
||||||
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
|
|
||||||
$id = $_REQUEST['id'];
|
|
||||||
else
|
|
||||||
return error("Incomplete call, missing AngelType ID.");
|
|
||||||
|
|
||||||
$angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
|
||||||
if (count($angel_type) > 0) {
|
|
||||||
sql_query("DELETE FROM `AngelTypes` WHERE `TID`=" . sql_escape($id) . " LIMIT 1");
|
|
||||||
sql_query("DELETE FROM `NeededAngelTypes` WHERE `angel_type_id`=" . sql_escape($id) . " LIMIT 1");
|
|
||||||
header("Location: " . page_link_to("admin_angel_types"));
|
|
||||||
} else
|
|
||||||
return error("No Angel Type found.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return page(array (
|
||||||
|
buttons(array (
|
||||||
|
button(page_link_to('admin_angel_types') . '&show=edit', "Add", 'add')
|
||||||
|
)),
|
||||||
|
msg(),
|
||||||
|
table(array (
|
||||||
|
'name' => "Name",
|
||||||
|
'restricted' => "Restricted",
|
||||||
|
'actions' => ""
|
||||||
|
), $angel_types)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -63,7 +63,7 @@ function admin_rooms() {
|
||||||
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
||||||
if (count($room) > 0) {
|
if (count($room) > 0) {
|
||||||
list ($room) = $room;
|
list ($room) = $room;
|
||||||
$room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`TID` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`Name`");
|
$room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`");
|
||||||
|
|
||||||
$angel_types = "";
|
$angel_types = "";
|
||||||
foreach ($room_angel_types as $room_angel_type) {
|
foreach ($room_angel_types as $room_angel_type) {
|
||||||
|
@ -101,7 +101,7 @@ function admin_rooms() {
|
||||||
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
$room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($rid) . " LIMIT 1");
|
||||||
if (count($room) > 0) {
|
if (count($room) > 0) {
|
||||||
list ($room) = $room;
|
list ($room) = $room;
|
||||||
$room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`TID` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`Name`");
|
$room_angel_types = sql_select("SELECT * FROM `AngelTypes` LEFT OUTER JOIN `NeededAngelTypes` ON (`AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($rid) . ") ORDER BY `AngelTypes`.`name`");
|
||||||
|
|
||||||
$name = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Name']));
|
$name = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Name']));
|
||||||
$man = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Man']));
|
$man = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui", '', strip_tags($_REQUEST['Man']));
|
||||||
|
|
|
@ -21,7 +21,7 @@ function admin_shifts() {
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
|
|
||||||
// Engeltypen laden
|
// Engeltypen laden
|
||||||
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `Name`");
|
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
$needed_angel_types = array ();
|
$needed_angel_types = array ();
|
||||||
foreach ($types as $type)
|
foreach ($types as $type)
|
||||||
$needed_angel_types[$type['TID']] = 0;
|
$needed_angel_types[$type['TID']] = 0;
|
||||||
|
|
|
@ -168,7 +168,7 @@ function guest_register() {
|
||||||
$html .= "<tr><td>" . Get_Text("makeuser_Engelart") . "</td><td align=\"left\">\n";
|
$html .= "<tr><td>" . Get_Text("makeuser_Engelart") . "</td><td align=\"left\">\n";
|
||||||
$html .= "<select name=\"Art\">\n";
|
$html .= "<select name=\"Art\">\n";
|
||||||
|
|
||||||
$engel_types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `NAME`");
|
$engel_types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
|
||||||
foreach ($engel_types as $engel_type) {
|
foreach ($engel_types as $engel_type) {
|
||||||
$Name = $engel_type['Name'] . Get_Text("inc_schicht_engel");
|
$Name = $engel_type['Name'] . Get_Text("inc_schicht_engel");
|
||||||
$html .= "<option value=\"" . $Name . "\"";
|
$html .= "<option value=\"" . $Name . "\"";
|
||||||
|
|
|
@ -27,7 +27,7 @@ function user_myshifts() {
|
||||||
}
|
}
|
||||||
elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
||||||
$id = $_REQUEST['edit'];
|
$id = $_REQUEST['edit'];
|
||||||
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`Name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`TID`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
||||||
if (count($shift) > 0) {
|
if (count($shift) > 0) {
|
||||||
$shift = $shift[0];
|
$shift = $shift[0];
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ function user_shifts() {
|
||||||
$room_array[$room['RID']] = $room['Name'];
|
$room_array[$room['RID']] = $room['Name'];
|
||||||
|
|
||||||
// Engeltypen laden
|
// Engeltypen laden
|
||||||
$types = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`TID`) WHERE `shift_id`=" . sql_escape($shift_id) . " ORDER BY `AngelTypes`.`Name`");
|
$types = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE `shift_id`=" . sql_escape($shift_id) . " ORDER BY `AngelTypes`.`name`");
|
||||||
$needed_angel_types = array ();
|
$needed_angel_types = array ();
|
||||||
foreach ($types as $type)
|
foreach ($types as $type)
|
||||||
$needed_angel_types[$type['TID']] = $type['count'];
|
$needed_angel_types[$type['TID']] = $type['count'];
|
||||||
|
@ -162,7 +162,7 @@ function user_shifts() {
|
||||||
else
|
else
|
||||||
header("Location: " . page_link_to('user_shifts'));
|
header("Location: " . page_link_to('user_shifts'));
|
||||||
|
|
||||||
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `TID`=" . sql_escape($type_id) . " LIMIT 1");
|
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
|
||||||
if (count($type) == 0)
|
if (count($type) == 0)
|
||||||
header("Location: " . page_link_to('user_shifts'));
|
header("Location: " . page_link_to('user_shifts'));
|
||||||
$type = $type[0];
|
$type = $type[0];
|
||||||
|
@ -240,9 +240,9 @@ function user_shifts() {
|
||||||
$shift_row .= ' <a href="?p=user_shifts&edit_shift=' . $shift['SID'] . '">[edit]</a> <a href="?p=user_shifts&delete_shift=' . $shift['SID'] . '">[x]</a>';
|
$shift_row .= ' <a href="?p=user_shifts&edit_shift=' . $shift['SID'] . '">[edit]</a> <a href="?p=user_shifts&delete_shift=' . $shift['SID'] . '">[x]</a>';
|
||||||
$shift_row .= '<br />';
|
$shift_row .= '<br />';
|
||||||
$show_shift = false;
|
$show_shift = false;
|
||||||
$angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`TID`) WHERE `shift_id`=" . sql_escape($shift['SID']) . " AND `count` > 0 ORDER BY `AngelTypes`.`Name`");
|
$angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE `shift_id`=" . sql_escape($shift['SID']) . " AND `count` > 0 ORDER BY `AngelTypes`.`name`");
|
||||||
if (count($angeltypes) == 0)
|
if (count($angeltypes) == 0)
|
||||||
$angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`TID`) WHERE `room_id`=" . sql_escape($shift['RID']) . " AND `count` > 0 ORDER BY `AngelTypes`.`Name`");
|
$angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` JOIN `AngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id`) WHERE `room_id`=" . sql_escape($shift['RID']) . " AND `count` > 0 ORDER BY `AngelTypes`.`name`");
|
||||||
|
|
||||||
if (count($angeltypes) > 0) {
|
if (count($angeltypes) > 0) {
|
||||||
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0;
|
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0;
|
||||||
|
|
|
@ -1,26 +1,97 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
|
||||||
|
*/
|
||||||
|
function redirect($to) {
|
||||||
|
header("Location: " . $to, true, 302);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den gefilterten REQUEST Wert ohne Zeilenumbrüche zurück
|
||||||
|
*/
|
||||||
function strip_request_item($name) {
|
function strip_request_item($name) {
|
||||||
return preg_replace(
|
return strip_item($_REQUEST[$name]);
|
||||||
"/([^\p{L}\p{P}\p{Z}\p{N}]{1,})/ui",
|
|
||||||
'',
|
|
||||||
strip_tags($_REQUEST[$name])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw. eine ID sein könnte.
|
||||||
|
*/
|
||||||
|
function test_request_int($name) {
|
||||||
|
if (isset ($_REQUEST[$name]))
|
||||||
|
return preg_match("/^[0-9]*$/", $_REQUEST[$name]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
|
||||||
|
*/
|
||||||
function strip_request_item_nl($name) {
|
function strip_request_item_nl($name) {
|
||||||
return preg_replace(
|
return preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}+\n]{1,})/ui", '', strip_tags($_REQUEST[$name]));
|
||||||
"/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
|
|
||||||
'',
|
|
||||||
strip_tags($_REQUEST[$name])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function error($msg) {
|
/**
|
||||||
|
* Entfernt unerwünschte Zeichen
|
||||||
|
*/
|
||||||
|
function strip_item($item) {
|
||||||
|
return preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
||||||
|
*/
|
||||||
|
function msg() {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
return "";
|
||||||
|
$msg = $_SESSION['msg'];
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Information
|
||||||
|
*/
|
||||||
|
function info($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
|
return '<p class="info">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= info($msg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Fehlermeldung
|
||||||
|
*/
|
||||||
|
function error($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
return '<p class="error">' . $msg . '</p>';
|
return '<p class="error">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= error($msg, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function success($msg) {
|
/**
|
||||||
|
* Rendert eine Erfolgsmeldung
|
||||||
|
*/
|
||||||
|
function success($msg, $immediatly = false) {
|
||||||
|
if ($immediatly) {
|
||||||
|
if ($msg == "")
|
||||||
|
return "";
|
||||||
return '<p class="success">' . $msg . '</p>';
|
return '<p class="success">' . $msg . '</p>';
|
||||||
|
} else {
|
||||||
|
if (!isset ($_SESSION['msg']))
|
||||||
|
$_SESSION['msg'] = "";
|
||||||
|
$_SESSION['msg'] .= success($msg, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,6 +1,130 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = "<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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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>');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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('<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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 '<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>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 .= '<table' . ($data ? ' class="data"' : '') . '>';
|
||||||
|
$html .= '<thead><tr>';
|
||||||
|
foreach ($columns as $key => $column)
|
||||||
|
$html .= '<th>' . $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 . '"> </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>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert eine Toolbar mit Knöpfen
|
||||||
|
*/
|
||||||
|
function buttons($buttons = array ()) {
|
||||||
|
return '<div class="toolbar">' . join($buttons) . '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
// Load and render template
|
// Load and render template
|
||||||
function template_render($file, $data) {
|
function template_render($file, $data) {
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
|
|
|
@ -106,6 +106,7 @@ a.sprache img {
|
||||||
|
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldset hr {
|
fieldset hr {
|
||||||
|
@ -194,12 +195,22 @@ tr:hover .hidden {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error, .info, .success {
|
||||||
|
background: #f0f0f0;
|
||||||
|
border: 1px solid #888;
|
||||||
|
border-radius: 2px;
|
||||||
|
color: #000;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
color: #f00;
|
background: #f99;
|
||||||
|
border-color: #900;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success {
|
.success {
|
||||||
color: #090;
|
background: #9f9;
|
||||||
|
border-color: #090;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notice {
|
.notice {
|
||||||
|
@ -262,3 +273,73 @@ tr:hover .hidden {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
width: 42px;
|
width: 42px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
margin: 5px 0 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
background: #f0f0f0;
|
||||||
|
border: 1px solid #888;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 5px;
|
||||||
|
padding: 2px 5px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.form {
|
||||||
|
border: 1px solid #888;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin: 10px 0;
|
||||||
|
padding: 10px 10px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form_element {
|
||||||
|
/* clear: left; */
|
||||||
|
min-height: 32px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form_label {
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form_input {
|
||||||
|
margin-left: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form input[type="text"], .form textarea {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #888;
|
||||||
|
color: inherit;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
padding: 2px;
|
||||||
|
width: 350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form input[disabled="disabled"] {
|
||||||
|
background: #f0f0f0;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form input[type="submit"] {
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form input[type="checkbox"] {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue