Merge branch '2.0' of https://github.com/s9y/Serendipity into 2.0
This commit is contained in:
@@ -6,6 +6,8 @@ if (IN_serendipity !== true) {
|
|||||||
die ("Don't hack!");
|
die ("Don't hack!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
if (!serendipity_checkPermission('adminImport')) {
|
if (!serendipity_checkPermission('adminImport')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -196,62 +198,41 @@ class Serendipity_Import {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
|
|
||||||
|
|
||||||
|
if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
|
||||||
|
$data['importForm'] = true;
|
||||||
/* Include the importer */
|
/* Include the importer */
|
||||||
$class = @require_once(S9Y_INCLUDE_PATH . 'include/admin/importers/'. basename($serendipity['GET']['importFrom']) .'.inc.php');
|
$class = @require_once(S9Y_INCLUDE_PATH . 'include/admin/importers/'. basename($serendipity['GET']['importFrom']) .'.inc.php');
|
||||||
if ( !class_exists($class) ) {
|
if ( !class_exists($class) ) {
|
||||||
die('FAILURE: Unable to require import module, possible syntax error?');
|
$data['die'] = true;
|
||||||
}
|
|
||||||
|
|
||||||
/* Init the importer with form data */
|
|
||||||
$importer = new $class($serendipity['POST']['import']);
|
|
||||||
|
|
||||||
/* Yes sir, we are importing if we have valid data */
|
|
||||||
if ( $importer->validateData() ) {
|
|
||||||
echo IMPORT_STARTING . '<br />';
|
|
||||||
|
|
||||||
/* import() MUST return (bool)true, otherwise we assume it failed */
|
|
||||||
if ( ($result = $importer->import()) !== true ) {
|
|
||||||
echo IMPORT_FAILED .': '. $result . '<br />';
|
|
||||||
} else {
|
|
||||||
echo IMPORT_DONE . '<br />';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Apprently we do not have valid data, ask for some */
|
|
||||||
} else {
|
} else {
|
||||||
?>
|
|
||||||
|
|
||||||
<?php echo IMPORT_PLEASE_ENTER ?>:<br />
|
/* Init the importer with form data */
|
||||||
<br />
|
$importer = new $class($serendipity['POST']['import']);
|
||||||
<form action="" method="POST" enctype="multipart/form-data">
|
|
||||||
<?php echo serendipity_setFormToken(); ?>
|
/* Yes sir, we are importing if we have valid data */
|
||||||
<table cellpadding="3" cellspacing="2">
|
if ( $importer->validateData() ) {
|
||||||
<?php foreach ( $importer->getInputFields() as $field ) { ?>
|
$data['validateData'] = true;
|
||||||
<tr>
|
|
||||||
<td><?php echo $field['text'] ?></td>
|
/* import() MUST return (bool)true, otherwise we assume it failed */
|
||||||
<td><?php serendipity_guessInput($field['type'], 'serendipity[import]['. $field['name'] .']', (isset($serendipity['POST']['import'][$field['name']]) ? $serendipity['POST']['import'][$field['name']] : $field['default']), $field['default']) ?></td>
|
if ( ($result = $importer->import()) !== true ) {
|
||||||
</tr>
|
$data['result'] = $result;
|
||||||
<?php } ?>
|
}
|
||||||
<?php if ($notes = $importer->getImportNotes()){ ?>
|
/* Apprently we do not have valid data, ask for some */
|
||||||
<tr>
|
} else {
|
||||||
<td colspan="2">
|
$data['formToken'] = serendipity_setFormToken();
|
||||||
<b><?php echo IMPORT_NOTES; ?></b><br />
|
$fields = $importer->getInputFields();
|
||||||
<?php echo $notes ?>
|
foreach ($fields as &$field ) {
|
||||||
</td>
|
ob_start();
|
||||||
</tr>
|
serendipity_guessInput($field['type'], 'serendipity[import]['. $field['name'] .']', (isset($serendipity['POST']['import'][$field['name']]) ? $serendipity['POST']['import'][$field['name']] : $field['default']), $field['default']);
|
||||||
<?php } ?>
|
$field['guessedInput'] = ob_get_contents();
|
||||||
<tr>
|
ob_end_clean();
|
||||||
<td colspan="2" align="right"><input type="submit" value="<?php echo IMPORT_NOW ?>" class="serendipityPrettyButton input_button"></td>
|
}
|
||||||
</tr>
|
$data['fields'] = $fields;
|
||||||
</table>
|
$data['notes'] = $importer->getImportNotes();
|
||||||
</form>
|
}
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$importpath = S9Y_INCLUDE_PATH . 'include/admin/importers/';
|
$importpath = S9Y_INCLUDE_PATH . 'include/admin/importers/';
|
||||||
$dir = opendir($importpath);
|
$dir = opendir($importpath);
|
||||||
$list = array();
|
$list = array();
|
||||||
@@ -269,24 +250,18 @@ if (isset($serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {
|
|||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
ksort($list);
|
ksort($list);
|
||||||
?>
|
$data['formToken'] = serendipity_setFormToken();
|
||||||
<?php echo IMPORT_WELCOME ?>.<br />
|
$data['list'] = $list;
|
||||||
<?php echo IMPORT_WHAT_CAN ?>. <br />
|
|
||||||
<br />
|
|
||||||
<?php echo IMPORT_SELECT ?>:<br />
|
|
||||||
<br />
|
|
||||||
<form action="" method="GET">
|
|
||||||
<input type="hidden" name="serendipity[adminModule]" value="import">
|
|
||||||
<?php echo serendipity_setFormToken(); ?>
|
|
||||||
<strong><?php echo IMPORT_WEBLOG_APP ?>: </strong>
|
|
||||||
<select name="serendipity[importFrom]">
|
|
||||||
<?php foreach ($list as $v=>$k) { ?>
|
|
||||||
<option value="<?php echo $v ?>"><?php echo $k ?></option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
<input type="submit" value="<?php echo GO ?>" class="serendipityPrettyButton input_button">
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_object($serendipity['smarty'])) {
|
||||||
|
serendipity_smarty_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
$serendipity['smarty']->assign($data);
|
||||||
|
$tfile = dirname(__FILE__) . "/tpl/import.inc.tpl";
|
||||||
|
$content = $serendipity['smarty']->fetch('file:'. $tfile);
|
||||||
|
echo $content;
|
||||||
|
|
||||||
|
|
||||||
/* vim: set sts=4 ts=4 expandtab : */
|
/* vim: set sts=4 ts=4 expandtab : */
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
{if $importForm}
|
||||||
|
{if $die}
|
||||||
|
FAILURE: Unable to require import module, possible syntax error?
|
||||||
|
{else}
|
||||||
|
{if $validateData}
|
||||||
|
{$CONST.IMPORT_STARTING}<br />
|
||||||
|
{if $result != true}
|
||||||
|
{$CONST.IMPORT_FAILED}: {$result}<br />
|
||||||
|
{else}
|
||||||
|
{$CONST.IMPORT_DONE}<br />
|
||||||
|
{/if}
|
||||||
|
{else}
|
||||||
|
{$CONST.IMPORT_PLEASE_ENTER}
|
||||||
|
<br />
|
||||||
|
<form action="" method="POST" enctype="multipart/form-data">
|
||||||
|
{$formToken}
|
||||||
|
<table cellpadding="3" cellspacing="2">
|
||||||
|
{foreach $fields as $field}
|
||||||
|
<tr>
|
||||||
|
<td>{$field.text}</td>
|
||||||
|
<td>{$field.guessedInput}</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
{if $notes}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<b>{$CONST.IMPORT_NOTES}</b><br />
|
||||||
|
{$notes}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" align="right"><input type="submit" value="{$CONST.IMPORT_NOW}" class="serendipityPrettyButton input_button"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{else}
|
||||||
|
{$CONST.IMPORT_WELCOME}.<br />
|
||||||
|
{$CONST.IMPORT_WHAT_CAN}. <br />
|
||||||
|
<br />
|
||||||
|
{$CONST.IMPORT_SELECT}:<br />
|
||||||
|
<br />
|
||||||
|
<form action="" method="GET">
|
||||||
|
<input type="hidden" name="serendipity[adminModule]" value="import">
|
||||||
|
{$formToken}
|
||||||
|
<strong>{$CONST.IMPORT_WEBLOG_APP}: </strong>
|
||||||
|
<select name="serendipity[importFrom]">
|
||||||
|
{foreach $list as $v => $k}
|
||||||
|
<option value="{$v}">{$k}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
<input type="submit" value="{$CONST.GO}" class="serendipityPrettyButton input_button">
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user