Index: trunk/extensions/wikihiero/wikihiero.php |
— | — | @@ -24,8 +24,10 @@ |
25 | 25 | // |
26 | 26 | ////////////////////////////////////////////////////////////////////////// |
27 | 27 | |
| 28 | +$wgHooks['ParserFirstCallInit'][] = 'wfRegisterWikiHiero'; |
| 29 | +$wgHooks['BeforePageDisplay'][] = 'wfHieroBeforePageDisplay'; |
| 30 | + |
28 | 31 | // Register MediaWiki extension |
29 | | -$wgHooks['ParserFirstCallInit'][] = 'wfRegisterWikiHiero'; |
30 | 32 | $wgExtensionCredits['parserhook'][] = array( |
31 | 33 | 'path' => __FILE__, |
32 | 34 | 'name' => 'WikiHiero', |
— | — | @@ -37,8 +39,20 @@ |
38 | 40 | |
39 | 41 | $wgAutoloadClasses['WikiHiero'] = dirname( __FILE__ ) . '/wh_main.php'; |
40 | 42 | |
| 43 | +$wgResourceModules['ext.wikihiero'] = array( |
| 44 | + 'styles' => 'ext.wikihiero.css', |
| 45 | + 'localBasePath' => dirname( __FILE__ ) . '/modules', |
| 46 | + 'remoteExtPath' => 'wikihiero/modules', |
| 47 | +); |
| 48 | + |
| 49 | +// Because <hiero> tag is used rarely, we don't need to load its body on every hook call, |
| 50 | +// so we keep our simple hook handlers here. |
41 | 51 | function wfRegisterWikiHiero( &$parser ) { |
42 | 52 | $parser->setHook( 'hiero', 'WikiHiero::parserHook' ); |
43 | 53 | return true; |
44 | 54 | } |
45 | 55 | |
| 56 | +function wfHieroBeforePageDisplay( $out ) { |
| 57 | + $out->addModuleStyles( 'ext.wikihiero' ); |
| 58 | + return true; |
| 59 | +} |
Index: trunk/extensions/wikihiero/modules/ext.wikihiero.css |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +.mw-hiero-table {
|
| 3 | + border: 0;
|
| 4 | + border-spacing: 0;
|
| 5 | +}
|
| 6 | +
|
| 7 | +.mw-hiero-pouter {
|
| 8 | + display: inline;
|
| 9 | +}
|
| 10 | +
|
| 11 | +.mw-hiero-table td {
|
| 12 | + padding: 0;
|
| 13 | + align: center;
|
| 14 | + vertical-align: middle;
|
| 15 | +}
|
Index: trunk/extensions/wikihiero/wh_main.php |
— | — | @@ -34,10 +34,10 @@ |
35 | 35 | |
36 | 36 | // ======================================================================== |
37 | 37 | // D E F I N E S |
38 | | -define( "WH_TABLE_S", "<table border='0' cellspacing='0' cellpadding='0'>" ); |
39 | | -define( "WH_TABLE_E", "</table>" ); |
40 | | -define( "WH_TD_S", "<td align='center' valign='middle'>" ); |
41 | | -define( "WH_TD_E", "</td>" ); |
| 38 | +define( "WH_TABLE_S", '<table class="mw-hiero-table">' ); |
| 39 | +define( "WH_TABLE_E", '</table>' ); |
| 40 | +define( "WH_TD_S", '<td>' ); |
| 41 | +define( "WH_TD_E", '</td>' ); |
42 | 42 | |
43 | 43 | define( "WH_MODE_DEFAULT", -1 ); // use default mode |
44 | 44 | define( "WH_MODE_TEXT", 0 ); // text only |
— | — | @@ -128,24 +128,24 @@ |
129 | 129 | |
130 | 130 | if ( $glyph == ".." ) { // Render void block |
131 | 131 | $width = WH_HEIGHT; |
132 | | - return "<table width='{$width}px' border='0' cellspacing='0' cellpadding='0'><tr><td> </td></tr></table>"; |
| 132 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
133 | 133 | } |
134 | 134 | elseif ( $glyph == "." ) // Render half-width void block |
135 | 135 | { |
136 | 136 | $width = WH_HEIGHT / 2; |
137 | | - return "<table width='{$width}px' border='0' cellspacing='0' cellpadding='0'><tr><td> </td></tr></table>"; |
| 137 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
138 | 138 | } |
139 | 139 | elseif ( $glyph == '<' ) // Render open cartouche |
140 | 140 | { |
141 | 141 | $height = intval( WH_HEIGHT * $this->scale / 100 ); |
142 | 142 | $code = $wh_phonemes[$glyph]; |
143 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}px' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 143 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
144 | 144 | } |
145 | 145 | elseif ( $glyph == '>' ) // Render close cartouche |
146 | 146 | { |
147 | 147 | $height = intval( WH_HEIGHT * $this->scale / 100 ); |
148 | 148 | $code = $wh_phonemes[$glyph]; |
149 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}px' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 149 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
150 | 150 | } |
151 | 151 | |
152 | 152 | if ( array_key_exists( $glyph, $wh_phonemes ) ) |
— | — | @@ -367,7 +367,7 @@ |
368 | 368 | $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
369 | 369 | |
370 | 370 | } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.' |
371 | | - $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "px'"; |
| 371 | + $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "'"; |
372 | 372 | |
373 | 373 | $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E; |
374 | 374 | } |
— | — | @@ -387,7 +387,7 @@ |
388 | 388 | |
389 | 389 | // test is block is into tje prefabs list |
390 | 390 | if ( in_array( $temp, $wh_prefabs ) ) { |
391 | | - $option = "height='" . $this->resizeGlyph( $temp, $is_cartouche ) . "px'"; |
| 391 | + $option = "height='" . $this->resizeGlyph( $temp, $is_cartouche ) . "'"; |
392 | 392 | |
393 | 393 | $contentHtml .= WH_TD_S . self::renderGlyph( $temp, $option ) . WH_TD_E; |
394 | 394 | |
— | — | @@ -440,7 +440,7 @@ |
441 | 441 | |
442 | 442 | } else { |
443 | 443 | // resize the glyph according to the block total height |
444 | | - $option = "height='" . $this->resizeGlyph( $t, $is_cartouche, $total ) . "px'"; |
| 444 | + $option = "height='" . $this->resizeGlyph( $t, $is_cartouche, $total ) . "'"; |
445 | 445 | $temp .= self::renderGlyph( $t, $option ); |
446 | 446 | } |
447 | 447 | } // end foreach |
— | — | @@ -460,7 +460,7 @@ |
461 | 461 | $html .= WH_TABLE_S . "<tr>\n" . $tableContentHtml . "</tr>" . WH_TABLE_E; |
462 | 462 | } |
463 | 463 | |
464 | | - return "<table border='0' cellspacing='0' cellpadding='0' style='display:inline;' class='mw-hierotable' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
| 464 | + return "<table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
465 | 465 | } |
466 | 466 | |
467 | 467 | } |