Browse code

Add customization fields for the displayed text.

Benjamin Roth authored on22/03/2019 16:56:28
Showing11 changed files
... ...
@@ -30,6 +30,11 @@
30 30
 
31 31
 namespace legalAgeCheck;
32 32
 
33
+use Contao\InsertTags;
34
+use Contao\PageModel;
35
+use Contao\LayoutModel;
36
+use Contao\PageRegular;
37
+use Contao\System;
33 38
 
34 39
 /**
35 40
  * Class LegalAgeCheck 
... ...
@@ -51,8 +56,12 @@ class LegalAgeCheck extends \Frontend
51 56
 	/**
52 57
 	 * Perform age check
53 58
 	 */
54
-	public function performAgeCheck(\PageModel $objPage, \LayoutModel $objLayout, \PageRegular $objPageRegular)
59
+	public function performAgeCheck(PageModel $objPage, LayoutModel $objLayout, PageRegular $objPageRegular)
55 60
 	{
61
+    if (System::getContainer()->get('kernel')->getEnvironment() != 'dev')
62
+    {
63
+      return;
64
+    }
56 65
 		// Skip age check if passed before
57 66
 		//if ($this->Session->get('legalAgeCheck_passed'))
58 67
 		if ($this->Input->cookie('legalAgeCheck_passed') || $objPage->es_ext_agecheck_ignorePage)
... ...
@@ -80,8 +89,8 @@ class LegalAgeCheck extends \Frontend
80 89
 		//$objModalBoxTemplate = new FrontendTemplate('agecheck_dialog_template');
81 90
 		
82 91
 		// Set template vars
83
-		$objTemplate->title = $GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['title'];
84
-		$objTemplate->text = $GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['text'];
92
+		$objTemplate->title = $objRootPage->es_ext_agecheck_title;
93
+		$objTemplate->text = str_replace(array("\r", "\n"),array("\\r","\\n"),$objRootPage->es_ext_agecheck_text);
85 94
 		$objTemplate->btn_over_18 = $GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['over_18'];
86 95
 		$objTemplate->btn_under_18 = $GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['under_18'];
87 96
 		$objTemplate->exitPageURL = $this->generateFrontendUrl($objExitPage->row(), null, null, true);
... ...
@@ -89,7 +98,7 @@ class LegalAgeCheck extends \Frontend
89 98
 		//$objTemplate->modalBoxTemplate = addcslashes($objModalBoxTemplate->parse(), "\\'\"&\n\r");
90 99
 		
91 100
 		// Add dialog code to page
92
-		$GLOBALS['TL_BODY'][] = $objTemplate->parse();
101
+		$GLOBALS['TL_BODY'][] = InsertTags::replaceInsertTags($objTemplate->parse());
93 102
 
94 103
 
95 104
 	}
96 105
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+<IfModule !mod_authz_core.c>
2
+  Order allow,deny
3
+  Allow from all
4
+</IfModule>
5
+<IfModule mod_authz_core.c>
6
+  Require all granted
7
+</IfModule>
0 8
\ No newline at end of file
... ...
@@ -35,7 +35,7 @@
35 35
 $GLOBALS['TL_DCA']['tl_page']['palettes']['root'] = str_replace('{meta_legend}', '{agecheck_legend:hide},es_ext_agecheck;{meta_legend}',$GLOBALS['TL_DCA']['tl_page']['palettes']['root']);
36 36
 $GLOBALS['TL_DCA']['tl_page']['palettes']['regular'] = str_replace('{meta_legend}', '{agecheck_legend:hide},es_ext_agecheck_ignorePage;{meta_legend}',$GLOBALS['TL_DCA']['tl_page']['palettes']['regular']);
37 37
 $GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'es_ext_agecheck';
