aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/front/controllers/LoginController.php10
-rw-r--r--application/front/controllers/ShaarliController.php22
2 files changed, 17 insertions, 15 deletions
diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php
index 23efb592..ae3599e0 100644
--- a/application/front/controllers/LoginController.php
+++ b/application/front/controllers/LoginController.php
@@ -22,11 +22,13 @@ class LoginController extends ShaarliController
22{ 22{
23 public function index(Request $request, Response $response): Response 23 public function index(Request $request, Response $response): Response
24 { 24 {
25 if ($this->ci->loginManager->isLoggedIn() || $this->ci->conf->get('security.open_shaarli', false)) { 25 if ($this->container->loginManager->isLoggedIn()
26 || $this->container->conf->get('security.open_shaarli', false)
27 ) {
26 return $response->withRedirect('./'); 28 return $response->withRedirect('./');
27 } 29 }
28 30
29 $userCanLogin = $this->ci->loginManager->canLogin($request->getServerParams()); 31 $userCanLogin = $this->container->loginManager->canLogin($request->getServerParams());
30 if ($userCanLogin !== true) { 32 if ($userCanLogin !== true) {
31 throw new LoginBannedException(); 33 throw new LoginBannedException();
32 } 34 }
@@ -37,8 +39,8 @@ class LoginController extends ShaarliController
37 39
38 $this 40 $this
39 ->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER'))) 41 ->assignView('returnurl', escape($request->getServerParam('HTTP_REFERER')))
40 ->assignView('remember_user_default', $this->ci->conf->get('privacy.remember_user_default', true)) 42 ->assignView('remember_user_default', $this->container->conf->get('privacy.remember_user_default', true))
41 ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli')) 43 ->assignView('pagetitle', t('Login') .' - '. $this->container->conf->get('general.title', 'Shaarli'))
42 ; 44 ;
43 45
44 return $response->write($this->render('loginform')); 46 return $response->write($this->render('loginform'));
diff --git a/application/front/controllers/ShaarliController.php b/application/front/controllers/ShaarliController.php
index 99e66d53..2b828588 100644
--- a/application/front/controllers/ShaarliController.php
+++ b/application/front/controllers/ShaarliController.php
@@ -10,12 +10,12 @@ use Shaarli\Container\ShaarliContainer;
10abstract class ShaarliController 10abstract class ShaarliController
11{ 11{
12 /** @var ShaarliContainer */ 12 /** @var ShaarliContainer */
13 protected $ci; 13 protected $container;
14 14
15 /** @param ShaarliContainer $ci Slim container (extended for attribute completion). */ 15 /** @param ShaarliContainer $container Slim container (extended for attribute completion). */
16 public function __construct(ShaarliContainer $ci) 16 public function __construct(ShaarliContainer $container)
17 { 17 {
18 $this->ci = $ci; 18 $this->container = $container;
19 } 19 }
20 20
21 /** 21 /**
@@ -25,20 +25,20 @@ abstract class ShaarliController
25 */ 25 */
26 protected function assignView(string $name, $value): self 26 protected function assignView(string $name, $value): self
27 { 27 {
28 $this->ci->pageBuilder->assign($name, $value); 28 $this->container->pageBuilder->assign($name, $value);
29 29
30 return $this; 30 return $this;
31 } 31 }
32 32
33 protected function render(string $template): string 33 protected function render(string $template): string
34 { 34 {
35 $this->assignView('linkcount', $this->ci->bookmarkService->count(BookmarkFilter::$ALL)); 35 $this->assignView('linkcount', $this->container->bookmarkService->count(BookmarkFilter::$ALL));
36 $this->assignView('privateLinkcount', $this->ci->bookmarkService->count(BookmarkFilter::$PRIVATE)); 36 $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE));
37 $this->assignView('plugin_errors', $this->ci->pluginManager->getErrors()); 37 $this->assignView('plugin_errors', $this->container->pluginManager->getErrors());
38 38
39 $this->executeDefaultHooks($template); 39 $this->executeDefaultHooks($template);
40 40
41 return $this->ci->pageBuilder->render($template); 41 return $this->container->pageBuilder->render($template);
42 } 42 }
43 43
44 /** 44 /**
@@ -55,12 +55,12 @@ abstract class ShaarliController
55 55
56 foreach ($common_hooks as $name) { 56 foreach ($common_hooks as $name) {
57 $plugin_data = []; 57 $plugin_data = [];
58 $this->ci->pluginManager->executeHooks( 58 $this->container->pluginManager->executeHooks(
59 'render_' . $name, 59 'render_' . $name,
60 $plugin_data, 60 $plugin_data,
61 [ 61 [
62 'target' => $template, 62 'target' => $template,
63 'loggedin' => $this->ci->loginManager->isLoggedIn() 63 'loggedin' => $this->container->loginManager->isLoggedIn()
64 ] 64 ]
65 ); 65 );
66 $this->assignView('plugins_' . $name, $plugin_data); 66 $this->assignView('plugins_' . $name, $plugin_data);