Revert accidental commit of experimentation
[lhc/web/wiklou.git] / includes / CategoryPage.php
index e5c11e8..53d6997 100644 (file)
@@ -7,12 +7,7 @@
  */
 
 if( !defined( 'MEDIAWIKI' ) )
-       die();
-
-global $wgCategoryMagicGallery;
-if( $wgCategoryMagicGallery )
-       /** */
-       require_once('ImageGallery.php');
+       die( 1 );
 
 /**
  * @package MediaWiki
@@ -41,17 +36,11 @@ class CategoryPage extends Article {
                # For overloading
        }
 
-       # generate a list of subcategories and pages for a category
-       # depending on wfMsg("usenewcategorypage") it either calls the new
-       # or the old code. The new code will not work properly for some
-       # languages due to sorting issues, so they might want to turn it
-       # off.
-
        function closeShowCategory() {
                global $wgOut, $wgRequest;
-               $pageConditions = array();
                $from = $wgRequest->getVal( 'from' );
                $until = $wgRequest->getVal( 'until' );
+               
                $wgOut->addHTML( $this->doCategoryMagic( $from, $until ) );
        }
 
@@ -61,10 +50,11 @@ class CategoryPage extends Article {
         * @param string $from -- return only sort keys from this item on
         * @param string $until -- don't return keys after this point.
         * @return string HTML output
-        * @access private
+        * @private
         */
        function doCategoryMagic( $from = '', $until = '' ) {
-               global $wgContLang,$wgUser, $wgCategoryMagicGallery;
+               global $wgOut;
+               global $wgContLang,$wgUser, $wgCategoryMagicGallery, $wgCategoryPagingLimit;
                $fname = 'CategoryPage::doCategoryMagic';
                wfProfileIn( $fname );
 
@@ -72,9 +62,11 @@ class CategoryPage extends Article {
                $articles_start_char = array();
                $children = array();
                $children_start_char = array();
-               $data = array();
-               if( $wgCategoryMagicGallery ) {
+               
+               $showGallery = $wgCategoryMagicGallery && !$wgOut->mNoGallery;
+               if( $showGallery ) {
                        $ig = new ImageGallery();
+                       $ig->setParsing();
                }
 
                $dbr =& wfGetDB( DB_SLAVE );
@@ -88,7 +80,7 @@ class CategoryPage extends Article {
                        $pageCondition = '1 = 1';
                        $flip = false;
                }
-               $limit = 200;
+               $limit = $wgCategoryPagingLimit;
                $res = $dbr->select(
                        array( 'page', 'categorylinks' ),
                        array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ),
@@ -130,7 +122,7 @@ class CategoryPage extends Article {
                                        $sortkey=$wgContLang->firstChar( $x->cl_sortkey );
                                }
                                array_push( $children_start_char, $wgContLang->convert( $sortkey ) ) ;
-                       } elseif( $wgCategoryMagicGallery && $title->getNamespace() == NS_IMAGE ) {
+                       } elseif( $showGallery && $title->getNamespace() == NS_IMAGE ) {
                                // Show thumbnails of categorized images, in a separate chunk
                                if( $flip ) {
                                        $ig->insert( Image::newFromTitle( $title ) );
@@ -162,39 +154,30 @@ class CategoryPage extends Article {
                if( count( $children ) > 0 ) {
                        # Showing subcategories
                        $r .= '<h2>' . wfMsg( 'subcategories' ) . "</h2>\n";
-                       $r .= $this->formatCount( $children, 'subcategorycount' );
+                       $r .= wfMsgExt( 'subcategorycount', array( 'parse' ), count( $children) );
                        $r .= $this->formatList( $children, $children_start_char );
                }
 
                # Showing articles in this category
                $ti = htmlspecialchars( $this->mTitle->getText() );
                $r .= '<h2>' . wfMsg( 'category_header', $ti ) . "</h2>\n";
-               $r .= $this->formatCount( $articles, 'categoryarticlecount' );
+               $r .= wfMsgExt( 'categoryarticlecount', array( 'parse' ), count( $articles) );
                $r .= $this->formatList( $articles, $articles_start_char );
 
-               if( $wgCategoryMagicGallery && ! $ig->isEmpty() ) {
+               if( $showGallery && ! $ig->isEmpty() ) {
                        $r.= $ig->toHTML();
                }
 
+               if( $until != '' ) {
+                       $r .= $this->pagingLinks( $this->mTitle, $nextPage, $until, $limit );
+               } elseif( $nextPage != '' || $from != '' ) {
+                       $r .= $this->pagingLinks( $this->mTitle, $from, $nextPage, $limit );
+               }
+
                wfProfileOut( $fname );
                return $r;
        }
 
-       /**
-        * @param array $articles
-        * @param string $message
-        * @return string
-        * @access private
-        */
-       function formatCount( $articles, $message ) {
-               global $wgContLang;
-               $numart = count( $articles );
-               if( $numart == 1 ) {
-                       # Slightly different message to avoid silly plural
-                       $message .= '1';
-               }
-               return wfMsg( $message, $wgContLang->formatNum( $numart ) );
-       }
        /**
         * Format a list of articles chunked by letter, either as a
         * bullet list or a columnar format, depending on the length.
@@ -203,7 +186,7 @@ class CategoryPage extends Article {
         * @param array $articles_start_char
         * @param int   $cutoff
         * @return string
-        * @access private
+        * @private
         */
        function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
                if ( count ( $articles ) > $cutoff ) {
@@ -222,7 +205,7 @@ class CategoryPage extends Article {
         * @param array $articles
         * @param array $articles_start_char
         * @return string
-        * @access private
+        * @private
         */
        function columnList( $articles, $articles_start_char ) {
                // divide list into three equal chunks
@@ -258,8 +241,8 @@ class CategoryPage extends Article {
                                        }
                                        $cont_msg = "";
                                        if ( $articles_start_char[$index] == $prev_start_char )
-                                               $cont_msg = wfMsg('listingcontinuesabbrev');
-                                       $r .= "<h3>{$articles_start_char[$index]}$cont_msg</h3>\n<ul>";
+                                               $cont_msg = wfMsgHtml('listingcontinuesabbrev');
+                                       $r .= "<h3>" . htmlspecialchars( $articles_start_char[$index] ) . "$cont_msg</h3>\n<ul>";
                                        $prev_start_char = $articles_start_char[$index];
                                }
 
@@ -281,16 +264,16 @@ class CategoryPage extends Article {
         * @param array $articles
         * @param array $articles_start_char
         * @return string
-        * @access private
+        * @private
         */
        function shortList( $articles, $articles_start_char ) {
-               $r = '<h3>'.$articles_start_char[0]."</h3>\n";
+               $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
                $r .= '<ul><li>'.$articles[0].'</li>';
                for ($index = 1; $index < count($articles); $index++ )
                {
                        if ($articles_start_char[$index] != $articles_start_char[$index - 1])
                        {
-                               $r .= "</ul><h3>{$articles_start_char[$index]}</h3>\n<ul>";
+                               $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
                        }
 
                        $r .= "<li>{$articles[$index]}</li>";
@@ -306,7 +289,7 @@ class CategoryPage extends Article {
         * @param int    $limit
         * @param array  $query - additional query options to pass
         * @return string
-        * @access private
+        * @private
         */
        function pagingLinks( $title, $first, $last, $limit, $query = array() ) {
                global $wgUser, $wgLang;