From 9c9119439fce8503f8bc9c333322307a8d46a31c Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 20 Apr 2004 21:08:24 +0000 Subject: [PATCH] Category namespaces --- includes/Parser.php | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index dd17a17e6d..7b978654bc 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 ); -- 2.20.1