r111845 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111844‎ | r111845 | r111846 >
Date:21:19, 18 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on article table
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticle.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.articletable.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -432,6 +432,20 @@
433433 'jquery.ui.button',
434434 'jquery.ui.dialog',
435435 ),
 436+ 'messages' => array(
 437+ 'ep-articletable-addreviwer-title',
 438+ 'ep-articletable-addreviwer-button',
 439+ 'ep-articletable-addreviwer-cancel',
 440+ 'ep-articletable-addreviwer-text',
 441+
 442+ 'ep-articletable-remreviwer-title',
 443+ 'ep-articletable-remreviwer-button',
 444+ 'ep-articletable-remreviwer-cancel',
 445+ 'ep-articletable-remreviwer-text',
 446+ 'ep-articletable-remreviwer-title-self',
 447+ 'ep-articletable-remreviwer-button-self',
 448+ 'ep-articletable-remreviwer-text-self',
 449+ ),
436450 );
437451
438452 $wgResourceModules['ep.addorg'] = $moduleTemplate + array(
Index: trunk/extensions/EducationProgram/includes/EPArticle.php
@@ -91,9 +91,8 @@
9292 public function canBecomeReviewer( User $user ) {
9393 if ( !array_key_exists( $user->getId(), $this->canBecomeReviwer ) ) {
9494 $this->canBecomeReviwer[$user->getId()] = $this->getUser()->isAllowed( 'ep-bereviewer' )
95 - //&& $this->getUser()->getId() !== $student->getField( 'user_id' )
96 - //&& !in_array( $this->getUser()->getId(), $article->getField( 'reviewers' ) )
97 - ;
 95+ && $this->getUser()->getId() !== $user->getId()
 96+ && !in_array( $this->getUser()->getId(), $this->getField( 'reviewers' ) );
9897 }
9998
10099 return $this->canBecomeReviwer[$user->getId()];
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -271,7 +271,7 @@
272272 * @since 0.1
273273 *
274274 * @param EPArticle $article
275 - * @param integer $userId
 275+ * @param integer $userId User id of the reviewer
276276 *
277277 * @return string
278278 */
@@ -292,6 +292,10 @@
293293 'href' => '#',
294294 'data-user-id' => $userId,
295295 'data-article-id' => $article->getId(),
 296+ 'data-article-name' => $article->getTitle()->getFullText(),
 297+ 'data-student-name' => $article->getUser()->getName(),
 298+ 'data-reviewer-name' => $user->getName(),
 299+ 'data-reviewer-id' => $user->getId(),
296300 'class' => 'ep-rem-reviewer',
297301 ),
298302 wfMsg( 'ep-artciles-remreviewer' )
@@ -307,6 +311,8 @@
308312 'class' => 'ep-rem-reviewer-self',
309313 'disabled' => 'disabled',
310314 'data-article-id' => $article->getId(),
 315+ 'data-article-name' => $article->getField( 'name' ),
 316+ 'data-student-name' => $article->getUser()->getName(),
311317 ),
312318 wfMsg( 'ep-artciles-remreviewer-self' )
313319 );
@@ -380,6 +386,8 @@
381387 'class' => 'ep-become-reviewer',
382388 'disabled' => 'disabled',
383389 'data-article-id' => $article->getId(),
 390+ 'data-article-name' => $article->getTitle()->getFullText(),
 391+ 'data-user-name' => $article->getUser()->getName(),
384392 ),
385393 wfMsg( 'ep-artciles-becomereviewer' )
386394 );
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -271,18 +271,32 @@
272272 'epstudentpager-yes' => 'Yes',
273273 'epstudentpager-no' => 'No',
274274
275 - // Student article pager
 275+ // Article table
276276 'epstudentpager-header-student' => 'Student',
277277 'epstudentpager-header-articles' => 'Articles',
278278 'epstudentpager-header-reviewers' => 'Reviewers',
279279 'ep-artciles-remstudent' => 'remove from course',
280 - 'ep-artciles-remreviewer-self' => 'Remove myself as reviewer',
281 - 'ep-artciles-remreviewer' => 'remove as reviewer',
 280+ 'ep-artciles-remreviewer-self' => 'Remove myself as {{GENDER:$1|reviewer}}',
 281+ 'ep-artciles-remreviewer' => 'remove as {{GENDER:$1|reviewer}}',
282282 'ep-artciles-remarticle' => 'remove article',
283283 'ep-artciles-addarticle-text' => 'Add an article:',
284284 'ep-artciles-addarticle-button' => 'Add article',
285 - 'ep-artciles-becomereviewer' => 'Add myself as reviewer',
 285+ 'ep-artciles-becomereviewer' => 'Add myself as {{GENDER:$1|reviewer}}',
286286
 287+ // ep.articletable
 288+ 'ep-articletable-addreviwer-title' => 'Become {{GENDER:$1|reviewer}}',
 289+ 'ep-articletable-addreviwer-button' => 'Become {{GENDER:$1|reviewer}}',
 290+ 'ep-articletable-addreviwer-cancel' => 'Cancel',
 291+ 'ep-articletable-addreviwer-text' => 'You are about to enlist yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
 292+
 293+ 'ep-articletable-remreviwer-title' => 'Remove $1 as {{GENDER:$1|reviewer}}',
 294+ 'ep-articletable-remreviwer-title-self' => 'Remove yourself as {{GENDER:$1|reviewer}}',
 295+ 'ep-articletable-remreviwer-button' => 'Remove {{GENDER:$1|reviewer}}',
 296+ 'ep-articletable-remreviwer-button-self' => 'Remove yourself',
 297+ 'ep-articletable-remreviwer-cancel' => 'Cancel',
 298+ 'ep-articletable-remreviwer-text-self' => 'You are about to remove yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
 299+ 'ep-articletable-remreviwer-text' => 'You are about to remove $4 as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
 300+
