Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | 'label-message' => 'educationprogram-org-edit-country', |
56 | 56 | 'maxlength' => 255, |
57 | 57 | 'required' => true, |
58 | | - 'options' => efEpGetCountryOptions( $this->getLanguage()->getCode() ), |
| 58 | + 'options' => EPUtils::getCountryOptions( $this->getLanguage()->getCode() ), |
59 | 59 | 'validation-callback' => array( $this, 'countryIsValid' ), |
60 | 60 | ); |
61 | 61 | |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | ); |
70 | 70 | break; |
71 | 71 | case 'country': |
72 | | - $countries = array_flip( efEpGetCountryOptions( $this->getLanguage()->getCode() ) ); |
| 72 | + $countries = array_flip( EPUtils::getCountryOptions( $this->getLanguage()->getCode() ) ); |
73 | 73 | $value = htmlspecialchars( $countries[$value] ); |
74 | 74 | break; |
75 | 75 | case 'courses': case 'students': case 'terms': |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | return array( |
124 | 124 | 'country' => array( |
125 | 125 | 'type' => 'select', |
126 | | - 'options' => efEpGetCountryOptions( $this->getLanguage()->getCode() ), |
| 126 | + 'options' => EPUtils::getCountryOptions( $this->getLanguage()->getCode() ), |
127 | 127 | 'value' => '' |
128 | 128 | ), |
129 | 129 | 'active' => array( |
Index: trunk/extensions/EducationProgram/includes/EPUtils.php |
— | — | @@ -13,6 +13,14 @@ |
14 | 14 | */ |
15 | 15 | class EPUtils { |
16 | 16 | |
| 17 | + /** |
| 18 | + * Create a log entry using the provided info. |
| 19 | + * Takes care about the logging interface changes in MediaWiki 1.19. |
| 20 | + * |
| 21 | + * @since 0.1 |
| 22 | + * |
| 23 | + * @param array $info |
| 24 | + */ |
17 | 25 | public static function log( array $info ) { |
18 | 26 | $user = array_key_exists( 'user', $info ) ? $info['user'] : $GLOBALS['wgUser']; |
19 | 27 | |
— | — | @@ -49,4 +57,32 @@ |
50 | 58 | } |
51 | 59 | } |
52 | 60 | |
| 61 | + /** |
| 62 | + * Returns a list of country names that can be used by |
| 63 | + * a select input localized in the lang of which the code is provided. |
| 64 | + * |
| 65 | + * @since 0.1 |
| 66 | + * |
| 67 | + * @param string $langCode |
| 68 | + * |
| 69 | + * @return array |
| 70 | + */ |
| 71 | + public static function getCountryOptions( $langCode ) { |
| 72 | + $countries = CountryNames::getNames( $langCode ); |
| 73 | + |
| 74 | + return array_merge( |
| 75 | + array( '' => '' ), |
| 76 | + array_combine( |
| 77 | + array_map( |
| 78 | + function( $value, $key ) { |
| 79 | + return $key . ' - ' . $value; |
| 80 | + } , |
| 81 | + array_values( $countries ), |
| 82 | + array_keys( $countries ) |
| 83 | + ), |
| 84 | + array_keys( $countries ) |
| 85 | + ) |
| 86 | + ); |
| 87 | + } |
| 88 | + |
53 | 89 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -358,22 +358,3 @@ |
359 | 359 | |
360 | 360 | # The default value for the user preferences. |
361 | 361 | $wgDefaultUserOptions['ep_showtoplink'] = false; |
362 | | - |
363 | | -// TODO: put somewhere decent + document |
364 | | -function efEpGetCountryOptions( $langCode ) { |
365 | | - $countries = CountryNames::getNames( $langCode ); |
366 | | - |
367 | | - return array_merge( |
368 | | - array( '' => '' ), |
369 | | - array_combine( |
370 | | - array_map( |
371 | | - function( $value, $key ) { |
372 | | - return $key . ' - ' . $value; |
373 | | - } , |
374 | | - array_values( $countries ), |
375 | | - array_keys( $countries ) |
376 | | - ), |
377 | | - array_keys( $countries ) |
378 | | - ) |
379 | | - ); |
380 | | -} |
\ No newline at end of file |