From 7313e15ce8236e19331fb6639a3a5b97c8f06ecd Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 2 Jan 2017 03:57:23 +0100 Subject: PSR-2 formatting --- includes/helper/email_helper.php | 32 ++++++------ includes/helper/error_helper.php | 7 ++- includes/helper/graph_helper.php | 33 ++++++------ includes/helper/internationalization_helper.php | 69 +++++++++++++------------ includes/helper/message_helper.php | 53 ++++++++++--------- 5 files changed, 99 insertions(+), 95 deletions(-) (limited to 'includes/helper') diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php index 0ef4326a..934193e2 100644 --- a/includes/helper/email_helper.php +++ b/includes/helper/email_helper.php @@ -1,25 +1,25 @@ "); - if ($result === false) { - engelsystem_error('Unable to send email.'); - } +function engelsystem_email($address, $title, $message) +{ + $result = mail($address, $title, $message, "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem "); + if ($result === false) { + engelsystem_error('Unable to send email.'); + } } - -?> diff --git a/includes/helper/error_helper.php b/includes/helper/error_helper.php index 58d0ac86..9314a57a 100644 --- a/includes/helper/error_helper.php +++ b/includes/helper/error_helper.php @@ -5,8 +5,7 @@ * * @param string $message */ -function engelsystem_error($message) { - raw_output($message); +function engelsystem_error($message) +{ + raw_output($message); } - -?> \ No newline at end of file diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php index 42a6c07a..c2d0f8a2 100644 --- a/includes/helper/graph_helper.php +++ b/includes/helper/graph_helper.php @@ -7,35 +7,34 @@ * @param unknown $colors colors for the data rows * @param unknown $data the data */ -function bargraph($dom_id, $key, $row_names, $colors, $data) { - $labels = []; - foreach ($data as $dataset) { - $labels[] = $dataset[$key]; - } - - $datasets = []; - foreach ($row_names as $row_key => $name) { - $values = []; +function bargraph($dom_id, $key, $row_names, $colors, $data) +{ + $labels = []; foreach ($data as $dataset) { - $values[] = $dataset[$row_key]; + $labels[] = $dataset[$key]; } - $datasets[] = [ + + $datasets = []; + foreach ($row_names as $row_key => $name) { + $values = []; + foreach ($data as $dataset) { + $values[] = $dataset[$row_key]; + } + $datasets[] = [ 'label' => $name, 'fillColor' => $colors[$row_key], - 'data' => $values + 'data' => $values ]; - } + } - return ' + return ' '; } - -?> \ No newline at end of file diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php index a537ef3d..4abf8c4d 100644 --- a/includes/helper/internationalization_helper.php +++ b/includes/helper/internationalization_helper.php @@ -1,7 +1,7 @@ "Deutsch", - 'en_US.UTF-8' => "English" + 'en_US.UTF-8' => "English" ]; $default_locale = 'en_US.UTF-8'; @@ -9,47 +9,51 @@ $default_locale = 'en_US.UTF-8'; /** * Return currently active locale */ -function locale() { - return $_SESSION['locale']; +function locale() +{ + return $_SESSION['locale']; } /** * Returns two letter language code from currently active locale */ -function locale_short() { - return substr(locale(), 0, 2); +function locale_short() +{ + return substr(locale(), 0, 2); } /** * Initializes gettext for internationalization and updates the sessions locale to use for translation. */ -function gettext_init() { - global $locales, $default_locale; +function gettext_init() +{ + global $locales, $default_locale; - if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) { - $_SESSION['locale'] = $_REQUEST['set_locale']; - } elseif (! isset($_SESSION['locale'])) { - $_SESSION['locale'] = $default_locale; - } + if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) { + $_SESSION['locale'] = $_REQUEST['set_locale']; + } elseif (! isset($_SESSION['locale'])) { + $_SESSION['locale'] = $default_locale; + } - gettext_locale(); - bindtextdomain('default', realpath(__DIR__ . '/../../locale')); - bind_textdomain_codeset('default', 'UTF-8'); - textdomain('default'); + gettext_locale(); + bindtextdomain('default', realpath(__DIR__ . '/../../locale')); + bind_textdomain_codeset('default', 'UTF-8'); + textdomain('default'); } /** * Swich gettext locale. * - * @param string $locale + * @param string $locale */ -function gettext_locale($locale = null) { - if ($locale == null) { - $locale = $_SESSION['locale']; - } +function gettext_locale($locale = null) +{ + if ($locale == null) { + $locale = $_SESSION['locale']; + } - putenv('LC_ALL=' . $locale); - setlocale(LC_ALL, $locale); + putenv('LC_ALL=' . $locale); + setlocale(LC_ALL, $locale); } /** @@ -57,15 +61,14 @@ function gettext_locale($locale = null) { * * @return string */ -function make_langselect() { - global $locales; - $URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale="; +function make_langselect() +{ + global $locales; + $URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale="; - $items = []; - foreach ($locales as $locale => $name) { - $items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '' . $name . ' ' . $name); - } - return $items; + $items = []; + foreach ($locales as $locale => $name) { + $items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '' . $name . ' ' . $name); + } + return $items; } - -?> \ No newline at end of file diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php index 37fc84bb..323eee4d 100644 --- a/includes/helper/message_helper.php +++ b/includes/helper/message_helper.php @@ -3,51 +3,54 @@ /** * Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher */ -function msg() { - if (! isset($_SESSION['msg'])) { - return ""; - } - $msg = $_SESSION['msg']; - $_SESSION['msg'] = ""; - return $msg; +function msg() +{ + if (! isset($_SESSION['msg'])) { + return ""; + } + $msg = $_SESSION['msg']; + $_SESSION['msg'] = ""; + return $msg; } /** * Rendert eine Information */ -function info($msg, $immediatly = false) { - return alert('info', $msg, $immediatly); +function info($msg, $immediatly = false) +{ + return alert('info', $msg, $immediatly); } /** * Rendert eine Fehlermeldung */ -function error($msg, $immediatly = false) { - return alert('danger', $msg, $immediatly); +function error($msg, $immediatly = false) +{ + return alert('danger', $msg, $immediatly); } /** * Rendert eine Erfolgsmeldung */ -function success($msg, $immediatly = false) { - return alert('success', $msg, $immediatly); +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 ($msg == "") { - return ""; +function alert($class, $msg, $immediatly = false) +{ + if ($immediatly) { + if ($msg == "") { + return ""; + } + return '
' . $msg . '
'; } - return '
' . $msg . '
'; - } - if (! isset($_SESSION['msg'])) { - $_SESSION['msg'] = ""; - } - $_SESSION['msg'] .= alert($class, $msg, true); + if (! isset($_SESSION['msg'])) { + $_SESSION['msg'] = ""; + } + $_SESSION['msg'] .= alert($class, $msg, true); } - -?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf