fetch commons descriptions for display on local wikis
[lhc/web/wiklou.git] / includes / CategoryPage.php
index 911f017..bb6314f 100644 (file)
@@ -9,6 +9,7 @@
 if( !defined( 'MEDIAWIKI' ) )
        die();
 
+global $wgCategoryMagicGallery;
 if( $wgCategoryMagicGallery )
        /** */
        require_once('ImageGallery.php');
@@ -19,6 +20,8 @@ if( $wgCategoryMagicGallery )
 class CategoryPage extends Article {
 
        function view() {
+               if(!wfRunHooks('CategoryPageView', array(&$this))) return;
+
                if ( NS_CATEGORY == $this->mTitle->getNamespace() ) {
                        $this->openShowCategory();
                }
@@ -88,11 +91,11 @@ 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(),
-                              'page_is_redirect' => 0),
+                              'cl_to'           => $this->mTitle->getDBKey()),
+                              #'page_is_redirect' => 0),
                        #+ $pageCondition,
                        $fname,
                        array( 'ORDER BY' => $flip ? 'cl_sortkey DESC' : 'cl_sortkey',
@@ -114,17 +117,19 @@ class CategoryPage extends Article {
                        
                        if( $title->getNamespace() == NS_CATEGORY ) {
                                // Subcategory; strip the 'Category' namespace from the link text.
-                               array_push( $children, $sk->makeKnownLinkObj( $title, $title->getText() ) );
+                               array_push( $children, $sk->makeKnownLinkObj( $title, $wgContLang->convertHtml( $title->getText() ) ) );
                                
                                // If there's a link from Category:A to Category:B, the sortkey of the resulting
                                // entry in the categorylinks table is Category:A, not A, which it SHOULD be.
                                // Workaround: If sortkey == "Category:".$title, than use $title for sorting,
                                // else use sortkey...
+                               $sortkey='';
                                if( $title->getPrefixedText() == $x->cl_sortkey ) {
-                                       array_push( $children_start_char, $wgContLang->firstChar( $x->page_title ) );
+                                       $sortkey=$wgContLang->firstChar( $x->page_title );
                                } else {
-                                       array_push( $children_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
+                                       $sortkey=$wgContLang->firstChar( $x->cl_sortkey );
                                }
+                               array_push( $children_start_char, $wgContLang->convert( $sortkey ) ) ;
                        } elseif( $wgCategoryMagicGallery && $title->getNamespace() == NS_IMAGE ) {
                                // Show thumbnails of categorized images, in a separate chunk
                                if( $flip ) {
@@ -134,8 +139,8 @@ class CategoryPage extends Article {
                                }
                        } else {
                                // Page in this category
-                               array_push( $articles, $sk->makeKnownLinkObj( $title ) ) ;
-                               array_push( $articles_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
+                               array_push( $articles, $sk->makeSizeLinkObj( $x->page_len, $title, $wgContLang->convert( $title->getPrefixedText() ) ) ) ;
+                               array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) );
                        }
                }
                $dbr->freeResult( $res );