r109755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109754‎ | r109755 | r109756 >
Date:20:45, 22 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r109656 - finishing up most remaining renaming, extension should work again now
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPMC.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.instructor.js (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -100,11 +100,11 @@
101101 htmlspecialchars( $org )
102102 );
103103
104 - $course = EPCourse::selectFieldsRow( 'name', array( 'id' => $course->getField( 'course_id' ) ) );
 104+ $masterCourse = EPMC::selectFieldsRow( 'name', array( 'id' => $course->getField( 'mc_id' ) ) );
105105
106 - $stats['course'] = Linker::linkKnown(
107 - SpecialPage::getTitleFor( 'Course', $course ),
108 - htmlspecialchars( $course )
 106+ $stats['mastercourse'] = Linker::linkKnown(
 107+ SpecialPage::getTitleFor( 'MasterCourse', $masterCourse ),
 108+ htmlspecialchars( $masterCourse )
109109 );
110110
111111 $stats['year'] = htmlspecialchars( $this->getLanguage()->formatNum( $course->getField( 'year' ), true ) );
Index: trunk/extensions/EducationProgram/specials/SpecialMasterCourse.php
@@ -180,8 +180,8 @@
181181 array(
182182 'href' => '#',
183183 'class' => 'ep-add-instructor',
184 - 'data-courseid' => $masterCourse->getId(),
185 - 'data-coursename' => $masterCourse->getField( 'name' ),
 184+ 'data-mcid' => $masterCourse->getId(),
 185+ 'data-mcname' => $masterCourse->getField( 'name' ),
186186 'data-mode' => 'self',
187187 ),
188188 wfMsg( 'ep-mc-become-instructor' )
@@ -194,8 +194,8 @@
195195 array(
196196 'href' => '#',
197197 'class' => 'ep-add-instructor',
198 - 'data-courseid' => $masterCourse->getId(),
199 - 'data-coursename' => $masterCourse->getField( 'name' ),
 198+ 'data-mcid' => $masterCourse->getId(),
 199+ 'data-mcname' => $masterCourse->getField( 'name' ),
200200 ),
201201 wfMsg( 'ep-mc-add-instructor' )
202202 );
Index: trunk/extensions/EducationProgram/includes/EPInstructor.php
@@ -121,26 +121,26 @@
122122 * @since 0.1
123123 *
124124 * @param IContextSource $context
125 - * @param EPCourse|null $course
 125+ * @param EPMC|null $course
