Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -32,6 +32,14 @@ |
33 | 33 | protected $articleConds; |
34 | 34 | |
35 | 35 | /** |
| 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 | + /** |
36 | 44 | * Constructor. |
37 | 45 | * |
38 | 46 | * @param IContextSource $context |
— | — | @@ -207,6 +215,8 @@ |
208 | 216 | 'href' => '#', |
209 | 217 | 'data-user-id' => $userId, |
210 | 218 | 'data-course-id' => $this->articleConds['course_id'], |
| 219 | + 'data-user-name' => $name, |
| 220 | + 'data-course-name' => $this->getCourseName(), |
211 | 221 | 'class' => 'ep-rem-student', |
212 | 222 | ), |
213 | 223 | wfMsg( 'ep-artciles-remstudent' ) |
— | — | @@ -228,6 +238,22 @@ |
229 | 239 | } |
230 | 240 | |
231 | 241 | /** |
| 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 | + /** |
232 | 258 | * Returns the HTML for an article cell. |
233 | 259 | * |
234 | 260 | * @since 0.1 |
— | — | @@ -236,21 +262,28 @@ |
237 | 263 | * @param integer $rowSpan |
238 | 264 | * |
239 | 265 | * @return string |
240 | | - */ |
| 266 | + */- |
241 | 267 | protected function getArticleCell( EPArticle $article, $rowSpan ) { |
242 | 268 | $html = Linker::link( |
243 | 269 | $article->getTitle(), |
244 | 270 | htmlspecialchars( $article->getTitle()->getFullText() ) |
245 | 271 | ); |
246 | 272 | |
| 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 | + |
247 | 284 | if ( $this->getUser()->getId() === $article->getField( 'user_id' ) ) { |
248 | 285 | $html .= ' (' . Html::element( |
249 | 286 | 'a', |
250 | | - array( |
251 | | - 'href' => '#', |
252 | | - 'data-article-id' => $article->getId(), |
253 | | - 'class' => 'ep-rem-article', |
254 | | - ), |
| 287 | + $attr, |
255 | 288 | wfMsg( 'ep-artciles-remarticle' ) |
256 | 289 | ) . ')'; |
257 | 290 | } |
— | — | @@ -344,7 +377,7 @@ |
345 | 378 | 'form', |
346 | 379 | array( |
347 | 380 | 'method' => 'post', |
348 | | - 'action' => $this->getTitle()->getLocalURL( array( 'action' => 'addarticle' ) ), |
| 381 | + 'action' => $this->getTitle()->getLocalURL( array( 'action' => 'epaddarticle' ) ), |
349 | 382 | ) |
350 | 383 | ); |
351 | 384 | |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -297,6 +297,19 @@ |
298 | 298 | 'ep-articletable-remreviwer-text-self' => 'You are about to remove yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.', |
299 | 299 | 'ep-articletable-remreviwer-text' => 'You are about to remove $4 as {{GENDER:$1|reviewer}} for article $2 worked on by $3.', |
300 | 300 | |
| 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 | + |
301 | 314 | // Article pager |
302 | 315 | 'ep-articles-noresults' => 'There are no articles to list.', |
303 | 316 | |
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js |
— | — | @@ -57,16 +57,108 @@ |
58 | 58 | $dialog.append( $form ); |
59 | 59 | } |
60 | 60 | |
61 | | - function addArticle() { |
62 | | - // TODO |
63 | | - } |
64 | | - |
65 | 61 | 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 ); |
67 | 114 | } |
68 | 115 | |
69 | 116 | 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 ); |
71 | 163 | } |
72 | 164 | |
73 | 165 | function removeReviewer() { |
— | — | @@ -135,8 +227,10 @@ |
136 | 228 | $( '.ep-become-reviewer' ).click( addReviewer ); |
137 | 229 | |
138 | 230 | $( '.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 ); |
141 | 235 | } ); |
142 | 236 | |
143 | 237 | })( window.jQuery, mw.educationProgram ); |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -445,6 +445,17 @@ |
446 | 446 | 'ep-articletable-remreviwer-title-self', |
447 | 447 | 'ep-articletable-remreviwer-button-self', |
448 | 448 | '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', |
449 | 460 | ), |
450 | 461 | ); |
451 | 462 | |