r111847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111846‎ | r111847 | r111848 >
Date:22:54, 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/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.articletable.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -32,6 +32,14 @@
3333 protected $articleConds;
3434
3535 /**
 36+ * Cached name of the course for which students are shown (if any).
 37+ *
 38+ * @since 0.1
 39+ * @var string|false
 40+ */
 41+ protected $courseName = false;
 42+
 43+ /**
3644 * Constructor.
3745 *
3846 * @param IContextSource $context
@@ -207,6 +215,8 @@
208216 'href' => '#',
209217 'data-user-id' => $userId,
210218 'data-course-id' => $this->articleConds['course_id'],
 219+ 'data-user-name' => $name,
 220+ 'data-course-name' => $this->getCourseName(),
211221 'class' => 'ep-rem-student',
212222 ),
213223 wfMsg( 'ep-artciles-remstudent' )
@@ -228,6 +238,22 @@
229239 }
230240
231241 /**
 242+ * Returns title of the course for which students are shown.
 243+ * Only call if there is a single course_id filter condition.
 244+ *
 245+ * @since 0.1
 246+ *
 247+ * @return string
 248+ */
 249+ protected function getCourseName() {
 250+ if ( $this->courseName === false ) {
 251+ $this->courseName = EPCourses::singleton()->selectFieldsRow( 'name', array( 'id' => $this->articleConds['course_id'] ) );
 252+ }
 253+
 254+ return $this->courseName;
 255+ }
 256+
 257+ /**
232258 * Returns the HTML for an article cell.
233259 *
234260 * @since 0.1
@@ -236,21 +262,28 @@
237263 * @param integer $rowSpan
238264 *
239265 * @return string
240 - */
 266+ */-
241267 protected function getArticleCell( EPArticle $article, $rowSpan ) {
242268 $html = Linker::link(
243269 $article->getTitle(),
244270 htmlspecialchars( $article->getTitle()->getFullText() )
245271 );
246272
 273+ $attr = array(
 274+ 'href' => '#',
 275+ 'data-article-id' => $article->getId(),
 276+ 'data-article-name' => $article->getTitle()->getFullText(),
 277+ 'class' => 'ep-rem-article',
 278+ );
 279+
 280+ if ( array_key_exists( 'course_id', $this->articleConds ) && is_integer( $this->articleConds['course_id'] ) ) {
 281+ $attr['data-course-name'] = $this->getCourseName();
 282+ }
 283+
247284 if ( $this->getUser()->getId() === $article->getField( 'user_id' ) ) {
248285 $html .= ' (' . Html::element(
249286 'a',
250 - array(
251 - 'href' => '#',
252 - 'data-article-id' => $article->getId(),
253 - 'class' => 'ep-rem-article',
254 - ),
 287+ $attr,
255288 wfMsg( 'ep-artciles-remarticle' )
256289 ) . ')';
257290 }
@@ -344,7 +377,7 @@
345378 'form',
346379 array(
347380 'method' => 'post',
348 - 'action' => $this->getTitle()->getLocalURL( array( 'action' => 'addarticle' ) ),
 381+ 'action' => $this->getTitle()->getLocalURL( array( 'action' => 'epaddarticle' ) ),
349382 )
350383 );
351384
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -297,6 +297,19 @@
298298 'ep-articletable-remreviwer-text-self' => 'You are about to remove yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
299299 'ep-articletable-remreviwer-text' => 'You are about to remove $4 as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
300300
 301+ 'ep-articletable-remstudent-title' => 'Remove {{GENDER:$1|student}} from course',
 302+ 'ep-articletable-remstudent-button' => 'Remove {{GENDER:$1|student}}',
 303+ 'ep-articletable-remstudent-cancel' => 'Cancel',
 304+ 'ep-articletable-remstudent-text' => 'You are about to remove $3 as {{GENDER:$1|student}} from course $2.
 305+
 306+This will permanently remove their associated articles and reviewers!',
 307+
 308+ 'ep-articletable-remarticle-title' => 'Remove article $1',
 309+ 'ep-articletable-remarticle-button' => 'Remove article',
 310+ 'ep-articletable-remarticle-cancel' => 'Cancel',
 311+ 'ep-articletable-remarticle-text' => 'You are about to remove article $1 from the list of articles you are working on.',
 312+ 'ep-articletable-remarticle-text-course' => 'You are about to remove article $1 from the list of articles you are working on as part of course $2.',
 313+
