sitepress = $sitepress;
$this->wpdb = $wpdb;
$this->tm_instance = $iclTranslationManagement;
$this->job_instance = $job_instance;
$this->job = $job_instance->get_basic_data();
$this->job_factory = $job_factory;
$this->job_layout = $job_layout;
if ( $job_instance->get_translator_id() <= 0 ) {
$job_instance->assign_to( $sitepress->get_wp_api()->get_current_user_id() );
}
}
function render() {
list( $this->rtl_original, $this->rtl_translation ) = $this->init_rtl_settings();
require_once ABSPATH . 'wp-admin/includes/image.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
?>
init_original_post();
$this->init_editor_object();
$this->output_model();
$this->output_ate_notice();
$this->output_gutenberg_notice();
$this->output_wysiwyg_editors();
$this->output_copy_all_dialog();
if ( $this->is_duplicate ) {
$this->output_edit_independently_dialog();
}
$this->output_editor_form();
?>
rtl_original = $this->sitepress->is_rtl( $this->job->source_language_code );
$this->rtl_translation = $this->sitepress->is_rtl( $this->job->language_code );
$this->rtl_original_attribute_object = $this->rtl_original ? ' dir="rtl"' : ' dir="ltr"';
$this->rtl_translation_attribute = $this->rtl_translation ? ' dir="rtl"' : ' dir="ltr"';
return array( $this->rtl_original, $this->rtl_translation );
}
private function init_original_post() {
// we do not need the original document of the job here
// but the document with the same trid and in the $this->job->source_language_code
$this->all_translations = $this->sitepress->get_element_translations( $this->job->trid, $this->job->original_post_type );
$this->original_post = false;
foreach ( (array) $this->all_translations as $t ) {
if ( $t->language_code === $this->job->source_language_code ) {
$this->original_post = $this->tm_instance->get_post( $t->element_id, $this->job->element_type_prefix );
// if this fails for some reason use the original doc from which the trid originated
break;
}
}
if ( ! $this->original_post ) {
$this->original_post = $this->tm_instance->get_post( $this->job_instance->get_original_element_id(), $this->job->element_type_prefix );
}
if ( isset( $this->all_translations[ $this->job->language_code ] ) ) {
$post_status = new WPML_Post_Status( $this->wpdb, $this->sitepress->get_wp_api() );
$this->is_duplicate = $post_status->is_duplicate( $this->all_translations[ $this->job->language_code ]->element_id );
}
return $this->original_post;
}
private function init_editor_object() {
global $wpdb;
$this->editor_object = new WPML_Translation_Editor( $this->sitepress, $wpdb, $this->job_instance );
}
private function output_model() {
$model = array(
'requires_translation_complete_for_each_field' => true,
'hide_empty_fields' => true,
'translation_is_complete' => ICL_TM_COMPLETE === (int) $this->job->status,
'show_media_button' => false,
'is_duplicate' => $this->is_duplicate,
'display_hide_completed_switcher' => true,
);
if ( ! empty( $_GET['return_url'] ) ) {
$model['return_url'] = filter_var( $_GET['return_url'], FILTER_SANITIZE_URL );
} else {
$model['return_url'] = 'admin.php?page=' . WPML_TM_FOLDER . '/menu/translations-queue.php';
}
$languages = new WPML_Translation_Editor_Languages( $this->sitepress, $this->job );
$model['languages'] = $languages->get_model();
$header = new WPML_Translation_Editor_Header( $this->job_instance );
$model['header'] = $header->get_model();
$model['note'] = $this->sitepress->get_wp_api()->get_post_meta(
$this->job_instance->get_original_element_id(),
WPML_TM_Translator_Note::META_FIELD_KEY,
true
);
$this->fields = $this->job_factory->field_contents( (int) $this->job_instance->get_id() )->run();
$this->fields = $this->add_titles_and_adjust_styles( $this->fields );
$this->fields = $this->add_rtl_attributes( $this->fields );
$model['fields'] = $this->fields;
$model['layout'] = $this->job_layout->run( $model['fields'], $this->tm_instance );
$model['rtl_original'] = $this->rtl_original;
$model['rtl_translation'] = $this->rtl_translation;
$model['translation_memory'] = (bool) $this->sitepress->get_setting( 'translation_memory', 1 );
$model = $this->filter_the_model( $model );
?>
fields,
function ( $field ) {
return $field['field_style'] === '1' && strpos( $field['field_data'], '<' ) !== false;
}
);
if ( count( $html_fields ) > 0 ) {
$link = 'https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/#html-markers';
$notice_text = esc_html__( 'We see you\'re translating content that contains HTML. Switch to the Advanced Translation Editor to translate content without the risk of breaking your HTML code.', 'wpml-translation-management' );
echo '';
}
}
private function output_gutenberg_notice() {
$has_gutenberg_block = false;
foreach ( $this->fields as $field ) {
if ( preg_match( '#