* 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-
* @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
*
* @return string
*/
- static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
if ( $html == '' ) {
$html = htmlspecialchars( $nt->getPrefixedText() );
}
*
* @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;
* @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;
*
* @return string
*/
- static function specialLink( $name, $key = '' ) {
+ public static function specialLink( $name, $key = '' ) {
if ( $key == '' ) {
$key = strtolower( $name );
}
* @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;
* @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' );
} elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
* @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' );
} elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
* @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:
# Media link; trail not supported.
$linkRegexp = '/\[\[(.*?)\]\]/';
$title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
- $thelink = self::makeMediaLinkObj( $title, $text );
+ if ( $title ) {
+ $thelink = self::makeMediaLinkObj( $title, $text );
+ }
} else {
# Other kind of link
if ( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) {
* @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)
# bug 7425
$target = trim( $target );
# Look at the first character
- if ( $target != '' && $target { 0 } === '/' ) {
+ if ( $target != '' && $target[0] === '/' ) {
# / at end means we don't want the slash to be shown
$m = array();
$trailingSlashes = preg_match_all( '%(/+)$%', $target, $m );
*
* @return string
*/
- static function commentBlock( $comment, $title = null, $local = false ) {
+ 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 );
- return " <span class=\"comment\">($formatted)</span>";
+ 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 "";
}
*
* @return string
*/
- static function tocIndent() {
+ public static function tocIndent() {
return "\n<ul>";
}
*
* @return string
*/
- static function tocUnindent( $level ) {
+ public static function tocUnindent( $level ) {
return "</li>\n" . str_repeat( "</ul>\n</li>\n", $level > 0 ? $level : 0 );
}
*
* @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 ) {
$classes .= " tocsection-$sectionIndex";
* 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>'
*
* @param $rev Revision object
*/
- static function generateRollback( $rev ) {
+ public static function generateRollback( $rev ) {
return '<span class="mw-rollback-link">['
. self::buildRollbackLink( $rev )
. ']</span>';