$attribs = array_merge(
$attribs,
- $this->linkAttribs( $target, $customAttribs, $options )
+ $this->linkAttribs( $target, $customAttribs, $options, $text )
);
if ( is_null( $text ) ) {
$text = $this->linkText( $target );
/**
* Returns the array of attributes used when linking to the Title $target
*/
- private function linkAttribs( $target, $attribs, $options ) {
+ private function linkAttribs( $target, $attribs, $options, $linkText ) {
wfProfileIn( __METHOD__ );
global $wgUser;
$defaults = array();
}
# Get a default title attribute.
+ $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 && strtolower($linkText) !== strtolower($target->getPrefixedText() ) ) {
$defaults['title'] = $target->getPrefixedText();
- } else {
+ } elseif ( !$known ) {
$defaults['title'] = wfMsg( 'red-link-title', $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
*/
function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
global $wgUser;
* 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 ) {
return $res;
}
- global $wgContLang, $wgThumbLimits, $wgThumbUpright;
if ( $file && !$file->allowInlineDisplay() ) {
wfDebug( __METHOD__ . ': ' . $title->getPrefixedDBkey() . " does not allow inline display\n" );
return $this->link( $title );
$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 {
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 ) . '">' .
+ htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
} else {
wfProfileOut( __METHOD__ );
- return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
+ return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
}
} else {
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
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 ) );
}
/**
# 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"
*/
function tocLineEnd() {
return "</li>\n";
- }
+ }
/**
* Wraps the TOC in a table and provides the hide/collapse javascript.
'<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.
public function accesskey( $name ) {
wfProfileIn( __METHOD__ );
- if ( wfEmptyMsg( "accesskey-$name" ) ) {
+ if ( isset( $this->accesskeycache[$name] ) ) {
+ return $this->accesskeycache[$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;
}
/**
*/
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 {
* @param $prefix String: Optional prefix
*/
function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- // wfDeprecated( __METHOD__ );
return $this->makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix );
}
* @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 = '';
return Xml::expandAttributes( $this->tooltipAndAccesskeyAttribs( $name ) );
}
-
/** @deprecated Returns raw bits of HTML, use titleAttrib() */
public function tooltip( $name, $options = null ) {
global $wgEnableTooltipsAndAccesskeys;