Index: trunk/extensions/wikihiero/wikihiero.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiHiero', |
35 | 35 | 'descriptionmsg' => 'wikihiero-desc', |
36 | 36 | ); |
37 | | -$wgExtensionMessagesFiles['Wikihiero'] = dirname(__FILE__) . '/wikihiero.i18n.php'; |
| 37 | +$wgExtensionMessagesFiles['Wikihiero'] = dirname( __FILE__ ) . '/wikihiero.i18n.php'; |
38 | 38 | |
39 | 39 | $wgAutoloadClasses['WikiHiero'] = dirname( __FILE__ ) . '/wh_main.php'; |
40 | 40 | |
Index: trunk/extensions/wikihiero/wh_main.php |
— | — | @@ -28,45 +28,45 @@ |
29 | 29 | die( 'Not an entry point' ); |
30 | 30 | } |
31 | 31 | |
32 | | -//======================================================================== |
| 32 | +// ======================================================================== |
33 | 33 | // I N C L U D E S |
34 | | -include( dirname(__FILE__) . '/wh_list.php' ); |
| 34 | +include( dirname( __FILE__ ) . '/wh_list.php' ); |
35 | 35 | |
36 | | -//======================================================================== |
| 36 | +// ======================================================================== |
37 | 37 | // D E F I N E S |
38 | | -define("WH_TABLE_S", "<table border='0' cellspacing='0' cellpadding='0'>"); |
39 | | -define("WH_TABLE_E", "</table>"); |
40 | | -define("WH_TD_S", "<td align='center' valign='middle'>"); |
41 | | -define("WH_TD_E", "</td>"); |
| 38 | +define( "WH_TABLE_S", "<table border='0' cellspacing='0' cellpadding='0'>" ); |
| 39 | +define( "WH_TABLE_E", "</table>" ); |
| 40 | +define( "WH_TD_S", "<td align='center' valign='middle'>" ); |
| 41 | +define( "WH_TD_E", "</td>" ); |
42 | 42 | |
43 | | -define("WH_MODE_DEFAULT", -1); // use default mode |
44 | | -define("WH_MODE_TEXT", 0); // text only |
45 | | -define("WH_MODE_HTML", 1); // HTML without CSS |
46 | | -define("WH_MODE_STYLE", 2); // HTML and CSS // not supported |
47 | | -define("WH_MODE_IMAGE", 3); // picture (PNG) // not supported |
48 | | -define("WH_MODE_RAW", 4); // MdC test as it |
| 43 | +define( "WH_MODE_DEFAULT", -1 ); // use default mode |
| 44 | +define( "WH_MODE_TEXT", 0 ); // text only |
| 45 | +define( "WH_MODE_HTML", 1 ); // HTML without CSS |
| 46 | +define( "WH_MODE_STYLE", 2 ); // HTML and CSS // not supported |
| 47 | +define( "WH_MODE_IMAGE", 3 ); // picture (PNG) // not supported |
| 48 | +define( "WH_MODE_RAW", 4 ); // MdC test as it |
49 | 49 | |
50 | | -define("WH_TYPE_NONE", 0); |
51 | | -define("WH_TYPE_GLYPH", 1); // rendered items |
52 | | -define("WH_TYPE_CODE", 2); // single code as ':', '*', '!', '(' or ')' |
53 | | -define("WH_TYPE_SPECIAL", 3); // advanced code (more than 1 caracter) |
54 | | -define("WH_TYPE_END", 4); // end of line '!' |
| 50 | +define( "WH_TYPE_NONE", 0 ); |
| 51 | +define( "WH_TYPE_GLYPH", 1 ); // rendered items |
| 52 | +define( "WH_TYPE_CODE", 2 ); // single code as ':', '*', '!', '(' or ')' |
| 53 | +define( "WH_TYPE_SPECIAL", 3 ); // advanced code (more than 1 caracter) |
| 54 | +define( "WH_TYPE_END", 4 ); // end of line '!' |
55 | 55 | |
56 | | -define("WH_SCALE_DEFAULT", -1); // use default scale |
57 | | -define("WH_HEIGHT", 44); |
58 | | -define("WH_IMG_MARGIN", 1); // default value |
59 | | -define("WH_CARTOUCHE_WIDTH", 2); // default value |
| 56 | +define( "WH_SCALE_DEFAULT", -1 ); // use default scale |
| 57 | +define( "WH_HEIGHT", 44 ); |
| 58 | +define( "WH_IMG_MARGIN", 1 ); // default value |
| 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); |
| 61 | +define( "WH_VER_MAJ", 0 ); |
| 62 | +define( "WH_VER_MED", 2 ); |
| 63 | +define( "WH_VER_MIN", 14 ); |
64 | 64 | |
65 | 65 | global $wgExtensionAssetsPath; |
66 | | -define("WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' ); |
67 | | -define("WH_IMG_PRE", "hiero_"); |
68 | | -define("WH_IMG_EXT", "png"); |
| 66 | +define( "WH_IMG_DIR", $wgExtensionAssetsPath . '/wikihiero/img/' ); |
| 67 | +define( "WH_IMG_PRE", "hiero_" ); |
| 68 | +define( "WH_IMG_EXT", "png" ); |
69 | 69 | |
70 | | -define("WH_DEBUG_MODE", false); |
| 70 | +define( "WH_DEBUG_MODE", false ); |
71 | 71 | |
72 | 72 | class WikiHiero { |
73 | 73 | private $scale = 100; |
— | — | @@ -83,20 +83,20 @@ |
84 | 84 | * @param $line string: use line [true|false] (def=false) |
85 | 85 | * @return string: converted code |
86 | 86 | */ |
87 | | - public static function render( $text, $mode=WH_MODE_DEFAULT, $scale=WH_SCALE_DEFAULT, $line=false ) { |
| 87 | + public static function render( $text, $mode = WH_MODE_DEFAULT, $scale = WH_SCALE_DEFAULT, $line = false ) { |
88 | 88 | if ( $mode == WH_MODE_DEFAULT ) { |
89 | 89 | $mode = WH_MODE_HTML; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $hiero = new WikiHiero( $scale ); |
93 | 93 | |
94 | | - switch($mode) { |
95 | | - case WH_MODE_TEXT: return $hiero->renderText( $text, $line); |
96 | | - case WH_MODE_HTML: return $hiero->renderHtml( $text, $scale, $line); |
97 | | - case WH_MODE_STYLE: die("ERROR: CSS version not yet implemented"); |
98 | | - case WH_MODE_IMAGE: die("ERROR: Image version not yet implemented"); |
| 94 | + switch( $mode ) { |
| 95 | + case WH_MODE_TEXT: return $hiero->renderText( $text, $line ); |
| 96 | + case WH_MODE_HTML: return $hiero->renderHtml( $text, $scale, $line ); |
| 97 | + case WH_MODE_STYLE: die( "ERROR: CSS version not yet implemented" ); |
| 98 | + case WH_MODE_IMAGE: die( "ERROR: Image version not yet implemented" ); |
99 | 99 | } |
100 | | - die("ERROR: Unknown mode!"); |
| 100 | + die( "ERROR: Unknown mode!" ); |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Renders a glyph |
121 | | - * |
| 121 | + * |
122 | 122 | * @param $glyph string: glyph's code to render |
123 | 123 | * @param $option string: option to add into <img> tag (use for height) |
124 | 124 | * @return string: a string to add to the stream |
— | — | @@ -126,40 +126,40 @@ |
127 | 127 | global $wh_phonemes; |
128 | 128 | global $wh_files; |
129 | 129 | |
130 | | - if($glyph == "..") { // Render void block |
| 130 | + if ( $glyph == ".." ) { // Render void block |
131 | 131 | $width = WH_HEIGHT; |
132 | 132 | return "<table width='{$width}px' border='0' cellspacing='0' cellpadding='0'><tr><td> </td></tr></table>"; |
133 | 133 | } |
134 | | - elseif($glyph == ".") // Render half-width void block |
| 134 | + elseif ( $glyph == "." ) // Render half-width void block |
135 | 135 | { |
136 | | - $width = WH_HEIGHT/2; |
| 136 | + $width = WH_HEIGHT / 2; |
137 | 137 | return "<table width='{$width}px' border='0' cellspacing='0' cellpadding='0'><tr><td> </td></tr></table>"; |
138 | 138 | } |
139 | | - elseif($glyph == '<') // Render open cartouche |
| 139 | + elseif ( $glyph == '<' ) // Render open cartouche |
140 | 140 | { |
141 | | - $height = intval(WH_HEIGHT * $this->scale / 100); |
| 141 | + $height = intval( WH_HEIGHT * $this->scale / 100 ); |
142 | 142 | $code = $wh_phonemes[$glyph]; |
143 | | - return "<img src='".htmlspecialchars(WH_IMG_DIR.WH_IMG_PRE."{$code}.".WH_IMG_EXT)."' height='{$height}px' title='".htmlspecialchars($glyph)."' alt='".htmlspecialchars($glyph)."' />"; |
| 143 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}px' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
144 | 144 | } |
145 | | - elseif($glyph == '>') // Render close cartouche |
| 145 | + elseif ( $glyph == '>' ) // Render close cartouche |
146 | 146 | { |
147 | | - $height = intval(WH_HEIGHT * $this->scale / 100); |
| 147 | + $height = intval( WH_HEIGHT * $this->scale / 100 ); |
148 | 148 | $code = $wh_phonemes[$glyph]; |
149 | | - return "<img src='".htmlspecialchars(WH_IMG_DIR.WH_IMG_PRE."{$code}.".WH_IMG_EXT)."' height='{$height}px' title='".htmlspecialchars($glyph)."' alt='".htmlspecialchars($glyph)."' />"; |
| 149 | + return "<img src='" . htmlspecialchars( WH_IMG_DIR . WH_IMG_PRE . "{$code}." . WH_IMG_EXT ) . "' height='{$height}px' title='" . htmlspecialchars( $glyph ) . "' alt='" . htmlspecialchars( $glyph ) . "' />"; |
150 | 150 | } |
151 | 151 | |
152 | | - if(array_key_exists($glyph, $wh_phonemes)) |
| 152 | + if ( array_key_exists( $glyph, $wh_phonemes ) ) |
153 | 153 | { |
154 | 154 | $code = $wh_phonemes[$glyph]; |
155 | | - 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)."' />"; |
| 155 | + 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 ) . "' />"; |
157 | 157 | else |
158 | | - return "<font title='".htmlspecialchars($code)."'>".htmlspecialchars($glyph)."</font>"; |
| 158 | + return "<font title='" . htmlspecialchars( $code ) . "'>" . htmlspecialchars( $glyph ) . "</font>"; |
159 | 159 | } |
160 | | - 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)."' />"; |
| 160 | + 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 ) . "' />"; |
162 | 162 | else |
163 | | - return htmlspecialchars($glyph); |
| 163 | + return htmlspecialchars( $glyph ); |
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
— | — | @@ -170,63 +170,63 @@ |
171 | 171 | * @param $total int: total size of a group for multi-glyph block |
172 | 172 | * @return size |
173 | 173 | */ |
174 | | - private function resizeGlyph( $item, $is_cartouche=false, $total=0 ) { |
| 174 | + private function resizeGlyph( $item, $is_cartouche = false, $total = 0 ) { |
175 | 175 | global $wh_phonemes; |
176 | 176 | global $wh_files; |
177 | 177 | |
178 | | - if(array_key_exists($item, $wh_phonemes)) { |
| 178 | + if ( array_key_exists( $item, $wh_phonemes ) ) { |
179 | 179 | $glyph = $wh_phonemes[$item]; |
180 | 180 | } else { |
181 | 181 | $glyph = $item; |
182 | 182 | } |
183 | 183 | |
184 | 184 | $margin = 2 * WH_IMG_MARGIN; |
185 | | - if($is_cartouche) { |
186 | | - $margin += 2 * intval(WH_CARTOUCHE_WIDTH * $this->scale / 100); |
| 185 | + if ( $is_cartouche ) { |
| 186 | + $margin += 2 * intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ); |
187 | 187 | } |
188 | 188 | |
189 | | - if(array_key_exists($glyph, $wh_files)) { |
| 189 | + if ( array_key_exists( $glyph, $wh_files ) ) { |
190 | 190 | $height = $margin + $wh_files[$glyph][1]; |
191 | | - if($total) { |
192 | | - if($total > WH_HEIGHT) { |
193 | | - return (intval( $height * WH_HEIGHT / $total ) - $margin) * $this->scale / 100; |
| 191 | + if ( $total ) { |
| 192 | + if ( $total > WH_HEIGHT ) { |
| 193 | + return ( intval( $height * WH_HEIGHT / $total ) - $margin ) * $this->scale / 100; |
194 | 194 | } else { |
195 | | - return ($height - $margin) * $this->scale / 100; |
| 195 | + return ( $height - $margin ) * $this->scale / 100; |
196 | 196 | } |
197 | 197 | } else { |
198 | | - if($height > WH_HEIGHT) { |
199 | | - return (intval( WH_HEIGHT * WH_HEIGHT / $height ) - $margin) * $this->scale / 100; |
| 198 | + if ( $height > WH_HEIGHT ) { |
| 199 | + return ( intval( WH_HEIGHT * WH_HEIGHT / $height ) - $margin ) * $this->scale / 100; |
200 | 200 | } else { |
201 | | - return ($height - $margin) * $this->scale / 100; |
| 201 | + return ( $height - $margin ) * $this->scale / 100; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | | - return (WH_HEIGHT - $margin) * $this->scale / 100; |
| 206 | + return ( WH_HEIGHT - $margin ) * $this->scale / 100; |
207 | 207 | } |
208 | 208 | |
209 | | - //------------------------------------------------------------------------ |
| 209 | + // ------------------------------------------------------------------------ |
210 | 210 | // WikiHieroText - Render hieroglyph text in text mode |
211 | | - //------------------------------------------------------------------------ |
| 211 | + // ------------------------------------------------------------------------ |
212 | 212 | // hiero << text to convert |
213 | 213 | // line << use line [true|false] (def=false) |
214 | 214 | // return >> string with converted code |
215 | | - //------------------------------------------------------------------------ |
216 | | - public function renderText($hiero, $line=false) { |
| 215 | + // ------------------------------------------------------------------------ |
| 216 | + public function renderText( $hiero, $line = false ) { |
217 | 217 | global $wh_text_conv; |
218 | 218 | |
219 | 219 | $html = ""; |
220 | 220 | |
221 | | - if($line) |
| 221 | + if ( $line ) |
222 | 222 | $html .= "<hr />\n"; |
223 | 223 | |
224 | | - for($char=0; $char<strlen($hiero); $char++) |
| 224 | + for ( $char = 0; $char < strlen( $hiero ); $char++ ) |
225 | 225 | { |
226 | | - if(array_key_exists($hiero[$char], $wh_text_conv)) |
| 226 | + if ( array_key_exists( $hiero[$char], $wh_text_conv ) ) |
227 | 227 | { |
228 | 228 | $html .= $wh_text_conv[$hiero[$char]]; |
229 | | - if($hiero[$char] == '!') |
230 | | - if($line) |
| 229 | + if ( $hiero[$char] == '!' ) |
| 230 | + if ( $line ) |
231 | 231 | $html .= "<hr />\n"; |
232 | 232 | } |
233 | 233 | else |
— | — | @@ -236,29 +236,29 @@ |
237 | 237 | return $html; |
238 | 238 | } |
239 | 239 | |
240 | | - //------------------------------------------------------------------------ |
| 240 | + // ------------------------------------------------------------------------ |
241 | 241 | // WikiHiero - Render hieroglyph text |
242 | | - //------------------------------------------------------------------------ |
| 242 | + // ------------------------------------------------------------------------ |
243 | 243 | // hiero << text to convert |
244 | 244 | // scale << global scale in percentage (def=100%) |
245 | 245 | // line << use line [true|false] (def=false) |
246 | 246 | // return >> string with converted code |
247 | | - //------------------------------------------------------------------------ |
248 | | - public function renderHtml($hiero, $scale = WH_SCALE_DEFAULT, $line=false) { |
| 247 | + // ------------------------------------------------------------------------ |
| 248 | + public function renderHtml( $hiero, $scale = WH_SCALE_DEFAULT, $line = false ) { |
249 | 249 | global $wh_prefabs; |
250 | 250 | global $wh_files; |
251 | 251 | global $wh_phonemes; |
252 | 252 | |
253 | | - if($scale != WH_SCALE_DEFAULT) |
| 253 | + if ( $scale != WH_SCALE_DEFAULT ) |
254 | 254 | $this->setScale( $scale ); |
255 | 255 | |
256 | 256 | $html = ""; |
257 | 257 | |
258 | | - if($line) { |
| 258 | + if ( $line ) { |
259 | 259 | $html .= "<hr />\n"; |
260 | 260 | } |
261 | 261 | |
262 | | - //------------------------------------------------------------------------ |
| 262 | + // ------------------------------------------------------------------------ |
263 | 263 | // Split text into block, then split block into item |
264 | 264 | $block = array(); |
265 | 265 | $block[0] = array(); |
— | — | @@ -269,17 +269,17 @@ |
270 | 270 | $type = WH_TYPE_NONE; |
271 | 271 | $is_cartouche = false; |
272 | 272 | |
273 | | - for($char=0; $char<strlen($hiero); $char++) { |
| 273 | + for ( $char = 0; $char < strlen( $hiero ); $char++ ) { |
274 | 274 | |
275 | | - if( $hiero[$char] == '(' ) { |
| 275 | + if ( $hiero[$char] == '(' ) { |
276 | 276 | $parenthesis++; |
277 | | - } elseif( $hiero[$char] == ')' ) { |
| 277 | + } elseif ( $hiero[$char] == ')' ) { |
278 | 278 | $parenthesis--; |
279 | 279 | } |
280 | 280 | |
281 | | - if( $parenthesis == 0 ) { |
282 | | - if($hiero[$char] == '-' || $hiero[$char] == ' ') { |
283 | | - if($type != WH_TYPE_NONE) { |
| 281 | + if ( $parenthesis == 0 ) { |
| 282 | + if ( $hiero[$char] == '-' || $hiero[$char] == ' ' ) { |
| 283 | + if ( $type != WH_TYPE_NONE ) { |
284 | 284 | $block_id++; |
285 | 285 | $block[$block_id] = array(); |
286 | 286 | $item_id = 0; |
— | — | @@ -288,15 +288,15 @@ |
289 | 289 | } |
290 | 290 | } |
291 | 291 | } else {// don't slit block if inside parenthesis |
292 | | - if($hiero[$char] == '-') { |
| 292 | + if ( $hiero[$char] == '-' ) { |
293 | 293 | $item_id++; |
294 | 294 | $block[$block_id][$item_id] = '-'; |
295 | 295 | $type = WH_TYPE_CODE; |
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | | - if($hiero[$char] == '!' ) { |
300 | | - if($item_id > 0) { |
| 299 | + if ( $hiero[$char] == '!' ) { |
| 300 | + if ( $item_id > 0 ) { |
301 | 301 | $block_id++; |
302 | 302 | $block[$block_id] = array(); |
303 | 303 | $item_id = 0; |
— | — | @@ -304,22 +304,22 @@ |
305 | 305 | $block[$block_id][$item_id] = $hiero[$char]; |
306 | 306 | $type = WH_TYPE_END; |
307 | 307 | |
308 | | - } elseif(preg_match("/[*:()]/", $hiero[$char])) { |
| 308 | + } elseif ( preg_match( "/[*:()]/", $hiero[$char] ) ) { |
309 | 309 | |
310 | | - if($type == WH_TYPE_GLYPH || $type == WH_TYPE_CODE) { |
| 310 | + if ( $type == WH_TYPE_GLYPH || $type == WH_TYPE_CODE ) { |
311 | 311 | $item_id++; |
312 | 312 | $block[$block_id][$item_id] = ""; |
313 | 313 | } |
314 | 314 | $block[$block_id][$item_id] = $hiero[$char]; |
315 | 315 | $type = WH_TYPE_CODE; |
316 | 316 | |
317 | | - } elseif(ctype_alnum($hiero[$char]) || $hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>') { |
318 | | - if($type == WH_TYPE_END) { |
| 317 | + } elseif ( ctype_alnum( $hiero[$char] ) || $hiero[$char] == '.' || $hiero[$char] == '<' || $hiero[$char] == '>' ) { |
| 318 | + if ( $type == WH_TYPE_END ) { |
319 | 319 | $block_id++; |
320 | 320 | $block[$block_id] = array(); |
321 | 321 | $item_id = 0; |
322 | 322 | $block[$block_id][$item_id] = ""; |
323 | | - } elseif($type == WH_TYPE_CODE) { |
| 323 | + } elseif ( $type == WH_TYPE_CODE ) { |
324 | 324 | $item_id++; |
325 | 325 | $block[$block_id][$item_id] = ""; |
326 | 326 | } |
— | — | @@ -329,11 +329,11 @@ |
330 | 330 | } |
331 | 331 | |
332 | 332 | // DEBUG: See the block split table |
333 | | - if(WH_DEBUG_MODE) { |
| 333 | + if ( WH_DEBUG_MODE ) { |
334 | 334 | |
335 | | - foreach($block as $code) { |
| 335 | + foreach ( $block as $code ) { |
336 | 336 | echo "| "; |
337 | | - foreach($code as $item) { |
| 337 | + foreach ( $code as $item ) { |
338 | 338 | echo "$item | "; |
339 | 339 | } |
340 | 340 | echo "<br />\n"; |
— | — | @@ -341,35 +341,35 @@ |
342 | 342 | } |
343 | 343 | |
344 | 344 | $contentHtml = $tableHtml = $tableContentHtml = ""; |
345 | | - //$html .= WH_TABLE_S."<tr>\n"; |
| 345 | + // $html .= WH_TABLE_S."<tr>\n"; |
346 | 346 | |
347 | | - //------------------------------------------------------------------------ |
| 347 | + // ------------------------------------------------------------------------ |
348 | 348 | // Loop into all blocks |
349 | | - foreach($block as $code) { |
| 349 | + foreach ( $block as $code ) { |
350 | 350 | |
351 | 351 | // simplest case, the block contain only 1 code -> render |
352 | | - if(count($code) == 1) |
| 352 | + if ( count( $code ) == 1 ) |
353 | 353 | { |
354 | | - if($code[0] == "!") { // end of line |
355 | | - $tableHtml = "</tr>".WH_TABLE_E.WH_TABLE_S."<tr>\n"; |
356 | | - if($line) { |
| 354 | + if ( $code[0] == "!" ) { // end of line |
| 355 | + $tableHtml = "</tr>" . WH_TABLE_E . WH_TABLE_S . "<tr>\n"; |
| 356 | + if ( $line ) { |
357 | 357 | $contentHtml .= "<hr />\n"; |
358 | 358 | } |
359 | 359 | |
360 | | - } elseif(strchr($code[0], '<')) { // start cartouche |
361 | | - $contentHtml .= WH_TD_S . self::renderGlyph($code[0]).WH_TD_E; |
| 360 | + } elseif ( strchr( $code[0], '<' ) ) { // start cartouche |
| 361 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
362 | 362 | $is_cartouche = true; |
363 | | - $contentHtml .= "<td>".WH_TABLE_S."<tr><td height='".intval(WH_CARTOUCHE_WIDTH * $this->scale / 100)."px' bgcolor='black'></td></tr><tr><td>".WH_TABLE_S."<tr>"; |
| 363 | + $contentHtml .= "<td>" . WH_TABLE_S . "<tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr><tr><td>" . WH_TABLE_S . "<tr>"; |
364 | 364 | |
365 | | - } elseif(strchr($code[0], '>')) { // end cartouche |
366 | | - $contentHtml .= "</tr>".WH_TABLE_E."</td></tr><tr><td height='".intval(WH_CARTOUCHE_WIDTH * $this->scale / 100)."px' bgcolor='black'></td></tr>".WH_TABLE_E."</td>"; |
| 365 | + } elseif ( strchr( $code[0], '>' ) ) { // end cartouche |
| 366 | + $contentHtml .= "</tr>" . WH_TABLE_E . "</td></tr><tr><td height='" . intval( WH_CARTOUCHE_WIDTH * $this->scale / 100 ) . "px' bgcolor='black'></td></tr>" . WH_TABLE_E . "</td>"; |
367 | 367 | $is_cartouche = false; |
368 | | - $contentHtml .= WH_TD_S . self::renderGlyph($code[0]).WH_TD_E; |
| 368 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0] ) . WH_TD_E; |
369 | 369 | |
370 | | - } elseif($code[0] != "") { // assum is glyph or '..' or '.' |
371 | | - $option = "height='".$this->resizeGlyph($code[0], $is_cartouche)."px'"; |
| 370 | + } elseif ( $code[0] != "" ) { // assum is glyph or '..' or '.' |
| 371 | + $option = "height='" . $this->resizeGlyph( $code[0], $is_cartouche ) . "px'"; |
372 | 372 | |
373 | | - $contentHtml .= WH_TD_S . self::renderGlyph($code[0], $option).WH_TD_E; |
| 373 | + $contentHtml .= WH_TD_S . self::renderGlyph( $code[0], $option ) . WH_TD_E; |
374 | 374 | } |
375 | 375 | |
376 | 376 | // block contain more than 1 glyph |
— | — | @@ -377,8 +377,8 @@ |
378 | 378 | |
379 | 379 | // convert all code into '&' to test prefabs glyph |
380 | 380 | $temp = ""; |
381 | | - foreach($code as $t) { |
382 | | - if(preg_match("/[*:!()]/", $t[0])) { |
| 381 | + foreach ( $code as $t ) { |
| 382 | + if ( preg_match( "/[*:!()]/", $t[0] ) ) { |
383 | 383 | $temp .= "&"; |
384 | 384 | } else { |
385 | 385 | $temp .= $t; |
— | — | @@ -386,10 +386,10 @@ |
387 | 387 | } |
388 | 388 | |
389 | 389 | // test is block is into tje prefabs list |
390 | | - if(in_array($temp, $wh_prefabs)) { |
391 | | - $option = "height='".$this->resizeGlyph($temp, $is_cartouche)."px'"; |
| 390 | + if ( in_array( $temp, $wh_prefabs ) ) { |
| 391 | + $option = "height='" . $this->resizeGlyph( $temp, $is_cartouche ) . "px'"; |
392 | 392 | |
393 | | - $contentHtml .= WH_TD_S . self::renderGlyph($temp, $option).WH_TD_E; |
| 393 | + $contentHtml .= WH_TD_S . self::renderGlyph( $temp, $option ) . WH_TD_E; |
394 | 394 | |
395 | 395 | // block must be manualy computed |
396 | 396 | } else { |
— | — | @@ -398,31 +398,31 @@ |
399 | 399 | $total = 0; |
400 | 400 | $height = 0; |
401 | 401 | |
402 | | - foreach($code as $t) { |
403 | | - if($t == ":") { |
404 | | - if($height > $line_max) { |
| 402 | + foreach ( $code as $t ) { |
| 403 | + if ( $t == ":" ) { |
| 404 | + if ( $height > $line_max ) { |
405 | 405 | $line_max = $height; |
406 | 406 | } |
407 | 407 | $total += $line_max; |
408 | 408 | $line_max = 0; |
409 | 409 | |
410 | | - } elseif($t == "*") { |
411 | | - if($height > $line_max) { |
| 410 | + } elseif ( $t == "*" ) { |
| 411 | + if ( $height > $line_max ) { |
412 | 412 | $line_max = $height; |
413 | 413 | } |
414 | 414 | } else { |
415 | | - if(array_key_exists($t, $wh_phonemes)) { |
| 415 | + if ( array_key_exists( $t, $wh_phonemes ) ) { |
416 | 416 | $glyph = $wh_phonemes[$t]; |
417 | 417 | } else { |
418 | 418 | $glyph = $t; |
419 | 419 | } |
420 | | - if(array_key_exists($glyph, $wh_files)) { |
| 420 | + if ( array_key_exists( $glyph, $wh_files ) ) { |
421 | 421 | $height = 2 + $wh_files[$glyph][1]; |
422 | 422 | } |
423 | 423 | } |
424 | 424 | } // end foreach |
425 | 425 | |
426 | | - if($height > $line_max) { |
| 426 | + if ( $height > $line_max ) { |
427 | 427 | $line_max = $height; |
428 | 428 | } |
429 | 429 | |
— | — | @@ -430,34 +430,34 @@ |
431 | 431 | |
432 | 432 | // render all glyph into the block |
433 | 433 | $temp = ""; |
434 | | - foreach($code as $t) { |
| 434 | + foreach ( $code as $t ) { |
435 | 435 | |
436 | | - if($t == ":") { |
| 436 | + if ( $t == ":" ) { |
437 | 437 | $temp .= "<br />"; |
438 | 438 | |
439 | | - } elseif($t == "*") { |
| 439 | + } elseif ( $t == "*" ) { |
440 | 440 | $temp .= " "; |
441 | 441 | |
442 | 442 | } else { |
443 | 443 | // resize the glyph according to the block total height |
444 | | - $option = "height='".$this->resizeGlyph($t, $is_cartouche, $total)."px'"; |
445 | | - $temp .= self::renderGlyph($t, $option); |
| 444 | + $option = "height='" . $this->resizeGlyph( $t, $is_cartouche, $total ) . "px'"; |
| 445 | + $temp .= self::renderGlyph( $t, $option ); |
446 | 446 | } |
447 | 447 | } // end foreach |
448 | 448 | |
449 | | - $contentHtml .= WH_TD_S.$temp.WH_TD_E; |
| 449 | + $contentHtml .= WH_TD_S . $temp . WH_TD_E; |
450 | 450 | } |
451 | 451 | $contentHtml .= "\n"; |
452 | 452 | } |
453 | 453 | |
454 | | - if(strlen($contentHtml) > 0) { |
455 | | - $tableContentHtml .= $tableHtml.$contentHtml; |
| 454 | + if ( strlen( $contentHtml ) > 0 ) { |
| 455 | + $tableContentHtml .= $tableHtml . $contentHtml; |
456 | 456 | $contentHtml = $tableHtml = ""; |
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | | - if(strlen($tableContentHtml) > 0) { |
461 | | - $html .= WH_TABLE_S."<tr>\n".$tableContentHtml."</tr>".WH_TABLE_E; |
| 460 | + if ( strlen( $tableContentHtml ) > 0 ) { |
| 461 | + $html .= WH_TABLE_S . "<tr>\n" . $tableContentHtml . "</tr>" . WH_TABLE_E; |
462 | 462 | } |
463 | 463 | |
464 | 464 | return "<table border='0' cellspacing='0' cellpadding='0' style='display:inline;' class='mw-hierotable' dir='ltr'><tr><td>\n$html\n</td></tr></table>"; |
— | — | @@ -465,7 +465,7 @@ |
466 | 466 | |
467 | 467 | } |
468 | 468 | |
469 | | -//======================================================================== |
| 469 | +// ======================================================================== |
470 | 470 | // G L O B A L S |
471 | 471 | global $wh_phonemes, $wh_text_conv; |
472 | 472 | |
— | — | @@ -866,13 +866,13 @@ |
867 | 867 | "y" => "Z4", |
868 | 868 | "W" => "Z7", |
869 | 869 | |
870 | | - "<1" => "Ca1", //cartouche |
| 870 | + "<1" => "Ca1", // cartouche |
871 | 871 | "2>" => "Ca2", |
872 | 872 | "<2" => "Ca2a", |
873 | 873 | "1>" => "Ca1a", |
874 | 874 | "<0" => "Ca1", |
875 | 875 | "0>" => "Ca2", |
876 | | - "<h1" => "Cah1", //horus |
| 876 | + "<h1" => "Cah1", // horus |
877 | 877 | "h1>" => "Cah1a", |
878 | 878 | "<h2" => "Cah2", |
879 | 879 | "h2>" => "Cah2a", |
— | — | @@ -880,7 +880,7 @@ |
881 | 881 | "h3>" => "Cah3a", |
882 | 882 | "<h0" => "Cah1", |
883 | 883 | "h0>" => "Cah1a", |
884 | | - "<" => "Ca1", //cartouche |
| 884 | + "<" => "Ca1", // cartouche |
885 | 885 | ">" => "Ca2", |
886 | 886 | "[&" => "Ba16", |
887 | 887 | "&]" => "Ba16", |
— | — | @@ -960,7 +960,7 @@ |
961 | 961 | "1>" => ")", |
962 | 962 | "<0" => "(", |
963 | 963 | "0>" => ")|", |
964 | | - "<h1" => "[", //horus |
| 964 | + "<h1" => "[", // horus |
965 | 965 | "h1>" => "]", |
966 | 966 | "<h2" => "[", |
967 | 967 | "h2>" => "]", |
— | — | @@ -968,37 +968,37 @@ |
969 | 969 | "h3>" => "]", |
970 | 970 | "<h0" => "[", |
971 | 971 | "h0>" => "]", |
972 | | - "<" => "(", //cartouche |
| 972 | + "<" => "(", // cartouche |
973 | 973 | ">" => ")|", |
974 | 974 | ); |
975 | 975 | |
976 | | -//======================================================================== |
| 976 | +// ======================================================================== |
977 | 977 | // F U N C T I O N S |
978 | 978 | |
979 | 979 | |
980 | | -//======================================================================== |
| 980 | +// ======================================================================== |
981 | 981 | // |
982 | 982 | // W i k i H i e r o |
983 | 983 | // |
984 | 984 | |
985 | | -//------------------------------------------------------------------------ |
| 985 | +// ------------------------------------------------------------------------ |
986 | 986 | // WH_GetCode - Get glyph code from file name |
987 | | -//------------------------------------------------------------------------ |
| 987 | +// ------------------------------------------------------------------------ |
988 | 988 | // file << file name |
989 | 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))); |
| 990 | +// ------------------------------------------------------------------------ |
| 991 | +function WH_GetCode( $file ) { |
| 992 | + return substr( $file, strlen( WH_IMG_PRE ), -( 1 + strlen( WH_IMG_EXT ) ) ); |
993 | 993 | } |
994 | 994 | |
995 | | -//------------------------------------------------------------------------ |
| 995 | +// ------------------------------------------------------------------------ |
996 | 996 | // WH_Credit - Get glyph code from file name |
997 | | -//------------------------------------------------------------------------ |
| 997 | +// ------------------------------------------------------------------------ |
998 | 998 | // return >> credit string |
999 | | -//------------------------------------------------------------------------ |
| 999 | +// ------------------------------------------------------------------------ |
1000 | 1000 | function WH_Credit() { |
1001 | 1001 | $html = ""; |
1002 | | - $html .= "<b>WikiHiero v".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN."</b>\n"; |
| 1002 | + $html .= "<b>WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN . "</b>\n"; |
1003 | 1003 | $html .= "by Guillaume Blanchard (Aoineko) under GPL (2004).<br />\n"; |
1004 | 1004 | $html .= "Hieroglyph credit: S. Rosmorduc, G. Watson, J. Hirst (under GFDL).\n"; |
1005 | 1005 | return $html; |
Index: trunk/extensions/wikihiero/wh_table.php |
— | — | @@ -32,13 +32,13 @@ |
33 | 33 | # |
34 | 34 | |
35 | 35 | # Fixme ! webRequest :) |
36 | | -if(array_key_exists("table", $_GET)) { |
| 36 | +if ( array_key_exists( "table", $_GET ) ) { |
37 | 37 | $table = $_GET["table"]; |
38 | 38 | } else { |
39 | 39 | $table = "All"; |
40 | 40 | } |
41 | 41 | |
42 | | -if(array_key_exists("lang", $_GET)) { |
| 42 | +if ( array_key_exists( "lang", $_GET ) ) { |
43 | 43 | $lang = $_GET["lang"]; |
44 | 44 | } else { |
45 | 45 | $lang = "fr"; |
— | — | @@ -49,8 +49,8 @@ |
50 | 50 | global $wh_language; |
51 | 51 | global $lang; |
52 | 52 | |
53 | | - if(isset($wh_language[$index])) { |
54 | | - if(isset($wh_language[$index][$lang])) { |
| 53 | + if ( isset( $wh_language[$index] ) ) { |
| 54 | + if ( isset( $wh_language[$index][$lang] ) ) { |
55 | 55 | return $wh_language[$index][$lang]; |
56 | 56 | } else { |
57 | 57 | return $wh_language[$index]["en"]; |
— | — | @@ -61,9 +61,9 @@ |
62 | 62 | } |
63 | 63 | |
64 | 64 | ?> |
65 | | -<html lang=<?php echo htmlspecialchars($lang); ?>> |
| 65 | +<html lang=<?php echo htmlspecialchars( $lang ); ?>> |
66 | 66 | <head> |
67 | | - <title><?php echo htmlspecialchars($table)." - ".WH_Text($table); ?> - WikiHiero</title> |
| 67 | + <title><?php echo htmlspecialchars( $table ) . " - " . WH_Text( $table ); ?> - WikiHiero</title> |
68 | 68 | <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> |
69 | 69 | <link rel="shortcut icon" href="https://www.mediawiki.org/favicon.ico"> |
70 | 70 | </head> |
— | — | @@ -71,59 +71,59 @@ |
72 | 72 | |
73 | 73 | <?php |
74 | 74 | |
75 | | - echo "<b>" . htmlspecialchars( $table ) . "</b> - ".WH_Text($table)."<br /><br />"; |
76 | | - $dh = opendir(WH_IMG_DIR); |
77 | | - if( $dh ) { |
78 | | - while(($file = readdir($dh)) !== false) { |
79 | | - if($table == "All") |
| 75 | + echo "<b>" . htmlspecialchars( $table ) . "</b> - " . WH_Text( $table ) . "<br /><br />"; |
| 76 | + $dh = opendir( WH_IMG_DIR ); |
| 77 | + if ( $dh ) { |
| 78 | + while ( ( $file = readdir( $dh ) ) !== false ) { |
| 79 | + if ( $table == "All" ) |
80 | 80 | { |
81 | | - $code = WH_GetCode($file); |
82 | | - if(in_array($code, $wh_phonemes)) |
83 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ) . "\" " . |
84 | | - "title=\"" . htmlspecialchars( $code ) . " [". |
85 | | - htmlspecialchars( array_search($code, $wh_phonemes) ) . "]\">\n"; |
| 81 | + $code = WH_GetCode( $file ); |
| 82 | + if ( in_array( $code, $wh_phonemes ) ) |
| 83 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" " . |
| 84 | + "title=\"" . htmlspecialchars( $code ) . " [" . |
| 85 | + htmlspecialchars( array_search( $code, $wh_phonemes ) ) . "]\">\n"; |
86 | 86 | else |
87 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ) . "\" title=\"" . |
| 87 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" title=\"" . |
88 | 88 | htmlspecialchars( $code ) . "\">\n"; |
89 | 89 | } |
90 | | - elseif($table == "Phoneme") |
| 90 | + elseif ( $table == "Phoneme" ) |
91 | 91 | { |
92 | | - $code = WH_GetCode($file); |
93 | | - if(in_array($code, $wh_phonemes)) |
94 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ) . "\" " . |
95 | | - "title=\"" . htmlspecialchars( $code ) . " [". |
96 | | - htmlspecialchars( array_search($code, $wh_phonemes) )."]\">\n"; |
| 92 | + $code = WH_GetCode( $file ); |
| 93 | + if ( in_array( $code, $wh_phonemes ) ) |
| 94 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" " . |
| 95 | + "title=\"" . htmlspecialchars( $code ) . " [" . |
| 96 | + htmlspecialchars( array_search( $code, $wh_phonemes ) ) . "]\">\n"; |
97 | 97 | } |
98 | | - elseif($table == "Aa") |
| 98 | + elseif ( $table == "Aa" ) |
99 | 99 | { |
100 | | - $code = WH_GetCode($file); |
101 | | - if((substr($code, 0, 2) == $table) && ctype_digit($code[2])) |
| 100 | + $code = WH_GetCode( $file ); |
| 101 | + if ( ( substr( $code, 0, 2 ) == $table ) && ctype_digit( $code[2] ) ) |
102 | 102 | { |
103 | | - if(in_array($code, $wh_phonemes)) |
104 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file) . "\" title=\"" . |
105 | | - htmlspecialchars( $code ) . " [". |
106 | | - htmlspecialchars( array_search($code, $wh_phonemes) )."]\">\n"; |
| 103 | + if ( in_array( $code, $wh_phonemes ) ) |
| 104 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" title=\"" . |
| 105 | + htmlspecialchars( $code ) . " [" . |
| 106 | + htmlspecialchars( array_search( $code, $wh_phonemes ) ) . "]\">\n"; |
107 | 107 | else |
108 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ) . "\" title=\"" . |
| 108 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" title=\"" . |
109 | 109 | htmlspecialchars( $code ) . "\">\n"; |
110 | 110 | } |
111 | 111 | } |
112 | 112 | else |
113 | 113 | { |
114 | | - $code = WH_GetCode($file); |
115 | | - if(($code[0] == $table) && ctype_digit($code[1])) |
| 114 | + $code = WH_GetCode( $file ); |
| 115 | + if ( ( $code[0] == $table ) && ctype_digit( $code[1] ) ) |
116 | 116 | { |
117 | | - if(in_array($code, $wh_phonemes)) |
118 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ) . "\" title=\"" . |
119 | | - htmlspecialchars( $code ) . "[". |
120 | | - htmlspecialchars( array_search($code, $wh_phonemes) )."]\">\n"; |
| 117 | + if ( in_array( $code, $wh_phonemes ) ) |
| 118 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" title=\"" . |
| 119 | + htmlspecialchars( $code ) . "[" . |
| 120 | + htmlspecialchars( array_search( $code, $wh_phonemes ) ) . "]\">\n"; |
121 | 121 | else |
122 | | - echo "<img src=\"".htmlspecialchars( WH_IMG_DIR.$file ). "\" title=\"" . |
| 122 | + echo "<img src=\"" . htmlspecialchars( WH_IMG_DIR . $file ) . "\" title=\"" . |
123 | 123 | htmlspecialchars( $code ) . "\">\n"; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | | - closedir($dh); |
| 127 | + closedir( $dh ); |
128 | 128 | } |
129 | 129 | |
130 | 130 | ?> |
Index: trunk/extensions/wikihiero/index.php |
— | — | @@ -29,40 +29,40 @@ |
30 | 30 | |
31 | 31 | $IP = getenv( 'MW_INSTALL_PATH' ); |
32 | 32 | if ( $IP === false ) { |
33 | | - $IP = dirname( __FILE__ ) .'/../..'; |
| 33 | + $IP = dirname( __FILE__ ) . '/../..'; |
34 | 34 | } |
35 | 35 | require( "$IP/includes/WebStart.php" ); |
36 | 36 | |
37 | | -require('wh_language.php'); |
38 | | -require('wikihiero.php'); |
| 37 | +require( 'wh_language.php' ); |
| 38 | +require( 'wikihiero.php' ); |
39 | 39 | # |
40 | 40 | # Initialization from request |
41 | 41 | # |
42 | 42 | |
43 | 43 | # FIXME : use webRequest |
44 | | -if(isset($_POST["text"])) |
| 44 | +if ( isset( $_POST["text"] ) ) |
45 | 45 | $text = $_POST["text"]; |
46 | 46 | else |
47 | 47 | $text = "anx-G5-zmA:tA:tA-nbty-zmA:tA:tA-sw:t-bit:t-<-zA-ra:.-mn:n-T:w-Htp:t*p->-anx-D:t:N17-!"; |
48 | 48 | |
49 | | -if(isset($_POST["scale"])) |
| 49 | +if ( isset( $_POST["scale"] ) ) |
50 | 50 | $scale = $_POST["scale"]; |
51 | 51 | else |
52 | 52 | $scale = $wh_scale; |
53 | 53 | |
54 | | -if(isset($_POST["mode"])) |
| 54 | +if ( isset( $_POST["mode"] ) ) |
55 | 55 | $mode = $_POST["mode"]; |
56 | 56 | else |
57 | 57 | $mode = $wh_mode; |
58 | 58 | |
59 | | -if(isset($_POST["lang"])) |
| 59 | +if ( isset( $_POST["lang"] ) ) |
60 | 60 | $lang = $_POST["lang"]; |
61 | | -elseif(isset($_GET["lang"])) |
| 61 | +elseif ( isset( $_GET["lang"] ) ) |
62 | 62 | $lang = $_GET["lang"]; |
63 | 63 | else |
64 | 64 | $lang = "fr"; |
65 | 65 | |
66 | | -if(isset($_POST["line"])) |
| 66 | +if ( isset( $_POST["line"] ) ) |
67 | 67 | $line = $_POST["line"]; |
68 | 68 | else |
69 | 69 | $line = false; |
— | — | @@ -75,8 +75,8 @@ |
76 | 76 | global $wh_language; |
77 | 77 | global $lang; |
78 | 78 | |
79 | | - if(isset($wh_language[$index])) { |
80 | | - if(isset($wh_language[$index][$lang])) |
| 79 | + if ( isset( $wh_language[$index] ) ) { |
| 80 | + if ( isset( $wh_language[$index][$lang] ) ) |
81 | 81 | return $wh_language[$index][$lang]; |
82 | 82 | else |
83 | 83 | return $wh_language[$index]["en"]; |
— | — | @@ -85,15 +85,15 @@ |
86 | 86 | } |
87 | 87 | |
88 | 88 | function WH_Packet( $ext ) { |
89 | | - if(file_exists("wikihiero.$ext")) { |
90 | | - $size = filesize("wikihiero.$ext"); |
91 | | - if($size <= 1024*1024) { |
92 | | - return sprintf("<a href=\"wikihiero.$ext\" title=\"%.2f Kb\">%s</a>", filesize("wikihiero.$ext")/1024, strtoupper($ext)); |
| 89 | + if ( file_exists( "wikihiero.$ext" ) ) { |
| 90 | + $size = filesize( "wikihiero.$ext" ); |
| 91 | + if ( $size <= 1024 * 1024 ) { |
| 92 | + return sprintf( "<a href=\"wikihiero.$ext\" title=\"%.2f Kb\">%s</a>", filesize( "wikihiero.$ext" ) / 1024, strtoupper( $ext ) ); |
93 | 93 | } else { |
94 | | - return sprintf("<a href=\"wikihiero.$ext\" title=\"%.2f Mb\">%s</a>", filesize("wikihiero.$ext")/(1024*1024), strtoupper($ext)); |
| 94 | + return sprintf( "<a href=\"wikihiero.$ext\" title=\"%.2f Mb\">%s</a>", filesize( "wikihiero.$ext" ) / ( 1024 * 1024 ), strtoupper( $ext ) ); |
95 | 95 | } |
96 | 96 | } else { |
97 | | - return "<font title=\"File <wikihiero.$ext> not found!\">".strtoupper($ext)."</font>"; |
| 97 | + return "<font title=\"File <wikihiero.$ext> not found!\">" . strtoupper( $ext ) . "</font>"; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | global $lang; |
103 | 103 | $url = "wh_table.php?table=" . urlencode( $table ) . '&lang=' . urlencode( $lang ); |
104 | 104 | $encUrl = htmlspecialchars( Xml::encodeJsVar( $url ) ); |
105 | | - echo "<a href=\"#\" onClick=\"MyWindow=window.open($encUrl,'$table','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300,left=20,top=20'); return false;\" title =\"".WH_Text($table)."\">$table</a>"; |
| 105 | + echo "<a href=\"#\" onClick=\"MyWindow=window.open($encUrl,'$table','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300,left=20,top=20'); return false;\" title =\"" . WH_Text( $table ) . "\">$table</a>"; |
106 | 106 | } |
107 | 107 | |
108 | 108 | # |
— | — | @@ -109,10 +109,10 @@ |
110 | 110 | # |
111 | 111 | |
112 | 112 | $start_time = microtime(); |
113 | | -list($a_dec, $a_sec) = explode(" ", $start_time); |
114 | | -$html = WikiHiero($text, $mode, $scale, $line); |
115 | | -list($b_dec, $b_sec) = explode(" ", microtime()); |
116 | | -$process_time = sprintf("%0.3f sec", $b_sec - $a_sec + $b_dec - $a_dec); |
| 113 | +list( $a_dec, $a_sec ) = explode( " ", $start_time ); |
| 114 | +$html = WikiHiero( $text, $mode, $scale, $line ); |
| 115 | +list( $b_dec, $b_sec ) = explode( " ", microtime() ); |
| 116 | +$process_time = sprintf( "%0.3f sec", $b_sec - $a_sec + $b_dec - $a_dec ); |
117 | 117 | |
118 | 118 | ?> |
119 | 119 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
— | — | @@ -143,83 +143,83 @@ |
144 | 144 | <TABLE border="0"> |
145 | 145 | <TR valign="top"><TD> |
146 | 146 | |
147 | | - <BIG><?php echo "WikiHiero v".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN; ?></BIG><br /> |
| 147 | + <BIG><?php echo "WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN; ?></BIG><br /> |
148 | 148 | <SMALL>[<?php |
149 | 149 | |
150 | | - reset($wh_language['Lang']); |
151 | | - while($l = current($wh_language['Lang'])) |
| 150 | + reset( $wh_language['Lang'] ); |
| 151 | + while ( $l = current( $wh_language['Lang'] ) ) |
152 | 152 | { |
153 | | - if(key($wh_language['Lang']) == $lang) |
| 153 | + if ( key( $wh_language['Lang'] ) == $lang ) |
154 | 154 | echo "<b>$l</b>"; |
155 | 155 | else |
156 | | - echo "<a href=\"javascript:LangLink('".key($wh_language['Lang'])."');\">$l</a>"; |
157 | | - next($wh_language['Lang']); |
158 | | - $l = current($wh_language['Lang']); |
159 | | - if( $l ) |
| 156 | + echo "<a href=\"javascript:LangLink('" . key( $wh_language['Lang'] ) . "');\">$l</a>"; |
| 157 | + next( $wh_language['Lang'] ); |
| 158 | + $l = current( $wh_language['Lang'] ); |
| 159 | + if ( $l ) |
160 | 160 | echo " | "; |
161 | 161 | } |
162 | 162 | ?>]</SMALL> |
163 | 163 | <br /><br /> |
164 | 164 | |
165 | 165 | <form name="wh_form" action="index.php?lang=<?php echo $lang; ?>" method="post"> |
166 | | - <textarea name="text" cols="60" rows="10" title="<?php echo WH_Text("Text"); ?>"><?php echo $text; ?></textarea> |
| 166 | + <textarea name="text" cols="60" rows="10" title="<?php echo WH_Text( "Text" ); ?>"><?php echo $text; ?></textarea> |
167 | 167 | <br /><br /> |
168 | | - <input type="submit" title="<?php echo WH_Text("Convert"); ?>" value="<?php echo WH_Text("Convert"); ?>"> |
169 | | - <select title="<?php echo WH_Text("Mode"); ?>" name="mode"> |
170 | | - <option value="0" <?php if($mode==0) echo "selected"; ?> title="<?php echo WH_Text("TEXT"); ?>" onclick="javascript:DisableScale(true);">Text only |
171 | | - <option value="1" <?php if($mode==1) echo "selected"; ?> title="<?php echo WH_Text("HTML"); ?>" onclick="javascript:DisableScale(false);">Simple HTML |
172 | | - <option disabled value="2" <?php if($mode==2) echo "selected"; ?> title="<?php echo WH_Text("CSS"); ?>">HTML & CSS |
173 | | - <option disabled value="3" <?php if($mode==3) echo "selected"; ?> title="<?php echo WH_Text("Image"); ?>">Image |
| 168 | + <input type="submit" title="<?php echo WH_Text( "Convert" ); ?>" value="<?php echo WH_Text( "Convert" ); ?>"> |
| 169 | + <select title="<?php echo WH_Text( "Mode" ); ?>" name="mode"> |
| 170 | + <option value="0" <?php if ( $mode == 0 ) echo "selected"; ?> title="<?php echo WH_Text( "TEXT" ); ?>" onclick="javascript:DisableScale(true);">Text only |
| 171 | + <option value="1" <?php if ( $mode == 1 ) echo "selected"; ?> title="<?php echo WH_Text( "HTML" ); ?>" onclick="javascript:DisableScale(false);">Simple HTML |
| 172 | + <option disabled value="2" <?php if ( $mode == 2 ) echo "selected"; ?> title="<?php echo WH_Text( "CSS" ); ?>">HTML & CSS |
| 173 | + <option disabled value="3" <?php if ( $mode == 3 ) echo "selected"; ?> title="<?php echo WH_Text( "Image" ); ?>">Image |
174 | 174 | </select> |
175 | | - <?php echo WH_Text("Scale"); ?><input type="range" name="scale" <?php if($mode==0) echo "disabled"; ?> title="<?php echo WH_Text("Size"); ?>" min="1" max="999" size="3" maxlength="3" value="<?php echo htmlspecialchars( $scale ); ?>">% |
176 | | - <?php echo WH_Text("Line"); ?><input type="checkbox" name="line" <?php if($line) echo "checked"; ?>> |
| 175 | + <?php echo WH_Text( "Scale" ); ?><input type="range" name="scale" <?php if ( $mode == 0 ) echo "disabled"; ?> title="<?php echo WH_Text( "Size" ); ?>" min="1" max="999" size="3" maxlength="3" value="<?php echo htmlspecialchars( $scale ); ?>">% |
| 176 | + <?php echo WH_Text( "Line" ); ?><input type="checkbox" name="line" <?php if ( $line ) echo "checked"; ?>> |
177 | 177 | <input type="hidden" name="lang" value="<?php echo htmlspecialchars( $lang ); ?>"> |
178 | 178 | </form> |
179 | 179 | |
180 | 180 | </td><td valign="top"> |
181 | 181 | |
182 | | - <b><?php echo WH_Text("Syntax"); ?></b><br /> |
183 | | - <tt>-</tt> <?php echo WH_Text("-"); ?><br /> |
184 | | - <tt>:</tt> <?php echo WH_Text(":"); ?><br /> |
185 | | - <tt>*</tt> <?php echo WH_Text("*"); ?><br /> |
186 | | - <tt>!</tt> <?php echo WH_Text("!"); ?><br /> |
| 182 | + <b><?php echo WH_Text( "Syntax" ); ?></b><br /> |
| 183 | + <tt>-</tt> <?php echo WH_Text( "-" ); ?><br /> |
| 184 | + <tt>:</tt> <?php echo WH_Text( ":" ); ?><br /> |
| 185 | + <tt>*</tt> <?php echo WH_Text( "*" ); ?><br /> |
| 186 | + <tt>!</tt> <?php echo WH_Text( "!" ); ?><br /> |
187 | 187 | |
188 | 188 | <br /> |
189 | | - <b><?php echo WH_Text("Tables"); ?></b><br /> |
190 | | - <?php WH_Table("Phoneme"); ?> |
191 | | - | <?php WH_Table("A"); ?> |
192 | | - | <?php WH_Table("B"); ?> |
193 | | - | <?php WH_Table("C"); ?> |
194 | | - | <?php WH_Table("D"); ?> |
195 | | - | <?php WH_Table("E"); ?> |
196 | | - | <?php WH_Table("F"); ?> |
197 | | - | <?php WH_Table("G"); ?> |
198 | | - | <?php WH_Table("H"); ?> |
199 | | - | <?php WH_Table("I"); ?> |
200 | | - | <?php WH_Table("J"); ?> |
201 | | - | <?php WH_Table("K"); ?> |
202 | | - | <?php WH_Table("L"); ?> |
203 | | - | <?php WH_Table("M"); ?> |
204 | | - | <?php WH_Table("N"); ?> |
205 | | - | <?php WH_Table("O"); ?> |
206 | | - | <?php WH_Table("P"); ?> |
207 | | - | <?php WH_Table("Q"); ?> |
208 | | - | <?php WH_Table("R"); ?> |
209 | | - | <?php WH_Table("S"); ?> |
210 | | - | <?php WH_Table("T"); ?> |
211 | | - | <?php WH_Table("U"); ?> |
212 | | - | <?php WH_Table("V"); ?> |
213 | | - | <?php WH_Table("W"); ?> |
214 | | - | <?php WH_Table("X"); ?> |
215 | | - | <?php WH_Table("Y"); ?> |
216 | | - | <?php WH_Table("Z"); ?> |
217 | | - | <?php WH_Table("Aa"); ?> |
218 | | - | <?php WH_Table("All"); ?> |
| 189 | + <b><?php echo WH_Text( "Tables" ); ?></b><br /> |
| 190 | + <?php WH_Table( "Phoneme" ); ?> |
| 191 | + | <?php WH_Table( "A" ); ?> |
| 192 | + | <?php WH_Table( "B" ); ?> |
| 193 | + | <?php WH_Table( "C" ); ?> |
| 194 | + | <?php WH_Table( "D" ); ?> |
| 195 | + | <?php WH_Table( "E" ); ?> |
| 196 | + | <?php WH_Table( "F" ); ?> |
| 197 | + | <?php WH_Table( "G" ); ?> |
| 198 | + | <?php WH_Table( "H" ); ?> |
| 199 | + | <?php WH_Table( "I" ); ?> |
| 200 | + | <?php WH_Table( "J" ); ?> |
| 201 | + | <?php WH_Table( "K" ); ?> |
| 202 | + | <?php WH_Table( "L" ); ?> |
| 203 | + | <?php WH_Table( "M" ); ?> |
| 204 | + | <?php WH_Table( "N" ); ?> |
| 205 | + | <?php WH_Table( "O" ); ?> |
| 206 | + | <?php WH_Table( "P" ); ?> |
| 207 | + | <?php WH_Table( "Q" ); ?> |
| 208 | + | <?php WH_Table( "R" ); ?> |
| 209 | + | <?php WH_Table( "S" ); ?> |
| 210 | + | <?php WH_Table( "T" ); ?> |
| 211 | + | <?php WH_Table( "U" ); ?> |
| 212 | + | <?php WH_Table( "V" ); ?> |
| 213 | + | <?php WH_Table( "W" ); ?> |
| 214 | + | <?php WH_Table( "X" ); ?> |
| 215 | + | <?php WH_Table( "Y" ); ?> |
| 216 | + | <?php WH_Table( "Z" ); ?> |
| 217 | + | <?php WH_Table( "Aa" ); ?> |
| 218 | + | <?php WH_Table( "All" ); ?> |
219 | 219 | <br /><br /> |
220 | 220 | |
221 | | - <b><?php echo WH_Text("Download"); ?></b><br /> |
222 | | - [<?php echo WH_Packet("rar"); ?>] - |
223 | | - [<?php echo WH_Packet("zip"); ?>] - |
| 221 | + <b><?php echo WH_Text( "Download" ); ?></b><br /> |
| 222 | + [<?php echo WH_Packet( "rar" ); ?>] - |
| 223 | + [<?php echo WH_Packet( "zip" ); ?>] - |
224 | 224 | <a href="README">ReadMe</a> |
225 | 225 | |
226 | 226 | </td></tr> |
— | — | @@ -240,7 +240,7 @@ |
241 | 241 | <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-style:solid; border-width:1px; padding:1em; border-color:gray; background:#ffffff;"> |
242 | 242 | <tr valign="middle"><td> |
243 | 243 | |
244 | | - <pre><?php echo htmlentities($html); ?></pre> |
| 244 | + <pre><?php echo htmlentities( $html ); ?></pre> |
245 | 245 | |
246 | 246 | </td></tr> |
247 | 247 | </table> |
Index: trunk/extensions/wikihiero/wh_generate.php |
— | — | @@ -2,22 +2,22 @@ |
3 | 3 | |
4 | 4 | ////////////////////////////////////////////////////////////////////////// |
5 | 5 | // |
6 | | -// WikiHiero - A PHP convert from text using "Manual for the encoding of |
| 6 | +// WikiHiero - A PHP convert from text using "Manual for the encoding of |
7 | 7 | // hieroglyphic texts for computer input" syntax to HTML entities (table and |
8 | 8 | // images). |
9 | 9 | // |
10 | 10 | // Copyright (C) 2004 Guillaume Blanchard (Aoineko) |
11 | | -// |
| 11 | +// |
12 | 12 | // This program is free software; you can redistribute it and/or |
13 | 13 | // modify it under the terms of the GNU General Public License |
14 | 14 | // as published by the Free Software Foundation; either version 2 |
15 | 15 | // of the License, or any later version. |
16 | | -// |
| 16 | +// |
17 | 17 | // This program is distributed in the hope that it will be useful, |
18 | 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | 20 | // GNU General Public License for more details. |
21 | | -// |
| 21 | +// |
22 | 22 | // You should have received a copy of the GNU General Public License |
23 | 23 | // along with this program; if not, write to the Free Software |
24 | 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | |
32 | 32 | include "wh_main.php"; |
33 | 33 | |
34 | | -if(array_key_exists("lang", $_GET)) { |
| 34 | +if ( array_key_exists( "lang", $_GET ) ) { |
35 | 35 | $lang = $_GET["lang"]; |
36 | 36 | } else { |
37 | 37 | $lang = "fr"; |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | </head> |
46 | 46 | <body bgcolor="#DDDDDD"> |
47 | 47 | |
48 | | - <big><?php echo "WikiHiero v".WH_VER_MAJ.".".WH_VER_MED.".".WH_VER_MIN; ?></big> |
| 48 | + <big><?php echo "WikiHiero v" . WH_VER_MAJ . "." . WH_VER_MED . "." . WH_VER_MIN; ?></big> |
49 | 49 | |
50 | 50 | <br /><br />Parsing hieroglyph files and creating tables...<br /><br /> |
51 | 51 | |
— | — | @@ -53,24 +53,24 @@ |
54 | 54 | $wh_prefabs = "\$wh_prefabs = array(\n"; |
55 | 55 | $wh_files = "\$wh_files = array(\n"; |
56 | 56 | |
57 | | - $img_dir = dirname(__FILE__) . '/img/'; |
| 57 | + $img_dir = dirname( __FILE__ ) . '/img/'; |
58 | 58 | |
59 | | - if(is_dir($img_dir)) |
| 59 | + if ( is_dir( $img_dir ) ) |
60 | 60 | { |
61 | | - $dh = opendir($img_dir); |
| 61 | + $dh = opendir( $img_dir ); |
62 | 62 | if ( $dh ) |
63 | 63 | { |
64 | | - while (($file = readdir($dh)) !== false) |
| 64 | + while ( ( $file = readdir( $dh ) ) !== false ) |
65 | 65 | { |
66 | | - if(stristr($file, WH_IMG_EXT)) |
| 66 | + if ( stristr( $file, WH_IMG_EXT ) ) |
67 | 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"; |
| 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 | 72 | } |
73 | 73 | } |
74 | | - closedir($dh); |
| 74 | + closedir( $dh ); |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
— | — | @@ -80,17 +80,17 @@ |
81 | 81 | echo "<pre>$wh_prefabs<br /><br />"; |
82 | 82 | echo "$wh_files<br /><br /></pre>"; |
83 | 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); |
| 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 | 93 | |
94 | | - //if(file_exists("wh_list(0).php")) |
| 94 | + // if(file_exists("wh_list(0).php")) |
95 | 95 | |
96 | 96 | ?> |
97 | 97 | |