diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2009-06-10 13:00:47 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2009-06-10 13:00:47 +0200 |
commit | 72e90545454c0e014318fa3c81658e035aac58c1 (patch) | |
tree | 9212e3f46868989c4d57ae9a5c8a1a80e4dc0702 /includes/Linker.php | |
parent | 565a0ccc371ec1a2a0e9b39487cbac18e6f60e25 (diff) |
applying patch to version 1.15.0
Diffstat (limited to 'includes/Linker.php')
-rw-r--r-- | includes/Linker.php | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/includes/Linker.php b/includes/Linker.php index f116fb4a..b739244b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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', @@ -882,10 +882,13 @@ class Linker { } } - if( $page ) { - $query = $query ? '&page=' . urlencode( $page ) : 'page=' . urlencode( $page ); - } + # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs + # So we don't need to pass it here in $query. However, the URL for the + # zoom icon still needs it, so we make a unique query for it. See bug 14771 $url = $title->getLocalURL( $query ); + if( $page ) { + $url = wfAppendQuery( $url, 'page=' . urlencode( $page ) ); + } $more = htmlspecialchars( wfMsg( 'thumbnail-more' ) ); @@ -1007,22 +1010,37 @@ class Linker { wfMsg( $key ) ); } - /** @todo document */ + /** + * Make an external link + * @param String $url URL to link to + * @param String $text text of link + * @param boolean $escape Do we escape the link text? + * @param String $linktype Type of external link. Gets added to the classes + * @param array $attribs Array of extra attributes to <a> + * + * @TODO! @FIXME! This is a really crappy implementation. $linktype and + * 'external' are mashed into the class attrib for the link (which is made + * into a string). Then, if we've got additional params in $attribs, we + * add to it. People using this might want to change the classes (or other + * default link attributes), but passing $attribsText is just messy. Would + * make a lot more sense to make put the classes into $attribs, let the + * hook play with them, *then* expand it all at once. + */ function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) { $attribsText = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); - if ( $attribs ) { - $attribsText .= Xml::expandAttributes( $attribs ); - } $url = htmlspecialchars( $url ); if( $escape ) { $text = htmlspecialchars( $text ); } $link = ''; - $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link ) ); + $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link, &$attribs, $linktype ) ); 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; } + if ( $attribs ) { + $attribsText .= Xml::expandAttributes( $attribs ); + } return '<a href="'.$url.'"'.$attribsText.'>'.$text.'</a>'; } @@ -1053,7 +1071,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 +1097,7 @@ class Linker { } if( $items ) { - return ' <span class="mw-usertoollinks">(' . implode( ' | ', $items ) . ')</span>'; + return ' <span class="mw-usertoollinks">(' . $wgLang->pipeList( $items ) . ')</span>'; } else { return ''; } @@ -1783,9 +1801,7 @@ class Linker { # FIXME: Per standard MW behavior, a value of '-' means to suppress the # attribute, but this is broken for accesskey: that might be a useful # value. - if( $accesskey != '' - && $accesskey != '-' - && !wfEmptyMsg( "accesskey-$name", $accesskey ) ) { + if( $accesskey != '' && $accesskey != '-' && !wfEmptyMsg( "accesskey-$name", $accesskey ) ) { wfProfileOut( __METHOD__ ); return $accesskey; } @@ -1793,4 +1809,21 @@ 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 = $restricted ? 'strong' : 'span'; + $link = $this->link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) ); + return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" ); + } } |