X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/maintenance/importTextFile.php diff --git a/maintenance/importTextFile.php b/maintenance/importTextFile.php deleted file mode 100644 index 3b77eb5f..00000000 --- a/maintenance/importTextFile.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - -$options = array( 'help', 'nooverwrite', 'norc' ); -$optionsWithArgs = array( 'title', 'user', 'comment' ); -require_once( dirname( __FILE__ ) . '/commandLine.inc' ); -echo( "Import Text File\n\n" ); - -if ( count( $args ) < 1 || isset( $options['help'] ) ) { - showHelp(); -} else { - - $filename = $args[0]; - echo( "Using {$filename}..." ); - if ( is_file( $filename ) ) { - - $title = isset( $options['title'] ) ? $options['title'] : titleFromFilename( $filename ); - $title = Title::newFromURL( $title ); - - if ( is_object( $title ) ) { - - echo( "\nUsing title '" . $title->getPrefixedText() . "'..." ); - if ( !$title->exists() || !isset( $options['nooverwrite'] ) ) { - - $text = file_get_contents( $filename ); - $user = isset( $options['user'] ) ? $options['user'] : 'Maintenance script'; - $user = User::newFromName( $user ); - - if ( is_object( $user ) ) { - - echo( "\nUsing username '" . $user->getName() . "'..." ); - $wgUser =& $user; - $comment = isset( $options['comment'] ) ? $options['comment'] : 'Importing text file'; - $flags = 0 | ( isset( $options['norc'] ) ? EDIT_SUPPRESS_RC : 0 ); - - echo( "\nPerforming edit..." ); - $article = new Article( $title ); - $article->doEdit( $text, $comment, $flags ); - echo( "done.\n" ); - - } else { - echo( "invalid username.\n" ); - } - - } else { - echo( "page exists.\n" ); - } - - } else { - echo( "invalid title.\n" ); - } - - } else { - echo( "does not exist.\n" ); - } - -} - -function titleFromFilename( $filename ) { - $parts = explode( '/', $filename ); - $parts = explode( '.', $parts[ count( $parts ) - 1 ] ); - return $parts[0]; -} - -function showHelp() { -print << - - : Path to the file containing page content to import - -Options: - ---title - Title for the new page; default is to use the filename as a base ---user <user> - User to be associated with the edit ---comment <comment> - Edit summary ---nooverwrite - Don't overwrite existing content ---norc - Don't update recent changes ---help - Show this information - -EOF; -}