diff options
Diffstat (limited to 'engine/lib/pageowner.php')
-rw-r--r-- | engine/lib/pageowner.php | 49 |
1 files changed, 26 insertions, 23 deletions
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/<handler>/owner/<username> - * pg/<handler>/friends/<username> - * pg/<handler>/view/<entity guid> - * pg/<handler>/add/<container guid> - * pg/<handler>/edit/<entity guid> - * pg/<handler>/group/<group guid> + * <handler>/owner/<username> + * <handler>/friends/<username> + * <handler>/view/<entity guid> + * <handler>/add/<container guid> + * <handler>/edit/<entity guid> + * <handler>/group/<group guid> * * * @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); } } |