* @subpackage Maintenance\r
* @author Rob Church <robchur@gmail.com>\r
*/\r
- \r
+\r
+require_once( "$IP/includes/RecentChange.php" );\r
+\r
/**\r
* Insert a new article\r
*\r
* @param $text Text of the article\r
* @param $user User associated with the edit\r
* @param $comment Edit summary\r
+ * @param $rc Whether or not to add a recent changes event\r
* @return bool\r
*/\r
-function insertNewArticle( &$title, $text, &$user, $comment ) {\r
+function insertNewArticle( &$title, $text, &$user, $comment, $rc ) {\r
if( !$title->exists() ) {\r
# Create the article\r
$dbw =& wfGetDB( DB_MASTER );\r
# Make it the current revision\r
$article->updateRevisionOn( $dbw, $revision );\r
$dbw->immediateCommit();\r
+ # Update recent changes if appropriate\r
+ if( $rc )\r
+ updateRecentChanges( $dbw, $title, $user, $comment, strlen( $text ), $articleId ); \r
return( true );\r
} else {\r
# Title exists; touch nothing\r
return( Title::newFromText( $parts[0] ) );\r
}\r
\r
+/**\r
+ * Update recent changes with the page creation event\r
+ *\r
+ * @param $dbw Database in use\r
+ * @param $title Title of the new page\r
+ * @param $user User responsible for the creation\r
+ * @param $comment Edit summary associated with the edit\r
+ * @param $size Size of the page\r
+ * @param $articleId Article identifier\r
+ */ \r
+function updateRecentChanges( &$dbw, &$title, &$user, $comment, $size, $articleId ) {\r
+ RecentChange::notifyNew( $dbw->timestamp(), $title, false, $user, $comment, 'default', '', $size, $articleId );\r
+}\r
+\r
?>
\ No newline at end of file
* @author Rob Church <robchur@gmail.com>\r
*/\r
\r
-$options = array( 'help' ); \r
+$options = array( 'help', 'norc' ); \r
$optionsWithArgs = array( 'title', 'user', 'comment' );\r
require_once( 'commandLine.inc' );\r
require_once( 'importTextFile.inc' );\r
}\r
echo( "Using edit summary '{$comment}'.\n" );\r
\r
+ # Do we need to update recent changes?\r
+ if( isset( $options['norc'] ) && $options['norc'] ) {\r
+ $rc = false;\r
+ } else {\r
+ $rc = true;\r
+ }\r
+ \r
# Attempt the insertion\r
echo( "Attempting to insert page..." );\r
- $success = insertNewArticle( $title, $text, $user, $comment );\r
+ $success = insertNewArticle( $title, $text, $user, $comment, $rc );\r
if( $success ) {\r
echo( "done.\n" );\r
} else {\r
} else {\r
# Show help\r
echo( "Imports the contents of a text file into a wiki page.\n\n" );\r
- echo( "USAGE: php importTextFile.php [--help|--title <title>|--user <user>|--comment <comment>] <filename>\n\n" );\r
+ echo( "USAGE: php importTextFile.php [--help|--title <title>|--user <user>|--comment <comment>|--norc] <filename>\n\n" );\r
echo( " --help: Show this help information\n" );\r
echo( " --title <title> : Title for the new page; if not supplied, the filename is used as a base for the title\n" );\r
echo( " --user <user> : User to be associated with the edit; if not supplied, a default is used\n" );\r
echo( "--comment <comment> : Edit summary to be associated with the edit; underscores are transformed into spaces; if not supplied, a default is used\n" );\r
echo( " <filename> : Path to the file containing the wikitext to import\n" );\r
+ echo( " --norc : Do not add a page creation event to recent changes\n" );\r
\r
}\r
echo( "\n" ); \r