287301 // Article pager
288302 'ep-articles-noresults' => 'There are no articles to list.',
289303
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js
@@ -9,16 +9,39 @@
1010 (function( $, ep ) {
1111
1212 function addReviewer() {
13 - $dialog = $( '<div>' ).html( '' ).dialog( {
14 - 'title': ep.msg( 'ep-articletable-addreviwer-title' ),
 13+ var $this = $( this );
 14+
 15+ var $form = $( '<form>' ).attr( {
 16+ 'method': 'post',
 17+ 'action': window.location
 18+ } ).msg(
 19+ 'ep-articletable-addreviwer-text',
 20+ mw.user.name,
 21+ $( '<b>' ).text( $this.attr( 'data-article-name' ) ),
 22+ $( '<b>' ).text( $this.attr( 'data-user-name' ) )
 23+ );
 24+
 25+ $form.append( $( '<input>' ).attr( {
 26+ 'type': 'hidden',
 27+ 'name': 'action',
 28+ 'value': 'epaddreviewer'
 29+ } ) );
 30+
 31+ $form.append( $( '<input>' ).attr( {
 32+ 'type': 'hidden',
 33+ 'name': 'article-id',
 34+ 'value': $this.attr( 'data-article-id' )
 35+ } ) );
 36+
 37+ var $dialog = $( '<div>' ).html( '' ).dialog( {
 38+ 'title': ep.msg('ep-articletable-addreviwer-title', mw.user.name ),
1539 'minWidth': 550,
1640 'buttons': [
1741 {
18 - 'text': ep.msg( 'ep-articletable-addreviwer-button' ),
 42+ 'text': ep.msg( 'ep-articletable-addreviwer-button', mw.user.name ),
1943 'id': 'ep-addreviwer-button',
2044 'click': function() {
21 - alert( 'submit' );
22 - // TODO
 45+ $form.submit();
2346 }
2447 },
2548 {
@@ -30,6 +53,8 @@
3154 }
3255 ]
3356 } );
 57+
 58+ $dialog.append( $form );
3459 }
3560
3661 function addArticle() {
@@ -45,7 +70,62 @@
4671 }
4772
4873 function removeReviewer() {
49 - // TODO
 74+ var $this = $( this ),
 75+ isSelf = $this.attr( 'data-reviewer-name' ) === undefined,
 76+ selfSuffix = isSelf ? '-self' : '',
 77+ reviewerName = isSelf ? mw.user.name : $this.attr( 'data-reviewer-name' );
 78+
 79+ var $form = $( '<form>' ).attr( {
 80+ 'method': 'post',
 81+ 'action': window.location
 82+ } ).msg(
 83+ 'ep-articletable-remreviwer-text' + selfSuffix,
 84+ reviewerName,
 85+ $( '<b>' ).text( $this.attr( 'data-article-name' ) ),
 86+ $( '<b>' ).text( $this.attr( 'data-student-name' ) ),
 87+ $( '<b>' ).text( reviewerName )
 88+ );
 89+
 90+ $form.append( $( '<input>' ).attr( {
 91+ 'type': 'hidden',
 92+ 'name': 'action',
 93+ 'value': 'epremreviewer'
 94+ } ) );
 95+
 96+ $form.append( $( '<input>' ).attr( {
 97+ 'type': 'hidden',
 98+ 'name': 'article-id',
 99+ 'value': $this.attr( 'data-article-id' )
 100+ } ) );
 101+
 102+ $form.append( $( '<input>' ).attr( {
 103+ 'type': 'hidden',
 104+ 'name': 'user-id',
 105+ 'value': isSelf ? mw.user.id : $this.attr( 'data-reviewer-id' )
 106+ } ) );
 107+
 108+ var $dialog = $( '<div>' ).html( '' ).dialog( {
 109+ 'title': ep.msg('ep-articletable-remreviwer-title' + selfSuffix, reviewerName ),
 110+ 'minWidth': 550,
 111+ 'buttons': [
 112+ {
 113+ 'text': ep.msg( 'ep-articletable-remreviwer-button' + selfSuffix, reviewerName ),
 114+ 'id': 'ep-remreviwer-button',
 115+ 'click': function() {
 116+ $form.submit();
 117+ }
 118+ },
 119+ {
 120+ 'text': ep.msg( 'ep-articletable-remreviwer-cancel' ),
 121+ 'id': 'ep-remreviwer-cancel',
 122+ 'click': function() {
 123+ $dialog.dialog( 'close' );
 124+ }
 125+ }
 126+ ]
 127+ } );
 128+
 129+ $dialog.append( $form );
50130 }
51131
52132 $( document ).ready( function() {
@@ -54,7 +134,7 @@
55135
56136 $( '.ep-become-reviewer' ).click( addReviewer );
57137
58 - $( '.ep-rem-reviewer-self' ).click( removeReviewer );
 138+ $( '.ep-rem-reviewer, .ep-rem-reviewer-self' ).click( removeReviewer );
59139
60140 // TODO
61141 } );

Status & tagging log