SpecialPage: DRY array filter for prefixSearchSubpages()
[lhc/web/wiklou.git] / includes / specials / SpecialLog.php
index 5265403..ced5d25 100644 (file)
@@ -80,7 +80,9 @@ class SpecialLog extends SpecialPage {
                $type = $opts->getValue( 'type' );
                if ( !LogPage::isLogType( $type ) ) {
                        $opts->setValue( 'type', '' );
-               } elseif ( isset( $wgLogRestrictions[$type] ) && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] ) ) {
+               } elseif ( isset( $wgLogRestrictions[$type] )
+                       && !$this->getUser()->isAllowed( $wgLogRestrictions[$type] )
+               ) {
                        throw new PermissionsError( $wgLogRestrictions[$type] );
                }
 
@@ -113,6 +115,21 @@ class SpecialLog extends SpecialPage {
                $this->show( $opts, $qc );
        }
 
+       /**
+        * Return an array of subpages beginning with $search that this special page will accept.
+        *
+        * @param string $search Prefix to search for
+        * @param integer $limit Maximum number of results to return
+        * @return string[] Matching subpages
+        */
+       public function prefixSearchSubpages( $search, $limit = 10 ) {
+               global $wgLogTypes;
+               $subpages = $wgLogTypes;
+               $subpages[] = 'all';
+               sort( $subpages );
+               return self::prefixSearchArray( $search, $limit, $subpages );
+       }
+
        private function parseParams( FormOptions $opts, $par ) {
                global $wgLogTypes;
 
@@ -218,7 +235,7 @@ class SpecialLog extends SpecialPage {
 
        /**
         * Set page title and show header for this log type
-        * @param $type string
+        * @param string $type
         * @since 1.19
         */
        protected function addHeader( $type ) {