* (bug 2274) Respect stub threshold in category page list
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Jun 2005 10:29:34 +0000 (10:29 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Jun 2005 10:29:34 +0000 (10:29 +0000)
Uses page_len field, so doesn't have to do extra lookups.

includes/CategoryPage.php
includes/Linker.php

index 2d09936..d7a1b40 100644 (file)
@@ -91,7 +91,7 @@ class CategoryPage extends Article {
                $limit = 200;
                $res = $dbr->select(
                        array( 'page', 'categorylinks' ),
-                       array( 'page_title', 'page_namespace', 'cl_sortkey' ),
+                       array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ),
                        array( $pageCondition,
                               'cl_from          =  page_id',
                               'cl_to'           => $this->mTitle->getDBKey()),
@@ -139,7 +139,7 @@ class CategoryPage extends Article {
                                }
                        } else {
                                // Page in this category
-                               array_push( $articles, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) ) ;
+                               array_push( $articles, $sk->makeSizeLinkObj( $x->page_len, $title, $wgContLang->convert( $title->getText() ) ) ) ;
                                array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) );
                        }
                }
index fdf5c88..3bdbab9 100644 (file)
@@ -309,6 +309,28 @@ class Linker {
                return $s;
        }
 
+       /**
+        * Generate either a normal exists-style link or a stub link, depending
+        * on the given page size.
+        *
+        * @param int $size
+        * @param Title $nt
+        * @param string $text
+        * @param string $query
+        * @param string $trail
+        * @param string $prefix
+        * @return string HTML of link
+        */
+       function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+               global $wgUser;
+               $threshold = IntVal( $wgUser->getOption( 'stubthreshold' ) );
+               if( $size < $threshold ) {
+                       return $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
+               } else {
+                       return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
+               }
+       }
+
        /** @todo document */
        function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                $u = $nt->escapeLocalURL( $query );