/** * Create empty archive and add package config * * @return void */ public function start() { // Set default progress Ai1wm_Status::set( array( 'total' => 0, 'processed' => 0, 'type' => 'info', 'message' => __( 'Creating an empty archive...', AI1WM_PLUGIN_NAME ) ) ); // Get package file $service = new Ai1wm_Service_Package( $this->args ); $service->export(); // Get archive file $archive = new Ai1wm_Compressor( $this->storage()->archive() ); // Add package file $archive->add_file( $this->storage()->package(), AI1WM_PACKAGE_NAME ); $archive->close(); // Set progress Ai1wm_Status::set( array( 'message' => __( 'Done creating an empty archive.', AI1WM_PLUGIN_NAME ) ) ); // Redirect $this->route_to( 'enumerate' ); }
/** * Export site * * @return StorageFile */ public function export() { $storage = StorageArea::getInstance(); // Enable maintenance mode Ai1wm_Maintenance::enable(); // Create export file $export_file = $storage->makeFile(); // Make archive file try { $zip = ZipFactory::makeZipArchiver($export_file->getName(), !class_exists('ZipArchive'), true); } catch (Exception $e) { $zip = ZipFactory::makeZipArchiver($export_file->getName(), true, true); } // Package if ($this->should_export_package()) { $service = new Ai1wm_Service_Package($this->options); $zip->addFromString(AI1WM_PACKAGE_NAME, $service->export()); } // Database if ($this->should_export_database()) { $service = new Ai1wm_Service_Database($this->options); // Add database to archive $zip->addFile($service->export(), AI1WM_DATABASE_NAME); } // Media if ($this->should_export_media()) { $service = new Ai1wm_Service_Media($this->options); // Add media to archive $zip->addDir($service->export(), AI1WM_MEDIA_NAME); // Sites (Network mode) $service = new Ai1wm_Service_Sites($this->options); if ($sites = $service->export()) { // Add sites to archive $zip->addDir($sites, AI1WM_SITES_NAME); } } // Themes if ($this->should_export_themes()) { $service = new Ai1wm_Service_Themes($this->options); // Add themes to archive $zip->addDir($service->export(), AI1WM_THEMES_NAME); } // Plugins if ($this->should_export_plugins()) { $service = new Ai1wm_Service_Plugins($this->options); // Add plugins to archive if ($plugins = $service->get_installed_plugins()) { $zip->addDir($service->export(), AI1WM_PLUGINS_NAME, $plugins); } } // Disable maintenance mode Ai1wm_Maintenance::disable(); return $export_file; }