Category namespaces
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 20 Apr 2004 21:08:24 +0000 (21:08 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 20 Apr 2004 21:08:24 +0000 (21:08 +0000)
includes/Parser.php

index dd17a17..7b97865 100644 (file)
@@ -276,8 +276,9 @@ class Parser
                $sk =& $wgUser->getSkin() ;
 
                $data = array () ;
-               $sql1 = "SELECT DISTINCT cur_title,cur_namespace FROM cur,links WHERE l_to={$id} AND l_from=cur_id";
-               $sql2 = "SELECT DISTINCT cur_title,cur_namespace FROM cur,brokenlinks WHERE bl_to={$id} AND bl_from=cur_id" ;
+               $cns = 14 ;
+               $sql1 = "SELECT DISTINCT cur_title,cur_namespace FROM cur,links WHERE cur_namespace={$cns} l_to={$id} AND l_from=cur_id";
+               $sql2 = "SELECT DISTINCT cur_title,cur_namespace FROM cur,brokenlinks cur_namespace={$cns} WHERE bl_to={$id} AND bl_from=cur_id" ;
 
                $res = wfQuery ( $sql1, DB_READ ) ;
                while ( $x = wfFetchObject ( $res ) ) $data[] = $x ;
@@ -892,6 +893,14 @@ class Parser
                                $wgLinkCache->addImageLinkObj( $nt );
                                return $s;
                        }
+                       if ( $ns == 14 ) {
+                               $t = $nt->getText() ;
+                               $nnt = Title::newFromText ( $category.":".$t ) ;
+                               $t = $sk->makeLinkObj( $nnt, $t, "", "" , $prefix );
+                               $this->mOutput->mCategoryLinks[] = $t ;
+                               $s .= $prefix . $trail ;
+                               return $s ;
+                       }
                }
                if( ( $nt->getPrefixedText() == $this->mTitle->getPrefixedText() ) &&
                    ( strpos( $link, "#" ) == FALSE ) ) {
@@ -899,23 +908,6 @@ class Parser
                        return $s;
                }
 
-               # Category feature
-               $catns = strtoupper ( $nt->getDBkey () ) ;
-               $catns = explode ( ":" , $catns ) ;
-               if ( count ( $catns ) > 1 ) $catns = array_shift ( $catns ) ;
-               else $catns = "" ;
-               if ( $catns == strtoupper($category) && $this->mOptions->getUseCategoryMagic() ) {
-                       $t = explode ( ":" , $nt->getText() ) ;
-                       array_shift ( $t ) ;
-                       $t = implode ( ":" , $t ) ;
-                       $t = $wgLang->ucFirst ( $t ) ;
-                       $nnt = Title::newFromText ( $category.":".$t ) ;
-                       $t = $sk->makeLinkObj( $nnt, $t, "", $trail , $prefix );
-                       $this->mOutput->mCategoryLinks[] = $t ;
-                       $s .= $prefix . $trail ;
-                       return $s ;
-               }
-
                if( $ns == $media ) {
                        $s .= $prefix . $sk->makeMediaLinkObj( $nt, $text ) . $trail;
                        $wgLinkCache->addImageLinkObj( $nt );