BPositive has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/133720

Change subject: [WIP] First version of Special:PageMigration
......................................................................

[WIP] First version of Special:PageMigration

Change-Id: Ic62ff3fcf52c1862b5d9f8ec14c60e1a00a340bb
---
A Autoload.php
M Resources.php
M Translate.alias.php
M Translate.php
A resources/css/ext.translate.special.pagemigration.css
A resources/js/ext.translate.special.pagemigration.js
A specials/SpecialPageMigration.php
M tests/phpunit/SpecialPagesTest.php
8 files changed, 501 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/20/133720/1

diff --git a/Autoload.php b/Autoload.php
new file mode 100644
index 0000000..398bf68
--- /dev/null
+++ b/Autoload.php
@@ -0,0 +1,318 @@
+<?php
+/**
+ * Autoload definitions.
+ *
+ * @file
+ * @author Niklas Laxström
+ * @copyright Copyright © 2008-2013, Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+/** @cond file_level_code */
+global $wgAutoloadClasses;
+$dir = dirname( __FILE__ );
+/** @endcond */
+
+/**
+ * @name   "Core Translate classes"
+ * @{
+ */
+$wgAutoloadClasses['FatMessage'] = "$dir/Message.php";
+$wgAutoloadClasses['MediaWikiMessageChecker'] = 
"$dir/MediaWikiMessageChecker.php";
+$wgAutoloadClasses['MessageChecker'] = "$dir/MessageChecks.php";
+$wgAutoloadClasses['MessageCollection'] = "$dir/MessageCollection.php";
+$wgAutoloadClasses['MessageDefinitions'] = "$dir/MessageCollection.php";
+$wgAutoloadClasses['MessageGroups'] = "$dir/MessageGroups.php";
+$wgAutoloadClasses['TMessage'] = "$dir/Message.php";
+$wgAutoloadClasses['ThinMessage'] = "$dir/Message.php";
+$wgAutoloadClasses['TranslateEditAddons'] = "$dir/TranslateEditAddons.php";
+$wgAutoloadClasses['TranslateHooks'] = "$dir/TranslateHooks.php";
+$wgAutoloadClasses['TranslateTasks'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['TranslateUtils'] = "$dir/TranslateUtils.php";
+/**@}*/
+
+/**
+ * @name   "Special pages"
+ * There are few more special pages in page translation section.
+ * @{
+ */
+$wgAutoloadClasses['TranslateSpecialPage'] = 
"$dir/specials/TranslateSpecialPage.php";
+$wgAutoloadClasses['SpecialAggregateGroups'] = 
"$dir/specials/SpecialAggregateGroups.php";
+$wgAutoloadClasses['SpecialImportTranslations'] = 
"$dir/specials/SpecialImportTranslations.php";
+$wgAutoloadClasses['SpecialLanguageStats'] = 
"$dir/specials/SpecialLanguageStats.php";
+$wgAutoloadClasses['SpecialMagic'] = "$dir/specials/SpecialMagic.php";
+$wgAutoloadClasses['SpecialManageGroups'] = 
"$dir/specials/SpecialManageGroups.php";
+$wgAutoloadClasses['SpecialMessageGroupStats'] = 
"$dir/specials/SpecialMessageGroupStats.php";
+$wgAutoloadClasses['SpecialMyLanguage'] = 
"$dir/specials/SpecialMyLanguage.php";
+$wgAutoloadClasses['SpecialSearchTranslations'] = 
"$dir/specials/SpecialSearchTranslations.php";
+$wgAutoloadClasses['SpecialSupportedLanguages'] = 
"$dir/specials/SpecialSupportedLanguages.php";
+$wgAutoloadClasses['SpecialTranslate'] = "$dir/specials/SpecialTranslate.php";
+$wgAutoloadClasses['SpecialManageTranslatorSandbox'] =
+       "$dir/specials/SpecialManageTranslatorSandbox.php";
+$wgAutoloadClasses['SpecialTranslationStats'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['SpecialTranslations'] = 
"$dir/specials/SpecialTranslations.php";
+$wgAutoloadClasses['SpecialTranslationStash'] = 
"$dir/specials/SpecialTranslationStash.php";
+$wgAutoloadClasses['SpecialPageMigration'] = 
"$dir/specials/SpecialPageMigration.php";
+/**@}*/
+
+/**
+ * @name   "Various utilities"
+ * @{
+ */
+$wgAutoloadClasses['CDBMessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['CachedMessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['DatabaseMessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['ExternalMessageSourceStateComparator'] =
+       "$dir/utils/ExternalMessageSourceStateComparator.php";
+$wgAutoloadClasses['FCFontFinder'] = "$dir/utils/Font.php";
+$wgAutoloadClasses['FileCachedMessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['FuzzyBot'] = "$dir/utils/FuzzyBot.php";
+$wgAutoloadClasses['HTMLJsSelectToInputField'] = 
"$dir/utils/HTMLJsSelectToInputField.php";
+$wgAutoloadClasses['JsSelectToInput'] = "$dir/utils/JsSelectToInput.php";
+$wgAutoloadClasses['MessageGroupCache'] = "$dir/utils/MessageGroupCache.php";
+$wgAutoloadClasses['MessageGroupStates'] = "$dir/utils/MessageGroupStates.php";
+$wgAutoloadClasses['MessageGroupStatesUpdaterJob'] = 
"$dir/utils/MessageGroupStatesUpdaterJob.php";
+$wgAutoloadClasses['MessageGroupStats'] = "$dir/utils/MessageGroupStats.php";
+$wgAutoloadClasses['MessageHandle'] = "$dir/utils/MessageHandle.php";
+$wgAutoloadClasses['MessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['MessageIndexRebuildJob'] = 
"$dir/utils/MessageIndexRebuildJob.php";
+$wgAutoloadClasses['MessageTable'] = "$dir/utils/MessageTable.php";
+$wgAutoloadClasses['MessageUpdateJob'] = "$dir/utils/MessageUpdateJob.php";
+$wgAutoloadClasses['MessageWebImporter'] = "$dir/utils/MessageWebImporter.php";
+$wgAutoloadClasses['PHPVariableLoader'] = "$dir/utils/ResourceLoader.php";
+$wgAutoloadClasses['RevTag'] = "$dir/utils/RevTag.php";
+$wgAutoloadClasses['ReviewPerLanguageStats'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['SerializedMessageIndex'] = "$dir/utils/MessageIndex.php";
+$wgAutoloadClasses['StatsBar'] = "$dir/utils/StatsBar.php";
+$wgAutoloadClasses['StatsTable'] = "$dir/utils/StatsTable.php";
+$wgAutoloadClasses['StringMangler'] = "$dir/utils/StringMatcher.php";
+$wgAutoloadClasses['StringMatcher'] = "$dir/utils/StringMatcher.php";
+$wgAutoloadClasses['TTMServer'] = "$dir/utils/TTMServer.php";
+$wgAutoloadClasses['TranslateLogFormatter'] = 
"$dir/utils/TranslateLogFormatter.php";
+$wgAutoloadClasses['TranslateMetadata'] = "$dir/utils/TranslateMetadata.php";
+$wgAutoloadClasses['TranslatePerLanguageStats'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['TranslatePreferences'] = "$dir/utils/UserToggles.php";
+$wgAutoloadClasses['TranslateRcFilter'] = "$dir/utils/RcFilter.php";
+$wgAutoloadClasses['TranslateRegistrationStats'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['TranslateSandbox'] = "$dir/utils/TranslateSandbox.php";
+$wgAutoloadClasses['TranslateSandboxEmailJob'] = 
"$dir/utils/TranslateSandboxEmailJob.php";
+$wgAutoloadClasses['TranslateStatsOutput'] = 
"$dir/scripts/TranslateStatsOutput.php";
+$wgAutoloadClasses['TranslateToolbox'] = "$dir/utils/ToolBox.php";
+$wgAutoloadClasses['TranslateYaml'] = "$dir/utils/TranslateYaml.php";
+$wgAutoloadClasses['TranslationEditPage'] = 
"$dir/utils/TranslationEditPage.php";
+$wgAutoloadClasses['TranslationHelperException'] = 
"$dir/utils/TranslationHelpers.php";
+$wgAutoloadClasses['TranslationHelpers'] = "$dir/utils/TranslationHelpers.php";
+$wgAutoloadClasses['TranslationStats'] = "$dir/utils/TranslationStats.php";
+$wgAutoloadClasses['TranslationStatsBase'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['TranslationStatsInterface'] = 
"$dir/specials/SpecialTranslationStats.php";
+$wgAutoloadClasses['TuxMessageTable'] = "$dir/utils/TuxMessageTable.php";
+/**@}*/
+
+/**
+ * @name   "Classes for predefined non-managed message groups"
+ * @{
+ */
+$wgAutoloadClasses['PremadeMediawikiExtensionGroups'] = 
"$dir/ffs/MediaWikiExtensions.php";
+$wgAutoloadClasses['PremadeIntuitionTextdomains'] = 
"$dir/ffs/IntuitionTextdomains.php";
+/**@}*/
+
+/**
+ * @name   "Support for MediaWiki non-message features"
+ * @{
+ */
+$wgAutoloadClasses['ComplexMessages'] = 
"$dir/ffs/MediaWikiComplexMessages.php";
+$wgAutoloadClasses['MagicWordsCM'] = "$dir/ffs/MediaWikiComplexMessages.php";
+$wgAutoloadClasses['NamespaceCM'] = "$dir/ffs/MediaWikiComplexMessages.php";
+$wgAutoloadClasses['SpecialPageAliasesCM'] = 
"$dir/ffs/MediaWikiComplexMessages.php";
+/**@}*/
+
+/**
+ * @name   "Classes for page translation feature"
+ * @ingroup PageTranslation
+ * @{
+ */
+$wgAutoloadClasses['TranslateDeleteJob'] = "$dir/tag/TranslateDeleteJob.php";
+$wgAutoloadClasses['TranslateMoveJob'] = "$dir/tag/TranslateMoveJob.php";
+$wgAutoloadClasses['PageTranslationHooks'] = 
"$dir/tag/PageTranslationHooks.php";
+$wgAutoloadClasses['PageTranslationLogFormatter'] = 
"$dir/tag/PageTranslationLogFormatter.php";
+$wgAutoloadClasses['TranslateRenderJob'] = "$dir/tag/TranslateRenderJob.php";
+$wgAutoloadClasses['SpecialPageTranslation'] = 
"$dir/tag/SpecialPageTranslation.php";
+$wgAutoloadClasses['SpecialPageTranslationDeletePage'] =
+       "$dir/tag/SpecialPageTranslationDeletePage.php";
+$wgAutoloadClasses['SpecialPageTranslationMovePage'] =
+       "$dir/tag/SpecialPageTranslationMovePage.php";
+$wgAutoloadClasses['TPException'] = "$dir/tag/TPException.php";
+$wgAutoloadClasses['TPParse'] = "$dir/tag/TPParse.php";
+$wgAutoloadClasses['TPSection'] = "$dir/tag/TPSection.php";
+$wgAutoloadClasses['TranslatablePage'] = "$dir/tag/TranslatablePage.php";
+/**@}*/
+
+/**
+ * @name   "Classes for TTMServer"
+ * @ingroup TTMServer
+ * @{
+ */
+$wgAutoloadClasses['ReadableTTMServer'] = "$dir/ttmserver/Interfaces.php";
+$wgAutoloadClasses['SearchableTTMServer'] = "$dir/ttmserver/Interfaces.php";
+$wgAutoloadClasses['WritableTTMServer'] = "$dir/ttmserver/Interfaces.php";
+
+$wgAutoloadClasses['TTMServerException'] = "$dir/ttmserver/Exceptions.php";
+
+$wgAutoloadClasses['DatabaseTTMServer'] = 
"$dir/ttmserver/DatabaseTTMServer.php";
+$wgAutoloadClasses['ElasticSearchTTMServer'] = 
"$dir/ttmserver/ElasticSearchTTMServer.php";
+$wgAutoloadClasses['FakeTTMServer'] = "$dir/ttmserver/FakeTTMServer.php";
+$wgAutoloadClasses['RemoteTTMServer'] = "$dir/ttmserver/RemoteTTMServer.php";
+$wgAutoloadClasses['SolrTTMServer'] = "$dir/ttmserver/SolrTTMServer.php";
+$wgAutoloadClasses['TTMServer'] = "$dir/ttmserver/TTMServer.php";
+$wgAutoloadClasses['TTMServerMessageUpdateJob'] = 
"$dir/ttmserver/TTMServerMessageUpdateJob.php";
+/**@}*/
+
+/**
+ * @name   "Classes for file format support (FFS)"
+ * @{
+ */
+$wgAutoloadClasses['AndroidXmlFFS'] = "$dir/ffs/AndroidXmlFFS.php";
+$wgAutoloadClasses['AppleFFS'] = "$dir/ffs/AppleFFS.php";
+$wgAutoloadClasses['DtdFFS'] = "$dir/ffs/DtdFFS.php";
+$wgAutoloadClasses['FFS'] = "$dir/ffs/FFS.php";
+$wgAutoloadClasses['FlatPhpFFS'] = "$dir/ffs/FlatPhpFFS.php";
+$wgAutoloadClasses['GettextFFS'] = "$dir/ffs/GettextFFS.php";
+$wgAutoloadClasses['GettextPluralException'] = "$dir/ffs/GettextFFS.php";
+$wgAutoloadClasses['IniFFS'] = "$dir/ffs/IniFFS.php";
+$wgAutoloadClasses['JavaFFS'] = "$dir/ffs/JavaFFS.php";
+$wgAutoloadClasses['JavaScriptFFS'] = "$dir/ffs/JavaScriptFFS.php";
+$wgAutoloadClasses['JsonFFS'] = "$dir/ffs/JsonFFS.php";
+$wgAutoloadClasses['MediaWikiExtensionFFS'] = 
"$dir/ffs/MediaWikiExtensionFFS.php";
+$wgAutoloadClasses['PythonSingleFFS'] = "$dir/ffs/PythonSingleFFS.php";
+$wgAutoloadClasses['RubyYamlFFS'] = "$dir/ffs/RubyYamlFFS.php";
+$wgAutoloadClasses['ShapadoJsFFS'] = "$dir/ffs/JavaScriptFFS.php";
+$wgAutoloadClasses['SimpleFFS'] = "$dir/ffs/SimpleFFS.php";
+$wgAutoloadClasses['XliffFFS'] = "$dir/ffs/XliffFFS.php";
+$wgAutoloadClasses['YamlFFS'] = "$dir/ffs/YamlFFS.php";
+/**@}*/
+
+/**
+ * @name   "API modules"
+ * @{
+ */
+$wgAutoloadClasses['ApiAggregateGroups'] = "$dir/api/ApiAggregateGroups.php";
+$wgAutoloadClasses['ApiGroupReview'] = "$dir/api/ApiGroupReview.php";
+$wgAutoloadClasses['ApiHardMessages'] = "$dir/api/ApiHardMessages.php";
+$wgAutoloadClasses['ApiQueryLanguageStats'] = 
"$dir/api/ApiQueryLanguageStats.php";
+$wgAutoloadClasses['ApiQueryMessageCollection'] = 
"$dir/api/ApiQueryMessageCollection.php";
+$wgAutoloadClasses['ApiQueryMessageGroupStats'] = 
"$dir/api/ApiQueryMessageGroupStats.php";
+$wgAutoloadClasses['ApiQueryMessageGroups'] = 
"$dir/api/ApiQueryMessageGroups.php";
+$wgAutoloadClasses['ApiQueryMessageTranslations'] = 
"$dir/api/ApiQueryMessageTranslations.php";
+$wgAutoloadClasses['ApiStatsQuery'] = "$dir/api/ApiStatsQuery.php";
+$wgAutoloadClasses['ApiTTMServer'] = "$dir/api/ApiTTMServer.php";
+$wgAutoloadClasses['ApiTranslateSandbox'] = "$dir/api/ApiTranslateSandbox.php";
+$wgAutoloadClasses['ApiTranslateUser'] = "$dir/api/ApiTranslateUser.php";
+$wgAutoloadClasses['ApiTranslationAids'] = 
"$dir/api/ApiQueryTranslationAids.php";
+$wgAutoloadClasses['ApiTranslationReview'] = 
"$dir/api/ApiTranslationReview.php";
+$wgAutoloadClasses['ApiTranslationStash'] = "$dir/api/ApiTranslationStash.php";
+/**@}*/
+
+/**
+ * @name   "Task classes"
+ * @{
+ */
+$wgAutoloadClasses['AcceptQueueMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['CustomFilteredMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ExportAsPoMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ExportMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ExportToFileMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ReviewAllMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ReviewMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['TranslateTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ViewMessagesTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ViewOptionalTask'] = "$dir/TranslateTasks.php";
+$wgAutoloadClasses['ViewUntranslatedTask'] = "$dir/TranslateTasks.php";
+/**@}*/
+
+/**
+ * @name   "Message group classes"
+ * @{
+ */
+$wgAutoloadClasses['AggregateMessageGroup'] = 
"$dir/messagegroups/AggregateMessageGroup.php";
+$wgAutoloadClasses['FileBasedMessageGroup'] = 
"$dir/messagegroups/FileBasedMessageGroup.php";
+$wgAutoloadClasses['MediaWikiExtensionMessageGroup'] =
+       "$dir/messagegroups/MediaWikiExtensionMessageGroup.php";
+$wgAutoloadClasses['MessageGroup'] = "$dir/messagegroups/MessageGroup.php";
+$wgAutoloadClasses['MessageGroupBase'] = 
"$dir/messagegroups/MessageGroupBase.php";
+$wgAutoloadClasses['MessageGroupOld'] = 
"$dir/messagegroups/MessageGroupOld.php";
+$wgAutoloadClasses['RecentMessageGroup'] = 
"$dir/messagegroups/RecentMessageGroup.php";
+$wgAutoloadClasses['RecentAdditionsMessageGroup'] =
+       "$dir/messagegroups/RecentAdditionsMessageGroup.php";
+$wgAutoloadClasses['SandboxMessageGroup'] = 
"$dir/messagegroups/SandboxMessageGroup.php";
+$wgAutoloadClasses['WikiMessageGroup'] = 
"$dir/messagegroups/WikiMessageGroup.php";
+$wgAutoloadClasses['WikiPageMessageGroup'] = 
"$dir/messagegroups/WikiPageMessageGroup.php";
+$wgAutoloadClasses['WorkflowStatesMessageGroup'] =
+       "$dir/messagegroups/WorkflowStatesMessageGroup.php";
+/**@}*/
+
+/**
+ * @name   "Stash"
+ * @{
+ */
+$wgAutoloadClasses['StashedTranslation'] = "$dir/stash/StashedTranslation.php";
+$wgAutoloadClasses['TranslationStashStorage'] = 
"$dir/stash/TranslationStashStorage.php";
+/**@}*/
+
+/**
+ * @name   "Test classes"
+ * @{
+ */
+$wgAutoloadClasses['MockFileBasedMessageGroup'] =
+       "$dir/tests/phpunit/MockFileBasedMessageGroup.php";
+$wgAutoloadClasses['MockMessageCollectionForExport'] =
+       "$dir/tests/phpunit/MockMessageCollectionForExport.php";
+$wgAutoloadClasses['MockSuperUser'] = "$dir/tests/phpunit/MockSuperUser.php";
+$wgAutoloadClasses['MockWikiMessageGroup'] = 
"$dir/tests/phpunit/MockWikiMessageGroup.php";
+$wgAutoloadClasses['MediaWikiInsertablesSuggesterTest'] =
+       "$dir/tests/phpunit/insertables/MediaWikiInsertablesSuggesterTest.php";
+
+/**@}*/
+
+/**
+ * @name   "Translation aids"
+ * @{
+ */
+$wgAutoloadClasses['CurrentTranslationAid'] = 
"$dir/translationaids/CurrentTranslationAid.php";
+$wgAutoloadClasses['DocumentationAid'] = 
"$dir/translationaids/DocumentationAid.php";
+$wgAutoloadClasses['GettextDocumentationAid'] = 
"$dir/translationaids/GettextDocumentationAid.php";
+$wgAutoloadClasses['InOtherLanguagesAid'] = 
"$dir/translationaids/InOtherLanguagesAid.php";
+$wgAutoloadClasses['InsertablesAid'] = 
"$dir/translationaids/InsertablesAid.php";
+$wgAutoloadClasses['MachineTranslationAid'] = 
"$dir/translationaids/MachineTranslationAid.php";
+$wgAutoloadClasses['MessageDefinitionAid'] = 
"$dir/translationaids/MessageDefinitionAid.php";
+$wgAutoloadClasses['SupportAid'] = "$dir/translationaids/SupportAid.php";
+$wgAutoloadClasses['TTMServerAid'] = "$dir/translationaids/TTMServerAid.php";
+$wgAutoloadClasses['TranslationAid'] = 
"$dir/translationaids/TranslationAid.php";
+$wgAutoloadClasses['UnsupportedTranslationAid'] =
+       "$dir/translationaids/UnsupportedTranslationAid.php";
+$wgAutoloadClasses['UpdatedDefinitionAid'] = 
"$dir/translationaids/UpdatedDefinitionAid.php";
+/**@}*/
+
+/**
+ * @name   "Translation web services"
+ * @{
+ */
+$wgAutoloadClasses['ApertiumWebService'] = 
"$dir/webservices/ApertiumWebService.php";
+$wgAutoloadClasses['MicrosoftWebService'] = 
"$dir/webservices/MicrosoftWebService.php";
+$wgAutoloadClasses['RemoteTTMServerWebService'] = 
"$dir/webservices/RemoteTTMServerWebService.php";
+$wgAutoloadClasses['TranslationWebService'] = 
"$dir/webservices/TranslationWebService.php";
+$wgAutoloadClasses['TranslationWebServiceException'] =
+       "$dir/webservices/TranslationWebServiceException.php";
+$wgAutoloadClasses['YandexWebService'] = 
"$dir/webservices/YandexWebService.php";
+/**@}*/
+
+/**
+ * @name   "Insertables"
+ * @{
+ */
+$wgAutoloadClasses['Insertable'] = "$dir/insertables/Insertable.php";
+$wgAutoloadClasses['InsertablesSuggester'] = 
"$dir/insertables/InsertablesSuggester.php";
+$wgAutoloadClasses['MediaWikiInsertablesSuggester'] =
+       "$dir/insertables/MediaWikiInsertablesSuggester.php";
+$wgAutoloadClasses['TranslatablePageInsertablesSuggester'] =
+       "$dir/insertables/TranslatablePageInsertablesSuggester.php";
+/**@}*/
diff --git a/Resources.php b/Resources.php
index 7045485..36de2b0 100644
--- a/Resources.php
+++ b/Resources.php
@@ -463,6 +463,11 @@
        ),
 ) + $resourcePaths;
 
+$wgResourceModules['ext.translate.special.pagemigration'] = array(
+       'styles' => 'resources/css/ext.translate.special.pagemigration.css',
+       'scripts' => 'resources/js/ext.translate.special.pagemigration.js',
+) + $resourcePaths;
+
 // Third party module
 $wgResourceModules['jquery.autosize'] = array(
        'scripts' => 'resources/js/jquery.autosize.js',
diff --git a/Translate.alias.php b/Translate.alias.php
index c5bf84a..a414826 100644
--- a/Translate.alias.php
+++ b/Translate.alias.php
@@ -27,6 +27,7 @@
        'TranslationStash' => array( 'TranslationStash' ),
        'TranslationStats' => array( 'TranslationStats', 
'TranslationStatistics' ),
        'Translations' => array( 'Translations' ),
+       'PageMigration' => array( 'PageMigration' ),
 );
 
 /** Afrikaans (Afrikaans) */
@@ -1132,4 +1133,4 @@
        'TranslationStash' => array( '翻譯隱藏' ),
        'TranslationStats' => array( '翻譯統計' ),
        'Translations' => array( '譯文' ),
-);
\ No newline at end of file
+);
diff --git a/Translate.php b/Translate.php
index 7679b39..7988110 100644
--- a/Translate.php
+++ b/Translate.php
@@ -40,7 +40,7 @@
  * Setup class autoloading.
  */
 $dir = __DIR__;
-require_once "$dir/_autoload.php";
+require_once "$dir/Autoload.php";
 /** @endcond */
 
 /**
@@ -91,6 +91,8 @@
 $GLOBALS['wgSpecialPageGroups']['ManageMessageGroups'] = 'wiki';
 $GLOBALS['wgSpecialPages']['SupportedLanguages'] = 'SpecialSupportedLanguages';
 $GLOBALS['wgSpecialPageGroups']['SupportedLanguages'] = 'wiki';
+$GLOBALS['wgSpecialPages']['PageMigration'] = 'SpecialPageMigration';
+//$GLOBALS['wgSpecialPageGroups']['PageMigration'] = 'wiki';
 // Unlisted special page; does not need $wgSpecialPageGroups.
 $GLOBALS['wgSpecialPages']['MyLanguage'] = 'SpecialMyLanguage';
 $GLOBALS['wgSpecialPages']['AggregateGroups'] = 'SpecialAggregateGroups';
diff --git a/resources/css/ext.translate.special.pagemigration.css 
b/resources/css/ext.translate.special.pagemigration.css
new file mode 100644
index 0000000..f540e83
--- /dev/null
+++ b/resources/css/ext.translate.special.pagemigration.css
@@ -0,0 +1,17 @@
+#sourceunits{
+       float: left;
+       display: inline-block;
+       width: 40%;
+}
+
+#translationunits{
+       margin-left: 1%;
+       display: inline-block;
+       width: 40%;     
+}
+
+#sourceunits > div, #translationunits > div{
+       overflow-y: auto;
+       height: 150px;
+       border:2px solid gray;
+}
\ No newline at end of file
diff --git a/resources/js/ext.translate.special.pagemigration.js 
b/resources/js/ext.translate.special.pagemigration.js
new file mode 100644
index 0000000..e4eebce
--- /dev/null
+++ b/resources/js/ext.translate.special.pagemigration.js
@@ -0,0 +1,130 @@
+( function ( $, mw ) {
+       'use strict';
+       $( document ).ready( function () {
+               //alert("Hello from ext.translate.special.pagemigration.js");
+
+               var api = new mw.Api(),
+                       translationUnits = [],
+                       messageToBeShown = "";
+
+               function splitTranslationPage( timestampOld, pageTitle ){
+                       console.log("pageTitle is" + pageTitle);
+                       var deferred = new $.Deferred();
+                       var api_2 = new mw.Api();
+                       //This api call returns the content before FuzzyBot's 
edit
+                   deferred = api_2.get ({
+                       action: 'query',
+                       prop: 'revisions',
+                       format: 'json',
+                       rvprop: 'content',
+                       rvstart: timestampOld,
+                       titles: pageTitle
+                   }).done ( function( data ) {
+                       for (var page in data['query']['pages']) {
+                                               var obj = 
data['query']['pages'][page];
+                       }
+                       if( typeof obj === 'undefined'){
+                               //obj was not initialized. Handle this case
+                               //deferred.reject()?
+                       }
+                       if (typeof obj['revisions'] === 'undefined') {
+                               //the case of /en subpage
+                               alert("Nothing to import");
+                               return; //can be replaced with 
deferred.reject();
+                       };
+                       console.log(obj['revisions'][0]['*'].split('\n\n'));
+                       
//console.log(data['query']['pages']['17']['revisions'][0]['*'].split('\n\n'));
+                       var pageContent = obj['revisions'][0]['*'];
+                       var oldTranslationUnits = pageContent.split('\n\n');
+                       for(var i=0; i < oldTranslationUnits.length; i++){
+                               $('#translationunits').append("<div id='t" + (i 
+ 1) + "'>" + 
+                                               oldTranslationUnits[i] + 
"</div><br/>");
+                       }
+                       
//renderContentDialog(data['query']['pages'][wgArticleId]['revisions'][0]['*']);
+                   });
+                       return deferred.promise();
+               }
+
+               function getFuzzyTimestamp( pageTitle ){
+                   var api = new mw.Api();
+                   var deferred = new $.Deferred();
+                   // alert(articleId);
+                   //This api call returns the timestamp of FuzzyBot's edit
+                   deferred = api.get ({
+                       action:'query',
+                       prop: 'revisions',
+                       format: 'json',
+                       rvprop: 'timestamp',
+                       rvuser: 'FuzzyBot',
+                       rvdir: 'newer',
+                       titles: pageTitle
+                   }).done ( function( data ) {
+                       //FB = FuzzyBot
+                       for (var page in data['query']['pages']) {
+                                               var obj = 
data['query']['pages'][page];
+                       }
+                       if( typeof obj === 'undefined'){
+                               //obj was not initialized. Handle this case
+                               //deferred.reject()?
+                       }
+                       console.log(data);
+                       if ( typeof obj['revisions'] === 'undefined' ) {        
// variable is undefined //replace 17 by wgArticleId
+                               alert("No edit by FuzzyBot on this page");
+                                       deferred.reject();
+                               }
+                               else {
+                                       /*FB over here refers to FuzzyBot*/
+                                       var timestampFB = 
obj['revisions'][0]['timestamp'];
+                               //var timestampFB = 
data['query']['pages']['17']['revisions'][0]['timestamp']; //replace 17 by 
wgArticleId
+                               console.log( "Timestamp for FuzzyBot's 
revision: " + timestampFB );
+                               var dateFB = new Date( timestampFB );
+                               dateFB.setSeconds( dateFB.getSeconds() - 1 );
+                               var timestampOld = dateFB.toISOString();
+                               console.log( "New Timestamp: " + timestampOld );
+                               //deferred.resolve();
+                                       splitTranslationPage(timestampOld, 
pageTitle);
+                                       
+                               }
+                   });
+                   return deferred.promise();
+       }
+
+       function getTranslationUnits( pageName ){
+
+               var deferred = new $.Deferred();
+                       deferred = api.get ({
+                               action:'query',
+                               list: 'messagecollection',
+                               format: 'json',
+                               mcgroup: 'page-' + pageName,
+                               mclanguage: 'en',
+                               mcprop: 'definition'
+                       }).done ( function( data ) {
+                               var result = data['query']['messagecollection'];
+                               //console.log(result.length);
+                               for (var i = 1; i < result.length; i++){
+                                       var tUnit = new Object();
+                                       var key = result[i].key;
+                                       tUnit.identifier = 
key.slice(key.lastIndexOf('/') + 1);
+                                       messageToBeShown += tUnit.identifier;
+                                       tUnit.definition = result[i].definition;
+                                       translationUnits.push(tUnit);
+                                       $('#sourceunits').append("<div id='s" + 
tUnit.identifier + "'>" + 
+                                               tUnit.definition + 
"</div><br/>");                                                      
+                               }
+                               console.log("messageToBeShown = " + 
messageToBeShown);
+                               //splitTranslationPage();
+                       });
+                       return deferred.promise();
+               }
+
+               $('#buttonImport').click(function(){
+                       var pageName = $('#pagename').val();
+                       var langCode = $('#langcode').val();
+                       var pageTitle = pageName + "/" + langCode;
+                       $.when( getTranslationUnits( pageName ), 
getFuzzyTimestamp( pageTitle ) ).then( function(){
+                               console.log("All done now!");
+                       } );
+               });
+       } );
+}( jQuery, mediaWiki ) );
\ No newline at end of file
diff --git a/specials/SpecialPageMigration.php 
b/specials/SpecialPageMigration.php
new file mode 100644
index 0000000..a95f652
--- /dev/null
+++ b/specials/SpecialPageMigration.php
@@ -0,0 +1,25 @@
+<?php
+class SpecialPageMigration extends SpecialPage {
+       function __construct() {
+               parent::__construct( 'PageMigration' );
+       }
+ 
+       function execute( $par ) {
+               $request = $this->getRequest();
+               $output = $this->getOutput();
+               $this->setHeaders();
+               $output->addModules( 'ext.translate.special.pagemigration' );
+               # Get request data from, e.g.
+               $param = $request->getText( 'param' );
+ 
+               # Do stuff
+               # ...
+               $output->addHTML( "<div id='pageinput'>
+                       <input type='text' id='pagename' placeholder='Enter 
page name'/>
+                       <input type='text' id='langcode' 
placeholder='langcode'/>
+                       <input type='submit' id='buttonImport' value='Import'/>
+                       </div>");
+               $output->addHTML("<br/><div id='sourceunits'></div>
+                       <div id='translationunits'></div>");
+       }
+}
diff --git a/tests/phpunit/SpecialPagesTest.php 
b/tests/phpunit/SpecialPagesTest.php
index 5c6e035..658d859 100644
--- a/tests/phpunit/SpecialPagesTest.php
+++ b/tests/phpunit/SpecialPagesTest.php
@@ -26,7 +26,7 @@
        }
 
        public static function provideSpecialPages() {
-               require __DIR__ . '/../../_autoload.php';
+               require __DIR__ . '/../../Autoload.php';
                global $wgSpecialPages;
 
                $pages = array();

-- 
To view, visit https://gerrit.wikimedia.org/r/133720
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic62ff3fcf52c1862b5d9f8ec14c60e1a00a340bb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: BPositive <pr4tiklah...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to