r64578 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64577‎ | r64578 | r64579 >
Date:22:49, 3 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
* SpecialPage aliases and i18n description added
* stylize.php, trailing whitespace removed
Modified paths:
  • /trunk/extensions/AjaxTest/AjaxTest.alias.php (added) (history)
  • /trunk/extensions/AjaxTest/AjaxTest.i18n.php (added) (history)
  • /trunk/extensions/AjaxTest/AjaxTest.js (modified) (history)
  • /trunk/extensions/AjaxTest/AjaxTest.php (modified) (history)
  • /trunk/extensions/AjaxTest/AjaxTestPage.php (modified) (history)

Diff [purge]

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
116 + native
Name: svn:keywords
217 + Id
Index: trunk/extensions/AjaxTest/AjaxTestPage.php
@@ -8,20 +8,19 @@
99 * @licence GNU General Public Licence 2.0 or later
1010 */
1111
12 -if( !defined( 'MEDIAWIKI' ) ) {
 12+if ( !defined( 'MEDIAWIKI' ) ) {
1313 echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" );
1414 die( 1 );
1515 }
1616
1717 class AjaxTestPage extends SpecialPage {
18 -
1918 /**
2019 * Constructor
2120 */
2221 function __construct() {
2322 SpecialPage::SpecialPage( 'AjaxTest', '', true );
2423 }
25 -
 24+
2625 /**
2726 * Main execution function
2827 * @param $par Parameters passed to the page
@@ -29,18 +28,18 @@
3029 function execute( $par ) {
3130 global $wgRequest, $wgOut;
3231 global $wgJsMimeType, $wgScriptPath;
33 -
 32+
3433 $this->setHeaders();
35 -
36 - $wgOut->addScript(
 34+
 35+ $wgOut->addScript(
3736 "<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}/extensions/AjaxTest/AjaxTest.js\">" .
38 - "</script>\n"
 37+ "</script>\n"
3938 );
40 -
41 -
 39+
 40+
4241 $wgOut->addHTML( $this->makeInputForm() );
4342 }
44 -
 43+
4544 /**
4645 * Input form for entering a category
4746 */
@@ -51,16 +50,16 @@
5251 $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'ajaxtest_text', 'id' => 'ajaxtest_text', 'value' => '', 'size' => '64' ) ) . ' ';
5352 $form .= Xml::element( 'br' );
5453 $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' ) );
5655 $form .= Xml::element( 'br' );
5756 $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' ) );
5958 $form .= Xml::element( 'br' );
6059 $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' ) );
6261 $form .= Xml::element( 'br' );
6362 $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' ) );
6564 $form .= Xml::element( 'br' );
6665 $form .= Xml::openElement( 'select', array( 'name' => 'ajaxtest_target', 'id' => 'ajaxtest_target' ) );
6766 $form .= Xml::element( 'option', array( 'value' => 'function' ), "function" );
@@ -69,9 +68,9 @@
7069 $form .= Xml::closeElement( 'select' );
7170 $form .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'doAjaxTest();', 'value' => 'TEST' ) );
7271 $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' ) );
7473 $form .= Xml::closeElement( 'form' );
75 -
 74+
7675 $form .= Xml::element( 'hr' );
7776 $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'ajaxtest_out', 'id' => 'ajaxtest_out', 'value' => '', 'size' => '64' ) ) . ' ';
7877 $form .= Xml::element( 'p', array( 'id' => 'ajaxtest_area' ) );
@@ -80,5 +79,3 @@
8180 return $form;
8281 }
8382 }
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
114 + native
Name: svn:keywords
215 + Id
Index: trunk/extensions/AjaxTest/AjaxTest.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * AjaxTest extension
65 *
@@ -8,8 +7,8 @@
98 * @copyright © 2006 Daniel Kinzler
109 * @license GNU General Public Licence 2.0 or later
1110 */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
 11+
 12+if ( !defined( 'MEDIAWIKI' ) ) {
1413 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1514 die( 1 );
1615 }
@@ -18,7 +17,7 @@
1918 * Abort if AJAX is not enabled
2019 **/
2120 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.
2322 trigger_error( 'CategoryTree: $wgUseAjax is not enabled, aborting extension setup.', E_USER_WARNING );
2423 return;
2524 }
@@ -30,12 +29,15 @@
3130 'path' => __FILE__,
3231 'name' => 'AjaxTest',
3332 'author' => 'Daniel Kinzler',
34 - 'description' => 'AjaxTest extension',
 33+ 'descriptionmsg' => 'ajaxtest-desc',
3534 );
3635 $wgExtensionFunctions[] = 'efAjaxTestSetup';
3736 $wgSpecialPages['AjaxTest'] = 'AjaxTestPage';
38 -$wgAutoloadClasses['AjaxTestPage'] = dirname( __FILE__ ) . '/AjaxTestPage.php';
3937
 38+$dir = dirname( __FILE__ ) . '/';
 39+$wgExtensionMessagesFiles['AjaxTest'] = $dir . 'AjaxTest.i18n.php';
 40+$wgExtensionAliasesFiles['AjaxTest'] = $dir . 'AjaxTest.alias.php';
 41+
4042 /**
4143 * register Ajax function
4244 */
@@ -53,20 +55,20 @@
5456 * This loads CategoryTreeFunctions.php and calls CategoryTree::ajax()
5557 */
5658 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;
6062 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
6971 }
70 -
 72+
7173 return $response;
7274 }
7375 }
Index: trunk/extensions/AjaxTest/AjaxTest.js
@@ -6,22 +6,22 @@
77 * @author Daniel Kinzler <duesentrieb@brightbyte.de>
88 * @copyright © 2006 Daniel Kinzler
99 * @licence GNU General Public Licence 2.0 or later
10 -*/
 10+ */
1111
1212 sajax_debug = true;
13 -
 13+
1414 function clearAjaxTest() {
1515 document.getElementById('ajaxtest_out').value= '';
1616 document.getElementById('ajaxtest_area').innerHTML= '';
1717 document.getElementById('sajax_debug').innerHTML= '';
1818 }
19 -
 19+
2020 function doAjaxTest() {
2121 sajax_debug_mode = true;
22 -
 22+
2323 var t = document.getElementById('ajaxtest_target').value;
2424 var tgt;
25 -
 25+
2626 if ( t == 'element' ) {
2727 tgt = document.getElementById('ajaxtest_area');
2828 }
@@ -32,18 +32,18 @@
3333 tgt = function ( request ) {
3434 result= request.responseText;
3535 if (request.status != 200) result= "ERROR: " + request.status + " " + request.statusText + ": " + result + "";
36 -
 36+
3737 alert(result);
3838 }
3939 }
40 -
 40+
4141 //alert(tgt);
42 -
 42+
4343 var usestring = document.getElementById('usestring').checked ? 1 : 0;
4444 var httpcache = document.getElementById('httpcache').checked ? 1 : 0;
4545 var lastmod = document.getElementById('lastmod').checked ? 1 : 0;
4646 var error = document.getElementById('error').checked ? 1 : 0;
4747 var text = document.getElementById('ajaxtest_text').value;
48 -
 48+
4949 sajax_do_call( "efAjaxTest", [ text, usestring, httpcache, lastmod, error], tgt );
5050 }

Status & tagging log