| 1 |
<?php
|
| 2 |
include_once 'includes/bootstrap.inc';
|
| 3 |
include_once 'includes/common.inc';
|
| 4 |
include_once 'blogger.inc';
|
| 5 |
|
| 6 |
// configurable variables
|
| 7 |
$type = 'blog'; // node type (defaults to 'blog'--if using blog, make sure to enable that module)
|
| 8 |
$promote = 1; // promote to front page? (defaults to 1 = yes)
|
| 9 |
// end configurable variables
|
| 10 |
|
| 11 |
// set variable defaults
|
| 12 |
global $user;
|
| 13 |
$current_user = $user;
|
| 14 |
|
| 15 |
// various counters
|
| 16 |
$count_nid = 0;
|
| 17 |
$count_uid = 0;
|
| 18 |
$count_pid = 0;
|
| 19 |
$count_cid = 0;
|
| 20 |
|
| 21 |
<Blogger>
|
| 22 |
// set defaults
|
| 23 |
$node->type = $type;
|
| 24 |
$node->promote = $promote;
|
| 25 |
|
| 26 |
// set user
|
| 27 |
$user->mail = '<$BlogItemAuthorEmail$>';
|
| 28 |
$user->name = '<$BlogItemAuthorNickname$>';
|
| 29 |
$user = import_create_user($user->mail, $user->name);
|
| 30 |
$node->uid = $user->uid;
|
| 31 |
$node->name = $user->name; // needed in node_validate()
|
| 32 |
|
| 33 |
// set node body (heredoc syntax)
|
| 34 |
$node->body = <<<NB
|
| 35 |
<$BlogItemBody$>
|
| 36 |
NB;
|
| 37 |
|
| 38 |
// set node title
|
| 39 |
$title = <<<NT
|
| 40 |
<BlogItemTitle><$BlogItemTitle$></BlogItemTitle>
|
| 41 |
NT;
|
| 42 |
$node->title = import_set_title($title, $node->body);
|
| 43 |
|
| 44 |
// use a UNIX timestamp for date
|
| 45 |
$node->created = strtotime('<$BlogItemDateTime$>');
|
| 46 |
$node->changed = strtotime('<$BlogItemDateTime$>');
|
| 47 |
|
| 48 |
// set comment status
|
| 49 |
// Blogger allows you to set comments to off & hidden, read-only, and on
|
| 50 |
// but only gives access to whether they're on or off. Thus, setting
|
| 51 |
// to read-only rather than off if they aren't enabled
|
| 52 |
$node->comment = 1; // default
|
| 53 |
|
| 54 |
<BlogItemCommentsEnabled>
|
| 55 |
$node->comment = 2; //comments enabled
|
| 56 |
</BlogItemCommentsEnabled>
|
| 57 |
|
| 58 |
// validate and save node
|
| 59 |
$node = import_create_node($node);
|
| 60 |
|
| 61 |
<BlogItemCommentsEnabled>
|
| 62 |
<BlogItemComments>
|
| 63 |
$comment->comment = <<<CB
|
| 64 |
<$BlogCommentBody$>
|
| 65 |
CB;
|
| 66 |
|
| 67 |
$comment->name = <<<CN
|
| 68 |
<$BlogCommentAuthor$>
|
| 69 |
CN;
|
| 70 |
|
| 71 |
$comment->timestamp = strtotime('<$BlogCommentDateTime$>');
|
| 72 |
|
| 73 |
$user = user_load(array('uid' => 0));
|
| 74 |
|
| 75 |
$comment = _import_get_comment_user($comment);
|
| 76 |
|
| 77 |
$cid = comment_post(array("comment" => $comment->comment, "pid" => 0, "nid" => $node->nid, "timestamp" => $comment->timestamp, "name" => $comment->name, "homepage" => $comment->homepage));
|
| 78 |
|
| 79 |
$count_cid++;
|
| 80 |
|
| 81 |
// clean up
|
| 82 |
unset($comment);
|
| 83 |
</BlogItemComments>
|
| 84 |
</BlogItemCommentsEnabled>
|
| 85 |
|
| 86 |
import_create_path('<$BlogItemPermalinkURL$>', $node->nid);
|
| 87 |
|
| 88 |
// clean up
|
| 89 |
unset($node);
|
| 90 |
unset($user);
|
| 91 |
|
| 92 |
</Blogger>
|
| 93 |
|
| 94 |
// reset user
|
| 95 |
$user = $current_user;
|
| 96 |
|
| 97 |
// echo the number of items added
|
| 98 |
echo($count_nid . ' ' . $type . ' entries added.<BR>');
|
| 99 |
echo($count_uid . ' users added.<BR>');
|
| 100 |
echo($count_pid . ' path aliases added.<BR>');
|
| 101 |
echo($count_cid . ' comments added.<BR>');
|
| 102 |
|
| 103 |
?>
|