Subject UtfNormal::cleanUp() to the same tests as UtfNormal::toNFC()
[lhc/web/wiklou.git] / extensions / UnicodeConverter.php
1 <?php
2
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.
6
7 # Not a valid entry point, skip unless MEDIAWIKI is defined
8 if (defined('MEDIAWIKI')) {
9 $wgExtensionFunctions[] = "wfUnicodeConverter";
10
11 function wfUnicodeConverter() {
12 global $IP;
13 require_once( "$IP/includes/SpecialPage.php" );
14
15 class UnicodeConverter extends SpecialPage
16 {
17 function UnicodeConverter() {
18 SpecialPage::SpecialPage("UnicodeConverter");
19 }
20
21 function execute( $par ) {
22 global $wgRequest, $wgOut, $wgTitle;
23
24 $this->setHeaders();
25
26 $q = $wgRequest->getText( 'q' );
27 $encQ = htmlspecialchars( $q );
28 $action = $wgTitle->escapeLocalUrl();
29 $ok = htmlspecialchars( wfMsg( "ok" ) );
30
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 />
35 </form>
36 END
37 );
38
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" );
43 }
44 }
45 }
46
47 global $wgMessageCache;
48 SpecialPage::addPage( new UnicodeConverter );
49 $wgMessageCache->addMessage( "unicodeconverter", "Unicode Converter" );
50
51 } # End of extension function
52 } # End of invocation guard
53 ?>