https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112444

Revision: 112444
Author:   jeroendedauw
Date:     2012-02-26 18:24:27 +0000 (Sun, 26 Feb 2012)
Log Message:
-----------
fixed filter on revision pages and added links for undo and restore actions

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/actions/EPHistoryAction.php
    trunk/extensions/EducationProgram/includes/EPRevisionPager.php

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-26 
17:19:11 UTC (rev 112443)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-26 
18:24:27 UTC (rev 112444)
@@ -235,6 +235,10 @@
        'ep-pager-withselected' => 'With selected',
        'ep-pager-delete-selected' => 'Delete',
 
+       // Revision pager
+       'ep-revision-undo' => 'undo',
+       'ep-revision-restore' => 'restore',
+
        // Org pager
        'eporgpager-header-name' => 'Name',
        'eporgpager-header-city' => 'City',

Modified: trunk/extensions/EducationProgram/actions/EPHistoryAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-26 17:19:11 UTC (rev 112443)
+++ trunk/extensions/EducationProgram/actions/EPHistoryAction.php       
2012-02-26 18:24:27 UTC (rev 112444)
@@ -16,7 +16,7 @@
 
        /**
         * @since 0.1
-        * @var DBTable
+        * @var EPPageTable
         */
        protected $table;
 
@@ -29,7 +29,7 @@
         * @param IContextSource $context
         * @param DBTable $table
         */
-       protected function __construct( Page $page, IContextSource $context = 
null, DBTable $table ) {
+       protected function __construct( Page $page, IContextSource $context = 
null, EPPageTable $table ) {
                $this->table = $table;
                parent::__construct( $page, $context );
        }
@@ -132,7 +132,7 @@
                                '</fieldset></form>'
                );
 
-               $pager = new EPRevisionPager( $this->getContext(), $conditions 
);
+               $pager = new EPRevisionPager( $this->getContext(), 
$this->table, $conditions );
 
                if ( $pager->getNumRows() ) {
                        $out->addHTML(

Modified: trunk/extensions/EducationProgram/includes/EPRevisionPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPRevisionPager.php      
2012-02-26 17:19:11 UTC (rev 112443)
+++ trunk/extensions/EducationProgram/includes/EPRevisionPager.php      
2012-02-26 18:24:27 UTC (rev 112444)
@@ -19,7 +19,15 @@
         * @var IContextSource
         */
        protected $context;
+       
+       /**
+        * @since 0.1
+        * @var EPPageTable
+        */
+       protected $table;
 
+       protected $rowNr = 0;
+       
        /**
         * Constructor.
         *
@@ -27,18 +35,23 @@
         * @param string $className
         * @param array $conds
         */
-       public function __construct( IContextSource $context, array $conds = 
array() ) {
-               $this->conds = $conds;
-               $this->context = $context;
-
-               $this->mDefaultDirection = true;
-
+       public function __construct( IContextSource $context, EPPageTable 
$table, array $conds = array() ) {
                if ( method_exists( 'ReverseChronologicalPager', 'getUser' ) ) {
                        parent::__construct( $context );
                }
                else {
                        parent::__construct();
                }
+               
+               $this->conds = $conds;
+               $this->context = $context;
+               $this->table = $table;
+
+               $this->mDefaultDirection = true;
+               $this->getDateCond( 
+                       $context->getRequest()->getText( 'year', '' ),
+                       $context->getRequest()->getText( 'month', '' ) 
+               );
        }
 
        /**
@@ -66,7 +79,7 @@
 
                $html .= $object->getLink(
                        'view',
-                       $this->getLanguage()->timeanddate( $revision->getField( 
'time' ) ),
+                       htmlspecialchars( $this->getLanguage()->timeanddate( 
$revision->getField( 'time' ) ) ),
                        array(),
                        array( 'revid' => $revision->getId() )
                );
@@ -93,7 +106,32 @@
                                '(' . $this->getOutput()->parseInline( 
$revision->getField( 'comment' ) ) . ')'
                        );
                }
+               
+               if ( $this->getUser()->isAllowed( $this->table->getEditRight() 
) ) {
+                       $actionLinks = array();
+                       
+                       if ( $this->mOffset !== '' || $this->rowNr < 
$this->mResult->numRows() - 1 ) {
+                               $actionLinks[] = $object->getLink(
+                                       'undo',
+                                       wfMsgHtml( 'ep-revision-undo' ),
+                                       array(),
+                                       array( 'revid' => $revision->getId() )
+                               );
+                       }
+                       
+                       $actionLinks[] = $object->getLink(
+                               'restore',
+                               wfMsgHtml( 'ep-revision-restore' ),
+                               array(),
+                               array( 'revid' => $revision->getId() )
+                       );
+                       
+                       $html .= '&#160;.&#160;.&#160;';
+                       $html .= '(' .  $this->getLanguage()->pipeList( 
$actionLinks ) . ')';
+               }
 
+               $this->rowNr++;
+               
                return '<li>' . $html . '</li>';
        }
 
@@ -118,10 +156,12 @@
         * @return Array
         */
        function getQueryInfo() {
+               $table = EPRevisions::singleton();
                return array(
-                       'tables' => EPRevisions::singleton()->getDBTable(),
-                       'fields' => 
EPRevisions::singleton()->getPrefixedFields( 
EPRevisions::singleton()->getFieldNames() ),
-                       'conds' => EPRevisions::singleton()->getPrefixedValues( 
$this->conds )
+                       'tables' => $table->getDBTable(),
+                       'fields' => $table->getPrefixedFields( 
$table->getFieldNames() ),
+                       'conds' => $table->getPrefixedValues( $this->conds ),
+                       'options' => array( 'USE INDEX' => array( 
$table->getDBTable() => $table->getPrefixedField( 'time' ) ) ),
                );
        }
 
@@ -138,7 +178,7 @@
         * @return string|Array
         */
        function getIndexField() {
-               return EPRevisions::singleton()->getPrefixedField( 'id' );
+               return EPRevisions::singleton()->getPrefixedField( 'time' );
        }
 
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to