r42700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42699‎ | r42700 | r42701 >
Date:23:47, 27 October 2008
Author:siebrand
Status:old
Tags:
Comment:
(bug 13712 / patch 5358 by Ficell) Add para 'output' to fix shortcoming of current code.
Modified paths:
  • /trunk/extensions/Hanp/Hanp.body.php (modified) (history)
  • /trunk/extensions/Hanp/Hanp.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Hanp/Hanp.body.php
@@ -1,20 +1,32 @@
22 <?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+
35 class Hanp {
46
57 /**
6 - * {{#hanp:word|particle}}
 8+ * {{#hanp:word|particle|output}}
79 */
8 - static function hangulParticle( $parser, $word = '', $particle = '') {
9 - switch ($particle) {
 10+ static function hangulParticle( $parser, $word = '', $particle = '', $output = '' ) {
1011
 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+
1123 case '로': # ro
1224 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 . '으로';
1729 } else {
18 - return $word . '로'; // Vowel or non-hangul
 30+ return $output . '로'; // Vowel or non-hangul
1931 }
2032 break;
2133
@@ -26,19 +38,14 @@
2739 case '가': # ga
2840 case '과': # gwa
2941 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 );
3244 } else {
33 - return $word . self::particleMap( $particle, self::HARD );
 45+ return $output . self::particleMap( $particle, self::HARD );
3446 }
3547 break;
3648
37 - case '의': # yi
38 - return $word . $particle;
39 - break;
40 -
41 - default: return $word;
42 -
 49+ default: return $output . $particle;
4350 }
4451 }
4552
@@ -60,7 +67,7 @@
6168
6269 if ( $dir === self::SOFT ) $map = array_flip( $map );
6370
64 - if ( isset($map[$particle]) ) {
 71+ if ( isset( $map[$particle] ) ) {
6572 return $map[$particle];
6673 } else {
6774 return $particle; # We want only valid input, so it is already correct
@@ -113,4 +120,4 @@
114121 return self::endsInHangul( $string ) && !self::endsInHangulVowel( $string );
115122 }
116123
117 -}
\ No newline at end of file
 124+}
Index: trunk/extensions/Hanp/Hanp.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44 /**
55 * This exension provides a parser function that aids in choosing the correct
66 * particle that is attached to the words.
@@ -20,7 +20,7 @@
2121 'descriptionmsg' => 'hanp-desc',
2222 );
2323
24 -$dir = dirname(__FILE__) . '/';
 24+$dir = dirname( __FILE__ ) . '/';
2525 $wgExtensionMessagesFiles['hanp'] = $dir . 'Hanp.i18n.php';
2626 $wgAutoloadClasses['Hanp'] = $dir . 'Hanp.body.php';
2727 $wgHooks['LanguageGetMagic'][] = 'efHanpLanguageGetMagic';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41088* A new extension requested in bug 13712nikerabbit07:26, 21 September 2008

Status & tagging log