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 );
/**
* 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 @since 1.17
*/
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
$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 {
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->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
# 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.
$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;
}
/**
/* 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.
}
/**
- * @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
}
/**
- * @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
}
/**
- * @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 = '';
/**
* Creates the HTML source for images
- * @deprecated use makeImageLink2
+ * @deprecated @since 1.16 use makeImageLink2
*
* @param $title Title object
* @param $label String: label text
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 )