r54659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54658‎ | r54659 | r54660 >
Date:14:20, 9 August 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* docs
* js fix
Modified paths:
  • /trunk/extensions/Translate/SpecialImportTranslations.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialImportTranslations.php
@@ -11,6 +11,9 @@
1212
1313 class SpecialImportTranslations extends SpecialPage {
1414
 15+ /**
 16+ * Set up and fill some dependencies.
 17+ */
1518 public function __construct() {
1619 parent::__construct( 'ImportTranslations', 'translate-import' );
1720 global $wgUser, $wgOut, $wgRequest;
@@ -19,11 +22,16 @@
2023 $this->request = $wgRequest;
2124 }
2225
 26+ // Dependencies
2327 protected $user, $out, $request;
2428
 29+ /**
 30+ * Special page entry point.
 31+ */
2532 public function execute( $parameters ) {
2633 $this->setHeaders();
2734
 35+ // Security and validity checks
2836 if ( !$this->userCanExecute( $this->user ) ) {
2937 $this->displayRestrictionError();
3038 return;
@@ -40,6 +48,7 @@
4149 return;
4250 }
4351
 52+ // Proceed to loading and parsing if possible
4453 $file = null;
4554 $msg = $this->loadFile( $file );
4655 if ( $this->checkError( $msg ) ) return;
@@ -49,6 +58,11 @@
5059
5160 }
5261
 62+ /**
 63+ * Checks for error state from the return value of loadFile and parseFile
 64+ * functions. Prints the error and the form and returns true if there is an
 65+ * error. Returns false and does nothing if there is no error.
 66+ */
5367 protected function checkError( $msg ) {
5468 if ( $msg[0] !== 'ok' ) {
5569 $errorWrap = "<div class='error'>\n$1\n</div>";
@@ -60,9 +74,11 @@
6175 return false;
6276 }
6377
 78+ /**
 79+ * Constructs and outputs file input form with supported methods.
 80+ */
6481 protected function outputForm() {
65 - global $wgScriptPath;
66 - $this->out->addScriptFile( "$wgScriptPath/extensions/Translate/js/import.js" );
 82+ $this->out->addScriptClass( 'TranslateImport' );
6783
6884 $this->out->addHTML(
6985
@@ -115,6 +131,9 @@
116132
117133 }
118134
 135+ /**
 136+ * Try to get the file data from any of the supported methods.
 137+ */
119138 protected function loadFile( &$filedata ) {
120139 $source = $this->request->getText( 'upload-type' );
121140
Index: trunk/extensions/Translate/Translate.php
@@ -66,7 +66,7 @@
6767 $wgHooks['SpecialRecentChangesPanel'][] = 'TranslateRcFilter::translationFilterForm';
6868 $wgHooks['SkinTemplateToolboxEnd'][] = 'TranslateToolbox::toolboxAllTranslations';
6969
70 -$wgJSAutoloadClasses['translate-import'] = "$dir/js/import.js";
 70+$wgJSAutoloadClasses['TranslateImport'] = "extensions/Translate/js/import.js";
7171
7272
7373 $wgEnablePageTranslation = false;

Status & tagging log