From 0800bd1afbc080465c91d8bdcd5012bc8e016529 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 14 Aug 2011 13:58:03 -0400 Subject: [PATCH] Add hoplite\views\MakeURL() in a kind of hacky way. --- http/root_controller.php | 3 +++ views/template.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/http/root_controller.php b/http/root_controller.php index 51b6940..f83c9fd 100644 --- a/http/root_controller.php +++ b/http/root_controller.php @@ -108,6 +108,9 @@ class RootController if ($this->request->http_method == 'PUT') parse_str(file_get_contents('php://input'), $this->request->data['_POST']); + // Register self as the active instance. + $GLOBALS[__CLASS__] = $this; + $this->delegate->OnInitialRequest($this->request, $this->response); // Dispatch the request to an Action. diff --git a/views/template.php b/views/template.php index bb18890..18f7796 100644 --- a/views/template.php +++ b/views/template.php @@ -18,7 +18,7 @@ namespace hoplite\views; require_once HOPLITE_ROOT . '/base/filter.php'; -/* +/*! Renders a template with additional vars. @param string The template name to render @param array Variables with which to render. @@ -28,6 +28,16 @@ function Inject($name, $vars = array()) echo TemplateLoader::Fetch($name)->Render($vars); } +/*! @brief Creates a URL via RootController::MakeURL(). + This requires the root controller be set in the $GLOBALS as + hoplite\http\RootController. + @param string Path. +*/ +function MakeURL($path) +{ + return $GLOBALS['hoplite\http\RootController']->MakeURL($path, FALSE); +} + /*! A Template is initialized with a text file (typically HTML) and can render it with data from some model. It has a short macro expansion system, equivalent -- 2.43.5