* Flags for userToolLinks()
*/
const TOOL_LINKS_NOBLOCK = 1;
+ const TOOL_LINKS_EMAIL = 2;
/**
* Get the appropriate HTML attributes to add to the "a" element of an ex-
static function getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' ) {
global $wgContLang;
- # FIXME: We have a whole bunch of handling here that doesn't happen in
+ # @todo FIXME: We have a whole bunch of handling here that doesn't happen in
# getExternalLinkAttributes, why?
$title = urldecode( $title );
$title = $wgContLang->checkTitleEncoding( $title );
/**
* Common code for getLinkAttributesX functions
+ *
+ * @param $title string
+ * @param $class string
+ *
+ * @return string
*/
private static function getLinkAttributesInternal( $title, $class ) {
$title = htmlspecialchars( $title );
* @param $threshold Integer: user defined threshold
* @return String: CSS class
*/
- static function getLinkColour( $t, $threshold ) {
+ public static function getLinkColour( $t, $threshold ) {
$colour = '';
if ( $t->isRedirect() ) {
# Page is a redirect
*
* @param $target Title Can currently only be a Title, but this may
* change to support Images, literal URLs, etc.
- * @param $text string The HTML contents of the <a> element, i.e.,
+ * @param $html string The HTML contents of the <a> element, i.e.,
* the link text. This is raw HTML and will not be escaped. If null,
* defaults to the prefixed text of the Title; or if the Title is just a
* fragment, the contents of the fragment.
* @param $query array The query string to append to the URL
* you're linking to, in key => value array form. Query keys and values
* will be URL-encoded.
- * @param $options mixed String or array of strings:
+ * @param $options string|array String or array of strings:
* 'known': Page is known to exist, so don't check if it does.
* 'broken': Page is known not to exist, so don't check if it does.
* 'noclasses': Don't add any classes automatically (includes "new",
* @return string HTML <a> attribute
*/
public static function link(
- $target, $text = null, $customAttribs = array(), $query = array(), $options = array()
+ $target, $html = null, $customAttribs = array(), $query = array(), $options = array()
) {
wfProfileIn( __METHOD__ );
if ( !$target instanceof Title ) {
wfProfileOut( __METHOD__ );
- return "<!-- ERROR -->$text";
+ return "<!-- ERROR -->$html";
}
$options = (array)$options;
$dummy = new DummyLinker; // dummy linker instance for bc on the hooks
$ret = null;
- if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$text,
+ if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
&$customAttribs, &$query, &$options, &$ret ) ) ) {
wfProfileOut( __METHOD__ );
return $ret;
$attribs,
self::linkAttribs( $target, $customAttribs, $options )
);
- if ( is_null( $text ) ) {
- $text = self::linkText( $target );
+ if ( is_null( $html ) ) {
+ $html = self::linkText( $target );
}
$ret = null;
- if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$text, &$attribs, &$ret ) ) ) {
- $ret = Html::rawElement( 'a', $attribs, $text );
+ if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
+ $ret = Html::rawElement( 'a', $attribs, $html );
}
wfProfileOut( __METHOD__ );
* Identical to link(), except $options defaults to 'known'.
*/
public static function linkKnown(
- $target, $text = null, $customAttribs = array(),
+ $target, $html = null, $customAttribs = array(),
$query = array(), $options = array( 'known', 'noclasses' ) )
{
- return self::link( $target, $text, $customAttribs, $query, $options );
+ return self::link( $target, $html, $customAttribs, $query, $options );
}
/**
* Returns the array of attributes used when linking to the Title $target
*
* @param $target Title
+ * @param $attribs
+ * @param $options
+ *
+ * @return array
*/
private static function linkAttribs( $target, $attribs, $options ) {
wfProfileIn( __METHOD__ );
$threshold = $wgUser->getStubThreshold();
$colour = ( $size < $threshold ) ? 'stub' : '';
- // FIXME: replace deprecated makeColouredLinkObj by link()
+ // @todo FIXME: Replace deprecated makeColouredLinkObj by link()
return self::makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
}
*
* @return string
*/
- static function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- if ( $text == '' ) {
- $text = htmlspecialchars( $nt->getPrefixedText() );
+ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+ if ( $html == '' ) {
+ $html = htmlspecialchars( $nt->getPrefixedText() );
}
list( $inside, $trail ) = self::splitTrail( $trail );
- return "<strong class=\"selflink\">{$prefix}{$text}{$inside}</strong>{$trail}";
+ return "<strong class=\"selflink\">{$prefix}{$html}{$inside}</strong>{$trail}";
}
/**
*
* @return string
*/
- static function fnamePart( $url ) {
+ private static function fnamePart( $url ) {
$basename = strrchr( $url, '/' );
if ( false === $basename ) {
$basename = $url;
*
* @return string
*/
- static function makeExternalImage( $url, $alt = '' ) {
+ public static function makeExternalImage( $url, $alt = '' ) {
if ( $alt == '' ) {
$alt = self::fnamePart( $url );
}
* @param $widthOption: Used by the parser to remember the user preference thumbnailsize
* @return String: HTML for an image, with links, wrappers, etc.
*/
- static function makeImageLink2( Title $title, $file, $frameParams = array(),
+ public static function makeImageLink2( Title $title, $file, $frameParams = array(),
$handlerParams = array(), $time = false, $query = "", $widthOption = null )
{
$res = null;
$fp['align'] = 'none';
}
if ( $file && !isset( $hp['width'] ) ) {
- $hp['width'] = $file->getWidth( $page );
+ if ( isset( $hp['height'] ) && $file->isVectorized() ) {
+ // If its a vector image, and user only specifies height
+ // we don't want it to be limited by its "normal" width.
+ global $wgSVGMaxSize;
+ $hp['width'] = $wgSVGMaxSize;
+ } else {
+ $hp['width'] = $file->getWidth( $page );
+ }
if ( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
global $wgThumbLimits, $wgThumbUpright;
* @param $frameParams The frame parameters
* @param $query An optional query string to add to description page links
*/
- static function getImageLinkMTOParams( $frameParams, $query = '' ) {
+ private static function getImageLinkMTOParams( $frameParams, $query = '' ) {
$mtoParams = array();
if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
* @param $framed Boolean
* @param $manualthumb String
*/
- static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
+ public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
$align = 'right', $params = array(), $framed = false , $manualthumb = "" )
{
$frameParams = array(
* @param string $query
* @return mixed
*/
- static function makeThumbLink2( Title $title, $file, $frameParams = array(),
+ public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
$handlerParams = array(), $time = false, $query = "" )
{
global $wgStylePath, $wgContLang;
* Make a "broken" link to an image
*
* @param $title Title object
- * @param $text String: link label in unescaped text form
+ * @param $html String: link label in htmlescaped text form
* @param $query String: query string
* @param $trail String: link trail (HTML fragment)
* @param $prefix String: link prefix (HTML fragment)
* @param $time Boolean: a file of a certain timestamp was requested
* @return String
*/
- public static function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) {
- global $wgEnableUploads, $wgUploadMissingFileUrl;
- if ( $title instanceof Title ) {
- wfProfileIn( __METHOD__ );
- $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
-
- list( $inside, $trail ) = self::splitTrail( $trail );
- if ( $text == '' )
- $text = htmlspecialchars( $title->getPrefixedText() );
-
- if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) {
- $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
+ public static function makeBrokenImageLinkObj( $title, $html = '', $query = '', $trail = '', $prefix = '', $time = false ) {
+ global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
+ if ( ! $title instanceof Title ) {
+ return "<!-- ERROR -->{$prefix}{$html}{$trail}";
+ }
+ wfProfileIn( __METHOD__ );
+ $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
- if ( $redir ) {
- wfProfileOut( __METHOD__ );
- return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
- }
+ list( $inside, $trail ) = self::splitTrail( $trail );
+ if ( $html == '' )
+ $html = htmlspecialchars( $title->getPrefixedText() );
- $href = self::getUploadUrl( $title, $query );
+ if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
+ $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
+ if ( $redir ) {
wfProfileOut( __METHOD__ );
- return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
- htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
- "$prefix$text$inside</a>$trail";
- } else {
- wfProfileOut( __METHOD__ );
- return self::linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
+ return self::linkKnown( $title, "$prefix$html$inside", array(), $query ) . $trail;
}
+
+ $href = self::getUploadUrl( $title, $query );
+
+ wfProfileOut( __METHOD__ );
+ return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
+ htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
+ "$prefix$html$inside</a>$trail";
} else {
- return "<!-- ERROR -->{$prefix}{$text}{$trail}";
+ wfProfileOut( __METHOD__ );
+ return self::linkKnown( $title, "$prefix$html$inside", array(), $query ) . $trail;
}
}
* @return String: urlencoded URL
*/
protected static function getUploadUrl( $destFile, $query = '' ) {
- global $wgUploadMissingFileUrl;
+ global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
$q = 'wpDestFile=' . $destFile->getPartialUrl();
if ( $query != '' )
$q .= '&' . $query;
if ( $wgUploadMissingFileUrl ) {
return wfAppendQuery( $wgUploadMissingFileUrl, $q );
+ } elseif( $wgUploadNavigationUrl ) {
+ return wfAppendQuery( $wgUploadNavigationUrl, $q );
} else {
$upload = SpecialPage::getTitleFor( 'Upload' );
return $upload->getLocalUrl( $q );
* Create a direct link to a given uploaded file.
*
* @param $title Title object.
- * @param $text String: pre-sanitized HTML
+ * @param $html String: pre-sanitized HTML
* @param $time string: MW timestamp of file creation time
* @return String: HTML
*/
- public static function makeMediaLinkObj( $title, $text = '', $time = false ) {
+ public static function makeMediaLinkObj( $title, $html = '', $time = false ) {
$img = wfFindFile( $title, array( 'time' => $time ) );
- return self::makeMediaLinkFile( $title, $img, $text );
+ return self::makeMediaLinkFile( $title, $img, $html );
}
/**
* This will make a broken link if $file is false.
*
* @param $title Title object.
- * @param $file mixed File object or false
- * @param $text String: pre-sanitized HTML
+ * @param $file File|false mixed File object or false
+ * @param $html String: pre-sanitized HTML
* @return String: HTML
*
* @todo Handle invalid or missing images better.
*/
- public static function makeMediaLinkFile( Title $title, $file, $text = '' ) {
+ public static function makeMediaLinkFile( Title $title, $file, $html = '' ) {
if ( $file && $file->exists() ) {
$url = $file->getURL();
$class = 'internal';
$class = 'new';
}
$alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
- if ( $text == '' ) {
- $text = $alt;
+ if ( $html == '' ) {
+ $html = $alt;
}
$u = htmlspecialchars( $url );
- return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$text}</a>";
+ return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$html}</a>";
}
/**
- * Make a link to a special page given its name and, optionally,
+ * Make a link to a special page given its name and, optionally,
* a message key from the link text.
* Usage example: $skin->specialLink( 'recentchanges' )
+ *
+ * @return string
*/
- static function specialLink( $name, $key = '' ) {
- if ( $key == '' ) { $key = strtolower( $name ); }
+ public static function specialLink( $name, $key = '' ) {
+ if ( $key == '' ) {
+ $key = strtolower( $name );
+ }
return self::linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) );
}
* @param $linktype String: type of external link. Gets added to the classes
* @param $attribs Array of extra attributes to <a>
*/
- static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) {
+ public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) {
$class = "external";
- if ( isset($linktype) && $linktype ) {
+ if ( $linktype ) {
$class .= " $linktype";
}
- if ( isset($attribs['class']) && $attribs['class'] ) {
+ if ( isset( $attribs['class'] ) && $attribs['class'] ) {
$class .= " {$attribs['class']}";
}
$attribs['class'] = $class;
-
+
if ( $escape ) {
$text = htmlspecialchars( $text );
}
* @param $userId Integer: user id in database.
* @param $userText String: user name in database
* @return String: HTML fragment
- * @private
*/
- static function userLink( $userId, $userText ) {
+ public static function userLink( $userId, $userText ) {
if ( $userId == 0 ) {
$page = SpecialPage::getTitleFor( 'Contributions', $userText );
} else {
* @param $userText String: user name or IP address
* @param $redContribsWhenNoEdits Boolean: should the contributions link be
* red if the user has no edits?
- * @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK)
+ * @param $flags Integer: customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL)
* @param $edits Integer: user edit count (optional, for performance)
* @return String: HTML fragment
*/
) {
global $wgUser, $wgDisableAnonTalk, $wgLang;
$talkable = !( $wgDisableAnonTalk && 0 == $userId );
- $blockable = !$flags & self::TOOL_LINKS_NOBLOCK;
+ $blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
+ $addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
$items = array();
if ( $talkable ) {
$items[] = self::blockLink( $userId, $userText );
}
+ if ( $addEmailLink && $wgUser->canSendEmail() ) {
+ $items[] = self::emailLink( $userId, $userText );
+ }
+
if ( $items ) {
return ' <span class="mw-usertoollinks">(' . $wgLang->pipeList( $items ) . ')</span>';
} else {
* @param $userId Integer: user id in database.
* @param $userText String: user name in database.
* @return String: HTML fragment with user talk link
- * @private
*/
- static function userTalkLink( $userId, $userText ) {
+ public static function userTalkLink( $userId, $userText ) {
$userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
$userTalkLink = self::link( $userTalkPage, wfMsgHtml( 'talkpagelinktext' ) );
return $userTalkLink;
* @param $userId Integer: userid
* @param $userText String: user name in database.
* @return String: HTML fragment with block link
- * @private
*/
- static function blockLink( $userId, $userText ) {
+ public static function blockLink( $userId, $userText ) {
$blockPage = SpecialPage::getTitleFor( 'Block', $userText );
$blockLink = self::link( $blockPage, wfMsgHtml( 'blocklink' ) );
return $blockLink;
}
+ /**
+ * @param $userId Integer: userid
+ * @param $userText String: user name in database.
+ * @return String: HTML fragment with e-mail user link
+ */
+ public static function emailLink( $userId, $userText ) {
+ $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
+ $emailLink = self::link( $emailPage, wfMsgHtml( 'emaillink' ) );
+ return $emailLink;
+ }
+
/**
* Generate a user link if the current user is allowed to view it
* @param $rev Revision object.
* @param $isPublic Boolean: show only if all users can see it
* @return String: HTML fragment
*/
- static function revUserLink( $rev, $isPublic = false ) {
+ public static function revUserLink( $rev, $isPublic = false ) {
if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
- } else if ( $rev->userCan( Revision::DELETED_USER ) ) {
+ } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
$link = self::userLink( $rev->getUser( Revision::FOR_THIS_USER ),
$rev->getUserText( Revision::FOR_THIS_USER ) );
} else {
* @param $isPublic Boolean: show only if all users can see it
* @return string HTML
*/
- static function revUserTools( $rev, $isPublic = false ) {
+ public static function revUserTools( $rev, $isPublic = false ) {
if ( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
- } else if ( $rev->userCan( Revision::DELETED_USER ) ) {
+ } elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
$userId = $rev->getUser( Revision::FOR_THIS_USER );
$userText = $rev->getUserText( Revision::FOR_THIS_USER );
$link = self::userLink( $userId, $userText ) .
* @param $title Mixed: Title object (to generate link to the section in autocomment) or null
* @param $local Boolean: whether section links should refer to local page
*/
- static function formatComment( $comment, $title = null, $local = false ) {
+ public static function formatComment( $comment, $title = null, $local = false ) {
wfProfileIn( __METHOD__ );
# Sanitize text a bit:
return $comment;
}
+ /**
+ * @var Title
+ */
static $autocommentTitle;
static $autocommentLocal;
return $comment;
}
+ /**
+ * @param $match
+ * @return string
+ */
private static function formatAutocommentsCallback( $match ) {
$title = self::$autocommentTitle;
$local = self::$autocommentLocal;
return $comment;
}
+ /**
+ * @var Title
+ */
static $commentContextTitle;
static $commentLocal;
* Formats wiki links and media links in text; all other wiki formatting
* is ignored
*
- * @todo Fixme: doesn't handle sub-links as in image thumb texts like the main parser
+ * @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
* @param $comment String: text to format links in
* @param $title An optional title object used to links to sections
* @param $local Boolean: whether section links should refer to local page
return $html;
}
+ /**
+ * @param $match
+ * @return mixed
+ */
protected static function formatLinksInCommentCallback( $match ) {
global $wgContLang;
* @param $text
* @return string
*/
- static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
+ public static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
# Valid link forms:
# Foobar -- normal
# :Foobar -- override special treatment of prefix (images, language links)
* @param $comment String
* @param $title Mixed: Title object (to generate link to section in autocomment) or null
* @param $local Boolean: whether section links should refer to local page
- * @param $embraced Boolean: whether the formatted comment should be embraced with ()
+ *
* @return string
*/
- static function commentBlock( $comment, $title = null, $local = false, $embraced = true ) {
+ public static function commentBlock( $comment, $title = null, $local = false ) {
// '*' used to be the comment inserted by the software way back
// in antiquity in case none was provided, here for backwards
// compatability, acc. to brion -ævar
return '';
} else {
$formatted = self::formatComment( $comment, $title, $local );
- if ( $embraced ) {
- $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped();
- }
- return Html::rawElement( 'span', array( 'class' => 'comment' ), $formatted );
+ return " <span class=\"comment\" dir=\"auto\">($formatted)</span>";
}
}
* @param $isPublic Boolean: show only if all users can see it
* @return String: HTML fragment
*/
- static function revComment( Revision $rev, $local = false, $isPublic = false ) {
+ public static function revComment( Revision $rev, $local = false, $isPublic = false ) {
if ( $rev->getRawComment() == "" ) {
return "";
}
if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
$block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
- } else if ( $rev->userCan( Revision::DELETED_COMMENT ) ) {
+ } elseif ( $rev->userCan( Revision::DELETED_COMMENT ) ) {
$block = self::commentBlock( $rev->getComment( Revision::FOR_THIS_USER ),
$rev->getTitle(), $local );
} else {
return $block;
}
+ /**
+ * @param $size
+ * @return string
+ */
public static function formatRevisionSize( $size ) {
if ( $size == 0 ) {
$stxt = wfMsgExt( 'historyempty', 'parsemag' );
/**
* Add another level to the Table of Contents
+ *
+ * @return string
*/
- static function tocIndent() {
+ public static function tocIndent() {
return "\n<ul>";
}
/**
* Finish one or more sublevels on the Table of Contents
+ *
+ * @return string
*/
- static function tocUnindent( $level ) {
+ public static function tocUnindent( $level ) {
return "</li>\n" . str_repeat( "</ul>\n</li>\n", $level > 0 ? $level : 0 );
}
/**
* parameter level defines if we are on an indentation level
+ *
+ * @return string
*/
- static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
+ public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
$classes = "toclevel-$level";
- if ( $sectionIndex !== false )
+ if ( $sectionIndex !== false ) {
$classes .= " tocsection-$sectionIndex";
+ }
return "\n<li class=\"$classes\"><a href=\"#" .
$anchor . '"><span class="tocnumber">' .
$tocnumber . '</span> <span class="toctext">' .
* tocUnindent() will be used instead if we're ending a line below
* the new level.
*/
- static function tocLineEnd() {
+ public static function tocLineEnd() {
return "</li>\n";
}
* @param $lang mixed: Language code for the toc title
* @return String: full html of the TOC
*/
- static function tocList( $toc, $lang = false ) {
+ public static function tocList( $toc, $lang = false ) {
$title = wfMsgExt( 'toc', array( 'language' => $lang, 'escape' ) );
return
'<table id="toc" class="toc"><tr><td>'
foreach ( $tree as $section ) {
if ( $section['toclevel'] > $lastLevel )
$toc .= self::tocIndent();
- else if ( $section['toclevel'] < $lastLevel )
+ elseif ( $section['toclevel'] < $lastLevel )
$toc .= self::tocUnindent(
$lastLevel - $section['toclevel'] );
else
* a space and ending with '>'
* This *must* be at least '>' for no attribs
* @param $anchor String: the anchor to give the headline (the bit after the #)
- * @param $text String: the text of the header
+ * @param $html String: html for the text of the header
* @param $link String: HTML to add for the section edit link
* @param $legacyAnchor Mixed: a second, optional anchor to give for
* backward compatibility (false to omit)
*
* @return String: HTML headline
*/
- public static function makeHeadline( $level, $attribs, $anchor, $text, $link, $legacyAnchor = false ) {
+ public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
$ret = "<h$level$attribs"
. $link
- . " <span class=\"mw-headline\" id=\"$anchor\">$text</span>"
+ . " <span class=\"mw-headline\" id=\"$anchor\">$html</span>"
. "</h$level>";
if ( $legacyAnchor !== false ) {
$ret = "<div id=\"$legacyAnchor\"></div>$ret";
*
* @param $rev Revision object
*/
- static function generateRollback( $rev ) {
+ public static function generateRollback( $rev ) {
return '<span class="mw-rollback-link">['
. self::buildRollbackLink( $rev )
. ']</span>';
$query['bot'] = '1';
$query['hidediff'] = '1'; // bug 15999
}
- return self::link(
- $title,
+ return self::link(
+ $title,
wfMsgHtml( 'rollbacklink' ),
array( 'title' => wfMsg( 'tooltip-rollback' ) ),
- $query,
- array( 'known', 'noclasses' )
+ $query,
+ array( 'known', 'noclasses' )
);
}
return $outText;
}
+ /**
+ * Returns HTML for the "templates used on this page" list.
+ *
+ * @param $templates Array of templates from Article::getUsedTemplate
+ * or similar
+ * @param $preview Boolean: whether this is for a preview
+ * @param $section Boolean: whether this is for a section edit
+ * @return String: HTML output
+ */
+ public static function formatDistantTemplates( $templates, $preview = false, $section = false ) {
+ wfProfileIn( __METHOD__ );
+
+ $outText = '';
+ if ( count( $templates ) > 0 ) {
+
+ # Construct the HTML
+ $outText = '<div class="mw-templatesUsedExplanation">';
+ if ( $preview ) {
+ $outText .= wfMsgExt( 'distanttemplatesusedpreview', array( 'parse' ), count( $templates ) );
+ } elseif ( $section ) {
+ $outText .= wfMsgExt( 'distanttemplatesusedsection', array( 'parse' ), count( $templates ) );
+ } else {
+ $outText .= wfMsgExt( 'distanttemplatesused', array( 'parse' ), count( $templates ) );
+ }
+ $outText .= "</div><ul>\n";
+
+ usort( $templates, array( 'Title', 'compare' ) );
+ foreach ( $templates as $titleObj ) {
+ $outText .= '<li>' . self::link( $titleObj ) . '</li>';
+ }
+ $outText .= '</ul>';
+ }
+ wfProfileOut( __METHOD__ );
+ return $outText;
+ }
+
/**
* Returns HTML for the "hidden categories on this page" list.
*
* escape), or false for no title attribute
*/
public static function titleAttrib( $name, $options = null ) {
+ global $wgEnableTooltipsAndAccesskeys;
+ if ( !$wgEnableTooltipsAndAccesskeys )
+ return false;
+
wfProfileIn( __METHOD__ );
$message = wfMessage( "tooltip-$name" );
} else {
$accesskey = $message->plain();
if ( $accesskey === '' || $accesskey === '-' ) {
- # FIXME: Per standard MW behavior, a value of '-' means to suppress the
+ # @todo 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.
$accesskey = false;
return self::$accesskeycache[$name] = $accesskey;
}
+ /**
+ * Get a revision-deletion link, or disabled link, or nothing, depending
+ * on user permissions & the settings on the revision.
+ *
+ * Will use forward-compatible revision ID in the Special:RevDelete link
+ * if possible, otherwise the timestamp-based ID which may break after
+ * undeletion.
+ *
+ * @param User $user
+ * @param Revision $rev
+ * @param Revision $title
+ * @return string HTML fragment
+ */
+ public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) {
+ $canHide = $user->isAllowed( 'deleterevision' );
+ if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
+ if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
+ $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
+ } else {
+ if ( $rev->getId() ) {
+ // RevDelete links using revision ID are stable across
+ // page deletion and undeletion; use when possible.
+ $query = array(
+ 'type' => 'revision',
+ 'target' => $title->getPrefixedDBkey(),
+ 'ids' => $rev->getId()
+ );
+ } else {
+ // Older deleted entries didn't save a revision ID.
+ // We have to refer to these by timestamp, ick!
+ $query = array(
+ 'type' => 'archive',
+ 'target' => $title->getPrefixedDBkey(),
+ 'ids' => $rev->getTimestamp()
+ );
+ }
+ return Linker::revDeleteLink( $query,
+ $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide );
+ }
+ } else {
+ return '';
+ }
+ }
+
/**
* Creates a (show/hide) link for deleting revisions/log entries
*
*/
public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {
$sp = SpecialPage::getTitleFor( 'Revisiondelete' );
- $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
+ $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
$tag = $restricted ? 'strong' : 'span';
- $link = self::link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) );
+ $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" );
}
* of appearance with CSS
*/
public static function revDeleteLinkDisabled( $delete = true ) {
- $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
- return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), "($text)" );
+ $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
+ return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), "($html)" );
}
/* Deprecated methods */
global $wgEnableTooltipsAndAccesskeys;
if ( !$wgEnableTooltipsAndAccesskeys )
return array();
- # FIXME: If Sanitizer::expandAttributes() treated "false" as "output
+ # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
# no attribute" instead of "output '' as value for attribute", this
# would be three lines.
$attribs = array(
global $wgEnableTooltipsAndAccesskeys;
if ( !$wgEnableTooltipsAndAccesskeys )
return '';
- # FIXME: If Sanitizer::expandAttributes() treated "false" as "output
+ # @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
# no attribute" instead of "output '' as value for attribute", this
# would be two lines.
$tooltip = self::titleAttrib( $name, $options );
}
}
+/**
+ * @since 1.18
+ */
class DummyLinker {
-
+
/**
* Use PHP's magic __call handler to transform instance calls to a dummy instance
* into static calls to the new Linker for backwards compatibility.
* @param $fname String Name of called method
* @param $args Array Arguments to the method
*/
- function __call( $fname, $args ) {
+ public function __call( $fname, $args ) {
return call_user_func_array( array( 'Linker', $fname ), $args );
}
-
}
-