r110787 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110786‎ | r110787 | r110788 >
Date:21:34, 6 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
ui tweaks and fixed redirect after renaming pages
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EPEditAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/EditCourseAction.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php
@@ -99,6 +99,24 @@
100100 'label-message' => 'ep-course-edit-name',
101101 'required' => true,
102102 );
 103+
 104+ $mcs = EPCourse::selectFields( 'mc', array(), array( 'DISTINCT' ) );
 105+
 106+ if ( $this->getRequest()->getCheck( 'newname' ) ) {
 107+ $newName = $this->getRequest()->getText( 'newname' );
 108+ $mcs = array_merge( array( $newName => $newName ), $mcs );
 109+ }
 110+ else {
 111+ $mcs = array_merge( array( '' => '' ), $mcs );
 112+ }
 113+
 114+
 115+ $fields['mc'] = array (
 116+ 'class' => 'EPHTMLCombobox',
 117+ 'label-message' => 'ep-course-edit-mc',
 118+ 'required' => true,
 119+ 'options' => array_combine( $mcs, $mcs ),
 120+ );
103121
104122 $fields['org_id'] = array (
105123 'type' => 'select',
@@ -169,23 +187,6 @@
170188 }
171189 );
172190
173 - $mcs = EPCourse::selectFields( 'mc', array(), array( 'DISTINCT' ) );
174 -
175 - if ( $this->getRequest()->getCheck( 'newname' ) ) {
176 - $newName = $this->getRequest()->getText( 'newname' );
177 - $mcs = array_merge( array( $newName => $newName ), $mcs );
178 - }
179 - else {
180 - $mcs = array_merge( array( '' => '' ), $mcs );
181 - }
182 -
183 - $fields['mc'] = array (
184 - 'class' => 'EPHTMLCombobox',
185 - 'label-message' => 'ep-course-edit-mc',
186 - 'required' => true,
187 - 'options' => array_combine( $mcs, $mcs ),
188 - );
189 -
190191 $fields['description'] = array (
191192 'type' => 'textarea',
192193 'label-message' => 'ep-course-edit-description',
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php
@@ -1,7 +1,7 @@
22 <?php
33
44 /**
5 - * Abstract action for editing EPDBObject items.
 5+ * Abstract action for editing EPPageObject items.
66 *
77 * @since 0.1
88 *
@@ -18,7 +18,7 @@
1919 * Instance of the object being edited or created.
2020 *
2121 * @since 0.1
22 - * @var EPDBObject|false
 22+ * @var EPPageObject|false
2323 */
2424 protected $item = false;
2525
@@ -31,7 +31,7 @@
3232 protected $isNew = null;
3333
3434 /**
35 - * Returns the class name of the EPDBObject this action handles.
 35+ * Returns the class name of the EPPageObject this action handles.
3636 *
3737 * @since 0.1
3838 *
@@ -305,12 +305,12 @@
306306 *
307307 * @since 0.1
308308 *
309 - * @param EPDBObject $item
 309+ * @param EPPageObject $item
310310 * @param string $name
311311 *
312312 * @return mixed
313313 */
314 - protected function getDefaultFromItem( EPDBObject $item, $name ) {
 314+ protected function getDefaultFromItem( EPPageObject $item, $name ) {
315315 return $item->getField( $name );
316316 }
317317
@@ -323,6 +323,16 @@
324324 $this->getOutput()->redirect( $this->getReturnToTitle( true )->getLocalURL() );
325325 }
326326
 327+ /**
 328+ * Returns the title to return to after the form has been submitted,
 329+ * or when form use is aborted for some other reason.
 330+ *
 331+ * @since 0.1
 332+ *
 333+ * @param boolean $addedItem
 334+ *
 335+ * @return Title
 336+ */
327337 protected function getReturnToTitle( $addedItem = false ) {
328338 if ( $this->getRequest()->getCheck( 'wpreturnto' ) ) {
329339 return Title::newFromText( $this->getRequest()->getText( 'wpreturnto' ) );
@@ -331,9 +341,20 @@
332342 $c = $this->getItemClass(); // Yeah, this is needed in PHP 5.3 >_>
333343 return SpecialPage::getTitleFor( $c::getListPage() );
334344 }
 345+ elseif ( $this->item !== false ) {
 346+ return $this->item->getTitle();
 347+ }
335348 else {
336 - return $this->getTitle();
337 - }
 349+ $c = $this->getItemClass(); // Yeah, this is needed in PHP 5.3 >_>
 350+ $fieldName = 'wpitem-' . $c::getIdentifierField();
 351+
 352+ if ( $this->getRequest()->getCheck( $fieldName ) ) {
 353+ return $c::getTitleFor( $this->getRequest()->getText( $fieldName ) );
 354+ }
 355+ else {
 356+ return $this->getTitle();
 357+ }
 358+ }
338359 }
339360
340361 /**
@@ -370,7 +391,7 @@
371392 $keys = array_keys( $fields );
372393 $fields = array_combine( $keys, array_map( array( $this, 'handleKnownField' ), $keys, $fields ) );
373394
374 - /* EPDBObject */ $item = new $c( $fields, is_null( $fields['id'] ) );
 395+ /* EPPageObject */ $item = new $c( $fields, is_null( $fields['id'] ) );
375396
376397 foreach ( $unknownValues as $name => $value ) {
377398 $this->handleUnknownField( $item, $name, $value );

Status & tagging log