38
-$GLOBALS['TL_DCA']['tl_page']['subpalettes']['es_ext_agecheck'] = 'es_ext_agecheck_exitPage';
38
+$GLOBALS['TL_DCA']['tl_page']['subpalettes']['es_ext_agecheck'] = 'es_ext_agecheck_exitPage,es_ext_agecheck_title,es_ext_agecheck_text';
39 39
 /**
40 40
  * Fields
41 41
  */
... ...
@@ -63,4 +63,50 @@ $GLOBALS['TL_DCA']['tl_page']['fields']['es_ext_agecheck_ignorePage'] = array
63 63
 	'exclude'                 => true,
64 64
 	'inputType'               => 'checkbox',
65 65
   'sql'                     => "char(1) NOT NULL default ''"
66
-);
67 66
\ No newline at end of file
67
+);
68
+
69
+$GLOBALS['TL_DCA']['tl_page']['fields']['es_ext_agecheck_title'] = array
70
+(
71
+  'label'                   => &$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_title'],
72
+  'exclude'                 => true,
73
+  'inputType'               => 'text',
74
+  'eval'                    => array('mandatory'=>true, 'rgxp'=>'extnd'),
75
+  'sql'                     => "varchar(255) NOT NULL default ''"
76
+);
77
+
78
+$GLOBALS['TL_DCA']['tl_page']['fields']['es_ext_agecheck_text'] = array
79
+(
80
+  'label'                   => &$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_text'],
81
+  'exclude'                 => true,
82
+  'inputType'               => 'textarea',
83
+  'load_callback'            => array
84
+  (
85
+    array('tl_page_legalAgeCheck', 'setDefaultLegalAgeText')
86
+  ),
87
+  'save_callback'            => array
88
+  (
89
+    array('tl_page_legalAgeCheck', 'setDefaultLegalAgeText')
90
+  ),
91
+  'eval'                    => array('rte'=>'tinyMCE', 'minlen'=>1, 'allowHtml'=>true),
92
+  'sql'                     => "text NULL"
93
+);
94
+
95
+class tl_page_legalAgeCheck extends \Backend
96
+{
97
+  /**
98
+   * Return default text if value is empty
99
+   *
100
+   * @param $varValue
101
+   * @param \DataContainer $dc
102
+   * @return String
103
+   */
104
+  public function setDefaultLegalAgeText($varValue, \DataContainer $dc)
105
+  {
106
+    if (!$varValue)
107
+    {
108
+      return $GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['text'];
109
+    }
110
+
111
+    return $varValue;
112
+  }
113
+}
68 114
\ No newline at end of file
69 115
deleted file mode 100644
... ...
@@ -1,43 +0,0 @@
1
-<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2
-
3
-/**
4
- * Contao Open Source CMS
5
- * Copyright (C) 2005-2011 Leo Feyer
6
- *
7
- * Formerly known as TYPOlight Open Source CMS.
8
- *
9
- * This program is free software: you can redistribute it and/or
10
- * modify it under the terms of the GNU Lesser General Public
11
- * License as published by the Free Software Foundation, either
12
- * version 3 of the License, or (at your option) any later version.
13
- * 
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * Lesser General Public License for more details.
18
- * 
19
- * You should have received a copy of the GNU Lesser General Public
20
- * License along with this program. If not, please visit the Free
21
- * Software Foundation website at <http://www.gnu.org/licenses/>.
22
- *
23
- * PHP version 5
24
- * @copyright  eSales Media 2012 
25
- * @author     Benjamin Roth <www.esales-media.de> 
26
- * @package    legalAgeCheck 
27
- * @license    GNU/LGPL 
28
- * @filesource
29
- */
30
-
31
-
32
-/**
33
- * Back end modules
34
- */
35
-$GLOBALS['TL_LANG']['MOD'][''] = array('', '');
36
-
37
-
38
-/**
39
- * Front end modules
40
- */
41
-$GLOBALS['TL_LANG']['FMD'][''] = array('', '');
42
-
43
-?>
44 0
\ No newline at end of file
... ...
@@ -35,6 +35,8 @@
35 35
 $GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck'] = array('Altersabfrage', 'Es erscheint eine Dialogbox mit der Frage, ob der User schon Volljährig ist.');
