[MediaWiki-commits] [Gerrit] mediawiki...FileImporter[master]: Show file details on special page
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337183 ) Change subject: Show file details on special page .. Show file details on special page This uses a pretend importable target to just throw some data on the special page. This also adds a POST vs GET case for the special page, the GET will simply show the infomation about the import and the POST would actually perform the import. The Importable interface will provide everything needed to import a file onto the wiki, currently only basic methods have been added, more will be added as needed. ExternalMediaWikiFile currently contains mock data. Some sort of factory will be needed to turn URLs into Importable objects. Bug: T156792 Change-Id: I71b7e7a3b6c09519d51789065d29a770a94e0338 --- M extension.json M i18n/en.json M i18n/qqq.json A src/ExternalMediaWikiFile.php A src/Importable.php M src/SpecialImportFile.php 6 files changed, 121 insertions(+), 13 deletions(-) Approvals: WMDE-Fisch: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index 75dd6bd..70fa5b7 100644 --- a/extension.json +++ b/extension.json @@ -19,6 +19,8 @@ "ImportFile": "FileImporter\\SpecialImportFile" }, "AutoloadClasses": { +"FileImporter\\ExternalMediaWikiFile": "src/ExternalMediaWikiFile.php", +"FileImporter\\Importable": "src/Importable.php", "FileImporter\\FileImporterHooks": "src/FileImporterHooks.php", "FileImporter\\SpecialImportFile": "src/SpecialImportFile.php", "FileImporter\\UrlBasedSiteLookup": "src/UrlBasedSiteLookup.php" diff --git a/i18n/en.json b/i18n/en.json index dc6073c..eb4b211 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -11,5 +11,6 @@ "fileimporter-cantimporturl": "Can't import the given URL", "fileimporter-exampleprefix": "Example", "fileimporter-submit": "Submit", + "fileimporter-import": "Import", "fileimporter-importfilefromprefix" : "Importing file from" } \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json index ffebc21..752a824 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -11,5 +11,6 @@ "fileimporter-cantimporturl": "Error message shown on the special page when the URL entered can not be imported from.", "fileimporter-exampleprefix": "Prefix for the example URL contained within the URL text box on the special page.", "fileimporter-submit": "Text for the submit button on the special page.", + "fileimporter-import": "Text for the import button on the special page.", "fileimporter-importfilefromprefix" : "Prefix for the URL being imported from on the special page." } diff --git a/src/ExternalMediaWikiFile.php b/src/ExternalMediaWikiFile.php new file mode 100644 index 000..22cb263 --- /dev/null +++ b/src/ExternalMediaWikiFile.php @@ -0,0 +1,20 @@ +https://upload.wikimedia.org/wikipedia/commons/5/52/Berlin_Montage_4.jpg'; + } + + public function getTargetUrl() { + return 'https://en.wikipedia.org/wiki/File:Berlin_Montage_4.jpg'; + } + +} diff --git a/src/Importable.php b/src/Importable.php new file mode 100644 index 000..ae8b8c2 --- /dev/null +++ b/src/Importable.php @@ -0,0 +1,24 @@ +enableOOUI(); $rawUrl = $out->getRequest()->getVal( 'clientUrl', '' ); + $wasPosted = $out->getRequest()->wasPosted(); if ( !$rawUrl ) { $this->showUrlEntryPage(); @@ -35,8 +37,17 @@ $this->showDisallowedUrlMessage(); $this->showUrlEntryPage(); } else { - $this->showImportPage( $parsedUrl ); + if ( $wasPosted ) { + $this->doImport(); + } else { + $this->showImportPage( $rawUrl ); + } } + } + + private function doImport() { + // TODO implement importing + $this->getOutput()->addHTML( 'TODO do the import' ); } /** @@ -71,8 +82,37 @@ } private function showUrlEntryPage() { + $this->showInputForm(); + } + + /** +* @param string $rawUrl +*/ + private function showImportPage( $rawUrl ) { + // TODO actually make the correct file? + $file = new ExternalMediaWikiFile(); + $out = $this->getOutput(); + $this->getOutput()->addModuleStyles( 'ext.FileImporter.Special' ); - $this->getOutput()->addHTML( + $this->showInputForm( $file->getTargetUrl() ); + + $out->addHTML( + Html::rawElement( + 'p', + [], + ( new Message( 'fileimporter-importfile
[MediaWiki-commits] [Gerrit] mediawiki...FileImporter[master]: Show file details on special page
Addshore has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/337183 ) Change subject: Show file details on special page .. Show file details on special page This uses a pretend importable target to just throw some data on the special page. This also adds a POST vs GET case for the special page, the GET will simply show the infomation about the import and the POST would actually perform the import. The Importable interface will provide everything needed to import a file onto the wiki, currently only basic methods have been added, more will be added as needed. ExternalMediaWikiFile currently contains mock data. Some sort of factory will be needed to turn URLs into Importable objects. Change-Id: I71b7e7a3b6c09519d51789065d29a770a94e0338 --- M extension.json M i18n/en.json M i18n/qqq.json A src/ExternalMediaWikiFile.php A src/Importable.php M src/SpecialImportFile.php 6 files changed, 121 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter refs/changes/83/337183/1 diff --git a/extension.json b/extension.json index 75dd6bd..70fa5b7 100644 --- a/extension.json +++ b/extension.json @@ -19,6 +19,8 @@ "ImportFile": "FileImporter\\SpecialImportFile" }, "AutoloadClasses": { +"FileImporter\\ExternalMediaWikiFile": "src/ExternalMediaWikiFile.php", +"FileImporter\\Importable": "src/Importable.php", "FileImporter\\FileImporterHooks": "src/FileImporterHooks.php", "FileImporter\\SpecialImportFile": "src/SpecialImportFile.php", "FileImporter\\UrlBasedSiteLookup": "src/UrlBasedSiteLookup.php" diff --git a/i18n/en.json b/i18n/en.json index dc6073c..eb4b211 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -11,5 +11,6 @@ "fileimporter-cantimporturl": "Can't import the given URL", "fileimporter-exampleprefix": "Example", "fileimporter-submit": "Submit", + "fileimporter-import": "Import", "fileimporter-importfilefromprefix" : "Importing file from" } \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json index c56b9a4..89afd5e 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -11,5 +11,6 @@ "fileimporter-cantimporturl": "Error message shown on the special page when the URL entered can not be imported from", "fileimporter-exampleprefix": "Prefix for the example URL contained within the URL text box on the special page", "fileimporter-submit": "Text for the submit button on the special page", + "fileimporter-import": "Text for the import button on the special page", "fileimporter-importfilefromprefix" : "prefix for the URL being imported from on the special page" } diff --git a/src/ExternalMediaWikiFile.php b/src/ExternalMediaWikiFile.php new file mode 100644 index 000..22cb263 --- /dev/null +++ b/src/ExternalMediaWikiFile.php @@ -0,0 +1,20 @@ +https://upload.wikimedia.org/wikipedia/commons/5/52/Berlin_Montage_4.jpg'; + } + + public function getTargetUrl() { + return 'https://en.wikipedia.org/wiki/File:Berlin_Montage_4.jpg'; + } + +} diff --git a/src/Importable.php b/src/Importable.php new file mode 100644 index 000..ae8b8c2 --- /dev/null +++ b/src/Importable.php @@ -0,0 +1,24 @@ +enableOOUI(); $rawUrl = $out->getRequest()->getVal( 'clientUrl', '' ); + $wasPosted = $out->getRequest()->wasPosted(); if ( !$rawUrl ) { $this->showUrlEntryPage(); @@ -35,8 +37,17 @@ $this->showDisallowedUrlMessage(); $this->showUrlEntryPage(); } else { - $this->showImportPage( $parsedUrl ); + if ( $wasPosted ) { + $this->doImport(); + } else { + $this->showImportPage( $rawUrl ); + } } + } + + private function doImport() { + // TODO implement importing + $this->getOutput()->addHTML( 'TODO do the import' ); } /** @@ -71,8 +82,37 @@ } private function showUrlEntryPage() { + $this->showInputForm(); + } + + /** +* @param string $rawUrl +*/ + private function showImportPage( $rawUrl ) { + // TODO actually make the correct file? + $file = new ExternalMediaWikiFile(); + $out = $this->getOutput(); + $this->getOutput()->addModuleStyles( 'ext.FileImporter.Special' ); - $this->getOutput()->addHTML( + $this->showInputForm( $file->getTargetUrl() ); + + $out->addHTML( + Html::rawElement( + 'p', + [], + ( new Message( 'fileimporter-importfilefrom