]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/import/dotclear.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / import / dotclear.php
index d51f04172aa0a1a52faa54abba1407902bfb8cf1..fcde9b1773838f947d5d13a7c4e32fc83fac1292 100644 (file)
@@ -48,115 +48,9 @@ if(!function_exists('link_exists'))
        }
 }
 
-/*
- Identify UTF-8 text
- Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
-*/
-//
-//    utf8 encoding validation developed based on Wikipedia entry at:
-//    http://en.wikipedia.org/wiki/UTF-8
-//
-//    Implemented as a recursive descent parser based on a simple state machine
-//    copyright 2005 Maarten Meijer
-//
-//    This cries out for a C-implementation to be included in PHP core
-//
-
-/**
- * @package WordPress
- * @subpackage Dotclear_Import
- *
- * @param string $char
- * @return string
- */
-function valid_1byte($char) {
-       if(!is_int($char)) return false;
-               return ($char & 0x80) == 0x00;
-}
-
-/**
- * @package WordPress
- * @subpackage Dotclear_Import
- *
- * @param string $char
- * @return string
- */
-function valid_2byte($char) {
-       if(!is_int($char)) return false;
-               return ($char & 0xE0) == 0xC0;
-}
-
 /**
- * @package WordPress
- * @subpackage Dotclear_Import
+ * Convert from dotclear charset to utf8 if required
  *
- * @param string $char
- * @return string
- */
-function valid_3byte($char) {
-       if(!is_int($char)) return false;
-               return ($char & 0xF0) == 0xE0;
-}
-
-/**
- * @package WordPress
- * @subpackage Dotclear_Import
- *
- * @param string $char
- * @return string
- */
-function valid_4byte($char) {
-       if(!is_int($char)) return false;
-               return ($char & 0xF8) == 0xF0;
-}
-
-/**
- * @package WordPress
- * @subpackage Dotclear_Import
- *
- * @param string $char
- * @return string
- */
-function valid_nextbyte($char) {
-       if(!is_int($char)) return false;
-               return ($char & 0xC0) == 0x80;
-}
-
-/**
- * @package WordPress
- * @subpackage Dotclear_Import
- *
- * @param string $string
- * @return string
- */
-function valid_utf8($string) {
-       $len = strlen($string);
-       $i = 0;
-       while( $i < $len ) {
-               $char = ord(substr($string, $i++, 1));
-               if(valid_1byte($char)) {    // continue
-                       continue;
-               } else if(valid_2byte($char)) { // check 1 byte
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-               } else if(valid_3byte($char)) { // check 2 bytes
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-               } else if(valid_4byte($char)) { // check 3 bytes
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-                       if(!valid_nextbyte(ord(substr($string, $i++, 1))))
-                               return false;
-               } // goto next char
-       }
-       return true; // done
-}
-
-/**
  * @package WordPress
  * @subpackage Dotclear_Import
  *
@@ -164,7 +58,7 @@ function valid_utf8($string) {
  * @return string
  */
 function csc ($s) {
-       if (valid_utf8 ($s)) {
+       if (seems_utf8 ($s)) {
                return $s;
        } else {
                return iconv(get_option ("dccharset"),"UTF-8",$s);
@@ -215,7 +109,7 @@ class Dotclear_Import {
                echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
                wp_nonce_field('import-dotclear');
                $this->db_form();
-               echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.attribute_escape(__('Import Categories')).'" /></p>';
+               echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.esc_attr__('Import Categories').'" /></p>';
                echo '</form></div>';
        }
 
@@ -312,7 +206,7 @@ class Dotclear_Import {
 
                        // Store category translation for future use
                        add_option('dccat2wpcat',$dccat2wpcat);
-                       echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
+                       echo '<p>'.sprintf(_n('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
                        return true;
                }
                echo __('No Categories to Import!');
@@ -519,11 +413,7 @@ class Dotclear_Import {
                                $web = "http://".$wpdb->escape($comment_site);
                                $message = $wpdb->escape(textconv ($comment_content));
 
-                               if($cinfo = comment_exists($name, $comment_dt))
-                               {
-                                       // Update comments
-                                       $ret_id = wp_update_comment(array(
-                                                       'comment_ID'            => $cinfo,
+                               $comment = array(
                                                        'comment_post_ID'       => $comment_post_ID,
                                                        'comment_author'        => $name,
                                                        'comment_author_email'  => $email,
@@ -532,23 +422,16 @@ class Dotclear_Import {
                                                        'comment_date'          => $comment_dt,
                                                        'comment_date_gmt'      => $comment_dt,
                                                        'comment_content'       => $message,
-                                                       'comment_approved'      => $comment_approved)
-                                                       );
-                               }
-                               else
-                               {
+                                                       'comment_approved'      => $comment_approved);
+                               $comment = wp_filter_comment($comment);
+
+                               if ( $cinfo = comment_exists($name, $comment_dt) ) {
+                                       // Update comments
+                                       $comment['comment_ID'] = $cinfo;
+                                       $ret_id = wp_update_comment($comment);
+                               } else {
                                        // Insert comments
-                                       $ret_id = wp_insert_comment(array(
-                                                       'comment_post_ID'       => $comment_post_ID,
-                                                       'comment_author'        => $name,
-                                                       'comment_author_email'  => $email,
-                                                       'comment_author_url'    => $web,
-                                                       'comment_author_IP'     => $comment_ip,
-                                                       'comment_date'          => $comment_dt,
-                                                       'comment_date_gmt'      => $comment_dt,
-                                                       'comment_content'       => $message,
-                                                       'comment_approved'      => $comment_approved)
-                                                       );
+                                       $ret_id = wp_insert_comment($comment);
                                }
                                $dccm2wpcm[$comment_ID] = $ret_id;
                        }
@@ -613,7 +496,7 @@ class Dotclear_Import {
                        }
                        add_option('dclinks2wplinks',$dclinks2wplinks);
                        echo '<p>';
-                       printf(__ngettext('Done! <strong>%s</strong> link or link category imported.', 'Done! <strong>%s</strong> links or link categories imported.', $count), $count);
+                       printf(_n('Done! <strong>%s</strong> link or link category imported.', 'Done! <strong>%s</strong> links or link categories imported.', $count), $count);
                        echo '<br /><br /></p>';
                        return true;
                }
@@ -632,7 +515,7 @@ class Dotclear_Import {
 
                echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
                wp_nonce_field('import-dotclear');
-               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Users')));
+               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Users'));
                echo '</form>';
 
        }
@@ -645,7 +528,7 @@ class Dotclear_Import {
 
                echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
                wp_nonce_field('import-dotclear');
-               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Posts')));
+               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Posts'));
                echo '</form>';
        }
 
@@ -659,7 +542,7 @@ class Dotclear_Import {
 
                echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
                wp_nonce_field('import-dotclear');
-               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Comments')));
+               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Comments'));
                echo '</form>';
        }
 
@@ -671,7 +554,7 @@ class Dotclear_Import {
 
                echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
                wp_nonce_field('import-dotclear');
-               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Links')));
+               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Import Links'));
                echo '</form>';
        }
 
@@ -684,7 +567,7 @@ class Dotclear_Import {
 
                echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
                wp_nonce_field('import-dotclear');
-               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Finish')));
+               printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', esc_attr__('Finish'));
                echo '</form>';
        }
 
@@ -710,11 +593,11 @@ class Dotclear_Import {
        {
                echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from DotClear, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
                echo '<h3>'.__('Users').'</h3>';
-               echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn\'t have that login in DotClear, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and DotClear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
+               echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn&#8217;t have that login in DotClear, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and DotClear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Log in</a> and change it.'), '/wp-login.php').'</p>';
                echo '<h3>'.__('Preserving Authors').'</h3>';
                echo '<p>'.__('Secondly, we have attempted to preserve post authors.  If you are the only author or contributor to your blog, then you are safe.  In most cases, we are successful in this preservation endeavor.  However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
                echo '<h3>'.__('Textile').'</h3>';
-               echo '<p>'.__('Also, since you\'re coming from DotClear, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
+               echo '<p>'.__('Also, since you&#8217;re coming from DotClear, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me&#8230; You&#8217;ll want it.').'</p>';
                echo '<h3>'.__('WordPress Resources').'</h3>';
                echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
                echo '<ul>';
@@ -722,7 +605,7 @@ class Dotclear_Import {
                echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
                echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
                echo '</ul>';
-               echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '../wp-login.php').'</p>';
+               echo '<p>'.sprintf(__('That&#8217;s it! What are you waiting for? Go <a href="%1$s">log in</a>!'), '../wp-login.php').'</p>';
        }
 
        function db_form()