From 7bbce3f6feded604919290c3825398b18ede9351 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 28 Feb 2005 07:07:14 +0000 Subject: [PATCH] Add experimental $wgActionPaths config option. To set 'pretty' URL paths for actions other than plain page views, add to this array. For instance: 'edit' => "$wgScriptPath/edit/$1" There must be an appropriate script or rewrite rule to handle these URLs. --- includes/DefaultSettings.php | 10 ++++++++++ includes/Title.php | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 995a23b81d..3bf5b5441c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -102,6 +102,16 @@ $wgTmpDirectory = "{$wgUploadDirectory}/tmp"; $wgUploadBaseUrl = ""; /**#@-*/ +/** + * To set 'pretty' URL paths for actions other than + * plain page views, add to this array. For instance: + * 'edit' => "$wgScriptPath/edit/$1" + * + * There must be an appropriate script or rewrite rule + * in place to handle these URLs. + */ +$wgActionPaths = array(); + /** * If you operate multiple wikis, you can define a shared upload path here. * Uploads to this wiki will NOT be put there - they will be put into diff --git a/includes/Title.php b/includes/Title.php index 850ad4e49a..9ac3be5243 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -654,6 +654,17 @@ class Title { if ( $query == '' ) { $url = str_replace( '$1', $dbkey, $wgArticlePath ); } else { + if( preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) ) { + global $wgActionPaths; + $action = urldecode( $matches[2] ); + if( isset( $wgActionPaths[$action] ) ) { + $query = $matches[1]; + if( isset( $matches[4] ) ) $query .= $matches[4]; + $url = str_replace( '$1', $dbkey, $wgActionPaths[$action] ); + if( $query != '' ) $url .= '?' . $query; + return $url; + } + } if ( $query == '-' ) { $query = ''; } -- 2.20.1