1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11require_once('tiki-setup.php'); 12require_once('lib/importer/tikiimporter.php'); 13require_once('lib/importer/tikiimporter_wiki.php'); 14require_once('lib/wiki/editlib.php'); 15 16$access->check_permission('tiki_p_admin_importer'); 17 18if (! empty($_POST['importerClassName'])) { 19 $importerClassName = filter_input(INPUT_POST, 'importerClassName', FILTER_SANITIZE_STRING); 20 21 switch ($importerClassName) { 22 case 'TikiImporter_Wiki_Mediawiki': 23 require_once('lib/importer/tikiimporter_wiki_mediawiki.php'); 24 break; 25 case 'TikiImporter_Blog_Wordpress': 26 require_once('lib/importer/tikiimporter_blog_wordpress.php'); 27 break; 28 case 'default': 29 break; 30 } 31 32 $importer = new $importerClassName(); 33 $smarty->assign('softwareName', $importer->softwareName); 34 35 TikiImporter::changePhpSettings(); 36} 37 38if (isset($_SESSION['tiki_importer_feedback'])) { 39 $smarty->assign('importFeedback', $_SESSION['tiki_importer_feedback']); 40 $smarty->assign('importLog', $_SESSION['tiki_importer_log']); 41 $smarty->assign('importErrors', $_SESSION['tiki_importer_errors']); 42 unset($_SESSION['tiki_importer_feedback']); 43 unset($_SESSION['tiki_importer_log']); 44 unset($_SESSION['tiki_importer_errors']); 45 46 // wordpress specific 47 if (isset($_SESSION['tiki_importer_wordpress_urls'])) { 48 $smarty->assign('wordpressUrls', $_SESSION['tiki_importer_wordpress_urls']); 49 unset($_SESSION['tiki_importer_wordpress_urls']); 50 } 51} elseif (! empty($_FILES['importFile'])) { 52 // third step: start the importing process 53 54 if ($_FILES['importFile']['error'] === UPLOAD_ERR_OK) { 55 try { 56 $importer->import($_FILES['importFile']['tmp_name']); 57 } catch (Exception $e) { 58 $smarty->assign('msg', $e->getMessage()); 59 $smarty->display('error.tpl'); 60 die; 61 } 62 } else { 63 $msg = TikiImporter::displayPhpUploadError($_FILES['importFile']['error']); 64 $smarty->assign('msg', $msg); 65 $smarty->display('error.tpl'); 66 die; 67 } 68 69 die; 70} elseif (! empty($_POST['importerClassName'])) { 71 // second step: display import options for the software previously chosen 72 if (! class_exists($importerClassName)) { 73 $smarty->assign('msg', tra("Invalid software name")); 74 $smarty->display("error.tpl"); 75 die; 76 } 77 78 try { 79 $importer->checkRequirements(); 80 } catch (Exception $e) { 81 $smarty->assign('msg', $e->getMessage()); 82 $smarty->display('error.tpl'); 83 die; 84 } 85 86 $importerOptions = $importer->getOptions(); 87 88 $smarty->assign('importerOptions', $importerOptions); 89 $smarty->assign('softwareSpecificOptions', true); 90 $smarty->assign('importerClassName', $importerClassName); 91} else { 92 // first step: display the list of available software importers 93 94 // $availableSoftwares is an array that control the list of available software importers. 95 // The array key is the name of the importer class and the value is the name of the software 96 $availableSoftwares = [ 97 'TikiImporter_Wiki_Mediawiki' => 'Mediawiki', 98 'TikiImporter_Blog_Wordpress' => 'Wordpress', 99 ]; 100 101 $smarty->assign('availableSoftwares', $availableSoftwares); 102 $smarty->assign('chooseSoftware', true); 103} 104 105$smarty->assign('mid', 'tiki-importer.tpl'); 106$smarty->display('tiki.tpl'); 107