--color=light will bright diffs output
[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 $wgExtensionFunctions[] = "wfUnicodeConverter";
8
9 function wfUnicodeConverter() {
10
11 require_once( "SpecialPage.php" );
12
13 class UnicodeConverter extends SpecialPage
14 {
15 function UnicodeConverter() {
16 SpecialPage::SpecialPage("UnicodeConverter");
17 }
18
19 function execute( $par ) {
20 global $wgRequest, $wgOut, $wgTitle;
21
22 $this->setHeaders();
23
24 $q = $wgRequest->getText( 'q' );
25 $encQ = htmlspecialchars( $q );
26 $action = $wgTitle->getLocalUrl();
27 $ok = wfMsg( "ok" );
28
29 $wgOut->addHTML( "
30 <form name=ucf method=post action=\"$action\">
31 <textarea rows=15 cols=80 name=q>
32 $encQ
33 </textarea><br />
34 <input type=submit name=submit value=\"$ok\"><br /><br />
35 </form>" );
36
37 if ( !is_null( $q ) ) {
38 $html = wfUtf8ToHTML( $q );
39 $wgOut->addHTML( "\n\n\n" . nl2br( $html ) . "\n<hr>\n" .
40 nl2br( htmlspecialchars( $html ) ) . "\n\n" );
41 }
42 }
43 }
44
45 global $wgMessageCache;
46 SpecialPage::addPage( new UnicodeConverter );
47 $wgMessageCache->addMessage( "unicodeconverter", "Unicode Converter" );
48
49 } # End of extension function
50 ?>