require_once HOPLITE_ROOT . '/http/action.php';
-class HomeAction extends http\Action
+class HomeAction extends http\Action implements TemplatePreCaching
{
+ public function TemplateSet()
+ {
+ return array('admin_index');
+ }
+
public function Invoke(http\Request $request, http\Response $response)
{
$response->data['title'] = T('Home');
use \bugdar;
use \hoplite\http;
+use \hoplite\views;
chdir('../');
require_once './includes/init.php';
{
$this->controller->StopWithCode(http\ResponseCode::FORBIDDEN);
}
+
+ public function WillInvokeAction(http\Action $action, http\Request $request, http\Response $response)
+ {
+ $templates = array('admin_header', 'admin_footer');
+ if ($action instanceof TemplatePreCaching)
+ $templates = array_merge($templates, $action->TemplateSet());
+ views\TemplateLoader::GetInstance()->PreCache($templates);
+ }
+}
+
+// Actions can implement this interface to have their required templates loaded
+// with the common templates.
+interface TemplatePreCaching
+{
+ // Return an array of template names to cache.
+ public function TemplateSet();
}
$controller = new http\RootController($GLOBALS);
$output_filter = new http\OutputFilter($controller);
$controller->set_output_filter($output_filter);
-$tpl_loader = \hoplite\views\TemplateLoader::GetInstance();
+$tpl_loader = views\TemplateLoader::GetInstance();
$tpl_loader->set_template_path(BUGDAR_ROOT . '/admin/templates/%s.tpl');
-$tpl_loader->set_cache_backend(new \hoplite\views\PDOCacheBackend(
+$tpl_loader->set_cache_backend(new views\PDOCacheBackend(
Bugdar::$db, // PDO object.
TABLE_PREFIX . 'template', // Database table.
'filename', // Name column.