'
+ '
'
. '' . $title . "\n"
. $toc
- . "\n\n";
+ . "\n |
\n";
}
/**
@@ -1498,17 +1517,17 @@ class Linker {
* a space and ending with '>'
* This *must* be at least '>' for no attribs
* @param $anchor String: the anchor to give the headline (the bit after the #)
- * @param $text String: the text of the header
+ * @param $html String: html for the text of the header
* @param $link String: HTML to add for the section edit link
* @param $legacyAnchor Mixed: a second, optional anchor to give for
* backward compatibility (false to omit)
*
* @return String: HTML headline
*/
- public static function makeHeadline( $level, $attribs, $anchor, $text, $link, $legacyAnchor = false ) {
+ public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
$ret = "
$text"
+ . " $html"
. "";
if ( $legacyAnchor !== false ) {
$ret = "
$ret";
@@ -1547,7 +1566,7 @@ class Linker {
*
* @param $rev Revision object
*/
- static function generateRollback( $rev ) {
+ public static function generateRollback( $rev ) {
return '
['
. self::buildRollbackLink( $rev )
. ']';
@@ -1565,7 +1584,7 @@ class Linker {
$query = array(
'action' => 'rollback',
'from' => $rev->getUserText(),
- 'token' => $wgUser->editToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
+ 'token' => $wgUser->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
);
if ( $wgRequest->getBool( 'bot' ) ) {
$query['bot'] = '1';
@@ -1697,10 +1716,6 @@ class Linker {
* escape), or false for no title attribute
*/
public static function titleAttrib( $name, $options = null ) {
- global $wgEnableTooltipsAndAccesskeys;
- if ( !$wgEnableTooltipsAndAccesskeys )
- return false;
-
wfProfileIn( __METHOD__ );
$message = wfMessage( "tooltip-$name" );
@@ -1768,6 +1783,49 @@ class Linker {
return self::$accesskeycache[$name] = $accesskey;
}
+ /**
+ * Get a revision-deletion link, or disabled link, or nothing, depending
+ * on user permissions & the settings on the revision.
+ *
+ * Will use forward-compatible revision ID in the Special:RevDelete link
+ * if possible, otherwise the timestamp-based ID which may break after
+ * undeletion.
+ *
+ * @param User $user
+ * @param Revision $rev
+ * @param Revision $title
+ * @return string HTML fragment
+ */
+ public static function getRevDeleteLink( User $user, Revision $rev, Title $title ) {
+ $canHide = $user->isAllowed( 'deleterevision' );
+ if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
+ if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
+ $revdlink = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
+ } else {
+ if ( $rev->getId() ) {
+ // RevDelete links using revision ID are stable across
+ // page deletion and undeletion; use when possible.
+ $query = array(
+ '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 = array(
+ 'type' => 'archive',
+ 'target' => $title->getPrefixedDBkey(),
+ 'ids' => $rev->getTimestamp()
+ );
+ }
+ return Linker::revDeleteLink( $query,
+ $rev->isDeleted( File::DELETED_RESTRICTED ), $canHide );
+ }
+ }
+ return '';
+ }
+
/**
* Creates a (show/hide) link for deleting revisions/log entries
*
@@ -1780,9 +1838,9 @@ class Linker {
*/
public static function revDeleteLink( $query = array(), $restricted = false, $delete = true ) {
$sp = SpecialPage::getTitleFor( 'Revisiondelete' );
- $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
+ $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
$tag = $restricted ? 'strong' : 'span';
- $link = self::link( $sp, $text, array(), $query, array( 'known', 'noclasses' ) );
+ $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), "($link)" );
}
@@ -1795,8 +1853,8 @@ class Linker {
* of appearance with CSS
*/
public static function revDeleteLinkDisabled( $delete = true ) {
- $text = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
- return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), "($text)" );
+ $html = $delete ? wfMsgHtml( 'rev-delundel' ) : wfMsgHtml( 'rev-showdeleted' );
+ return Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), "($html)" );
}
/* Deprecated methods */
@@ -1947,9 +2005,6 @@ class Linker {
* Returns the attributes for the tooltip and access key.
*/
public static function tooltipAndAccesskeyAttribs( $name ) {
- global $wgEnableTooltipsAndAccesskeys;
- if ( !$wgEnableTooltipsAndAccesskeys )
- return array();
# @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
# no attribute" instead of "output '' as value for attribute", this
# would be three lines.
@@ -1971,9 +2026,6 @@ class Linker {
* Returns raw bits of HTML, use titleAttrib()
*/
public static function tooltip( $name, $options = null ) {
- global $wgEnableTooltipsAndAccesskeys;
- if ( !$wgEnableTooltipsAndAccesskeys )
- return '';
# @todo FIXME: If Sanitizer::expandAttributes() treated "false" as "output
# no attribute" instead of "output '' as value for attribute", this
# would be two lines.
@@ -2003,4 +2055,3 @@ class DummyLinker {
return call_user_func_array( array( 'Linker', $fname ), $args );
}
}
-