wikihiero.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. //////////////////////////////////////////////////////////////////////////
  3. //
  4. // WikiHiero - A PHP convert from text using "Manual for the encoding of
  5. // hieroglyphic texts for computer input" syntax to HTML entities (table and
  6. // images).
  7. //
  8. // Copyright (C) 2004 Guillaume Blanchard (Aoineko)
  9. //
  10. // This program is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU General Public License
  12. // as published by the Free Software Foundation; either version 2
  13. // of the License, or any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program; if not, write to the Free Software
  22. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. //
  24. //////////////////////////////////////////////////////////////////////////
  25. // Register MediaWiki extension
  26. $wgHooks['ParserFirstCallInit'][] = 'WH_Register';
  27. $wgExtensionCredits['parserhook'][] = array(
  28. 'path' => __FILE__,
  29. 'name' => 'WikiHiero',
  30. 'author' => 'Guillaume Blanchard',
  31. 'url' => 'http://www.mediawiki.org/wiki/Extension:WikiHiero',
  32. 'description' => 'Syntax to display hieroglyph',
  33. 'descriptionmsg' => 'wikihiero-desc',
  34. );
  35. $wgExtensionMessagesFiles['Wikihiero'] = dirname(__FILE__) . '/wikihiero.i18n.php';
  36. function WH_Register( &$parser ) {
  37. $parser->setHook( 'hiero', 'WikiHieroLoader' );
  38. return true;
  39. }
  40. function WikiHieroLoad() {
  41. static $loaded = false;
  42. if ( !$loaded ) {
  43. require( dirname( __FILE__ ) . '/wh_main.php' );
  44. $loaded = true;
  45. }
  46. }
  47. // MediaWiki entry point
  48. function WikiHieroLoader( $text, $attribs, &$parser ) {
  49. WikiHieroLoad();
  50. $parser->setHook( 'hiero', 'WikiHieroHook' );
  51. return WikiHieroHook( $text, $attribs, $parser );
  52. }
  53. // Generic embedded entry point
  54. function WikiHiero($hiero, $mode=WH_MODE_DEFAULT, $scale=WH_SCALE_DEFAULT, $line=false) {
  55. WikiHieroLoad();
  56. return _WikiHiero( $hiero, $mode, $scale, $line );
  57. }
  58. // If anyone needs WikiHieroHTML() etc., loader functions should be put here.
  59. // Hopefully everyone's using the general-purpose entry point above.