X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fedit.php;h=6bdb15d90b587ecabbd1c3d84dfcef81e5064f78;hb=280cb03b4d87e864a723686daf5d1699b3566ec1;hp=7c24f0fab7a6c8f548a1c21fb6faa3cfab422d46;hpb=c46df11c1ec9ef526f173a00df724b19fc1ec754;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/edit.php b/maintenance/edit.php index 7c24f0fab7..6bdb15d90b 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -38,11 +38,13 @@ class EditCLI extends Maintenance { $this->addOption( 'bot', 'Bot edit', false, false, 'b' ); $this->addOption( 'autosummary', 'Enable autosummary', false, false, 'a' ); $this->addOption( 'no-rc', 'Do not show the change in recent changes', false, false, 'r' ); + $this->addOption( 'nocreate', 'Don\'t create new pages', false, false ); + $this->addOption( 'createonly', 'Only create new pages', false, false ); $this->addArg( 'title', 'Title of article to edit' ); } public function execute() { - global $wgUser, $wgTitle; + global $wgUser; $userName = $this->getOption( 'user', 'Maintenance script' ); $summary = $this->getOption( 'summary', '' ); @@ -61,17 +63,23 @@ class EditCLI extends Maintenance { $wgUser->addToDatabase(); } - $wgTitle = Title::newFromText( $this->getArg() ); - if ( !$wgTitle ) { + $title = Title::newFromText( $this->getArg() ); + if ( !$title ) { $this->error( "Invalid title", true ); } - $context->setTitle( $wgTitle ); + $context->setTitle( $title ); - $page = WikiPage::factory( $wgTitle ); + if ( $this->hasOption( 'nocreate' ) && !$title->exists() ) { + $this->error( "Page does not exist", true ); + } elseif ( $this->hasOption( 'createonly' ) && $title->exists() ) { + $this->error( "Page already exists", true ); + } + + $page = WikiPage::factory( $title ); # Read the text $text = $this->getStdin( Maintenance::STDIN_ALL ); - $content = ContentHandler::makeContent( $text, $wgTitle ); + $content = ContentHandler::makeContent( $text, $title ); # Do the edit $this->output( "Saving... " );