Scripts and data used for generating ZhConversion.php
[lhc/web/wiklou.git] / includes / CategoryPage.php
index 5070c1b..3e89a5f 100644 (file)
@@ -6,6 +6,9 @@
  * @package MediaWiki
  */
 
+if ( $wgCategoryMagicGallery ) 
+       require_once('ImageGallery.php');
+
 /**
  * @package MediaWiki 
  */
@@ -50,7 +53,7 @@ class CategoryPage extends Article {
 
         # This method generates the list of subcategories and pages for a category
         function oldCategoryMagic () {
-                global $wgLang, $wgUser ;
+                global $wgContLang, $wgUser ;
                 $fname = 'CategoryPage::oldCategoryMagic';
 
 
@@ -73,7 +76,7 @@ class CategoryPage extends Article {
                 # For all pages that link to this category
                 while ( $x = $dbr->fetchObject ( $res ) )
                 {
-                        $t = $wgLang->getNsText ( $x->cur_namespace ) ;
+                        $t = $wgContLang->getNsText ( $x->cur_namespace ) ;
                         if ( $t != '' ) $t .= ':' ;
                         $t .= $x->cur_title ;
 
@@ -103,7 +106,7 @@ class CategoryPage extends Article {
        }
 
         function newCategoryMagic () {
-                global $wgLang,$wgUser;
+                global $wgContLang,$wgUser, $wgCategoryMagicGallery;
 
                $sk =& $wgUser->getSkin();
 
@@ -116,6 +119,10 @@ class CategoryPage extends Article {
                 $data = array () ;
                 $id = $this->mTitle->getArticleID() ;
 
+               if ( $wgCategoryMagicGallery ) {
+                       $ig = new ImageGallery();
+               }
+
                 # FIXME: add limits
                 $dbr =& wfGetDB( DB_SLAVE );
                 $cur = $dbr->tableName( 'cur' );
@@ -127,12 +134,12 @@ class CategoryPage extends Article {
                 $res = $dbr->query ( $sql ) ;
                 while ( $x = $dbr->fetchObject ( $res ) )
                 {
-                        $t = $ns = $wgLang->getNsText ( $x->cur_namespace ) ;
+                        $t = $ns = $wgContLang->getNsText ( $x->cur_namespace ) ;
                         if ( $t != '' ) $t .= ':' ;
                         $t .= $x->cur_title ;
+                       $ctitle = str_replace( '_',' ',$x->cur_title );
 
                         if ( $x->cur_namespace == NS_CATEGORY ) {
-                                $ctitle = str_replace( '_',' ',$x->cur_title );
                                 array_push ( $children, $sk->makeKnownLink ( $t, $ctitle ) ) ; # Subcategory
 
                                 // If there's a link from Category:A to Category:B, the sortkey of the resulting
@@ -140,13 +147,15 @@ class CategoryPage extends Article {
                                 // Workaround: If sortkey == "Category:".$title, than use $title for sorting,
                                 // else use sortkey...
                                 if ( ($ns.':'.$ctitle) == $x->cl_sortkey ) {
-                                        array_push ( $children_start_char, $wgLang->firstChar( $x->cur_title ) );
+                                        array_push ( $children_start_char, $wgContLang->firstChar( $x->cur_title ) );
                                 } else {
-                                        array_push ( $children_start_char, $wgLang->firstChar( $x->cl_sortkey ) ) ;
+                                        array_push ( $children_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
                                 }
-                        } else {
+                        } elseif ( $wgCategoryMagicGallery && $x->cur_namespace == NS_IMAGE ) {
+                               $ig->add( new Image( $x->cur_title ) );
+                       } else {
                                 array_push ( $articles , $sk->makeKnownLink ( $t ) ) ; # Page in this category
-                                array_push ( $articles_start_char, $wgLang->firstChar( $x->cl_sortkey ) ) ;
+                                array_push ( $articles_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
                         }
                 }
                 $dbr->freeResult ( $res ) ;
@@ -286,6 +295,11 @@ class CategoryPage extends Article {
                         }
                         $r .= '</ul>';
                 }
+
+               if ( $wgCategoryMagicGallery && ! $ig->isEmpty() ) {
+                       $r.= $ig->toHTML();
+               }
+
                 return $r ;
         }
 }