aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/container/ContainerBuilder.php4
-rw-r--r--application/container/ShaarliContainer.php2
-rw-r--r--application/front/controllers/LoginController.php2
-rw-r--r--application/front/controllers/ShaarliController.php38
4 files changed, 45 insertions, 1 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php
index ff29825c..e2c78ccc 100644
--- a/application/container/ContainerBuilder.php
+++ b/application/container/ContainerBuilder.php
@@ -72,6 +72,10 @@ class ContainerBuilder
72 ); 72 );
73 }; 73 };
74 74
75 $container['pluginManager'] = function (ShaarliContainer $container): PluginManager {
76 return new PluginManager($container->conf);
77 };
78
75 return $container; 79 return $container;
76 } 80 }
77} 81}
diff --git a/application/container/ShaarliContainer.php b/application/container/ShaarliContainer.php
index f5483d5e..3fa9116e 100644
--- a/application/container/ShaarliContainer.php
+++ b/application/container/ShaarliContainer.php
@@ -7,6 +7,7 @@ namespace Shaarli\Container;
7use Shaarli\Bookmark\BookmarkServiceInterface; 7use Shaarli\Bookmark\BookmarkServiceInterface;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Shaarli\Render\PageBuilder; 11use Shaarli\Render\PageBuilder;
11use Shaarli\Security\LoginManager; 12use Shaarli\Security\LoginManager;
12use Shaarli\Security\SessionManager; 13use Shaarli\Security\SessionManager;
@@ -21,6 +22,7 @@ use Slim\Container;
21 * @property History $history 22 * @property History $history
22 * @property BookmarkServiceInterface $bookmarkService 23 * @property BookmarkServiceInterface $bookmarkService
23 * @property PageBuilder $pageBuilder 24 * @property PageBuilder $pageBuilder
25 * @property PluginManager $pluginManager
24 */ 26 */
25class ShaarliContainer extends Container 27class ShaarliContainer extends Container
26{ 28{
diff --git a/application/front/controllers/LoginController.php b/application/front/controllers/LoginController.php
index 47fa3ee3..23efb592 100644
--- a/application/front/controllers/LoginController.php
+++ b/application/front/controllers/LoginController.php
@@ -41,6 +41,6 @@ class LoginController extends ShaarliController
41 ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli')) 41 ->assignView('pagetitle', t('Login') .' - '. $this->ci->conf->get('general.title', 'Shaarli'))
42 ; 42 ;
43 43
44 return $response->write($this->ci->pageBuilder->render('loginform')); 44 return $response->write($this->render('loginform'));
45 } 45 }
46} 46}
diff --git a/application/front/controllers/ShaarliController.php b/application/front/controllers/ShaarliController.php
index 2a166c3c..99e66d53 100644
--- a/application/front/controllers/ShaarliController.php
+++ b/application/front/controllers/ShaarliController.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Front\Controller; 5namespace Shaarli\Front\Controller;
6 6
7use Shaarli\Bookmark\BookmarkFilter;
7use Shaarli\Container\ShaarliContainer; 8use Shaarli\Container\ShaarliContainer;
8 9
9abstract class ShaarliController 10abstract class ShaarliController
@@ -28,4 +29,41 @@ abstract class ShaarliController
28 29
29 return $this; 30 return $this;
30 } 31 }
32
33 protected function render(string $template): string
34 {
35 $this->assignView('linkcount', $this->ci->bookmarkService->count(BookmarkFilter::$ALL));
36 $this->assignView('privateLinkcount', $this->ci->bookmarkService->count(BookmarkFilter::$PRIVATE));
37 $this->assignView('plugin_errors', $this->ci->pluginManager->getErrors());
38
39 $this->executeDefaultHooks($template);
40
41 return $this->ci->pageBuilder->render($template);
42 }
43
44 /**
45 * Call plugin hooks for header, footer and includes, specifying which page will be rendered.
46 * Then assign generated data to RainTPL.
47 */
48 protected function executeDefaultHooks(string $template): void
49 {
50 $common_hooks = [
51 'includes',
52 'header',
53 'footer',
54 ];
55
56 foreach ($common_hooks as $name) {
57 $plugin_data = [];
58 $this->ci->pluginManager->executeHooks(
59 'render_' . $name,
60 $plugin_data,
61 [
62 'target' => $template,
63 'loggedin' => $this->ci->loginManager->isLoggedIn()
64 ]
65 );
66 $this->assignView('plugins_' . $name, $plugin_data);
67 }
68 }
31} 69}