http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82858
Revision: 82858
Author: btongminh
Date: 2011-02-26 16:29:48 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
Follow-up r82853: Filter out create restriction from SpecialProtectedPages and
Api. Added Title::getFilteredRestrictionTypes() for this purpose.
Modified Paths:
--------------
trunk/phase3/includes/Title.php
trunk/phase3/includes/api/ApiQueryAllpages.php
trunk/phase3/includes/specials/SpecialProtectedpages.php
Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php 2011-02-26 16:19:36 UTC (rev 82857)
+++ trunk/phase3/includes/Title.php 2011-02-26 16:29:48 UTC (rev 82858)
@@ -4116,14 +4116,8 @@
* @return array applicable restriction types
*/
public function getRestrictionTypes() {
- global $wgRestrictionTypes;
+ $types = self::getFilteredRestrictionTypes( $this->exists() );
- $types = $wgRestrictionTypes;
-
- if ( !$this->exists() ) {
- # Only the create and upload types are applicable for
non-existing titles
- $types = array_intersect( $types, array( 'create',
'upload' ) );
- }
if ( $this->getNamespace() != NS_FILE ) {
# Remove the upload restriction for non-file titles
$types = array_diff( $types, array( 'upload' ) );
@@ -4136,6 +4130,25 @@
return $types;
}
+ /**
+ * Get a filtered list of all restriction types supported by this wiki.
+ * @param bool $exists True to get all restriction types that apply to
+ * titles that do exist, False for all restriction types that apply to
+ * titles that do not exist
+ * @return array
+ */
+ public static function getFilteredRestrictionTypes( $exists = true ) {
+ global $wgRestrictionTypes;
+ $types = $wgRestrictionTypes;
+ if ( $exists ) {
+ # Remove the create restriction for existing titles
+ $types = array_diff( $types, array( 'create' ) );
+ } else {
+ # Only the create and upload restrictions apply to
non-existing titles
+ $types = array_intersect( $types, array( 'create',
'upload' ) );
+ }
+ return $types;
+ }
/**
* Returns the raw sort key to be used for categories, with the
specified
Modified: trunk/phase3/includes/api/ApiQueryAllpages.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryAllpages.php 2011-02-26 16:19:36 UTC
(rev 82857)
+++ trunk/phase3/includes/api/ApiQueryAllpages.php 2011-02-26 16:29:48 UTC
(rev 82858)
@@ -195,7 +195,7 @@
}
public function getAllowedParams() {
- global $wgRestrictionTypes, $wgRestrictionLevels;
+ global $wgRestrictionLevels;
return array(
'from' => null,
@@ -220,7 +220,7 @@
ApiBase::PARAM_TYPE => 'integer',
),
'prtype' => array(
- ApiBase::PARAM_TYPE => $wgRestrictionTypes,
+ ApiBase::PARAM_TYPE =>
Title::getFilteredRestrictionTypes( true ),
ApiBase::PARAM_ISMULTI => true
),
'prlevel' => array(
Modified: trunk/phase3/includes/specials/SpecialProtectedpages.php
===================================================================
--- trunk/phase3/includes/specials/SpecialProtectedpages.php 2011-02-26
16:19:36 UTC (rev 82857)
+++ trunk/phase3/includes/specials/SpecialProtectedpages.php 2011-02-26
16:29:48 UTC (rev 82858)
@@ -224,13 +224,11 @@
* @return string Formatted HTML
*/
protected function getTypeMenu( $pr_type ) {
- global $wgRestrictionTypes;
-
$m = array(); // Temporary array
$options = array();
// First pass to load the log names
- foreach( $wgRestrictionTypes as $type ) {
+ foreach( Title::getFilteredRestrictionTypes( true ) as $type ) {
$text = wfMsg("restriction-$type");
$m[$text] = $type;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs