From adae1958a95d7e801de91d673e927cac348236d9 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Thu, 10 Mar 2011 22:05:49 +0000 Subject: Fixes #2228: Major cleanup of urls -- remove leading pg/ and trailing / from most urls in core and plugins git-svn-id: http://code.elgg.org/elgg/trunk@8653 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/pageowner.php | 49 +++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'engine/lib/pageowner.php') diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php index c7ec0b52b..065a96bc2 100644 --- a/engine/lib/pageowner.php +++ b/engine/lib/pageowner.php @@ -68,12 +68,12 @@ function elgg_set_page_owner_guid($guid) { * parameter. The request parameters used are 'username' and 'owner_guid'. If * the page request is going through the page handling system, this function * attempts to figure out the owner if the url fits the patterns of: - * pg//owner/ - * pg//friends/ - * pg//view/ - * pg//add/ - * pg//edit/ - * pg//group/ + * /owner/ + * /friends/ + * /view/ + * /add/ + * /edit/ + * /group/ * * * @param string $hook 'page_owner' @@ -113,34 +113,35 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params) } // ignore root and query - $uri = current_page_url(); - $path = str_replace(elgg_get_site_url(), '', $uri); - $path = trim($path, "/"); - if (strpos($path, "?")) { - $path = substr($path, 0, strpos($path, "?")); - } - - if (strpos($path, 'pg') === 0) { + $uri = current_page_url(); + $path = str_replace(elgg_get_site_url(), '', $uri); + $path = trim($path, "/"); + if (strpos($path, "?")) { + $path = substr($path, 0, strpos($path, "?")); + } + + // @todo feels hacky + if (get_input('page', FALSE)) { $segments = explode('/', $path); - if (isset($segments[2]) && isset($segments[3])) { - switch ($segments[2]) { + if (isset($segments[1]) && isset($segments[2])) { + switch ($segments[1]) { case 'owner': case 'friends': - $user = get_user_by_username($segments[3]); + $user = get_user_by_username($segments[2]); if ($user) { return $user->getGUID(); } break; case 'view': case 'edit': - $entity = get_entity($segments[3]); + $entity = get_entity($segments[2]); if ($entity) { return $entity->getContainerGUID(); } break; case 'add': case 'group': - $entity = get_entity($segments[3]); + $entity = get_entity($segments[2]); if ($entity) { return $entity->getGUID(); } @@ -160,8 +161,8 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params) * output could be different for those two contexts ('blog' vs 'widget'). * * Pages that pass through the page handling system set the context to the - * first string after 'pg'. Example: http://elgg.org/pg/bookmarks/ results in - * the initial context being set to 'bookmarks'. + * first string after the root url. Example: http://example.org/elgg/bookmarks/ + * results in the initial context being set to 'bookmarks'. * * The context is a stack so that for a widget on a profile, the context stack * may contain first 'profile' and then 'widget'. @@ -261,8 +262,10 @@ function page_owner_boot() { elgg_register_plugin_hook_handler('page_owner', 'system', 'default_page_owner_handler'); $CONFIG->context = array(); - if (preg_match("/\/pg\/([\w\-\_]+)/", $_SERVER['REQUEST_URI'], $matches)) { - elgg_set_context($matches[1]); + // @todo Ew... hacky + $handler = get_input('handler', FALSE); + if ($handler) { + elgg_set_context($handler); } } -- cgit v1.2.3