... | ... |
@@ -37,55 +37,57 @@ namespace eSM_artLayout; |
37 | 37 |
class ModuleArticle extends \Contao\ModuleArticle |
38 | 38 |
{ |
39 | 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); |
|
40 |
+ /** |
|
41 |
+ * Inject some article layout stuff |
|
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 | 52 |
|
53 |
- if ($ArticleLayout !== null) |
|
54 |
- { |
|
53 |
+ if ($ArticleLayout !== null) |
|
54 |
+ { |
|
55 | 55 |
|
56 |
- if ($ArticleLayout->showBackgroundImage) |
|
57 |
- { |
|
58 |
- $Image = \FilesModel::findByPk($this->es_backgroundSRC); |
|
56 |
+ // Select background image and add inline styles |
|
57 |
+ if ($ArticleLayout->showBackgroundImage) |
|
58 |
+ { |
|
59 |
+ $Image = \FilesModel::findByPk($this->es_backgroundSRC); |
|
59 | 60 |
|
60 |
- if (!is_null($Image)) |
|
61 |
- { |
|
62 |
- $arrData = array |
|
63 |
- ( |
|
64 |
- 'singleSRC' => $Image->path, |
|
65 |
- 'size' => $ArticleLayout->bgImageSize |
|
66 |
- ); |
|
67 |
- $objClass = new \stdClass(); |
|
61 |
+ if (!is_null($Image)) |
|
62 |
+ { |
|
63 |
+ $arrData = array |
|
64 |
+ ( |
|
65 |
+ 'singleSRC' => $Image->path, |
|
66 |
+ 'size' => $ArticleLayout->bgImageSize |
|
67 |
+ ); |
|
68 |
+ $objClass = new \stdClass(); |
|
68 | 69 |
|
69 |
- $this->addImageToTemplate($objClass, $arrData, \Config::get('maxImageWidth')); |
|
70 |
+ $this->addImageToTemplate($objClass, $arrData, \Config::get('maxImageWidth')); |
|
70 | 71 |
|
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 |
- } |
|
72 |
+ if (trim($ArticleLayout->bgStyle)) |
|
73 |
+ { |
|
74 |
+ $this->arrStyle[] = str_ireplace('##bg_image##',$objClass->src,$ArticleLayout->bgStyle); |
|
75 |
+ } |
|
76 |
+ else |
|
77 |
+ { |
|
78 |
+ $this->arrStyle[] = "background: url('".$objClass->src."');"; |
|
79 |
+ } |
|
80 |
+ } |
|
81 |
+ } |
|
81 | 82 |
|
82 |
- $this->useHelper = $ArticleLayout->useHelper; |
|
83 |
- $this->maxWidth = $ArticleLayout->maxWidth; |
|
84 |
- $this->center = $ArticleLayout->center; |
|
85 |
- $this->articleLayoutClass = $ArticleLayout->alias; |
|
86 |
- } |
|
87 |
- } |
|
83 |
+ // Set article layout related variables to be used in article template |
|
84 |
+ $this->useHelper = $ArticleLayout->useHelper; |
|
85 |
+ $this->maxWidth = $ArticleLayout->maxWidth; |
|
86 |
+ $this->center = $ArticleLayout->center; |
|
87 |
+ $this->articleLayoutClass = $ArticleLayout->alias; |
|
88 |
+ } |
|
89 |
+ } |
|
88 | 90 |
|
89 |
- return parent::generate($blnNoMarkup); |
|
90 |
- } |
|
91 |
+ return parent::generate($blnNoMarkup); |
|
92 |
+ } |
|
91 | 93 |
} |
1 | 1 |
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 |
+} |