diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-07-26 14:43:10 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-26 14:43:10 +0200 |
commit | 9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9 (patch) | |
tree | 9bfc3c9b185eb0c185d23146d44d42dd6685a4da /application/render/PageBuilder.php | |
parent | bc583903adfd768f115fae438e4d9ed1043682d9 (diff) | |
download | Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.gz Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.tar.zst Shaarli-9fbc42294e7667c5ef19cafa0d1fcfbc1c0f36a9.zip |
New basePath: fix officiel plugin paths and vintage template
Diffstat (limited to 'application/render/PageBuilder.php')
-rw-r--r-- | application/render/PageBuilder.php | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 471724c0..7a716673 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Shaarli\Render; | 3 | namespace Shaarli\Render; |
4 | 4 | ||
5 | use Exception; | 5 | use Exception; |
6 | use exceptions\MissingBasePathException; | ||
6 | use RainTPL; | 7 | use RainTPL; |
7 | use Shaarli\ApplicationUtils; | 8 | use Shaarli\ApplicationUtils; |
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 9 | use Shaarli\Bookmark\BookmarkServiceInterface; |
@@ -156,7 +157,7 @@ class PageBuilder | |||
156 | * Affect variable after controller processing. | 157 | * Affect variable after controller processing. |
157 | * Used for alert messages. | 158 | * Used for alert messages. |
158 | */ | 159 | */ |
159 | protected function finalize(): void | 160 | protected function finalize(string $basePath): void |
160 | { | 161 | { |
161 | // TODO: use the SessionManager | 162 | // TODO: use the SessionManager |
162 | $messageKeys = [ | 163 | $messageKeys = [ |
@@ -170,6 +171,14 @@ class PageBuilder | |||
170 | unset($_SESSION[$messageKey]); | 171 | unset($_SESSION[$messageKey]); |
171 | } | 172 | } |
172 | } | 173 | } |
174 | |||
175 | $this->assign('base_path', $basePath); | ||
176 | $this->assign( | ||
177 | 'asset_path', | ||
178 | $basePath . '/' . | ||
179 | rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' . | ||
180 | $this->conf->get('resource.theme', 'default') | ||
181 | ); | ||
173 | } | 182 | } |
174 | 183 | ||
175 | /** | 184 | /** |
@@ -210,23 +219,6 @@ class PageBuilder | |||
210 | } | 219 | } |
211 | 220 | ||
212 | /** | 221 | /** |
213 | * Render a specific page (using a template file). | ||
214 | * e.g. $pb->renderPage('picwall'); | ||
215 | * | ||
216 | * @param string $page Template filename (without extension). | ||
217 | */ | ||
218 | public function renderPage($page) | ||
219 | { | ||
220 | if ($this->tpl === false) { | ||
221 | $this->initialize(); | ||
222 | } | ||
223 | |||
224 | $this->finalize(); | ||
225 | |||
226 | $this->tpl->draw($page); | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * Render a specific page as string (using a template file). | 222 | * Render a specific page as string (using a template file). |
231 | * e.g. $pb->render('picwall'); | 223 | * e.g. $pb->render('picwall'); |
232 | * | 224 | * |
@@ -234,13 +226,13 @@ class PageBuilder | |||
234 | * | 226 | * |
235 | * @return string Processed template content | 227 | * @return string Processed template content |
236 | */ | 228 | */ |
237 | public function render(string $page): string | 229 | public function render(string $page, string $basePath): string |
238 | { | 230 | { |
239 | if ($this->tpl === false) { | 231 | if ($this->tpl === false) { |
240 | $this->initialize(); | 232 | $this->initialize(); |
241 | } | 233 | } |
242 | 234 | ||
243 | $this->finalize(); | 235 | $this->finalize($basePath); |
244 | 236 | ||
245 | return $this->tpl->draw($page, true); | 237 | return $this->tpl->draw($page, true); |
246 | } | 238 | } |