36 36
 $GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_exitPage'] = array('Ausstiegs-/Fallbackseite', 'Seite, die geladen werden soll, wenn der User noch nicht volljährig ist, oder Javascript deaktiviert ist.');
37 37
 $GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_ignorePage'] = array('Alterscheck ignorieren', 'Keine Altersabfrage auf dieser Seite, falls aktiviert.');
38
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_title'] = array('Alterscheck-Titel', 'Die Überschrift des Altersabfrage-Fensters.');
39
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_text'] = array('Alterscheck-Text', 'Der Text der Altersabfrage.');
38 40
 
39 41
 
40 42
 /**
... ...
@@ -32,6 +32,9 @@
32 32
 /**
33 33
  * Miscellaneous
34 34
  */
35
-$GLOBALS['TL_LANG']['MSC'][''] = '';
35
+$GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['title'] = 'Age verification';
36
+$GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['text'] = 'Are you 18 years of age or older?';
37
+$GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['over_18'] = 'Yes, I am at least 18';
38
+$GLOBALS['TL_LANG']['MSC']['es_legalagecheck']['under_18'] = 'No';
36 39
 
37 40
 ?>
38 41
\ No newline at end of file
39 42
deleted file mode 100644
... ...
@@ -1,43 +0,0 @@
1
-<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2
-
3
-/**
4
- * Contao Open Source CMS
5
- * Copyright (C) 2005-2011 Leo Feyer
6
- *
7
- * Formerly known as TYPOlight Open Source CMS.
8
- *
9
- * This program is free software: you can redistribute it and/or
10
- * modify it under the terms of the GNU Lesser General Public
11
- * License as published by the Free Software Foundation, either
12
- * version 3 of the License, or (at your option) any later version.
13
- * 
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * Lesser General Public License for more details.
18
- * 
19
- * You should have received a copy of the GNU Lesser General Public
20
- * License along with this program. If not, please visit the Free
21
- * Software Foundation website at <http://www.gnu.org/licenses/>.
22
- *
23
- * PHP version 5
24
- * @copyright  eSales Media 2012 
25
- * @author     Benjamin Roth <www.esales-media.de> 
26
- * @package    Paketname 
27
- * @license    Commercial 
28
- * @filesource
29
- */
30
-
31
-
32
-/**
33
- * Back end modules
34
- */
35
-$GLOBALS['TL_LANG']['MOD'][''] = array('', '');
36
-
37
-
38
-/**
39
- * Front end modules
40
- */
41
-$GLOBALS['TL_LANG']['FMD'][''] = array('', '');
42
-
43
-?>
44 0
\ No newline at end of file
45 1
new file mode 100644
... ...
@@ -0,0 +1,53 @@
1
+<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2
+
3
+/**
4
+ * Contao Open Source CMS
5
+ * Copyright (C) 2005-2011 Leo Feyer
6
+ *
7
+ * Formerly known as TYPOlight Open Source CMS.
8
+ *
9
+ * This program is free software: you can redistribute it and/or
10
+ * modify it under the terms of the GNU Lesser General Public
11
+ * License as published by the Free Software Foundation, either
12
+ * version 3 of the License, or (at your option) any later version.
13
+ * 
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ * Lesser General Public License for more details.
18
+ * 
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with this program. If not, please visit the Free
21
+ * Software Foundation website at <http://www.gnu.org/licenses/>.
22
+ *
23
+ * PHP version 5
24
+ * @copyright  eSales Media 2012 
25
+ * @author     Benjamin Roth <www.esales-media.de> 
26
+ * @package    legalAgeCheck 
27
+ * @license    GNU/LGPL 
28
+ * @filesource
29
+ */
30
+
31
+
32
+/**
33
+ * Fields
34
+ */
35
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck'] = array('Age verification', 'An age verification modal will be shown on every page.');
36
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_exitPage'] = array('Fallback page', 'The page the user will be redirected to if they\'re not of full age.');
37
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_ignorePage'] = array('Ignore age verification', 'Do not show the age verification modal on this page.');
38
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_title'] = array('Age verification title', 'The headline of the age verification modal.');
39
+$GLOBALS['TL_LANG']['tl_page']['es_ext_agecheck_text'] = array('Age verification text', 'The text of the age verification modal.');
40
+
41
+
42
+/**
43
+ * Reference
44
+ */
45
+$GLOBALS['TL_LANG']['tl_page'][''] = '';
46
+
47
+/**
48
+ * Legends
49
+ */
50
+$GLOBALS['TL_LANG']['tl_page']['agecheck_legend'] = 'Age verification';
51
+
52
+
53
+?>
0 54
\ No newline at end of file
1 55
deleted file mode 100644
... ...
@@ -1,53 +0,0 @@
1
-<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
2
-
3
-/**
4
- * Contao Open Source CMS
5
- * Copyright (C) 2005-2011 Leo Feyer
6
- *
7
- * Formerly known as TYPOlight Open Source CMS.
8
- *
9
- * This program is free software: you can redistribute it and/or
10
- * modify it under the terms of the GNU Lesser General Public
11
- * License as published by the Free Software Foundation, either
12
- * version 3 of the License, or (at your option) any later version.
13
- * 
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- * Lesser General Public License for more details.
18
- * 
19
- * You should have received a copy of the GNU Lesser General Public
20
- * License along with this program. If not, please visit the Free
21
- * Software Foundation website at <http://www.gnu.org/licenses/>.
22
- *
23
- * PHP version 5
24
- * @copyright  eSales Media 2012 
25
- * @author     Benjamin Roth <www.esales-media.de> 
26
- * @package    Paketname 
27
- * @license    Commercial 
28
- * @filesource
29
- */
30
-
31
-
32
-/**
33
- * Fields
34
- */
35
-$GLOBALS['TL_LANG']['tl_skeleton'][''] = array('', '');
36
-
37
-
38
-/**
39
- * Reference
40
- */
41
-$GLOBALS['TL_LANG']['tl_skeleton'][''] = '';
42
-
43
-
44
-/**
45
- * Buttons
46
- */
47
-$GLOBALS['TL_LANG']['tl_skeleton']['new']    = array('', '');
48
-$GLOBALS['TL_LANG']['tl_skeleton']['edit']   = array('', '');
49
-$GLOBALS['TL_LANG']['tl_skeleton']['copy']   = array('', '');
50
-$GLOBALS['TL_LANG']['tl_skeleton']['delete'] = array('', '');
51
-$GLOBALS['TL_LANG']['tl_skeleton']['show']   = array('', '');
52
-
53
-?>
54 0
\ No newline at end of file
... ...
@@ -6,7 +6,7 @@ $GLOBALS['TL_CSS'][] = 'system/modules/legalAgeCheck/assets/css/vex-theme-defaul
6 6
 <script>
7 7
 
8 8
 	var comPromo = vex.dialog.open({
9
-		message: '<h1 class="vex-header"><?php echo $this->title; ?></h1>' +
9
+		unsafeMessage: '<h1 class="vex-header"><?php echo $this->title; ?></h1>' +
10 10
 		'<?php echo $this->text; ?>',
11 11
 		overlayClosesOnClick: false,
12 12
 		escapeButtonCloses: false,
13 13
deleted file mode 100644
... ...
@@ -1,9 +0,0 @@
1
-<div class="simple-modal-header">
2
-	<h1>{_TITLE_}</h1>
3
-</div>
4
-<div class="simple-modal-body">
5
-	<div class="contents">
6
-		{_CONTENTS_}
7
-	</div>
8
-</div>
9
-<div class="simple-modal-footer"></div>
10 0
\ No newline at end of file