Index: trunk/extensions/Hanp/Hanp.body.php |
— | — | @@ -1,20 +1,32 @@ |
2 | 2 | <?php |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
| 4 | + |
3 | 5 | class Hanp { |
4 | 6 | |
5 | 7 | /** |
6 | | - * {{#hanp:word|particle}} |
| 8 | + * {{#hanp:word|particle|output}} |
7 | 9 | */ |
8 | | - static function hangulParticle( $parser, $word = '', $particle = '') { |
9 | | - switch ($particle) { |
| 10 | + static function hangulParticle( $parser, $word = '', $particle = '', $output = '' ) { |
10 | 11 | |
| 12 | + /** |
| 13 | + * Initialization of $output parameter |
| 14 | + * This parameter used if $word contains signs not read |
| 15 | + * For example: {{#hanp:Wikimedia|particle|[[Wikimedia]]}} |
| 16 | + */ |
| 17 | + if ( $output == '' ) { |
| 18 | + $output = $word; |
| 19 | + } |
| 20 | + |
| 21 | + switch ( $particle ) { |
| 22 | + |
11 | 23 | case '로': # ro |
12 | 24 | case '으로': # euro |
13 | | - if ( self::endsInHangulRieul($word) ) { |
14 | | - return $word . '로'; |
15 | | - } elseif ( self::endsInHangulConsonant($word) ) { |
16 | | - return $word . '으로'; |
| 25 | + if ( self::endsInHangulRieul( $word ) ) { |
| 26 | + return $output . '로'; |
| 27 | + } elseif ( self::endsInHangulConsonant( $word ) ) { |
| 28 | + return $output . '으로'; |
17 | 29 | } else { |
18 | | - return $word . '로'; // Vowel or non-hangul |
| 30 | + return $output . '로'; // Vowel or non-hangul |
19 | 31 | } |
20 | 32 | break; |
21 | 33 | |
— | — | @@ -26,19 +38,14 @@ |
27 | 39 | case '가': # ga |
28 | 40 | case '과': # gwa |
29 | 41 | case '는': # neun |
30 | | - if ( self::endsInHangulConsonant($word) ) { |
31 | | - return $word . self::particleMap( $particle, self::SOFT ); |
| 42 | + if ( self::endsInHangulConsonant( $word ) ) { |
| 43 | + return $output . self::particleMap( $particle, self::SOFT ); |
32 | 44 | } else { |
33 | | - return $word . self::particleMap( $particle, self::HARD ); |
| 45 | + return $output . self::particleMap( $particle, self::HARD ); |
34 | 46 | } |
35 | 47 | break; |
36 | 48 | |
37 | | - case '의': # yi |
38 | | - return $word . $particle; |
39 | | - break; |
40 | | - |
41 | | - default: return $word; |
42 | | - |
| 49 | + default: return $output . $particle; |
43 | 50 | } |
44 | 51 | } |
45 | 52 | |
— | — | @@ -60,7 +67,7 @@ |
61 | 68 | |
62 | 69 | if ( $dir === self::SOFT ) $map = array_flip( $map ); |
63 | 70 | |
64 | | - if ( isset($map[$particle]) ) { |
| 71 | + if ( isset( $map[$particle] ) ) { |
65 | 72 | return $map[$particle]; |
66 | 73 | } else { |
67 | 74 | return $particle; # We want only valid input, so it is already correct |
— | — | @@ -113,4 +120,4 @@ |
114 | 121 | return self::endsInHangul( $string ) && !self::endsInHangulVowel( $string ); |
115 | 122 | } |
116 | 123 | |
117 | | -} |
\ No newline at end of file |
| 124 | +} |
Index: trunk/extensions/Hanp/Hanp.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | /** |
5 | 5 | * This exension provides a parser function that aids in choosing the correct |
6 | 6 | * particle that is attached to the words. |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | 'descriptionmsg' => 'hanp-desc', |
22 | 22 | ); |
23 | 23 | |
24 | | -$dir = dirname(__FILE__) . '/'; |
| 24 | +$dir = dirname( __FILE__ ) . '/'; |
25 | 25 | $wgExtensionMessagesFiles['hanp'] = $dir . 'Hanp.i18n.php'; |
26 | 26 | $wgAutoloadClasses['Hanp'] = $dir . 'Hanp.body.php'; |
27 | 27 | $wgHooks['LanguageGetMagic'][] = 'efHanpLanguageGetMagic'; |