diff options
| author | Nick Palmer <nick@sluggardy.net> | 2007-11-18 10:18:52 +0000 |
|---|---|---|
| committer | Nick Palmer <nick@sluggardy.net> | 2007-11-18 10:18:52 +0000 |
| commit | 43c5ef3c561c548e089f56f677111eb92112f010 (patch) | |
| tree | 3a4841e2ed5dd4f40991ea8be8b92564d7332522 /admin | |
| parent | 49db85f99edbc9a970e66763ab9d31c15cbb6511 (diff) | |
| download | blogs-43c5ef3c561c548e089f56f677111eb92112f010.tar.gz blogs-43c5ef3c561c548e089f56f677111eb92112f010.tar.bz2 blogs-43c5ef3c561c548e089f56f677111eb92112f010.zip | |
Update to handle posts properly and allow multiple runs.
Diffstat (limited to 'admin')
| -rw-r--r-- | admin/wp-migrate.php | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/admin/wp-migrate.php b/admin/wp-migrate.php index 3edffbe..940194f 100644 --- a/admin/wp-migrate.php +++ b/admin/wp-migrate.php @@ -188,9 +188,9 @@ function migrate_wp_categories() { $pParamHash = array(); $pParamHash['title'] = $blog->cat_name; $pParamHash['use_title'] = 'y'; - + // ToDo: Map Posts level to user group. - + // ToDO: Make this options in the prep. $pParamHash['is_public'] = 'y'; $pParamHash['allow_comments'] = 'y'; @@ -242,7 +242,7 @@ function migrate_wp_posts() { $pParamHash['current_owner_id'] = -1; } - // TODO: Check attachments + // TODO: Check attachments $bp = new BitBlogPost(); $bp->store($pParamHash); @@ -256,6 +256,44 @@ function migrate_wp_posts() { } } + if (!empty($posts)) { + foreach ($posts as $post) { + $pParamHash = array(); + $pParamHash['data'] = wptexturize(convert_chars(wpautop($post->post_content))); + $pParamHash['title'] = $post->post_title; + if ($post->post_status == 'draft') { + $pParamHash['content_status'] = -5; + } + else { + $pParamHash['content_status'] = 50; + } + $pParamHash['publish_date'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($post->post_date_gmt); + $pParamHash['last_modified'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($post->post_modified_gmt); + $pParamHash['expire_date'] = NULL; + if (empty($gUserMap[$post->post_author])) { + $pParamHash['owner_id'] = 1; + $gErrorMap[]['warning'] = "Blog Post: " . $pParamHash['title'] . " author defaulted to Administrator."; + } + else { + $pParamHash['owner_id'] = $gUserMap[$post->post_author]; + $pParamHash['current_owner_id'] = -1; + } + + // TODO: Check attachments + + $bp = new BitBlogPost(); + $bp->store($pParamHash); + if (empty($bp->mErrors)) { + $gPostMap[$post->ID] = $bp->mContentId; + $query = "UPDATE liberty_content SET created = ? WHERE content_id = ?"; + $gBitSystem->mDb->query($query, array($pParamHash['publish_date'], $bp->mContentId)); + } + else { + $pErrorMap[]['error'] = "Blog Post: " . $pParamHash['title'] . " had errors " . implode(", ", $bp->mErrors); + } + } + } + $sql = "INSERT INTO `".BIT_DB_PREFIX."blogs_wp_posts` (`wp_id`, `post_id`) VALUES (?, ?)"; foreach($gPostMap as $wp_id => $post_id) { if ($wp_id > $gMaxPost) { @@ -275,7 +313,7 @@ function migrate_wp_post_map() { foreach ($post2cat as $map) { $post = new BitBlogPost(); if (!empty($gPostMap[$map->post_id])) { - + if (!empty($gBlogMap[$map->category_id])) { $post->storePostMap($gPostMap[$map->post_id], $gBlogMap[$map->category_id]); } |
