r110241 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110240‎ | r110241 | r110242 >
Date:13:39, 29 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed some issues with creating new stuffs
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EditCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.addcourse.js (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.addorg.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
@@ -27,7 +27,14 @@
2828
2929 if ( $this->getUser()->isAllowed( 'ep-course' ) ) {
3030 $out->addWikiMsg( 'ep-course-create', $name );
31 - EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $name ) );
 31+
 32+ EPCourse::displayAddNewRegion(
 33+ $this->getContext(),
 34+ array(
 35+ 'name' => $this->getRequest()->getText( 'newname', '' ),
 36+ 'term' => $this->getRequest()->getText( 'newterm', '' ),
 37+ )
 38+ );
3239 }
3340 else {
3441 $out->addWikiMsg( 'ep-course-none', $name );
Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php
@@ -107,7 +107,15 @@
108108 );
109109
110110 $mcs = EPCourse::selectFields( 'mc', array(), array( 'DISTINCT' ) );
111 - $mcs = array_merge( array( '' => '' ), $mcs );
 111+
 112+ if ( $this->getRequest()->getCheck( 'newname' ) ) {
 113+ $newName = $this->getRequest()->getText( 'newname' );
 114+ $mcs = array_merge( array( $newName => $newName ), $mcs );
 115+ }
 116+ else {
 117+ $mcs = array_merge( array( '' => '' ), $mcs );
 118+ }
 119+
112120 $fields['mc'] = array (
113121 'class' => 'EPHTMLCombobox',
114122 'label-message' => 'ep-course-edit-mc',
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -216,7 +216,7 @@
217217 'form',
218218 array(
219219 'method' => 'post',
220 - 'action' => self::getTitleFor( 'NAME' )->getLocalURL(),
 220+ 'action' => self::getTitleFor( 'NAME_PLACEHOLDER' )->getLocalURL( array( 'action' => 'edit' ) ),
221221 )
222222 ) );
223223
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -336,7 +336,7 @@
337337 'form',
338338 array(
339339 'method' => 'post',
340 - 'action' => self::getTitleFor( 'NAME' )->getLocalURL(),
 340+ 'action' => self::getTitleFor( 'NAME_PLACEHOLDER' )->getLocalURL( array( 'action' => 'edit' ) ),
341341 )
342342 ) );
343343
@@ -357,9 +357,21 @@
358358 $select->addOptions( EPOrg::getOrgOptions() );
359359 $out->addHTML( $select->getHTML() );
360360
361 - $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-courses-newname' ), 'newname', 'newname', 20 ) );
 361+ $out->addHTML( ' ' . Xml::inputLabel(
 362+ wfMsg( 'ep-courses-newname' ),
 363+ 'newname',
 364+ 'newname',
 365+ 20,
 366+ array_key_exists( 'name', $args ) ? $args['name'] : false
 367+ ) );
362368
363 - $out->addHTML( ' ' . Xml::inputLabel( wfMsg( 'ep-courses-newterm' ), 'newterm', 'newterm', 10 ) );
 369+ $out->addHTML( ' ' . Xml::inputLabel(
 370+ wfMsg( 'ep-courses-newterm' ),
 371+ 'newterm',
 372+ 'newterm',
 373+ 10,
 374+ array_key_exists( 'term', $args ) ? $args['term'] : false
 375+ ) );
364376
365377 $out->addHTML( ' ' . Html::input(
366378 'addnewcourse',
Index: trunk/extensions/EducationProgram/resources/ep.addcourse.js
@@ -11,10 +11,12 @@
1212 $( document ).ready( function() {
1313
1414 $( '.ep-course-add' ).closest( 'form' ).submit( function() {
15 - var action = $( this ).attr( 'action' );
1615 $( this ).attr(
1716 'action',
18 - action.substring( 0, action.length - 4 ) + $( '#newname' ).val() + ' (' + $( '#newterm' ).val() + ')'
 17+ $( this ).attr( 'action' ).replace(
 18+ 'NAME_PLACEHOLDER',
 19+ $( '#newname' ).val() + ' (' + $( '#newterm' ).val() + ')'
 20+ )
1921 );
2022 } );
2123
Index: trunk/extensions/EducationProgram/resources/ep.addorg.js
@@ -11,8 +11,7 @@
1212 $( document ).ready( function() {
1313
1414 $( '.ep-org-add' ).closest( 'form' ).submit( function() {
15 - var action = $( this ).attr( 'action' );
16 - $( this ).attr( 'action', action.substring( 0, action.length - 4 ) + $( '#newname' ).val() );
 15+ $( this ).attr( 'action', $( this ).attr( 'action' ).replace( 'NAME_PLACEHOLDER', $( '#newname' ).val() ) );
1716 } );
1817
1918 $( '.ep-org-add' ).removeAttr( 'disabled' );

Status & tagging log