]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/import/greymatter.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / import / greymatter.php
index 4305cd18ce18bc472b1ee2c95c10b52ed41f6b75..47c15d4b1cb7337630005d1fd45f63c2f164650a 100644 (file)
@@ -1,11 +1,26 @@
 <?php
-
+/**
+ * GreyMatter Importer
+ *
+ * @package WordPress
+ * @subpackage Importer
+ */
+
+/**
+ * GreyMatter Importer class
+ *
+ * Basic GreyMatter to WordPress importer, will import posts, comments, and
+ * posts karma.
+ *
+ * @since unknown
+ */
 class GM_Import {
 
        var $gmnames = array ();
 
        function header() {
                echo '<div class="wrap">';
+               screen_icon();
                echo '<h2>'.__('Import GreyMatter').'</h2>';
        }
 
@@ -31,32 +46,28 @@ class GM_Import {
 </ul>
 <p>&nbsp;</p>
 
-<form name="stepOne" method="get">
+<form name="stepOne" method="get" action="">
 <input type="hidden" name="import" value="greymatter" />
 <input type="hidden" name="step" value="1" />
 <?php wp_nonce_field('import-greymatter'); ?>
 <h3><?php _e('Second step: GreyMatter details:') ?></h3>
-<p><table cellpadding="0">
-<tr>
-<td><?php _e('Path to GM files:') ?></td>
-<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
-</tr>
+<table class="form-table">
 <tr>
-<td><?php _e('Path to GM entries:') ?></td>
-<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
+<td><label for="gmpath"><?php _e('Path to GM files:') ?></label></td>
+<td><input type="text" style="width:300px" name="gmpath" id="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
 </tr>
 <tr>
-<td colspan="2"><br /><?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td>
+<td><label for="archivespath"><?php _e('Path to GM entries:') ?></label></td>
+<td><input type="text" style="width:300px" name="archivespath" id="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
 </tr>
 <tr>
-<td><?php _e("Last entry's number:") ?></td>
-<td><input type="text" name="lastentry" value="00000001" /></td>
+<td><label for="lastentry"><?php _e('Last entry&#8217;s number:') ?></label></td>
+<td><input type="text" name="lastentry" id="lastentry" value="00000001" /><br />
+       <?php _e('This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don&#8217;t know that number, just log in to your FTP and look it out<br />in the entries&#8217; folder)') ?></td>
 </tr>
 </table>
-</p>
-<p><?php _e("When you're ready, click OK to start importing: ") ?><input type="submit" name="submit" value="<?php _e('OK') ?>" class="search" /></p>
+<p class="submit"><input type="submit" name="submit" class="button" value="<?php esc_attr_e('Start Importing') ?>" /></p>
 </form>
-<p>&nbsp</p>
 <?php
                $this->footer();
        }
@@ -233,6 +244,8 @@ class GM_Import {
 
                                $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
                                $post_ID = wp_insert_post($postdata);
+                               if ( is_wp_error( $post_ID ) )
+                                       return $post_ID;
                        }
 
                        $c=count($entry);
@@ -270,23 +283,25 @@ class GM_Import {
                                }
                                if ($numAddedComments > 0) {
                                        echo ': ';
-                                       printf(__('imported %d comment(s)'), $numAddedComments);
+                               printf( _n('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments);
                                }
                                $preExisting = $numComments - numAddedComments;
                                if ($preExisting > 0) {
                                        echo ' ';
-                                       printf(__('ignored %d pre-existing comments'), $preExisting);
+                                       printf( _n( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting);
                                }
                        }
                        echo '... <strong>'.__('Done').'</strong></li>';
                }
        }
+       do_action('import_done', 'greymatter');
        ?>
 </ul><strong><?php _e('Done') ?></strong></li></ul>
 <p>&nbsp;</p>
 <p><?php _e('Completed GreyMatter import!') ?></p>
 <?php
        $this->footer();
+       return;
        }
 
        function dispatch() {
@@ -301,7 +316,9 @@ class GM_Import {
                                break;
                        case 1:
                                check_admin_referer('import-greymatter');
-                               $this->import();
+                               $result = $this->import();
+                               if ( is_wp_error( $result ) )
+                                       echo $result->get_error_message();
                                break;
                }
        }
@@ -313,5 +330,5 @@ class GM_Import {
 
 $gm_import = new GM_Import();
 
-register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog'), array ($gm_import, 'dispatch'));
+register_importer('greymatter', __('GreyMatter'), __('Import users, posts, and comments from a Greymatter blog.'), array ($gm_import, 'dispatch'));
 ?>