From: Bartosz DziewoƄski Date: Wed, 23 Nov 2016 12:19:50 +0000 (+0100) Subject: Add maintenance/view.php for viewing page contents X-Git-Tag: 1.31.0-rc.0~4581^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=8c20e1ae7df779d6f44a70e3d8dd7029048c1f47;p=lhc%2Fweb%2Fwiklou.git Add maintenance/view.php for viewing page contents Use case: php maintenance/view.php Foo_bar | \ sed s/foo/bar/ | \ php maintenance/edit.php Foo_bar Adapted from maintenance/edit.php and RawAction.php. Change-Id: I170ac989e0a5b21a22054b549d62023014cb658a --- diff --git a/autoload.php b/autoload.php index 30ef985be0..4231c1f7e1 100644 --- a/autoload.php +++ b/autoload.php @@ -1522,6 +1522,7 @@ $wgAutoloadLocalClasses = [ 'VFormHTMLForm' => __DIR__ . '/includes/htmlform/VFormHTMLForm.php', 'ValidateRegistrationFile' => __DIR__ . '/maintenance/validateRegistrationFile.php', 'ViewAction' => __DIR__ . '/includes/actions/ViewAction.php', + 'ViewCLI' => __DIR__ . '/maintenance/view.php', 'VirtualRESTService' => __DIR__ . '/includes/libs/virtualrest/VirtualRESTService.php', 'VirtualRESTServiceClient' => __DIR__ . '/includes/libs/virtualrest/VirtualRESTServiceClient.php', 'WANObjectCache' => __DIR__ . '/includes/libs/objectcache/WANObjectCache.php', diff --git a/maintenance/view.php b/maintenance/view.php new file mode 100644 index 0000000000..af7eb2d923 --- /dev/null +++ b/maintenance/view.php @@ -0,0 +1,59 @@ +addDescription( 'Show article contents on the command line' ); + $this->addArg( 'title', 'Title of article to view' ); + } + + public function execute() { + $title = Title::newFromText( $this->getArg() ); + if ( !$title ) { + $this->error( "Invalid title", true ); + } + + $page = WikiPage::factory( $title ); + + $content = $page->getContent( Revision::RAW ); + if ( !$content ) { + $this->error( "Page has no content", true ); + } + if ( !$content instanceof TextContent ) { + $this->error( "Non-text content models not supported", true ); + } + + $this->output( $content->getNativeData() ); + } +} + +$maintClass = "ViewCLI"; +require_once RUN_MAINTENANCE_IF_MAIN;