*
* @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
/**
* 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, $linkText ) {
wfProfileIn( __METHOD__ );
/**
* 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() );
* 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 == '' ) {
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;
}
// 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 = '';
'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 );
}
+ /**
+ * @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
*/
wfProfileOut( __METHOD__ );
return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
- htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
+ "$prefix$text$inside</a>$trail";
} else {
wfProfileOut( __METHOD__ );
return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
}
} else {
+ wfProfileOut( __METHOD__ );
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
}
* @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 );
}
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 );
}
/**
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 ) ) {
* 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"
* escape), or false for no accesskey attribute
*/
public function accesskey( $name ) {
- wfProfileIn( __METHOD__ );
-
if ( isset( $this->accesskeycache[$name] ) ) {
return $this->accesskeycache[$name];
}
+ wfProfileIn( __METHOD__ );
$message = wfMessage( "accesskey-$name" );
*/
function makeLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfProfileIn( __METHOD__ );
-
$query = wfCgiToArray( $query );
list( $inside, $trail ) = Linker::splitTrail( $trail );
if ( $text === '' ) {
function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
if ( $colour != '' ) {
$style = $this->getInternalLinkAttributesObj( $nt, $text, $colour );
- } else $style = '';
+ } else {
+ $style = '';
+ }
return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
}
* @return String
*/
function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(), $framed = false,
- $thumb = false, $manualthumb = '', $valign = '', $time = false )
- {
+ $thumb = false, $manualthumb = '', $valign = '', $time = false ) {
$frameParams = array( 'alt' => $alt, 'caption' => $label );
if ( $align ) {
$frameParams['align'] = $align;