1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,114 +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\Config; |
|
20 |
-use Contao\CoreBundle\Exception\PageNotFoundException; |
|
21 |
-use Contao\Environment; |
|
22 |
-use Contao\FrontendTemplate; |
|
23 |
-use Contao\Input; |
|
24 |
-use Contao\MemberModel; |
|
25 |
-use Contao\StringUtil; |
|
26 |
-use Contao\System; |
|
27 |
- |
|
28 |
-/** |
|
29 |
- * Class ModuleMemberList |
|
30 |
- * |
|
31 |
- * @property string $ext_groups considered member groups |
|
32 |
- * @property string $memberFields Fields to be displayed |
|
33 |
- * @property string $memberReaderTpl Frontend reader template |
|
34 |
- */ |
|
35 |
-class ModuleMemberReader extends ModuleMemberExtension |
|
36 |
-{ |
|
37 |
- |
|
38 |
- /** |
|
39 |
- * Template |
|
40 |
- * @var string |
|
41 |
- */ |
|
42 |
- protected $strTemplate = 'mod_memberReader'; |
|
43 |
- |
|
44 |
- /** |
|
45 |
- * Template |
|
46 |
- * @var string |
|
47 |
- */ |
|
48 |
- protected $strMemberTemplate = 'memberExtension_reader_full'; |
|
49 |
- |
|
50 |
- /** |
|
51 |
- * Display a wildcard in the back end |
|
52 |
- * |
|
53 |
- * @return string |
|
54 |
- */ |
|
55 |
- public function generate() |
|
56 |
- { |
|
57 |
- $container = System::getContainer(); |
|
58 |
- $request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
|
59 |
- |
|
60 |
- if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
61 |
- { |
|
62 |
- $objTemplate = new BackendTemplate('be_wildcard'); |
|
63 |
- $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['memberList'][0] . ' ###'; |
|
64 |
- $objTemplate->title = $this->headline; |
|
65 |
- $objTemplate->id = $this->id; |
|
66 |
- $objTemplate->link = $this->name; |
|
67 |
- $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id])); |
|
68 |
- |
|
69 |
- return $objTemplate->parse(); |
|
70 |
- } |
|
71 |
- |
|
72 |
- // Set the item from the auto_item parameter |
|
73 |
- if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem')) |
|
74 |
- { |
|
75 |
- Input::setGet('items', Input::get('auto_item')); |
|
76 |
- } |
|
77 |
- |
|
78 |
- return parent::generate(); |
|
79 |
- } |
|
80 |
- |
|
81 |
- /** |
|
82 |
- * Generate the module |
|
83 |
- */ |
|
84 |
- protected function compile() |
|
85 |
- { |
|
86 |
- $this->Template->referer = 'javascript:history.go(-1)'; |
|
87 |
- $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; |
|
88 |
- |
|
89 |
- // Get the member |
|
90 |
- $objMember = MemberModel::findByIdOrAlias(Input::get('items')); |
|
91 |
- |
|
92 |
- // The member does not exist and is not deactivated |
|
93 |
- if ($objMember === null || $objMember->disable) |
|
94 |
- { |
|
95 |
- throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); |
|
96 |
- } |
|
97 |
- |
|
98 |
- // Check for group intersection |
|
99 |
- $arrGroups = StringUtil::deserialize($this->ext_groups); |
|
100 |
- $memberGroups = StringUtil::deserialize($objMember->groups); |
|
101 |
- |
|
102 |
- if (empty($arrGroups) || !\is_array($arrGroups) || !\count(array_intersect($arrGroups, $memberGroups))) |
|
103 |
- { |
|
104 |
- throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); |
|
105 |
- } |
|
106 |
- |
|
107 |
- $arrMemberFields = StringUtil::deserialize($this->memberFields, true); |
|
108 |
- |
|
109 |
- $objTemplate = new FrontendTemplate($this->memberReaderTpl ?: $this->strMemberTemplate); |
|
110 |
- $objTemplate->setData($objMember->row()); |
|
111 |
- |
|
112 |
- $this->Template->member = $this->parseMemberTemplate($objMember, $objTemplate, $arrMemberFields, $this->imgSize); |
|
113 |
- } |
|
114 |
-} |
... | ... |
@@ -48,22 +48,23 @@ class ModuleMemberReader extends ModuleMemberExtension |
48 | 48 |
protected $strMemberTemplate = 'memberExtension_reader_full'; |
49 | 49 |
|
50 | 50 |
/** |
51 |
- * Return a wildcard in the back end |
|
51 |
+ * Display a wildcard in the back end |
|
52 | 52 |
* |
53 | 53 |
* @return string |
54 | 54 |
*/ |
55 | 55 |
public function generate() |
56 | 56 |
{ |
57 |
+ $container = System::getContainer(); |
|
57 | 58 |
$request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
58 | 59 |
|
59 |
- if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
60 |
+ if ($request && $container->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
60 | 61 |
{ |
61 | 62 |
$objTemplate = new BackendTemplate('be_wildcard'); |
62 |
- $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['memberList'][0], 'UTF-8') . ' ###'; |
|
63 |
+ $objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['FMD']['memberList'][0] . ' ###'; |
|
63 | 64 |
$objTemplate->title = $this->headline; |
64 | 65 |
$objTemplate->id = $this->id; |
65 | 66 |
$objTemplate->link = $this->name; |
66 |
- $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
67 |
+ $objTemplate->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do'=>'themes', 'table'=>'tl_module', 'act'=>'edit', 'id'=>$this->id])); |
|
67 | 68 |
|
68 | 69 |
return $objTemplate->parse(); |
69 | 70 |
} |
... | ... |
@@ -35,38 +35,38 @@ use Contao\System; |
35 | 35 |
class ModuleMemberReader extends ModuleMemberExtension |
36 | 36 |
{ |
37 | 37 |
|
38 |
- /** |
|
39 |
- * Template |
|
40 |
- * @var string |
|
41 |
- */ |
|
42 |
- protected $strTemplate = 'mod_memberReader'; |
|
43 |
- |
|
44 |
- /** |
|
45 |
- * Template |
|
46 |
- * @var string |
|
47 |
- */ |
|
48 |
- protected $strMemberTemplate = 'memberExtension_reader_full'; |
|
49 |
- |
|
50 |
- /** |
|
51 |
- * Return a wildcard in the back end |
|
52 |
- * |
|
53 |
- * @return string |
|
54 |
- */ |
|
55 |
- public function generate() |
|
56 |
- { |
|
38 |
+ /** |
|
39 |
+ * Template |
|
40 |
+ * @var string |
|
41 |
+ */ |
|
42 |
+ protected $strTemplate = 'mod_memberReader'; |
|
43 |
+ |
|
44 |
+ /** |
|
45 |
+ * Template |
|
46 |
+ * @var string |
|
47 |
+ */ |
|
48 |
+ protected $strMemberTemplate = 'memberExtension_reader_full'; |
|
49 |
+ |
|
50 |
+ /** |
|
51 |
+ * Return a wildcard in the back end |
|
52 |
+ * |
|
53 |
+ * @return string |
|
54 |
+ */ |
|
55 |
+ public function generate() |
|
56 |
+ { |
|
57 | 57 |
$request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
58 | 58 |
|
59 | 59 |
if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
60 | 60 |
{ |
61 | 61 |
$objTemplate = new BackendTemplate('be_wildcard'); |
62 |
- $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['memberList'][0], 'UTF-8') . ' ###'; |
|
63 |
- $objTemplate->title = $this->headline; |
|
64 |
- $objTemplate->id = $this->id; |
|
65 |
- $objTemplate->link = $this->name; |
|
66 |
- $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
62 |
+ $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['memberList'][0], 'UTF-8') . ' ###'; |
|
63 |
+ $objTemplate->title = $this->headline; |
|
64 |
+ $objTemplate->id = $this->id; |
|
65 |
+ $objTemplate->link = $this->name; |
|
66 |
+ $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
67 | 67 |
|
68 |
- return $objTemplate->parse(); |
|
69 |
- } |
|
68 |
+ return $objTemplate->parse(); |
|
69 |
+ } |
|
70 | 70 |
|
71 | 71 |
// Set the item from the auto_item parameter |
72 | 72 |
if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem')) |
... | ... |
@@ -74,14 +74,14 @@ class ModuleMemberReader extends ModuleMemberExtension |
74 | 74 |
Input::setGet('items', Input::get('auto_item')); |
75 | 75 |
} |
76 | 76 |
|
77 |
- return parent::generate(); |
|
78 |
- } |
|
77 |
+ return parent::generate(); |
|
78 |
+ } |
|
79 | 79 |
|
80 |
- /** |
|
81 |
- * Generate the module |
|
82 |
- */ |
|
83 |
- protected function compile() |
|
84 |
- { |
|
80 |
+ /** |
|
81 |
+ * Generate the module |
|
82 |
+ */ |
|
83 |
+ protected function compile() |
|
84 |
+ { |
|
85 | 85 |
$this->Template->referer = 'javascript:history.go(-1)'; |
86 | 86 |
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; |
87 | 87 |
|
... | ... |
@@ -109,5 +109,5 @@ class ModuleMemberReader extends ModuleMemberExtension |
109 | 109 |
$objTemplate->setData($objMember->row()); |
110 | 110 |
|
111 | 111 |
$this->Template->member = $this->parseMemberTemplate($objMember, $objTemplate, $arrMemberFields, $this->imgSize); |
112 |
- } |
|
112 |
+ } |
|
113 | 113 |
} |
... | ... |
@@ -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,113 @@ |
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\CoreBundle\Exception\PageNotFoundException; |
|
21 |
+use Contao\Environment; |
|
22 |
+use Contao\FrontendTemplate; |
|
23 |
+use Contao\Input; |
|
24 |
+use Contao\MemberModel; |
|
25 |
+use Contao\StringUtil; |
|
26 |
+use Contao\System; |
|
27 |
+ |
|
28 |
+/** |
|
29 |
+ * Class ModuleMemberList |
|
30 |
+ * |
|
31 |
+ * @property string $ext_groups considered member groups |
|
32 |
+ * @property string $memberFields Fields to be displayed |
|
33 |
+ * @property string $memberReaderTpl Frontend reader template |
|
34 |
+ */ |
|
35 |
+class ModuleMemberReader extends ModuleMemberExtension |
|
36 |
+{ |
|
37 |
+ |
|
38 |
+ /** |
|
39 |
+ * Template |
|
40 |
+ * @var string |
|
41 |
+ */ |
|
42 |
+ protected $strTemplate = 'mod_memberReader'; |
|
43 |
+ |
|
44 |
+ /** |
|
45 |
+ * Template |
|
46 |
+ * @var string |
|
47 |
+ */ |
|
48 |
+ protected $strMemberTemplate = 'memberExtension_reader_full'; |
|
49 |
+ |
|
50 |
+ /** |
|
51 |
+ * Return a wildcard in the back end |
|
52 |
+ * |
|
53 |
+ * @return string |
|
54 |
+ */ |
|
55 |
+ public function generate() |
|
56 |
+ { |
|
57 |
+ $request = System::getContainer()->get('request_stack')->getCurrentRequest(); |
|
58 |
+ |
|
59 |
+ if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request)) |
|
60 |
+ { |
|
61 |
+ $objTemplate = new BackendTemplate('be_wildcard'); |
|
62 |
+ $objTemplate->wildcard = '### ' . mb_strtoupper($GLOBALS['TL_LANG']['FMD']['memberList'][0], 'UTF-8') . ' ###'; |
|
63 |
+ $objTemplate->title = $this->headline; |
|
64 |
+ $objTemplate->id = $this->id; |
|
65 |
+ $objTemplate->link = $this->name; |
|
66 |
+ $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; |
|
67 |
+ |
|
68 |
+ return $objTemplate->parse(); |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ // Set the item from the auto_item parameter |
|
72 |
+ if (!isset($_GET['items']) && isset($_GET['auto_item']) && Config::get('useAutoItem')) |
|
73 |
+ { |
|
74 |
+ Input::setGet('items', Input::get('auto_item')); |
|
75 |
+ } |
|
76 |
+ |
|
77 |
+ return parent::generate(); |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ /** |
|
81 |
+ * Generate the module |
|
82 |
+ */ |
|
83 |
+ protected function compile() |
|
84 |
+ { |
|
85 |
+ $this->Template->referer = 'javascript:history.go(-1)'; |
|
86 |
+ $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; |
|
87 |
+ |
|
88 |
+ // Get the member |
|
89 |
+ $objMember = MemberModel::findByIdOrAlias(Input::get('items')); |
|
90 |
+ |
|
91 |
+ // The member does not exist and is not deactivated |
|
92 |
+ if ($objMember === null || $objMember->disable) |
|
93 |
+ { |
|
94 |
+ throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); |
|
95 |
+ } |
|
96 |
+ |
|
97 |
+ // Check for group intersection |
|
98 |
+ $arrGroups = StringUtil::deserialize($this->ext_groups); |
|
99 |
+ $memberGroups = StringUtil::deserialize($objMember->groups); |
|
100 |
+ |
|
101 |
+ if (empty($arrGroups) || !\is_array($arrGroups) || !\count(array_intersect($arrGroups, $memberGroups))) |
|
102 |
+ { |
|
103 |
+ throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ $arrMemberFields = StringUtil::deserialize($this->memberFields, true); |
|
107 |
+ |
|
108 |
+ $objTemplate = new FrontendTemplate($this->memberReaderTpl ?: $this->strMemberTemplate); |
|
109 |
+ $objTemplate->setData($objMember->row()); |
|
110 |
+ |
|
111 |
+ $this->Template->member = $this->parseMemberTemplate($objMember, $objTemplate, $arrMemberFields, $this->imgSize); |
|
112 |
+ } |
|
113 |
+} |