Index: trunk/phase3/maintenance/importTextFile.inc |
— | — | @@ -7,7 +7,9 @@ |
8 | 8 | * @subpackage Maintenance
|
9 | 9 | * @author Rob Church <robchur@gmail.com>
|
10 | 10 | */
|
11 | | -
|
| 11 | +
|
| 12 | +require_once( "$IP/includes/RecentChange.php" );
|
| 13 | +
|
12 | 14 | /**
|
13 | 15 | * Insert a new article
|
14 | 16 | *
|
— | — | @@ -15,9 +17,10 @@ |
16 | 18 | * @param $text Text of the article
|
17 | 19 | * @param $user User associated with the edit
|
18 | 20 | * @param $comment Edit summary
|
| 21 | + * @param $rc Whether or not to add a recent changes event
|
19 | 22 | * @return bool
|
20 | 23 | */
|
21 | | -function insertNewArticle( &$title, $text, &$user, $comment ) {
|
| 24 | +function insertNewArticle( &$title, $text, &$user, $comment, $rc ) {
|
22 | 25 | if( !$title->exists() ) {
|
23 | 26 | # Create the article
|
24 | 27 | $dbw =& wfGetDB( DB_MASTER );
|
— | — | @@ -30,6 +33,9 @@ |
31 | 34 | # Make it the current revision
|
32 | 35 | $article->updateRevisionOn( $dbw, $revision );
|
33 | 36 | $dbw->immediateCommit();
|
| 37 | + # Update recent changes if appropriate
|
| 38 | + if( $rc )
|
| 39 | + updateRecentChanges( $dbw, $title, $user, $comment, strlen( $text ), $articleId );
|
34 | 40 | return( true );
|
35 | 41 | } else {
|
36 | 42 | # Title exists; touch nothing
|
— | — | @@ -49,4 +55,18 @@ |
50 | 56 | return( Title::newFromText( $parts[0] ) );
|
51 | 57 | }
|
52 | 58 |
|
| 59 | +/**
|
| 60 | + * Update recent changes with the page creation event
|
| 61 | + *
|
| 62 | + * @param $dbw Database in use
|
| 63 | + * @param $title Title of the new page
|
| 64 | + * @param $user User responsible for the creation
|
| 65 | + * @param $comment Edit summary associated with the edit
|
| 66 | + * @param $size Size of the page
|
| 67 | + * @param $articleId Article identifier
|
| 68 | + */
|
| 69 | +function updateRecentChanges( &$dbw, &$title, &$user, $comment, $size, $articleId ) {
|
| 70 | + RecentChange::notifyNew( $dbw->timestamp(), $title, false, $user, $comment, 'default', '', $size, $articleId );
|
| 71 | +}
|
| 72 | +
|
53 | 73 | ?> |
\ No newline at end of file |
Index: trunk/phase3/maintenance/importTextFile.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * @author Rob Church <robchur@gmail.com>
|
10 | 10 | */
|
11 | 11 |
|
12 | | -$options = array( 'help' );
|
| 12 | +$options = array( 'help', 'norc' );
|
13 | 13 | $optionsWithArgs = array( 'title', 'user', 'comment' );
|
14 | 14 | require_once( 'commandLine.inc' );
|
15 | 15 | require_once( 'importTextFile.inc' );
|
— | — | @@ -62,9 +62,16 @@ |
63 | 63 | }
|
64 | 64 | echo( "Using edit summary '{$comment}'.\n" );
|
65 | 65 |
|
| 66 | + # Do we need to update recent changes?
|
| 67 | + if( isset( $options['norc'] ) && $options['norc'] ) {
|
| 68 | + $rc = false;
|
| 69 | + } else {
|
| 70 | + $rc = true;
|
| 71 | + }
|
| 72 | +
|
66 | 73 | # Attempt the insertion
|
67 | 74 | echo( "Attempting to insert page..." );
|
68 | | - $success = insertNewArticle( $title, $text, $user, $comment );
|
| 75 | + $success = insertNewArticle( $title, $text, $user, $comment, $rc );
|
69 | 76 | if( $success ) {
|
70 | 77 | echo( "done.\n" );
|
71 | 78 | } else {
|
— | — | @@ -89,12 +96,13 @@ |
90 | 97 | } else {
|
91 | 98 | # Show help
|
92 | 99 | echo( "Imports the contents of a text file into a wiki page.\n\n" );
|
93 | | - echo( "USAGE: php importTextFile.php [--help|--title <title>|--user <user>|--comment <comment>] <filename>\n\n" );
|
| 100 | + echo( "USAGE: php importTextFile.php [--help|--title <title>|--user <user>|--comment <comment>|--norc] <filename>\n\n" );
|
94 | 101 | echo( " --help: Show this help information\n" );
|
95 | 102 | echo( " --title <title> : Title for the new page; if not supplied, the filename is used as a base for the title\n" );
|
96 | 103 | echo( " --user <user> : User to be associated with the edit; if not supplied, a default is used\n" );
|
97 | 104 | echo( "--comment <comment> : Edit summary to be associated with the edit; underscores are transformed into spaces; if not supplied, a default is used\n" );
|
98 | 105 | echo( " <filename> : Path to the file containing the wikitext to import\n" );
|
| 106 | + echo( " --norc : Do not add a page creation event to recent changes\n" );
|
99 | 107 |
|
100 | 108 | }
|
101 | 109 | echo( "\n" );
|