* replace use of deprecated makeLinkObj() by link() in core
[lhc/web/wiklou.git] / includes / PageHistory.php
index fde2167..923d47c 100644 (file)
@@ -67,7 +67,7 @@ class PageHistory {
         * @returns nothing
         */
        function history() {
-               global $wgOut, $wgRequest, $wgTitle, $wgScript;
+               global $wgOut, $wgRequest, $wgScript;
 
                /*
                 * Allow client caching.
@@ -153,33 +153,51 @@ class PageHistory {
         * @return string HTML output
         */
        function beginHistoryList() {
-               global $wgTitle, $wgScript, $wgEnableHtmlDiff;
+               global $wgUser, $wgScript, $wgEnableHtmlDiff;
                $this->lastdate = '';
                $s = wfMsgExt( 'histlegend', array( 'parse') );
-               $s .= Xml::openElement( 'form', array( 'action' => $wgScript, 'id' => 'mw-history-compare' ) );
-               $s .= Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() );
+               if( $this->linesonpage > 1 && $wgUser->isAllowed('deleterevision') ) {
+                       $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
+                       $s .= Xml::openElement( 'form',
+                               array(
+                                       'action' => $revdel->getLocalURL( array( 
+                                               'type' => 'revision',
+                                               'target' => $this->mTitle->getPrefixedDbKey()
+                                       ) ),
+                                       'method' => 'post', 
+                                       'id' => 'mw-history-revdeleteform',
+                                       'style'  => 'visibility:hidden;float:right;'
+                               )
+                       );
+                       $s .= Xml::hidden( 'ids', '', array('id'=>'revdel-oldid') );
+                       $s .= Xml::submitButton( wfMsg( 'showhideselectedversions' ) );
+                       $s .= Xml::closeElement( 'form' );
+               }
+               $s .= Xml::openElement( 'form', array( 'action' => $wgScript,
+                       'id' => 'mw-history-compare' ) );
+               $s .= Xml::hidden( 'title', $this->mTitle->getPrefixedDbKey() );
                if( $wgEnableHtmlDiff ) {
                        $s .= $this->submitButton( wfMsg( 'visualcomparison'),
                                array(
-                                               'name' => 'htmldiff',
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'name' => 'htmldiff',
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                        $s .= $this->submitButton( wfMsg( 'wikicodecomparison'),
                                array(
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                } else {
                        $s .= $this->submitButton( wfMsg( 'compareselectedversions'),
                                array(
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                }
@@ -198,25 +216,25 @@ class PageHistory {
                if( $wgEnableHtmlDiff ) {
                        $s .= $this->submitButton( wfMsg( 'visualcomparison'),
                                array(
-                                               'name' => 'htmldiff',
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'name' => 'htmldiff',
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                        $s .= $this->submitButton( wfMsg( 'wikicodecomparison'),
                                array(
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                } else {
                        $s .= $this->submitButton( wfMsg( 'compareselectedversions'),
                                array(
-                                               'class'     => 'historysubmit',
-                                               'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
-                                               'title'     => wfMsg( 'tooltip-compareselectedversions' ),
+                                       'class'     => 'historysubmit',
+                                       'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
+                                       'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                )
                        );
                }
@@ -268,15 +286,25 @@ class PageHistory {
                $s = "($curlink) ($lastlink) $arbitrary";
 
                if( $wgUser->isAllowed( 'deleterevision' ) ) {
+                       // Hide JS by default for non-JS browsing
+                       $hidden = array( 'style' => 'display:none' );
+                       // If revision was hidden from sysops
                        if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
-                               // If revision was hidden from sysops
-                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.
-                                       $this->message['rev-delundel'].')' );
+                               $del = Xml::check( 'deleterevisions', false,
+                                       $hidden + array('disabled' => 'disabled') );
+                               $del .= Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
+                                       '(' . $this->message['rev-delundel'] . ')' );
+                       // Otherwise, show the link...
                        } else {
-                               $query = array( 'target' => $this->mTitle->getPrefixedDbkey(),
-                                       'oldid' => $rev->getId()
-                               );
-                               $del = $this->mSkin->revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
+                               $jsCall = 'updateShowHideForm('.$rev->getId().',this.checked)';
+                               $del = Xml::check( 'showhiderevisions', false,
+                                       $hidden + array('onchange' => $jsCall) );
+                               $query = array(
+                                       'type' => 'revision',
+                                       'target' => $this->mTitle->getPrefixedDbkey(),
+                                       'ids' => $rev->getId() );
+                               $del .= $this->mSkin->revDeleteLink( $query,
+                                       $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
                        }
                        $s .= " $del ";
                }
@@ -297,19 +325,18 @@ class PageHistory {
                if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
                        $s .= ' <span class="updatedmarker">' .  wfMsgHtml( 'updatedmarker' ) . '</span>';
                }
-               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
-                       $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
-               }
 
                $tools = array();
 
                if( !is_null( $next ) && is_object( $next ) ) {
                        if( $latest && $this->mTitle->userCan( 'rollback' ) && $this->mTitle->userCan( 'edit' ) ) {
-                               $tools[] = '<span class="mw-rollback-link">'.$this->mSkin->buildRollbackLink( $rev ).'</span>';
+                               $tools[] = '<span class="mw-rollback-link">'.
+                                       $this->mSkin->buildRollbackLink( $rev ).'</span>';
                        }
 
-                       if( $this->mTitle->quickUserCan( 'edit' ) && !$rev->isDeleted( Revision::DELETED_TEXT ) &&
-                               !$next->rev_deleted & Revision::DELETED_TEXT )
+                       if( $this->mTitle->quickUserCan( 'edit' )
+                               && !$rev->isDeleted( Revision::DELETED_TEXT )
+                               && !$next->rev_deleted & Revision::DELETED_TEXT )
                        {
                                # Create undo tooltip for the first (=latest) line only
                                $undoTooltip = $latest
@@ -350,13 +377,11 @@ class PageHistory {
        function revLink( $rev ) {
                global $wgLang;
                $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
-               if( $rev->userCan( Revision::DELETED_TEXT ) ) {
+               $date = htmlspecialchars( $date );
+               if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
                        $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() );
                } else {
-                       $link = $date;
-               }
-               if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
-                       $link = "<span class=\"history-deleted\">$link</span>";
+                       $link = "<span class=\"history-deleted\">$date</span>";
                }
                return $link;
        }
@@ -535,9 +560,12 @@ class PageHistory {
 
                if( $rev->getComment() == '' ) {
                        global $wgContLang;
+                       $ts = $rev->getTimestamp();
                        $title = wfMsgForContent( 'history-feed-item-nocomment',
-                       $rev->getUserText(),
-                       $wgContLang->timeanddate( $rev->getTimestamp() ) );
+                               $rev->getUserText(),
+                               $wgContLang->timeanddate( $ts ),
+                               $wgContLang->date( $ts ),
+                               $wgContLang->time( $ts ) );
                } else {
                        $title = $rev->getUserText() . wfMsgForContent( 'colon-separator' ) . FeedItem::stripComment( $rev->getComment() );
                }