Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -903,11 +903,28 @@ |
904 | 904 | indexed by page_id. |
905 | 905 | &$colours: (output) array of CSS classes, indexed by prefixed DB keys |
906 | 906 | |
907 | | -'GetLocalURL': modify local URLs as output into page links |
| 907 | +'GetLocalURL': modify local URLs as output into page links. Note that if you |
| 908 | + are working with internal urls (non-interwiki) then it may be preferable |
| 909 | + to work with the GetLocalURL::Internal or GetLocalURL::Article hooks as |
| 910 | + GetLocalURL can be buggy for internal urls on render if you do not |
| 911 | + re-implement the horrible hack that Title::getLocalURL uses |
| 912 | + in your own extension. |
908 | 913 | $title: Title object of page |
909 | | -$url: string value as output (out parameter, can modify) |
| 914 | +&$url: string value as output (out parameter, can modify) |
910 | 915 | $query: query options passed to Title::getLocalURL() |
| 916 | +$variant: variant options passed to Title::getLocalURL() |
911 | 917 | |
| 918 | +'GetLocalURL::Internal': modify local URLs to internal pages. |
| 919 | +$title: Title object of page |
| 920 | +&$url: string value as output (out parameter, can modify) |
| 921 | +$query: query options passed to Title::getLocalURL() |
| 922 | +$variant: variant options passed to Title::getLocalURL() |
| 923 | + |
| 924 | +'GetLocalURL::Article': modify local URLs specifically pointing to article paths |
| 925 | + without any fancy queries or variants. |
| 926 | +$title: Title object of page |
| 927 | +&$url: string value as output (out parameter, can modify) |
| 928 | + |
912 | 929 | 'GetMetadataVersion': modify the image metadata version currently in use. This is |
913 | 930 | used when requesting image metadata from a ForiegnApiRepo. Media handlers |
914 | 931 | that need to have versioned metadata should add an element to the end of |
— | — | @@ -2056,6 +2073,15 @@ |
2057 | 2074 | $redirect: whether the page is a redirect |
2058 | 2075 | $skin: Skin object |
2059 | 2076 | |
| 2077 | +'WebRequestGetPathInfoRequestURI': while extracting path info from REQUEST_URI. |
| 2078 | + Allows an extension to extend the extraction of titles from paths. |
| 2079 | + Implementing hooks should follow the pattern used in core: |
| 2080 | + * Use the `$matches = WebRequest::extractTitle` pattern |
| 2081 | + * Ensure that you test `if ( !$matches ) {` before you try extracting a title |
| 2082 | + from the path so that you don't override an already found match. |
| 2083 | +$path: The request path to extract a title from. |
| 2084 | +&$matches: The array to apply matches to. |
| 2085 | + |
2060 | 2086 | 'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions |
2061 | 2087 | dumps |
2062 | 2088 | One, and only one hook should set this, and return false. |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -28,6 +28,9 @@ |
29 | 29 | as with templates. |
30 | 30 | * Installer now issues a warning if mod_security is present. |
31 | 31 | * (bug 29455) Add support for a filter callback function in jQuery byteLimit plugin. |
| 32 | +* Extensions can now participate in the extraction of titles from url paths |
| 33 | +* Added two new GetLocalURL hooks to better serve extensions working on a limited |
| 34 | + type of titles. |
32 | 35 | |
33 | 36 | === Bug fixes in 1.19 === |
34 | 37 | * $wgUploadNavigationUrl should be used for file redlinks if |
Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -109,6 +109,8 @@ |
110 | 110 | } |
111 | 111 | $matches = self::extractTitle( $path, $variantPaths, 'variant' ); |
112 | 112 | } |
| 113 | + |
| 114 | + wfRunHooks( 'WebRequestGetPathInfoRequestURI', array( $path, &$matches ) ); |
113 | 115 | } |
114 | 116 | } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { |
115 | 117 | // Mangled PATH_INFO |
— | — | @@ -192,7 +194,7 @@ |
193 | 195 | } |
194 | 196 | |
195 | 197 | /** |
196 | | - * Internal URL rewriting function; tries to extract page title and, |
| 198 | + * URL rewriting function; tries to extract page title and, |
197 | 199 | * optionally, one other fixed parameter value from a URL path. |
198 | 200 | * |
199 | 201 | * @param $path string: the URL path given from the client |
— | — | @@ -201,7 +203,7 @@ |
202 | 204 | * passed on as the value of this URL parameter |
203 | 205 | * @return array of URL variables to interpolate; empty if no match |
204 | 206 | */ |
205 | | - private static function extractTitle( $path, $bases, $key = false ) { |
| 207 | + static function extractTitle( $path, $bases, $key = false ) { |
206 | 208 | foreach( (array)$bases as $keyValue => $base ) { |
207 | 209 | // Find the part after $wgArticlePath |
208 | 210 | $base = str_replace( '$1', '', $base ); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -909,6 +909,7 @@ |
910 | 910 | $url = str_replace( '$1', $dbkey, $url ); |
911 | 911 | } else { |
912 | 912 | $url = str_replace( '$1', $dbkey, $wgArticlePath ); |
| 913 | + wfRunHooks( 'GetLocalURL::Article', array( &$this, &$url ) ); |
913 | 914 | } |
914 | 915 | } else { |
915 | 916 | global $wgActionPaths; |
— | — | @@ -937,6 +938,8 @@ |
938 | 939 | $url = "{$wgScript}?title={$dbkey}&{$query}"; |
939 | 940 | } |
940 | 941 | } |
| 942 | + |
| 943 | + wfRunHooks( 'GetLocalURL::Internal', array( &$this, &$url, $query, $variant ) ); |
941 | 944 | |
942 | 945 | // @todo FIXME: This causes breakage in various places when we |
943 | 946 | // actually expected a local URL and end up with dupe prefixes. |
— | — | @@ -944,7 +947,7 @@ |
945 | 948 | $url = $wgServer . $url; |
946 | 949 | } |
947 | 950 | } |
948 | | - wfRunHooks( 'GetLocalURL', array( &$this, &$url, $query ) ); |
| 951 | + wfRunHooks( 'GetLocalURL', array( &$this, &$url, $query, $variant ) ); |
949 | 952 | return $url; |
950 | 953 | } |
951 | 954 | |