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

Revision: 105808
Author:   yuvipanda
Date:     2011-12-11 18:23:08 +0000 (Sun, 11 Dec 2011)
Log Message:
-----------
Added filtering and UI for AssessmentLog

Modified Paths:
--------------
    trunk/extensions/SelectionSifter/SelectionSifter.i18n.php
    trunk/extensions/SelectionSifter/SpecialAssessmentLog.php
    trunk/extensions/SelectionSifter/models/Log.php

Modified: trunk/extensions/SelectionSifter/SelectionSifter.i18n.php
===================================================================
--- trunk/extensions/SelectionSifter/SelectionSifter.i18n.php   2011-12-11 
17:02:18 UTC (rev 105807)
+++ trunk/extensions/SelectionSifter/SelectionSifter.i18n.php   2011-12-11 
18:23:08 UTC (rev 105808)
@@ -14,11 +14,16 @@
  * @author Yuvi Panda
  */
 $messages['en'] = array(
-    'ss-project' => 'Project',
-    'ss-article' => 'Article',
-    'ss-quality' => 'Quality',
-    'ss-importance' => 'Importance',
-    'ss-filter-ratings' => 'Filter Ratings',
-    'ss-ratings-empty' => 'No articles found'
+       'ss-project' => 'Project',
+       'ss-article' => 'Article',
+       'ss-quality' => 'Quality',
+       'ss-importance' => 'Importance',
+       'ss-filter-ratings' => 'Filter Ratings',
+       'ss-ratings-empty' => 'No articles found',
+       'ss-assessment-log' => 'Assessment Log',
+       'ss-action' => 'Action',
+       'ss-old' => 'Old Value',
+       'ss-new' => 'New Value',
+       'ss-assessment-log-empty' => 'No log entries found'
 );
 

Modified: trunk/extensions/SelectionSifter/SpecialAssessmentLog.php
===================================================================
--- trunk/extensions/SelectionSifter/SpecialAssessmentLog.php   2011-12-11 
17:02:18 UTC (rev 105807)
+++ trunk/extensions/SelectionSifter/SpecialAssessmentLog.php   2011-12-11 
18:23:08 UTC (rev 105808)
@@ -18,12 +18,98 @@
        }
 
        public function execute( $par ) {
-        global $wgOut, $wgRequest;
+               $out = $this->getOutput();
+               $request = $this->getRequest();
 
-               $entries = AssessmentChangeLog::getLogs();
+               $this->setHeaders();
+               $this->outputHeader();
+               $out->setPageTitle( $this->msg( 'ss-assessment-log' ) );
 
-               $element = Html::element( 'div', array(), print_r( $entries, 
true) );
+        $fields = array(
+            'Project' => array(
+                'type' => 'text',
+                'label-message' => 'ss-project',
+                'tabindex' => '1'
+            )
+        );
 
-               $wgOut->addHTML( $element );
+        $project = $request->getText( 'wpProject' );
+               
+               $filters = array_filter( array(
+            'l_project' => $project
+               ) );
+
+        $form = new HTMLForm( $fields, $this->getContext() );
+        $form->setMethod( 'get' );
+        $form->prepareForm();
+
+        $form->displayForm( '' );
+
+               $pager = new AssessmentLogPager( $this, $filters );
+               if( $pager->getNumRows() ) {
+                       $out->addHTML( 
+                       $pager->getNavigationBar() . 
+                       '<table>' . 
+                               Html::rawElement( 'tr', array(), 
+                                       Html::element( 'td', array(), 
wfMessage( 'ss-action' ) ) .
+                                       Html::element( 'td', array(), 
wfMessage( 'ss-old' ) ) .
+                                       Html::element( 'td', array(), 
wfMessage( 'ss-new' ) ) .
+                                       Html::element( 'td', array(), 
wfMessage( 'ss-article' ) ) .
+                                       Html::element( 'td', array(), 
wfMessage( 'ss-project' ) )
+                               ) .
+                               $pager->getBody() .
+                               '</table>' .
+                               $pager->getNavigationBar()
+                       );
+               } else {
+                       $out->addWikiMsg( 'ss-assessment-log-empty' );
+               }
        }
 }
+
+class AssessmentLogPager extends ReverseChronologicalPager {
+
+       function __construct( $page, $conds ) {
+               $this->page = $page;
+               $this->conds = $conds;
+               parent::__construct( $page->getContext() );
+       }
+       
+       function getQueryInfo() {
+               return array(
+                       'tables' => array( 'assessment_changelog' ),
+                       'fields' => array(
+                               'l_project',
+                               'l_namespace',
+                               'l_article',
+                               'l_action',
+                               'l_timestamp',
+                               'l_old',
+                               'l_new',
+                               'l_revision_timestamp'
+                       ),
+                       'conds' => $this->conds 
+               );
+       }
+
+       function getIndexField() {
+               return 'l_timestamp';
+       }
+
+       function formatRow( $row ) {
+               $title = Title::makeTitleSafe( $row->l_namespace, 
$row->l_article );
+               $project_title = Title::newFromText( $row->l_project );
+               return Html::rawElement( 'tr', array(),
+                       Html::element( 'td', array(), $row->l_action ) .
+                       Html::element( 'td', array(), $row->l_old ) .
+                       Html::element( 'td', array(), $row->l_new ) .
+                       Html::rawElement( 'td', array(), 
+                               Linker::linkKnown( $title, htmlspecialchars( 
$title->getText() ) ) 
+                       ) .
+                       Html::rawElement( 'td', array(), 
+                               Linker::linkKnown( $project_title, 
htmlspecialchars( $project_title->getText() ) ) 
+                       ) .
+                       Html::element( 'td', array(), $row->l_timestamp )
+               );
+       }
+}      

Modified: trunk/extensions/SelectionSifter/models/Log.php
===================================================================
--- trunk/extensions/SelectionSifter/models/Log.php     2011-12-11 17:02:18 UTC 
(rev 105807)
+++ trunk/extensions/SelectionSifter/models/Log.php     2011-12-11 18:23:08 UTC 
(rev 105808)
@@ -21,18 +21,4 @@
                        __METHOD__
                );
        }
-
-       public static function getLogs() {
-               $dbr = wfGetDB( DB_SLAVE );
-               $logs = $dbr->select(
-                       'assessment_changelog',
-                       '*'
-               );      
-               $entries = array();     
-               foreach( $logs as $entry ) {
-                       $entry = (array)$entry;
-                       array_push( $entries, $entry );
-               }
-               return $entries;
-       }
 }


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to