*/
private static function fnamePart( $url ) {
$basename = strrchr( $url, '/' );
- if ( false === $basename ) {
+ if ( $basename === false ) {
$basename = $url;
} else {
$basename = substr( $basename, 1 );
$prefix = $postfix = '';
- if ( 'center' == $frameParams['align'] ) {
+ if ( $frameParams['align'] == 'center' ) {
$prefix = '<div class="center">';
$postfix = '</div>';
$frameParams['align'] = 'none';
* @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
* and Linker::TOOL_LINKS_EMAIL).
* @param int|null $edits User edit count (optional, for performance)
+ * @param bool $useParentheses (optional) Wrap comments in parentheses where needed
* @return string HTML fragment
*/
public static function userToolLinks(
- $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
+ $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null,
+ $useParentheses = true
) {
global $wgUser, $wgDisableAnonTalk, $wgLang;
- $talkable = !( $wgDisableAnonTalk && 0 == $userId );
+ $talkable = !( $wgDisableAnonTalk && $userId == 0 );
$blockable = !( $flags & self::TOOL_LINKS_NOBLOCK );
$addEmailLink = $flags & self::TOOL_LINKS_EMAIL && $userId;
Hooks::run( 'UserToolLinksEdit', [ $userId, $userText, &$items ] );
- if ( $items ) {
+ if ( !$items ) {
+ return '';
+ }
+
+ if ( $useParentheses ) {
return wfMessage( 'word-separator' )->escaped()
. '<span class="mw-usertoollinks">'
. wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
. '</span>';
- } else {
- return '';
}
+
+ $tools = [];
+ foreach ( $items as $tool ) {
+ $tools[] = Html::rawElement( 'span', [], $tool );
+ }
+ return ' <span class="mw-usertoollinks mw-changeslist-links">' .
+ implode( ' ', $tools ) . '</span>';
}
/**
);
if ( $comment === null ) {
- $link = '';
if ( $title ) {
$section = $auto;
# Remove links that a user may have manually put in the autosummary
$section = str_replace( '[[', '', $section );
$section = str_replace( ']]', '', $section );
+ // We don't want any links in the auto text to be linked, but we still
+ // want to show any [[ ]]
+ $sectionText = str_replace( '[[', '[[', $auto );
+
$section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
if ( $local ) {
$sectionTitle = Title::makeTitleSafe( NS_MAIN, '', $section );
$title->getDBkey(), $section );
}
if ( $sectionTitle ) {
- $link = Linker::makeCommentLink(
- $sectionTitle, $wgLang->getArrow() . $auto, $wikiId, 'noclasses'
+ $auto = Linker::makeCommentLink(
+ $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
+ $wikiId, 'noclasses'
);
- $auto = '';
- } else {
- $link = '';
}
}
if ( $pre ) {
$auto = '<span dir="auto"><span class="autocomment">' . $auto . '</span>';
$append .= '</span>';
}
- $comment = $pre . $link . $wgLang->getDirMark() . $auto;
+ $comment = $pre . $auto;
}
return $comment;
},
// compatibility, acc. to brion -ævar
if ( $comment == '' || $comment == '*' ) {
return '';
+ }
+ $formatted = self::formatComment( $comment, $title, $local, $wikiId );
+ if ( $useParentheses ) {
+ $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped();
+ $classNames = 'comment';
} else {
- $formatted = self::formatComment( $comment, $title, $local, $wikiId );
- if ( $useParentheses ) {
- $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped();
- $classNames = 'comment';
- } else {
- $classNames = 'comment comment--without-parentheses';
- }
- return " <span class=\"$classNames\">$formatted</span>";
+ $classNames = 'comment comment--without-parentheses';
}
+ return " <span class=\"$classNames\">$formatted</span>";
}
/**
*
* @since 1.16.3
* @param string $toc Html of the Table Of Contents
- * @param string|Language|bool $lang Language for the toc title, defaults to user language
+ * @param string|Language|bool|null $lang Language for the toc title, defaults to user language.
+ * The types string and bool are deprecated.
* @return string Full html of the TOC
*/
- public static function tocList( $toc, $lang = false ) {
- $lang = wfGetLangObj( $lang );
+ public static function tocList( $toc, $lang = null ) {
+ global $wgLang;
+ $lang = $lang ?? $wgLang;
+ if ( !is_object( $lang ) ) {
+ wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' );
+ $lang = wfGetLangObj( $lang );
+ }
+
$title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
return '<div id="toc" class="toc">'
*
* @since 1.16.3. $lang added in 1.17
* @param array $tree Return value of ParserOutput::getSections()
- * @param string|Language|bool $lang Language for the toc title, defaults to user language
+ * @param string|Language|bool|null $lang Language for the toc title, defaults to user language.
+ * The types string and bool are deprecated.
* @return string HTML fragment
*/
- public static function generateTOC( $tree, $lang = false ) {
+ public static function generateTOC( $tree, $lang = null ) {
$toc = '';
$lastLevel = 0;
foreach ( $tree as $section ) {
}
}
- /**
- * @deprecated since 1.28, use TemplatesOnThisPageFormatter directly
- *
- * Returns HTML for the "templates used on this page" list.
- *
- * Make an HTML list of templates, and then add a "More..." link at
- * the bottom. If $more is null, do not add a "More..." link. If $more
- * is a Title, make a link to that title and use it. If $more is a string,
- * directly paste it in as the link (escaping needs to be done manually).
- * Finally, if $more is a Message, call toString().
- *
- * @since 1.16.3. $more added in 1.21
- * @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
- * @return string HTML output
- */
- public static function formatTemplates( $templates, $preview = false,
- $section = false, $more = null
- ) {
- wfDeprecated( __METHOD__, '1.28' );
-
- $type = false;
- if ( $preview ) {
- $type = 'preview';
- } elseif ( $section ) {
- $type = 'section';
- }
-
- if ( $more instanceof Message ) {
- $more = $more->toString();
- }
-
- $formatter = new TemplatesOnThisPageFormatter(
- RequestContext::getMain(),
- MediaWikiServices::getInstance()->getLinkRenderer()
- );
- return $formatter->format( $templates, $type, $more );
- }
-
/**
* Returns HTML for the "hidden categories on this page" list.
*
return $outText;
}
- /**
- * @deprecated since 1.28, use Language::formatSize() directly
- *
- * Format a size in bytes for output, using an appropriate
- * unit (B, KB, MB or GB) according to the magnitude in question
- *
- * @since 1.16.3
- * @param int $size Size to format
- * @return string
- */
- public static function formatSize( $size ) {
- wfDeprecated( __METHOD__, '1.28' );
-
- global $wgLang;
- return htmlspecialchars( $wgLang->formatSize( $size ) );
- }
-
/**
* Given the id of an interface element, constructs the appropriate title
* attribute from the system messages. (Note, this is usually the id but
if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
return self::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
+ }
+ if ( $rev->getId() ) {
+ // RevDelete links using revision ID are stable across
+ // page deletion and undeletion; use when possible.
+ $query = [
+ 'type' => 'revision',
+ 'target' => $title->getPrefixedDBkey(),
+ 'ids' => $rev->getId()
+ ];
} else {
- if ( $rev->getId() ) {
- // RevDelete links using revision ID are stable across
- // page deletion and undeletion; use when possible.
- $query = [
- 'type' => 'revision',
- 'target' => $title->getPrefixedDBkey(),
- 'ids' => $rev->getId()
- ];
- } else {
- // Older deleted entries didn't save a revision ID.
- // We have to refer to these by timestamp, ick!
- $query = [
- 'type' => 'archive',
- 'target' => $title->getPrefixedDBkey(),
- 'ids' => $rev->getTimestamp()
- ];
- }
- return self::revDeleteLink( $query,
- $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
+ // Older deleted entries didn't save a revision ID.
+ // We have to refer to these by timestamp, ick!
+ $query = [
+ 'type' => 'archive',
+ 'target' => $title->getPrefixedDBkey(),
+ 'ids' => $rev->getTimestamp()
+ ];
}
+ return self::revDeleteLink( $query,
+ $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
}
/**