*
* @param $class String: the contents of the class attribute; if an empty
* string is passed, which is the default value, defaults to 'external'.
+ * @deprecated Just pass the external class directly to something using Html::expandAttributes
*/
function getExternalLinkAttributes( $class = 'external' ) {
+ wfDeprecated( __METHOD__ );
return $this->getLinkAttributesInternal( '', $class );
}
* Get the appropriate HTML attributes to add to the "a" element of an in-
* ternal link, given the Title object for the page we want to link to.
*
- * @param $nt The Title object
+ * @param $nt Title
* @param $unused String: unused
* @param $class String: the contents of the class attribute, default none
* @param $title Mixed: optional (unescaped) string to use in the title
* Has compatibility issues on some setups, so avoid wherever possible.
* @return string HTML <a> attribute
*/
- public function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
+ public function link(
+ $target, $text = null, $customAttribs = array(), $query = array(), $options = array()
+ ) {
wfProfileIn( __METHOD__ );
if ( !$target instanceof Title ) {
+ wfProfileOut( __METHOD__ );
return "<!-- ERROR -->$text";
}
$options = (array)$options;
$attribs = array_merge(
$attribs,
- $this->linkAttribs( $target, $customAttribs, $options )
+ $this->linkAttribs( $target, $customAttribs, $options, $text )
);
if ( is_null( $text ) ) {
$text = $this->linkText( $target );
/**
* Identical to link(), except $options defaults to 'known'.
*/
- public function linkKnown( $target, $text = null, $customAttribs = array(), $query = array(), $options = array( 'known', 'noclasses' ) ) {
+ public function linkKnown(
+ $target, $text = null, $customAttribs = array(),
+ $query = array(), $options = array( 'known', 'noclasses' ) )
+ {
return $this->link( $target, $text, $customAttribs, $query, $options );
}
/**
* Returns the Url used to link to a Title
+ *
+ * @param $target Title
*/
private function linkUrl( $target, $query, $options ) {
wfProfileIn( __METHOD__ );
# We don't want to include fragments for broken links, because they
# generally make no sense.
- if ( in_array( 'broken', $options ) and $target->mFragment !== '' ) {
+ if ( in_array( 'broken', $options ) && $target->mFragment !== '' ) {
$target = clone $target;
$target->mFragment = '';
}
# If it's a broken link, add the appropriate query pieces, unless
# there's already an action specified, or unless 'edit' makes no sense
# (i.e., for a nonexistent special page).
- if ( in_array( 'broken', $options ) and empty( $query['action'] )
- and $target->getNamespace() != NS_SPECIAL ) {
+ if ( in_array( 'broken', $options ) && empty( $query['action'] )
+ && $target->getNamespace() != NS_SPECIAL ) {
$query['action'] = 'edit';
$query['redlink'] = '1';
}
/**
* Returns the array of attributes used when linking to the Title $target
+ *
+ * @param $target Title
*/
- private function linkAttribs( $target, $attribs, $options ) {
+ private function linkAttribs( $target, $attribs, $options, $linkText ) {
wfProfileIn( __METHOD__ );
global $wgUser;
$defaults = array();
}
# Get a default title attribute.
+ global $wgLang;
+ $known = in_array( 'known', $options );
if ( $target->getPrefixedText() == '' ) {
# A link like [[#Foo]]. This used to mean an empty title
# attribute, but that's silly. Just don't output a title.
- } elseif ( in_array( 'known', $options ) ) {
+ } elseif ( $known &&
+ $wgLang->caseFold($linkText) !== $wgLang->caseFold($target->getPrefixedText() ) )
+ {
$defaults['title'] = $target->getPrefixedText();
- } else {
+ } elseif ( !$known ) {
$defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() );
}
/**
* Default text of the links to the Title $target
+ *
+ * @param $target Title
*/
private function linkText( $target ) {
# We might be passed a non-Title by make*LinkObj(). Fail gracefully.
# If the target is just a fragment, with no title, we return the frag-
# ment text. Otherwise, we return the title text itself.
- if ( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) {
+ if ( $target->getPrefixedText() === '' && $target->getFragment() !== '' ) {
return htmlspecialchars( $target->getFragment() );
}
return htmlspecialchars( $target->getPrefixedText() );
* Generate either a normal exists-style link or a stub link, depending
* on the given page size.
*
- * @param $size Integer
- * @param $nt Title object.
- * @param $text String
- * @param $query String
- * @param $trail String
- * @param $prefix String
- * @return string HTML of link
- * @deprecated
+ * @param $size Integer
+ * @param $nt Title object.
+ * @param $text String
+ * @param $query String
+ * @param $trail String
+ * @param $prefix String
+ * @return string HTML of link
+ * @deprecated since 1.17
*/
function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
global $wgUser;
* Make appropriate markup for a link to the current article. This is currently rendered
* as the bold link text. The calling sequence is the same as the other make*LinkObj functions,
* despite $query not being used.
+ *
+ * @param $nt Title
*/
function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
if ( $text == '' ) {
* caption HTML for image caption.
* link-url URL to link to
* link-title Title object to link to
+ * link-target Value for the target attribue, only with link-url
* no-link Boolean, suppress description link
*
* @param $handlerParams Array: associative array of media handler parameters, to be passed
* to transform(). Typical keys are "width" and "page".
* @param $time String: timestamp of the file, set as false for current
* @param $query String: query params for desc url
+ * @param $widthOption: Used by the parser to remember the user preference thumbnailsize
* @return String: HTML for an image, with links, wrappers, etc.
*/
- function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
+ function makeImageLink2( Title $title, $file, $frameParams = array(),
+ $handlerParams = array(), $time = false, $query = "", $widthOption = null )
+ {
$res = null;
if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title,
- &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
+ &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
return $res;
}
- global $wgContLang, $wgThumbLimits, $wgThumbUpright;
if ( $file && !$file->allowInlineDisplay() ) {
wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" );
return $this->link( $title );
// Clean up parameters
$page = isset( $hp['page'] ) ? $hp['page'] : false;
- if ( !isset( $fp['align'] ) ) $fp['align'] = '';
- if ( !isset( $fp['alt'] ) ) $fp['alt'] = '';
- if ( !isset( $fp['title'] ) ) $fp['title'] = '';
+ if ( !isset( $fp['align'] ) ) {
+ $fp['align'] = '';
+ }
+ if ( !isset( $fp['alt'] ) ) {
+ $fp['alt'] = '';
+ }
+ if ( !isset( $fp['title'] ) ) {
+ $fp['title'] = '';
+ }
$prefix = $postfix = '';
$hp['width'] = $file->getWidth( $page );
if ( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
+ global $wgThumbLimits, $wgThumbUpright;
if ( !isset( $widthOption ) || !isset( $wgThumbLimits[$widthOption] ) ) {
- $widthOption = User::getDefaultOption( 'thumbsize' );
+ $widthOption = User::getDefaultOption( 'thumbsize' );
}
// Reduce width for upright images when parameter 'upright' is used
if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
$fp['upright'] = $wgThumbUpright;
}
- // Use width which is smaller: real image width or user preference width
// For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
$prefWidth = isset( $fp['upright'] ) ?
round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
$wgThumbLimits[$widthOption];
- if ( $hp['width'] <= 0 || $prefWidth < $hp['width'] ) {
- if ( !isset( $hp['height'] ) ) {
- $hp['width'] = $prefWidth;
- }
+
+ // Use width which is smaller: real image width or user preference width
+ // Unless image is scalable vector.
+ if ( !isset( $hp['height'] ) && ( $hp['width'] <= 0 ||
+ $prefWidth < $hp['width'] || $file->isVectorized() ) ) {
+ $hp['width'] = $prefWidth;
}
}
}
if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) ) {
+ global $wgContLang;
# Create a thumbnail. Alignment depends on language
# writing direction, # right aligned for left-to-right-
# languages ("Western languages"), left-aligned
}
}
- if ( $file && $hp['width'] ) {
+ if ( $file && isset( $hp['width'] ) ) {
# Create a resized image, without the additional thumbnail features
$thumb = $file->transform( $hp );
} else {
$mtoParams = array();
if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
+ if ( isset( $frameParams['link-target'] ) ) {
+ $mtoParams['custom-target-link'] = $frameParams['link-target'];
+ }
} elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) {
- $mtoParams['custom-title-link'] = $frameParams['link-title'];
+ $mtoParams['custom-title-link'] = $this->normaliseSpecialPage( $frameParams['link-title'] );
} elseif ( !empty( $frameParams['no-link'] ) ) {
// No link
} else {
* @param $framed Boolean
* @param $manualthumb String
*/
- function makeThumbLinkObj( Title $title, $file, $label = '', $alt, $align = 'right', $params = array(), $framed = false , $manualthumb = "" ) {
+ function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
+ $align = 'right', $params = array(), $framed = false , $manualthumb = "" )
+ {
$frameParams = array(
'alt' => $alt,
'caption' => $label,
'align' => $align
);
- if ( $framed ) $frameParams['framed'] = true;
- if ( $manualthumb ) $frameParams['manualthumb'] = $manualthumb;
+ if ( $framed ) {
+ $frameParams['framed'] = true;
+ }
+ if ( $manualthumb ) {
+ $frameParams['manualthumb'] = $manualthumb;
+ }
return $this->makeThumbLink2( $title, $file, $frameParams, $params );
}
- function makeThumbLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "" ) {
+ /**
+ * @param $title Title
+ * @param $file File
+ * @param array $frameParams
+ * @param array $handlerParams
+ * @param bool $time
+ * @param string $query
+ * @return mixed
+ */
+ function makeThumbLink2( Title $title, $file, $frameParams = array(),
+ $handlerParams = array(), $time = false, $query = "" )
+ {
global $wgStylePath;
$exists = $file && $file->exists();
* Make a "broken" link to an image
*
* @param $title Title object
- * @param $text String: link label
+ * @param $text String: link label in unescaped text form
* @param $query String: query string
- * @param $trail String: link trail
- * @param $prefix String: link prefix
+ * @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
*/
if ( $title instanceof Title ) {
wfProfileIn( __METHOD__ );
$currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
- if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) {
- if ( $text == '' )
- $text = htmlspecialchars( $title->getPrefixedText() );
+ list( $inside, $trail ) = self::splitTrail( $trail );
+ if ( $text == '' )
+ $text = htmlspecialchars( $title->getPrefixedText() );
+
+ if ( ( $wgUploadMissingFileUrl || $wgEnableUploads ) && !$currentExists ) {
$redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
+
if ( $redir ) {
wfProfileOut( __METHOD__ );
- return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
+ return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
}
$href = $this->getUploadUrl( $title, $query );
-
- list( $inside, $trail ) = self::splitTrail( $trail );
-
wfProfileOut( __METHOD__ );
return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
- htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
- htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
+ htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
+ "$prefix$text$inside</a>$trail";
} else {
wfProfileOut( __METHOD__ );
- return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
+ return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
}
} else {
+ wfProfileOut( __METHOD__ );
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
}
*
* @param $title Title object.
* @param $text String: pre-sanitized HTML
- * @param $time string: time image was created
+ * @param $time string: MW timestamp of file creation time
+ * @return String: HTML
+ */
+ public function makeMediaLinkObj( $title, $text = '', $time = false ) {
+ $img = wfFindFile( $title, array( 'time' => $time ) );
+ return $this->makeMediaLinkFile( $title, $img, $text );
+ }
+
+ /**
+ * Create a direct link to a given uploaded file.
+ * 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
* @return String: HTML
*
* @todo Handle invalid or missing images better.
*/
- public function makeMediaLinkObj( $title, $text = '', $time = false ) {
- if ( is_null( $title ) ) {
- # # # HOTFIX. Instead of breaking, return empty string.
- return $text;
+ public function makeMediaLinkFile( Title $title, $file, $text = '' ) {
+ if ( $file && $file->exists() ) {
+ $url = $file->getURL();
+ $class = 'internal';
} else {
- $img = wfFindFile( $title, array( 'time' => $time ) );
- if ( $img ) {
- $url = $img->getURL();
- $class = 'internal';
- } else {
- $url = $this->getUploadUrl( $title );
- $class = 'new';
- }
- $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
- if ( $text == '' ) {
- $text = $alt;
- }
- $u = htmlspecialchars( $url );
- return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$text}</a>";
+ $url = $this->getUploadUrl( $title );
+ $class = 'new';
+ }
+ $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
+ if ( $text == '' ) {
+ $text = $alt;
}
+ $u = htmlspecialchars( $url );
+ return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$text}</a>";
}
/**
function specialLink( $name, $key = '' ) {
if ( $key == '' ) { $key = strtolower( $name ); }
- return $this->link( SpecialPage::getTitleFor( $name ) , wfMsg( $key ), array(), array(), array( 'known', 'noclasses' ) );
+ return $this->linkKnown( SpecialPage::getTitleFor( $name ) , wfMsg( $key ) );
}
/**
* @param $escape Boolean: do we escape the link text?
* @param $linktype String: type of external link. Gets added to the classes
* @param $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() ) {
- if ( isset( $attribs['class'] ) ) {
- # yet another hack :(
- $class = $attribs['class'];
- } else {
- $class = "external $linktype";
+ $class = "external";
+ if ( isset($linktype) && $linktype ) {
+ $class .= " $linktype";
}
-
- $attribsText = $this->getExternalLinkAttributes( $class );
- $url = htmlspecialchars( $url );
+ if ( isset($attribs['class']) && $attribs['class'] ) {
+ $class .= " {$attribs['class']}";
+ }
+ $attribs['class'] = $class;
+
if ( $escape ) {
$text = htmlspecialchars( $text );
}
$link = '';
- $success = wfRunHooks( 'LinkerMakeExternalLink', array( &$url, &$text, &$link, &$attribs, $linktype ) );
+ $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}\n", true );
return $link;
}
- if ( $attribs ) {
- $attribsText .= Html::expandAttributes( $attribs );
- }
- return '<a href="' . $url . '"' . $attribsText . '>' . $text . '</a>';
+ $attribs['href'] = $url;
+ return Html::rawElement( 'a', $attribs, $text );
}
/**
* @param $edits Integer: user edit count (optional, for performance)
* @return String: HTML fragment
*/
- public function userToolLinks( $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null ) {
- global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans, $wgLang;
+ public function userToolLinks(
+ $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
+ ) {
+ global $wgUser, $wgDisableAnonTalk, $wgLang;
$talkable = !( $wgDisableAnonTalk && 0 == $userId );
- $blockable = ( $wgSysopUserBans || 0 == $userId ) && !$flags & self::TOOL_LINKS_NOBLOCK;
+ $blockable = !$flags & self::TOOL_LINKS_NOBLOCK;
$items = array();
if ( $talkable ) {
* @private
*/
function blockLink( $userId, $userText ) {
- $blockPage = SpecialPage::getTitleFor( 'Blockip', $userText );
+ $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
$blockLink = $this->link( $blockPage, wfMsgHtml( 'blocklink' ) );
return $blockLink;
}
# fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
if ( strpos( $match[1], '%' ) !== false ) {
- $match[1] = str_replace( array( '<', '>' ), array( '<', '>' ), urldecode( $match[1] ) );
+ $match[1] = str_replace( array( '<', '>' ), array( '<', '>' ), rawurldecode( $match[1] ) );
}
# Handle link renaming [[foo|text]] will show link as "text"
return $comment;
}
+ /**
+ * @static
+ * @param $contextTitle Title
+ * @param $target
+ * @param $text
+ * @return string
+ */
static function normalizeSubpageLink( $contextTitle, $target, &$text ) {
# Valid link forms:
# Foobar -- normal
* @return String: HTML fragment
*/
function revComment( Revision $rev, $local = false, $isPublic = false ) {
- if ( $rev->getRawComment() == "" ) return "";
+ 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 ) ) {
*/
function tocLineEnd() {
return "</li>\n";
- }
+ }
/**
* Wraps the TOC in a table and provides the hide/collapse javascript.
*
* @param $toc String: html of the Table Of Contents
+ * @param $lang mixed: Language code for the toc title
* @return String: full html of the TOC
*/
- function tocList( $toc ) {
- $title = wfMsgHtml( 'toc' ) ;
+ function tocList( $toc, $lang = false ) {
+ $title = wfMsgExt( 'toc', array( 'language' => $lang, 'escape' ) );
return
'<table id="toc" class="toc"><tr><td>'
. '<div id="toctitle"><h2>' . $title . "</h2></div>\n"
. $toc
- # no trailing newline, script should not be wrapped in a
- # paragraph
- . "</ul>\n</td></tr></table>"
- . Html::inlineScript(
- 'if (window.showTocToggle) {'
- . ' var tocShowText = "' . Xml::escapeJsString( wfMsg( 'showtoc' ) ) . '";'
- . ' var tocHideText = "' . Xml::escapeJsString( wfMsg( 'hidetoc' ) ) . '";'
- . ' showTocToggle();'
- . ' } ' )
- . "\n";
+ . "</ul>\n</td></tr></table>\n";
}
/**
// added to it for LTR text on RTL pages
$attribs = array();
if ( !is_null( $tooltip ) ) {
+ # Bug 25462: undo double-escaping.
+ $tooltip = Sanitizer::decodeCharReferences( $tooltip );
$attribs['title'] = wfMsgReal( 'editsectionhint', array( $tooltip ), true, $lang );
}
$link = $this->link( $nt, wfMsgExt( 'editsection', array( 'language' => $lang ) ),
$attribs = " title=\"$attribs\"";
}
$result = null;
- wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result ) );
+ wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result, $lang ) );
if ( !is_null( $result ) ) {
# For reverse compatibility, add the brackets *after* the hook is
# run, and even add them to hook-provided text. (This is the main
# reason that the EditSectionLink hook is deprecated in favor of
# DoEditSectionLink: it can't change the brackets or the span.)
- $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $link );
+ $result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $result );
return "<span class=\"editsection\">$result</span>";
}
$result = wfMsgExt( 'editsection-brackets', array( 'escape', 'replaceafter', 'language' => $lang ), $link );
$result = "<span class=\"editsection\">$result</span>";
- wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result ) );
+ wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) );
return $result;
}
$title = $rev->getTitle();
$query = array(
'action' => 'rollback',
- 'from' => $rev->getUserText()
+ 'from' => $rev->getUserText(),
+ 'token' => $wgUser->editToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
);
if ( $wgRequest->getBool( 'bot' ) ) {
$query['bot'] = '1';
$query['hidediff'] = '1'; // bug 15999
}
- $query['token'] = $wgUser->editToken( array( $title->getPrefixedText(),
- $rev->getUserText() ) );
- return $this->link( $title, wfMsgHtml( 'rollbacklink' ),
+ return $this->link(
+ $title,
+ wfMsgHtml( 'rollbacklink' ),
array( 'title' => wfMsg( 'tooltip-rollback' ) ),
- $query, array( 'known', 'noclasses' ) );
+ $query,
+ array( 'known', 'noclasses' )
+ );
}
/**
public function titleAttrib( $name, $options = null ) {
wfProfileIn( __METHOD__ );
- if ( wfEmptyMsg( "tooltip-$name" ) ) {
+ $message = wfMessage( "tooltip-$name" );
+
+ if ( !$message->exists() ) {
$tooltip = false;
} else {
- $tooltip = wfMsg( "tooltip-$name" );
+ $tooltip = $message->text();
# Compatibility: formerly some tooltips had [alt-.] hardcoded
$tooltip = preg_replace( "/ ?\[alt-.\]$/", '', $tooltip );
# Message equal to '-' means suppress it.
* escape), or false for no accesskey attribute
*/
public function accesskey( $name ) {
+ if ( isset( $this->accesskeycache[$name] ) ) {
+ return $this->accesskeycache[$name];
+ }
wfProfileIn( __METHOD__ );
- if ( wfEmptyMsg( "accesskey-$name" ) ) {
+ $message = wfMessage( "accesskey-$name" );
+
+ if ( !$message->exists() ) {
$accesskey = false;
} else {
- $accesskey = wfMsg( "accesskey-$name" );
+ $accesskey = $message->plain();
if ( $accesskey === '' || $accesskey === '-' ) {
# FIXME: Per standard MW behavior, a value of '-' means to suppress the
# attribute, but this is broken for accesskey: that might be a useful
}
wfProfileOut( __METHOD__ );
- return $accesskey;
+ return $this->accesskeycache[$name] = $accesskey;
}
/**
/* Deprecated methods */
/**
- * @deprecated
- */
- function postParseLinkColour( $s = null ) {
- wfDeprecated( __METHOD__ );
- return null;
- }
-
-
- /**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* This function is a shortcut to makeLinkObj(Title::newFromText($title),...). Do not call
* it if you already have a title object handy. See makeLinkObj for further documentation.
*/
function makeLink( $title, $text = '', $query = '', $trail = '' ) {
wfProfileIn( __METHOD__ );
- $nt = Title::newFromText( $title );
+ $nt = Title::newFromText( $title );
if ( $nt instanceof Title ) {
$result = $this->makeLinkObj( $nt, $text, $query, $trail );
} else {
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* This function is a shortcut to makeKnownLinkObj(Title::newFromText($title),...). Do not call
* it if you already have a title object handy. See makeKnownLinkObj for further documentation.
* @param $prefix String: Optional prefix
* @param $aprops String: extra attributes to the a-element
*/
- function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '' ) {
+ function makeKnownLink(
+ $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = ''
+ ) {
$nt = Title::newFromText( $title );
if ( $nt instanceof Title ) {
return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops );
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* This function is a shortcut to makeBrokenLinkObj(Title::newFromText($title),...). Do not call
* it if you already have a title object handy. See makeBrokenLinkObj for further documentation.
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* This function is a shortcut to makeStubLinkObj(Title::newFromText($title),...). Do not call
* it if you already have a title object handy. See makeStubLinkObj for further documentation.
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* Make a link for a title which may or may not be in the database. If you need to
* call this lots of times, pre-fill the link cache with a LinkBatch, otherwise each
*/
function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfProfileIn( __METHOD__ );
-
$query = wfCgiToArray( $query );
list( $inside, $trail ) = Linker::splitTrail( $trail );
if ( $text === '' ) {
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* Make a link for a title which definitely exists. This is faster than makeLinkObj because
* it doesn't have to do a database query. It's also valid for interwiki titles and special
* @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead
* @return the a-element
*/
- function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
+ function makeKnownLinkObj(
+ $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = ''
+ ) {
wfProfileIn( __METHOD__ );
if ( $text == '' ) {
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* Make a red link to the edit page of a given title.
*
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* Make a brown link to a short article.
*
* @param $prefix String: Optional prefix
*/
function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- // wfDeprecated( __METHOD__ );
return $this->makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix );
}
/**
- * @deprecated Use link()
+ * @deprecated since 1.16 Use link()
*
* Make a coloured link.
*
* @param $prefix String: Optional prefix
*/
function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
- // wfDeprecated( __METHOD__ );
if ( $colour != '' ) {
$style = $this->getInternalLinkAttributesObj( $nt, $text, $colour );
- } else $style = '';
+ } else {
+ $style = '';
+ }
return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
}
/**
* Creates the HTML source for images
- * @deprecated use makeImageLink2
+ * @deprecated since 1.16 use makeImageLink2
*
* @param $title Title object
* @param $label String: label text
* @param $time String: timestamp of the file, set as false for current
* @return String
*/
- function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(), $framed = false,
- $thumb = false, $manualthumb = '', $valign = '', $time = false )
+ function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(),
+ $framed = false, $thumb = false, $manualthumb = '', $valign = '', $time = false )
{
$frameParams = array( 'alt' => $alt, 'caption' => $label );
if ( $align ) {
return $this->makeMediaLinkObj( $nt, $text, $time );
}
- /**
- * Used to generate section edit links that point to "other" pages
- * (sections that are really part of included pages).
- *
- * @deprecated use Linker::doEditSectionLink()
- * @param $title Title string.
- * @param $section Integer: section number.
- */
- public function editSectionLinkForOther( $title, $section ) {
- wfDeprecated( __METHOD__ );
- $title = Title::newFromText( $title );
- return $this->doEditSectionLink( $title, $section );
- }
-
- /**
- * @deprecated use Linker::doEditSectionLink()
- * @param $nt Title object.
- * @param $section Integer: section number.
- * @param $hint Link String: title, or default if omitted or empty
- */
- public function editSectionLink( Title $nt, $section, $hint = '' ) {
- wfDeprecated( __METHOD__ );
- if ( $hint === '' ) {
- # No way to pass an actual empty $hint here! The new interface al-
- # lows this, so we have to do this for compatibility.
- $hint = null;
- }
- return $this->doEditSectionLink( $nt, $section, $hint );
- }
-
/**
* Returns the attributes for the tooltip and access key.
*/
}
return $attribs;
}
+
/**
- * @deprecated Returns raw bits of HTML, use titleAttrib() and accesskey()
+ * @deprecated since 1.14
+ * Returns raw bits of HTML, use titleAttrib() and accesskey()
*/
public function tooltipAndAccesskey( $name ) {
return Xml::expandAttributes( $this->tooltipAndAccesskeyAttribs( $name ) );
}
-
- /** @deprecated Returns raw bits of HTML, use titleAttrib() */
+ /**
+ * @deprecated since 1.14
+ * Returns raw bits of HTML, use titleAttrib()
+ */
public function tooltip( $name, $options = null ) {
global $wgEnableTooltipsAndAccesskeys;
if ( !$wgEnableTooltipsAndAccesskeys )