r111833 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111832‎ | r111833 | r111834 >
Date:16:50, 18 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on article table
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPArticleTable.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.articletable.js (added) (history)
  • /trunk/extensions/EducationProgram/resources/ep.disenroll.js (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.formpage.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -424,6 +424,16 @@
425425 ),
426426 );
427427
 428+$wgResourceModules['ep.articletable'] = $moduleTemplate + array(
 429+ 'scripts' => array(
 430+ 'ep.articletable.js',
 431+ ),
 432+ 'dependencies' => array(
 433+ 'jquery.ui.button',
 434+ 'jquery.ui.dialog',
 435+ ),
 436+);
 437+
428438 $wgResourceModules['ep.addorg'] = $moduleTemplate + array(
429439 'scripts' => array(
430440 'ep.addorg.js',
Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php
@@ -45,6 +45,11 @@
4646 // when MW 1.19 becomes min, we want to pass an IContextSource $context here.
4747 parent::__construct( $context, $conds, EPStudents::singleton() );
4848 }
 49+
 50+ public function getBody() {
 51+ $this->getOutput()->addModules( 'ep.articletable' );
 52+ return parent::getBody();
 53+ }
4954
5055 /**
5156 * (non-PHPdoc)
@@ -108,6 +113,23 @@
109114
110115 $html .= $this->getUserCell( $student->getField( 'user_id' ), $rowCount );
111116
 117+ $this->addNonStudentHTML( $html, $articles, $showArticleAdittion );
 118+
 119+ $html .= '</tr>';
 120+
 121+ return $html;
 122+ }
 123+
 124+ /**
 125+ * Adds the HTML for the article and reviewers to the table row.
 126+ *
 127+ * @since 0.1
 128+ *
 129+ * @param string $html
 130+ * @param array $articles
 131+ * @param boolean $showArticleAdittion
 132+ */
 133+ protected function addNonStudentHTML( &$html, array $articles, $showArticleAdittion ) {
112134 $isFirst = true;
113135
114136 foreach ( $articles as /* EPArticle */ $article ) {
@@ -121,7 +143,7 @@
122144
123145 $articleRowCount = count( $reviewers );
124146
125 - if ( $article->canBecomeReviewer( $user ) ) {
 147+ if ( $article->canBecomeReviewer( $this->getUser() ) ) {
126148 $articleRowCount++;
127149 }
128150
@@ -137,7 +159,7 @@
138160 $html .= $this->getReviewerCell( $article, $userId );
139161 }
140162
141 - if ( $article->canBecomeReviewer( $user ) ) {
 163+ if ( $article->canBecomeReviewer( $this->getUser() ) ) {
142164 if ( count( $reviewers ) !== 0 ) {
143165 $html .= '</tr><tr>';
144166 }
@@ -152,11 +174,7 @@
153175 }
154176
155177 $html .= $this->getArticleAdittionControl( $this->articleConds['course_id'] );
156 - }
157 -
158 - $html .= '</tr>';
159 -
160 - return $html;
 178+ }
161179 }
162180
163181 /**
@@ -304,6 +322,15 @@
305323 );
306324 }
307325
 326+ /**
 327+ * Returns the HTML for the article adittion control.
 328+ *
 329+ * @since 0.1
 330+ *
 331+ * @param integer $courseId
 332+ *
 333+ * @return string
 334+ */
308335 protected function getArticleAdittionControl( $courseId ) {
309336 $html = '';
310337
@@ -337,12 +364,21 @@
338365 return '<td colspan="2">' . $html . '</td>';
339366 }
340367
 368+ /**
 369+ * Returns the HTML for the reviewer adittion control.
 370+ *
 371+ * @since 0.1
 372+ *
 373+ * @param EPArticle $article
 374+ *
 375+ * @return string
 376+ */
341377 protected function getReviewerAdittionControl( EPArticle $article ) {
342378 $html = Html::element(
343379 'button',
344380 array(
345381 'class' => 'ep-become-reviewer',
346 - //'disabled' => 'disabled',
 382+ 'disabled' => 'disabled',
347383 'data-article-id' => $article->getId(),
348384 ),
349385 wfMsg( 'ep-artciles-becomereviewer' )
Index: trunk/extensions/EducationProgram/resources/ep.articletable.js
@@ -0,0 +1,62 @@
 2+/**
 3+ * JavasSript for the Education Program MediaWiki extension.
 4+ * @see https://www.mediawiki.org/wiki/Extension:Education_Program
 5+ *
 6+ * @licence GNU GPL v3 or later
 7+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 8+ */
 9+
 10+(function( $, ep ) {
 11+
 12+ function addReviewer() {
 13+ $dialog = $( '<div>' ).html( '' ).dialog( {
 14+ 'title': ep.msg( 'ep-articletable-addreviwer-title' ),
 15+ 'minWidth': 550,
 16+ 'buttons': [
 17+ {
 18+ 'text': ep.msg( 'ep-articletable-addreviwer-button' ),
 19+ 'id': 'ep-addreviwer-button',
 20+ 'click': function() {
 21+ alert( 'submit' );
 22+ // TODO
 23+ }
 24+ },
 25+ {
 26+ 'text': ep.msg( 'ep-articletable-addreviwer-cancel' ),
 27+ 'id': 'ep-addreviwer-cancel',
 28+ 'click': function() {
 29+ $dialog.dialog( 'close' );
 30+ }
 31+ }
 32+ ]
 33+ } );
 34+ }
 35+
 36+ function addArticle() {
 37+ // TODO
 38+ }
 39+
 40+ function removeStudent() {
 41+ // TODO
 42+ }
 43+
 44+ function removeArticle() {
 45+ // TODO
 46+ }
 47+
 48+ function removeReviewer() {
 49+ // TODO
 50+ }
 51+
 52+ $( document ).ready( function() {
 53+
 54+ $( '.ep-rem-reviewer-self, .ep-become-reviewer' ).removeAttr( 'disabled' );
 55+
 56+ $( '.ep-become-reviewer' ).click( addReviewer );
 57+
 58+ $( '.ep-rem-reviewer-self' ).click( removeReviewer );
 59+
 60+ // TODO
 61+ } );
 62+
 63+})( window.jQuery, mw.educationProgram );
\ No newline at end of file
Property changes on: trunk/extensions/EducationProgram/resources/ep.articletable.js
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/EducationProgram/resources/ep.disenroll.js
@@ -10,8 +10,7 @@
1111
1212 $( document ).ready( function() {
1313
14 - $( '.ep-disenroll-cancel' ).button();
15 - $( '.ep-disenroll' ).button();
 14+ $( '.ep-disenroll-cancel, .ep-disenroll' ).button();
1615
1716 $( '.ep-disenroll-cancel' ).click( function( event ) {
1817 window.location = $( this ).attr( 'target-url' );
Index: trunk/extensions/EducationProgram/resources/ep.formpage.js
@@ -17,8 +17,6 @@
1818 event.preventDefault();
1919 } );
2020
21 - //$( 'textarea.wiki-editor-input' ).attr( 'class', 'wiki-editor' ).wikiEditor( 'addModule', $.wikiEditor.modules.toolbar.config.getDefaultConfig() );
22 -
2321 } );
2422
2523 })( window.jQuery, window.mediaWiki );
\ No newline at end of file

Status & tagging log