2006-12-16 06:15:04 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2012-07-10 16:50:19 +00:00
|
|
|
* Make a page edit.
|
2009-08-02 19:35:17 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-17 05:40:40 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2006-12-16 06:15:04 +00:00
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2006-12-16 06:15:04 +00:00
|
|
|
|
2012-07-10 16:50:19 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to make a page edit.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class EditCLI extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->mDescription = "Edit an article from the command line, text is from stdin";
|
2011-04-06 18:37:09 +00:00
|
|
|
$this->addOption( 'user', 'Username', false, true, 'u' );
|
|
|
|
|
$this->addOption( 'summary', 'Edit summary', false, true, 's' );
|
|
|
|
|
$this->addOption( 'minor', 'Minor edit', false, false, 'm' );
|
|
|
|
|
$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' );
|
2009-08-18 23:06:24 +00:00
|
|
|
$this->addArg( 'title', 'Title of article to edit' );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2006-12-16 06:15:04 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2013-11-17 02:03:11 +00:00
|
|
|
global $wgUser;
|
2006-12-16 06:15:04 +00:00
|
|
|
|
2011-04-06 18:37:09 +00:00
|
|
|
$userName = $this->getOption( 'user', 'Maintenance script' );
|
|
|
|
|
$summary = $this->getOption( 'summary', '' );
|
|
|
|
|
$minor = $this->hasOption( 'minor' );
|
|
|
|
|
$bot = $this->hasOption( 'bot' );
|
|
|
|
|
$autoSummary = $this->hasOption( 'autosummary' );
|
2009-08-02 19:35:17 +00:00
|
|
|
$noRC = $this->hasOption( 'no-rc' );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$wgUser = User::newFromName( $userName );
|
2013-06-06 20:20:20 +00:00
|
|
|
$context = RequestContext::getMain();
|
|
|
|
|
$context->setUser( $wgUser );
|
2009-08-02 19:35:17 +00:00
|
|
|
if ( !$wgUser ) {
|
2009-08-02 21:55:10 +00:00
|
|
|
$this->error( "Invalid username", true );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
|
|
|
|
if ( $wgUser->isAnon() ) {
|
|
|
|
|
$wgUser->addToDatabase();
|
|
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2013-11-17 02:03:11 +00:00
|
|
|
$title = Title::newFromText( $this->getArg() );
|
|
|
|
|
if ( !$title ) {
|
2009-08-02 21:55:10 +00:00
|
|
|
$this->error( "Invalid title", true );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2013-11-17 02:03:11 +00:00
|
|
|
$context->setTitle( $title );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2013-11-17 02:03:11 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
# Read the text
|
2009-08-02 21:42:47 +00:00
|
|
|
$text = $this->getStdin( Maintenance::STDIN_ALL );
|
2013-11-17 02:03:11 +00:00
|
|
|
$content = ContentHandler::makeContent( $text, $title );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
# Do the edit
|
|
|
|
|
$this->output( "Saving... " );
|
2012-08-28 14:02:13 +00:00
|
|
|
$status = $page->doEditContent( $content, $summary,
|
2009-08-02 19:35:17 +00:00
|
|
|
( $minor ? EDIT_MINOR : 0 ) |
|
2010-05-22 16:50:39 +00:00
|
|
|
( $bot ? EDIT_FORCE_BOT : 0 ) |
|
2009-08-02 19:35:17 +00:00
|
|
|
( $autoSummary ? EDIT_AUTOSUMMARY : 0 ) |
|
|
|
|
|
( $noRC ? EDIT_SUPPRESS_RC : 0 ) );
|
|
|
|
|
if ( $status->isOK() ) {
|
|
|
|
|
$this->output( "done\n" );
|
|
|
|
|
$exit = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( "failed\n" );
|
|
|
|
|
$exit = 1;
|
|
|
|
|
}
|
|
|
|
|
if ( !$status->isGood() ) {
|
|
|
|
|
$this->output( $status->getWikiText() . "\n" );
|
|
|
|
|
}
|
|
|
|
|
exit( $exit );
|
|
|
|
|
}
|
2006-12-16 06:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$maintClass = "EditCLI";
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|