http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96686
Revision: 96686
Author: maxsem
Date: 2011-09-09 20:10:01 +0000 (Fri, 09 Sep 2011)
Log Message:
-----------
New feature: hieroglyph mirroring, e.g. Amun must face Ra in C12\-C2
Modified Paths:
--------------
trunk/extensions/wikihiero/SpecialHieroglyphs.php
trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css
trunk/extensions/wikihiero/tests.txt
trunk/extensions/wikihiero/wikihiero.body.php
trunk/extensions/wikihiero/wikihiero.i18n.php
Modified: trunk/extensions/wikihiero/SpecialHieroglyphs.php
===================================================================
--- trunk/extensions/wikihiero/SpecialHieroglyphs.php 2011-09-09 19:46:00 UTC
(rev 96685)
+++ trunk/extensions/wikihiero/SpecialHieroglyphs.php 2011-09-09 20:10:01 UTC
(rev 96686)
@@ -27,6 +27,7 @@
array( 'code' => ':', 'message' => 'wikihiero-superposition',
'example' => 'p:t' ),
array( 'code' => ':', 'message' => 'wikihiero-juxtaposition',
'example' => 'p*t' ),
array( 'code' => '!', 'message' => 'wikihiero-eol', 'example'
=> 'A1-B1 ! C1-D1' ),
+ array( 'code' => '\\', 'message' => 'wikihiero-mirror',
'example' => 'A1\-A1' ),
);
private $helpColumns = array(
'code',
Modified: trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css
===================================================================
--- trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css
2011-09-09 19:46:00 UTC (rev 96685)
+++ trunk/extensions/wikihiero/modules/ext.wikihiero.Special.css
2011-09-09 20:10:01 UTC (rev 96686)
@@ -8,3 +8,13 @@
.mw-hiero-toc {
text-align: center;
}
+
+.mw-mirrored {
+ -moz-transform: scaleX(-1);
+ -o-transform: scaleX(-1);
+ -webkit-transform: scaleX(-1);
+ transform: scaleX(-1);
+ filter: FlipH;
+ -ms-filter: "FlipH";
+}
+
Modified: trunk/extensions/wikihiero/tests.txt
===================================================================
--- trunk/extensions/wikihiero/tests.txt 2011-09-09 19:46:00 UTC (rev
96685)
+++ trunk/extensions/wikihiero/tests.txt 2011-09-09 20:10:01 UTC (rev
96686)
@@ -52,3 +52,12 @@
<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>
!! end
+
+!! test
+WikiHiero - image mirroring
+!! input
+<hiero>A1\-A1</hiero>
+!! result
+<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>
+
+!! end
Modified: trunk/extensions/wikihiero/wikihiero.body.php
===================================================================
--- trunk/extensions/wikihiero/wikihiero.body.php 2011-09-09 19:46:00 UTC
(rev 96685)
+++ trunk/extensions/wikihiero/wikihiero.body.php 2011-09-09 20:10:01 UTC
(rev 96686)
@@ -144,6 +144,11 @@
* @return string: a string to add to the stream
*/
private function renderGlyph( $glyph, $option = '' ) {
+ $imageClass = '';
+ if ( $this->isMirrored( $glyph ) ) {
+ $imageClass = 'class="mw-mirrored" ';
+ }
+ $glyph = $this->extractCode( $glyph );
if ( $glyph == ".." ) { // Render void block
$width = WH_HEIGHT;
return "<table class=\"mw-hiero-table\" style=\"width:
{$width}px;\"><tr><td> </td></tr></table>";
@@ -170,17 +175,27 @@
{
$code = self::$phonemes[$glyph];
if ( array_key_exists( $code, self::$files ) )
- 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 ) . "' />";
+ 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 ) . "' />";
else
return "<font title='" . htmlspecialchars( $code ) .
"'>" . htmlspecialchars( $glyph ) . "</font>";
}
elseif ( array_key_exists( $glyph, self::$files ) )
- 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 ) . "' />";
+ 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 ) . "' />";
else
return htmlspecialchars( $glyph );
}
+ private function isMirrored( $glyph ) {
+ return substr( $glyph, -1 ) == '\\';
+ }
+
/**
+ * Extracts hieroglyph code from glyph, e.g. A1\ --> A1
+ */
+ private function extractCode( $glyph ) {
+ return preg_replace( '/\\\\.*$/', '', $glyph );
+ }
+ /**
* Resize a glyph
*
* @param $item string: glyph code
@@ -189,6 +204,7 @@
* @return size
*/
private function resizeGlyph( $item, $is_cartouche = false, $total = 0
) {
+ $item = $this->extractCode( $item );
if ( array_key_exists( $item, self::$phonemes ) ) {
$glyph = self::$phonemes[$item];
} else {
@@ -322,7 +338,8 @@
$block[$block_id][$item_id] = $hiero[$char];
$type = WH_TYPE_CODE;
- } elseif ( ctype_alnum( $hiero[$char] ) ||
$hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>' ) {
+ } elseif ( ctype_alnum( $hiero[$char] ) ||
$hiero[$char] == '.' || $hiero[$char] == '<'
+ || $hiero[$char] == '>' || $hiero[$char] ==
'\\' ) {
if ( $type == WH_TYPE_END ) {
$block_id++;
$block[$block_id] = array();
Modified: trunk/extensions/wikihiero/wikihiero.i18n.php
===================================================================
--- trunk/extensions/wikihiero/wikihiero.i18n.php 2011-09-09 19:46:00 UTC
(rev 96685)
+++ trunk/extensions/wikihiero/wikihiero.i18n.php 2011-09-09 20:10:01 UTC
(rev 96686)
@@ -24,6 +24,7 @@
'wikihiero-eol' => 'End of line',
'wikihiero-superposition' => 'Subdivision',
'wikihiero-juxtaposition' => 'Juxtaposition',
+ 'wikihiero-mirror' => 'Mirror a hieroglyph',
'wikihiero-load-error' => 'Load error!',
'wikihiero-category-A' => 'A: Man and his occupations',
'wikihiero-category-B' => 'B: Woman and her occupations',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs