aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/container/ShaarliContainer.php1
-rw-r--r--application/front/ShaarliMiddleware.php2
-rw-r--r--application/front/controller/visitor/ShaarliVisitorController.php15
-rw-r--r--application/render/PageBuilder.php4
4 files changed, 21 insertions, 1 deletions
diff --git a/application/container/ShaarliContainer.php b/application/container/ShaarliContainer.php
index fec398d0..a95393cd 100644
--- a/application/container/ShaarliContainer.php
+++ b/application/container/ShaarliContainer.php
@@ -22,6 +22,7 @@ use Slim\Container;
22 * Extension of Slim container to document the injected objects. 22 * Extension of Slim container to document the injected objects.
23 * 23 *
24 * @property mixed[] $environment $_SERVER automatically injected by Slim 24 * @property mixed[] $environment $_SERVER automatically injected by Slim
25 * @property string $basePath Shaarli's instance base path (e.g. `/shaarli/`)
25 * @property ConfigManager $conf 26 * @property ConfigManager $conf
26 * @property SessionManager $sessionManager 27 * @property SessionManager $sessionManager
27 * @property LoginManager $loginManager 28 * @property LoginManager $loginManager
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php
index f8992e0b..47aa61bb 100644
--- a/application/front/ShaarliMiddleware.php
+++ b/application/front/ShaarliMiddleware.php
@@ -39,6 +39,8 @@ class ShaarliMiddleware
39 public function __invoke(Request $request, Response $response, callable $next) 39 public function __invoke(Request $request, Response $response, callable $next)
40 { 40 {
41 try { 41 try {
42 $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/');
43
42 $response = $next($request, $response); 44 $response = $next($request, $response);
43 } catch (ShaarliFrontException $e) { 45 } catch (ShaarliFrontException $e) {
44 $this->container->pageBuilder->assign('message', $e->getMessage()); 46 $this->container->pageBuilder->assign('message', $e->getMessage());
diff --git a/application/front/controller/visitor/ShaarliVisitorController.php b/application/front/controller/visitor/ShaarliVisitorController.php
index 98423d90..b90b1e8f 100644
--- a/application/front/controller/visitor/ShaarliVisitorController.php
+++ b/application/front/controller/visitor/ShaarliVisitorController.php
@@ -60,6 +60,19 @@ abstract class ShaarliVisitorController
60 $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE)); 60 $this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE));
61 $this->assignView('plugin_errors', $this->container->pluginManager->getErrors()); 61 $this->assignView('plugin_errors', $this->container->pluginManager->getErrors());
62 62
63 /*
64 * Define base path (if Shaarli is installed in a domain's subfolder, e.g. `/shaarli`)
65 * and the asset path (subfolder/tpl/default for default theme).
66 * These MUST be used to create an internal link or to include an asset in templates.
67 */
68 $this->assignView('base_path', $this->container->basePath);
69 $this->assignView(
70 'asset_path',
71 $this->container->basePath . '/' .
72 rtrim($this->container->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
73 $this->container->conf->get('resource.theme', 'default')
74 );
75
63 $this->executeDefaultHooks($template); 76 $this->executeDefaultHooks($template);
64 77
65 return $this->container->pageBuilder->render($template); 78 return $this->container->pageBuilder->render($template);
@@ -105,7 +118,7 @@ abstract class ShaarliVisitorController
105 array $clearParams = [], 118 array $clearParams = [],
106 string $anchor = null 119 string $anchor = null
107 ): Response { 120 ): Response {
108 $defaultPath = rtrim($request->getUri()->getBasePath(), '/') . '/'; 121 $defaultPath = $this->container->basePath . '/';
109 $referer = $this->container->environment['HTTP_REFERER'] ?? null; 122 $referer = $this->container->environment['HTTP_REFERER'] ?? null;
110 123
111 if (null !== $referer) { 124 if (null !== $referer) {
diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php
index d90ed58b..2779eb90 100644
--- a/application/render/PageBuilder.php
+++ b/application/render/PageBuilder.php
@@ -149,6 +149,10 @@ class PageBuilder
149 */ 149 */
150 protected function finalize(): void 150 protected function finalize(): void
151 { 151 {
152 //FIXME - DEV _ REMOVE ME
153 $this->assign('base_path', '/Shaarli');
154 $this->assign('asset_path', '/Shaarli/tpl/default');
155
152 // TODO: use the SessionManager 156 // TODO: use the SessionManager
153 $messageKeys = [ 157 $messageKeys = [
154 SessionManager::KEY_SUCCESS_MESSAGES, 158 SessionManager::KEY_SUCCESS_MESSAGES,