Add hoplite\views\MakeURL() in a kind of hacky way.
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Aug 2011 17:58:03 +0000 (13:58 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 14 Aug 2011 17:58:03 +0000 (13:58 -0400)
http/root_controller.php
views/template.php

index 51b69401be5938ea76d27e898ac9d237cdbd5a36..f83c9fdefd01ea6727331b6ad99544484202a091 100644 (file)
@@ -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.
index bb188909d93fb12d17880ac9b9602dc3b29e8449..18f7796c3cdb73ee99e5e0bc835082b076cf9386 100644 (file)
@@ -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