22class ControllerExtensionModuleWebwinkelkeur extends Controller {
33 private $ error = array ();
44
5- public function index ( ) {
6- $ this -> language -> load ( ' common/header ' );
5+ public function __construct ( $ registry ) {
6+ parent :: __construct ( $ registry );
77
8+ $ this ->load ->model ('extension/module/webwinkelkeur ' );
9+ $ this ->load ->model ('localisation/order_status ' );
10+ try {
11+ $ this ->load ->model ('setting/module ' );
12+ } catch (Exception $ e ) {
13+ $ this ->load ->model ('extension/module ' );
14+ $ this ->model_setting_module = $ this ->model_extension_module ;
15+ }
816 $ this ->load ->model ('setting/setting ' );
17+ $ this ->load ->model ('setting/store ' );
18+ }
19+
20+ public function index () {
21+ $ this ->language ->load ('common/header ' );
922
1023 $ path_module = 'extension/module/webwinkelkeur ' ;
11- $ path_extensions = 'marketplace/extension ' ;
24+
25+ $ path_extensions =
26+ is_file (DIR_APPLICATION . 'controller/marketplace/extension.php ' ) ?
27+ 'marketplace/extension ' : 'extension/extension ' ;
1228
1329 $ this ->language ->load ('extension/module/account ' );
1430
1531 $ text_extension = $ this ->language ->get ('text_extension ' );
1632
1733 $ msg = @include DIR_SYSTEM . 'library/webwinkelkeur-messages.php ' ;
1834
19- $ this ->load ->model ('extension/module/webwinkelkeur ' );
20-
2135 $ this ->model_extension_module_webwinkelkeur ->installEvents ();
2236
2337 $ this ->document ->setTitle ($ msg ['WEBWINKELKEUR ' ]);
@@ -40,8 +54,7 @@ public function index() {
4054 $ this ->createModule ($ this ->request ->post );
4155 $ module_id = $ this ->findModule ($ this ->request ->post ['store_id ' ]);
4256 }
43- $ this ->response ->redirect ($ this ->url ->link ($ path_module ,
44- 'user_token= ' . $ this ->session ->data ['user_token ' ] . '&module_id= ' . $ module_id , 'SSL ' ));
57+ $ this ->response ->redirect ($ this ->link ($ path_module , ['module_id ' => $ module_id ]));
4558 }
4659
4760 if ($ this ->validateForm ()) {
@@ -52,7 +65,7 @@ public function index() {
5265
5366 $ new_settings = $ this ->cleanSettings ($ form_data );
5467 $ this ->editSettings ($ new_settings );
55- $ this ->response ->redirect ($ this ->url -> link ($ path_extensions, ' user_token= ' . $ this -> session -> data [ ' user_token ' ], ' SSL ' ));
68+ $ this ->response ->redirect ($ this ->link ($ path_extensions ));
5669 }
5770 }
5871
@@ -70,22 +83,22 @@ public function index() {
7083
7184 $ data ['breadcrumbs ' ][] = array (
7285 'text ' => $ this ->language ->get ('text_home ' ),
73- 'href ' => $ this ->url -> link ('common/dashboard ' , ' user_token= ' . $ this -> session -> data [ ' user_token ' ], ' ssl ' ),
86+ 'href ' => $ this ->link ('common/dashboard ' ),
7487 );
7588
7689 $ data ['breadcrumbs ' ][] = array (
7790 'text ' => $ text_extension ,
78- 'href ' => $ this ->url -> link ($ path_extensions, ' user_token= ' . $ this -> session -> data [ ' user_token ' ], ' ssl ' ),
91+ 'href ' => $ this ->link ($ path_extensions ),
7992 'separator ' => false
8093 );
8194
8295 $ data ['breadcrumbs ' ][] = array (
8396 'text ' => $ msg ['WEBWINKELKEUR ' ],
84- 'href ' => $ this ->url -> link ($ path_module, ' user_token= ' . $ this -> session -> data [ ' user_token ' ], ' ssl ' ),
97+ 'href ' => $ this ->link ($ path_module ),
8598 'separator ' => ' :: '
8699 );
87100
88- $ data ['cancel ' ] = $ this ->url -> link ($ path_extensions, ' user_token= ' . $ this -> session -> data [ ' user_token ' ], ' ssl ' );
101+ $ data ['cancel ' ] = $ this ->link ($ path_extensions );
89102
90103 $ data ['button_save ' ] = $ this ->language ->get ('button_save ' );
91104 $ data ['button_cancel ' ] = $ this ->language ->get ('button_cancel ' );
@@ -97,17 +110,22 @@ public function index() {
97110 'settings ' => $ settings ,
98111 ));
99112
100- $ this ->load ->model ('localisation/order_status ' );
101-
102113 $ data ['order_statuses ' ] = $ this ->model_localisation_order_status ->getOrderStatuses ();
103114
104115 $ data ['invite_errors ' ] = $ this ->model_extension_module_webwinkelkeur ->getInviteErrors ();
105116
106- $ data ['header ' ] = $ this ->load ->controller ('common/header ' ) . $ this ->load ->controller ('common/column_left ' );
117+ $ data ['header ' ] =
118+ $ this ->load ->controller ('common/header ' ) .
119+ $ this ->load ->controller ('common/column_left ' );
107120 $ data ['footer ' ] = $ this ->load ->controller ('common/footer ' );
108121 $ data ['version ' ] = '$VERSION$ ' ;
109122
110- $ this ->response ->setOutput ($ this ->load ->view ('extension/module/webwinkelkeur ' , $ data ));
123+ return $ this ->render ('extension/module/webwinkelkeur ' , $ data );
124+ }
125+
126+ private function render ($ __template , array $ __data ) {
127+ extract ($ __data );
128+ require DIR_TEMPLATE . $ __template . '.tpl ' ;
111129 }
112130
113131 private function validateForm () {
@@ -130,28 +148,22 @@ private function validateSettings(array &$data) {
130148 }
131149
132150 public function install () {
133- $ this ->load ->model ('extension/module/webwinkelkeur ' );
134-
135151 $ this ->model_extension_module_webwinkelkeur ->install ();
136152
137153 $ this ->createModule (array ('store_id ' => 0 ));
138154 $ this ->editSettings ();
139155 }
140156
141157 public function uninstall () {
142- $ this ->load ->model ('extension/module/webwinkelkeur ' );
143-
144158 $ this ->model_extension_module_webwinkelkeur ->uninstall ();
145159 }
146160
147161 private function getSettings () {
148- $ this ->load ->model ('setting/module ' );
149162 if (isset ($ this ->request ->get ['module_id ' ])) {
150163 $ settings = $ this ->model_setting_module ->getModule ($ this ->request ->get ['module_id ' ]);
151164 return $ this ->defaultSettings ($ settings );
152165 }
153166
154- $ this ->load ->model ('setting/setting ' );
155167 $ wwk_settings = $ this ->model_setting_setting ->getSetting ('webwinkelkeur ' );
156168
157169 $ settings = array ();
@@ -210,8 +222,6 @@ private function cleanIntegerArray($array) {
210222 }
211223
212224 private function editSettings (array $ settings = array ()) {
213- $ this ->load ->model ('setting/module ' );
214-
215225 if (isset ($ this ->request ->get ['module_id ' ])) {
216226 $ modules = $ this ->model_setting_module ->getModulesByCode ('webwinkelkeur ' );
217227 foreach ($ modules as $ module ) {
@@ -222,8 +232,6 @@ private function editSettings(array $settings = array()) {
222232 return ;
223233 }
224234
225- $ this ->load ->model ('setting/setting ' );
226-
227235 $ wwk_settings = array ();
228236 foreach ($ settings as $ key => $ value ) {
229237 $ wwk_settings ["webwinkelkeur_ $ {key}" ] = $ value ;
@@ -233,8 +241,6 @@ private function editSettings(array $settings = array()) {
233241 }
234242
235243 private function findModule ($ store ) {
236- $ this ->load ->model ('setting/module ' );
237-
238244 foreach ($ this ->model_setting_module ->getModulesByCode ('webwinkelkeur ' ) as $ module ) {
239245 $ data = $ this ->model_setting_module ->getModule ($ module ['module_id ' ]);
240246 if ($ data ['store_id ' ] == $ store )
@@ -244,9 +250,6 @@ private function findModule($store) {
244250 }
245251
246252 private function createModule ($ settings ) {
247- $ this ->load ->model ('setting/module ' );
248- $ this ->load ->model ('setting/store ' );
249-
250253 $ stores = $ this ->model_setting_store ->getStores ();
251254 foreach ($ stores as $ store ) {
252255 if ($ store ['store_id ' ] == $ settings ['store_id ' ])
@@ -264,4 +267,10 @@ private function createModule($settings) {
264267
265268 $ this ->model_setting_module ->addModule ('webwinkelkeur ' , $ module_settings );
266269 }
270+
271+ private function link ($ action , array $ params = []) {
272+ $ params += array_intersect_key ($ this ->request ->get , array_flip (['token ' , 'user_token ' ]));
273+ return $ this ->url ->link ($ action , http_build_query ($ params ), true );
274+ }
275+
267276}
0 commit comments