Index: trunk/extensions/EducationProgram/actions/EditCourseAction.php |
— | — | @@ -99,6 +99,24 @@ |
100 | 100 | 'label-message' => 'ep-course-edit-name', |
101 | 101 | 'required' => true, |
102 | 102 | ); |
| 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 | + ); |
103 | 121 | |
104 | 122 | $fields['org_id'] = array ( |
105 | 123 | 'type' => 'select', |
— | — | @@ -169,23 +187,6 @@ |
170 | 188 | } |
171 | 189 | ); |
172 | 190 | |
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 | | - |
190 | 191 | $fields['description'] = array ( |
191 | 192 | 'type' => 'textarea', |
192 | 193 | 'label-message' => 'ep-course-edit-description', |
Index: trunk/extensions/EducationProgram/actions/EPEditAction.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Abstract action for editing EPDBObject items. |
| 5 | + * Abstract action for editing EPPageObject items. |
6 | 6 | * |
7 | 7 | * @since 0.1 |
8 | 8 | * |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * Instance of the object being edited or created. |
20 | 20 | * |
21 | 21 | * @since 0.1 |
22 | | - * @var EPDBObject|false |
| 22 | + * @var EPPageObject|false |
23 | 23 | */ |
24 | 24 | protected $item = false; |
25 | 25 | |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | protected $isNew = null; |
33 | 33 | |
34 | 34 | /** |
35 | | - * Returns the class name of the EPDBObject this action handles. |
| 35 | + * Returns the class name of the EPPageObject this action handles. |
36 | 36 | * |
37 | 37 | * @since 0.1 |
38 | 38 | * |
— | — | @@ -305,12 +305,12 @@ |
306 | 306 | * |
307 | 307 | * @since 0.1 |
308 | 308 | * |
309 | | - * @param EPDBObject $item |
| 309 | + * @param EPPageObject $item |
310 | 310 | * @param string $name |
311 | 311 | * |
312 | 312 | * @return mixed |
313 | 313 | */ |
314 | | - protected function getDefaultFromItem( EPDBObject $item, $name ) { |
| 314 | + protected function getDefaultFromItem( EPPageObject $item, $name ) { |
315 | 315 | return $item->getField( $name ); |
316 | 316 | } |
317 | 317 | |
— | — | @@ -323,6 +323,16 @@ |
324 | 324 | $this->getOutput()->redirect( $this->getReturnToTitle( true )->getLocalURL() ); |
325 | 325 | } |
326 | 326 | |
| 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 | + */ |
327 | 337 | protected function getReturnToTitle( $addedItem = false ) { |
328 | 338 | if ( $this->getRequest()->getCheck( 'wpreturnto' ) ) { |
329 | 339 | return Title::newFromText( $this->getRequest()->getText( 'wpreturnto' ) ); |
— | — | @@ -331,9 +341,20 @@ |
332 | 342 | $c = $this->getItemClass(); // Yeah, this is needed in PHP 5.3 >_> |
333 | 343 | return SpecialPage::getTitleFor( $c::getListPage() ); |
334 | 344 | } |
| 345 | + elseif ( $this->item !== false ) { |
| 346 | + return $this->item->getTitle(); |
| 347 | + } |
335 | 348 | 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 | + } |
338 | 359 | } |
339 | 360 | |
340 | 361 | /** |
— | — | @@ -370,7 +391,7 @@ |
371 | 392 | $keys = array_keys( $fields ); |
372 | 393 | $fields = array_combine( $keys, array_map( array( $this, 'handleKnownField' ), $keys, $fields ) ); |
373 | 394 | |
374 | | - /* EPDBObject */ $item = new $c( $fields, is_null( $fields['id'] ) ); |
| 395 | + /* EPPageObject */ $item = new $c( $fields, is_null( $fields['id'] ) ); |
375 | 396 | |
376 | 397 | foreach ( $unknownValues as $name => $value ) { |
377 | 398 | $this->handleUnknownField( $item, $name, $value ); |