3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2006 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * This script will import a Blogger blog into a Nucleus blog, using
14 * a easy to use wizard.
17 * - Templates are not converted
18 * - Nucleus should already be installed
19 * - Members should exist for all teammembers
22 * v1.0 initial version
23 * v1.1 (04/09/2005) change instruction as suggested by user (lloyd_borrett)
25 * @license http://nucleuscms.org/license.txt GNU General Public License
26 * @copyright Copyright (C) 2002-2006 The Nucleus Group
27 * @version $Id: blogger.php 846 2005-12-30 10:38:32Z dekarma $
30 include("../../config.php");
31 include("functions.inc.php");
32 include($DIR_LIBS . "ADMIN.php");
33 include($DIR_LIBS . "MEDIA.php");
35 $thisFile = 'blogger.php';
36 $xmlFile = 'blogger.xml';
38 if (!$member->isLoggedIn($thisFile)) {
39 convert_showLogin('blogger.php');
42 if (!$member->isAdmin()) {
43 convert_doError('Only Super-Admins are allowed to perform blog conversions');
46 // include PRAX lib (to read XML files easily)
51 bc_selectBlog(); break;
53 bc_assignMembers(); break;
55 bc_showOverview(); break;
57 bc_doConversion(); break;
58 case 'login': // drop through
63 // step 1: get the Blogger Blog ID
64 function bc_BloggerToXml() {
65 global $xmlFile, $thisFile;
70 <h1>Step 1: Exporting to a file</h1>
73 The first step in the conversion is to export all your Blogger entries into one single file. This is done by logging in in Blogger and by temporary changing your settings and templates.
74 <br />The full procedure is explained below:
79 <div class="note"><b>Note:</b> If you intend to keep using your weblog afterwards, write down the changes you made, so they can be undone afterwards. For the templates, copy paste the old ones in a textfile.</div>
83 Log into <a href="http://www.blogger.com/">Blogger</a> and go to the blog you want to export.
86 Change the template of your blog to the following:
88 <pre><code><?xml version="1.0"?>
90 <blog xmlns="http://nucleuscms.org/ns/import1.0" version="1.0">
94 <item id="<$BlogItemNumber$>">
95 <title><BlogItemTitle><$BlogItemTitle$></BlogItemTitle></title>
96 <body><![CDATA[<$BlogItemBody$>]]></body>
97 <timestamp type="blogger"><$BlogItemDateTime$></timestamp>
98 <author><$BlogItemAuthor$></author>
103 </blog></code></pre>
104 Don't forget to save changes!
107 Go to the settings and change the following options:
110 Blog filename: <strong><?php echo $xmlFile?></strong>
113 Show <b>900</b> <b>day's posts</b> on main page
116 Under <b>Settings : Formating</b>, change the Timestamp Format to the date/time format <b>MM/DD/YYYY HH:MM:SS AM|PM</b> (that option is not listed as such, instead it has the current date filled in)
119 Archive Frequency: <b>No Archive</b>
124 Save the settings and publish your blog. You'll end up with a <?php echo $xmlFile;?> file on your server containing all of your blog items.
127 If you're running blogspot, you'll need to edit this file and take out the advertising banner code.
133 <p>You now have a file called <code><?php echo $xmlFile?></code>. Upload it in the same directory as the convert files (<code>/nucleus/convert</code>) and continue to the next step.</p>
136 <form method="post" action="<?php echo $thisFile;?>">
137 <input type="submit" value="Next Step: Select Blog" />
138 <input type="hidden" name="action" value="selectBlog" />
146 function bc_selectBlog() {
147 global $CONF, $xmlFile, $thisFile;
150 if (!file_exists($xmlFile))
151 convert_doError($xmlFile . " not found. Make sure it is in the correct directory");
152 if (!is_readable($xmlFile))
153 convert_doError($xmlFile ." file is not readable. Make sure the file permissions are set correctly so PHP can access it.");
157 $oImport = new BlogImport();
161 <h1>Step 2: Select Destination Blog</h1>
163 <form method="post" action="<?php echo $thisFile;?>"><div>
166 echo $oImport->getHtmlCode('ConvertSelectBlog');
170 <input type="submit" value="Next Step: Assign Members" />
171 <input type="hidden" name="action" value="assignMembers" />
172 (Could take quite a while. Press the button only once)
183 function bc_assignMembers() {
184 global $xmlFile, $thisFile;
188 if (!file_exists($xmlFile))
189 convert_doError($xmlFile . " not found. Make sure it is in the correct directory");
190 if (!is_readable($xmlFile))
191 convert_doError($xmlFile ." file is not readable. Make sure the file permissions are set correctly so PHP can access it.");
196 <form method="post" action="<?php echo $thisFile;?>"><div>
198 <h1>Step 3: Assign members and Categories</h1>
202 // create blog if requested
203 $blogid = BlogImport::getBlogIdFromRequest();
205 // read author and category names
206 $oImport = new BlogImport($blogid, array('ReadNamesOnly' => 1));
207 $oImport->importXmlFile($xmlFile);
209 echo $oImport->getHtmlCode('ConvertSelectMembers');
210 // echo $oImport->getHtmlCode('ConvertSelectCategories');
214 <input type="submit" value="Start Conversion" />
215 <input type="hidden" name="blogid" value="<?php echo intval($blogid) ?>" />
216 <input type="hidden" name="action" value="doConvert" /> (Could take quite a while. Press the button only once)
226 function bc_doConversion() {
227 global $xmlFile, $thisFile;
230 if (!file_exists($xmlFile))
231 convert_doError($xmlFile . " not found. Make sure it is in the correct directory");
232 if (!is_readable($xmlFile))
233 convert_doError($xmlFile ." file is not readable. Make sure the file permissions are set correctly so PHP can access it.");
237 echo '<h1>Step 4: Conversion</h1>';
239 echo '<h2>Importing...</h2>';
240 echo '<p>Hold on while your blog is imported...</p>';
243 $blogid = BlogImport::getBlogIdFromRequest();
244 $oImport = new BlogImport($blogid);
246 $oImport->getFromRequest('authors');
247 $oImport->getFromRequest('categories');
248 $oImport->strCallback = ''; // don't use a callback method
251 $bOk = $oImport->importXmlFile($xmlFile);
256 echo '<p class="error">Error on import: ' . $oImport->getLastError() . '</p>';
260 echo '<p>Successfully imported items</p>';
262 echo '<h2>Mappings</h2>';
264 echo '<p>The mapping below maps blogger post ids to nucleus ids.</p>';
267 print_r($oImport->aMapIdToNucleusId);