Add experimental $wgActionPaths config option.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 28 Feb 2005 07:07:14 +0000 (07:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 28 Feb 2005 07:07:14 +0000 (07:07 +0000)
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
includes/Title.php

index 995a23b..3bf5b54 100644 (file)
@@ -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
index 850ad4e..9ac3be5 100644 (file)
@@ -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 = '';
                        }