From cb9619a8b81cd2e3ec7b046ac98e9b7d5e459b11 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 4 Jun 2013 01:29:18 -0400 Subject: [PATCH] Set up templating in the admin/ section using hoplite\views. --- admin/home.php | 3 +-- admin/index.php | 12 ++++++++++++ includes/hoplite | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/admin/home.php b/admin/home.php index 80bef6d..b8db8f1 100644 --- a/admin/home.php +++ b/admin/home.php @@ -30,8 +30,7 @@ class HomeAction extends http\Action { public function Invoke(http\Request $request, http\Response $response) { - $response->body = 'Hello World'; - $response->body .= Bugdar::$db->ConstructHTMLDebugBlock(); + $response->context['template'] = 'admin_index'; } } diff --git a/admin/index.php b/admin/index.php index e34a2cc..fa14143 100644 --- a/admin/index.php +++ b/admin/index.php @@ -31,6 +31,8 @@ require_once HOPLITE_ROOT . '/http/output_filter.php'; require_once HOPLITE_ROOT . '/http/response_code.php'; require_once HOPLITE_ROOT . '/http/root_controller.php'; require_once HOPLITE_ROOT . '/http/url_map.php'; +require_once HOPLITE_ROOT . '/views/pdo_cache_backend.php'; +require_once HOPLITE_ROOT . '/views/template_loader.php'; /** * @implements \hoplite\http\RootControllerDelegate @@ -92,4 +94,14 @@ $url_map->set_map(array( $output_filter = new http\OutputFilter($controller); $controller->set_output_filter($output_filter); +$tpl_loader = \hoplite\views\TemplateLoader::GetInstance(); +$tpl_loader->set_template_path(BUGDAR_ROOT . '/admin/templates/%s.tpl'); +$tpl_loader->set_cache_backend(new \hoplite\views\PDOCacheBackend( + Bugdar::$db, // PDO object. + TABLE_PREFIX . 'template', // Database table. + 'filename', // Name column. + 'template', // Data column. + 'timestamp' // Modified time column. +)); + $controller->Run(); diff --git a/includes/hoplite b/includes/hoplite index 27dda14..d2f83c1 160000 --- a/includes/hoplite +++ b/includes/hoplite @@ -1 +1 @@ -Subproject commit 27dda14dbe778b3d448ad82218e97611bee9302d +Subproject commit d2f83c12edda9c38835a5a0561d781a6284baf91 -- 2.43.5