Index: trunk/extensions/SelectionSifter/models/Log.php |
— | — | @@ -21,18 +21,4 @@ |
22 | 22 | __METHOD__ |
23 | 23 | ); |
24 | 24 | } |
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 | | - } |
39 | 25 | } |
Index: trunk/extensions/SelectionSifter/SelectionSifter.i18n.php |
— | — | @@ -14,11 +14,16 @@ |
15 | 15 | * @author Yuvi Panda |
16 | 16 | */ |
17 | 17 | $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' |
24 | 29 | ); |
25 | 30 | |
Index: trunk/extensions/SelectionSifter/SpecialAssessmentLog.php |
— | — | @@ -18,12 +18,98 @@ |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function execute( $par ) { |
22 | | - global $wgOut, $wgRequest; |
| 22 | + $out = $this->getOutput(); |
| 23 | + $request = $this->getRequest(); |
23 | 24 | |
24 | | - $entries = AssessmentChangeLog::getLogs(); |
| 25 | + $this->setHeaders(); |
| 26 | + $this->outputHeader(); |
| 27 | + $out->setPageTitle( $this->msg( 'ss-assessment-log' ) ); |
25 | 28 | |
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 | + ); |
27 | 36 | |
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 | + } |
29 | 68 | } |
30 | 69 | } |
| 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 | +} |