7 $optionsWithArgs = array( 'u', 's' );
9 require_once( 'commandLine.inc' );
11 if ( count( $args ) == 0 ||
isset( $options['help'] ) ) {
13 Edit an article from the command line
15 Usage: php edit.php [options...] <title>
19 -s <summary> Edit summary
23 --no-rc Do not show the change in recent changes
25 If the specified user does not exist, it will be created.
26 The text for the edit will be read from stdin.
32 $userName = isset( $options['u'] ) ?
$options['u'] : 'Maintenance script';
33 $summary = isset( $options['s'] ) ?
$options['s'] : '';
34 $minor = isset( $options['m'] );
35 $bot = isset( $options['b'] );
36 $autoSummary = isset( $options['a'] );
37 $noRC = isset( $options['no-rc'] );
39 $wgUser = User
::newFromName( $userName );
41 print "Invalid username\n";
44 if ( $wgUser->isAnon() ) {
45 $wgUser->addToDatabase();
48 $wgTitle = Title
::newFromText( $args[0] );
50 print "Invalid title\n";
54 $wgArticle = new Article( $wgTitle );
57 $text = file_get_contents( 'php://stdin' );
61 $status = $wgArticle->doEdit( $text, $summary,
62 ( $minor ? EDIT_MINOR
: 0 ) |
63 ( $bot ? EDIT_FORCE_BOT
: 0 ) |
64 ( $autoSummary ? EDIT_AUTOSUMMARY
: 0 ) |
65 ( $noRC ? EDIT_SUPPRESS_RC
: 0 ) );
66 if ( $status->isOK() ) {
73 if ( !$status->isGood() ) {
74 print $status->getWikiText() . "\n";