Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | } |
197 | 197 | |
198 | 198 | public function getAllowedParams() { |
199 | | - global $wgRestrictionTypes, $wgRestrictionLevels; |
| 199 | + global $wgRestrictionLevels; |
200 | 200 | |
201 | 201 | return array( |
202 | 202 | 'from' => null, |
— | — | @@ -220,7 +220,7 @@ |
221 | 221 | ApiBase::PARAM_TYPE => 'integer', |
222 | 222 | ), |
223 | 223 | 'prtype' => array( |
224 | | - ApiBase::PARAM_TYPE => $wgRestrictionTypes, |
| 224 | + ApiBase::PARAM_TYPE => Title::getFilteredRestrictionTypes( true ), |
225 | 225 | ApiBase::PARAM_ISMULTI => true |
226 | 226 | ), |
227 | 227 | 'prlevel' => array( |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -4116,14 +4116,8 @@ |
4117 | 4117 | * @return array applicable restriction types |
4118 | 4118 | */ |
4119 | 4119 | public function getRestrictionTypes() { |
4120 | | - global $wgRestrictionTypes; |
| 4120 | + $types = self::getFilteredRestrictionTypes( $this->exists() ); |
4121 | 4121 | |
4122 | | - $types = $wgRestrictionTypes; |
4123 | | - |
4124 | | - if ( !$this->exists() ) { |
4125 | | - # Only the create and upload types are applicable for non-existing titles |
4126 | | - $types = array_intersect( $types, array( 'create', 'upload' ) ); |
4127 | | - } |
4128 | 4122 | if ( $this->getNamespace() != NS_FILE ) { |
4129 | 4123 | # Remove the upload restriction for non-file titles |
4130 | 4124 | $types = array_diff( $types, array( 'upload' ) ); |
— | — | @@ -4136,6 +4130,25 @@ |
4137 | 4131 | |
4138 | 4132 | return $types; |
4139 | 4133 | } |
| 4134 | + /** |
| 4135 | + * Get a filtered list of all restriction types supported by this wiki. |
| 4136 | + * @param bool $exists True to get all restriction types that apply to |
| 4137 | + * titles that do exist, False for all restriction types that apply to |
| 4138 | + * titles that do not exist |
| 4139 | + * @return array |
| 4140 | + */ |
| 4141 | + public static function getFilteredRestrictionTypes( $exists = true ) { |
| 4142 | + global $wgRestrictionTypes; |
| 4143 | + $types = $wgRestrictionTypes; |
| 4144 | + if ( $exists ) { |
| 4145 | + # Remove the create restriction for existing titles |
| 4146 | + $types = array_diff( $types, array( 'create' ) ); |
| 4147 | + } else { |
| 4148 | + # Only the create and upload restrictions apply to non-existing titles |
| 4149 | + $types = array_intersect( $types, array( 'create', 'upload' ) ); |
| 4150 | + } |
| 4151 | + return $types; |
| 4152 | + } |
4140 | 4153 | |
4141 | 4154 | /** |
4142 | 4155 | * Returns the raw sort key to be used for categories, with the specified |
Index: trunk/phase3/includes/specials/SpecialProtectedpages.php |
— | — | @@ -224,13 +224,11 @@ |
225 | 225 | * @return string Formatted HTML |
226 | 226 | */ |
227 | 227 | protected function getTypeMenu( $pr_type ) { |
228 | | - global $wgRestrictionTypes; |
229 | | - |
230 | 228 | $m = array(); // Temporary array |
231 | 229 | $options = array(); |
232 | 230 | |
233 | 231 | // First pass to load the log names |
234 | | - foreach( $wgRestrictionTypes as $type ) { |
| 232 | + foreach( Title::getFilteredRestrictionTypes( true ) as $type ) { |
235 | 233 | $text = wfMsg("restriction-$type"); |
236 | 234 | $m[$text] = $type; |
237 | 235 | } |