Browse code

Initial commit

Benjamin Roth authored on26/03/2015 16:12:11
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media reveal toolkit for Contao Open Source CMS
5
+ *
6
+ * Copyright (C) 2015 eSales Media
7
+ *
8
+ * @package    eSM_onePage
9
+ * @link       http://www.esales-media.de
10
+ * @license    commercial
11
+ *
12
+ * @author     Benjamin Roth <benjamin@esales-media.de>
13
+ */
14
+
15
+namespace eSalesMedia\Reveal;
16
+
17
+class RevealHooks extends \Controller
18
+{
19
+
20
+	/**
21
+	 * Array containing all fields which shouldn't use reveal options
22
+	 * @var array
23
+	 */
24
+	protected $arrNoReveal = array('__selector__','html');
25
+
26
+	/**
27
+	 * Hook for adding reveal fields to content elements
28
+	 * @param $strName
29
+	 */
30
+	public function eSMLoadDataContainer($strName)
31
+	{
32
+		if ($strName != 'tl_content')
33
+		{
34
+			return;
35
+		}
36
+
37
+		// Hook in the reveal fields
38
+		if (is_array($GLOBALS['TL_DCA']['tl_content']['palettes']))
39
+		{
40
+			foreach (array_keys($GLOBALS['TL_DCA']['tl_content']['palettes']) as $k)
41
+			{
42
+				if (!in_array($k,$this->arrNoReveal))
43
+				{
44
+					$strReveal = ';{reveal_legend:hide},eSM_rv_reveal';
45
+					$intPos = strpos($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], ';{expert_legend');
46
+					$intDupe = strpos($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], ';{reveal_legend:hide');
47
+					if ($intPos !== false && $intDupe === false)
48
+					{
49
+						$GLOBALS['TL_DCA']['tl_content']['palettes'][$k] =
50
+							substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], 0, $intPos) .
51
+							$strReveal .
52
+							substr($GLOBALS['TL_DCA']['tl_content']['palettes'][$k], $intPos);
53
+					}
54
+					else if ($intDupe === false)
55
+					{
56
+						$GLOBALS['TL_DCA']['tl_content']['palettes'][$k] .= $strReveal;
57
+					}
58
+				}
59
+			}
60
+		}
61
+	}
62
+}
0 63
\ No newline at end of file