From 678704c38419b1621b7e32cdee971effc2728884 Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Mon, 4 Oct 2010 18:03:15 +0300 Subject: [PATCH] Fix URL generation --- controllers/cache.php | 6 +++--- request.php | 6 +++++- services/dispatcher/midgard3.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/controllers/cache.php b/controllers/cache.php index b844751..cc8e2ff 100644 --- a/controllers/cache.php +++ b/controllers/cache.php @@ -13,9 +13,9 @@ */ class midgardmvc_core_controllers_cache { - public function __construct() + public function __construct($request) { - $this->configuration = midgardmvc_core::get_instance()->configuration; + $this->request = $request; } public function get_invalidate(array $args) @@ -25,7 +25,7 @@ public function get_invalidate(array $args) midgardmvc_core::get_instance()->context->cache_enabled = false; midgardmvc_core::get_instance()->head->relocate ( - midgardmvc_core::get_instance()->dispatcher->generate_url($this->request, 'page_read', array()) + midgardmvc_core::get_instance()->dispatcher->generate_url('page_read', array(), $this->request) ); } diff --git a/request.php b/request.php index 88bd8a4..aa47f03 100644 --- a/request.php +++ b/request.php @@ -91,12 +91,16 @@ public function resolve_node($path) /** * Get the request path */ - public function get_path() + public function get_path($include_arguments = true) { if (substr($this->path, -1, 1) !== '/') { $this->path .= '/'; } + if (!$include_arguments) + { + return $this->path; + } return $this->path . implode('/', $this->argv); } diff --git a/services/dispatcher/midgard3.php b/services/dispatcher/midgard3.php index fa46550..7d5072f 100644 --- a/services/dispatcher/midgard3.php +++ b/services/dispatcher/midgard3.php @@ -321,7 +321,7 @@ public function generate_url($route_id, array $args, $intent) //echo ("Deleting context " . $this->midgardmvc->context->get_current_context()); $this->midgardmvc->context->delete(); - return preg_replace('%/{2,}%', '/', $request->get_path() . $link); + return preg_replace('%/{2,}%', '/', $request->get_path(false) . $link); } public function get_midgard_connection()