$this->assignView('privateLinkcount', $this->container->bookmarkService->count(BookmarkFilter::$PRIVATE));
$this->assignView('plugin_errors', $this->container->pluginManager->getErrors());
+ /*
+ * Define base path (if Shaarli is installed in a domain's subfolder, e.g. `/shaarli`)
+ * and the asset path (subfolder/tpl/default for default theme).
+ * These MUST be used to create an internal link or to include an asset in templates.
+ */
+ $this->assignView('base_path', $this->container->basePath);
+ $this->assignView(
+ 'asset_path',
+ $this->container->basePath . '/' .
+ rtrim($this->container->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
+ $this->container->conf->get('resource.theme', 'default')
+ );
+
$this->executeDefaultHooks($template);
return $this->container->pageBuilder->render($template);
}
}
+ /**
+ * Simple helper which prepend the base path to redirect path.
+ *
+ * @param Response $response
+ * @param string $path Absolute path, e.g.: `/`, or `/admin/shaare/123` regardless of install directory
+ *
+ * @return Response updated
+ */
+ protected function redirect(Response $response, string $path): Response
+ {
+ return $response->withRedirect($this->container->basePath . $path);
+ }
+
/**
* Generates a redirection to the previous page, based on the HTTP_REFERER.
* It fails back to the home page.
array $clearParams = [],
string $anchor = null
): Response {
- $defaultPath = rtrim($request->getUri()->getBasePath(), '/') . '/';
+ $defaultPath = $this->container->basePath . '/';
$referer = $this->container->environment['HTTP_REFERER'] ?? null;
if (null !== $referer) {