diff --git includes/bootstrap.inc includes/bootstrap.inc index 54826c9..d737595 100644 --- includes/bootstrap.inc +++ includes/bootstrap.inc @@ -2415,7 +2415,44 @@ function arg($index = NULL, $path = NULL) { $path = $_GET['q']; } if (!isset($arguments[$path])) { - $arguments[$path] = explode('/', $path); + $path_parts = explode('/', $path); + + // 'admin' anywhere but index 0? Let's check. + $admin_key = 0; + foreach ($path_parts as $k => $part) { + if (0 == $k) continue; + + // Found an admin? Let's make sure it's valid. + if ('admin' == $part) { + $admin_parts = array_slice($path_parts, $k); + $admin_path = implode('/', $admin_parts); + + // It's valid; drop out. + if (path_is_admin($admin_path)) { + $admin_key = $k; + break; + } + } + } + + // We found an admin page embedded in the link. + if ($admin_key > 0) { + + // Slice out the admin parts after the path and set them as the actual + // path. + $admin_parts = array_slice($path_parts, $admin_key); + $path = implode('/', $admin_parts); + $arguments[$path] = $admin_parts; + + // Assign the regular path to the last_non_admin arg. + $path_parts = array_slice($path_parts, 0, $admin_key); + $arguments[$path]['last_non_admin'] = implode('/', $path_parts); + } + + // Otherwise, default behavior. + else { + $arguments[$path] = $path_parts; + } } if (!isset($index)) { return $arguments[$path]; diff --git modules/system/system.module modules/system/system.module index 0317810..f7f3e84 100644 --- modules/system/system.module +++ modules/system/system.module @@ -1820,7 +1820,6 @@ function system_init() { drupal_add_css(drupal_get_path('module', 'system') . '/system-menus.css', array('weight' => CSS_SYSTEM)); drupal_add_css(drupal_get_path('module', 'system') . '/system-messages.css', array('weight' => CSS_SYSTEM)); - // Ignore slave database servers for this request. // // In Drupal's distributed database structure, new data is written to the master @@ -3691,3 +3690,14 @@ function system_admin_paths() { ); return $paths; } + +/** + * Returns the last non-administrative page visited by an authenticated user. + * + * @return + * A link to the 'back' page, if one is set. + */ +function drupal_get_last_non_admin_page() { + + return arg('last_non_admin'); +}