prohibit inline control structures on helpers

main
msquare 8 years ago
parent bd9003f5d5
commit 5170fd7f6e

@ -3,8 +3,9 @@
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) { function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) {
global $user; global $user;
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
return true; return true;
}
gettext_locale($recipient_user['Sprache']); gettext_locale($recipient_user['Sprache']);

@ -9,14 +9,16 @@
*/ */
function bargraph($id, $key, $row_names, $colors, $data) { function bargraph($id, $key, $row_names, $colors, $data) {
$labels = []; $labels = [];
foreach ($data as $dataset) foreach ($data as $dataset) {
$labels[] = $dataset[$key]; $labels[] = $dataset[$key];
}
$datasets = []; $datasets = [];
foreach ($row_names as $row_key => $name) { foreach ($row_names as $row_key => $name) {
$values = []; $values = [];
foreach ($data as $dataset) foreach ($data as $dataset) {
$values[] = $dataset[$row_key]; $values[] = $dataset[$row_key];
}
$datasets[] = [ $datasets[] = [
'label' => $name, 'label' => $name,
'fillColor' => $colors[$row_key], 'fillColor' => $colors[$row_key],

@ -26,10 +26,11 @@ function locale_short() {
function gettext_init() { function gettext_init() {
global $locales, $default_locale; global $locales, $default_locale;
if (isset($_REQUEST['set_locale']) && in_array($_REQUEST['set_locale'], array_keys($locales))) if (isset($_REQUEST['set_locale']) && in_array($_REQUEST['set_locale'], array_keys($locales))) {
$_SESSION['locale'] = $_REQUEST['set_locale']; $_SESSION['locale'] = $_REQUEST['set_locale'];
elseif (! isset($_SESSION['locale'])) } elseif (! isset($_SESSION['locale'])) {
$_SESSION['locale'] = $default_locale; $_SESSION['locale'] = $default_locale;
}
gettext_locale(); gettext_locale();
bindtextdomain('default', '../locale'); bindtextdomain('default', '../locale');
@ -43,8 +44,9 @@ function gettext_init() {
* @param string $locale * @param string $locale
*/ */
function gettext_locale($locale = null) { function gettext_locale($locale = null) {
if ($locale == null) if ($locale == null) {
$locale = $_SESSION['locale']; $locale = $_SESSION['locale'];
}
putenv('LC_ALL=' . $locale); putenv('LC_ALL=' . $locale);
setlocale(LC_ALL, $locale); setlocale(LC_ALL, $locale);
@ -60,8 +62,9 @@ function make_langselect() {
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale="; $URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
$items = array(); $items = array();
foreach ($locales as $locale => $name) foreach ($locales as $locale => $name) {
$items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name); $items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name);
}
return $items; return $items;
} }

@ -4,8 +4,9 @@
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher * Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
*/ */
function msg() { function msg() {
if (! isset($_SESSION['msg'])) if (! isset($_SESSION['msg'])) {
return ""; return "";
}
$msg = $_SESSION['msg']; $msg = $_SESSION['msg'];
$_SESSION['msg'] = ""; $_SESSION['msg'] = "";
return $msg; return $msg;
@ -15,44 +16,37 @@ function msg() {
* Rendert eine Information * Rendert eine Information
*/ */
function info($msg, $immediatly = false) { function info($msg, $immediatly = false) {
if ($immediatly) { return alert('info', $msg, $immediatly);
if ($msg == "")
return "";
return '<div class="alert alert-info">' . $msg . '</div>';
} else {
if (! isset($_SESSION['msg']))
$_SESSION['msg'] = "";
$_SESSION['msg'] .= info($msg, true);
}
} }
/** /**
* Rendert eine Fehlermeldung * Rendert eine Fehlermeldung
*/ */
function error($msg, $immediatly = false) { function error($msg, $immediatly = false) {
if ($immediatly) { return alert('danger', $msg, $immediatly);
if ($msg == "")
return "";
return '<div class="alert alert-danger">' . $msg . '</div>';
} else {
if (! isset($_SESSION['msg']))
$_SESSION['msg'] = "";
$_SESSION['msg'] .= error($msg, true);
}
} }
/** /**
* Rendert eine Erfolgsmeldung * Rendert eine Erfolgsmeldung
*/ */
function success($msg, $immediatly = false) { function success($msg, $immediatly = false) {
return alert('success', $msg, $immediatly);
}
/**
* Renders an alert with given alert-* class.
*/
function alert($class, $msg, $immediatly = false) {
if ($immediatly) { if ($immediatly) {
if ($msg == "") if ($msg == "") {
return ""; return "";
return '<div class="alert alert-success">' . $msg . '</div>'; }
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
} else { } else {
if (! isset($_SESSION['msg'])) if (! isset($_SESSION['msg'])) {
$_SESSION['msg'] = ""; $_SESSION['msg'] = "";
$_SESSION['msg'] .= success($msg, true); }
$_SESSION['msg'] .= alert($class, $msg, true);
} }
} }

@ -313,13 +313,13 @@ function guest_login() {
return page([ return page([
div('col-md-12', [ div('col-md-12', [
msg(),
div('row', [ div('row', [
div('col-md-4', [ div('col-md-4', [
EventConfig_countdown_page($event_config) EventConfig_countdown_page($event_config)
]), ]),
div('col-md-4', [ div('col-md-4', [
heading(login_title(), 2), heading(login_title(), 2),
msg(),
form([ form([
form_text('nick', _("Nick"), $nick), form_text('nick', _("Nick"), $nick),
form_password('password', _("Password")), form_password('password', _("Password")),

Loading…
Cancel
Save