aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/render
diff options
context:
space:
mode:
Diffstat (limited to 'application/render')
-rw-r--r--application/render/PageBuilder.php32
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 @@
3namespace Shaarli\Render; 3namespace Shaarli\Render;
4 4
5use Exception; 5use Exception;
6use exceptions\MissingBasePathException;
6use RainTPL; 7use RainTPL;
7use Shaarli\ApplicationUtils; 8use Shaarli\ApplicationUtils;
8use Shaarli\Bookmark\BookmarkServiceInterface; 9use 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 }