summaryrefslogtreecommitdiff
path: root/includes/view
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/view
parentd50cc21f50cb3ec3afdabb74a20d81bd1a53dfbd (diff)
mysql to mysqli and a lot of cleanup and mvc
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/Shifts_view.php11
-rw-r--r--includes/view/Sprache_view.php36
-rw-r--r--includes/view/User_view.php45
3 files changed, 92 insertions, 0 deletions
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
new file mode 100644
index 00000000..824f519a
--- /dev/null
+++ b/includes/view/Shifts_view.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Calc shift length in format 12:23h.
+ * @param Shift $shift
+ */
+function shift_length($shift) {
+ $length = round(($shift['end'] - $shift['start']) / (60 * 60), 0) . ":";
+ $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
+ return $length;
+}
+?> \ No newline at end of file
diff --git a/includes/view/Sprache_view.php b/includes/view/Sprache_view.php
new file mode 100644
index 00000000..88c7435c
--- /dev/null
+++ b/includes/view/Sprache_view.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Names of available languages.
+ */
+$languages = array (
+ 'DE' => "Deutsch",
+ 'EN' => "English"
+);
+
+/**
+ * Display acutual translation of given text id.
+ * @param string $TextID
+ * @param bool $NoError
+ * @return string
+ */
+function Get_Text($TextID, $NoError = false) {
+ global $debug;
+
+ if (!isset ($_SESSION['Sprache']))
+ $_SESSION['Sprache'] = "EN";
+ if ($_SESSION['Sprache'] == "")
+ $_SESSION['Sprache'] = "EN";
+ if (isset ($_GET["SetLanguage"]))
+ $_SESSION['Sprache'] = $_GET["SetLanguage"];
+
+ $sprache_source = Sprache($TextID, $_SESSION['Sprache']);
+ if($sprache_source === false)
+ engelsystem_error("Unable to load text key.");
+ if($sprache_source == null) {
+ if($NoError && !$debug)
+ return "";
+ return $TextID;
+ }
+ return $sprache_source['Text'];
+}
+?> \ No newline at end of file
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
new file mode 100644
index 00000000..eb69b8c4
--- /dev/null
+++ b/includes/view/User_view.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Available T-Shirt sizes
+ */
+$tshirt_sizes = array (
+ '' => "Please select...",
+ 'S' => "S",
+ 'M' => "M",
+ 'L' => "L",
+ 'XL' => "XL",
+ '2XL' => "2XL",
+ '3XL' => "3XL",
+ '4XL' => "4XL",
+ '5XL' => "5XL",
+ 'S-G' => "S Girl",
+ 'M-G' => "M Girl",
+ 'L-G' => "L Girl",
+ 'XL-G' => "XL Girl"
+);
+
+/**
+ * Render a users avatar.
+ * @param User $user
+ * @return string
+ */
+function User_Avatar_render($user) {
+ return '<div class="avatar">&nbsp;<img src="pic/avatar/avatar' . $user['Avatar'] . '.gif"></div>';
+}
+
+/**
+ * Render a user nickname.
+ * @param User $user_source
+ * @return string
+ */
+function User_Nick_render($user_source) {
+ global $user, $privileges;
+ if($user['UID'] == $user_source['UID'] || in_array('user_shifts_admin', $privileges))
+ return '<a href="' . page_link_to('user_myshifts') . '&amp;id=' . $user_source['UID'] . '">' . htmlspecialchars($user_source['Nick']) . '</a>';
+ else
+ return htmlspecialchars($user_source['Nick']);
+}
+
+
+?> \ No newline at end of file