public function build_archive() { $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/"; $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory)); if ($download_directory = ContentManager::download_temp_file_and_assign_extension(self::DUMP_URL)) { if (is_dir($download_directory) && file_exists($download_directory . "/names.dmp")) { $this->download_directory = $download_directory; $this->get_names(); $this->get_nodes(); recursive_rmdir($download_directory); } } $this->archive_builder->finalize(true); }
public function build_archive() { $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/"; $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory)); if ($download_directory = ContentManager::download_temp_file_and_assign_extension(self::DUMP_URL, "")) { echo "\ndownload_directory:[{$download_directory}]\n"; // $download_directory = '/Library/WebServer/Webroot/eol_php_code/applications/content_server/tmp/9f508e44e8038fb56bbc0c9b34eb3ac7'; if (is_dir($download_directory) && file_exists($download_directory . "/itis.sql")) { $this->download_directory = $download_directory; $this->all_statuses = array(); echo "Getting file names...\n"; $this->get_file_names(); echo "Getting ranks...\n"; $this->get_ranks(); echo "Getting authors...\n"; $this->get_authors(); echo "Getting locations...\n"; $this->get_locations(); echo "Getting publications...\n"; $this->get_publications(); echo "Getting publication links...\n"; $this->get_publication_links(); echo "Getting comments...\n"; $this->get_comments(); echo "Getting comment links...\n"; $this->get_comment_links(); echo "Getting vernaculars...\n"; $this->get_vernaculars(); echo "Getting synonyms...\n"; $this->get_synonyms(); $this->get_names(); print_r($this->all_statuses); recursive_rmdir($download_directory); } } $this->archive_builder->finalize(true); }
public static function validate_url($url, $suffix = null) { if (!$suffix && preg_match("/\\.([a-z]{2,4})\$/", $url, $arr)) { $suffix = $arr[1]; } if ($temp_dir = ContentManager::download_temp_file_and_assign_extension($url, $suffix, array('suffix' => $suffix, 'timeout' => 900))) { if (is_dir($temp_dir)) { if (file_exists($temp_dir . "/meta.xml")) { $archive = new ContentArchiveReader(null, $temp_dir); $validator = new ContentArchiveValidator($archive); $validator->get_validation_errors(); return array('errors' => $validator->display_errors(), 'structural_errors' => $validator->structural_errors(), 'warnings' => $validator->display_warnings(), 'stats' => $validator->stats()); } else { $error = new \eol_schema\ContentArchiveError(); $error->message = "Unable to locate a meta.xml file. Make sure the archive does not contain a directory - just the archive files."; return array('structural_errors' => array($error)); } recursive_rmdir($temp_dir); } else { $path_parts = pathinfo($temp_dir); $extension = @$path_parts['extension']; $archive_tmp_dir = @$path_parts['dirname'] . "/" . @$path_parts['filename']; recursive_rmdir($archive_tmp_dir); mkdir($archive_tmp_dir); if ($extension == 'xlsx' || $extension == 'xls') { require_library('ExcelToText'); $archive_converter = new ExcelToText($temp_dir, $archive_tmp_dir); if ($archive_converter->errors()) { return array('errors' => $archive_converter->errors()); } if ($archive_converter->is_new_schema_spreadsheet()) { $archive_converter->convert_to_new_schema_archive(); if ($archive_converter->errors()) { return array('errors' => $archive_converter->errors()); } $archive = new ContentArchiveReader(null, $archive_tmp_dir); $validator = new ContentArchiveValidator($archive); $validator->get_validation_errors(); return array('errors' => $validator->display_errors(), 'structural_errors' => $validator->structural_errors(), 'warnings' => $validator->display_warnings(), 'stats' => $validator->stats()); } $error = new \eol_schema\ContentArchiveError(); $error->message = "Unable to determine the template of Excel file"; return array('structural_errors' => array($error)); } else { $error = new \eol_schema\ContentArchiveError(); $error->message = "The uploaded file was not in a format we recognize"; return array('structural_errors' => array($error)); } wildcard_rm($archive_tmp_dir); } } else { $error = new \eol_schema\ContentArchiveError(); $error->message = "There was a problem with the uploaded file"; return array('structural_errors' => array($error)); } }