Index: trunk/extensions/AjaxTest/AjaxTest.alias.php |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for special pages |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$aliases = array(); |
| 11 | + |
| 12 | +/** English */ |
| 13 | +$aliases['en'] = array( |
| 14 | + 'AjaxTest' => array( 'AjaxTest' ), |
| 15 | +); |
Property changes on: trunk/extensions/AjaxTest/AjaxTest.alias.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 16 | + native |
Name: svn:keywords |
2 | 17 | + Id |
Index: trunk/extensions/AjaxTest/AjaxTestPage.php |
— | — | @@ -8,20 +8,19 @@ |
9 | 9 | * @licence GNU General Public Licence 2.0 or later |
10 | 10 | */ |
11 | 11 | |
12 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 12 | +if ( !defined( 'MEDIAWIKI' ) ) { |
13 | 13 | echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" ); |
14 | 14 | die( 1 ); |
15 | 15 | } |
16 | 16 | |
17 | 17 | class AjaxTestPage extends SpecialPage { |
18 | | - |
19 | 18 | /** |
20 | 19 | * Constructor |
21 | 20 | */ |
22 | 21 | function __construct() { |
23 | 22 | SpecialPage::SpecialPage( 'AjaxTest', '', true ); |
24 | 23 | } |
25 | | - |
| 24 | + |
26 | 25 | /** |
27 | 26 | * Main execution function |
28 | 27 | * @param $par Parameters passed to the page |
— | — | @@ -29,18 +28,18 @@ |
30 | 29 | function execute( $par ) { |
31 | 30 | global $wgRequest, $wgOut; |
32 | 31 | global $wgJsMimeType, $wgScriptPath; |
33 | | - |
| 32 | + |
34 | 33 | $this->setHeaders(); |
35 | | - |
36 | | - $wgOut->addScript( |
| 34 | + |
| 35 | + $wgOut->addScript( |
37 | 36 | "<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/AjaxTest/AjaxTest.js\">" . |
38 | | - "</script>\n" |
| 37 | + "</script>\n" |
39 | 38 | ); |
40 | | - |
41 | | - |
| 39 | + |
| 40 | + |
42 | 41 | $wgOut->addHTML( $this->makeInputForm() ); |
43 | 42 | } |
44 | | - |
| 43 | + |
45 | 44 | /** |
46 | 45 | * Input form for entering a category |
47 | 46 | */ |
— | — | @@ -51,16 +50,16 @@ |
52 | 51 | $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'ajaxtest_text', 'id' => 'ajaxtest_text', 'value' => '', 'size' => '64' ) ) . ' '; |
53 | 52 | $form .= Xml::element( 'br' ); |
54 | 53 | $form .= Xml::element( 'label', array( 'for' => 'usestring' ), 'use string value' ); |
55 | | - $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'usestring', 'id' => 'usestring') ); |
| 54 | + $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'usestring', 'id' => 'usestring' ) ); |
56 | 55 | $form .= Xml::element( 'br' ); |
57 | 56 | $form .= Xml::element( 'label', array( 'for' => 'httpcache' ), 'use http cache' ); |
58 | | - $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'httpcache', 'id' => 'httpcache') ); |
| 57 | + $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'httpcache', 'id' => 'httpcache' ) ); |
59 | 58 | $form .= Xml::element( 'br' ); |
60 | 59 | $form .= Xml::element( 'label', array( 'for' => 'lastmod' ), 'use last modified' ); |
61 | | - $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'lastmod', 'id' => 'lastmod') ); |
| 60 | + $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'lastmod', 'id' => 'lastmod' ) ); |
62 | 61 | $form .= Xml::element( 'br' ); |
63 | 62 | $form .= Xml::element( 'label', array( 'for' => 'error' ), 'trigger error' ); |
64 | | - $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'error', 'id' => 'error') ); |
| 63 | + $form .= Xml::element( 'input', array( 'type' => 'checkbox', 'name' => 'error', 'id' => 'error' ) ); |
65 | 64 | $form .= Xml::element( 'br' ); |
66 | 65 | $form .= Xml::openElement( 'select', array( 'name' => 'ajaxtest_target', 'id' => 'ajaxtest_target' ) ); |
67 | 66 | $form .= Xml::element( 'option', array( 'value' => 'function' ), "function" ); |
— | — | @@ -69,9 +68,9 @@ |
70 | 69 | $form .= Xml::closeElement( 'select' ); |
71 | 70 | $form .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'doAjaxTest();', 'value' => 'TEST' ) ); |
72 | 71 | $form .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'clearAjaxTest();', 'value' => 'CLEAR' ) ); |
73 | | - #$form .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'getElementById("ajaxtest_out").value= getElementById("ajaxtest_text").value;', 'value' => 'DUMMY' ) ); |
| 72 | + # $form .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'getElementById("ajaxtest_out").value= getElementById("ajaxtest_text").value;', 'value' => 'DUMMY' ) ); |
74 | 73 | $form .= Xml::closeElement( 'form' ); |
75 | | - |
| 74 | + |
76 | 75 | $form .= Xml::element( 'hr' ); |
77 | 76 | $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'ajaxtest_out', 'id' => 'ajaxtest_out', 'value' => '', 'size' => '64' ) ) . ' '; |
78 | 77 | $form .= Xml::element( 'p', array( 'id' => 'ajaxtest_area' ) ); |
— | — | @@ -80,5 +79,3 @@ |
81 | 80 | return $form; |
82 | 81 | } |
83 | 82 | } |
84 | | - |
85 | | - |
Index: trunk/extensions/AjaxTest/AjaxTest.i18n.php |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for extension AjaxTest. |
| 5 | + * |
| 6 | + * @addtogroup Extensions |
| 7 | + */ |
| 8 | + |
| 9 | +$messages = array(); |
| 10 | + |
| 11 | +$messages['en'] = array( |
| 12 | + 'ajaxtest-desc' => '[[Special:AjaxTest|AjaxTest]] extension', |
| 13 | +); |
Property changes on: trunk/extensions/AjaxTest/AjaxTest.i18n.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 14 | + native |
Name: svn:keywords |
2 | 15 | + Id |
Index: trunk/extensions/AjaxTest/AjaxTest.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * AjaxTest extension |
6 | 5 | * |
— | — | @@ -8,8 +7,8 @@ |
9 | 8 | * @copyright © 2006 Daniel Kinzler |
10 | 9 | * @license GNU General Public Licence 2.0 or later |
11 | 10 | */ |
12 | | - |
13 | | -if( !defined( 'MEDIAWIKI' ) ) { |
| 11 | + |
| 12 | +if ( !defined( 'MEDIAWIKI' ) ) { |
14 | 13 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
15 | 14 | die( 1 ); |
16 | 15 | } |
— | — | @@ -18,7 +17,7 @@ |
19 | 18 | * Abort if AJAX is not enabled |
20 | 19 | **/ |
21 | 20 | if ( !$wgUseAjax ) { |
22 | | - #NOTE: GlobalFunctions is not yet loaded, so use standard API only. |
| 21 | + # NOTE: GlobalFunctions is not yet loaded, so use standard API only. |
23 | 22 | trigger_error( 'CategoryTree: $wgUseAjax is not enabled, aborting extension setup.', E_USER_WARNING ); |
24 | 23 | return; |
25 | 24 | } |
— | — | @@ -30,12 +29,15 @@ |
31 | 30 | 'path' => __FILE__, |
32 | 31 | 'name' => 'AjaxTest', |
33 | 32 | 'author' => 'Daniel Kinzler', |
34 | | - 'description' => 'AjaxTest extension', |
| 33 | + 'descriptionmsg' => 'ajaxtest-desc', |
35 | 34 | ); |
36 | 35 | $wgExtensionFunctions[] = 'efAjaxTestSetup'; |
37 | 36 | $wgSpecialPages['AjaxTest'] = 'AjaxTestPage'; |
38 | | -$wgAutoloadClasses['AjaxTestPage'] = dirname( __FILE__ ) . '/AjaxTestPage.php'; |
39 | 37 | |
| 38 | +$dir = dirname( __FILE__ ) . '/'; |
| 39 | +$wgExtensionMessagesFiles['AjaxTest'] = $dir . 'AjaxTest.i18n.php'; |
| 40 | +$wgExtensionAliasesFiles['AjaxTest'] = $dir . 'AjaxTest.alias.php'; |
| 41 | + |
40 | 42 | /** |
41 | 43 | * register Ajax function |
42 | 44 | */ |
— | — | @@ -53,20 +55,20 @@ |
54 | 56 | * This loads CategoryTreeFunctions.php and calls CategoryTree::ajax() |
55 | 57 | */ |
56 | 58 | function efAjaxTest( $text, $usestring, $httpcache, $lastmod, $error ) { |
57 | | - $text = htmlspecialchars($text) . "(".wfTimestampNow().")"; |
58 | | - |
59 | | - if ($usestring) return $text; |
| 59 | + $text = htmlspecialchars( $text ) . "(" . wfTimestampNow() . ")"; |
| 60 | + |
| 61 | + if ( $usestring ) return $text; |
60 | 62 | else { |
61 | | - $response= new AjaxResponse($text); |
62 | | - |
63 | | - if ($error) throw new Exception( $text ); |
64 | | - |
65 | | - if ($httpcache) $response->setCacheDuration( 24*60*60 ); #cache for a day |
66 | | - |
67 | | - if ($lastmod) { |
68 | | - $response->checkLastModified( '19700101000001' ); #never modified |
| 63 | + $response = new AjaxResponse( $text ); |
| 64 | + |
| 65 | + if ( $error ) throw new Exception( $text ); |
| 66 | + |
| 67 | + if ( $httpcache ) $response->setCacheDuration( 24 * 60 * 60 ); # cache for a day |
| 68 | + |
| 69 | + if ( $lastmod ) { |
| 70 | + $response->checkLastModified( '19700101000001' ); # never modified |
69 | 71 | } |
70 | | - |
| 72 | + |
71 | 73 | return $response; |
72 | 74 | } |
73 | 75 | } |
Index: trunk/extensions/AjaxTest/AjaxTest.js |
— | — | @@ -6,22 +6,22 @@ |
7 | 7 | * @author Daniel Kinzler <duesentrieb@brightbyte.de> |
8 | 8 | * @copyright © 2006 Daniel Kinzler |
9 | 9 | * @licence GNU General Public Licence 2.0 or later |
10 | | -*/ |
| 10 | + */ |
11 | 11 | |
12 | 12 | sajax_debug = true; |
13 | | - |
| 13 | + |
14 | 14 | function clearAjaxTest() { |
15 | 15 | document.getElementById('ajaxtest_out').value= ''; |
16 | 16 | document.getElementById('ajaxtest_area').innerHTML= ''; |
17 | 17 | document.getElementById('sajax_debug').innerHTML= ''; |
18 | 18 | } |
19 | | - |
| 19 | + |
20 | 20 | function doAjaxTest() { |
21 | 21 | sajax_debug_mode = true; |
22 | | - |
| 22 | + |
23 | 23 | var t = document.getElementById('ajaxtest_target').value; |
24 | 24 | var tgt; |
25 | | - |
| 25 | + |
26 | 26 | if ( t == 'element' ) { |
27 | 27 | tgt = document.getElementById('ajaxtest_area'); |
28 | 28 | } |
— | — | @@ -32,18 +32,18 @@ |
33 | 33 | tgt = function ( request ) { |
34 | 34 | result= request.responseText; |
35 | 35 | if (request.status != 200) result= "ERROR: " + request.status + " " + request.statusText + ": " + result + ""; |
36 | | - |
| 36 | + |
37 | 37 | alert(result); |
38 | 38 | } |
39 | 39 | } |
40 | | - |
| 40 | + |
41 | 41 | //alert(tgt); |
42 | | - |
| 42 | + |
43 | 43 | var usestring = document.getElementById('usestring').checked ? 1 : 0; |
44 | 44 | var httpcache = document.getElementById('httpcache').checked ? 1 : 0; |
45 | 45 | var lastmod = document.getElementById('lastmod').checked ? 1 : 0; |
46 | 46 | var error = document.getElementById('error').checked ? 1 : 0; |
47 | 47 | var text = document.getElementById('ajaxtest_text').value; |
48 | | - |
| 48 | + |
49 | 49 | sajax_do_call( "efAjaxTest", [ text, usestring, httpcache, lastmod, error], tgt ); |
50 | 50 | } |