* despite $query not being used.
*
* @param $nt Title
+ * @param $html String [optional]
+ * @param $query String [optional]
+ * @param $trail String [optional]
+ * @param $prefix String [optional]
+ *
*
* @return string
*/
* @param $userName String: user name in database.
* @param $altUserName String: text to display instead of the user name (optional)
* @return String: HTML fragment
- * @since 1.19 Method exists for a long time. $displayText was added in 1.19.
+ * @since 1.19 Method exists for a long time. $altUserName was added in 1.19.
*/
public static function userLink( $userId, $userName, $altUserName = false ) {
if ( $userId == 0 ) {
wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
if ( $items ) {
- return ' <span class="mw-usertoollinks">' . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped() . '</span>';
+ return wfMessage( 'word-separator' )->plain()
+ . '<span class="mw-usertoollinks">'
+ . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
+ . '</span>';
} else {
return '';
}
} elseif ( $rev->userCan( Revision::DELETED_USER ) ) {
$userId = $rev->getUser( Revision::FOR_THIS_USER );
$userText = $rev->getUserText( Revision::FOR_THIS_USER );
- $link = self::userLink( $userId, $userText ) .
- ' ' . self::userToolLinks( $userId, $userText );
+ $link = self::userLink( $userId, $userText )
+ . wfMessage( 'word-separator' )->plain()
+ . self::userToolLinks( $userId, $userText );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
$pre = $match[1];
$auto = $match[2];
$post = $match[3];
- $link = '';
- if ( $title ) {
- $section = $auto;
-
- # Remove links that a user may have manually put in the autosummary
- # This could be improved by copying as much of Parser::stripSectionName as desired.
- $section = str_replace( '[[:', '', $section );
- $section = str_replace( '[[', '', $section );
- $section = str_replace( ']]', '', $section );
-
- $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
- if ( $local ) {
- $sectionTitle = Title::newFromText( '#' . $section );
- } else {
- $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
- $title->getDBkey(), $section );
+ $comment = null;
+ wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
+ if ( $comment === null ) {
+ $link = '';
+ if ( $title ) {
+ $section = $auto;
+
+ # Remove links that a user may have manually put in the autosummary
+ # This could be improved by copying as much of Parser::stripSectionName as desired.
+ $section = str_replace( '[[:', '', $section );
+ $section = str_replace( '[[', '', $section );
+ $section = str_replace( ']]', '', $section );
+
+ $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
+ if ( $local ) {
+ $sectionTitle = Title::newFromText( '#' . $section );
+ } else {
+ $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
+ $title->getDBkey(), $section );
+ }
+ if ( $sectionTitle ) {
+ $link = self::link( $sectionTitle,
+ $wgLang->getArrow(), array(), array(),
+ 'noclasses' );
+ } else {
+ $link = '';
+ }
}
- if ( $sectionTitle ) {
- $link = self::link( $sectionTitle,
- $wgLang->getArrow(), array(), array(),
- 'noclasses' );
- } else {
- $link = '';
+ if ( $pre ) {
+ # written summary $presep autocomment (summary /* section */)
+ $pre .= wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) );
}
+ if ( $post ) {
+ # autocomment $postsep written summary (/* section */ summary)
+ $auto .= wfMsgExt( 'colon-separator', array( 'escapenoentities', 'content' ) );
+ }
+ $auto = '<span class="autocomment">' . $auto . '</span>';
+ $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
}
- if ( $pre ) {
- # written summary $presep autocomment (summary /* section */)
- $pre .= wfMsgExt( 'autocomment-prefix', array( 'escapenoentities', 'content' ) );
- }
- if ( $post ) {
- # autocomment $postsep written summary (/* section */ summary)
- $auto .= wfMsgExt( 'colon-separator', array( 'escapenoentities', 'content' ) );
- }
- $auto = '<span class="autocomment">' . $auto . '</span>';
- $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
return $comment;
}
* other users.
*
* @param $rev Revision object
+ * @param $context IContextSource context to use or null for the main context.
* @return string
*/
- public static function generateRollback( $rev ) {
+ public static function generateRollback( $rev, IContextSource $context = null ) {
+ if ( $context === null ) {
+ $context = RequestContext::getMain();
+ }
+
return '<span class="mw-rollback-link">'
- . wfMessage( 'brackets' )->rawParams( self::buildRollbackLink( $rev ) )->plain()
+ . $context->msg( 'brackets' )->rawParams(
+ self::buildRollbackLink( $rev, $context ) )->plain()
. '</span>';
}
* Build a raw rollback link, useful for collections of "tool" links
*
* @param $rev Revision object
+ * @param $context IContextSource context to use or null for the main context.
* @return String: HTML fragment
*/
- public static function buildRollbackLink( $rev ) {
- global $wgRequest, $wgUser;
+ public static function buildRollbackLink( $rev, IContextSource $context = null ) {
+ if ( $context === null ) {
+ $context = RequestContext::getMain();
+ }
+
$title = $rev->getTitle();
$query = array(
'action' => 'rollback',
'from' => $rev->getUserText(),
- 'token' => $wgUser->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
+ 'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
);
- if ( $wgRequest->getBool( 'bot' ) ) {
+ if ( $context->getRequest()->getBool( 'bot' ) ) {
$query['bot'] = '1';
$query['hidediff'] = '1'; // bug 15999
}
return self::link(
$title,
- wfMsgHtml( 'rollbacklink' ),
- array( 'title' => wfMsg( 'tooltip-rollback' ) ),
+ $context->msg( 'rollbacklink' )->escaped(),
+ array( 'title' => $context->msg( 'tooltip-rollback' )->text() ),
$query,
array( 'known', 'noclasses' )
);
}
$outText .= "</div><ul>\n";
- usort( $templates, array( 'Title', 'compare' ) );
+ usort( $templates, 'Title::compare' );
foreach ( $templates as $titleObj ) {
$r = $titleObj->getRestrictions( 'edit' );
if ( in_array( 'sysop', $r ) ) {
* Creates a (show/hide) link for deleting revisions/log entries
*
* @param $query Array: query parameters to be passed to link()
- * @param $restricted Boolean: set to true to use a <strong> instead of a <span>
+ * @param $restricted Boolean: set to true to use a "<strong>" instead of a "<span>"
* @param $delete Boolean: set to true to use (show/hide) rather than (show)
*
- * @return String: HTML <a> link to Special:Revisiondelete, wrapped in a
+ * @return String: HTML "<a>" link to Special:Revisiondelete, wrapped in a
* span to allow for customization of appearance with CSS
*/
public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {