r104352 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104351‎ | r104352 | r104353 >
Date:17:53, 27 November 2011
Author:maxsem
Status:ok
Tags:
Comment:
WikiHiero:
* Use protocol-relative URL in $wgExtensionCredits
* Ran stylize.php
* Fixed indentation
Modified paths:
  • /trunk/extensions/wikihiero/SpecialHieroglyphs.php (modified) (history)
  • /trunk/extensions/wikihiero/generateTables.php (modified) (history)
  • /trunk/extensions/wikihiero/wikihiero.body.php (modified) (history)
  • /trunk/extensions/wikihiero/wikihiero.php (modified) (history)

Diff [purge]

Index: trunk/extensions/wikihiero/wikihiero.php
@@ -32,7 +32,7 @@
3333 'name' => 'WikiHiero',
3434 'version' => WIKIHIERO_VERSION,
3535 'author' => array( 'Guillaume Blanchard', 'Max Semenik' ),
36 - 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiHiero',
 36+ 'url' => '//www.mediawiki.org/wiki/Extension:WikiHiero',
3737 'descriptionmsg' => 'wikihiero-desc',
3838 );
3939
Index: trunk/extensions/wikihiero/SpecialHieroglyphs.php
@@ -48,16 +48,16 @@
4949 $out = $this->getContext()->getOutput();
5050 $out->addModules( 'ext.wikihiero.Special' );
5151 $out->addWikiMsg( 'wikihiero-special-page-text' );
52 -
 52+
5353 $out->addHTML( '<div id="hiero-result">' );
5454
5555 $text = trim( $this->getContext()->getRequest()->getVal( 'text', '' ) );
5656 if ( $text !== '' ) {
5757 $hiero = new WikiHiero();
5858 $out->addHTML( '<table class="wikitable">'
59 - . '<tr><th>' . wfMsg( 'wikihiero-input' ) . '</th><th>'
 59+ . '<tr><th>' . wfMsg( 'wikihiero-input' ) . '</th><th>'
6060 . wfMsg( 'wikihiero-result' ) . '</th></tr>'
61 - . '<tr><td><code>&lt;hiero&gt;' . nl2br( htmlspecialchars( $text ) )
 61+ . '<tr><td><code>&lt;hiero&gt;' . nl2br( htmlspecialchars( $text ) )
6262 . "&lt;/hiero&gt;</code></td><td>{$hiero->render( $text )}</td></tr></table>"
6363 );
6464 }
Index: trunk/extensions/wikihiero/generateTables.php
@@ -37,7 +37,7 @@
3838
3939 $this->moreTables = str_replace( "\r", '', $this->moreTables );
4040 }
41 -
 41+
4242 public function execute() {
4343 if ( !defined( 'WIKIHIERO_VERSION' ) ) {
4444 $this->error( "Please install WikiHiero first!\n", true );
Index: trunk/extensions/wikihiero/wikihiero.body.php
@@ -231,7 +231,7 @@
232232
233233 } elseif ( strchr( $code[0], '>' ) ) { // end cartouche
234234 $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 )
236236 . "px;'></td></tr>" . '</table></td>';
237237 $is_cartouche = false;
238238 $contentHtml .= '<td>' . $this->renderGlyph( $code[0] ) . '</td>';
@@ -244,7 +244,6 @@
245245
246246 // block contains more than 1 glyph
247247 } else {
248 -
249248 // convert all codes into '&' to test prefabs glyph
250249 $temp = "";
251250 foreach ( $code as $t ) {
@@ -255,70 +254,70 @@
256255 }
257256 }
258257
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;";
262261
263 - $contentHtml .= '<td>' . $this->renderGlyph( $temp, $option ) . '</td>';
 262+ $contentHtml .= '<td>' . $this->renderGlyph( $temp, $option ) . '</td>';
264263
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;
271270
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;
279278
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+ }
287283 } 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+ }
289292 }
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;
293297 }
294 - } // end foreach
295298
296 - if ( $height > $line_max ) {
297 - $line_max = $height;
298 - }
 299+ $total += $line_max;
299300
300 - $total += $line_max;
 301+ // render all glyph into the block
 302+ $temp = "";
 303+ foreach ( $code as $t ) {
301304
302 - // render all glyph into the block
303 - $temp = "";
304 - foreach ( $code as $t ) {
 305+ if ( $t == ":" ) {
 306+ $temp .= "<br />";
305307
306 - if ( $t == ":" ) {
307 - $temp .= "<br />";
 308+ } elseif ( $t == "*" ) {
 309+ $temp .= " ";
308310
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
311317
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";
320321 }
321 - $contentHtml .= "\n";
322 - }
323322
324323 if ( strlen( $contentHtml ) > 0 ) {
325324 $tableContentHtml .= $tableHtml . $contentHtml;
@@ -377,7 +376,7 @@
378377 /**
379378 * Constructor
380379 *
381 - * @param $text string:
 380+ * @param $text string:
382381 */
383382 public function __construct( $text ) {
384383 $this->text = $text;
@@ -396,7 +395,7 @@
397396
398397 /**
399398 * Split text into blocks, then split blocks into items
400 - *
 399+ *
401400 * @return array: tokenized text
402401 */
403402 public function tokenize() {
@@ -406,7 +405,7 @@
407406 $this->blocks = array();
408407 $this->currentBlock = array();
409408 $this->token = '';
410 -
 409+
411410 $text = preg_replace( '/\\<!--.*?--\\>/s', '', $this->text ); // remove HTML comments
412411
413412 for ( $i = 0; $i < strlen( $text ); $i++ ) {
@@ -435,7 +434,7 @@
436435 */
437436 private function newBlock() {
438437 $this->newToken();
439 - if( $this->currentBlock ) {
 438+ if ( $this->currentBlock ) {
440439 $this->blocks[] = $this->currentBlock;
441440 $this->currentBlock = array();
442441 }

Status & tagging log