} elseif ( in_array( 'known', $options ) ) {
$defaults['title'] = $target->getPrefixedText();
} else {
- $defaults['title'] = wfMessage( 'red-link-title', $target->getPrefixedText() )->text();
+ // This ends up in parser cache!
+ $defaults['title'] = wfMessage( 'red-link-title', $target->getPrefixedText() )
+ ->inContentLanguage()
+ ->text();
}
# Finally, merge the custom attribs with the default ones, and iterate
# Create a thumbnail. Alignment depends on the writing direction of
# the page content language (right-aligned for LTR languages,
# left-aligned for RTL languages)
- #
# If a thumbnail width has not been provided, it is set
# to the default user option as specified in Language*.php
if ( $fp['align'] == '' ) {
return str_replace( "\n", ' ', $prefix . $s . $postfix );
}
- /**
- * See makeImageLink()
- * When this function is removed, remove if( $parser instanceof Parser ) check there too
- * @deprecated since 1.20
- */
- public static function makeImageLink2( Title $title, $file, $frameParams = array(),
- $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
- return self::makeImageLink( null, $title, $file, $frameParams,
- $handlerParams, $time, $query, $widthOption );
- }
-
/**
* Get the link parameters for MediaTransformOutput::toHtml() from given
* frame parameters supplied by the Parser.
* temporarily to a value pass. Should be adjusted further. --brion
*
* @param string $comment
- * @param Title|null $title Title object (to generate link to the section in autocomment) or null
+ * @param Title|null $title Title object (to generate link to the section in autocomment)
+ * or null
* @param bool $local Whether section links should refer to local page
- * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to. For use with external changes.
+ * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to.
+ * For use with external changes.
*
* @return mixed|string
*/
- public static function formatComment( $comment, $title = null, $local = false, $wikiId = null ) {
-
+ public static function formatComment(
+ $comment, $title = null, $local = false, $wikiId = null
+ ) {
# Sanitize text a bit:
$comment = str_replace( "\n", " ", $comment );
# Allow HTML entities (for bug 13815)
* @param string $comment Comment text
* @param Title|null $title An optional title object used to links to sections
* @param bool $local Whether section links should refer to local page
- * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap.
+ * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
+ * as used by WikiMap.
*
* @return string Formatted comment (wikitext)
*/
- private static function formatAutocomments( $comment, $title = null, $local = false, $wikiId = null ) {
+ private static function formatAutocomments(
+ $comment, $title = null, $local = false, $wikiId = null
+ ) {
// @todo $append here is something of a hack to preserve the status
// quo. Someone who knows more about bidi and such should decide
// (1) what sane rendering even *is* for an LTR edit summary on an RTL
$auto = $match[2];
$post = $match[3] !== '';
$comment = null;
- Hooks::run( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local, $wikiId ) );
+
+ Hooks::run(
+ 'FormatAutocomments',
+ array( &$comment, $pre, $auto, $post, $title, $local, $wikiId )
+ );
+
if ( $comment === null ) {
$link = '';
if ( $title ) {
* is ignored
*
* @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
- * @param string $comment Text to format links in
+ * @param string $comment Text to format links in. WARNING! Since the output of this
+ * function is html, $comment must be sanitized for use as html. You probably want
+ * to pass $comment through Sanitizer::escapeHtmlAllowEntities() before calling
+ * this function.
* @param Title|null $title An optional title object used to links to sections
* @param bool $local Whether section links should refer to local page
- * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap.
+ * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
+ * as used by WikiMap.
*
* @return string
*/
if ( $target->getText() == '' && !$target->isExternal()
&& !$local && $title
) {
- $newTarget = clone ( $title );
+ $newTarget = clone $title;
$newTarget->setFragment( '#' . $target->getFragment() );
$target = $newTarget;
}
*
* @param Title $title
* @param string $text
- * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap.
+ * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
+ * as used by WikiMap.
* @param string|string[] $options See the $options parameter in Linker::link.
*
* @return string HTML link
*/
- public static function makeCommentLink( Title $title, $text, $wikiId = null, $options = array() ) {
+ public static function makeCommentLink(
+ Title $title, $text, $wikiId = null, $options = array()
+ ) {
if ( $wikiId !== null && !$title->isExternal() ) {
$link = Linker::makeExternalLink(
- WikiMap::getForeignURL( $wikiId, $title->getPrefixedText(), $title->getFragment() ),
- $text,
- /* escape = */ false // Already escaped
- );
+ WikiMap::getForeignURL(
+ $wikiId,
+ $title->getPrefixedText(),
+ $title->getFragment()
+ ),
+ $text,
+ /* escape = */ false // Already escaped
+ );
} else {
$link = Linker::link( $title, $text, array(), array(), $options );
}
* @param string $comment
* @param Title|null $title Title object (to generate link to section in autocomment) or null
* @param bool $local Whether section links should refer to local page
- * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to. For use with external changes.
+ * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to.
+ * For use with external changes.
*
* @return string
*/
- public static function commentBlock( $comment, $title = null, $local = false, $wikiId = null ) {
+ public static function commentBlock(
+ $comment, $title = null, $local = false, $wikiId = null
+ ) {
// '*' used to be the comment inserted by the software way back
// in antiquity in case none was provided, here for backwards
// compatibility, acc. to brion -ævar
* directly paste it in as the link (escaping needs to be done manually).
* Finally, if $more is a Message, call toString().
*
- * @param array $templates Array of templates from Article::getUsedTemplate or similar
+ * @param Title[] $templates Array of templates
* @param bool $preview Whether this is for a preview
* @param bool $section Whether this is for a section edit
* @param Title|Message|string|null $more An escaped link for "More..." of the templates
* @param string $name Id of the element, minus prefixes.
* @param string|null $options Null or the string 'withaccess' to add an access-
* key hint
+ * @param array $msgParams Parameters to pass to the message
+ *
* @return string Contents of the title attribute (which you must HTML-
* escape), or false for no title attribute
*/
- public static function titleAttrib( $name, $options = null ) {
-
- $message = wfMessage( "tooltip-$name" );
-
+ public static function titleAttrib( $name, $options = null, array $msgParams = array() ) {
+ $message = wfMessage( "tooltip-$name", $msgParams );
if ( !$message->exists() ) {
$tooltip = false;
} else {
/* Deprecated methods */
- /**
- * @deprecated since 1.16 Use link(); warnings since 1.21
- *
- * 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
- * call to this will result in a DB query.
- *
- * @param Title $nt The title object to make the link from, e.g. from Title::newFromText.
- * @param string $text Link text
- * @param string $query Optional query part
- * @param string $trail Optional trail. Alphabetic characters at the start of this string will
- * be included in the link text. Other characters will be appended after
- * the end of the link.
- * @param string $prefix Optional prefix. As trail, only before instead of after.
- * @return string
- */
- static function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- $query = wfCgiToArray( $query );
- list( $inside, $trail ) = self::splitTrail( $trail );
- if ( $text === '' ) {
- $text = self::linkText( $nt );
- }
-
- $ret = self::link( $nt, "$prefix$text$inside", array(), $query ) . $trail;
-
- return $ret;
- }
-
- /**
- * @deprecated since 1.16 Use link(); warnings since 1.21
- *
- * 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
- * pages.
- *
- * @param Title $title Title object of target page
- * @param string $text Text to replace the title
- * @param string $query Link target
- * @param string $trail Text after link
- * @param string $prefix Text before link text
- * @param string $aprops Extra attributes to the a-element
- * @param string $style Style to apply - if empty, use getInternalLinkAttributesObj instead
- * @return string The a-element
- */
- static function makeKnownLinkObj(
- $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = '', $style = ''
- ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- if ( $text == '' ) {
- $text = self::linkText( $title );
- }
- $attribs = Sanitizer::mergeAttributes(
- Sanitizer::decodeTagAttributes( $aprops ),
- Sanitizer::decodeTagAttributes( $style )
- );
- $query = wfCgiToArray( $query );
- list( $inside, $trail ) = self::splitTrail( $trail );
-
- $ret = self::link( $title, "$prefix$text$inside", $attribs, $query,
- array( 'known', 'noclasses' ) ) . $trail;
-
- return $ret;
- }
-
/**
* Returns the attributes for the tooltip and access key.
+ *
* @param string $name
+ * @param array $msgParams Params for constructing the message
+ *
* @return array
*/
- public static function tooltipAndAccesskeyAttribs( $name ) {
+ public static function tooltipAndAccesskeyAttribs( $name, array $msgParams = array() ) {
# @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(
- 'title' => self::titleAttrib( $name, 'withaccess' ),
+ 'title' => self::titleAttrib( $name, 'withaccess', $msgParams ),
'accesskey' => self::accesskey( $name )
);
if ( $attribs['title'] === false ) {