Index: trunk/extensions/MetadataEdit/MetadataEdit.php |
— | — | @@ -24,6 +24,11 @@ |
25 | 25 | */ |
26 | 26 | $wgMetadataWhitelist = ''; |
27 | 27 | |
| 28 | +/** |
| 29 | + * Restrict function to one or more namespaces, i.e. NS_MAIN |
| 30 | + */ |
| 31 | +$wgMetadataNamespaces = array(); |
| 32 | + |
28 | 33 | $dir = dirname( __FILE__ ) . '/'; |
29 | 34 | $wgExtensionMessagesFiles['MetadataEdit'] = $dir . 'MetadataEdit.i18n.php'; |
30 | 35 | |
Index: trunk/extensions/MetadataEdit/MetadataEdit.hooks.php |
— | — | @@ -4,8 +4,7 @@ |
5 | 5 | |
6 | 6 | public static function wfMetadataEditExtractFromArticle( $editPage ) { |
7 | 7 | global $wgMetadataWhitelist, $wgContLang; |
8 | | - |
9 | | - if ( $wgMetadataWhitelist == '' ) { |
| 8 | + if ( $wgMetadataWhitelist == '' || !self::isValidMetadataNamespace( $editPage->mTitle->getNamespace() ) ) { |
10 | 9 | return true; |
11 | 10 | } |
12 | 11 | |
— | — | @@ -95,7 +94,7 @@ |
96 | 95 | } |
97 | 96 | |
98 | 97 | public static function wfMetadataEditOnImportData( $editPage, $request ) { |
99 | | - if ( $request->wasPosted() ) { |
| 98 | + if ( self::isValidMetadataNamespace( $editPage->mTitle->getNamespace() ) && $request->wasPosted() ) { |
100 | 99 | $editPage->mMetaData = rtrim( $request->getText( 'metadata' ) ); |
101 | 100 | } else { |
102 | 101 | $editPage->mMetaData = ''; |
— | — | @@ -115,6 +114,10 @@ |
116 | 115 | } |
117 | 116 | |
118 | 117 | public static function wfMetadataEditOnShowFields( $editPage ) { |
| 118 | + if ( !self::isValidMetadataNamespace( $editPage->mTitle->getNamespace() ) ) { |
| 119 | + return true; |
| 120 | + } |
| 121 | + |
119 | 122 | global $wgContLang, $wgUser; |
120 | 123 | $metadata = htmlspecialchars( $wgContLang->recodeForEdit( $editPage->mMetaData ) ); |
121 | 124 | |
— | — | @@ -147,4 +150,9 @@ |
148 | 151 | } |
149 | 152 | return true; |
150 | 153 | } |
| 154 | + |
| 155 | + public static function isValidMetadataNamespace( $namespace ) { |
| 156 | + global $wgMetadataNamespaces; |
| 157 | + return in_array( $namespace, $wgMetadataNamespaces ); |
| 158 | + } |
151 | 159 | } |