Branch merge of change-tagging branch with trunk
[lhc/web/wiklou.git] / includes / PageHistory.php
index 27880c6..0441cf2 100644 (file)
@@ -112,6 +112,7 @@ class PageHistory {
                 */
                $year = $wgRequest->getInt( 'year' );
                $month = $wgRequest->getInt( 'month' );
+               $tagFilter = $wgRequest->getVal( 'tagfilter' );
 
                $action = htmlspecialchars( $wgScript );
                $wgOut->addHTML(
@@ -120,6 +121,7 @@ class PageHistory {
                        Xml::hidden( 'title', $this->mTitle->getPrefixedDBKey() ) . "\n" .
                        Xml::hidden( 'action', 'history' ) . "\n" .
                        $this->getDateMenu( $year, $month ) . ' ' .
+                       implode( ' ', ChangeTags::buildTagFilterSelector( $tagFilter ) ) . ' ' .
                        Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
                        '</fieldset></form>'
                );
@@ -129,7 +131,7 @@ class PageHistory {
                /**
                 * Do the list
                 */
-               $pager = new PageHistoryPager( $this, $year, $month );
+               $pager = new PageHistoryPager( $this, $year, $month, $tagFilter );
                $this->linesonpage = $pager->getNumRows();
                $wgOut->addHTML(
                        $pager->getNavigationBar() .
@@ -287,27 +289,24 @@ class PageHistory {
                $lastlink = $this->lastLink( $rev, $next, $counter );
                $arbitrary = $this->diffButtons( $rev, $firstInList, $counter );
                $link = $this->revLink( $rev );
+               $classes = array();
 
                $s = "($curlink) ($lastlink) $arbitrary";
 
                if( $wgUser->isAllowed( 'deleterevision' ) ) {
-                       $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
                        if( $firstInList ) {
                                // We don't currently handle well changing the top revision's settings
-                               $del = $this->message['rev-delundel'];
+                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
                        } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
                                // If revision was hidden from sysops
-                               $del = $this->message['rev-delundel'];
+                               $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
                        } else {
-                               $del = $this->mSkin->makeKnownLinkObj( $revdel,
-                               $this->message['rev-delundel'],
-                                       'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) .
-                                       '&oldid=' . urlencode( $rev->getId() ) );
-                               // Bolden oversighted content
-                               if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) )
-                               $del = "<strong>$del</strong>";
+                               $query = array( 'target' => $this->mTitle->getPrefixedDbkey(),
+                                       'oldid' => $rev->getId()
+                               );
+                               $del = $this->mSkin->revDeleteLink( $query, $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
                        }
-                       $s .= " <tt>(<small>$del</small>)</tt> ";
+                       $s .= " $del ";
                }
 
                $s .= " $link";
@@ -359,9 +358,16 @@ class PageHistory {
                        $s .= ' (' . implode( ' | ', $tools ) . ')';
                }
 
+               # Tags
+               list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
+               $classes = array_merge( $classes, $newClasses );
+               $s .= " $tagSummary";
+
                wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s ) );
 
-               return "<li>$s</li>\n";
+               $classes = implode( ' ', $classes );
+
+               return "<li class=\"$classes\">$s</li>\n";
        }
 
        /**
@@ -593,20 +599,23 @@ class PageHistory {
 class PageHistoryPager extends ReverseChronologicalPager {
        public $mLastRow = false, $mPageHistory, $mTitle;
 
-       function __construct( $pageHistory, $year='', $month='' ) {
+       function __construct( $pageHistory, $year='', $month='', $tagFilter = '' ) {
                parent::__construct();
                $this->mPageHistory = $pageHistory;
                $this->mTitle =& $this->mPageHistory->mTitle;
+               $this->tagFilter = $tagFilter;
                $this->getDateCond( $year, $month );
        }
 
        function getQueryInfo() {
                $queryInfo = array(
                        'tables'  => array('revision'),
-                       'fields'  => Revision::selectFields(),
+                       'fields'  => array_merge( Revision::selectFields(), array('ts_tags') ),
                        'conds'   => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ),
-                       'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') )
+                       'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
+                       'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
                );
+               ChangeTags::modifyDisplayQuery( $queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $this->tagFilter );
                wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
                return $queryInfo;
        }