Refactor out protocol preperation to ApiQueryExtLinksUsage::prepareProtocols()
authorSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 19:28:00 +0000 (19:28 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 19:28:00 +0000 (19:28 +0000)
includes/api/ApiQueryExtLinksUsage.php

index 7bfa9cc..1e26a9a 100644 (file)
@@ -154,12 +154,6 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
        }
 
        public function getAllowedParams() {
-               global $wgUrlProtocols;
-               $protocols = array( '' );
-               foreach ( $wgUrlProtocols as $p ) {
-                       $protocols[] = substr( $p, 0, strpos( $p, ':' ) );
-               }
-
                return array(
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
@@ -174,7 +168,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                                ApiBase::PARAM_TYPE => 'integer'
                        ),
                        'protocol' => array(
-                               ApiBase::PARAM_TYPE => $protocols,
+                               ApiBase::PARAM_TYPE => self::prepareProtocols(),
                                ApiBase::PARAM_DFLT => '',
                        ),
                        'query' => null,
@@ -192,6 +186,15 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                );
        }
 
+       public static function prepareProtocols() {
+               global $wgUrlProtocols;
+               $protocols = array( '' );
+               foreach ( $wgUrlProtocols as $p ) {
+                       $protocols[] = substr( $p, 0, strpos( $p, ':' ) );
+               }
+           return $protocols;
+       }
+
        public function getParamDescription() {
                $p = $this->getModulePrefix();
                return array(