aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-10 22:05:49 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-10 22:05:49 +0000
commitadae1958a95d7e801de91d673e927cac348236d9 (patch)
treedeb60ecca44c95abc5301b0d64bcd08585e85798 /engine
parentea14bfe87eda3af8e8002c64ad909cf592d7fe76 (diff)
downloadelgg-adae1958a95d7e801de91d673e927cac348236d9.tar.gz
elgg-adae1958a95d7e801de91d673e927cac348236d9.tar.bz2
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
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggSite.php8
-rw-r--r--engine/lib/admin.php10
-rw-r--r--engine/lib/cache.php2
-rw-r--r--engine/lib/cron.php20
-rw-r--r--engine/lib/elgglib.php2
-rw-r--r--engine/lib/entities.php2
-rw-r--r--engine/lib/input.php2
-rw-r--r--engine/lib/navigation.php2
-rw-r--r--engine/lib/output.php4
-rw-r--r--engine/lib/pagehandler.php2
-rw-r--r--engine/lib/pageowner.php49
-rw-r--r--engine/lib/plugins.php5
-rw-r--r--engine/lib/river.php2
-rw-r--r--engine/lib/user_settings.php6
-rw-r--r--engine/lib/users.php32
-rw-r--r--engine/tests/api/helpers.php8
16 files changed, 80 insertions, 76 deletions
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index a6499cc97..d3cb0d488 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -398,16 +398,16 @@ class ElggSite extends ElggEntity {
// default public pages
$defaults = array(
'action/login',
- 'pg/register',
+ 'register',
'action/register',
'pages/account/forgotten_password\.php',
'action/user/requestnewpassword',
- 'pg/resetpassword',
+ 'resetpassword',
'upgrade\.php',
'xml-rpc\.php',
'mt/mt-xmlrpc\.cgi',
- 'pg/css/.*',
- 'pg/js/.*'
+ 'css/.*',
+ 'js/.*'
);
// include a hook for plugin authors to include public pages
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 1459c7716..7774f78e0 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -133,7 +133,7 @@ function elgg_register_admin_menu_item($menu_id, $parent_id = NULL, $priority =
// in the admin section parents never have links
if ($parent_id) {
- $href = "pg/admin/$parent_id/$menu_id";
+ $href = "admin/$parent_id/$menu_id";
} else {
$href = NULL;
}
@@ -209,7 +209,7 @@ function admin_init() {
// dashboard
elgg_register_menu_item('page', array(
'name' => 'dashboard',
- 'href' => 'pg/admin/dashboard',
+ 'href' => 'admin/dashboard',
'text' => elgg_echo('admin:dashboard'),
'context' => 'admin',
'priority' => 10,
@@ -217,7 +217,7 @@ function admin_init() {
elgg_register_menu_item('topbar', array(
'name' => 'administration',
- 'href' => 'pg/admin',
+ 'href' => 'admin',
'text' => elgg_view_icon('settings') . elgg_echo('admin'),
'priority' => 100,
'section' => 'alt',
@@ -262,7 +262,7 @@ function elgg_admin_add_plugin_settings_menu() {
if (elgg_view_exists("settings/$plugin_id/edit")) {
elgg_register_menu_item('page', array(
'name' => $plugin_id,
- 'href' => "pg/admin/plugin_settings/$plugin_id",
+ 'href' => "admin/plugin_settings/$plugin_id",
'text' => $plugin->manifest->getName(),
'parent_name' => 'plugin_settings',
'context' => 'admin',
@@ -369,7 +369,7 @@ function admin_settings_page_handler($page) {
/**
* Serves up screenshots for plugins from
- * elgg/pg/admin_plugin_ss/<plugin_id>/<size>/<ss_name>.<ext>
+ * elgg/admin_plugin_ss/<plugin_id>/<size>/<ss_name>.<ext>
*
* @param array $pages The pages array
* @return true
diff --git a/engine/lib/cache.php b/engine/lib/cache.php
index 32f36ff03..bc279e8ea 100644
--- a/engine/lib/cache.php
+++ b/engine/lib/cache.php
@@ -168,7 +168,7 @@ function elgg_get_simplecache_url($type, $view) {
$viewtype = elgg_get_viewtype();
$url = elgg_get_site_url() . "cache/$type/$view/$viewtype/$view.$lastcache.$type";
} else {
- $url = elgg_get_site_url() . "pg/$type/$view.$lastcache.$type";
+ $url = elgg_get_site_url() . "$type/$view.$lastcache.$type";
}
return $url;
}
diff --git a/engine/lib/cron.php b/engine/lib/cron.php
index ef0cf17b2..2a0b1d665 100644
--- a/engine/lib/cron.php
+++ b/engine/lib/cron.php
@@ -74,16 +74,16 @@ function cron_page_handler($page) {
* @return array
*/
function cron_public_pages($hook, $type, $return_value, $params) {
- $return_value[] = 'pg/cron/minute';
- $return_value[] = 'pg/cron/fiveminute';
- $return_value[] = 'pg/cron/fifteenmin';
- $return_value[] = 'pg/cron/halfhour';
- $return_value[] = 'pg/cron/hourly';
- $return_value[] = 'pg/cron/daily';
- $return_value[] = 'pg/cron/weekly';
- $return_value[] = 'pg/cron/monthly';
- $return_value[] = 'pg/cron/yearly';
- $return_value[] = 'pg/cron/reboot';
+ $return_value[] = 'cron/minute';
+ $return_value[] = 'cron/fiveminute';
+ $return_value[] = 'cron/fifteenmin';
+ $return_value[] = 'cron/halfhour';
+ $return_value[] = 'cron/hourly';
+ $return_value[] = 'cron/daily';
+ $return_value[] = 'cron/weekly';
+ $return_value[] = 'cron/monthly';
+ $return_value[] = 'cron/yearly';
+ $return_value[] = 'cron/reboot';
return $return_value;
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index c97fa433c..bc272fbd7 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1761,7 +1761,7 @@ function elgg_is_valid_options_for_batch_operation($options, $type) {
* @return boolean
*/
function elgg_walled_garden_index() {
- elgg_register_css('/pg/css/walled_garden.css');
+ elgg_register_css('/css/walled_garden.css');
$login = elgg_view('core/account/login_walled_garden');
echo elgg_view_page('', $login, 'walled_garden');
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index eff0330a1..3bf3259e2 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1819,7 +1819,7 @@ function get_entity_url($entity_guid) {
}
if ($url == "") {
- $url = "pg/view/" . $entity_guid;
+ $url = "view/" . $entity_guid;
}
return elgg_normalize_url($url);
diff --git a/engine/lib/input.php b/engine/lib/input.php
index cbc112772..c3fabbe5d 100644
--- a/engine/lib/input.php
+++ b/engine/lib/input.php
@@ -197,7 +197,7 @@ function elgg_clear_sticky_value($form_name, $variable) {
/**
* Page handler for autocomplete endpoint.
*
- * /pg/livesearch/?q=<query>
+ * /livesearch?q=<query>
*
* Other options include:
* match_on string all|array(groups|users|friends|subtype)
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 8c71de03a..891527d38 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -258,7 +258,7 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) {
$options = array(
'name' => 'edit',
'text' => elgg_echo('edit'),
- 'href' => "pg/$handler/edit/{$entity->getGUID()}",
+ 'href' => "$handler/edit/{$entity->getGUID()}",
'priority' => 200,
);
$return[] = ElggMenuItem::factory($options);
diff --git a/engine/lib/output.php b/engine/lib/output.php
index cba1ffae9..7a38e5b8c 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -225,7 +225,7 @@ function elgg_clean_vars(array $vars = array()) {
*
* @example
* elgg_normalize_url(''); // 'http://my.site.com/'
- * elgg_normalize_url('pg/dashboard'); // 'http://my.site.com/pg/dashboard'
+ * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard'
* elgg_normalize_url('http://google.com/'); // no change
* elgg_normalize_url('//google.com/'); // no change
*
@@ -255,7 +255,7 @@ function elgg_normalize_url($url) {
return "http://$url";
}
- // 'pg/page/handler', 'mod/plugin/file.php'
+ // 'page/handler', 'mod/plugin/file.php'
else {
// trim off any leading / because the site URL is stored
// with a trailing /
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index 1fa073c1e..e598d6821 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -53,7 +53,7 @@ function page_handler($handler, $page) {
* Registers a page handler for a particular identifier
*
* For example, you can register a function called 'blog_page_handler' for handler type 'blog'
- * For all URLs http://yoururl/pg/blog/*, the blog_page_handler() function will be called.
+ * For all URLs http://yoururl/blog/*, the blog_page_handler() function will be called.
* The part of the URL marked with * above will be exploded on '/' characters and passed as an
* array to that function.
* For example, the URL http://yoururl/blog/username/friends/ would result in the call:
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);
}
}
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index e0a6f134d..981896588 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -538,8 +538,9 @@ function elgg_get_calling_plugin_id($mainfilename = false) {
}
}
} else {
- if (preg_match("/pg\/([a-zA-Z0-9\-\_]*)\//", $_SERVER['REQUEST_URI'], $matches)) {
- return $matches[1];
+ //@todo this is a hack -- plugins do not have to match their page handler names!
+ if ($handler = get_input('handler', FALSE)) {
+ return $handler;
} else {
$file = $_SERVER["SCRIPT_NAME"];
$file = str_replace("\\", "/", $file);
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 3a351805e..c0100bb81 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -532,7 +532,7 @@ function elgg_river_page_handler($page) {
*/
function elgg_river_init() {
elgg_register_page_handler('activity', 'elgg_river_page_handler');
- $item = new ElggMenuItem('activity', elgg_echo('activity'), 'pg/activity');
+ $item = new ElggMenuItem('activity', elgg_echo('activity'), 'activity');
elgg_register_menu_item('site', $item);
}
diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php
index f3e586851..5c4d1fbe4 100644
--- a/engine/lib/user_settings.php
+++ b/engine/lib/user_settings.php
@@ -254,19 +254,19 @@ function usersettings_pagesetup() {
$params = array(
'name' => '1_account',
'text' => elgg_echo('usersettings:user:opt:linktext'),
- 'href' => "pg/settings/user/{$user->username}",
+ 'href' => "settings/user/{$user->username}",
);
elgg_register_menu_item('page', $params);
$params = array(
'name' => '1_plugins',
'text' => elgg_echo('usersettings:plugins:opt:linktext'),
- 'href' => "pg/settings/plugins/{$user->username}",
+ 'href' => "settings/plugins/{$user->username}",
);
elgg_register_menu_item('page', $params);
$params = array(
'name' => '1_statistics',
'text' => elgg_echo('usersettings:statistics:opt:linktext'),
- 'href' => "pg/settings/statistics/{$user->username}",
+ 'href' => "settings/statistics/{$user->username}",
);
elgg_register_menu_item('page', $params);
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 318cd71bd..ef673cacb 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -689,7 +689,7 @@ function send_new_password_request($user_guid) {
// generate link
- $link = $CONFIG->site->url . "pg/resetpassword?u=$user_guid&c=$code";
+ $link = $CONFIG->site->url . "resetpassword?u=$user_guid&c=$code";
// generate email
$email = elgg_echo('email:resetreq:body', array($user->name, $_SERVER['REMOTE_ADDR'], $link));
@@ -1089,13 +1089,13 @@ function collections_submenu_items() {
elgg_register_menu_item('page', array(
'name' => 'friends:view:collections',
'text' => elgg_echo('friends:collections'),
- 'href' => "pg/collections/$user->username",
+ 'href' => "collections/$user->username",
));
/*
elgg_register_menu_item('page', array(
'name' => 'friends:collections:add',
'text' => elgg_echo('friends:collections:add'),
- 'href' => "pg/collections/add",
+ 'href' => "collections/add",
));
*
*/
@@ -1268,7 +1268,7 @@ function user_avatar_hook($hook, $entity_type, $returnvalue, $params) {
$size = $params['size'];
if (isset($user->icontime)) {
- return "pg/avatar/view/$user->username/$size/$user->icontime";
+ return "avatar/view/$user->username/$size/$user->icontime";
} else {
return "_graphics/icons/user/default{$size}.gif";
}
@@ -1294,12 +1294,12 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$item->setSection('action');
$return[] = $item;
} else {
- $url = "pg/profile/$user->username/edit";
+ $url = "profile/$user->username/edit";
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('action');
$return[] = $item;
- $url = "pg/avatar/edit/$user->username";
+ $url = "avatar/edit/$user->username";
$item = new ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url);
$item->setSection('action');
$return[] = $item;
@@ -1336,7 +1336,7 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$return[] = $item;
}
- $url = "pg/profile/$user->username/edit";
+ $url = "profile/$user->username/edit";
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
$return[] = $item;
@@ -1403,8 +1403,8 @@ function elgg_profile_fields_setup() {
/**
* Avatar page handler
*
- * /pg/avatar/edit/<username>
- * /pg/avatar/view/<username>/<size>/<icontime>
+ * /avatar/edit/<username>
+ * /avatar/view/<username>/<size>/<icontime>
*
* @param array $page
*/
@@ -1471,7 +1471,7 @@ function users_pagesetup() {
$params = array(
'name' => 'friends',
'text' => elgg_echo('friends'),
- 'href' => 'pg/friends/' . elgg_get_page_owner_entity()->username,
+ 'href' => 'friends/' . elgg_get_page_owner_entity()->username,
'contexts' => array('friends')
);
elgg_register_menu_item('page', $params);
@@ -1479,7 +1479,7 @@ function users_pagesetup() {
$params = array(
'name' => 'friends:of',
'text' => elgg_echo('friends:of'),
- 'href' => 'pg/friendsof/' . elgg_get_page_owner_entity()->username,
+ 'href' => 'friendsof/' . elgg_get_page_owner_entity()->username,
'contexts' => array('friends')
);
elgg_register_menu_item('page', $params);
@@ -1490,14 +1490,14 @@ function users_pagesetup() {
if ($user) {
elgg_register_menu_item('page', array(
'name' => 'edit_avatar',
- 'href' => "pg/avatar/edit/{$user->username}",
+ 'href' => "avatar/edit/{$user->username}",
'text' => elgg_echo('avatar:edit'),
'contexts' => array('profile_edit'),
));
elgg_register_menu_item('page', array(
'name' => 'edit_profile',
- 'href' => "pg/profile/{$user->username}/edit",
+ 'href' => "profile/{$user->username}/edit",
'text' => elgg_echo('profile:edit'),
'contexts' => array('profile_edit'),
));
@@ -1512,7 +1512,7 @@ function users_pagesetup() {
elgg_register_menu_item('topbar', array(
'name' => 'friends',
- 'href' => "pg/friends/{$user->username}",
+ 'href' => "friends/{$user->username}",
'text' => elgg_view_icon('friends'),
'title' => elgg_echo('friends'),
'priority' => 300,
@@ -1520,7 +1520,7 @@ function users_pagesetup() {
elgg_register_menu_item('topbar', array(
'name' => 'usersettings',
- 'href' => "pg/settings/user/{$user->username}",
+ 'href' => "settings/user/{$user->username}",
'text' => elgg_view_icon('settings') . elgg_echo('settings'),
'priority' => 500,
'section' => 'alt',
@@ -1557,7 +1557,7 @@ function users_init() {
elgg_register_page_handler('profile', 'elgg_profile_page_handler');
elgg_register_page_handler('collections', 'collections_page_handler');
- $item = new ElggMenuItem('members', elgg_echo('members'), 'pg/members');
+ $item = new ElggMenuItem('members', elgg_echo('members'), 'members');
elgg_register_menu_item('site', $item);
elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'elgg_user_hover_menu');
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index e969eb6c8..488fd8390 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -76,15 +76,15 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
'example.com' => 'http://example.com',
'example.com/subpage' => 'http://example.com/subpage',
- 'pg/page/handler' => elgg_get_site_url() . 'pg/page/handler',
- 'pg/page/handler?p=v&p2=v2' => elgg_get_site_url() . 'pg/page/handler?p=v&p2=v2',
+ 'page/handler' => elgg_get_site_url() . 'page/handler',
+ 'page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2',
'mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php',
'mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2',
'rootfile.php' => elgg_get_site_url() . 'rootfile.php',
'rootfile.php?p=v&p2=v2' => elgg_get_site_url() . 'rootfile.php?p=v&p2=v2',
- '/pg/page/handler' => elgg_get_site_url() . 'pg/page/handler',
- '/pg/page/handler?p=v&p2=v2' => elgg_get_site_url() . 'pg/page/handler?p=v&p2=v2',
+ '/page/handler' => elgg_get_site_url() . 'page/handler',
+ '/page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2',
'/mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php',
'/mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2',
'/rootfile.php' => elgg_get_site_url() . 'rootfile.php',