Index: trunk/extensions/wikihiero/tests.txt |
— | — | @@ -52,3 +52,12 @@ |
53 | 53 | <table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td> <table class="mw-hiero-table"><tr> <td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_M23.png' title='M23' alt='M23' /></td><td><img style='margin:1px;' height='11' src='/extensions/wikihiero/img/hiero_X1.png' title='X1' alt='X1' /><br /><img style='margin:1px;' height='15' src='/extensions/wikihiero/img/hiero_R4.png' title='R4' alt='R4' /></td> <td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_X8.png' title='X8' alt='X8' /></td><td><img style='margin:1px;' height='24' src='/extensions/wikihiero/img/hiero_Q2.png' title='Q2' alt='Q2' /><br /><img style='margin:1px;' height='12' src='/extensions/wikihiero/img/hiero_D4.png' title='D4' alt='D4' /></td> <td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_W17.png' title='W17' alt='W17' /></td><td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_R14.png' title='R14' alt='R14' /></td><td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_G4.png' title='G4' alt='G4' /></td><td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_R8.png' title='R8' alt='R8' /></td><td><img style='margin:1px;' height='7' src='/extensions/wikihiero/img/hiero_O29.png' title='O29' alt='O29' /><br /><img style='margin:1px;' height='12' src='/extensions/wikihiero/img/hiero_V30.png' title='V30' alt='V30' /></td> <td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_U23.png' title='U23' alt='U23' /></td></tr></table><table class="mw-hiero-table"><tr> <td><img style='margin:1px;' height='15' src='/extensions/wikihiero/img/hiero_N26.png' title='N26' alt='N26' /></td><td><img style='margin:1px;' height='35' src='/extensions/wikihiero/img/hiero_D58.png' title='D58' alt='D58' /></td><td><img style='margin:1px;' height='18' src='/extensions/wikihiero/img/hiero_O49.png' title='O49' alt='O49' /><br /><img style='margin:1px;' height='16' src='/extensions/wikihiero/img/hiero_Z1.png' title='Z1' alt='Z1' /></td> <td><img style='margin:1px;' height='22' src='/extensions/wikihiero/img/hiero_F13.png' title='F13' alt='F13' /><br /><img style='margin:1px;' height='17' src='/extensions/wikihiero/img/hiero_N31.png' title='N31' alt='N31' /></td> <td><img style='margin:1px;' height='12' src='/extensions/wikihiero/img/hiero_V30.png' title='V30' alt='V30' /><br /><img style='margin:1px;' height='9' src='/extensions/wikihiero/img/hiero_N16.png' title='N16' alt='N16' /><br /><img style='margin:1px;' height='11' src='/extensions/wikihiero/img/hiero_N21.png' title='N21' alt='N21' /> <img style='margin:1px;' height='16' src='/extensions/wikihiero/img/hiero_Z1.png' title='Z1' alt='Z1' /></td> <td><img style='margin:1px;' height='24' src='/extensions/wikihiero/img/hiero_D45.png' title='D45' alt='D45' /><br /><img style='margin:1px;' height='16' src='/extensions/wikihiero/img/hiero_N25.png' title='N25' alt='N25' /></td> </tr></table> </td></tr></table> |
54 | 54 | |
55 | 55 | !! end |
| 56 | + |
| 57 | +!! test |
| 58 | +WikiHiero - image mirroring |
| 59 | +!! input |
| 60 | +<hiero>A1\-A1</hiero> |
| 61 | +!! result |
| 62 | +<table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td> <table class="mw-hiero-table"><tr> <td><img class="mw-mirrored" style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_A1.png' title='A1' alt='A1' /></td><td><img style='margin:1px;' height='38' src='/extensions/wikihiero/img/hiero_A1.png' title='A1' alt='A1' /></td></tr></table> </td></tr></table> |
| 63 | + |
| 64 | +!! end |
Index: trunk/extensions/wikihiero/SpecialHieroglyphs.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | array( 'code' => ':', 'message' => 'wikihiero-superposition', 'example' => 'p:t' ), |
29 | 29 | array( 'code' => ':', 'message' => 'wikihiero-juxtaposition', 'example' => 'p*t' ), |
30 | 30 | array( 'code' => '!', 'message' => 'wikihiero-eol', 'example' => 'A1-B1 ! C1-D1' ), |
| 31 | + array( 'code' => '\\', 'message' => 'wikihiero-mirror', 'example' => 'A1\-A1' ), |
31 | 32 | ); |
32 | 33 | private $helpColumns = array( |
33 | 34 | 'code', |
Index: trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css |
— | — | @@ -8,3 +8,13 @@ |
9 | 9 | .mw-hiero-toc { |
10 | 10 | text-align: center; |
11 | 11 | } |
| 12 | + |
| 13 | +.mw-mirrored { |
| 14 | + -moz-transform: scaleX(-1); |
| 15 | + -o-transform: scaleX(-1); |
| 16 | + -webkit-transform: scaleX(-1); |
| 17 | + transform: scaleX(-1); |
| 18 | + filter: FlipH; |
| 19 | + -ms-filter: "FlipH"; |
| 20 | +} |
| 21 | + |
Index: trunk/extensions/wikihiero/wikihiero.body.php |
— | — | @@ -144,6 +144,11 @@ |
145 | 145 | * @return string: a string to add to the stream |
146 | 146 | */ |
147 | 147 | private function renderGlyph( $glyph, $option = '' ) { |
| 148 | + $imageClass = ''; |
| 149 | + if ( $this->isMirrored( $glyph ) ) { |
| 150 | + $imageClass = 'class="mw-mirrored" '; |
| 151 | + } |
| 152 | + $glyph = $this->extractCode( $glyph ); |
148 | 153 | if ( $glyph == ".." ) { // Render void block |
149 | 154 | $width = WH_HEIGHT; |
150 | 155 | return "<table class=\"mw-hiero-table\" style=\"width: {$width}px;\"><tr><td> </td></tr></table>"; |
— | — | @@ -170,17 +175,27 @@ |
171 | 176 | { |
172 | 177 | $code = self::$phonemes[$glyph]; |
173 | 178 | if ( array_key_exists( $code, self::$files ) ) |
174 | | - return "<img 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 ) . "' />"; |
| 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 ) . "' />"; |
175 | 180 | else |
176 | 181 | return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>"; |
177 | 182 | } |
178 | 183 | elseif ( array_key_exists( $glyph, self::$files ) ) |
179 | | - return "<img 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 ) . "' />"; |
| 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 ) . "' />"; |
180 | 185 | else |
181 | 186 | return htmlspecialchars( $glyph ); |
182 | 187 | } |
183 | 188 | |
| 189 | + private function isMirrored( $glyph ) { |
| 190 | + return substr( $glyph, -1 ) == '\\'; |
| 191 | + } |
| 192 | + |
184 | 193 | /** |
| 194 | + * Extracts hieroglyph code from glyph, e.g. A1\ --> A1 |
| 195 | + */ |
| 196 | + private function extractCode( $glyph ) { |
| 197 | + return preg_replace( '/\\\\.*$/', '', $glyph ); |
| 198 | + } |
| 199 | + /** |
185 | 200 | * Resize a glyph |
186 | 201 | * |
187 | 202 | * @param $item string: glyph code |
— | — | @@ -189,6 +204,7 @@ |
190 | 205 | * @return size |
191 | 206 | */ |
192 | 207 | private function resizeGlyph( $item, $is_cartouche = false, $total = 0 ) { |
| 208 | + $item = $this->extractCode( $item ); |
193 | 209 | if ( array_key_exists( $item, self::$phonemes ) ) { |
194 | 210 | $glyph = self::$phonemes[$item]; |
195 | 211 | } else { |
— | — | @@ -322,7 +338,8 @@ |
323 | 339 | $block[$block_id][$item_id] = $hiero[$char]; |
324 | 340 | $type = WH_TYPE_CODE; |
325 | 341 | |
326 | | - } elseif ( ctype_alnum( $hiero[$char] ) || $hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>' ) { |
| 342 | + } elseif ( ctype_alnum( $hiero[$char] ) || $hiero[$char] == '.' || $hiero[$char] == '<' |
| 343 | + || $hiero[$char] == '>' || $hiero[$char] == '\\' ) { |
327 | 344 | if ( $type == WH_TYPE_END ) { |
328 | 345 | $block_id++; |
329 | 346 | $block[$block_id] = array(); |
Index: trunk/extensions/wikihiero/wikihiero.i18n.php |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | 'wikihiero-eol' => 'End of line', |
26 | 26 | 'wikihiero-superposition' => 'Subdivision', |
27 | 27 | 'wikihiero-juxtaposition' => 'Juxtaposition', |
| 28 | + 'wikihiero-mirror' => 'Mirror a hieroglyph', |
28 | 29 | 'wikihiero-load-error' => 'Load error!', |
29 | 30 | 'wikihiero-category-A' => 'A: Man and his occupations', |
30 | 31 | 'wikihiero-category-B' => 'B: Woman and her occupations', |