Index: trunk/extensions/FilePageMasking/FilePageMasking.i18n.php |
— | — | @@ -8,5 +8,5 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $messages['en'] = array( |
12 | | - 'file_masking_desc' => 'Rewrites ".xxx" into "_xxx" in image description page links', |
| 12 | + 'file_masking_desc' => 'Rewrites ".xxx" into "_xxx" in file description page links', |
13 | 13 | ); |
Index: trunk/extensions/FilePageMasking/FilePageMasking.php |
— | — | @@ -1,24 +1,24 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /* |
| 4 | + This extension masks local links for file description pages by modifying the |
| 5 | + file extension at the end of the description page URL so it does not also look |
| 6 | + like a file. This makes it easier for search engines and other programs to |
| 7 | + recognize the file description page as HTML rather than assuming it is also a |
| 8 | + file based on its extension. |
5 | 9 | |
6 | | - This extension masks local links for file description pages by modifying the file extension |
7 | | - at the end of the description page URL so it does not also look like a file. This makes it |
8 | | - easier for search engines and other programs to recognize the file description page as HTML |
9 | | - rather than assuming it is also a file based on its extension. |
10 | | - |
11 | | - By default, extensions of the form ".xxx" are translated to "_xxx". This only occurs |
12 | | - for internal links that should target the file description page. When a file description page |
13 | | - of the form "_xxx" is requested, this extension automatically translates it back to ".xxx" |
14 | | - so that Mediawiki will retrieve the correct page. The choice of masking character can be |
15 | | - set by changing $wgFilePageMaskingCharacter, which defaults to "_". The setting of this |
| 10 | + By default, extensions of the form ".xxx" are translated to "_xxx". This only |
| 11 | + occurs for internal links that should target the file description page. When |
| 12 | + a file description page of the form "_xxx" is requested, this extension |
| 13 | + automatically translates it back to ".xxx" so that Mediawiki will retrieve the |
| 14 | + correct page. The choice of masking character can be set by changing |
| 15 | + $wgFilePageMaskingCharacter, which defaults to "_". The setting of this |
16 | 16 | variable must be a single character, and must be valid in a URL. |
17 | 17 | |
18 | | - This extension relies on $wgFileExtensions to determine the list of case insensitive file |
19 | | - extensions to translate. On sites where $wgStrictFileExtensions is set to false, the user may |
20 | | - upload files with extensions not considered by $wgFileExtensions. If this is the case, those |
| 18 | + This extension relies on $wgFileExtensions to determine the list of case |
| 19 | + insensitive file extensions to translate. On sites where |
| 20 | + $wgStrictFileExtensions is set to false, the user may upload files with |
| 21 | + extensions not considered by $wgFileExtensions. If this is the case, those |
21 | 22 | file extensions will not be masked. |
22 | | - |
23 | 23 | */ |
24 | 24 | |
25 | 25 | if ( ! defined( 'MEDIAWIKI' ) ) |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | 'version' => '1.0', |
32 | 32 | 'description' => 'Converts file extensions ".xxx" to "_xxx" on description page links', // kept for b/c |
33 | 33 | 'descriptionmsg' => 'file_masking_desc', |
34 | | - 'path' => __FILE__, |
| 34 | + 'path' => __FILE__, |
35 | 35 | 'url' => 'http://www.mediawiki.org/wiki/Extension:FilePageMasking', |
36 | 36 | ); |
37 | 37 | |
— | — | @@ -41,19 +41,18 @@ |
42 | 42 | $wgHooks['GetLocalURL'][] = 'wfFilePageMasking_Mask'; |
43 | 43 | $wgHooks['ArticleFromTitle'][] = 'wfFilePageMasking_Unmask'; |
44 | 44 | |
45 | | - |
46 | 45 | /** |
47 | 46 | * This hook applies masking to file page links. |
48 | | - **/ |
| 47 | + **/ |
49 | 48 | function wfFilePageMasking_Mask( &$title, &$url, $query ) { |
50 | 49 | global $wgFileExtensions, $wgFilePageMaskingCharacter; |
51 | 50 | |
52 | | - if( $title->getNamespace() == NS_FILE ) { |
53 | | - $lUrl = strlen($url); |
54 | | - foreach( $wgFileExtensions as $ext ) { |
55 | | - $lExt = strlen($ext); |
| 51 | + if ( $title->getNamespace() == NS_FILE ) { |
| 52 | + $lUrl = strlen( $url ); |
| 53 | + foreach ( $wgFileExtensions as $ext ) { |
| 54 | + $lExt = strlen( $ext ); |
56 | 55 | $p = stripos( $url, "." . $ext, $lUrl - $lExt - 1 ); |
57 | | - if( $p == $lUrl - $lExt - 1 ) { |
| 56 | + if ( $p == $lUrl - $lExt - 1 ) { |
58 | 57 | $url[$p] = $wgFilePageMaskingCharacter; |
59 | 58 | break; |
60 | 59 | } |
— | — | @@ -62,20 +61,19 @@ |
63 | 62 | return true; |
64 | 63 | } |
65 | 64 | |
66 | | - |
67 | 65 | /** |
68 | 66 | * This hook removes masking to file page requests. |
69 | | - **/ |
| 67 | + **/ |
70 | 68 | function wfFilePageMasking_Unmask( &$title, &$article ) { |
71 | 69 | global $wgFileExtensions, $wgFilePageMaskingCharacter; |
72 | 70 | |
73 | | - if( $title->getNamespace() == NS_FILE ) { |
| 71 | + if ( $title->getNamespace() == NS_FILE ) { |
74 | 72 | $name = $title->getDBkey(); |
75 | | - $lName = strlen($name); |
76 | | - foreach( $wgFileExtensions as $ext ) { |
77 | | - $lExt = strlen($ext); |
| 73 | + $lName = strlen( $name ); |
| 74 | + foreach ( $wgFileExtensions as $ext ) { |
| 75 | + $lExt = strlen( $ext ); |
78 | 76 | $p = stripos( $name, $wgFilePageMaskingCharacter . $ext, $lName - $lExt - 1 ); |
79 | | - if( $p == $lName - $lExt - 1 ) { |
| 77 | + if ( $p == $lName - $lExt - 1 ) { |
80 | 78 | $name[$p] = "."; |
81 | 79 | $title = Title::newFromText( $name, NS_FILE ); |
82 | 80 | break; |
— | — | @@ -84,4 +82,3 @@ |
85 | 83 | } |
86 | 84 | return true; |
87 | 85 | } |
88 | | - |