1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,88 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-declare(strict_types=1); |
|
4 |
- |
|
5 |
-/* |
|
6 |
- * This file is part of Oveleon ContaoMemberExtension Bundle. |
|
7 |
- * |
|
8 |
- * @package contao-member-extension-bundle |
|
9 |
- * @license MIT |
|
10 |
- * @author Daniele Sciannimanica <https://github.com/doishub> |
|
11 |
- * @author Fabian Ekert <https://github.com/eki89> |
|
12 |
- * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
13 |
- * @copyright Oveleon <https://www.oveleon.de/> |
|
14 |
- */ |
|
15 |
- |
|
16 |
-namespace Oveleon\ContaoMemberExtensionBundle; |
|
17 |
- |
|
18 |
-use Contao\BackendTemplate; |
|
19 |
-use Contao\Config; |
|
20 |
-use Contao\FilesModel; |
|
21 |
-use Contao\FrontendUser; |
|
22 |
-use Contao\MemberModel; |
|
23 |
-use Contao\Module; |
|
24 |
-use Contao\System; |
|
25 |
- |
|
26 |
-/** |
|
27 |
- * Class ModuleAvatar |
|
28 |
- * |
|
29 |
- * @author Fabian Ekert <fabian@oveleon.de> |
|
30 |
- * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
31 |
- */ |
|
32 |
-class ModuleAvatar extends ModuleMemberExtension |
|
33 |
-{ |
|
34 |
- /** |
|
35 |
- * Template. |
|
36 |
- * |
|
37 |
- * @var string |
|
38 |
- */ |
|
39 |
- protected $strTemplate = 'memberExtension_avatar'; |
|
40 |
- |
|
41 |
- /** |
|
42 |
- * Return a wildcard in the back end |
|
43 |
- * |
|
44 |
- * @return string |
|
45 |
- */ |
|
46 |
- public function generate() |
|
47 |
- { |
|
48 |
- $request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
|
49 |
- |
|
50 |
- if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
51 |
- { |
|
52 |
- $objTemplate = new BackendTemplate('be_wildcard'); |
|
53 |
- $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['avatar'][0], 'UTF-8') . ' ###'; |
|
54 |
- $objTemplate->title = $this->headline; |
|
55 |
- $objTemplate->id = $this->id; |
|
56 |
- $objTemplate->link = $this->name; |
|
57 |
- $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
58 |
- |
|
59 |
- return $objTemplate->parse(); |
|
60 |
- } |
|
61 |
- |
|
62 |
- // Return if user is not logged in |
|
63 |
- $tokenChecker = System::getContainer()->get('contao.security.token_checker'); |
|
64 |
- $blnFeUserLoggedIn = $tokenChecker->hasFrontendUser(); |
|
65 |
- |
|
66 |
- if (!$blnFeUserLoggedIn) |
|
67 |
- { |
|
68 |
- return ''; |
|
69 |
- } |
|
70 |
- |
|
71 |
- $this->strTemplate = $this->customTpl ?: 'memberExtension_avatar'; |
|
72 |
- |
|
73 |
- return parent::generate(); |
|
74 |
- } |
|
75 |
- |
|
76 |
- /** |
|
77 |
- * Generate the module |
|
78 |
- */ |
|
79 |
- protected function compile() |
|
80 |
- { |
|
81 |
- $objTemplate = $this->Template; |
|
82 |
- |
|
83 |
- $this->import(FrontendUser::class, 'User'); |
|
84 |
- $objMember = MemberModel::findByPk($this->User->id); |
|
85 |
- |
|
86 |
- Member::parseMemberAvatar($objMember, $objTemplate, $this->imgSize); |
|
87 |
- } |
|
88 |
-} |
... | ... |
@@ -83,6 +83,6 @@ class ModuleAvatar extends ModuleMemberExtension |
83 | 83 |
$this->import(FrontendUser::class, 'User'); |
84 | 84 |
$objMember = MemberModel::findByPk($this->User->id); |
85 | 85 |
|
86 |
- $this->parseMemberAvatar($objMember, $objTemplate, $this->imgSize); |
|
86 |
+ Member::parseMemberAvatar($objMember, $objTemplate, $this->imgSize); |
|
87 | 87 |
} |
88 | 88 |
} |
... | ... |
@@ -29,7 +29,7 @@ use Contao\System; |
29 | 29 |
* @author Fabian Ekert <fabian@oveleon.de> |
30 | 30 |
* @author Sebastian Zoglowek <https://github.com/zoglo> |
31 | 31 |
*/ |
32 |
-class ModuleAvatar extends Module |
|
32 |
+class ModuleAvatar extends ModuleMemberExtension |
|
33 | 33 |
{ |
34 | 34 |
/** |
35 | 35 |
* Template. |
... | ... |
@@ -38,8 +38,6 @@ class ModuleAvatar extends Module |
38 | 38 |
*/ |
39 | 39 |
protected $strTemplate = 'memberExtension_avatar'; |
40 | 40 |
|
41 |
- const DEFAULT_PICTURE = 'bundles/contaomemberextension/avatar.png'; |
|
42 |
- |
|
43 | 41 |
/** |
44 | 42 |
* Return a wildcard in the back end |
45 | 43 |
* |
... | ... |
@@ -82,36 +80,9 @@ class ModuleAvatar extends Module |
82 | 80 |
{ |
83 | 81 |
$objTemplate = $this->Template; |
84 | 82 |
|
85 |
- $this->size = $this->imgSize; |
|
86 |
- |
|
87 |
- $objTemplate->noAvatar = true; |
|
88 |
- |
|
89 | 83 |
$this->import(FrontendUser::class, 'User'); |
90 | 84 |
$objMember = MemberModel::findByPk($this->User->id); |
91 | 85 |
|
92 |
- $projectDir = System::getContainer()->getParameter('kernel.project_dir'); |
|
93 |
- |
|
94 |
- // Check for avatar |
|
95 |
- if(!!$objMember->avatar) |
|
96 |
- { |
|
97 |
- $objFile = FilesModel::findByUuid($objMember->avatar); |
|
98 |
- } |
|
99 |
- // Check for standard avatar from member configuration |
|
100 |
- else if(!!Config::get('defaultAvatar')) |
|
101 |
- { |
|
102 |
- $objFile = FilesModel::findByUuid(Config::get('defaultAvatar')); |
|
103 |
- } |
|
104 |
- |
|
105 |
- // If file does not exist use default image |
|
106 |
- if (null !== $objFile || is_file($projectDir . '/' . $objFile->path)) |
|
107 |
- { |
|
108 |
- $objTemplate->noAvatar = false; |
|
109 |
- $this->singleSRC = $objFile->path; |
|
110 |
- $this->addImageToTemplate($this->Template, $this->arrData); |
|
111 |
- } |
|
112 |
- else |
|
113 |
- { |
|
114 |
- $objTemplate->singleSRC = self::DEFAULT_PICTURE; |
|
115 |
- } |
|
86 |
+ $this->parseMemberAvatar($objMember, $objTemplate, $this->imgSize); |
|
116 | 87 |
} |
117 | 88 |
} |
... | ... |
@@ -38,12 +38,7 @@ class ModuleAvatar extends Module |
38 | 38 |
*/ |
39 | 39 |
protected $strTemplate = 'memberExtension_avatar'; |
40 | 40 |
|
41 |
- /** |
|
42 |
- * Default avatar file path |
|
43 |
- * |
|
44 |
- * @var string |
|
45 |
- */ |
|
46 |
- private static $strDefaultPath = 'bundles/contaomemberextension/avatar.png'; |
|
41 |
+ const DEFAULT_PICTURE = 'bundles/contaomemberextension/avatar.png'; |
|
47 | 42 |
|
48 | 43 |
/** |
49 | 44 |
* Return a wildcard in the back end |
... | ... |
@@ -106,21 +101,17 @@ class ModuleAvatar extends Module |
106 | 101 |
{ |
107 | 102 |
$objFile = FilesModel::findByUuid(Config::get('defaultAvatar')); |
108 | 103 |
} |
109 |
- else |
|
110 |
- { |
|
111 |
- $objTemplate->singleSRC = self::$strDefaultPath; |
|
112 |
- } |
|
113 | 104 |
|
114 | 105 |
// If file does not exist use default image |
115 |
- if ($objFile === null || !is_file($projectDir . '/' . $objFile->path)) |
|
116 |
- { |
|
117 |
- $objTemplate->singleSRC = self::$strDefaultPath; |
|
118 |
- } |
|
119 |
- else |
|
106 |
+ if (null !== $objFile || is_file($projectDir . '/' . $objFile->path)) |
|
120 | 107 |
{ |
121 | 108 |
$objTemplate->noAvatar = false; |
122 | 109 |
$this->singleSRC = $objFile->path; |
123 | 110 |
$this->addImageToTemplate($this->Template, $this->arrData); |
124 | 111 |
} |
112 |
+ else |
|
113 |
+ { |
|
114 |
+ $objTemplate->singleSRC = self::DEFAULT_PICTURE; |
|
115 |
+ } |
|
125 | 116 |
} |
126 | 117 |
} |
... | ... |
@@ -16,6 +16,7 @@ declare(strict_types=1); |
16 | 16 |
namespace Oveleon\ContaoMemberExtensionBundle; |
17 | 17 |
|
18 | 18 |
use Contao\BackendTemplate; |
19 |
+use Contao\Config; |
|
19 | 20 |
use Contao\FilesModel; |
20 | 21 |
use Contao\FrontendUser; |
21 | 22 |
use Contao\MemberModel; |
... | ... |
@@ -95,25 +96,31 @@ class ModuleAvatar extends Module |
95 | 96 |
|
96 | 97 |
$projectDir = System::getContainer()->getParameter('kernel.project_dir'); |
97 | 98 |
|
99 |
+ // Check for avatar |
|
100 |
+ if(!!$objMember->avatar) |
|
101 |
+ { |
|
102 |
+ $objFile = FilesModel::findByUuid($objMember->avatar); |
|
103 |
+ } |
|
104 |
+ // Check for standard avatar from member configuration |
|
105 |
+ else if(!!Config::get('defaultAvatar')) |
|
106 |
+ { |
|
107 |
+ $objFile = FilesModel::findByUuid(Config::get('defaultAvatar')); |
|
108 |
+ } |
|
109 |
+ else |
|
110 |
+ { |
|
111 |
+ $objTemplate->singleSRC = self::$strDefaultPath; |
|
112 |
+ } |
|
98 | 113 |
|
99 |
- if (!$this->User->avatar) |
|
114 |
+ // If file does not exist use default image |
|
115 |
+ if ($objFile === null || !is_file($projectDir . '/' . $objFile->path)) |
|
100 | 116 |
{ |
101 | 117 |
$objTemplate->singleSRC = self::$strDefaultPath; |
102 | 118 |
} |
103 | 119 |
else |
104 | 120 |
{ |
105 |
- $objFile = FilesModel::findByUuid($this->User->avatar); |
|
106 |
- |
|
107 |
- if ($objFile === null || !is_file($projectDir . '/' . $objFile->path)) |
|
108 |
- { |
|
109 |
- $objTemplate->singleSRC = self::$strDefaultPath; |
|
110 |
- } |
|
111 |
- else |
|
112 |
- { |
|
113 |
- $objTemplate->noAvatar = false; |
|
114 |
- $this->singleSRC = $objFile->path; |
|
115 |
- $this->addImageToTemplate($this->Template, $this->arrData); |
|
116 |
- } |
|
121 |
+ $objTemplate->noAvatar = false; |
|
122 |
+ $this->singleSRC = $objFile->path; |
|
123 |
+ $this->addImageToTemplate($this->Template, $this->arrData); |
|
117 | 124 |
} |
118 | 125 |
} |
119 | 126 |
} |
... | ... |
@@ -35,7 +35,7 @@ class ModuleAvatar extends Module |
35 | 35 |
* |
36 | 36 |
* @var string |
37 | 37 |
*/ |
38 |
- protected $strTemplate = 'member_avatar'; |
|
38 |
+ protected $strTemplate = 'memberExtension_avatar'; |
|
39 | 39 |
|
40 | 40 |
/** |
41 | 41 |
* Default avatar file path |
... | ... |
@@ -74,7 +74,7 @@ class ModuleAvatar extends Module |
74 | 74 |
return ''; |
75 | 75 |
} |
76 | 76 |
|
77 |
- $this->strTemplate = $this->memberTpl ?: 'member_avatar'; |
|
77 |
+ $this->strTemplate = $this->memberTpl ?: 'memberExtension_avatar'; |
|
78 | 78 |
|
79 | 79 |
return parent::generate(); |
80 | 80 |
} |
... | ... |
@@ -1,105 +1,119 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 |
+declare(strict_types=1); |
|
4 |
+ |
|
3 | 5 |
/* |
4 | 6 |
* This file is part of Oveleon ContaoMemberExtension Bundle. |
5 | 7 |
* |
6 |
- * (c) https://www.oveleon.de/ |
|
8 |
+ * @package contao-member-extension-bundle |
|
9 |
+ * @license MIT |
|
10 |
+ * @author Daniele Sciannimanica <https://github.com/doishub> |
|
11 |
+ * @author Fabian Ekert <https://github.com/eki89> |
|
12 |
+ * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
13 |
+ * @copyright Oveleon <https://www.oveleon.de/> |
|
7 | 14 |
*/ |
8 | 15 |
|
9 | 16 |
namespace Oveleon\ContaoMemberExtensionBundle; |
10 | 17 |
|
11 |
-use Patchwork\Utf8; |
|
18 |
+use Contao\BackendTemplate; |
|
19 |
+use Contao\FilesModel; |
|
20 |
+use Contao\FrontendUser; |
|
21 |
+use Contao\MemberModel; |
|
22 |
+use Contao\Module; |
|
23 |
+use Contao\System; |
|
12 | 24 |
|
13 | 25 |
/** |
14 | 26 |
* Class ModuleAvatar |
15 | 27 |
* |
16 | 28 |
* @author Fabian Ekert <fabian@oveleon.de> |
29 |
+ * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
17 | 30 |
*/ |
18 |
-class ModuleAvatar extends \Module |
|
31 |
+class ModuleAvatar extends Module |
|
19 | 32 |
{ |
33 |
+ /** |
|
34 |
+ * Template. |
|
35 |
+ * |
|
36 |
+ * @var string |
|
37 |
+ */ |
|
38 |
+ protected $strTemplate = 'member_avatar'; |
|
39 |
+ |
|
40 |
+ /** |
|
41 |
+ * Default avatar file path |
|
42 |
+ * |
|
43 |
+ * @var string |
|
44 |
+ */ |
|
45 |
+ private static $strDefaultPath = 'bundles/contaomemberextension/avatar.png'; |
|
46 |
+ |
|
47 |
+ /** |
|
48 |
+ * Return a wildcard in the back end |
|
49 |
+ * |
|
50 |
+ * @return string |
|
51 |
+ */ |
|
52 |
+ public function generate() |
|
53 |
+ { |
|
54 |
+ $request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
|
55 |
+ |
|
56 |
+ if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
57 |
+ { |
|
58 |
+ $objTemplate = new BackendTemplate('be_wildcard'); |
|
59 |
+ $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['avatar'][0], 'UTF-8') . ' ###'; |
|
60 |
+ $objTemplate->title = $this->headline; |
|
61 |
+ $objTemplate->id = $this->id; |
|
62 |
+ $objTemplate->link = $this->name; |
|
63 |
+ $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
64 |
+ |
|
65 |
+ return $objTemplate->parse(); |
|
66 |
+ } |
|
20 | 67 |
|
21 |
- /** |
|
22 |
- * Template |
|
23 |
- * @var string |
|
24 |
- */ |
|
25 |
- protected $strTemplate = 'member_avatar'; |
|
26 |
- |
|
27 |
- /** |
|
28 |
- * Return a wildcard in the back end |
|
29 |
- * |
|
30 |
- * @return string |
|
31 |
- */ |
|
32 |
- public function generate() |
|
33 |
- { |
|
34 |
- if (TL_MODE == 'BE') |
|
35 |
- { |
|
36 |
- /** @var BackendTemplate|object $objTemplate */ |
|
37 |
- $objTemplate = new \BackendTemplate('be_wildcard'); |
|
38 |
- |
|
39 |
- $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['avatar'][0]) . ' ###'; |
|
40 |
- $objTemplate->title = $this->headline; |
|
41 |
- $objTemplate->id = $this->id; |
|
42 |
- $objTemplate->link = $this->name; |
|
43 |
- $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
44 |
- |
|
45 |
- return $objTemplate->parse(); |
|
46 |
- } |
|
47 |
- |
|
48 |
- // Return if user is not logged in |
|
49 |
- if (!FE_USER_LOGGED_IN) |
|
50 |
- { |
|
51 |
- return ''; |
|
52 |
- } |
|
53 |
- |
|
54 |
- if ($this->memberTpl != '') |
|
55 |
- { |
|
56 |
- $this->strTemplate = $this->memberTpl; |
|
57 |
- } |
|
58 |
- |
|
59 |
- return parent::generate(); |
|
60 |
- } |
|
61 |
- |
|
62 |
- /** |
|
63 |
- * Generate the module |
|
64 |
- */ |
|
65 |
- protected function compile() |
|
66 |
- { |
|
67 |
- $this->size = $this->imgSize; |
|
68 |
- |
|
69 |
- $this->import('FrontendUser', 'User'); |
|
68 |
+ // Return if user is not logged in |
|
69 |
+ $tokenChecker = System::getContainer()->get('contao.security.token_checker'); |
|
70 |
+ $blnFeUserLoggedIn = $tokenChecker->hasFrontendUser(); |
|
70 | 71 |
|
71 |
- if ($this->User->avatar == '' && \Config::get('defaultAvatar') == '') |
|
72 |
+ if (!$blnFeUserLoggedIn) |
|
72 | 73 |
{ |
73 | 74 |
return ''; |
74 | 75 |
} |
75 | 76 |
|
76 |
- if ($this->User->avatar == '') |
|
77 |
- { |
|
78 |
- $objFile = \FilesModel::findByUuid(\Config::get('defaultAvatar')); |
|
77 |
+ $this->strTemplate = $this->memberTpl ?: 'member_avatar'; |
|
79 | 78 |
|
80 |
- if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) |
|
81 |
- { |
|
82 |
- return ''; |
|
83 |
- } |
|
79 |
+ return parent::generate(); |
|
80 |
+ } |
|
84 | 81 |
|
85 |
- $this->singleSRC = $objFile->path; |
|
82 |
+ /** |
|
83 |
+ * Generate the module |
|
84 |
+ */ |
|
85 |
+ protected function compile() |
|
86 |
+ { |
|
87 |
+ $objTemplate = $this->Template; |
|
86 | 88 |
|
87 |
- $this->addImageToTemplate($this->Template, $this->arrData); |
|
88 |
- return; |
|
89 |
- } |
|
89 |
+ $this->size = $this->imgSize; |
|
90 | 90 |
|
91 |
- $objFile = \FilesModel::findByUuid($this->User->avatar); |
|
91 |
+ $objTemplate->noAvatar = true; |
|
92 | 92 |
|
93 |
- if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) |
|
94 |
- { |
|
95 |
- $this->singleSRC = \FilesModel::findByUuid(\Config::get('defaultAvatar'))->path; |
|
93 |
+ $this->import(FrontendUser::class, 'User'); |
|
94 |
+ $objMember = MemberModel::findByPk($this->User->id); |
|
95 |
+ |
|
96 |
+ $projectDir = System::getContainer()->getParameter('kernel.project_dir'); |
|
96 | 97 |
|
97 |
- $this->addImageToTemplate($this->Template, $this->arrData); |
|
98 |
- return; |
|
99 |
- } |
|
100 | 98 |
|
101 |
- $this->singleSRC = $objFile->path; |
|
99 |
+ if (!$this->User->avatar) |
|
100 |
+ { |
|
101 |
+ $objTemplate->singleSRC = self::$strDefaultPath; |
|
102 |
+ } |
|
103 |
+ else |
|
104 |
+ { |
|
105 |
+ $objFile = FilesModel::findByUuid($this->User->avatar); |
|
102 | 106 |
|
103 |
- $this->addImageToTemplate($this->Template, $this->arrData, null, null, $objFile); |
|
104 |
- } |
|
107 |
+ if ($objFile === null || !is_file($projectDir . '/' . $objFile->path)) |
|
108 |
+ { |
|
109 |
+ $objTemplate->singleSRC = self::$strDefaultPath; |
|
110 |
+ } |
|
111 |
+ else |
|
112 |
+ { |
|
113 |
+ $objTemplate->noAvatar = false; |
|
114 |
+ $this->singleSRC = $objFile->path; |
|
115 |
+ $this->addImageToTemplate($this->Template, $this->arrData); |
|
116 |
+ } |
|
117 |
+ } |
|
118 |
+ } |
|
105 | 119 |
} |
... | ... |
@@ -1,11 +1,9 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
/* |
4 |
- * This file is part of Contao. |
|
4 |
+ * This file is part of Oveleon ContaoMemberExtension Bundle. |
|
5 | 5 |
* |
6 |
- * (c) Leo Feyer |
|
7 |
- * |
|
8 |
- * @license LGPL-3.0-or-later |
|
6 |
+ * (c) https://www.oveleon.de/ |
|
9 | 7 |
*/ |
10 | 8 |
|
11 | 9 |
namespace Oveleon\ContaoMemberExtensionBundle; |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,107 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * This file is part of Contao. |
|
5 |
+ * |
|
6 |
+ * (c) Leo Feyer |
|
7 |
+ * |
|
8 |
+ * @license LGPL-3.0-or-later |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+namespace Oveleon\ContaoMemberExtensionBundle; |
|
12 |
+ |
|
13 |
+use Patchwork\Utf8; |
|
14 |
+ |
|
15 |
+/** |
|
16 |
+ * Class ModuleAvatar |
|
17 |
+ * |
|
18 |
+ * @author Fabian Ekert <fabian@oveleon.de> |
|
19 |
+ */ |
|
20 |
+class ModuleAvatar extends \Module |
|
21 |
+{ |
|
22 |
+ |
|
23 |
+ /** |
|
24 |
+ * Template |
|
25 |
+ * @var string |
|
26 |
+ */ |
|
27 |
+ protected $strTemplate = 'member_avatar'; |
|
28 |
+ |
|
29 |
+ /** |
|
30 |
+ * Return a wildcard in the back end |
|
31 |
+ * |
|
32 |
+ * @return string |
|
33 |
+ */ |
|
34 |
+ public function generate() |
|
35 |
+ { |
|
36 |
+ if (TL_MODE == 'BE') |
|
37 |
+ { |
|
38 |
+ /** @var BackendTemplate|object $objTemplate */ |
|
39 |
+ $objTemplate = new \BackendTemplate('be_wildcard'); |
|
40 |
+ |
|
41 |
+ $objTemplate->wildcard = '### ' . Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['avatar'][0]) . ' ###'; |
|
42 |
+ $objTemplate->title = $this->headline; |
|
43 |
+ $objTemplate->id = $this->id; |
|
44 |
+ $objTemplate->link = $this->name; |
|
45 |
+ $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
46 |
+ |
|
47 |
+ return $objTemplate->parse(); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ // Return if user is not logged in |
|
51 |
+ if (!FE_USER_LOGGED_IN) |
|
52 |
+ { |
|
53 |
+ return ''; |
|
54 |
+ } |
|
55 |
+ |
|
56 |
+ if ($this->memberTpl != '') |
|
57 |
+ { |
|
58 |
+ $this->strTemplate = $this->memberTpl; |
|
59 |
+ } |
|
60 |
+ |
|
61 |
+ return parent::generate(); |
|
62 |
+ } |
|
63 |
+ |
|
64 |
+ /** |
|
65 |
+ * Generate the module |
|
66 |
+ */ |
|
67 |
+ protected function compile() |
|
68 |
+ { |
|
69 |
+ $this->size = $this->imgSize; |
|
70 |
+ |
|
71 |
+ $this->import('FrontendUser', 'User'); |
|
72 |
+ |
|
73 |
+ if ($this->User->avatar == '' && \Config::get('defaultAvatar') == '') |
|
74 |
+ { |
|
75 |
+ return ''; |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ if ($this->User->avatar == '') |
|
79 |
+ { |
|
80 |
+ $objFile = \FilesModel::findByUuid(\Config::get('defaultAvatar')); |
|
81 |
+ |
|
82 |
+ if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) |
|
83 |
+ { |
|
84 |
+ return ''; |
|
85 |
+ } |
|
86 |
+ |
|
87 |
+ $this->singleSRC = $objFile->path; |
|
88 |
+ |
|
89 |
+ $this->addImageToTemplate($this->Template, $this->arrData); |
|
90 |
+ return; |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ $objFile = \FilesModel::findByUuid($this->User->avatar); |
|
94 |
+ |
|
95 |
+ if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) |
|
96 |
+ { |
|
97 |
+ $this->singleSRC = \FilesModel::findByUuid(\Config::get('defaultAvatar'))->path; |
|
98 |
+ |
|
99 |
+ $this->addImageToTemplate($this->Template, $this->arrData); |
|
100 |
+ return; |
|
101 |
+ } |
|
102 |
+ |
|
103 |
+ $this->singleSRC = $objFile->path; |
|
104 |
+ |
|
105 |
+ $this->addImageToTemplate($this->Template, $this->arrData, null, null, $objFile); |
|
106 |
+ } |
|
107 |
+} |