/** * Base function to import a website into Wordpress. Takes $settings that have been set in the plugin's settings page, and uses $_FILES to access uploaded files (if required). In the end all pages and media should be imported into Wordpress with internal links updated. * * @param \html_import\admin\HtmlImportSettings $settings */ public function importHTMLFiles(html_import\admin\HtmlImportSettings $settings) { echo '<h2>Output from Import</h2><br>Please be patient</br>'; echo '<ul>'; if ($settings->validate()) { // TODO: prefer to pass this value in rather than use global $zip_to_upload = $_FILES['file-upload']; if (strcmp('upload', $settings->getImportSource()->getValue()) == 0) { $mime_type = $zip_to_upload['type']; echo 'uploading file of mime-type ' . $mime_type . ' <br>'; if ($this->isFileMimeTypeCompressed($mime_type)) { // echo 'mime-type: '.$mime_type; $filePath = $this->decompressAndUploadFiletoSite($zip_to_upload); if (!is_null($filePath)) { $this->routeImportToCorrectImporter($filePath, $settings); // clean up the files that were unzipped html_import\FileHelper::delTree($filePath); } } else { echo 'File is not a ZIP file.'; } } else { $this->routeImportToCorrectImporter($settings->getFileLocation()->getValue(), $settings); } } else { echo 'The required parameters were not set.<br>'; } echo '</ul>'; }
<label for="file-type-index"><input type="radio" name="file-type" id="file-type-index" value="index" <?php checked(strcmp('index', $settings->getFileType()->getValue()), 0, true); ?> />Index File</label><br> <label for="file-type-zip"><input type="radio" name="file-type" id="file-type-zip" value="zip" <?php checked(strcmp('zip', $settings->getFileType()->getValue()), 0, true); ?> />ZIP Archive</label><br> </p> </div> <div> <p id="import-source"> <h3>Select the source of the import</h3> <label for="import-source-location"><input type="radio" name="import-source" id="import-source-location" value="location" onclick="javascript: jQuery('#define-upload').hide('fast'); jQuery('#define-location').show('fast');" <?php checked(strcmp('location', $settings->getImportSource()->getValue()), 0, true); ?> />Location (local, remote, or URL)</label><br> <label for="import-source-upload"><input type="radio" name="import-source" id="import-source-upload" value="upload" onclick="javascript: jQuery('#define-upload').show('fast'); jQuery('#define-location').hide('fast');"<?php checked(strcmp('upload', $settings->getImportSource()->getValue()), 0, true); ?> />Upload ZIP</label><br> </p> </div> <p id="define-location" style="display:<?php echo strcmp('location', $settings->getImportSource()->getValue()) == 0 ? 'visible' : 'none'; ?> ;"> <label for="file-location"><?php _e('Enter in the absolute file location of the index file:', 'file_location'); ?>