Index: trunk/extensions/wikihiero/wikihiero.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | 'name' => 'WikiHiero', |
34 | 34 | 'version' => WIKIHIERO_VERSION, |
35 | 35 | 'author' => array( 'Guillaume Blanchard', 'Max Semenik' ), |
36 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiHiero', |
| 36 | + 'url' => '//www.mediawiki.org/wiki/Extension:WikiHiero', |
37 | 37 | 'descriptionmsg' => 'wikihiero-desc', |
38 | 38 | ); |
39 | 39 | |
Index: trunk/extensions/wikihiero/SpecialHieroglyphs.php |
— | — | @@ -48,16 +48,16 @@ |
49 | 49 | $out = $this->getContext()->getOutput(); |
50 | 50 | $out->addModules( 'ext.wikihiero.Special' ); |
51 | 51 | $out->addWikiMsg( 'wikihiero-special-page-text' ); |
52 | | - |
| 52 | + |
53 | 53 | $out->addHTML( '<div id="hiero-result">' ); |
54 | 54 | |
55 | 55 | $text = trim( $this->getContext()->getRequest()->getVal( 'text', '' ) ); |
56 | 56 | if ( $text !== '' ) { |
57 | 57 | $hiero = new WikiHiero(); |
58 | 58 | $out->addHTML( '<table class="wikitable">' |
59 | | - . '<tr><th>' . wfMsg( 'wikihiero-input' ) . '</th><th>' |
| 59 | + . '<tr><th>' . wfMsg( 'wikihiero-input' ) . '</th><th>' |
60 | 60 | . wfMsg( 'wikihiero-result' ) . '</th></tr>' |
61 | | - . '<tr><td><code><hiero>' . nl2br( htmlspecialchars( $text ) ) |
| 61 | + . '<tr><td><code><hiero>' . nl2br( htmlspecialchars( $text ) ) |
62 | 62 | . "</hiero></code></td><td>{$hiero->render( $text )}</td></tr></table>" |
63 | 63 | ); |
64 | 64 | } |
Index: trunk/extensions/wikihiero/generateTables.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | |
39 | 39 | $this->moreTables = str_replace( "\r", '', $this->moreTables ); |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | public function execute() { |
43 | 43 | if ( !defined( 'WIKIHIERO_VERSION' ) ) { |
44 | 44 | $this->error( "Please install WikiHiero first!\n", true ); |
Index: trunk/extensions/wikihiero/wikihiero.body.php |
— | — | @@ -231,7 +231,7 @@ |
232 | 232 | |
233 | 233 | } elseif ( strchr( $code[0], '>' ) ) { // end cartouche |
234 | 234 | $contentHtml .= "</tr></table></td></tr><tr><td class='mw-hiero-box' style='height: " |
235 | | - . intval( self::CARTOUCHE_WIDTH * $this->scale / 100 ) |
| 235 | + . intval( self::CARTOUCHE_WIDTH * $this->scale / 100 ) |
236 | 236 | . "px;'></td></tr>" . '</table></td>'; |
237 | 237 | $is_cartouche = false; |
238 | 238 | $contentHtml .= '<td>' . $this->renderGlyph( $code[0] ) . '</td>'; |
— | — | @@ -244,7 +244,6 @@ |
245 | 245 | |
246 | 246 | // block contains more than 1 glyph |
247 | 247 | } else { |
248 | | - |
249 | 248 | // convert all codes into '&' to test prefabs glyph |
250 | 249 | $temp = ""; |
251 | 250 | foreach ( $code as $t ) { |
— | — | @@ -255,70 +254,70 @@ |
256 | 255 | } |
257 | 256 | } |
258 | 257 | |
259 | | - // test if block exists in the prefabs list |
260 | | - if ( in_array( $temp, self::$prefabs ) ) { |
261 | | - $option = "height: " . $this->resizeGlyph( $temp, $is_cartouche ) . "px;"; |
| 258 | + // test if block exists in the prefabs list |
| 259 | + if ( in_array( $temp, self::$prefabs ) ) { |
| 260 | + $option = "height: " . $this->resizeGlyph( $temp, $is_cartouche ) . "px;"; |
262 | 261 | |
263 | | - $contentHtml .= '<td>' . $this->renderGlyph( $temp, $option ) . '</td>'; |
| 262 | + $contentHtml .= '<td>' . $this->renderGlyph( $temp, $option ) . '</td>'; |
264 | 263 | |
265 | | - // block must be manually computed |
266 | | - } else { |
267 | | - // get block total height |
268 | | - $line_max = 0; |
269 | | - $total = 0; |
270 | | - $height = 0; |
| 264 | + // block must be manually computed |
| 265 | + } else { |
| 266 | + // get block total height |
| 267 | + $line_max = 0; |
| 268 | + $total = 0; |
| 269 | + $height = 0; |
271 | 270 | |
272 | | - foreach ( $code as $t ) { |
273 | | - if ( $t == ":" ) { |
274 | | - if ( $height > $line_max ) { |
275 | | - $line_max = $height; |
276 | | - } |
277 | | - $total += $line_max; |
278 | | - $line_max = 0; |
| 271 | + foreach ( $code as $t ) { |
| 272 | + if ( $t == ":" ) { |
| 273 | + if ( $height > $line_max ) { |
| 274 | + $line_max = $height; |
| 275 | + } |
| 276 | + $total += $line_max; |
| 277 | + $line_max = 0; |
279 | 278 | |
280 | | - } elseif ( $t == "*" ) { |
281 | | - if ( $height > $line_max ) { |
282 | | - $line_max = $height; |
283 | | - } |
284 | | - } else { |
285 | | - if ( array_key_exists( $t, self::$phonemes ) ) { |
286 | | - $glyph = self::$phonemes[$t]; |
| 279 | + } elseif ( $t == "*" ) { |
| 280 | + if ( $height > $line_max ) { |
| 281 | + $line_max = $height; |
| 282 | + } |
287 | 283 | } else { |
288 | | - $glyph = $t; |
| 284 | + if ( array_key_exists( $t, self::$phonemes ) ) { |
| 285 | + $glyph = self::$phonemes[$t]; |
| 286 | + } else { |
| 287 | + $glyph = $t; |
| 288 | + } |
| 289 | + if ( array_key_exists( $glyph, self::$files ) ) { |
| 290 | + $height = 2 + self::$files[$glyph][1]; |
| 291 | + } |
289 | 292 | } |
290 | | - if ( array_key_exists( $glyph, self::$files ) ) { |
291 | | - $height = 2 + self::$files[$glyph][1]; |
292 | | - } |
| 293 | + } // end foreach |
| 294 | + |
| 295 | + if ( $height > $line_max ) { |
| 296 | + $line_max = $height; |
293 | 297 | } |
294 | | - } // end foreach |
295 | 298 | |
296 | | - if ( $height > $line_max ) { |
297 | | - $line_max = $height; |
298 | | - } |
| 299 | + $total += $line_max; |
299 | 300 | |
300 | | - $total += $line_max; |
| 301 | + // render all glyph into the block |
| 302 | + $temp = ""; |
| 303 | + foreach ( $code as $t ) { |
301 | 304 | |
302 | | - // render all glyph into the block |
303 | | - $temp = ""; |
304 | | - foreach ( $code as $t ) { |
| 305 | + if ( $t == ":" ) { |
| 306 | + $temp .= "<br />"; |
305 | 307 | |
306 | | - if ( $t == ":" ) { |
307 | | - $temp .= "<br />"; |
| 308 | + } elseif ( $t == "*" ) { |
| 309 | + $temp .= " "; |
308 | 310 | |
309 | | - } elseif ( $t == "*" ) { |
310 | | - $temp .= " "; |
| 311 | + } else { |
| 312 | + // resize the glyph according to the block total height |
| 313 | + $option = "height: " . $this->resizeGlyph( $t, $is_cartouche, $total ) . "px;"; |
| 314 | + $temp .= $this->renderGlyph( $t, $option ); |
| 315 | + } |
| 316 | + } // end foreach |
311 | 317 | |
312 | | - } else { |
313 | | - // resize the glyph according to the block total height |
314 | | - $option = "height: " . $this->resizeGlyph( $t, $is_cartouche, $total ) . "px;"; |
315 | | - $temp .= $this->renderGlyph( $t, $option ); |
316 | | - } |
317 | | - } // end foreach |
318 | | - |
319 | | - $contentHtml .= '<td>' . $temp . '</td>'; |
| 318 | + $contentHtml .= '<td>' . $temp . '</td>'; |
| 319 | + } |
| 320 | + $contentHtml .= "\n"; |
320 | 321 | } |
321 | | - $contentHtml .= "\n"; |
322 | | - } |
323 | 322 | |
324 | 323 | if ( strlen( $contentHtml ) > 0 ) { |
325 | 324 | $tableContentHtml .= $tableHtml . $contentHtml; |
— | — | @@ -377,7 +376,7 @@ |
378 | 377 | /** |
379 | 378 | * Constructor |
380 | 379 | * |
381 | | - * @param $text string: |
| 380 | + * @param $text string: |
382 | 381 | */ |
383 | 382 | public function __construct( $text ) { |
384 | 383 | $this->text = $text; |
— | — | @@ -396,7 +395,7 @@ |
397 | 396 | |
398 | 397 | /** |
399 | 398 | * Split text into blocks, then split blocks into items |
400 | | - * |
| 399 | + * |
401 | 400 | * @return array: tokenized text |
402 | 401 | */ |
403 | 402 | public function tokenize() { |
— | — | @@ -406,7 +405,7 @@ |
407 | 406 | $this->blocks = array(); |
408 | 407 | $this->currentBlock = array(); |
409 | 408 | $this->token = ''; |
410 | | - |
| 409 | + |
411 | 410 | $text = preg_replace( '/\\<!--.*?--\\>/s', '', $this->text ); // remove HTML comments |
412 | 411 | |
413 | 412 | for ( $i = 0; $i < strlen( $text ); $i++ ) { |
— | — | @@ -435,7 +434,7 @@ |
436 | 435 | */ |
437 | 436 | private function newBlock() { |
438 | 437 | $this->newToken(); |
439 | | - if( $this->currentBlock ) { |
| 438 | + if ( $this->currentBlock ) { |
440 | 439 | $this->blocks[] = $this->currentBlock; |
441 | 440 | $this->currentBlock = array(); |
442 | 441 | } |