r97747 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97746‎ | r97747 | r97748 >
Date:17:04, 21 September 2011
Author:maxsem
Status:ok
Tags:
Comment:
* Got rid of remaining defines
* Removed unused parameter from constructor
Modified paths:
  • /trunk/extensions/wikihiero/wikihiero.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/wikihiero/wikihiero.body.php
@@ -27,16 +27,11 @@
2828 die( 'Not an entry point' );
2929 }
3030
31 -define( "WH_SCALE_DEFAULT", -1 ); // use default scale
32 -
33 -global $wgExtensionAssetsPath;
34 -define( "WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' );
35 -
36 -
3731 class WikiHiero {
3832 const IMAGE_EXT = 'png';
3933 const IMAGE_PREFIX = 'hiero_';
4034
 35+ const DEFAULT_SCALE = -1; // use default scale
4136 const CARTOUCHE_WIDTH = 2;
4237 const IMAGE_MARGIN = 1;
4338 const MAX_HEIGHT = 44;
@@ -47,7 +42,7 @@
4843
4944 private static $phonemes, $prefabs, $files;
5045
51 - public function __construct( $scale = WH_SCALE_DEFAULT ) {
 46+ public function __construct() {
5247 self::loadData();
5348 }
5449
@@ -117,23 +112,23 @@
118113 elseif ( $glyph == '<' ) { // Render open cartouche
119114 $height = intval( self::MAX_HEIGHT * $this->scale / 100 );
120115 $code = self::$phonemes[$glyph];
121 - return "<img src='" . htmlspecialchars( WH_IMG_DIR . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 116+ return "<img src='" . htmlspecialchars( self::getImagePath() . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
122117 }
123118 elseif ( $glyph == '>' ) { // Render close cartouche
124119 $height = intval( self::MAX_HEIGHT * $this->scale / 100 );
125120 $code = self::$phonemes[$glyph];
126 - return "<img src='" . htmlspecialchars( WH_IMG_DIR . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 121+ return "<img src='" . htmlspecialchars( self::getImagePath() . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
127122 }
128123
129124 if ( array_key_exists( $glyph, self::$phonemes ) ) {
130125 $code = self::$phonemes[$glyph];
131126 if ( array_key_exists( $code, self::$files ) ) {
132 - return "<img {$imageClass}style='margin:" . self::IMAGE_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 127+ return "<img {$imageClass}style='margin:" . self::IMAGE_MARGIN . "px;' $option src='" . htmlspecialchars( self::getImagePath() . self::IMAGE_PREFIX . "{$code}." . self::IMAGE_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
133128 } else {
134129 return htmlspecialchars( $glyph );
135130 }
136131 } elseif ( array_key_exists( $glyph, self::$files ) ) {
137 - return "<img {$imageClass}style='margin:" . self::IMAGE_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . self::IMAGE_PREFIX . "{$glyph}." . self::IMAGE_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
 132+ return "<img {$imageClass}style='margin:" . self::IMAGE_MARGIN . "px;' $option src='" . htmlspecialchars( self::getImagePath() . self::IMAGE_PREFIX . "{$glyph}." . self::IMAGE_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />";
138133 } else {
139134 return htmlspecialchars( $glyph );
140135 }
@@ -199,8 +194,8 @@
200195 * @param $line bool: use line (default = false)
201196 * @return string: converted code
202197 */
203 - public function render( $hiero, $scale = WH_SCALE_DEFAULT, $line = false ) {
204 - if ( $scale != WH_SCALE_DEFAULT ) {
 198+ public function render( $hiero, $scale = self::DEFAULT_SCALE, $line = false ) {
 199+ if ( $scale != self::DEFAULT_SCALE ) {
205200 $this->setScale( $scale );
206201 }
207202
@@ -350,7 +345,8 @@
351346 * @return string: URL of images directory
352347 */
353348 public static function getImagePath() {
354 - return WH_IMG_DIR;
 349+ global $wgExtensionAssetsPath;
 350+ return "$wgExtensionAssetsPath/wikihiero/img/";
355351 }
356352
357353 /**

Status & tagging log