Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
— | — | @@ -279,7 +279,10 @@ |
280 | 280 | */ |
281 | 281 | public function handleSubmission( array $data ) { |
282 | 282 | $fields = array(); |
| 283 | + $unknownValues = array(); |
283 | 284 | |
| 285 | + $c = $this->itemClass; // Yeah, this is needed in PHP 5.3 >_> |
| 286 | + |
284 | 287 | foreach ( $data as $name => $value ) { |
285 | 288 | $matches = array(); |
286 | 289 | |
— | — | @@ -288,13 +291,22 @@ |
289 | 292 | $value = null; |
290 | 293 | } |
291 | 294 | |
292 | | - $fields[$matches[1]] = $value; |
| 295 | + if ( $c::canHasField( $matches[1] ) ) { |
| 296 | + $fields[$matches[1]] = $value; |
| 297 | + } |
| 298 | + else { |
| 299 | + $unknownValues[$matches[1]] = $value; |
| 300 | + } |
293 | 301 | } |
294 | 302 | } |
295 | 303 | |
296 | | - $c = $this->itemClass; // Yeah, this is needed in PHP 5.3 >_> |
| 304 | + |
297 | 305 | /* EPDBObject */ $item = new $c( $fields, is_null( $fields['id'] ) ); |
298 | 306 | |
| 307 | + foreach ( $unknownValues as $name => $value ) { |
| 308 | + |
| 309 | + } |
| 310 | + |
299 | 311 | $success = $item->writeToDB(); |
300 | 312 | |
301 | 313 | if ( $success ) { |
— | — | @@ -305,4 +317,17 @@ |
306 | 318 | } |
307 | 319 | } |
308 | 320 | |
| 321 | + /** |
| 322 | + * Gets called for evey unknown submitted value, so they can be dealth with if needed. |
| 323 | + * |
| 324 | + * @since 0.1 |
| 325 | + * |
| 326 | + * @param EPDBObject $item |
| 327 | + * @param string $name |
| 328 | + * @param string $value This is a string, since it comes from request data, but might be a number or other type. |
| 329 | + */ |
| 330 | + protected function handleUnknownField( EPDBObject $item, $name, $value ) { |
| 331 | + // Override to use. |
| 332 | + } |
| 333 | + |
309 | 334 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialEditCourse.php |
— | — | @@ -35,19 +35,19 @@ |
36 | 36 | 'label-message' => 'ep-course-edit-name', |
37 | 37 | 'required' => true, |
38 | 38 | 'validation-callback' => function ( $value, array $alldata = null ) { |
39 | | - return strlen( $value ) < 5 ? wfMsg( 'ep-course-invalid-name' ) : true; |
| 39 | + return strlen( $value ) < 5 ? wfMsgExt( 'ep-course-invalid-name', 'parsemag', 5 ) : true; |
40 | 40 | }, |
41 | 41 | ); |
42 | 42 | |
43 | 43 | $orgOptions = EPOrg::getOrgOptions( EPOrg::getEditableOrgs( $this->getUser() ) ); |
44 | 44 | |
45 | | - $fields['org'] = array ( |
| 45 | + $fields['org_id'] = array ( |
46 | 46 | 'type' => 'select', |
47 | 47 | 'label-message' => 'ep-course-edit-org', |
48 | 48 | 'required' => true, |
49 | 49 | 'options' => $orgOptions, |
50 | | - 'validation-callback' => function ( $value, array $alldata = null ) { |
51 | | - return strlen( $value ) < 10 ? wfMsg( 'ep-course-invalid-description' ) : true; |
| 50 | + 'validation-callback' => function ( $value, array $alldata = null ) use ( $orgOptions ) { |
| 51 | + return in_array( (int)$value, array_values( $orgOptions ) ) ? true : wfMsg( 'ep-course-invalid-org' ); |
52 | 52 | }, |
53 | 53 | 'default' => array_shift( $orgOptions ) |
54 | 54 | ); |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | 'label-message' => 'ep-course-edit-description', |
59 | 59 | 'required' => true, |
60 | 60 | 'validation-callback' => function ( $value, array $alldata = null ) { |
61 | | - return strlen( $value ) < 10 ? wfMsg( 'ep-course-invalid-description' ) : true; |
| 61 | + return strlen( $value ) < 10 ? wfMsgExt( 'ep-course-invalid-description', 'parsemag', 10 ) : true; |
62 | 62 | }, |
63 | 63 | 'default' => '', |
64 | 64 | 'rows' => 5 |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -114,6 +114,10 @@ |
115 | 115 | 'ep-course-edit-org' => 'Institution', |
116 | 116 | 'ep-course-edit-description' => 'Description', |
117 | 117 | |
| 118 | + 'ep-course-invalid-name' => 'This name is to short. It needs to be at least contain $1 {{PLURAL:$1|character|characters}}.', |
| 119 | + 'ep-course-invalid-description' => 'This description is to short. It needs to be at least contain $1 {{PLURAL:$1|character|characters}}.', |
| 120 | + 'ep-course-invalid-org' => 'This institution does not exist', |
| 121 | + |
118 | 122 | ); |
119 | 123 | |
120 | 124 | /** Message documentation (Message documentation) |