API: Page prop=revisions by rev_id or (rev_page, rev_id), depending on mode, because...
[lhc/web/wiklou.git] / includes / Linker.php
index ec63357..9b52671 100644 (file)
@@ -618,7 +618,7 @@ class Linker {
                $img = '';
                $success = wfRunHooks('LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
                if(!$success) {
-                       wfDebug("Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}", true);
+                       wfDebug("Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}\n", true);
                        return $img;
                }
                return Xml::element( 'img',
@@ -1020,7 +1020,7 @@ class Linker {
                $link = '';
                $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link ) );
                if(!$success) {
-                       wfDebug("Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}", true);
+                       wfDebug("Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true);
                        return $link;
                }
                return '<a href="'.$url.'"'.$attribsText.'>'.$text.'</a>';
@@ -1053,7 +1053,7 @@ class Linker {
         * @return string
         */
        public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits=null ) {
-               global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans;
+               global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans, $wgLang;
                $talkable = !( $wgDisableAnonTalk && 0 == $userId );
                $blockable = ( $wgSysopUserBans || 0 == $userId ) && !$flags & self::TOOL_LINKS_NOBLOCK;
 
@@ -1079,7 +1079,7 @@ class Linker {
                }
 
                if( $items ) {
-                       return ' <span class="mw-usertoollinks">(' . implode( ' | ', $items ) . ')</span>';
+                       return ' <span class="mw-usertoollinks">(' . $wgLang->pipeList( $items ) . ')</span>';
                } else {
                        return '';
                }
@@ -1515,11 +1515,21 @@ class Linker {
         * @param string $anchor  The anchor to give the headline (the bit after the #)
         * @param string $text    The text of the header
         * @param string $link    HTML to add for the section edit link
+        * @param mixed  $legacyAnchor A second, optional anchor to give for
+        *   backward compatibility (false to omit)
         *
         * @return string HTML headline
         */
-       public function makeHeadline( $level, $attribs, $anchor, $text, $link ) {
-               return "<a name=\"$anchor\" id=\"$anchor\"></a><h$level$attribs$link <span class=\"mw-headline\">$text</span></h$level>";
+       public function makeHeadline( $level, $attribs, $anchor, $text, $link, $legacyAnchor = false ) {
+               $ret = "<a name=\"$anchor\" id=\"$anchor\"></a>"
+                       . "<h$level$attribs"
+                       . $link
+                       . " <span class=\"mw-headline\">$text</span>"
+                       . "</h$level>";
+               if ( $legacyAnchor !== false ) {
+                       $ret = "<a name=\"$legacyAnchor\" id=\"$legacyAnchor\"></a>$ret";
+               }
+               return $ret;
        }
 
        /**
@@ -1579,6 +1589,7 @@ class Linker {
                );
                if( $wgRequest->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
+                       $query['hidediff'] = '1'; // bug 15999
                }
                $query['token'] = $wgUser->editToken( array( $title->getPrefixedText(),
                        $rev->getUserText() ) );
@@ -1596,12 +1607,9 @@ class Linker {
         * @param bool $section Whether this is for a section edit
         * @return string HTML output
         */
-       public function formatTemplates( $templates, $preview = false, $section = false) {
-               global $wgUser;
+       public function formatTemplates( $templates, $preview = false, $section = false ) {
                wfProfileIn( __METHOD__ );
 
-               $sk = $wgUser->getSkin();
-
                $outText = '';
                if ( count( $templates ) > 0 ) {
                        # Do a batch existence check
@@ -1620,7 +1628,7 @@ class Linker {
                        } else {
                                $outText .= wfMsgExt( 'templatesused', array( 'parse' ) );
                        }
-                       $outText .= '</div><ul>';
+                       $outText .= "</div><ul>\n";
 
                        usort( $templates, array( 'Title', 'compare' ) );
                        foreach ( $templates as $titleObj ) {
@@ -1633,13 +1641,11 @@ class Linker {
                                        $protected = '';
                                }
                                if( $titleObj->quickUserCan( 'edit' ) ) {
-                                       $editLink = $sk->link( $titleObj, wfMsg( 'editlink' ), array(), array( 'action' => 'edit' ), 'known' );
+                                       $editLink = $this->makeLinkObj( $titleObj, wfMsg('editlink'), 'action=edit' );
                                } else {
-                                       $editLink = $sk->link( $titleObj, wfMsg( 'viewsourcelink' ), array(), array( 'action' => 'edit' ), 'known' );
+                                       $editLink = $this->makeLinkObj( $titleObj, wfMsg('viewsourcelink'), 'action=edit' );
                                }
-                               $talkLink = $sk->link( $titleObj->getTalkPage(), wfMsg( 'talkpagelinktext' ) );
-                               $outText .= Xml::tags( 'li', array(),
-                                               $sk->link( $titleObj ) . ' (' . $editLink . ' ' . wfMsg( 'pipe-separator' ) . ' ' . $talkLink . ') ' . $protected );
+                               $outText .= '<li>' . $this->link( $titleObj ) . ' (' . $editLink . ') ' . $protected . '</li>';
                        }
                        $outText .= '</ul>';
                }
@@ -1654,21 +1660,19 @@ class Linker {
         * or similar
         * @return string HTML output
         */
-       public function formatHiddenCategories( $hiddencats) {
-               global $wgUser, $wgLang;
+       public function formatHiddenCategories( $hiddencats ) {
+               global $wgLang;
                wfProfileIn( __METHOD__ );
 
-               $sk = $wgUser->getSkin();
-
                $outText = '';
                if ( count( $hiddencats ) > 0 ) {
                        # Construct the HTML
                        $outText = '<div class="mw-hiddenCategoriesExplanation">';
                        $outText .= wfMsgExt( 'hiddencategories', array( 'parse' ), $wgLang->formatnum( count( $hiddencats ) ) );
-                       $outText .= '</div><ul>';
+                       $outText .= "</div><ul>\n";
 
                        foreach ( $hiddencats as $titleObj ) {
-                               $outText .= '<li>' . $sk->link( $titleObj, null, array(), array(), 'known' ) . '</li>'; # If it's hidden, it must exist - no need to check with a LinkBatch
+                               $outText .= '<li>' . $this->link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch
                        }
                        $outText .= '</ul>';
                }
@@ -1789,4 +1793,23 @@ class Linker {
                wfProfileOut( __METHOD__ );
                return false;
        }
+       
+       /**
+        * Creates a (show/hide) link for deleting revisions/log entries
+        *
+        * @param array $query  Query parameters to be passed to link()
+        * @param bool $restricted  Set to true to use a <strong> instead of a <span>
+        *
+        * @return string HTML <a> link to Special:Revisiondelete, wrapped in a
+        * span to allow for customization of appearance with CSS
+        */
+       public function revDeleteLink( $query = array(), $restricted = false ) {
+               $sp = SpecialPage::getTitleFor( 'Revisiondelete' );
+               $text = wfMsgHtml( 'rev-delundel' );
+               $tag = 'span';
+               if( $restricted )
+                       $tag = 'strong';
+               $link = $this->link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) );
+               return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" );
+       }
 }