From 61b139544e944c8b89723077bed6db082fe94258 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 24 Feb 2004 14:20:21 +0000 Subject: [PATCH] Category function now working --- includes/OutputPage.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 4c2ed2ea37..049b99e0c2 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -579,7 +579,7 @@ class OutputPage { function categoryMagic () { - global $wgTitle , $wgUseCategoryMagic ; + global $wgTitle , $wgUseCategoryMagic , $wgLang ; if ( !isset ( $wgUseCategoryMagic ) || !$wgUseCategoryMagic ) return ; $id = $wgTitle->getArticleID() ; $cat = ucfirst ( wfMsg ( "category" ) ) ; @@ -595,14 +595,22 @@ class OutputPage { global $wgUser ; $sk = $wgUser->getSkin() ; - $sql = "SELECT l_from FROM links WHERE l_to={$id}" ; + + $doesexist = false ; + if ( $doesexist ) $sql = "SELECT l_from FROM links WHERE l_to={$id}" ; + else $sql = "SELECT cur_title,cur_namespace FROM cur,brokenlinks WHERE bl_to={$id} AND bl_from=cur_id" ; $res = wfQuery ( $sql, DB_READ ) ; while ( $x = wfFetchObject ( $res ) ) { # $t = new Title ; # $t->newFromDBkey ( $x->l_from ) ; # $t = $t->getText() ; - $t = $x->l_from ; + if ( $doesexist ) $t = $x->l_from ; + else { + $t = $wgLang->getNsText ( $x->cur_namespace ) ; + if ( $t != "" ) $t .= ":" ; + $t .= $x->cur_title ; + } $y = explode ( ":" , $t , 2 ) ; if ( count ( $y ) == 2 && $y[0] == $cat ) { array_push ( $children , $sk->makeLink ( $t , $y[1] ) ) ; @@ -629,7 +637,6 @@ class OutputPage { $r .= implode ( ", " , $articles ) ; } - return $r ; } @@ -1084,7 +1091,9 @@ $t[] = "" ; array_shift ( $t ) ; $t = implode ( ":" , $t ) ; $t = $wgLang->ucFirst ( $t ) ; - $t = $sk->makeKnownLink( $category.":".$t, $t, "", $trail , $prefix ); +# $t = $sk->makeKnownLink( $category.":".$t, $t, "", $trail , $prefix ); + $nnt = Title::newFromText ( $category.":".$t ) ; + $t = $sk->makeLinkObj( $nnt, $t, "", $trail , $prefix ); $this->mCategoryLinks[] = $t ; $s .= $prefix . $trail ; continue ; -- 2.20.1