} if ($job_object && $job_object->user_can_translate($current_user)) { $translation_editor_ui = new WPML_Translation_Editor_UI($sitepress, $iclTranslationManagement, $job_object); $translation_editor_ui->render(); return; } } if (!empty($_GET['resigned'])) { $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => __("You've resigned from this job.", 'wpml-translation-management'))); } if (isset($_SESSION['translation_ujobs_filter'])) { $icl_translation_filter = $_SESSION['translation_ujobs_filter']; } $current_translator = $iclTranslationManagement->get_current_translator(); $can_translate = $current_translator && $current_translator->ID > 0 && $current_translator->language_pairs; $post_link_factory = new WPML_TM_Post_Link_Factory($sitepress); if ($can_translate) { $icl_translation_filter['translator_id'] = $current_translator->ID; $icl_translation_filter['include_unassigned'] = true; $element_type_prefix = isset($_GET['element_type']) ? $_GET['element_type'] : 'post'; if (isset($_GET['updated']) && $_GET['updated']) { $post = get_post($_GET['updated']); $tm_post_link_updated = $post_link_factory->view_link($_GET['updated']); if ($iclTranslationManagement->is_external_type($element_type_prefix)) { $tm_post_link_updated = apply_filters('wpml_external_item_link', $tm_post_link_updated, $_GET['updated'], false); } $user_message = __('Translation updated: ', 'wpml-translation-management') . $tm_post_link_updated; $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => $user_message)); } elseif (isset($_GET['added']) && $_GET['added']) { $post = get_post($_GET['added']); $tm_post_link_added = $post_link_factory->view_link($_GET['added']);
public function display($odd_row) { global $iclTranslationManagement; $alternate = $odd_row ? 'class="alternate"' : ''; $current_document = $this->data; $count = $this->get_word_count(); $post_actions = array(); $post_actions_link = ""; $element_type = $this->get_type_prefix(); $check_field_name = $element_type; $post_title = $this->get_title(); $post_view_link = ''; $post_edit_link = ''; if (!$this->is_external_type()) { $post_link_factory = new WPML_TM_Post_Link_Factory($this->sitepress); $post_view_link = $post_link_factory->view_link_anchor($current_document->ID, __('View', 'wpml-translation-management')); $post_edit_link = $post_link_factory->edit_link_anchor($current_document->ID, __('Edit', 'wpml-translation-management')); } $post_view_link = apply_filters('wpml_document_view_item_link', $post_view_link, __('View', 'wpml-translation-management'), $current_document, $element_type, $this->get_type()); if ($post_view_link) { $post_actions[] = "<span class='view'>" . $post_view_link . "</span>"; } $post_edit_link = apply_filters('wpml_document_edit_item_link', $post_edit_link, __('Edit', 'wpml-translation-management'), $current_document, $element_type, $this->get_type()); if ($post_edit_link) { $post_actions[] = "<span class='edit'>" . $post_edit_link . "</span>"; } if ($post_actions) { $post_actions_link .= '<div class="row-actions">' . implode(' | ', $post_actions) . '</div>'; } ?> <tr id="row_<?php echo sanitize_html_class($current_document->ID); ?> " data-word_count="<?php echo $count; ?> " <?php echo $alternate; ?> > <td scope="row"> <?php $checked = checked(true, isset($_GET['post_id']) || $this->selected, false); ?> <input type="checkbox" value="<?php echo $current_document->ID; ?> " name="<?php echo $check_field_name; ?> [<?php echo $current_document->ID; ?> ][checked]" <?php echo $checked; ?> /> <input type="hidden" value="<?php echo $element_type; ?> " name="<?php echo $check_field_name; ?> [<?php echo $current_document->ID; ?> ][type]"/> </td> <td scope="row" class="post-title column-title"> <?php echo esc_html($post_title); echo $post_actions_link; ?> <div class="icl_post_note" id="icl_post_note_<?php echo $current_document->ID; ?> "> <?php $note = ''; if (!$current_document->is_translation) { $note = get_post_meta($current_document->ID, '_icl_translator_note', true); $this->note_text = ''; if ($note) { $this->note_text = __('Edit note for the translators', 'wpml-translation-management'); $this->note_icon = 'edit_translation.png'; } else { $this->note_text = __('Add note for the translators', 'wpml-translation-management'); $this->note_icon = 'add_translation.png'; } } ?> <label for="post_note_<?php echo $current_document->ID; ?> "> <?php _e('Note for the translators', 'wpml-translation-management'); ?> </label> <textarea id="post_note_<?php echo $current_document->ID; ?> " rows="5"><?php echo $note; ?> </textarea> <table width="100%"> <tr> <td style="border-bottom:none"> <input type="button" class="icl_tn_clear button" value="<?php _e('Clear', 'wpml-translation-management'); ?> " <?php if (!$note) { ?> disabled="disabled"<?php } ?> /> <input class="icl_tn_post_id" type="hidden" value="<?php echo $current_document->ID; ?> "/> </td> <td align="right" style="border-bottom:none"> <input type="button" class="icl_tn_save button-primary" value="<?php _e('Save', 'wpml-translation-management'); ?> "/> </td> </tr> </table> </div> </td> <td scope="row" class="post-date column-date"> <?php $element_date = $this->get_date(); if ($element_date) { echo date('Y-m-d', strtotime($element_date)); } ?> </td> <td scope="row" class="icl_tn_link" id="icl_tn_link_<?php echo $current_document->ID; ?> "> <?php if (!$current_document->is_translation) { ?> <a title="<?php echo $this->note_text; ?> " href="#"> <img src="<?php echo WPML_TM_URL; ?> /res/img/<?php echo $this->note_icon; ?> " width="16" height="16"/> </a> <?php } ?> </td> <td scope="row" class="manage-column column-date"> <?php if (isset($this->post_types[$this->get_type()])) { $custom_post_type_labels = $this->post_types[$this->get_type()]->labels; if ($custom_post_type_labels->singular_name != "") { echo $custom_post_type_labels->singular_name; } else { echo $custom_post_type_labels->name; } } else { echo $this->get_type(); } ?> </td> <td scope="row" class="manage-column column-date"> <?php echo $this->get_general_status(); ?> </td> <td scope="row" class="manage-column column-active-languages"> <?php foreach ($this->active_languages as $code => $lang) { if ($code == $this->data->language_code) { continue; } $status = $this->get_status_in_lang($code); switch ($status) { case ICL_TM_NOT_TRANSLATED: $translation_status_text = esc_attr(__('Not translated', 'wpml-translation-management')); break; case ICL_TM_WAITING_FOR_TRANSLATOR: $translation_status_text = esc_attr(__('Waiting for translator', 'wpml-translation-management')); break; case ICL_TM_IN_BASKET: $translation_status_text = esc_attr(__('In basket', 'wpml-translation-management')); break; case ICL_TM_IN_PROGRESS: $translation_status_text = esc_attr(__('In progress', 'wpml-translation-management')); break; case ICL_TM_DUPLICATE: $translation_status_text = esc_attr(__('Duplicate', 'wpml-translation-management')); break; case ICL_TM_COMPLETE: $translation_status_text = esc_attr(__('Complete', 'wpml-translation-management')); break; case ICL_TM_NEEDS_UPDATE: $translation_status_text = ' - ' . esc_attr(__('needs update', 'wpml-translation-management')); break; default: $translation_status_text = ''; } $status_image_file_name = $iclTranslationManagement->status2img_filename($status, ICL_TM_NEEDS_UPDATE === (int) $status); ?> <span data-document_status="<?php echo $status; ?> " style="padding-top:4px;"> <img title="<?php echo $lang['display_name']; ?> : <?php echo $translation_status_text; ?> " src="<?php echo WPML_TM_URL; ?> /res/img/<?php echo $status_image_file_name; ?> " width="16" height="16" alt="<?php echo $lang['display_name']; ?> : <?php echo $translation_status_text; ?> "/> </span> <?php } ?> </td> </tr> <?php }
/** * @param array $icl_translation_filter */ public function display($icl_translation_filter = array()) { /** * @var TranslationManagement $iclTranslationManagement * @var WPML_Translation_Job_Factory $wpml_translation_job_factory */ global $iclTranslationManagement, $current_user, $wpml_translation_job_factory, $wpdb; if (isset($_GET['job_id']) && $_GET['job_id'] > 0 || isset($_GET['trid']) && $_GET['trid'] > 0) { $job_id = $this->get_job_id_from_request(); $job_object = $wpml_translation_job_factory->get_translation_job($job_id, false, 0, true); if ($job_object && $job_object->user_can_translate($current_user)) { $translation_editor_ui = new WPML_Translation_Editor_UI($wpdb, $this->sitepress, $iclTranslationManagement, $job_object, new WPML_TM_Job_Action_Factory($wpml_translation_job_factory), new WPML_TM_Job_Layout($wpdb, $this->sitepress->get_wp_api())); $translation_editor_ui->render(); return; } } if (!empty($_GET['resigned'])) { $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => __("You've resigned from this job.", 'wpml-translation-management'))); } if (isset($_SESSION['translation_ujobs_filter'])) { $icl_translation_filter = $_SESSION['translation_ujobs_filter']; } $current_translator = $iclTranslationManagement->get_current_translator(); $can_translate = $current_translator && $current_translator->ID > 0 && $current_translator->language_pairs; $post_link_factory = new WPML_TM_Post_Link_Factory($this->sitepress); if ($can_translate) { $icl_translation_filter['translator_id'] = $current_translator->ID; $icl_translation_filter['include_unassigned'] = true; $element_type_prefix = isset($_GET['element_type']) ? $_GET['element_type'] : 'post'; if (isset($_GET['updated']) && $_GET['updated']) { $tm_post_link_updated = $post_link_factory->view_link($_GET['updated']); if ($iclTranslationManagement->is_external_type($element_type_prefix)) { $tm_post_link_updated = apply_filters('wpml_external_item_link', $tm_post_link_updated, $_GET['updated'], false); } $user_message = __('Translation updated: ', 'wpml-translation-management') . $tm_post_link_updated; $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => $user_message)); } elseif (isset($_GET['added']) && $_GET['added']) { $tm_post_link_added = $post_link_factory->view_link($_GET['added']); if ($iclTranslationManagement->is_external_type($element_type_prefix)) { $tm_post_link_added = apply_filters('wpml_external_item_link', $tm_post_link_added, $_GET['added'], false); } $user_message = __('Translation added: ', 'wpml-translation-management') . $tm_post_link_added; $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => $user_message)); } elseif (isset($_GET['job-cancelled'])) { $user_message = __('Translation has been removed by admin', 'wpml-translation-management'); $iclTranslationManagement->add_message(array('type' => 'error', 'text' => $user_message)); } $translation_jobs = array(); if (!empty($current_translator->language_pairs)) { $_langs_to = array(); if (1 < count($current_translator->language_pairs)) { foreach ($current_translator->language_pairs as $lang => $to) { $langs_from[] = $this->sitepress->get_language_details($lang); $_langs_to = array_merge((array) $_langs_to, array_keys($to)); } $_langs_to = array_unique($_langs_to); } else { $_langs_to = array_keys(current($current_translator->language_pairs)); $lang_from = $this->sitepress->get_language_details(key($current_translator->language_pairs)); $icl_translation_filter['from'] = $lang_from['code']; } if (1 < count($_langs_to)) { foreach ($_langs_to as $lang) { $langs_to[] = $this->sitepress->get_language_details($lang); } } else { $lang_to = $this->sitepress->get_language_details(current($_langs_to)); $icl_translation_filter['to'] = $lang_to['code']; } $job_types = $wpml_translation_job_factory->get_translation_job_types_filter(array(), array('translator_id' => $current_translator->ID, 'include_unassigned' => true)); $translation_jobs = $wpml_translation_job_factory->get_translation_jobs((array) $icl_translation_filter); } } ?> <div class="wrap"> <h2><?php echo __('Translations queue', 'wpml-translation-management'); ?> </h2> <?php if (empty($current_translator->language_pairs)) { ?> <div class="error below-h2"><p><?php _e("No translation languages configured for this user.", 'wpml-translation-management'); ?> </p></div> <?php } ?> <?php do_action('icl_tm_messages'); ?> <?php if (!empty($current_translator->language_pairs)) { ?> <div class="alignright"> <form method="post" name="translation-jobs-filter" id="tm-queue-filter" action="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/translations-queue.php"> <input type="hidden" name="icl_tm_action" value="ujobs_filter" /> <table class=""> <tbody> <tr valign="top"> <td> <select name="filter[type]"> <option value=""><?php _e('All types', 'wpml-translation-management'); ?> </option> <?php foreach ($job_types as $job_type => $job_type_name) { ?> <option value="<?php echo $job_type; ?> " <?php if (!empty($icl_translation_filter['type']) && $icl_translation_filter['type'] == $job_type) { ?> selected="selected"<?php } ?> ><?php echo $job_type_name; ?> </option> <?php } ?> </select> <label> <strong><?php _e('From', 'wpml-translation-management'); ?> </strong> <?php if (1 < count($current_translator->language_pairs)) { $from_select = new WPML_Simple_Language_Selector($this->sitepress); echo $from_select->render(array('name' => 'filter[from]', 'please_select_text' => __('Any language', 'wpml-translation-management'), 'style' => '', 'languages' => $langs_from, 'selected' => isset($icl_translation_filter['from']) ? $icl_translation_filter['from'] : '')); } else { ?> <input type="hidden" name="filter[from]" value="<?php echo esc_attr($lang_from['code']); ?> " /> <?php echo $this->sitepress->get_flag_img($lang_from['code']) . ' ' . $lang_from['display_name']; ?> <?php } ?> </label> <label> <strong><?php _e('To', 'wpml-translation-management'); ?> </strong> <?php if (1 < @count($langs_to)) { $to_select = new WPML_Simple_Language_Selector($this->sitepress); echo $to_select->render(array('name' => 'filter[to]', 'please_select_text' => __('Any language', 'wpml-translation-management'), 'style' => '', 'languages' => $langs_to, 'selected' => isset($icl_translation_filter['to']) ? $icl_translation_filter['to'] : '')); } else { ?> <input type="hidden" name="filter[to]" value="<?php echo esc_attr($lang_to['code']); ?> " /> <?php echo $this->sitepress->get_flag_img($lang_to['code']) . ' ' . $lang_to['display_name']; ?> <?php } ?> </label> <select name="filter[status]"> <option value=""><?php _e('All statuses', 'wpml-translation-management'); ?> </option> <option value="<?php echo ICL_TM_COMPLETE; ?> " <?php if (@intval($icl_translation_filter['status']) == ICL_TM_COMPLETE) { ?> selected="selected"<?php } ?> ><?php echo TranslationManagement::status2text(ICL_TM_COMPLETE); ?> </option> <option value="<?php echo ICL_TM_IN_PROGRESS; ?> " <?php if (@intval($icl_translation_filter['status']) == ICL_TM_IN_PROGRESS) { ?> selected="selected"<?php } ?> ><?php echo TranslationManagement::status2text(ICL_TM_IN_PROGRESS); ?> </option> <option value="<?php echo ICL_TM_WAITING_FOR_TRANSLATOR; ?> " <?php if (@intval($icl_translation_filter['status']) && $icl_translation_filter['status'] == ICL_TM_WAITING_FOR_TRANSLATOR) { ?> selected="selected"<?php } ?> ><?php _e('Available to translate', 'wpml-translation-management'); ?> </option> </select> <input class="button-secondary" type="submit" value="<?php _e('Filter', 'wpml-translation-management'); ?> " /> </td> </tr> </tbody> </table> </form> </div> <?php $actions = apply_filters('wpml_translation_queue_actions', array()); /** * @deprecated Use 'wpml_translation_queue_actions' instead */ $actions = apply_filters('WPML_translation_queue_actions', $actions); ?> <?php if (sizeof($actions) > 0) { ?> <form method="post" name="translation-jobs-action" action="admin.php?page=<?php echo WPML_TM_FOLDER; ?> /menu/translations-queue.php"> <?php } ?> <?php do_action('wpml_xliff_select_actions', $actions, 'action'); /** * @deprecated Use 'wpml_xliff_select_actions' instead */ do_action('WPML_xliff_select_actions', $actions, 'action'); ?> <?php $translation_queue_pagination = new WPML_Translations_Queue_Pagination_UI($translation_jobs, $this->screen_options->get_items_per_page()); $translation_jobs = $translation_queue_pagination->get_paged_jobs(); ?> <?php // pagination - end ?> <?php $blog_translators = wpml_tm_load_blog_translators(); $tm_api = new WPML_TM_API($blog_translators, $iclTranslationManagement); $translation_queue_jobs_model = new WPML_Translations_Queue_Jobs_Model($this->sitepress, $iclTranslationManagement, $tm_api, $post_link_factory, $translation_jobs); $translation_jobs = $translation_queue_jobs_model->get(); $this->show_table($translation_jobs, sizeof($actions) > 0); ?> <div id="tm-queue-pagination" class="tablenav"> <?php $translation_queue_pagination->show(); ?> <?php do_action('wpml_xliff_select_actions', $actions, 'action2'); /** * @deprecated Use 'wpml_xliff_select_actions' instead */ do_action('WPML_xliff_select_actions', $actions, 'action2'); ?> </div> <?php // pagination - end ?> <?php if (sizeof($actions) > 0) { ?> </form> <?php } ?> <?php do_action('wpml_translation_queue_after_display'); ?> <?php } ?> </div> <?php // Check for any bulk actions if (isset($_POST['action']) || isset($_POST["action2"])) { $xliff_version = isset($_POST['doaction']) ? $_POST['action'] : $_POST['action2']; do_action('wpml_translation_queue_do_actions_export_xliff', $_POST, $xliff_version); /** * @deprecated Use 'wpml_translation_queue_do_actions_export_xliff' instead */ do_action('WPML_translation_queue_do_actions_export_xliff', $_POST, $xliff_version); } }