301314 // Article pager
302315 'ep-articles-noresults' => 'There are no articles to list.',
303316
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js
@@ -57,16 +57,108 @@
5858 $dialog.append( $form );
5959 }
6060
61 - function addArticle() {
62 - // TODO
63 - }
64 -
6561 function removeStudent() {
66 - // TODO
 62+ var $this = $( this );
 63+
 64+ var $form = $( '<form>' ).attr( {
 65+ 'method': 'post',
 66+ 'action': window.location
 67+ } ).msg(
 68+ 'ep-articletable-remstudent-text',
 69+ mw.user.name,
 70+ $( '<b>' ).text( $this.attr( 'data-course-name' ) ),
 71+ $( '<b>' ).text( $this.attr( 'data-user-name' ) )
 72+ );
 73+
 74+ $form.append( $( '<input>' ).attr( {
 75+ 'type': 'hidden',
 76+ 'name': 'action',
 77+ 'value': 'epremstudent'
 78+ } ) );
 79+
 80+ $form.append( $( '<input>' ).attr( {
 81+ 'type': 'hidden',
 82+ 'name': 'user-id',
 83+ 'value': $this.attr( 'data-user-id' )
 84+ } ) );
 85+
 86+ $form.append( $( '<input>' ).attr( {
 87+ 'type': 'hidden',
 88+ 'name': 'course-id',
 89+ 'value': $this.attr( 'data-course-id' )
 90+ } ) );
 91+
 92+ var $dialog = $( '<div>' ).html( '' ).dialog( {
 93+ 'title': ep.msg('ep-articletable-remstudent-title', mw.user.name ),
 94+ 'minWidth': 550,
 95+ 'buttons': [
 96+ {
 97+ 'text': ep.msg( 'ep-articletable-remstudent-button', mw.user.name ),
 98+ 'id': 'ep-remstudent-button',
 99+ 'click': function() {
 100+ $form.submit();
 101+ }
 102+ },
 103+ {
 104+ 'text': ep.msg( 'ep-articletable-remstudent-cancel' ),
 105+ 'id': 'ep-remstudent-cancel',
 106+ 'click': function() {
 107+ $dialog.dialog( 'close' );
 108+ }
 109+ }
 110+ ]
 111+ } );
 112+
 113+ $dialog.append( $form );
67114 }
68115
69116 function removeArticle() {
70 - // TODO
 117+ var $this = $( this ),
 118+ courseName = $this.attr( 'data-course-name' );
 119+
 120+ var $form = $( '<form>' ).attr( {
 121+ 'method': 'post',
 122+ 'action': window.location
 123+ } ).msg(
 124+ 'ep-articletable-remarticle-text' + ( courseName === undefined ? '' : '-course' ),
 125+ $( '<b>' ).text( $this.attr( 'data-article-name' ) ),
 126+ $( '<b>' ).text( courseName )
 127+ );
 128+
 129+ $form.append( $( '<input>' ).attr( {
 130+ 'type': 'hidden',
 131+ 'name': 'action',
 132+ 'value': 'epremarticle'
 133+ } ) );
 134+
 135+ $form.append( $( '<input>' ).attr( {
 136+ 'type': 'hidden',
 137+ 'name': 'article-id',
 138+ 'value': $this.attr( 'data-article-id' )
 139+ } ) );
 140+
 141+ var $dialog = $( '<div>' ).html( '' ).dialog( {
 142+ 'title': ep.msg( 'ep-articletable-remarticle-title', $this.attr( 'data-article-name' ) ),
 143+ 'minWidth': 550,
 144+ 'buttons': [
 145+ {
 146+ 'text': ep.msg( 'ep-articletable-remarticle-button' ),
 147+ 'id': 'ep-remarticle-button',
 148+ 'click': function() {
 149+ $form.submit();
 150+ }
 151+ },
 152+ {
 153+ 'text': ep.msg( 'ep-articletable-remarticle-cancel' ),
 154+ 'id': 'ep-remarticle-cancel',
 155+ 'click': function() {
 156+ $dialog.dialog( 'close' );
 157+ }
 158+ }
 159+ ]
 160+ } );
 161+
 162+ $dialog.append( $form );
71163 }
72164
73165 function removeReviewer() {
@@ -135,8 +227,10 @@
136228 $( '.ep-become-reviewer' ).click( addReviewer );
137229
138230 $( '.ep-rem-reviewer, .ep-rem-reviewer-self' ).click( removeReviewer );
139 -
140 - // TODO
 231+
 232+ $( '.ep-rem-student' ).click( removeStudent );
 233+
 234+ $( '.ep-rem-article' ).click( removeArticle );
141235 } );
142236
143237 })( window.jQuery, mw.educationProgram );
\ No newline at end of file
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -445,6 +445,17 @@
446446 'ep-articletable-remreviwer-title-self',
447447 'ep-articletable-remreviwer-button-self',
448448 'ep-articletable-remreviwer-text-self',
 449+
 450+ 'ep-articletable-remstudent-title',
 451+ 'ep-articletable-remstudent-button',
 452+ 'ep-articletable-remstudent-cancel',
 453+ 'ep-articletable-remstudent-text',
 454+
 455+ 'ep-articletable-remarticle-title',
 456+ 'ep-articletable-remarticle-button',
 457+ 'ep-articletable-remarticle-cancel',
 458+ 'ep-articletable-remarticle-text',
 459+ 'ep-articletable-remarticle-text-course',
449460 ),
450461 );
451462

Status & tagging log