Index: trunk/extensions/wikihiero/wikihiero.body.php |
— | — | @@ -150,39 +150,40 @@ |
151 | 151 | } |
152 | 152 | $glyph = $this->extractCode( $glyph ); |
153 | 153 | if ( $glyph == ".." ) { // Render void block |
154 | | - $width = WH_HEIGHT; |
155 | | - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
| 154 | + $width = WH_HEIGHT; |
| 155 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
156 | 156 | } |
157 | 157 | elseif ( $glyph == "." ) // Render half-width void block |
158 | 158 | { |
159 | | - $width = WH_HEIGHT / 2; |
160 | | - return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
| 159 | + $width = WH_HEIGHT / 2; |
| 160 | + return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
161 | 161 | } |
162 | 162 | elseif ( $glyph == '<' ) // Render open cartouche |
163 | 163 | { |
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 ) . "' />"; |
167 | 167 | } |
168 | 168 | elseif ( $glyph == '>' ) // Render close cartouche |
169 | 169 | { |
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 ) . "' />"; |
173 | 173 | } |
174 | 174 | |
175 | 175 | if ( array_key_exists( $glyph, self::$phonemes ) ) |
176 | 176 | { |
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 ); |
182 | 187 | } |
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 ); |
187 | 188 | } |
188 | 189 | |
189 | 190 | private function isMirrored( $glyph ) { |
— | — | @@ -208,7 +209,7 @@ |
209 | 210 | if ( array_key_exists( $item, self::$phonemes ) ) { |
210 | 211 | $glyph = self::$phonemes[$item]; |
211 | 212 | } else { |
212 | | - $glyph = $item; |
| 213 | + $glyph = $item; |
213 | 214 | } |
214 | 215 | |
215 | 216 | $margin = 2 * WH_IMG_MARGIN; |
— | — | @@ -246,20 +247,20 @@ |
247 | 248 | public function renderText( $hiero, $line = false ) { |
248 | 249 | $html = ""; |
249 | 250 | |
250 | | - if ( $line ) |
251 | | - $html .= "<hr />\n"; |
| 251 | + if ( $line ) { |
| 252 | + $html .= "<hr />\n"; |
| 253 | + } |
252 | 254 | |
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 | + } |
264 | 265 | } |
265 | 266 | |
266 | 267 | return $html; |
— | — | @@ -274,13 +275,14 @@ |
275 | 276 | * @return string: converted code |
276 | 277 | */ |
277 | 278 | 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 | + } |
280 | 282 | |
281 | 283 | $html = ""; |
282 | 284 | |
283 | 285 | if ( $line ) { |
284 | | - $html .= "<hr />\n"; |
| 286 | + $html .= "<hr />\n"; |
285 | 287 | } |
286 | 288 | |
287 | 289 | // ------------------------------------------------------------------------ |
— | — | @@ -312,7 +314,7 @@ |
313 | 315 | $type = WH_TYPE_NONE; |
314 | 316 | } |
315 | 317 | } |
316 | | - } else {// don't slit block if inside parenthesis |
| 318 | + } else {// don't split block if inside parenthesis |
317 | 319 | if ( $hiero[$char] == '-' ) { |
318 | 320 | $item_id++; |
319 | 321 | $block[$block_id][$item_id] = '-'; |
— | — | @@ -392,7 +394,7 @@ |
393 | 395 | $is_cartouche = false; |
394 | 396 | $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
395 | 397 | |
396 | | - } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.' |
| 398 | + } elseif ( $code[0] != "" ) { // assume it's a glyph or '..' or '.' |
397 | 399 | $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "'"; |
398 | 400 | |
399 | 401 | $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E; |