Index: trunk/extensions/wikihiero/wh_list.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -// File created by wh_generate.php version 0.2.14 |
5 | | -// 2006/03/05 pm31 13:04 |
| 4 | +// File created by generateTables.php version 0.3.0alpha |
| 5 | +// 2011/08/20 at 07:34 |
6 | 6 | |
7 | 7 | global $wh_prefabs, $wh_files; |
8 | 8 | |
— | — | @@ -300,8 +300,8 @@ |
301 | 301 | "C9" => array( 20, 38 ), |
302 | 302 | "Ca0" => array( 5, 50 ), |
303 | 303 | "Ca1" => array( 14, 48 ), |
304 | | - "Ca1a" => array( 14, 49 ), |
305 | | - "Ca2" => array( 16, 49 ), |
| 304 | + "Ca1a" => array( 14, 50 ), |
| 305 | + "Ca2" => array( 16, 50 ), |
306 | 306 | "Ca2a" => array( 16, 48 ), |
307 | 307 | "Cah1" => array( 5, 48 ), |
308 | 308 | "Cah1a" => array( 5, 50 ), |
Index: trunk/extensions/wikihiero/generateTables.php |
— | — | @@ -1,100 +1,81 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -////////////////////////////////////////////////////////////////////////// |
5 | | -// |
6 | | -// WikiHiero - A PHP convert from text using "Manual for the encoding of |
7 | | -// hieroglyphic texts for computer input" syntax to HTML entities (table and |
8 | | -// images). |
9 | | -// |
10 | | -// Copyright (C) 2004 Guillaume Blanchard (Aoineko) |
11 | | -// |
12 | | -// This program is free software; you can redistribute it and/or |
13 | | -// modify it under the terms of the GNU General Public License |
14 | | -// as published by the Free Software Foundation; either version 2 |
15 | | -// of the License, or any later version. |
16 | | -// |
17 | | -// This program is distributed in the hope that it will be useful, |
18 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | | -// GNU General Public License for more details. |
21 | | -// |
22 | | -// You should have received a copy of the GNU General Public License |
23 | | -// along with this program; if not, write to the Free Software |
24 | | -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | | -// |
26 | | -////////////////////////////////////////////////////////////////////////// |
| 4 | +/** |
| 5 | + * WikiHiero - A PHP convert from text using "Manual for the encoding of |
| 6 | + * hieroglyphic texts for computer input" syntax to HTML entities (table and |
| 7 | + * images). |
| 8 | + * |
| 9 | + * Copyright (C) 2004 Guillaume Blanchard (Aoineko) |
| 10 | + * |
| 11 | + * This program is free software; you can redistribute it and/or modify |
| 12 | + * it under the terms of the GNU General Public License as published by |
| 13 | + * the Free Software Foundation; either version 2 of the License, or |
| 14 | + * (at your option) any later version. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License along |
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 24 | + * http://www.gnu.org/copyleft/gpl.html |
| 25 | + */ |
27 | 26 | |
28 | | -echo "This script is insecure and shouldn't be used on a public wiki.\n"; |
29 | | -exit( 1 ); |
30 | | - |
31 | | - |
32 | | -include "wh_main.php"; |
33 | | - |
34 | | -if ( array_key_exists( "lang", $_GET ) ) { |
35 | | - $lang = $_GET["lang"]; |
36 | | -} else { |
37 | | - $lang = "fr"; |
| 27 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 28 | +if ( $IP === false ) { |
| 29 | + $IP = dirname( __FILE__ ) . '/../..'; |
38 | 30 | } |
39 | | -?> |
40 | | -<html lang=<?php echo htmlspecialchars( $lang ); ?>> |
41 | | - <head> |
42 | | - <title>WikiHiero - Table generator</title> |
43 | | - <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> |
44 | | - <link rel="shortcut icon" href="https://www.mediawiki.org/favicon.ico"> |
45 | | - </head> |
46 | | - <body bgcolor="#DDDDDD"> |
| 31 | +require_once( "$IP/maintenance/Maintenance.php" ); |
47 | 32 | |
48 | | - <big><?php echo "WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN; ?></big> |
| 33 | +class GenerateWikiHieroTables extends Maintenance { |
49 | 34 | |
50 | | - <br /><br />Parsing hieroglyph files and creating tables...<br /><br /> |
| 35 | + public function __construct() { |
| 36 | + parent::__construct(); |
| 37 | + $this->mDescription = 'Generate tables with hieroglyph information'; |
| 38 | + // if ( !MWInit::classExists( 'WikiHiero' ) ) { |
| 39 | + // $this->error( "Please install WikiHiero first!\n", true ); |
| 40 | + // } |
| 41 | + } |
| 42 | + |
| 43 | + public function execute() { |
| 44 | + $wh_prefabs = "\$wh_prefabs = array(\n"; |
| 45 | + $wh_files = "\$wh_files = array(\n"; |
51 | 46 | |
52 | | - <?php |
| 47 | + $imgDir = dirname( __FILE__ ) . '/img/'; |
53 | 48 | |
54 | | - $wh_prefabs = "\$wh_prefabs = array(\n"; |
55 | | - $wh_files = "\$wh_files = array(\n"; |
| 49 | + if ( is_dir( $imgDir ) ) { |
| 50 | + $dh = opendir( $imgDir ); |
| 51 | + if ( $dh ) { |
| 52 | + while ( ( $file = readdir( $dh ) ) !== false ) { |
| 53 | + if ( stristr( $file, WikiHiero::IMG_EXT ) ) { |
| 54 | + list( $width, $height, $type, $attr ) = getimagesize( $imgDir . $file ); |
| 55 | + $wh_files .= " \"" . WikiHiero::getCode( $file ) . "\" => array( $width, $height ),\n"; |
| 56 | + if ( strchr( $file, '&' ) ) { |
| 57 | + $wh_prefabs .= " \"" . WikiHiero::getCode( $file ) . "\",\n"; |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + closedir( $dh ); |
| 62 | + } |
| 63 | + } else { |
| 64 | + $this->error( "Images directory $imgDir not found!\n", true ); |
| 65 | + } |
56 | 66 | |
57 | | - $img_dir = dirname( __FILE__ ) . '/img/'; |
| 67 | + $wh_prefabs .= ");"; |
| 68 | + $wh_files .= ");"; |
58 | 69 | |
59 | | - if ( is_dir( $img_dir ) ) |
60 | | - { |
61 | | - $dh = opendir( $img_dir ); |
62 | | - if ( $dh ) |
63 | | - { |
64 | | - while ( ( $file = readdir( $dh ) ) !== false ) |
65 | | - { |
66 | | - if ( stristr( $file, WH_IMG_EXT ) ) |
67 | | - { |
68 | | - list( $width, $height, $type, $attr ) = getimagesize( $img_dir . $file ); |
69 | | - $wh_files .= " \"" . WH_GetCode( $file ) . "\" => array( $width, $height ),\n"; |
70 | | - if ( strchr( $file, '&' ) ) |
71 | | - $wh_prefabs .= " \"" . WH_GetCode( $file ) . "\",\n"; |
72 | | - } |
73 | | - } |
74 | | - closedir( $dh ); |
75 | | - } |
76 | | - } |
| 70 | + $file = fopen( 'wh_list.php', 'w+' ); |
| 71 | + fwrite( $file, "<?php\n\n" ); |
| 72 | + fwrite( $file, '// File created by generateTables.php version ' . WikiHiero::VERSION . "\n" ); |
| 73 | + fwrite( $file, '// ' . date( 'Y/m/d \a\t H:i' ) . "\n\n" ); |
| 74 | + fwrite( $file, "global \$wh_prefabs, \$wh_files;\n\n" ); |
| 75 | + fwrite( $file, "$wh_prefabs\n\n" ); |
| 76 | + fwrite( $file, "$wh_files\n\n" ); |
| 77 | + fclose( $file ); |
| 78 | + } |
| 79 | +} |
77 | 80 | |
78 | | - $wh_prefabs .= ");"; |
79 | | - $wh_files .= ");"; |
80 | | - |
81 | | - echo "<pre>$wh_prefabs<br /><br />"; |
82 | | - echo "$wh_files<br /><br /></pre>"; |
83 | | - |
84 | | - $file = fopen( "wh_list.php", "w+" ); |
85 | | - fwrite( $file, "<?php\n\n" ); |
86 | | - fwrite( $file, "// File created by wh_generate.php version " . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN . "\n" ); |
87 | | - fwrite( $file, "// " . date( "Y/m/d at H:i" ) . "\n\n" ); |
88 | | - fwrite( $file, "global \$wh_prefabs, \$wh_files;\n\n" ); |
89 | | - fwrite( $file, "$wh_prefabs\n\n" ); |
90 | | - fwrite( $file, "$wh_files\n\n" ); |
91 | | - fwrite( $file, "?>" ); |
92 | | - fclose( $file ); |
93 | | - |
94 | | - // if(file_exists("wh_list(0).php")) |
95 | | - |
96 | | - ?> |
97 | | - |
98 | | - <small><?php echo WH_Credit(); ?></small> |
99 | | - |
100 | | - </body> |
101 | | -</html> |
| 81 | +$maintClass = "GenerateWikiHieroTables"; |
| 82 | +require_once( RUN_MAINTENANCE_IF_MAIN ); |
Index: trunk/extensions/wikihiero/wikihiero.body.php |
— | — | @@ -57,18 +57,16 @@ |
58 | 58 | define( "WH_IMG_MARGIN", 1 ); // default value |
59 | 59 | define( "WH_CARTOUCHE_WIDTH", 2 ); // default value |
60 | 60 | |
61 | | -define( "WH_VER_MAJ", 0 ); |
62 | | -define( "WH_VER_MED", 2 ); |
63 | | -define( "WH_VER_MIN", 14 ); |
64 | | - |
65 | 61 | global $wgExtensionAssetsPath; |
66 | 62 | define( "WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' ); |
67 | 63 | define( "WH_IMG_PRE", "hiero_" ); |
68 | | -define( "WH_IMG_EXT", "png" ); |
69 | 64 | |
70 | 65 | define( "WH_DEBUG_MODE", false ); |
71 | 66 | |
72 | 67 | class WikiHiero { |
| 68 | + const VERSION = '0.3.0alpha'; |
| 69 | + const IMG_EXT = 'png'; |
| 70 | + |
73 | 71 | private $scale = 100; |
74 | 72 | |
75 | 73 | public function __construct( $scale = WH_SCALE_DEFAULT ) { |
— | — | @@ -139,25 +137,25 @@ |
140 | 138 | { |
141 | 139 | $height = intval( WH_HEIGHT * $this->scale / 100 ); |
142 | 140 | $code = $wh_phonemes[$glyph]; |
143 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 141 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
144 | 142 | } |
145 | 143 | elseif ( $glyph == '>' ) // Render close cartouche |
146 | 144 | { |
147 | 145 | $height = intval( WH_HEIGHT * $this->scale / 100 ); |
148 | 146 | $code = $wh_phonemes[$glyph]; |
149 | | - return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 147 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . self::IMG_EXT ) . "' height='{$height}' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
150 | 148 | } |
151 | 149 | |
152 | 150 | if ( array_key_exists( $glyph, $wh_phonemes ) ) |
153 | 151 | { |
154 | 152 | $code = $wh_phonemes[$glyph]; |
155 | 153 | if ( array_key_exists( $code, $wh_files ) ) |
156 | | - return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( "{$code} [{$glyph}]" ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 154 | + 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 ) . "' />"; |
157 | 155 | else |
158 | 156 | return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>"; |
159 | 157 | } |
160 | 158 | elseif ( array_key_exists( $glyph, $wh_files ) ) |
161 | | - return "<img style='margin:" . WH_IMG_MARGIN . "px;' $option src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$glyph}." . WH_IMG_EXT ) . "' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
| 159 | + 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 ) . "' />"; |
162 | 160 | else |
163 | 161 | return htmlspecialchars( $glyph ); |
164 | 162 | } |
— | — | @@ -463,6 +461,15 @@ |
464 | 462 | return "<table class='mw-hiero-table mw-hiero-outer' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
465 | 463 | } |
466 | 464 | |
| 465 | + /** |
| 466 | + * Get glyph code from file name |
| 467 | + * |
| 468 | + * @param $file string: file name |
| 469 | + * @return string: converted code |
| 470 | + */ |
| 471 | + public static function getCode( $file ) { |
| 472 | + return substr( $file, strlen( WH_IMG_PRE ), -( 1 + strlen( self::IMG_EXT ) ) ); |
| 473 | + } |
467 | 474 | } |
468 | 475 | |
469 | 476 | // ======================================================================== |
— | — | @@ -971,35 +978,3 @@ |
972 | 979 | "<" => "(", // cartouche |
973 | 980 | ">" => ")|", |
974 | 981 | ); |
975 | | - |
976 | | -// ======================================================================== |
977 | | -// F U N C T I O N S |
978 | | - |
979 | | - |
980 | | -// ======================================================================== |
981 | | -// |
982 | | -// W i k i H i e r o |
983 | | -// |
984 | | - |
985 | | -// ------------------------------------------------------------------------ |
986 | | -// WH_GetCode - Get glyph code from file name |
987 | | -// ------------------------------------------------------------------------ |
988 | | -// file << file name |
989 | | -// return >> string with converted code |
990 | | -// ------------------------------------------------------------------------ |
991 | | -function WH_GetCode( $file ) { |
992 | | - return substr( $file, strlen( WH_IMG_PRE ), -( 1 + strlen( WH_IMG_EXT ) ) ); |
993 | | -} |
994 | | - |
995 | | -// ------------------------------------------------------------------------ |
996 | | -// WH_Credit - Get glyph code from file name |
997 | | -// ------------------------------------------------------------------------ |
998 | | -// return >> credit string |
999 | | -// ------------------------------------------------------------------------ |
1000 | | -function WH_Credit() { |
1001 | | - $html = ""; |
1002 | | - $html .= "<b>WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN . "</b>\n"; |
1003 | | - $html .= "by Guillaume Blanchard (Aoineko) under GPL (2004).<br />\n"; |
1004 | | - $html .= "Hieroglyph credit: S. Rosmorduc, G. Watson, J. Hirst (under GFDL).\n"; |
1005 | | - return $html; |
1006 | | -} |