Browse code

Initial commit

Benjamin Roth authored on07/09/2015 15:02:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,73 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media oxVoucher for Contao Open Source CMS
5
+ *
6
+ * Copyright (c) 2015 eSales Media
7
+ *
8
+ * @author  Benjamin Roth [benjamin@esales-media.de]
9
+ * @license proprietary
10
+ */
11
+
12
+namespace eSM_oxVoucher;
13
+
14
+abstract class ModuleVoucher extends \Module
15
+{
16
+
17
+	/**
18
+	 * Oxid Database Object
19
+	 * @var \Database|null
20
+	 */
21
+	protected $oxDB = null;
22
+
23
+	/**
24
+	 * Import Oxid database instance
25
+	 */
26
+	protected function importOxDbInstance()
27
+	{
28
+		$this->oxDB = Voucher::getOxDbInstance();
29
+	}
30
+
31
+	protected function setMessage($strMessage, $strType = 'info')
32
+	{
33
+
34
+		$strType = strtolower($strType);
35
+
36
+		if ($strMessage == '')
37
+		{
38
+			return;
39
+		}
40
+
41
+		if (!in_array(strtolower($strType), array('confirm','info','error')))
42
+		{
43
+			throw new \Exception("Invalid message type $strType");
44
+		}
45
+
46
+		if (!is_array($_SESSION['eSM_oxVoucher'][$strType]))
47
+		{
48
+			$_SESSION['eSM_oxVoucher'][$strType] = array();
49
+		}
50
+
51
+		$_SESSION['eSM_oxVoucher'][$strType][] = $strMessage;
52
+	}
53
+
54
+	protected function getMessages()
55
+	{
56
+		$strMessages = '';
57
+
58
+		foreach (array('confirm','info','error') as $strType)
59
+		{
60
+			if ($_SESSION['eSM_oxVoucher'][$strType])
61
+			{
62
+				foreach ($_SESSION['eSM_oxVoucher'][$strType] as $message)
63
+				{
64
+					$strMessages .= '<p class="'.$strType.'">'.$message.'</p>'."\n";
65
+				}
66
+			}
67
+		}
68
+
69
+		unset($_SESSION['eSM_oxVoucher']);
70
+
71
+		return $strMessages;
72
+	}
73
+}
0 74
\ No newline at end of file