diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-12-26 12:59:33 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-12-26 12:59:33 +0000 |
commit | 5beef288184938af60e93569b1e616b30e861fa9 (patch) | |
tree | 180cabdf0b2b5a3ac084555925b3c50c391d048e | |
parent | 8fc094b4471e50f335abaed758a5f3eab06e5ce4 (diff) | |
download | wordpress-mu-5beef288184938af60e93569b1e616b30e861fa9.tar.gz wordpress-mu-5beef288184938af60e93569b1e616b30e861fa9.tar.xz wordpress-mu-5beef288184938af60e93569b1e616b30e861fa9.zip |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@487 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r-- | wp-inst/wp-admin/admin-db.php | 12 | ||||
-rw-r--r-- | wp-inst/wp-admin/edit-form-advanced.php | 8 | ||||
-rw-r--r-- | wp-inst/wp-admin/import/mt.php | 39 | ||||
-rw-r--r-- | wp-inst/wp-admin/link-import.php | 23 | ||||
-rw-r--r-- | wp-inst/wp-admin/wp-admin.css | 6 | ||||
-rw-r--r-- | wp-inst/wp-includes/classes.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-includes/functions-post.php | 61 | ||||
-rw-r--r-- | wp-inst/wp-includes/functions.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-includes/registration-functions.php | 2 |
9 files changed, 101 insertions, 56 deletions
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php index d02303f..e10c765 100644 --- a/wp-inst/wp-admin/admin-db.php +++ b/wp-inst/wp-admin/admin-db.php @@ -218,16 +218,8 @@ function wp_delete_user($id, $reassign = 'novalue') { $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); if ($post_ids) { - $post_ids = implode(',', $post_ids); - - // Delete comments, *backs - $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)"); - // Clean cats - $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)"); - // Clean post_meta - $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)"); - // Delete posts - $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id"); + foreach ($post_ids as $post_id) + wp_delete_post($post_id); } // Clean links diff --git a/wp-inst/wp-admin/edit-form-advanced.php b/wp-inst/wp-admin/edit-form-advanced.php index 1907da4..f77b4ae 100644 --- a/wp-inst/wp-admin/edit-form-advanced.php +++ b/wp-inst/wp-admin/edit-form-advanced.php @@ -33,9 +33,9 @@ $form_prevstatus = '<input type="hidden" name="prev_status" value="' . $post->po $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />'; -if ('' != $pinged) { - $pings .= '<p>'. __('Already pinged:') . '</p><ul>'; - $already_pinged = explode("\n", trim($pinged)); +if ('' != $post->pinged) { + $pings = '<p>'. __('Already pinged:') . '</p><ul>'; + $already_pinged = explode("\n", trim($post->pinged)); foreach ($already_pinged as $pinged_url) { $pings .= "\n\t<li>$pinged_url</li>"; } @@ -237,7 +237,7 @@ if ( false != $uploading_iframe_src ) <h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3> <div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>) <?php -if ('' != $pinged) +if ( ! empty($pings) ) echo $pings; ?> </div> diff --git a/wp-inst/wp-admin/import/mt.php b/wp-inst/wp-admin/import/mt.php index 4a505ba..c880544 100644 --- a/wp-inst/wp-admin/import/mt.php +++ b/wp-inst/wp-admin/import/mt.php @@ -172,13 +172,13 @@ class MT_Import { } function process_posts() { + global $wpdb; $i = -1; echo "<ol>"; - foreach ($posts as $post) { + foreach ($this->posts as $post) { if ('' != trim($post)) { ++ $i; unset ($post_categories); - echo '<li>'.__('Processing post...'); // Take the pings out first preg_match("|(-----\n\nPING:.*)|s", $post, $pings); @@ -224,7 +224,6 @@ class MT_Import { break; case 'TITLE' : $post_title = $wpdb->escape($value); - echo '<i>'.stripslashes($post_title).'</i>... '; break; case 'STATUS' : // "publish" and "draft" enumeration items match up; no change required @@ -252,15 +251,19 @@ class MT_Import { } break; case 'PRIMARY CATEGORY' : - $post_categories[] = $wpdb->escape($value); + if (! empty ($value) ) + $post_categories[] = $wpdb->escape($value); break; case 'CATEGORY' : - $post_categories[] = $wpdb->escape($value); + if (! empty ($value) ) + $post_categories[] = $wpdb->escape($value); break; case 'DATE' : $post_modified = strtotime($value); $post_modified = date('Y-m-d H:i:s', $post_modified); $post_modified_gmt = get_gmt_from_date("$post_modified"); + $post_date = $post_modified; + $post_date_gmt = $post_modified_gmt; break; default : // echo "\n$key: $value"; @@ -269,24 +272,28 @@ class MT_Import { } // End foreach // Let's check to see if it's in already - if ($post_id = posts_exists($post_title, '', $post_date)) { - _e('Post already imported.'); + if ($post_id = post_exists($post_title, '', $post_date)) { + echo '<li>'; + printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); } else { - $post_author = checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor + echo '<li>'; + printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); + + $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor $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); // Add categories. if (0 != count($post_categories)) { - wp_create_categories($post_categories); + wp_create_categories($post_categories, $post_id); } - _e(' Post imported successfully...'); } $comment_post_ID = $post_id; // Now for comments $comments = explode("-----\nCOMMENT:", $comments[0]); + $num_comments = 0; foreach ($comments as $comment) { if ('' != trim($comment)) { // Author @@ -317,15 +324,18 @@ class MT_Import { $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content'); $commentdata = wp_filter_comment($commentdata); wp_insert_comment($commentdata); - echo "Comment added."; + $num_comments++; } } } + if ( $num_comments ) + printf(__('(%s comments)'), $num_comments); // Finally the pings // fix the double newline on the first one $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]); $pings = explode("-----\nPING:", $pings[0]); + $num_pings = 0; foreach ($pings as $ping) { if ('' != trim($ping)) { // 'Author' @@ -362,10 +372,13 @@ class MT_Import { $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type'); $commentdata = wp_filter_comment($commentdata); wp_insert_comment($commentdata); - _e('Comment added.'); + $num_pings++; } } } + if ( $num_pings ) + printf(__('(%s pings)'), $num_pings); + echo "</li>"; } flush(); @@ -412,5 +425,5 @@ class MT_Import { $mt_import = new MT_Import(); -//register_importer('mt', 'Movable Type', 'Import posts and comments from your Movable Type blog', array ($mt_import, 'dispatch')); +register_importer('mt', 'Movable Type', __('Import posts and comments from your Movable Type blog'), array ($mt_import, 'dispatch')); ?> diff --git a/wp-inst/wp-admin/link-import.php b/wp-inst/wp-admin/link-import.php index 30fa178..a5f2208 100644 --- a/wp-inst/wp-admin/link-import.php +++ b/wp-inst/wp-admin/link-import.php @@ -82,17 +82,15 @@ foreach ($categories as $category) { } else // try to get the upload file. { - $uploaddir = get_settings('fileupload_realpath'); - $uploadfile = $uploaddir.'/'.$_FILES['userfile']['name']; - - if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) - { - //echo "Upload successful."; - $blogrolling = false; - $opml_url = $uploadfile; - } else { - echo __("Upload error"); - } + $overrides = array('test_form' => false, 'test_type' => false); + $file = wp_handle_upload($_FILES['import'], $overrides); + + if ( isset($file['error']) ) + die($file['error']); + + $url = $file['url']; + $opml_url = $file['file']; + $blogrolling = false; } if (isset($opml_url) && $opml_url != '') { @@ -105,6 +103,7 @@ foreach ($categories as $category) { $titles[$i] = ''; if ('http' == substr($titles[$i], 0, 4)) $titles[$i] = ''; + // FIXME: Use wp_insert_link(). $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss) VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n"; $result = $wpdb->query($query); @@ -119,6 +118,8 @@ foreach ($categories as $category) { echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n"; } // end else + if ( ! $blogrolling ) + @unlink($opml_url); ?> </div> <?php diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css index 4168954..bf4e35d 100644 --- a/wp-inst/wp-admin/wp-admin.css +++ b/wp-inst/wp-admin/wp-admin.css @@ -732,6 +732,10 @@ table .vers, table .name { display:block; } +* html #themeselect { + padding: 0px 3px; + height: 22px; +} /**************************************************************** avoid padding, margins or borders on dbx-box, @@ -837,7 +841,7 @@ table .vers, table .name { #moremeta .dbx-handle { padding: 6px 1em 2px; font-size: 12px; - background: url(images/box-head.gif) no-repeat right; + background: #2685af url(images/box-head.gif) no-repeat right; } #moremeta .dbx-box { diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php index 2a967f4..c057693 100644 --- a/wp-inst/wp-includes/classes.php +++ b/wp-inst/wp-includes/classes.php @@ -370,7 +370,7 @@ class WP_Query { $page_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); $all_page_ids = get_all_page_ids(); - $reqpage = 0; + $reqpage = 0; foreach ( $all_page_ids as $page_id ) { $page = get_page($page_id); if ( $page->fullpath == $page_path ) { diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php index e0136d4..eaaab76 100644 --- a/wp-inst/wp-includes/functions-post.php +++ b/wp-inst/wp-includes/functions-post.php @@ -136,8 +136,8 @@ function wp_insert_post($postarr = array()) { post_name = '$post_name', to_ping = '$to_ping', pinged = '$pinged', - post_modified = '$post_date', - post_modified_gmt = '$post_date_gmt', + post_modified = '".current_time('mysql')."', + post_modified_gmt = '".current_time('mysql',1)."', post_parent = '$post_parent', menu_order = '$menu_order' WHERE ID = $post_ID"); @@ -272,8 +272,11 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) { $to_ping = preg_replace('|\s+|', "\n", $to_ping); else $to_ping = ''; - - $post_parent = (int) $post_parent; + + if ( isset($post_parent) ) + $post_parent = (int) $post_parent; + else + $post_parent = 0; if ( isset($menu_order) ) $menu_order = (int) $menu_order; @@ -283,6 +286,14 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) { if ( !isset($post_password) ) $post_password = ''; + if ( isset($to_ping) ) + $to_ping = preg_replace('|\s+|', "\n", $to_ping); + else + $to_ping = ''; + + if ( ! isset($pinged) ) + $pinged = ''; + if ($update) { $wpdb->query( "UPDATE $wpdb->posts SET @@ -298,8 +309,9 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) { post_password = '$post_password', post_name = '$post_name', to_ping = '$to_ping', - post_modified = '$post_date', - post_modified_gmt = '$post_date_gmt', + pinged = '$pinged', + post_modified = '".current_time('mysql')."', + post_modified_gmt = '".current_time('mysql',1)."', post_parent = '$post_parent', menu_order = '$menu_order', post_mime_type = '$post_mime_type', @@ -308,9 +320,9 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) { } else { $wpdb->query( "INSERT INTO $wpdb->posts - (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) + (post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) VALUES - ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')"); + ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')"); $post_ID = $wpdb->insert_id; } @@ -757,18 +769,37 @@ function add_ping($post_id, $uri) { // Add a URI to those already pung return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id"); } +//fetches the pages returned as a FLAT list, but arranged in order of their hierarchy, i.e., child parents +//immediately follow their parents +function get_page_hierarchy($posts, $parent = 0) { + $result = array ( ); + if ($posts) { foreach ($posts as $post) { + if ($post->post_parent == $parent) { + $result[$post->ID] = $post->post_name; + $children = get_page_hierarchy($posts, $post->ID); + $result += $children; //append $children to $result + } + } } + return $result; +} + function generate_page_rewrite_rules() { global $wpdb; - $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_parent DESC"); + + //get pages in order of hierarchy, i.e. children after parents + $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_status = 'static'")); + //now reverse it, because we need parents after children for rewrite rules to work properly + $posts = array_reverse($posts, true); $page_rewrite_rules = array(); if ($posts) { - foreach ($posts as $post) { + + foreach ($posts as $id => $post) { // URI => page name - $uri = get_page_uri($post->ID); + $uri = get_page_uri($id); - $page_rewrite_rules[$uri] = $post->post_name; + $page_rewrite_rules[$uri] = $post; } update_option('page_uris', $page_rewrite_rules); @@ -819,7 +850,7 @@ function wp_upload_dir() { // Make sure we have an uploads dir if ( ! file_exists( $path ) ) { - if ( ! mkdir( $path ) ) + if ( ! @ mkdir( $path ) ) return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?"); @ chmod( $path, $dir_perms ); } @@ -833,14 +864,14 @@ function wp_upload_dir() { // Make sure we have a yearly dir if ( ! file_exists( $pathy ) ) { - if ( ! mkdir( $pathy ) ) + if ( ! @ mkdir( $pathy ) ) return array('error' => "Unable to create directory $pathy. Is $path writable?"); @ chmod( $pathy, $dir_perms ); } // Make sure we have a monthly dir if ( ! file_exists( $pathym ) ) { - if ( ! mkdir( $pathym ) ) + if ( ! @ mkdir( $pathym ) ) return array('error' => "Unable to create directory $pathym. Is $pathy writable?"); @ chmod( $pathym, $dir_perms ); } diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php index 74b8c56..de64053 100644 --- a/wp-inst/wp-includes/functions.php +++ b/wp-inst/wp-includes/functions.php @@ -22,6 +22,10 @@ function mysql2date($dateformatstring, $mysqlstring, $translate = true) { return false; } $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); + + if ( -1 == $i || false == $i ) + $i = 0; + if ( !empty($month) && !empty($weekday) && $translate ) { $datemonth = $month[date('m', $i)]; $datemonth_abbrev = $month_abbrev[$datemonth]; diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php index 3adc184..a2313dc 100644 --- a/wp-inst/wp-includes/registration-functions.php +++ b/wp-inst/wp-includes/registration-functions.php @@ -5,7 +5,7 @@ function username_exists( $username ) { $username = sanitize_user( $username ); $user = get_userdatabylogin($username); if ( $user ) - return $user->user_login; + return $user->ID; return null; } |