126126 *
127127 * @return string
128128 */
129 - public function getToolLinks( IContextSource $context, EPCourse $course = null ) {
 129+ public function getToolLinks( IContextSource $context, EPMC $masterCourse = null ) {
130130 $links = array();
131131
132132 $links[] = Linker::userTalkLink( $this->getUser()->getId(), $this->getUser()->getName() );
133133
134134 $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() ), wfMsgHtml( 'contribslink' ) );
135135
136 - if ( !is_null( $course ) &&
 136+ if ( !is_null( $masterCourse ) &&
137137 ( $context->getUser()->isAllowed( 'ep-instructor' ) || $this->getUser()->getId() == $context->getUser()->getId() ) ) {
138138 $links[] = Html::element(
139139 'a',
140140 array(
141141 'href' => '#',
142142 'class' => 'ep-instructor-remove',
143 - 'data-courseid' => $course->getId(),
144 - 'data-coursename' => $course->getField( 'name' ),
 143+ 'data-mcid' => $masterCourse->getId(),
 144+ 'data-mcname' => $masterCourse->getField( 'name' ),
145145 'data-userid' => $this->getUser()->getId(),
146146 'data-username' => $this->getUser()->getName(),
147147 'data-bestname' => $this->getName(),
Index: trunk/extensions/EducationProgram/includes/EPMC.php
@@ -85,9 +85,9 @@
8686
8787 if ( count( $termIds ) > 0 ) {
8888 $fields['students'] = wfGetDB( DB_SLAVE )->select(
89 - 'ep_students_per_term',
 89+ 'ep_students_per_course',
9090 'COUNT(*) AS rowcount',
91 - array( 'spt_term_id' => $termIds )
 91+ array( 'spc_course_id' => $termIds )
9292 );
9393
9494 $fields['students'] = $fields['students']->fetchObject()->rowcount;
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -133,7 +133,7 @@
134134 $conditions,
135135 array(),
136136 array(
137 - 'ep_students_per_term' => array( 'INNER JOIN', array( array( array( 'ep_students_per_course', 'student_id' ), array( 'ep_students', 'id' ) ) ) ),
 137+ 'ep_students_per_course' => array( 'INNER JOIN', array( array( array( 'ep_students_per_course', 'student_id' ), array( 'ep_students', 'id' ) ) ) ),
138138 'ep_courses' => array( 'INNER JOIN', array( array( array( 'ep_students_per_course', 'course_id' ), array( 'ep_courses', 'id' ) ) ) )
139139 )
140140 );
@@ -189,9 +189,9 @@
190190
191191 if ( in_array( 'students', $summaryFields ) ) {
192192 $fields['students'] = wfGetDB( DB_SLAVE )->select(
193 - 'ep_students_per_term',
 193+ 'ep_students_per_course',
194194 'COUNT(*) AS rowcount',
195 - array( 'spt_term_id' => $this->getId() )
 195+ array( 'spc_course_id' => $this->getId() )
196196 );
197197
198198 $fields['students'] = $fields['students']->fetchObject()->rowcount;
@@ -206,7 +206,7 @@
207207 */
208208 protected function insertIntoDB() {
209209 if ( !$this->hasField( 'org_id' ) ) {
210 - $this->setField( 'org_id', $this->getCourse( 'org_id' )->getField( 'org_id' ) );
 210+ $this->setField( 'org_id', $this->getMasterCourse( 'org_id' )->getField( 'org_id' ) );
211211 }
212212
213213 $success = parent::insertIntoDB();
@@ -240,7 +240,7 @@
241241 }
242242
243243 if ( $success ) {
244 - $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_term', array( 'spt_term_id' => $id ) ) && $success;
 244+ $success = wfGetDB( DB_MASTER )->delete( 'ep_students_per_course', array( 'spc_term_id' => $id ) ) && $success;
245245 }
246246
247247 return $success;
@@ -409,11 +409,11 @@
410410 * @param array $args
411411 */
412412 public static function displayAddNewRegion( IContextSource $context, array $args = array() ) {
413 - if ( EPCourse::has() ) {
 413+ if ( EPMC::has() ) {
414414 EPCourse::displayAddNewControl( $context, $args );
415415 }
416416 elseif ( $context->getUser()->isAllowed( 'ep-course' ) ) {
417 - $context->getOutput()->addWikiMsg( 'ep-courses-addcoursefirst' );
 417+ $context->getOutput()->addWikiMsg( 'ep-courses-addmastercoursefirst' );
418418 }
419419 }
420420
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -186,7 +186,7 @@
187187 'ep-courses-newmastercourse' => 'Course master course:',
188188 'ep-courses-add' => 'Add course',
189189 'ep-courses-nocourses' => 'There are no master courses yet. You need to [[Special:MasterCourses|add a master course]] before you can create any courses.',
190 - 'ep-courses-addcoursefirst' => 'The institutions you are a mentor for do not have any master courses associated with them. You need to [[Special:MasterCourses|add a master course]] before you can create any courses.',
 190+ 'ep-courses-addmastercoursefirst' => 'There are no master courses yet. You need to [[Special:MasterCourses|add a master course]] before you can create any courses.',
191191
192192 // Special:Students
193193 'ep-students-noresults' => 'There are no students to list.',
@@ -226,7 +226,7 @@
227227
228228 // Course pager
229229 'epcoursepager-header-id' => 'Id',
230 - 'epcoursepager-header-course-id' => 'Master course',
 230+ 'epcoursepager-header-mc-id' => 'Master course',
231231 'epcoursepager-header-year' => 'Year',
232232 'epcoursepager-header-start' => 'Start',
233233 'epcoursepager-header-end' => 'End',
@@ -391,33 +391,33 @@
392392 'ep-mycourses-not-a-student' => 'You are not enrolled in any [[Special:Courses|courses]].',
393393
394394 // ep.instructor
395 - 'ep-instructor-remove-title' => 'Remove instructor from course',
 395+ 'ep-instructor-remove-title' => 'Remove instructor from master course',
396396 'ep-instructor-remove-button' => 'Remove instructor',
397397 'ep-instructor-removing' => 'Removing...',
398 - 'ep-instructor-removal-success' => 'This instructor has been successfully removed from this course.',
 398+ 'ep-instructor-removal-success' => 'This instructor has been successfully removed from this master course.',
399399 'ep-instructor-close-button' => 'Close',
400400 'ep-instructor-remove-retry' => 'Retry',
401 - 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the course.',
 401+ 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the master course.',
402402 'ep-instructor-cancel-button' => 'Cancel',
403 - 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from course $3. Please enter a brief summary with the reason for this removal.',
 403+ 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from master course $3. Please enter a brief summary with the reason for this removal.',
404404 'ep-instructor-adding' => 'Adding...',
405 - 'ep-instructor-addittion-success' => '$1 has been successfully added as {{GENDER:$1|instructor}} for course $2!',
406 - 'ep-instructor-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|instructor}} for course $2!',
 405+ 'ep-instructor-addittion-success' => '$1 has been successfully added as {{GENDER:$1|instructor}} for master course $2!',
 406+ 'ep-instructor-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|instructor}} for master course $2!',
407407 'ep-instructor-add-close-button' => 'Close',
408408 'ep-instructor-add-retry' => 'Retry',
409 - 'ep-instructor-addittion-failed' => 'Something went wrong - could not add the instructor to the course.',
410 - 'ep-instructor-add-title' => 'Add an instructor to the course',
411 - 'ep-instructor-add-self-title' => 'Become an {{GENDER:$1|instructor}} for this course',
 409+ 'ep-instructor-addittion-failed' => 'Something went wrong - could not add the instructor to the master course.',
 410+ 'ep-instructor-add-title' => 'Add an instructor to the master course',
 411+ 'ep-instructor-add-self-title' => 'Become an {{GENDER:$1|instructor}} for this master course',
412412 'ep-instructor-add-button' => 'Add instructor',
413413 'ep-instructor-add-self-button' => 'Become {{GENDER:$1|instructor}}',
414 - 'ep-instructor-add-text' => 'You are adding an instructor for course $1. Enter the username of the instructor and a brief description why this person is being added.',
415 - 'ep-instructor-add-self-text' => 'You are adding yourself as {{GENDER:$1|instructor}} for course $1. Please add a brief description why you are doing so.',
 414+ 'ep-instructor-add-text' => 'You are adding an instructor for master course $1. Enter the username of the instructor and a brief description why this person is being added.',
 415+ 'ep-instructor-add-self-text' => 'You are adding yourself as {{GENDER:$1|instructor}} for master course $1. Please add a brief description why you are doing so.',
416416 'ep-instructor-add-cancel-button' => 'Cancel',
417417 'ep-instructor-summary-input' => 'Summary',
418418 'ep-instructor-name-input' => 'User name',
419419
420420 // EPInstrucor
421 - 'ep-instructor-remove' => 'remove from course',
 421+ 'ep-instructor-remove' => 'remove as instructor',
422422
423423 // API addinstructor
424424 'ep-addinstructor-invalid-user-args' => 'You need to either provide the username or the userid parameter',
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -394,7 +394,7 @@
395395 'ep-instructor-add-cancel-button',
396396 'ep-instructor-summary-input',
397397 'ep-instructor-name-input',
398 - 'ep-course-no-instructors',
 398+ 'ep-mc-no-instructors',
399399 ),
400400 );
401401
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js
@@ -14,8 +14,8 @@
1515
1616 $( '.ep-instructor-remove' ).click( function( event ) {
1717 var $this = $( this ),
18 - courseId = $this.attr( 'data-courseid' ),
19 - courseName = $this.attr( 'data-coursename' ),
 18+ mcId = $this.attr( 'data-mcid' ),
 19+ mcName = $this.attr( 'data-mcname' ),
2020 userId = $this.attr( 'data-userid' ),
2121 userName = $this.attr( 'data-username' ),
2222 bestName = $this.attr( 'data-bestname' ),
@@ -29,7 +29,7 @@
3030 $remove.button( 'option', 'label', ep.msg( 'ep-instructor-removing' ) );
3131
3232 ep.api.removeInstructor( {
33 - 'courseid': courseId,
 33+ 'mcid': mcId,
3434 'userid': userId,
3535 'reason': summaryInput.val()
3636 } ).done( function() {
@@ -43,7 +43,7 @@
4444 $li.remove();
4545
4646 if ( $ul.find( 'li' ).length < 1 ) {
47 - $ul.closest( 'div' ).text( mw.msg( 'ep-course-no-instructors' ) );
 47+ $ul.closest( 'div' ).text( mw.msg( 'ep-mc-no-instructors' ) );
4848 }
4949 } ).fail( function() {
5050 $remove.button( 'option', 'disabled', false );
@@ -81,7 +81,7 @@
8282 'ep-instructor-remove-text',
8383 mw.html.escape( userName ),
8484 '<b>' + mw.html.escape( bestName ) + '</b>',
85 - '<b>' + mw.html.escape( courseName ) + '</b>'
 85+ '<b>' + mw.html.escape( mcName ) + '</b>'
8686 ) );
8787
8888 $dialog.append( summaryInput );
@@ -99,8 +99,8 @@
100100 $( '.ep-add-instructor' ).click( function( event ) {
101101 var $this = $( this ), _this = this;
102102
103 - this.courseId = $this.attr( 'data-courseid' );
104 - this.courseName = $this.attr( 'data-coursename' );
 103+ this.mcId = $this.attr( 'data-mcid' );
 104+ this.mcName = $this.attr( 'data-mcname' );
105105 this.selfMode = $this.attr( 'data-mode' ) === 'self';
106106 this.$dialog = null;
107107
@@ -132,14 +132,14 @@
133133 $add.button( 'option', 'label', ep.msg( 'ep-instructor-adding' ) );
134134
135135 ep.api.addInstructor( {
136 - 'courseid': _this.courseId,
 136+ 'mcid': _this.mcId,
137137 'username': _this.getName(),
138138 'reason': _this.summaryInput.val()
139139 } ).done( function() {
140140 _this.$dialog.text( ep.msg(
141141 _this.selfMode ? 'ep-instructor-addittion-self-success' : 'ep-instructor-addittion-success',
142142 _this.getName(),
143 - _this.courseName
 143+ _this.mcName
144144 ) );
145145
146146 $add.remove();
@@ -147,11 +147,11 @@
148148 $cancel.focus();
149149
150150 // TODO: link name to user page and show control links
151 - $ul = $( '#ep-course-instructors' ).find( 'ul' );
 151+ $ul = $( '#ep-mc-instructors' ).find( 'ul' );
152152
153153 if ( $ul.length < 1 ) {
154154 $ul = $( '<ul>' );
155 - $( '#ep-course-instructors' ).html( $ul );
 155+ $( '#ep-mc-instructors' ).html( $ul );
156156 }
157157
158158 $ul.append( $( '<li>' ).text( _this.getName() ) )
@@ -185,7 +185,7 @@
186186
187187 this.$dialog.append( $( '<p>' ).text( gM(
188188 this.selfMode ? 'ep-instructor-add-self-text' : 'ep-instructor-add-text',
189 - this.courseName,
 189+ this.mcName,
190190 this.getName()
191191 ) ) );
192192

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109656schema changes currently completely breaking the extension and added hook to ...jeroendedauw22:24, 20 January 2012

Status & tagging log