r105808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105807‎ | r105808 | r105809 >
Date:18:23, 11 December 2011
Author:yuvipanda
Status:deferred (Comments)
Tags:
Comment:
Added filtering and UI for AssessmentLog
Modified paths:
  • /trunk/extensions/SelectionSifter/SelectionSifter.i18n.php (modified) (history)
  • /trunk/extensions/SelectionSifter/SpecialAssessmentLog.php (modified) (history)
  • /trunk/extensions/SelectionSifter/models/Log.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SelectionSifter/models/Log.php
@@ -21,18 +21,4 @@
2222 __METHOD__
2323 );
2424 }
25 -
26 - public static function getLogs() {
27 - $dbr = wfGetDB( DB_SLAVE );
28 - $logs = $dbr->select(
29 - 'assessment_changelog',
30 - '*'
31 - );
32 - $entries = array();
33 - foreach( $logs as $entry ) {
34 - $entry = (array)$entry;
35 - array_push( $entries, $entry );
36 - }
37 - return $entries;
38 - }
3925 }
Index: trunk/extensions/SelectionSifter/SelectionSifter.i18n.php
@@ -14,11 +14,16 @@
1515 * @author Yuvi Panda
1616 */
1717 $messages['en'] = array(
18 - 'ss-project' => 'Project',
19 - 'ss-article' => 'Article',
20 - 'ss-quality' => 'Quality',
21 - 'ss-importance' => 'Importance',
22 - 'ss-filter-ratings' => 'Filter Ratings',
23 - 'ss-ratings-empty' => 'No articles found'
 18+ 'ss-project' => 'Project',
 19+ 'ss-article' => 'Article',
 20+ 'ss-quality' => 'Quality',
 21+ 'ss-importance' => 'Importance',
 22+ 'ss-filter-ratings' => 'Filter Ratings',
 23+ 'ss-ratings-empty' => 'No articles found',
 24+ 'ss-assessment-log' => 'Assessment Log',
 25+ 'ss-action' => 'Action',
 26+ 'ss-old' => 'Old Value',
 27+ 'ss-new' => 'New Value',
 28+ 'ss-assessment-log-empty' => 'No log entries found'
2429 );
2530
Index: trunk/extensions/SelectionSifter/SpecialAssessmentLog.php
@@ -18,12 +18,98 @@
1919 }
2020
2121 public function execute( $par ) {
22 - global $wgOut, $wgRequest;
 22+ $out = $this->getOutput();
 23+ $request = $this->getRequest();
2324
24 - $entries = AssessmentChangeLog::getLogs();
 25+ $this->setHeaders();
 26+ $this->outputHeader();
 27+ $out->setPageTitle( $this->msg( 'ss-assessment-log' ) );
2528
26 - $element = Html::element( 'div', array(), print_r( $entries, true) );
 29+ $fields = array(
 30+ 'Project' => array(
 31+ 'type' => 'text',
 32+ 'label-message' => 'ss-project',
 33+ 'tabindex' => '1'
 34+ )
 35+ );
2736
28 - $wgOut->addHTML( $element );
 37+ $project = $request->getText( 'wpProject' );
 38+
 39+ $filters = array_filter( array(
 40+ 'l_project' => $project
 41+ ) );
 42+
 43+ $form = new HTMLForm( $fields, $this->getContext() );
 44+ $form->setMethod( 'get' );
 45+ $form->prepareForm();
 46+
 47+ $form->displayForm( '' );
 48+
 49+ $pager = new AssessmentLogPager( $this, $filters );
 50+ if( $pager->getNumRows() ) {
 51+ $out->addHTML(
 52+ $pager->getNavigationBar() .
 53+ '<table>' .
 54+ Html::rawElement( 'tr', array(),
 55+ Html::element( 'td', array(), wfMessage( 'ss-action' ) ) .
 56+ Html::element( 'td', array(), wfMessage( 'ss-old' ) ) .
 57+ Html::element( 'td', array(), wfMessage( 'ss-new' ) ) .
 58+ Html::element( 'td', array(), wfMessage( 'ss-article' ) ) .
 59+ Html::element( 'td', array(), wfMessage( 'ss-project' ) )
 60+ ) .
 61+ $pager->getBody() .
 62+ '</table>' .
 63+ $pager->getNavigationBar()
 64+ );
 65+ } else {
 66+ $out->addWikiMsg( 'ss-assessment-log-empty' );
 67+ }
2968 }
3069 }
 70+
 71+class AssessmentLogPager extends ReverseChronologicalPager {
 72+
 73+ function __construct( $page, $conds ) {
 74+ $this->page = $page;
 75+ $this->conds = $conds;
 76+ parent::__construct( $page->getContext() );
 77+ }
 78+
 79+ function getQueryInfo() {
 80+ return array(
 81+ 'tables' => array( 'assessment_changelog' ),
 82+ 'fields' => array(
 83+ 'l_project',
 84+ 'l_namespace',
 85+ 'l_article',
 86+ 'l_action',
 87+ 'l_timestamp',
 88+ 'l_old',
 89+ 'l_new',
 90+ 'l_revision_timestamp'
 91+ ),
 92+ 'conds' => $this->conds
 93+ );
 94+ }
 95+
 96+ function getIndexField() {
 97+ return 'l_timestamp';
 98+ }
 99+
 100+ function formatRow( $row ) {
 101+ $title = Title::makeTitleSafe( $row->l_namespace, $row->l_article );
 102+ $project_title = Title::newFromText( $row->l_project );
 103+ return Html::rawElement( 'tr', array(),
 104+ Html::element( 'td', array(), $row->l_action ) .
 105+ Html::element( 'td', array(), $row->l_old ) .
 106+ Html::element( 'td', array(), $row->l_new ) .
 107+ Html::rawElement( 'td', array(),
 108+ Linker::linkKnown( $title, htmlspecialchars( $title->getText() ) )
 109+ ) .
 110+ Html::rawElement( 'td', array(),
 111+ Linker::linkKnown( $project_title, htmlspecialchars( $project_title->getText() ) )
 112+ ) .
 113+ Html::element( 'td', array(), $row->l_timestamp )
 114+ );
 115+ }
 116+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r105814Fixed tabs and spacing (hopefully)yuvipanda18:50, 11 December 2011

Comments

#Comment by Johnduhart (talk | contribs)   18:25, 11 December 2011

Spaces instead of tabs.

#Comment by YuviPanda (talk | contribs)   18:53, 11 December 2011

Fixed in r105814

Status & tagging log