Merge "Function type hints for LinkHolderArray.php"
[lhc/web/wiklou.git] / includes / specials / SpecialPagesWithProp.php
index 27331e5..05f0b2b 100644 (file)
@@ -30,6 +30,7 @@
  */
 class SpecialPagesWithProp extends QueryPage {
        private $propName = null;
+       private $existingPropNames = null;
 
        function __construct( $name = 'PagesWithProp' ) {
                parent::__construct( $name );
@@ -42,21 +43,12 @@ class SpecialPagesWithProp extends QueryPage {
        function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
+               $this->getOutput()->addModuleStyles( 'mediawiki.special.pagesWithProp' );
 
                $request = $this->getRequest();
                $propname = $request->getVal( 'propname', $par );
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select(
-                       'page_props',
-                       'pp_propname',
-                       '',
-                       __METHOD__,
-                       array( 'DISTINCT', 'ORDER BY' => 'pp_propname' )
-               );
-               foreach ( $res as $row ) {
-                       $propnames[$row->pp_propname] = $row->pp_propname;
-               }
+               $propnames = $this->getExistingPropNames();
 
                $form = new HTMLForm( array(
                        'propname' => array(
@@ -86,6 +78,18 @@ class SpecialPagesWithProp extends QueryPage {
                parent::execute( $data['propname'] );
        }
 
+       /**
+        * 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 ) {
+               $subpages = array_keys( $this->getExistingPropNames() );
+               return self::prefixSearchArray( $search, $limit, $subpages );
+       }
+
        /**
         * Disable RSS/Atom feeds
         * @return bool
@@ -135,7 +139,7 @@ class SpecialPagesWithProp extends QueryPage {
                        if ( $isBinary || $isTooLong ) {
                                $message = $this
                                        ->msg( $isBinary ? 'pageswithprop-prophidden-binary' : 'pageswithprop-prophidden-long' )
-                                       ->numParams( round( $valueLength / 1024, 2 ) );
+                                       ->params( $this->getLanguage()->formatSize( $valueLength ) );
 
                                $propValue = Html::element( 'span', array( 'class' => 'prop-value-hidden' ), $message->text() );
                        } else {
@@ -148,6 +152,25 @@ class SpecialPagesWithProp extends QueryPage {
                return $ret;
        }
 
+       public function getExistingPropNames() {
+               if ( $this->existingPropNames === null ) {
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $res = $dbr->select(
+                               'page_props',
+                               'pp_propname',
+                               '',
+                               __METHOD__,
+                               array( 'DISTINCT', 'ORDER BY' => 'pp_propname' )
+                       );
+                       $propnames = array();
+                       foreach ( $res as $row ) {
+                               $propnames[$row->pp_propname] = $row->pp_propname;
+                       }
+                       $this->existingPropNames = $propnames;
+               }
+               return $this->existingPropNames;
+       }
+
        protected function getGroupName() {
                return 'pages';
        }