3 # This is a simple example of a special page module
4 # Given a string in UTF-8, it converts it to HTML entities suitable for
5 # an ISO 8859-1 web page.
7 # Not a valid entry point, skip unless MEDIAWIKI is defined
8 if (defined('MEDIAWIKI')) {
9 $wgExtensionFunctions[] = "wfUnicodeConverter";
11 function wfUnicodeConverter() {
13 require_once( "$IP/includes/SpecialPage.php" );
15 class UnicodeConverter
extends SpecialPage
17 function UnicodeConverter() {
18 SpecialPage
::SpecialPage("UnicodeConverter");
21 function execute( $par ) {
22 global $wgRequest, $wgOut, $wgTitle;
26 $q = $wgRequest->getText( 'q' );
27 $encQ = htmlspecialchars( $q );
28 $action = $wgTitle->escapeLocalUrl();
29 $ok = htmlspecialchars( wfMsg( "ok" ) );
31 $wgOut->addHTML( <<<END
32 <form name="ucf" method="post" action="$action">
33 <textarea rows="15" cols="80" name="q">$encQ</textarea><br />
34 <input type="submit" name="submit" value="$ok" /><br /><br />
39 if ( !is_null( $q ) ) {
40 $html = wfUtf8ToHTML( htmlspecialchars( $q ) );
41 $wgOut->addHTML( "\n\n\n" . nl2br( $html ) . "\n<hr />\n" .
42 nl2br( htmlspecialchars( $html ) ) . "\n\n" );
47 global $wgMessageCache;
48 SpecialPage
::addPage( new UnicodeConverter
);
49 $wgMessageCache->addMessage( "unicodeconverter", "Unicode Converter" );
51 } # End of extension function
52 } # End of invocation guard