Changed LinkHolderArray::makeHolder() to use Linker::link() instead of Linker::makeBr...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 15 Mar 2011 16:47:55 +0000 (16:47 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 15 Mar 2011 16:47:55 +0000 (16:47 +0000)
includes/parser/CoreLinkFunctions.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php

index 5c79649..4893614 100644 (file)
@@ -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(), '', '' );
        }
 
        /**
index 04b61d2..25f5ab0 100644 (file)
@@ -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 = "<!--LINK $key-->";
-                               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 );
index 7792e75..3f9dccf 100644 (file)
@@ -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 );
        }