Browse code

Initial commit

Benjamin Roth authored on13/07/2016 09:17:47
Showing18 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+;;
2
+; List modules which are required to be loaded beforehand
3
+;;
4
+requires[] = "core"
5
+
6
+;;
7
+; Configure what you want the autoload creator to register
8
+;;
9
+register_namespaces = true
10
+register_classes    = true
11
+register_templates  = true
12
+
13
+;;
14
+; Override the default configuration for certain sub directories
15
+;;
16
+[vendor/*]
17
+register_namespaces = false
18
+register_classes    = false
19
+register_templates  = false
0 20
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Register the namespaces
14
+ */
15
+ClassLoader::addNamespaces(array
16
+(
17
+	'eSM_artLayout',
18
+));
19
+
20
+/**
21
+ * Register the classes
22
+ */
23
+ClassLoader::addClasses(array
24
+(
25
+	// Models
26
+	'eSM_artLayout\ArticleLayoutsModel'     => 'system/modules/eSM_artLayout/models/ArticleLayoutsModel.php',
27
+
28
+	// Modules
29
+	'eSM_artLayout\ModuleArticle'           => 'system/modules/eSM_artLayout/modules/ModuleArticle.php',
30
+));
31
+
32
+/**
33
+ * Register the templates
34
+ */
35
+TemplateLoader::addFiles(array
36
+(
37
+	'mod_article'      => 'system/modules/eSM_artLayout/templates/modules',
38
+));
0 39
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+$GLOBALS['BE_MOD']['design']['themes']['tables'][] = 'tl_article_layouts';
13
+
14
+$GLOBALS['TL_EASY_THEMES_MODULES']['artLayout'] = array
15
+(
16
+  'href_fragment' => 'table=tl_article_layouts',
17
+  'icon'          => 'system/themes/##backend_theme##/images/themes.gif',
18
+);
0 19
new file mode 100644
... ...
@@ -0,0 +1,130 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Callback
14
+ */
15
+
16
+$GLOBALS['TL_DCA']['tl_article']['config']['onload_callback'][] = array('tl_article_eSM_artLayout','registerSubPalettes');
17
+
18
+/**
19
+ * Extend default palette
20
+ */
21
+$GLOBALS['TL_DCA']['tl_article']['palettes']['__selector__'][] = 'es_type';
22
+$GLOBALS['TL_DCA']['tl_article']['palettes']['default'] = str_replace('customTpl;', 'customTpl,es_type;', $GLOBALS['TL_DCA']['tl_article']['palettes']['default']);
23
+
24
+
25
+/**
26
+ * Add fields to tl_article
27
+ */
28
+$GLOBALS['TL_DCA']['tl_article']['fields']['guests']['eval']['tl_class'] .= ' m12';
29
+
30
+$GLOBALS['TL_DCA']['tl_article']['fields']['es_type'] = array
31
+(
32
+  'label'                   => &$GLOBALS['TL_LANG']['tl_article']['es_type'],
33
+  'exclude'                 => true,
34
+  'inputType'               => 'select',
35
+  'options_callback'        => array('tl_article_eSM_artLayout','getArticleLayouts'),
36
+  'eval'                    => array('tl_class'=>'w50', 'includeBlankOption'=>true, 'submitOnChange'=>true),
37
+  'sql'                     => "int(10) unsigned NOT NULL default '0'"
38
+);
39
+
40
+$GLOBALS['TL_DCA']['tl_article']['fields']['es_maxWidth'] = array
41
+(
42
+  'label'                   => &$GLOBALS['TL_LANG']['tl_article']['es_maxWidth'],
43
+  'exclude'                 => true,
44
+  'inputType'               => 'checkbox',
45
+  'eval'                    => array('tl_class'=>'w50 m12'),
46
+  'sql'                     => "char(1) NOT NULL default '1'"
47
+);
48
+
49
+$GLOBALS['TL_DCA']['tl_article']['fields']['es_backgroundSRC'] = array
50
+(
51
+  'label'                   => &$GLOBALS['TL_LANG']['tl_article']['es_backgroundSRC'],
52
+  'exclude'                 => true,
53
+  'inputType'               => 'fileTree',
54
+  'eval'                    => array('filesOnly'=>true, 'fieldType'=>'radio', 'mandatory'=>true, 'tl_class'=>'clr', 'extensions' => \Config::get('validImageTypes')),
55
+  'sql'                     => "binary(16) NULL"
56
+);
57
+
58
+$GLOBALS['TL_DCA']['tl_article']['fields']['es_size'] = array
59
+(
60
+  'label'                   => &$GLOBALS['TL_LANG']['tl_article']['es_size'],
61
+  'exclude'                 => true,
62
+  'inputType'               => 'imageSize',
63
+  'options'                 => System::getImageSizes(),
64
+  'reference'               => &$GLOBALS['TL_LANG']['MSC'],
65
+  'eval'                    => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
66
+  'sql'                     => "varchar(64) NOT NULL default ''"
67
+);
68
+
69
+/**
70
+ * Provide miscellaneous methods that are used by the data configuration array.
71
+ *
72
+ * @author Benjamin Roth <http://www.esales-media.de>
73
+ */
74
+class tl_article_eSM_artLayout extends Backend
75
+{
76
+
77
+  /**
78
+   * Import the back end user object
79
+   */
80
+  public function __construct()
81
+  {
82
+    parent::__construct();
83
+    $this->import('BackendUser', 'User');
84
+  }
85
+
86
+  public function getArticleLayouts(\DataContainer $dc)
87
+  {
88
+
89
+    $arrLayoutIds = array();
90
+    $PageModel = \PageModel::findWithDetails($dc->activeRecord->pid);
91
+    if ($PageModel->layout)
92
+    {
93
+      $arrLayoutIds[] = $PageModel->layout;
94
+    }
95
+    if ($PageModel->mobileLayout)
96
+    {
97
+      $arrLayoutIds[] = $PageModel->mobileLayout;
98
+    }
99
+
100
+    $Themes = \ThemeModel::findMultipleByIds($arrLayoutIds);
101
+    if ($Themes === null)
102
+    {
103
+      return array();
104
+    }
105
+
106
+    $arrArticleLayouts = array();
107
+    $ArticleLayouts = \Database::getInstance()->execute("SELECT id, title FROM tl_article_layouts WHERE ".\Database::getInstance()->findInSet('pid',$Themes->fetchEach('id'))." ORDER BY sorting");
108
+
109
+    while ($ArticleLayouts->next())
110
+    {
111
+      $arrArticleLayouts[$ArticleLayouts->id] = $ArticleLayouts->title;
112
+    }
113
+
114
+    return $arrArticleLayouts;
115
+  }
116
+
117
+  public function registerSubPalettes(\DataContainer $dc)
118
+  {
119
+    $Layouts = \Database::getInstance()->execute("SELECT * FROM tl_article_layouts");
120
+
121
+    while ($Layouts->next())
122
+    {
123
+      if ($Layouts->showBackgroundImage)
124
+      {
125
+        $GLOBALS['TL_DCA']['tl_article']['subpalettes']['es_type_'.$Layouts->id] = 'es_backgroundSRC';
126
+      }
127
+    }
128
+
129
+  }
130
+}
0 131
new file mode 100644
... ...
@@ -0,0 +1,295 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+
13
+/**
14
+ * Table tl_article_layouts
15
+ */
16
+$GLOBALS['TL_DCA']['tl_article_layouts'] = array
17
+(
18
+
19
+	// Config
20
+	'config' => array
21
+	(
22
+		'dataContainer'             => 'Table',
23
+		'ptable'                    => 'tl_theme',
24
+		'switchToEdit'              => true,
25
+		'onload_callback' => array
26
+		(
27
+			array('tl_article_layouts', 'checkPermission'),
28
+		),
29
+		'enableVersioning'          => true,
30
+		'sql' => array
31
+		(
32
+			'keys' => array
33
+			(
34
+				'id' => 'primary'
35
+			)
36
+		)
37
+	),
38
+
39
+	// List
40
+	'list' => array
41
+	(
42
+		'sorting' => array
43
+		(
44
+			'mode'                    => 4,
45
+			'flag'                    => 11,
46
+			'fields'                  => array('sorting'),
47
+			'panelLayout'             => 'filter;search,limit',
48
+			'headerFields'            => array('name', 'author', 'tstamp'),
49
+			'child_record_callback'   => array('tl_article_layouts', 'listLayout'),
50
+			'disableGrouping'         => true
51
+		),
52
+		'global_operations' => array
53
+		(
54
+			'all' => array
55
+			(
56
+				'label'                 => &$GLOBALS['TL_LANG']['MSC']['all'],
57
+				'href'                  => 'act=select',
58
+				'class'                 => 'header_edit_all',
59
+				'attributes'            => 'onclick="Backend.getScrollOffset()" accesskey="e"'
60
+			)
61
+		),
62
+		'operations' => array
63
+		(
64
+			'edit' => array
65
+			(
66
+				'label'                 => &$GLOBALS['TL_LANG']['tl_article_layouts']['edit'],
67
+				'href'                  => 'table=tl_article_layouts&amp;act=edit',
68
+				'icon'                  => 'edit.gif'
69
+			),
70
+			'copy' => array
71
+			(
72
+				'label'                 => &$GLOBALS['TL_LANG']['tl_article_layouts']['copy'],
73
+				'href'                  => 'act=paste&amp;mode=copy',
74
+				'icon'                  => 'copy.gif'
75
+			),
76
+			'cut' => array
77
+			(
78
+				'label'                 => &$GLOBALS['TL_LANG']['tl_article_layouts']['cut'],
79
+				'href'                  => 'act=paste&amp;mode=cut',
80
+				'icon'                  => 'cut.gif',
81
+				'attributes'            => 'onclick="Backend.getScrollOffset()"'
82
+			),
83
+			'delete' => array
84
+			(
85
+				'label'                 => &$GLOBALS['TL_LANG']['tl_article_layouts']['delete'],
86
+				'href'                  => 'act=delete',
87
+				'icon'                  => 'delete.gif',
88
+				'attributes'            => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
89
+			),
90
+			'show' => array
91
+			(
92
+				'label'                 => &$GLOBALS['TL_LANG']['tl_article_layouts']['show'],
93
+				'href'                  => 'act=show',
94
+				'icon'                  => 'show.gif'
95
+			)
96
+		)
97
+	),
98
+
99
+	// Palettes
100
+	'palettes' => array
101
+	(
102
+		'__selector__'              => array('showBackgroundImage'),
103
+		'default'                   => '{title_legend},title,alias;{content_legend},maxWidth,center,useHelper;{image_legend},showBackgroundImage'
104
+	),
105
+
106
+	// Subpalettes
107
+	'subpalettes' => array
108
+	(
109
+		'showBackgroundImage'       => 'bgImageSize,bgStyle'
110
+	),
111
+
112
+	// Fields
113
+	'fields' => array
114
+	(
115
+		'id' => array
116
+		(
117
+			'sql'                     => "int(10) unsigned NOT NULL auto_increment"
118
+		),
119
+		'pid' => array
120
+		(
121
+			'foreignKey'              => 'tl_theme.name',
122
+			'sql'                     => "int(10) unsigned NOT NULL default '0'",
123
+			'relation'                => array('type'=>'belongsTo', 'load'=>'lazy')
124
+		),
125
+		'sorting' => array
126
+		(
127
+			'sql'                     => "int(10) unsigned NOT NULL default '0'"
128
+		),
129
+		'tstamp' => array
130
+		(
131
+			'sql'                     => "int(10) unsigned NOT NULL default '0'"
132
+		),
133
+		'title' => array
134
+		(
135
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['title'],
136
+			'inputType'               => 'text',
137
+			'exclude'                 => true,
138
+			'search'                  => true,
139
+			'eval'                    => array('mandatory'=>true, 'rgxp'=>'extnd', 'maxlength'=>64, 'tl_class'=>'w50'),
140
+			'sql'                     => "varchar(64) NULL"
141
+		),
142
+		'alias' => array
143
+		(
144
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['alias'],
145
+			'exclude'                 => true,
146
+			'inputType'               => 'text',
147
+			'search'                  => true,
148
+			'eval'                    => array('rgxp'=>'alias', 'doNotCopy'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
149
+			'save_callback' => array
150
+			(
151
+				array('tl_article_layouts', 'generateAlias')
152
+			),
153
+			'sql'                     => "varchar(128) COLLATE utf8_bin NOT NULL default ''"
154
+		),
155
+		'showBackgroundImage' => array
156
+		(
157
+			'exclude'                 => true,
158
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['showBackgroundImage'],
159
+			'inputType'               => 'checkbox',
160
+			'eval'                    => array('tl_class'=>'w50 m12','submitOnChange'=>true),
161
+			'sql'                     => "char(1) NOT NULL default ''"
162
+		),
163
+		'bgImageSize' => array
164
+		(
165
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['bgImageSize'],
166
+			'exclude'                 => true,
167
+			'inputType'               => 'imageSize',
168
+			'options'                 => System::getImageSizes(),
169
+			'reference'               => &$GLOBALS['TL_LANG']['MSC'],
170
+			'eval'                    => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
171
+			'sql'                     => "varchar(64) NOT NULL default ''"
172
+		),
173
+		'center' => array
174
+		(
175
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['center'],
176
+			'exclude'                 => true,
177
+			'inputType'               => 'checkbox',
178
+			'eval'                    => array('tl_class'=>'w50 m12'),
179
+			'sql'                     => "char(1) NOT NULL default ''"
180
+		),
181
+		'maxWidth' => array
182
+		(
183
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['maxWidth'],
184
+			'exclude'                 => true,
185
+			'inputType'               => 'checkbox',
186
+			'eval'                    => array('tl_class'=>'w50 m12'),
187
+			'sql'                     => "char(1) NOT NULL default ''"
188
+		),
189
+		'useHelper' => array
190
+		(
191
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['useHelper'],
192
+			'exclude'                 => true,
193
+			'inputType'               => 'checkbox',
194
+			'eval'                    => array('tl_class'=>'w50 m12'),
195
+			'sql'                     => "char(1) NOT NULL default ''"
196
+		),
197
+		'bgStyle' => array
198
+		(
199
+			'label'                   => &$GLOBALS['TL_LANG']['tl_article_layouts']['bgStyle'],
200
+			'exclude'                 => true,
201
+			'inputType'               => 'text',
202
+			'eval'                    => array('tl_class'=>'long','maxlength'=>255),
203
+			'sql'                     => "varchar(255) NOT NULL default ''"
204
+		),
205
+	)
206
+);
207
+
208
+
209
+/**
210
+ * Provide miscellaneous methods that are used by the data configuration array.
211
+ *
212
+ * @author Benjamin Roth <http://www.esales-media.de>
213
+ */
214
+class tl_article_layouts extends Backend
215
+{
216
+
217
+	/**
218
+	 * Import the back end user object
219
+	 */
220
+	public function __construct()
221
+	{
222
+		parent::__construct();
223
+		$this->import('BackendUser', 'User');
224
+	}
225
+
226
+
227
+	/**
228
+	 * Check permissions to edit the table
229
+	 */
230
+	public function checkPermission()
231
+	{
232
+		if ($this->User->isAdmin)
233
+		{
234
+			return;
235
+		}
236
+
237
+		if (!$this->User->hasAccess('artLayout', 'themes'))
238
+		{
239
+			$this->log('Not enough permissions to access the article layouts module', __METHOD__, TL_ERROR);
240
+			$this->redirect('contao/main.php?act=error');
241
+		}
242
+	}
243
+
244
+	/**
245
+	 * Auto-generate an article layout alias if it has not been set yet
246
+	 *
247
+	 * @param mixed         $varValue
248
+	 * @param DataContainer $dc
249
+	 *
250
+	 * @return string
251
+	 *
252
+	 * @throws Exception
253
+	 */
254
+	public function generateAlias($varValue, DataContainer $dc)
255
+	{
256
+		$autoAlias = false;
257
+
258
+		// Generate an alias if there is none
259
+		if ($varValue == '')
260
+		{
261
+			$autoAlias = true;
262
+			$varValue = StringUtil::generateAlias($dc->activeRecord->title);
263
+		}
264
+
265
+
266
+		$objAlias = $this->Database->prepare("SELECT id FROM tl_article_layouts WHERE id=? OR alias=?")
267
+			->execute($dc->id, $varValue);
268
+
269
+		// Check whether the page alias exists
270
+		if ($objAlias->numRows > 1)
271
+		{
272
+			if (!$autoAlias)
273
+			{
274
+				throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
275
+			}
276
+
277
+			$varValue .= '-' . $dc->id;
278
+		}
279
+
280
+		return $varValue;
281
+	}
282
+
283
+	/**
284
+	 * List an article layout
285
+	 *
286
+	 * @param array $row
287
+	 *
288
+	 * @return string
289
+	 */
290
+	public function listLayout($row)
291
+	{
292
+		return '<div style="float:left">'. $row['title'] .' <span style="color:#b3b3b3;">['.$row['alias']."]</span></div>\n";
293
+	}
294
+
295
+}
0 296
new file mode 100644
... ...
@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+
13
+/**
14
+ * Add operations button to tl_theme
15
+ */
16
+array_insert($GLOBALS['TL_DCA']['tl_theme']['list']['operations'],count($GLOBALS['TL_DCA']['tl_theme']['list']['operations'])-1,array
17
+(
18
+  'artLayout' => array
19
+  (
20
+    'label'               => &$GLOBALS['TL_LANG']['tl_theme']['artLayout'],
21
+    'href'                => 'table=tl_article_layouts',
22
+    'icon'                => 'themes.gif',
23
+    'button_callback'     => array('tl_theme_eSM_artLayout', 'editArticleLayouts')
24
+  )
25
+));
26
+
27
+/**
28
+ * Provide miscellaneous methods that are used by the data configuration array.
29
+ *
30
+ * @author Benjamin Roth <http://www.esales-media.de>
31
+ */
32
+class tl_theme_eSM_artLayout extends Backend
33
+{
34
+
35
+  /**
36
+   * Import the back end user object
37
+   */
38
+  public function __construct()
39
+  {
40
+    parent::__construct();
41
+    $this->import('BackendUser', 'User');
42
+  }
43
+
44
+  public function editArticleLayouts($row, $href, $label, $title, $icon, $attributes)
45
+  {
46
+    return $this->User->hasAccess('artLayout', 'themes') ? '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ' : Image::getHtml(preg_replace('/\.gif$/i', '_.gif', $icon)).' ';
47
+  }
48
+}
0 49
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+
13
+/**
14
+ * Add article layouts to theme access options
15
+ */
16
+array_insert($GLOBALS['TL_DCA']['tl_user_group']['fields']['themes']['options'],count($GLOBALS['TL_DCA']['tl_user_group']['fields']['themes']['options'])-2,array('artLayout'));
0 17
\ No newline at end of file
1 18
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['MOD']['tl_article_layouts'] = 'Artikellayouts';
16
+$GLOBALS['TL_LANG']['MOD']['artLayout'] = 'Artikellayouts';
0 17
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['tl_article']['es_type'][0] = 'Layout';
16
+$GLOBALS['TL_LANG']['tl_article']['es_type'][1] = 'Definiert das Aussehen des Artikels';
17
+$GLOBALS['TL_LANG']['tl_article']['es_backgroundSRC'][0] = 'Hintergrundbild';
18
+$GLOBALS['TL_LANG']['tl_article']['es_backgroundSRC'][1] = 'Das Bild welches im Artikelhintergrund angezeigt werden soll.';
0 19
\ No newline at end of file
1 20
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['tl_article_layouts']['title'][0] = 'Titel';
16
+$GLOBALS['TL_LANG']['tl_article_layouts']['title'][1] = 'Der Titel des Layouts';
17
+$GLOBALS['TL_LANG']['tl_article_layouts']['alias'][0] = 'Alias';
18
+$GLOBALS['TL_LANG']['tl_article_layouts']['alias'][1] = 'Das Layoutalias wird für die CSS Klassen verwendet.';
19
+$GLOBALS['TL_LANG']['tl_article_layouts']['maxWidth'][0] = 'Breite einschränken';
20
+$GLOBALS['TL_LANG']['tl_article_layouts']['maxWidth'][1] = 'Schränkt die Breite des Inhaltes auf einen global definierten Wert ein.';
21
+$GLOBALS['TL_LANG']['tl_article_layouts']['center'][0] = 'Inhalte zentrieren';
22
+$GLOBALS['TL_LANG']['tl_article_layouts']['center'][1] = 'Verwende eine zentrierte Textausrichtung.';
23
+$GLOBALS['TL_LANG']['tl_article_layouts']['showBackgroundImage'][0] = 'Hintergrundbild';
24
+$GLOBALS['TL_LANG']['tl_article_layouts']['showBackgroundImage'][1] = 'Erlaubt die Definition eines Hintergrundbildes in den Artikeleinstellungen.';
25
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgImageSize'][0] = 'Bildgröße';
26
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgImageSize'][1] = 'Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen.';
27
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgStyle'][0] = 'Eigener Inline-CSS Code';
28
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgStyle'][1] = 'Hier können Sie einen eigenen Inline-CSS Code für das Hintergrundbild angeben. ##bg_image## wird ersetzt durch den Bildpfad.';
29
+$GLOBALS['TL_LANG']['tl_article_layouts']['useHelper'][0] = 'Zusätzlicher Content-Wrapper';
30
+$GLOBALS['TL_LANG']['tl_article_layouts']['useHelper'][1] = 'Fügt einen zusätzlichen Content-Wrapper innerhalb des inside Containers hinzu.';
31
+
32
+/**
33
+ * Legends
34
+ */
35
+$GLOBALS['TL_LANG']['tl_article_layouts']['title_legend'] = 'Titel/Klassenname';
36
+$GLOBALS['TL_LANG']['tl_article_layouts']['content_legend'] = 'Inhalt-Einstellungen';
37
+$GLOBALS['TL_LANG']['tl_article_layouts']['image_legend'] = 'Bild-Einstellungen';
0 38
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Buttons
14
+ */
15
+$GLOBALS['TL_LANG']['tl_theme']['artLayout'][0] = 'Artikellayouts';
16
+$GLOBALS['TL_LANG']['tl_theme']['artLayout'][1] = 'Die Artikellayouts des Theme ID %s bearbeiten';
0 17
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['MOD']['tl_article_layouts'] = 'Article layouts';
16
+$GLOBALS['TL_LANG']['MOD']['artLayout'] = 'Article layouts';
0 17
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['tl_article']['es_type'][0] = 'Layout';
16
+$GLOBALS['TL_LANG']['tl_article']['es_type'][1] = 'Defines the article\'s appearance.';
17
+$GLOBALS['TL_LANG']['tl_article']['es_backgroundSRC'][0] = 'Background image';
18
+$GLOBALS['TL_LANG']['tl_article']['es_backgroundSRC'][1] = 'The image which should be displayed as article background.';
0 19
\ No newline at end of file
1 20
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Fields
14
+ */
15
+$GLOBALS['TL_LANG']['tl_article_layouts']['title'][0] = 'Title';
16
+$GLOBALS['TL_LANG']['tl_article_layouts']['title'][1] = 'Title of the layout';
17
+$GLOBALS['TL_LANG']['tl_article_layouts']['alias'][0] = 'Alias';
18
+$GLOBALS['TL_LANG']['tl_article_layouts']['alias'][1] = 'The alias is used for CSS classes.';
19
+$GLOBALS['TL_LANG']['tl_article_layouts']['maxWidth'][0] = 'Restrict width';
20
+$GLOBALS['TL_LANG']['tl_article_layouts']['maxWidth'][1] = 'Restricts the content width to a globally CSS defined value.';
21
+$GLOBALS['TL_LANG']['tl_article_layouts']['center'][0] = 'Center content';
22
+$GLOBALS['TL_LANG']['tl_article_layouts']['center'][1] = 'Use a centered text alignment.';
23
+$GLOBALS['TL_LANG']['tl_article_layouts']['showBackgroundImage'][0] = 'Background image';
24
+$GLOBALS['TL_LANG']['tl_article_layouts']['showBackgroundImage'][1] = 'Allows the selection of an background image in the article settings.';
25
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgImageSize'][0] = 'Image size';
26
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgImageSize'][1] = 'Here you can set the image dimensions and the resize mode.';
27
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgStyle'][0] = 'Custom inline CSS code';
28
+$GLOBALS['TL_LANG']['tl_article_layouts']['bgStyle'][1] = 'Here you can define a custom inline CSS code to be used for the background image. ##bg_image## will be replaced with the image path.';
29
+$GLOBALS['TL_LANG']['tl_article_layouts']['useHelper'][0] = 'Additional content wrapper';
30
+$GLOBALS['TL_LANG']['tl_article_layouts']['useHelper'][1] = 'Inserts an additional content wrapper within the inside container.';
31
+
32
+/**
33
+ * Legends
34
+ */
35
+$GLOBALS['TL_LANG']['tl_article_layouts']['title_legend'] = 'Title';
36
+$GLOBALS['TL_LANG']['tl_article_layouts']['content_legend'] = 'Content settings';
37
+$GLOBALS['TL_LANG']['tl_article_layouts']['image_legend'] = 'Image settings';
0 38
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+/**
13
+ * Buttons
14
+ */
15
+$GLOBALS['TL_LANG']['tl_theme']['artLayout'][0] = 'Article layouts';
16
+$GLOBALS['TL_LANG']['tl_theme']['artLayout'][1] = 'Edit the article layoutsof theme ID %s';
0 17
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+namespace eSM_artLayout;
13
+
14
+
15
+/**
16
+ * Reads and writes article layouts
17
+ *
18
+ * @property integer $id
19
+ * @property integer $pid
20
+ * @property integer $sorting
21
+ * @property integer $tstamp
22
+ * @property string  $title
23
+ * @property string  $alias
24
+ * @property integer $showBackgroundImage
25
+ * @property string  $bgImageSize
26
+ * @property integer $center
27
+ * @property integer $maxWidth
28
+ * @property integer $useHelper
29
+ * @property string  $bgStyle
30
+ *
31
+ * @method static \ThemeModel|null findById($id, $opt=array())
32
+ * @method static \ThemeModel|null findByPk($id, $opt=array())
33
+ * @method static \ThemeModel|null findByIdOrAlias($val, $opt=array())
34
+ * @method static \ThemeModel|null findOneBy($col, $val, $opt=array())
35
+ * @method static \ThemeModel|null findOneByTstamp($val, $opt=array())
36
+ * @method static \ThemeModel|null findOneByTitle($val, $opt=array())
37
+ * @method static \ThemeModel|null findOneByAlias($val, $opt=array())
38
+ *
39
+ * @method static \Model\Collection|\ThemeModel|null findByTstamp($val, $opt=array())
40
+ * @method static \Model\Collection|\ThemeModel|null findByTitle($val, $opt=array())
41
+ * @method static \Model\Collection|\ThemeModel|null findByAlias($val, $opt=array())
42
+ * @method static \Model\Collection|\ThemeModel|null findMultipleByIds($val, $opt=array())
43
+ * @method static \Model\Collection|\ThemeModel|null findBy($col, $val, $opt=array())
44
+ * @method static \Model\Collection|\ThemeModel|null findAll($opt=array())
45
+ *
46
+ * @method static integer countById($id, $opt=array())
47
+ * @method static integer countByTstamp($val, $opt=array())
48
+ * @method static integer countByTitle($val, $opt=array())
49
+ * @method static integer countByAlias($val, $opt=array())
50
+ *
51
+ * @author Benjamin Roth <http://www.esales-media.de>
52
+ */
53
+class ArticleLayoutsModel extends \Model
54
+{
55
+
56
+	/**
57
+	 * Table name
58
+	 * @var string
59
+	 */
60
+	protected static $strTable = 'tl_article_layouts';
61
+
62
+}
0 63
new file mode 100644
... ...
@@ -0,0 +1,91 @@
1
+<?php
2
+
3
+/**
4
+ * ArtLayout for Contao
5
+ *
6
+ * Copyright (c) 2016 Benjamin Roth
7
+ *
8
+ * @link    http://www.esales-media.de
9
+ * @license commercial
10
+ */
11
+
12
+namespace eSM_artLayout;
13
+
14
+
15
+/**
16
+ * Provides methodes to handle articles.
17
+ *
18
+ * @property integer $tstamp
19
+ * @property string  $title
20
+ * @property string  $alias
21
+ * @property string  $inColumn
22
+ * @property boolean $showTeaser
23
+ * @property boolean $multiMode
24
+ * @property string  $teaser
25
+ * @property string  $teaserCssID
26
+ * @property string  $classes
27
+ * @property string  $keywords
28
+ * @property boolean $printable
29
+ * @property boolean $published
30
+ * @property integer $start
31
+ * @property integer $stop
32
+ * @property integer $es_type
33
+ * @property string  $es_backgroundSRC
34
+ *
35
+ * @author Leo Feyer <https://github.com/leofeyer>
36
+ */
37
+class ModuleArticle extends \Contao\ModuleArticle
38
+{
39
+
40
+	/**
41
+	 * Add style if needed
42
+	 *
43
+	 * @param boolean $blnNoMarkup
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function generate($blnNoMarkup=false)
48
+	{
49
+		if ($this->es_type)
50
+		{
51
+			$ArticleLayout = ArticleLayoutsModel::findByPk($this->es_type);
52
+
53
+			if ($ArticleLayout !== null)
54
+			{
55
+
56
+				if ($ArticleLayout->showBackgroundImage)
57
+				{
58
+					$Image = \FilesModel::findByPk($this->es_backgroundSRC);
59
+
60
+					if (!is_null($Image))
61
+					{
62
+						$arrData = array
63
+						(
64
+							'singleSRC' => $Image->path,
65
+							'size' => $ArticleLayout->bgImageSize
66
+						);
67
+						$objClass = new \stdClass();
68
+
69
+						$this->addImageToTemplate($objClass, $arrData, \Config::get('maxImageWidth'));
70
+
71
+						if (trim($ArticleLayout->bgStyle))
72
+						{
73
+							$this->arrStyle[] = str_ireplace('##bg_image##',$objClass->src,$ArticleLayout->bgStyle);
74
+						}
75
+						else
76
+						{
77
+							$this->arrStyle[] = "background: url('".$objClass->src."');";
78
+						}
79
+					}
80
+				}
81
+
82
+				$this->useHelper = $ArticleLayout->useHelper;
83
+				$this->maxWidth = $ArticleLayout->maxWidth;
84
+				$this->center = $ArticleLayout->center;
85
+				$this->articleLayoutClass = $ArticleLayout->alias;
86
+			}
87
+		}
88
+
89
+		return parent::generate($blnNoMarkup);
90
+	}
91
+}
0 92
new file mode 100644
... ...
@@ -0,0 +1,44 @@
1
+
2
+<div class="<?= $this->class ?><?= $this->articleLayoutClass ? ' ' . $this->articleLayoutClass: '' ?><?= $this->maxWidth ? ' mw-centered' : '' ?><?= $this->center ? ' tac' : '' ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>
3
+  <div class="inside">
4
+  <?php if ($this->useHelper): ?><div class="inside-helper"><?php endif; ?>
5
+
6
+    <?php if ($this->printable): ?>
7
+      <!-- indexer::stop -->
8
+      <div class="pdf_link">
9
+
10
+        <?php if ($this->printButton): ?>
11
+          <a href="<?= $this->print ?>" rel="nofollow" title="<?= $this->printTitle ?>" onclick="window.print();return false"><img src="<?= TL_FILES_URL ?>assets/contao/images/print.gif" width="16" height="16" alt=""></a>
12
+        <?php endif; ?>
13
+
14
+        <?php if ($this->pdfButton): ?>
15
+          <a href="<?= $this->href ?>" rel="nofollow" title="<?= $this->pdfTitle ?>"><img src="<?= TL_FILES_URL ?>assets/contao/images/pdf.gif" width="16" height="16" alt=""></a>
16
+        <?php endif; ?>
17
+
18
+        <?php if ($this->facebookButton): ?>
19
+          <a href="share/?p=facebook&amp;u=<?= $this->encUrl ?>&amp;t=<?= $this->encTitle ?>" rel="nofollow" title="<?= $this->facebookTitle ?>" onclick="window.open(this.href,'','width=640,height=380,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');return false"><img src="<?= TL_FILES_URL ?>assets/contao/images/facebook.gif" width="16" height="16" alt=""></a>
20
+        <?php endif; ?>
21
+
22
+        <?php if ($this->twitterButton): ?>
23
+          <a href="share/?p=twitter&amp;u=<?= $this->encUrl ?>&amp;t=<?= $this->encTitle ?>" rel="nofollow" title="<?= $this->twitterTitle ?>" onclick="window.open(this.href,'','width=640,height=380,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');return false"><img src="<?= TL_FILES_URL ?>assets/contao/images/twitter.gif" width="16" height="16" alt=""></a>
24
+        <?php endif; ?>
25
+
26
+        <?php if ($this->gplusButton): ?>
27
+          <a href="share/?p=gplus&amp;u=<?= $this->encUrl ?>&amp;t=<?= $this->encTitle ?>" rel="nofollow" title="<?= $this->gplusTitle ?>" onclick="window.open(this.href,'','width=600,height=200,modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');return false"><img src="<?= TL_FILES_URL ?>assets/contao/images/gplus.gif" width="16" height="16" alt=""></a>
28
+        <?php endif; ?>
29
+
30
+      </div>
31
+      <!-- indexer::continue -->
32
+    <?php endif; ?>
33
+
34
+    <?= implode('', $this->elements) ?>
35
+
36
+    <?php if ($this->backlink): ?>
37
+      <!-- indexer::stop -->
38
+      <p class="back"><a href="<?= $this->backlink ?>" title="<?= $this->back ?>"><?= $this->back ?></a></p>
39
+      <!-- indexer::continue -->
40
+    <?php endif; ?>
41
+
42
+  <?php if ($this->useHelper): ?></div><?php endif; ?>
43
+  </div>
44
+</div>