https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111847
Revision: 111847
Author: jeroendedauw
Date: 2012-02-18 22:54:47 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
work on article table
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.i18n.php
trunk/extensions/EducationProgram/EducationProgram.php
trunk/extensions/EducationProgram/includes/EPArticleTable.php
trunk/extensions/EducationProgram/resources/ep.articletable.js
Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-18
21:46:27 UTC (rev 111846)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-02-18
22:54:47 UTC (rev 111847)
@@ -297,6 +297,19 @@
'ep-articletable-remreviwer-text-self' => 'You are about to remove
yourself as {{GENDER:$1|reviewer}} for article $2 worked on by $3.',
'ep-articletable-remreviwer-text' => 'You are about to remove $4 as
{{GENDER:$1|reviewer}} for article $2 worked on by $3.',
+ 'ep-articletable-remstudent-title' => 'Remove {{GENDER:$1|student}}
from course',
+ 'ep-articletable-remstudent-button' => 'Remove {{GENDER:$1|student}}',
+ 'ep-articletable-remstudent-cancel' => 'Cancel',
+ 'ep-articletable-remstudent-text' => 'You are about to remove $3 as
{{GENDER:$1|student}} from course $2.
+
+This will permanently remove their associated articles and reviewers!',
+
+ 'ep-articletable-remarticle-title' => 'Remove article $1',
+ 'ep-articletable-remarticle-button' => 'Remove article',
+ 'ep-articletable-remarticle-cancel' => 'Cancel',
+ 'ep-articletable-remarticle-text' => 'You are about to remove article
$1 from the list of articles you are working on.',
+ '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.',
+
// Article pager
'ep-articles-noresults' => 'There are no articles to list.',
Modified: trunk/extensions/EducationProgram/EducationProgram.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.php 2012-02-18
21:46:27 UTC (rev 111846)
+++ trunk/extensions/EducationProgram/EducationProgram.php 2012-02-18
22:54:47 UTC (rev 111847)
@@ -445,6 +445,17 @@
'ep-articletable-remreviwer-title-self',
'ep-articletable-remreviwer-button-self',
'ep-articletable-remreviwer-text-self',
+
+ 'ep-articletable-remstudent-title',
+ 'ep-articletable-remstudent-button',
+ 'ep-articletable-remstudent-cancel',
+ 'ep-articletable-remstudent-text',
+
+ 'ep-articletable-remarticle-title',
+ 'ep-articletable-remarticle-button',
+ 'ep-articletable-remarticle-cancel',
+ 'ep-articletable-remarticle-text',
+ 'ep-articletable-remarticle-text-course',
),
);
Modified: trunk/extensions/EducationProgram/includes/EPArticleTable.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-18 21:46:27 UTC (rev 111846)
+++ trunk/extensions/EducationProgram/includes/EPArticleTable.php
2012-02-18 22:54:47 UTC (rev 111847)
@@ -32,6 +32,14 @@
protected $articleConds;
/**
+ * Cached name of the course for which students are shown (if any).
+ *
+ * @since 0.1
+ * @var string|false
+ */
+ protected $courseName = false;
+
+ /**
* Constructor.
*
* @param IContextSource $context
@@ -207,6 +215,8 @@
'href' => '#',
'data-user-id' => $userId,
'data-course-id' =>
$this->articleConds['course_id'],
+ 'data-user-name' => $name,
+ 'data-course-name' =>
$this->getCourseName(),
'class' => 'ep-rem-student',
),
wfMsg( 'ep-artciles-remstudent' )
@@ -228,6 +238,22 @@
}
/**
+ * Returns title of the course for which students are shown.
+ * Only call if there is a single course_id filter condition.
+ *
+ * @since 0.1
+ *
+ * @return string
+ */
+ protected function getCourseName() {
+ if ( $this->courseName === false ) {
+ $this->courseName =
EPCourses::singleton()->selectFieldsRow( 'name', array( 'id' =>
$this->articleConds['course_id'] ) );
+ }
+
+ return $this->courseName;
+ }
+
+ /**
* Returns the HTML for an article cell.
*
* @since 0.1
@@ -236,21 +262,28 @@
* @param integer $rowSpan
*
* @return string
- */
+ */-
protected function getArticleCell( EPArticle $article, $rowSpan ) {
$html = Linker::link(
$article->getTitle(),
htmlspecialchars( $article->getTitle()->getFullText() )
);
+ $attr = array(
+ 'href' => '#',
+ 'data-article-id' => $article->getId(),
+ 'data-article-name' =>
$article->getTitle()->getFullText(),
+ 'class' => 'ep-rem-article',
+ );
+
+ if ( array_key_exists( 'course_id', $this->articleConds ) &&
is_integer( $this->articleConds['course_id'] ) ) {
+ $attr['data-course-name'] = $this->getCourseName();
+ }
+
if ( $this->getUser()->getId() === $article->getField(
'user_id' ) ) {
$html .= ' (' . Html::element(
'a',
- array(
- 'href' => '#',
- 'data-article-id' => $article->getId(),
- 'class' => 'ep-rem-article',
- ),
+ $attr,
wfMsg( 'ep-artciles-remarticle' )
) . ')';
}
@@ -344,7 +377,7 @@
'form',
array(
'method' => 'post',
- 'action' => $this->getTitle()->getLocalURL(
array( 'action' => 'addarticle' ) ),
+ 'action' => $this->getTitle()->getLocalURL(
array( 'action' => 'epaddarticle' ) ),
)
);
Modified: trunk/extensions/EducationProgram/resources/ep.articletable.js
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.articletable.js
2012-02-18 21:46:27 UTC (rev 111846)
+++ trunk/extensions/EducationProgram/resources/ep.articletable.js
2012-02-18 22:54:47 UTC (rev 111847)
@@ -57,16 +57,108 @@
$dialog.append( $form );
}
- function addArticle() {
- // TODO
- }
-
function removeStudent() {
- // TODO
+ var $this = $( this );
+
+ var $form = $( '<form>' ).attr( {
+ 'method': 'post',
+ 'action': window.location
+ } ).msg(
+ 'ep-articletable-remstudent-text',
+ mw.user.name,
+ $( '<b>' ).text( $this.attr( 'data-course-name' ) ),
+ $( '<b>' ).text( $this.attr( 'data-user-name' ) )
+ );
+
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'action',
+ 'value': 'epremstudent'
+ } ) );
+
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'user-id',
+ 'value': $this.attr( 'data-user-id' )
+ } ) );
+
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'course-id',
+ 'value': $this.attr( 'data-course-id' )
+ } ) );
+
+ var $dialog = $( '<div>' ).html( '' ).dialog( {
+ 'title': ep.msg('ep-articletable-remstudent-title',
mw.user.name ),
+ 'minWidth': 550,
+ 'buttons': [
+ {
+ 'text': ep.msg(
'ep-articletable-remstudent-button', mw.user.name ),
+ 'id': 'ep-remstudent-button',
+ 'click': function() {
+ $form.submit();
+ }
+ },
+ {
+ 'text': ep.msg(
'ep-articletable-remstudent-cancel' ),
+ 'id': 'ep-remstudent-cancel',
+ 'click': function() {
+ $dialog.dialog( 'close' );
+ }
+ }
+ ]
+ } );
+
+ $dialog.append( $form );
}
function removeArticle() {
- // TODO
+ var $this = $( this ),
+ courseName = $this.attr( 'data-course-name' );
+
+ var $form = $( '<form>' ).attr( {
+ 'method': 'post',
+ 'action': window.location
+ } ).msg(
+ 'ep-articletable-remarticle-text' + ( courseName ===
undefined ? '' : '-course' ),
+ $( '<b>' ).text( $this.attr( 'data-article-name' ) ),
+ $( '<b>' ).text( courseName )
+ );
+
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'action',
+ 'value': 'epremarticle'
+ } ) );
+
+ $form.append( $( '<input>' ).attr( {
+ 'type': 'hidden',
+ 'name': 'article-id',
+ 'value': $this.attr( 'data-article-id' )
+ } ) );
+
+ var $dialog = $( '<div>' ).html( '' ).dialog( {
+ 'title': ep.msg( 'ep-articletable-remarticle-title',
$this.attr( 'data-article-name' ) ),
+ 'minWidth': 550,
+ 'buttons': [
+ {
+ 'text': ep.msg(
'ep-articletable-remarticle-button' ),
+ 'id': 'ep-remarticle-button',
+ 'click': function() {
+ $form.submit();
+ }
+ },
+ {
+ 'text': ep.msg(
'ep-articletable-remarticle-cancel' ),
+ 'id': 'ep-remarticle-cancel',
+ 'click': function() {
+ $dialog.dialog( 'close' );
+ }
+ }
+ ]
+ } );
+
+ $dialog.append( $form );
}
function removeReviewer() {
@@ -135,8 +227,10 @@
$( '.ep-become-reviewer' ).click( addReviewer );
$( '.ep-rem-reviewer, .ep-rem-reviewer-self' ).click(
removeReviewer );
-
- // TODO
+
+ $( '.ep-rem-student' ).click( removeStudent );
+
+ $( '.ep-rem-article' ).click( removeArticle );
} );
})( window.jQuery, mw.educationProgram );
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs