From: Brion Vibber Date: Mon, 28 Feb 2005 07:07:14 +0000 (+0000) Subject: Add experimental $wgActionPaths config option. X-Git-Tag: 1.5.0alpha1~688 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=7bbce3f6feded604919290c3825398b18ede9351;p=lhc%2Fweb%2Fwiklou.git 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. --- 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 = ''; }