/** * @param $xliff_version * * @throws Exception */ function export_xliff($xliff_version) { global $wpdb, $current_user; get_currentuserinfo(); $data = unserialize(base64_decode($_GET['xliff_export_data'])); $archive = new wpml_zip(); $job_ids = array(); foreach ($data['job'] as $job_id => $dummy) { $xliff_file = $this->get_xliff_file($job_id, $xliff_version); // assign the job to this translator $rid = $wpdb->get_var($wpdb->prepare("SELECT rid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translate_job\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE job_id=%d ", $job_id)); $data = array('translator_id' => $current_user->ID); $data_where = array('job_id' => $job_id); $wpdb->update($wpdb->prefix . 'icl_translate_job', $data, $data_where); $data_where = array('rid' => $rid); $wpdb->update($wpdb->prefix . 'icl_translation_status', $data, $data_where); $archive->addFile($xliff_file, get_bloginfo('name') . '-translation-job-' . $job_id . '.xliff'); $job_ids[] = $job_id; } $archive->sendZip($this->_get_zip_name_from_jobs($job_ids)); exit; }
/** * @param string $xliff_version * @param array|null $job_ids * * @return wpml_zip * * @throws Exception */ function get_xliff_archive($xliff_version, $job_ids = array()) { global $wpdb, $current_user; if (empty($job_ids) && isset($_GET['xliff_export_data'])) { $data = unserialize(base64_decode($_GET['xliff_export_data'])); $job_ids = isset($data['job']) ? array_keys($data['job']) : array(); } $archive = new wpml_zip(); foreach ($job_ids as $job_id) { $xliff_file = $this->get_xliff_file($job_id, $xliff_version); // assign the job to this translator $rid = $wpdb->get_var($wpdb->prepare("SELECT rid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM {$wpdb->prefix}icl_translate_job\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE job_id=%d ", $job_id)); $data_value = array('translator_id' => $current_user->ID); $data_where = array('job_id' => $job_id); $wpdb->update($wpdb->prefix . 'icl_translate_job', $data_value, $data_where); $data_where = array('rid' => $rid); $wpdb->update($wpdb->prefix . 'icl_translation_status', $data_value, $data_where); $archive->addFile($xliff_file, get_bloginfo('name') . '-translation-job-' . $job_id . '.xliff'); } $this->export_archive_name = $this->_get_zip_name_from_jobs($job_ids); $archive->finalize(); return $archive; }