https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111833

Revision: 111833
Author:   jeroendedauw
Date:     2012-02-18 16:50:27 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
work on article table

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.php
    trunk/extensions/EducationProgram/includes/EPArticleTable.php
    trunk/extensions/EducationProgram/resources/ep.disenroll.js
    trunk/extensions/EducationProgram/resources/ep.formpage.js

Added Paths:
-----------
    trunk/extensions/EducationProgram/resources/ep.articletable.js

Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php      2012-02-18 
15:34:12 UTC (rev 111832)
+++ trunk/extensions/EducationProgram/EducationProgram.php      2012-02-18 
16:50:27 UTC (rev 111833)
@@ -424,6 +424,16 @@
        ),
 );
 
+$wgResourceModules['ep.articletable'] = $moduleTemplate + array(
+       'scripts' => array(
+               'ep.articletable.js',
+       ),
+       'dependencies' => array(
+               'jquery.ui.button',
+               'jquery.ui.dialog',
+       ),
+);
+
 $wgResourceModules['ep.addorg'] = $moduleTemplate + array(
        'scripts' => array(
                'ep.addorg.js',

Modified: trunk/extensions/EducationProgram/includes/EPArticleTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticleTable.php       
2012-02-18 15:34:12 UTC (rev 111832)
+++ trunk/extensions/EducationProgram/includes/EPArticleTable.php       
2012-02-18 16:50:27 UTC (rev 111833)
@@ -45,6 +45,11 @@
                // when MW 1.19 becomes min, we want to pass an IContextSource 
$context here.
                parent::__construct( $context, $conds, EPStudents::singleton() 
);
        }
+       
+       public function getBody() {
+               $this->getOutput()->addModules( 'ep.articletable' );
+               return parent::getBody();
+       }
 
        /**
         * (non-PHPdoc)
@@ -108,6 +113,23 @@
 
                $html .= $this->getUserCell( $student->getField( 'user_id' ), 
$rowCount );
 
+               $this->addNonStudentHTML( $html, $articles, 
$showArticleAdittion );
+
+               $html .= '</tr>';
+
+               return $html;
+       }
+       
+       /**
+        * Adds the HTML for the article and reviewers to the table row.
+        * 
+        * @since 0.1
+        * 
+        * @param string $html
+        * @param array $articles
+        * @param boolean $showArticleAdittion
+        */
+       protected function addNonStudentHTML( &$html, array $articles, 
$showArticleAdittion ) {
                $isFirst = true;
 
                foreach ( $articles as /* EPArticle */ $article ) {
@@ -121,7 +143,7 @@
 
                        $articleRowCount = count( $reviewers );
 
-                       if ( $article->canBecomeReviewer( $user ) ) {
+                       if ( $article->canBecomeReviewer( $this->getUser() ) ) {
                                $articleRowCount++;
                        }
 
@@ -137,7 +159,7 @@
                                $html .= $this->getReviewerCell( $article, 
$userId );
                        }
 
-                       if ( $article->canBecomeReviewer( $user ) ) {
+                       if ( $article->canBecomeReviewer( $this->getUser() ) ) {
                                if ( count( $reviewers ) !== 0 ) {
                                        $html .= '</tr><tr>';
                                }
@@ -152,11 +174,7 @@
                        }
 
                        $html .= $this->getArticleAdittionControl( 
$this->articleConds['course_id'] );
-               }
-
-               $html .= '</tr>';
-
-               return $html;
+               }       
        }
 
        /**
@@ -304,6 +322,15 @@
                );
        }
 
+       /**
+        * Returns the HTML for the article adittion control.
+        * 
+        * @since 0.1
+        * 
+        * @param integer $courseId
+        * 
+        * @return string
+        */
        protected function getArticleAdittionControl( $courseId ) {
                $html = '';
 
@@ -337,12 +364,21 @@
                return '<td colspan="2">' . $html . '</td>';
        }
 
+       /**
+        * Returns the HTML for the reviewer adittion control.
+        * 
+        * @since 0.1
+        * 
+        * @param EPArticle $article
+        * 
+        * @return string
+        */
        protected function getReviewerAdittionControl( EPArticle $article ) {
                $html = Html::element(
                        'button',
                        array(
                                'class' => 'ep-become-reviewer',
-                               //'disabled' => 'disabled',
+                               'disabled' => 'disabled',
                                'data-article-id' => $article->getId(),
                        ),
                        wfMsg( 'ep-artciles-becomereviewer' )

Added: trunk/extensions/EducationProgram/resources/ep.articletable.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.articletable.js              
                (rev 0)
+++ trunk/extensions/EducationProgram/resources/ep.articletable.js      
2012-02-18 16:50:27 UTC (rev 111833)
@@ -0,0 +1,62 @@
+/**
+ * JavasSript for the Education Program MediaWiki extension.
+ * @see https://www.mediawiki.org/wiki/Extension:Education_Program
+ *
+ * @licence GNU GPL v3 or later
+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
+ */
+
+(function( $, ep ) {
+       
+       function addReviewer() {
+               $dialog = $( '<div>' ).html( '' ).dialog( {
+                       'title': ep.msg( 'ep-articletable-addreviwer-title' ),
+                       'minWidth': 550,
+                       'buttons': [
+                               {
+                                       'text': ep.msg( 
'ep-articletable-addreviwer-button' ),
+                                       'id': 'ep-addreviwer-button',
+                                       'click': function() {
+                                               alert( 'submit' );
+                                               // TODO
+                                       }
+                               },
+                               {
+                                       'text': ep.msg( 
'ep-articletable-addreviwer-cancel' ),
+                                       'id': 'ep-addreviwer-cancel',
+                                       'click': function() {
+                                               $dialog.dialog( 'close' );
+                                       }
+                               }
+                       ]
+               } );
+       }
+       
+       function addArticle() {
+               // TODO
+       }
+       
+       function removeStudent() {
+               // TODO
+       }
+       
+       function removeArticle() {
+               // TODO
+       }
+       
+       function removeReviewer() {
+               // TODO
+       }
+       
+       $( document ).ready( function() {
+
+               $( '.ep-rem-reviewer-self, .ep-become-reviewer' ).removeAttr( 
'disabled' );
+
+               $( '.ep-become-reviewer' ).click( addReviewer );
+               
+               $( '.ep-rem-reviewer-self' ).click( removeReviewer );
+               
+               // TODO
+       } );
+
+})( window.jQuery, mw.educationProgram );
\ No newline at end of file


Property changes on: 
trunk/extensions/EducationProgram/resources/ep.articletable.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/EducationProgram/resources/ep.disenroll.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.disenroll.js 2012-02-18 
15:34:12 UTC (rev 111832)
+++ trunk/extensions/EducationProgram/resources/ep.disenroll.js 2012-02-18 
16:50:27 UTC (rev 111833)
@@ -10,8 +10,7 @@
 
        $( document ).ready( function() {
 
-               $( '.ep-disenroll-cancel' ).button();
-               $( '.ep-disenroll' ).button();
+               $( '.ep-disenroll-cancel, .ep-disenroll' ).button();
 
                $( '.ep-disenroll-cancel' ).click( function( event ) {
                        window.location = $( this ).attr( 'target-url' );

Modified: trunk/extensions/EducationProgram/resources/ep.formpage.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.formpage.js  2012-02-18 
15:34:12 UTC (rev 111832)
+++ trunk/extensions/EducationProgram/resources/ep.formpage.js  2012-02-18 
16:50:27 UTC (rev 111833)
@@ -17,8 +17,6 @@
                        event.preventDefault();
                } );
 
-               //$( 'textarea.wiki-editor-input' ).attr( 'class', 
'wiki-editor' ).wikiEditor( 'addModule', 
$.wikiEditor.modules.toolbar.config.getDefaultConfig() );
-
        } );
        
 })( window.jQuery, window.mediaWiki );
\ No newline at end of file


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to