From b974497da87c899ed96009003f39860a5e9703cd Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Tue, 15 Mar 2011 16:47:55 +0000 Subject: [PATCH] Changed LinkHolderArray::makeHolder() to use Linker::link() instead of Linker::makeBrokenLinkObj() and Linker::makeColouredLinkObj() --- includes/parser/CoreLinkFunctions.php | 2 +- includes/parser/LinkHolderArray.php | 32 ++++++++++++++++----------- includes/parser/Parser.php | 4 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/includes/parser/CoreLinkFunctions.php b/includes/parser/CoreLinkFunctions.php index 5c796494cc..48936146c5 100644 --- a/includes/parser/CoreLinkFunctions.php +++ b/includes/parser/CoreLinkFunctions.php @@ -41,7 +41,7 @@ class CoreLinkFunctions { # Return false so that this link is reverted back to WikiText return false; } - return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, '', '', '' ); + return $holders->makeHolder( $title, isset($displayText) ? $displayText : $titleText, array(), '', '' ); } /** diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index 04b61d278c..25f5ab0ab9 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -191,7 +191,7 @@ class LinkHolderArray { * * @param $nt Title */ - function makeHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeHolder( $nt, $text = '', $query = array(), $trail = '', $prefix = '' ) { wfProfileIn( __METHOD__ ); if ( ! is_object($nt) ) { # Fail gracefully @@ -205,7 +205,7 @@ class LinkHolderArray { 'text' => $prefix.$text.$inside, 'pdbk' => $nt->getPrefixedDBkey(), ); - if ( $query !== '' ) { + if ( $query !== array() ) { $entry['query'] = $query; } @@ -349,23 +349,29 @@ class LinkHolderArray { foreach ( $entries as $index => $entry ) { $pdbk = $entry['pdbk']; $title = $entry['title']; - $query = isset( $entry['query'] ) ? $entry['query'] : ''; + $query = isset( $entry['query'] ) ? $entry['query'] : array(); $key = "$ns:$index"; $searchkey = ""; - if ( !isset( $colours[$pdbk] ) || $colours[$pdbk] == 'new' ) { - $linkCache->addBadLinkObj( $title ); + $displayText = $entry['text']; + if ( $displayText === '' ) { + $displayText = null; + } + if ( !isset( $colours[$pdbk] ) ) { $colours[$pdbk] = 'new'; + } + $attribs = array(); + if ( $colours[$pdbk] == 'new' ) { + $linkCache->addBadLinkObj( $title ); $output->addLink( $title, 0 ); - // FIXME: replace deprecated makeBrokenLinkObj() by link() - $replacePairs[$searchkey] = $sk->makeBrokenLinkObj( $title, - $entry['text'], - $query ); + $type = array( 'broken' ); } else { - // FIXME: replace deprecated makeColouredLinkObj() by link() - $replacePairs[$searchkey] = $sk->makeColouredLinkObj( $title, $colours[$pdbk], - $entry['text'], - $query ); + if ( $colours[$pdbk] != '' ) { + $attribs['class'] = $colours[$pdbk]; + } + $type = array( 'known', 'noclasses' ); } + $replacePairs[$searchkey] = $sk->link( $title, $displayText, + $attribs, $query, $type ); } } $replacer = new HashtableReplacer( $replacePairs, 1 ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7792e75d17..3f9dccfd43 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1935,7 +1935,7 @@ class Parser { $s .= $this->makeKnownLinkHolder( $nt, $text, array(), $trail, $prefix ); } else { # Links will be added to the output link list after checking - $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix ); + $s .= $holders->makeHolder( $nt, $text, array(), $trail, $prefix ); } wfProfileOut( __METHOD__."-always_known" ); } @@ -1951,7 +1951,7 @@ class Parser { * * @deprecated */ - function makeLinkHolder( &$nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeLinkHolder( &$nt, $text = '', $query = array(), $trail = '', $prefix = '' ) { return $this->mLinkHolders->makeHolder( $nt, $text, $query, $trail, $prefix ); } -- 2.20.1