r96689 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96688‎ | r96689 | r96690 >
Date:20:17, 9 September 2011
Author:maxsem
Status:ok
Tags:
Comment:
Indentation, braces and comment typos
Modified paths:
  • /trunk/extensions/wikihiero/wikihiero.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/wikihiero/wikihiero.body.php
@@ -150,39 +150,40 @@
151151 }
152152 $glyph = $this->extractCode( $glyph );
153153 if ( $glyph == ".." ) { // Render void block
154 - $width = WH_HEIGHT;
155 - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td>&#160;</td></tr></table>";
 154+ $width = WH_HEIGHT;
 155+ return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td>&#160;</td></tr></table>";
156156 }
157157 elseif ( $glyph == "." ) // Render half-width void block
158158 {
159 - $width = WH_HEIGHT / 2;
160 - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td>&#160;</td></tr></table>";
 159+ $width = WH_HEIGHT / 2;
 160+ return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td>&#160;</td></tr></table>";
161161 }
162162 elseif ( $glyph == '<' ) // Render open cartouche
163163 {
164 - $height = intval( WH_HEIGHT * $this->scale / 100 );
165 - $code = self::$phonemes[$glyph];
166 - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 164+ $height = intval( WH_HEIGHT * $this->scale / 100 );
 165+ $code = self::$phonemes[$glyph];
 166+ return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
167167 }
168168 elseif ( $glyph == '>' ) // Render close cartouche
169169 {
170 - $height = intval( WH_HEIGHT * $this->scale / 100 );
171 - $code = self::$phonemes[$glyph];
172 - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 170+ $height = intval( WH_HEIGHT * $this->scale / 100 );
 171+ $code = self::$phonemes[$glyph];
 172+ return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
173173 }
174174
175175 if ( array_key_exists( $glyph, self::$phonemes ) )
176176 {
177 - $code = self::$phonemes[$glyph];
178 - if ( array_key_exists( $code, self::$files ) )
179 - return "<img {$imageClass}style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
180 - else
181 - return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>";
 177+ $code = self::$phonemes[$glyph];
 178+ if ( array_key_exists( $code, self::$files ) ) {
 179+ return "<img {$imageClass}style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 180+ } else {
 181+ return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>";
 182+ }
 183+ } elseif ( array_key_exists( $glyph, self::$files ) ) {
 184+ return "<img {$imageClass}style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$glyph}." . self::IMG_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 185+ } else {
 186+ return htmlspecialchars( $glyph );
182187 }
183 - elseif ( array_key_exists( $glyph, self::$files ) )
184 - return "<img {$imageClass}style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$glyph}." . self::IMG_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
185 - else
186 - return htmlspecialchars( $glyph );
187188 }
188189
189190 private function isMirrored( $glyph ) {
@@ -208,7 +209,7 @@
209210 if ( array_key_exists( $item, self::$phonemes ) ) {
210211 $glyph = self::$phonemes[$item];
211212 } else {
212 - $glyph = $item;
 213+ $glyph = $item;
213214 }
214215
215216 $margin = 2 * WH_IMG_MARGIN;
@@ -246,20 +247,20 @@
247248 public function renderText( $hiero, $line = false ) {
248249 $html = "";
249250
250 - if ( $line )
251 - $html .= "<hr />\n";
 251+ if ( $line ) {
 252+ $html .= "<hr />\n";
 253+ }
252254
253 - for ( $char = 0; $char < strlen( $hiero ); $char++ )
254 - {
255 - if ( array_key_exists( $hiero[$char], self::$textConv ) )
256 - {
257 - $html .= self::$textConv[$hiero[$char]];
258 - if ( $hiero[$char] == '!' )
259 - if ( $line )
260 - $html .= "<hr />\n";
261 - }
262 - else
263 - $html .= $hiero[$char];
 255+ for ( $char = 0; $char < strlen( $hiero ); $char++ ) {
 256+ if ( array_key_exists( $hiero[$char], self::$textConv ) ) {
 257+ $html .= self::$textConv[$hiero[$char]];
 258+ if ( $hiero[$char] == '!' && $line ) {
 259+ $html .= "<hr />\n";
 260+ }
 261+ }
 262+ else {
 263+ $html .= $hiero[$char];
 264+ }
264265 }
265266
266267 return $html;
@@ -274,13 +275,14 @@
275276 * @return string: converted code
276277 */
277278 public function renderHtml( $hiero, $scale = WH_SCALE_DEFAULT, $line = false ) {
278 - if ( $scale != WH_SCALE_DEFAULT )
279 - $this->setScale( $scale );
 279+ if ( $scale != WH_SCALE_DEFAULT ) {
 280+ $this->setScale( $scale );
 281+ }
280282
281283 $html = "";
282284
283285 if ( $line ) {
284 - $html .= "<hr />\n";
 286+ $html .= "<hr />\n";
285287 }
286288
287289 // ------------------------------------------------------------------------
@@ -312,7 +314,7 @@
313315 $type = WH_TYPE_NONE;
314316 }
315317 }
316 - } else {// don't slit block if inside parenthesis
 318+ } else {// don't split block if inside parenthesis
317319 if ( $hiero[$char] == '-' ) {
318320 $item_id++;
319321 $block[$block_id][$item_id] = '-';
@@ -392,7 +394,7 @@
393395 $is_cartouche = false;
394396 $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E;
395397
396 - } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.'
 398+ } elseif ( $code[0] != "" ) { // assume it's a glyph or '..' or '.'
397399 $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "'";
398400
399401 $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E;

Status & tagging log