| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,87 +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 Sebastian Zoglowek <https://github.com/zoglo> |
|
| 11 |
- * @author Daniele Sciannimanica <https://github.com/doishub> |
|
| 12 |
- * @author Fabian Ekert <https://github.com/eki89> |
|
| 13 |
- * @copyright Oveleon <https://www.oveleon.de/> |
|
| 14 |
- */ |
|
| 15 |
- |
|
| 16 |
-namespace Oveleon\ContaoMemberExtensionBundle; |
|
| 17 |
- |
|
| 18 |
-use Contao\BackendTemplate; |
|
| 19 |
-use Contao\FrontendUser; |
|
| 20 |
-use Contao\MemberModel; |
|
| 21 |
-use Contao\StringUtil; |
|
| 22 |
-use Contao\System; |
|
| 23 |
- |
|
| 24 |
-/** |
|
| 25 |
- * Class ModuleAvatar |
|
| 26 |
- * |
|
| 27 |
- * @author Fabian Ekert <fabian@oveleon.de> |
|
| 28 |
- * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
| 29 |
- */ |
|
| 30 |
-class ModuleAvatar extends ModuleMemberExtension |
|
| 31 |
-{
|
|
| 32 |
- /** |
|
| 33 |
- * Template. |
|
| 34 |
- * |
|
| 35 |
- * @var string |
|
| 36 |
- */ |
|
| 37 |
- protected $strTemplate = 'memberExtension_avatar'; |
|
| 38 |
- |
|
| 39 |
- /** |
|
| 40 |
- * Display a wildcard in the back end |
|
| 41 |
- * |
|
| 42 |
- * @return string |
|
| 43 |
- */ |
|
| 44 |
- public function generate() |
|
| 45 |
- {
|
|
| 46 |
- $container = System::getContainer(); |
|
| 47 |
- $request = System::getContainer()->get('request_stack')->getCurrentRequest();
|
|
| 48 |
- |
|
| 49 |
- if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request))
|
|
| 50 |
- {
|
|
| 51 |
- $objTemplate = new BackendTemplate('be_wildcard');
|
|
| 52 |
- $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['avatar'][0] . ' ###'; |
|
| 53 |
- $objTemplate->title = $this->headline; |
|
| 54 |
- $objTemplate->id = $this->id; |
|
| 55 |
- $objTemplate->link = $this->name; |
|
| 56 |
- $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id]));
|
|
| 57 |
- |
|
| 58 |
- return $objTemplate->parse(); |
|
| 59 |
- } |
|
| 60 |
- |
|
| 61 |
- // Return if user is not logged in |
|
| 62 |
- $tokenChecker = System::getContainer()->get('contao.security.token_checker');
|
|
| 63 |
- $blnFeUserLoggedIn = $tokenChecker->hasFrontendUser(); |
|
| 64 |
- |
|
| 65 |
- if (!$blnFeUserLoggedIn) |
|
| 66 |
- {
|
|
| 67 |
- return ''; |
|
| 68 |
- } |
|
| 69 |
- |
|
| 70 |
- $this->strTemplate = $this->customTpl ?: 'memberExtension_avatar'; |
|
| 71 |
- |
|
| 72 |
- return parent::generate(); |
|
| 73 |
- } |
|
| 74 |
- |
|
| 75 |
- /** |
|
| 76 |
- * Generate the module |
|
| 77 |
- */ |
|
| 78 |
- protected function compile() |
|
| 79 |
- {
|
|
| 80 |
- $objTemplate = $this->Template; |
|
| 81 |
- |
|
| 82 |
- $this->import(FrontendUser::class, 'User'); |
|
| 83 |
- $objMember = MemberModel::findByPk($this->User->id); |
|
| 84 |
- |
|
| 85 |
- Member::parseMemberAvatar($objMember, $objTemplate, $this->imgSize); |
|
| 86 |
- } |
|
| 87 |
-} |
| ... | ... |
@@ -16,11 +16,9 @@ declare(strict_types=1); |
| 16 | 16 |
namespace Oveleon\ContaoMemberExtensionBundle; |
| 17 | 17 |
|
| 18 | 18 |
use Contao\BackendTemplate; |
| 19 |
-use Contao\Config; |
|
| 20 |
-use Contao\FilesModel; |
|
| 21 | 19 |
use Contao\FrontendUser; |
| 22 | 20 |
use Contao\MemberModel; |
| 23 |
-use Contao\Module; |
|
| 21 |
+use Contao\StringUtil; |
|
| 24 | 22 |
use Contao\System; |
| 25 | 23 |
|
| 26 | 24 |
/** |
| ... | ... |
@@ -39,22 +37,23 @@ class ModuleAvatar extends ModuleMemberExtension |
| 39 | 37 |
protected $strTemplate = 'memberExtension_avatar'; |
| 40 | 38 |
|
| 41 | 39 |
/** |
| 42 |
- * Return a wildcard in the back end |
|
| 40 |
+ * Display a wildcard in the back end |
|
| 43 | 41 |
* |
| 44 | 42 |
* @return string |
| 45 | 43 |
*/ |
| 46 | 44 |
public function generate() |
| 47 | 45 |
{
|
| 46 |
+ $container = System::getContainer(); |
|
| 48 | 47 |
$request = System::getContainer()->get('request_stack')->getCurrentRequest();
|
| 49 | 48 |
|
| 50 |
- if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
|
|
| 49 |
+ if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request))
|
|
| 51 | 50 |
{
|
| 52 | 51 |
$objTemplate = new BackendTemplate('be_wildcard');
|
| 53 |
- $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['avatar'][0], 'UTF-8') . ' ###'; |
|
| 52 |
+ $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['avatar'][0] . ' ###'; |
|
| 54 | 53 |
$objTemplate->title = $this->headline; |
| 55 | 54 |
$objTemplate->id = $this->id; |
| 56 | 55 |
$objTemplate->link = $this->name; |
| 57 |
- $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
| 56 |
+ $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id]));
|
|
| 58 | 57 |
|
| 59 | 58 |
return $objTemplate->parse(); |
| 60 | 59 |
} |
| ... | ... |
@@ -7,10 +7,10 @@ declare(strict_types=1); |
| 7 | 7 |
* |
| 8 | 8 |
* @package contao-member-extension-bundle |
| 9 | 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/> |
|
| 10 |
+ * @author Sebastian Zoglowek <https://github.com/zoglo> |
|
| 11 |
+ * @author Daniele Sciannimanica <https://github.com/doishub> |
|
| 12 |
+ * @author Fabian Ekert <https://github.com/eki89> |
|
| 13 |
+ * @copyright Oveleon <https://www.oveleon.de/> |
|
| 14 | 14 |
*/ |
| 15 | 15 |
|
| 16 | 16 |
namespace Oveleon\ContaoMemberExtensionBundle; |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,88 @@ |
| 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 |
+} |