OSDN Git Service

58f5f7da360b617064326c53b02e0080aa3bd956
[nucleus-jp/nucleus-next.git] / nucleus / convert / genericImport.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2006 The Nucleus Group
5  *
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)
11  */
12 /**
13  * This script is intended to be used in conjunction with one
14  * of the specific convert tools that exist for different
15  * blogging tools
16  *
17  * Here's how everything works together
18  *              Step 1:
19  *                      - bloggerToXml.php:             Blogger -> generic XML
20  *                      - pMachineToXml.php             pMachine -> generic XML
21  *                      - MovableTypeToXml.php  MT -> generic XML
22  *              Step 1:
23  *                      - genericImport.php             generic XML -> Nucleus
24  *
25  * @license http://nucleuscms.org/license.txt GNU General Public License
26  * @copyright Copyright (C) 2002-2006 The Nucleus Group
27  * @version $Id: genericImport.php 846 2005-12-30 10:38:32Z dekarma $
28  */
29
30 include("../../config.php");
31 include("functions.inc.php");
32 include($DIR_LIBS . "ADMIN.php");
33 include($DIR_LIBS . "MEDIA.php");
34
35 if (!$member->isLoggedIn()) {
36         convert_showLogin('genericImport.php');
37 }
38
39 if (!$member->isAdmin()) {
40         convert_doError('Only Super-Admins are allowed to perform blog conversions');
41 }
42
43 $ver = convert_getNucleusVersion();
44 if ($ver > 250)
45         convert_doError("You should check the Nucleus website for updates to this convert tool. This one might not work with your current Nucleus installation.");
46
47 // include PRAX lib (to read XML files easily)
48 include ('PRAX.php');
49
50 switch($action) {
51         case "assignMembers":
52                 gi_assignMembers(); break;
53         case "doConversion":
54                 gi_doConversion(); break;
55         case "login": // drop through
56         default:
57                 gi_chooseXmlFile();
58 }
59
60 // step 1: Let the user choose which XML file she wants to import
61 function gi_chooseXmlFile() {
62         global $HTTP_SERVER_VARS, $PHP_SELF;
63
64         convert_head();
65
66         ?>
67
68                 <h1>Step 1: Choose File To Import</h1>
69
70                 <p>
71                 You're about to import the contents of a weblog that was created with another blogging tool than Nucleus.
72                 </p>
73
74                 <h2>Export to generic XML</h2>
75
76                 <p>
77                 Before you can start the actual import process, you'll need to export the contents from your (non-Nucleus) weblog into a generic XML file using one of the conversion scripts listed below. Such scripts are available for a variety of blog scripts:
78                 </p>
79
80                 <ul>
81                         <li><a href="bloggerToXml.php">Blogger</a> <strong>(not implemented yet)</strong></li>
82                         <li><a href="pMachineToXml.php">pMachine</a> <strong>(not implemented yet)</strong></li>
83                         <li><strong>(to be worked out)</strong></li>
84                 </ul>
85
86                 <h2>Import from generic XML</h2>
87
88                 <p>
89                 You'll end up with an XML file (e.g. <code>export.xml</code>). Upload this file to the same directory as the convert files (<code>/nucleus/convert/</code>) and reload this page. Your file should appear in the selection box below.
90                 </p>
91
92                 <p>
93                         <strong>(to be worked out)</strong>
94
95                         <form method="post" action="genericImport.php"><div>
96                         <input type="submit" value="Next Step: Assign Members to Authors" />
97                         <input type="hidden" name="action" value="assignMembers" />
98                         </div></form>
99                 </p>
100
101         <?php
102         convert_foot();
103 }
104
105
106 function gi_assignMembers() {
107         global $CONF;
108
109         // some checks
110         if (!file_exists('export.xml'))
111                 convert_doError("export.xml not found. Make sure it is in the correct directory");
112         if (!is_readable('export.xml'))
113                 convert_doError("The export.xml file is not readable. Make sure the file permissions are set correctly so PHP can access it.");
114
115         convert_head();
116
117         ?>
118                 <form method="post" action="genericImport.php">
119
120
121                 <h1>Step 2: Assign Members to Authors</h1>
122
123                 <p>
124                 Below is a list of all the authors that Nucleus could discover (only authors that have posted at least one entry are listed). Please assign a Nucleus Member to all of these authors.
125                 </p>
126
127
128                 <table>
129                 <tr>
130                         <th>Tool Author</th>
131                         <th>Nucleus Member</th>
132                         <th>Blog Admin?</th>
133                 </tr>
134
135         <?php           // TODO
136
137         ?>
138                 </table>
139
140                 <h1>Choose Destination Weblog</h1>
141
142                 <p>
143                 There are two options: you can either choose an existing blog to add the imported entries into, or you can choose to create a new weblog.
144                 </p>
145
146                 <div>
147                         <input name="createnew" value="0" type="radio" checked='checked' id="createnew_no" /><label for="createnew_no">Choose existing weblog to add to:</label>
148
149                         <?php                                   $query =  'SELECT bname as text, bnumber as value FROM '.sql_table('blog');
150                                         $template['name'] = 'blogid';
151                                         $template['selected'] = $CONF['DefaultBlog'];
152                                         showlist($query,'select',$template);
153                         ?>
154                 </div>
155                 <div>
156                         <input name="createnew" value="1" type="radio" id="createnew_yes" /><label for="createnew_yes">Create new weblog</label>
157                         <ul>
158                                 <li>New blog name: <input name="newblogname" /></li>
159                                 <li>Blog owner:
160                                 <?php                                   $query =  'SELECT mname as text, mnumber as value FROM '.sql_table('member');
161
162                                         $template['name'] = 'newowner';
163                                         showlist($query,'select',$template);
164                                 ?>
165                                 </li>
166                         </ul>
167                 </div>
168
169                 <h1>Do the conversion!</h1>
170                 <p>
171                 <input type="hidden" name="authorcount" value="<?php echo $idx?>" />
172                 <input type="submit" value="Step 3: Do the conversion!" />
173                 <input type="hidden" name="action" value="doConversion" />
174                 </p>
175
176                 <div class="note">
177                 <b>Note:</b> Clicking the button once is enough, even if it takes a while to complete.
178                 </div>
179
180                 </form>
181         <?php
182         convert_foot();
183
184 }
185
186
187 function gi_doConversion() {
188         // TODO
189 }
190
191
192
193 ?>