function column_default($item, $column_name) { // generic case (count) if (false === strpos($column_name, 'language_')) { return $item[$column_name]; } // language column $language = $this->pllm->get_language(substr($column_name, 9)); $document = $this->lgtm->get_group('string', $item['context']); // FIXME // post ready for upload if ($this->lgtm->can_upload('string', $item['context']) && $language->slug == $this->pllm->options['default_lang']) { echo $this->string_actions->upload_icon($item['context']); } elseif (isset($document->source) && $document->is_disabled_target($language)) { echo '<div class="lingotek-color dashicons dashicons-no"></div>'; } elseif (isset($document->source) && $document->source == $language->mo_id) { echo 'importing' == $document->status ? Lingotek_Actions::importing_icon($document) : Lingotek_String_actions::uploaded_icon($item['context']); } elseif (isset($document->translations[$language->locale]) || isset($document->source) && 'current' == $document->status) { echo Lingotek_Actions::translation_icon($document, $language); } else { echo '<div class="lingotek-color dashicons dashicons-no"></div>'; } $language_only = 'language_' . $language->slug; $errors = get_option('lingotek_log_errors'); if ($language_only == $this->get_first_language_column()) { if (isset($errors[$item['context']])) { $api_error = Lingotek_Actions::retrieve_api_error($errors[$item['context']]); echo Lingotek_Actions::display_error_icon('error', $api_error); } } }
protected function _column($type, $column, $object_id, $custom_data = NULL) { $action = 'post' == $type ? 'inline-save' : 'inline-save-tax'; $inline = defined('DOING_AJAX') && $_REQUEST['action'] == $action && isset($_POST['inline_lang_choice']); $lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : call_user_func(array($this->model, 'get_' . $type . '_language'), $object_id); if (false === strpos($column, 'language_') || !$lang) { if ($custom_data) { return $custom_data; } else { return ''; } } $language = $this->model->get_language(substr($column, 9)); // FIXME should I suppress quick edit? // yes for uploaded posts, but I will need js as the field is built for all posts // /!\ also take care not add this field two times when translations are managed by Polylang // hidden field containing the post language for quick edit (used to filter categories since Polylang 1.7) if ($column == $this->get_first_language_column()) { printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($object_id), esc_html($lang->slug)); } $id = $inline && $lang->slug != $this->model->get_language($_POST['old_lang'])->slug ? $language->slug == $lang->slug ? $object_id : 0 : call_user_func(array($this->model, 'get_' . $type), $object_id, $language); $document = $this->lgtm->get_group($type, $object_id); if (isset($document->source)) { $source_language = $type == 'post' ? $this->model->get_post_language($document->source) : $this->model->get_term_language($document->source); } else { $source_language = $lang; } // FIXME not very clean $actions = 'post' == $type ? $GLOBALS['wp_lingotek']->post_actions : $GLOBALS['wp_lingotek']->term_actions; $profile = Lingotek_Model::get_profile($this->content_type, $language, $object_id); $source_profile = Lingotek_Model::get_profile($this->content_type, $lang, $id); $disabled = 'disabled' == $profile['profile']; // post ready for upload if ($this->lgtm->can_upload($type, $object_id) && $object_id == $id) { return $disabled ? 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id) : ($document && count($document->desc_array) >= 3 ? $actions->upload_icon($object_id, true) : $actions->upload_icon($object_id)); } elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) { return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id); } elseif (isset($document->source) && $document->source == $id) { // source ready for upload if ($this->lgtm->can_upload($type, $id)) { return $actions->upload_icon($id); } // importing source if ($id == $object_id && 'importing' == $document->status) { return Lingotek_Actions::importing_icon($document); } // uploaded return 'post' == $type ? Lingotek_Post_actions::uploaded_icon($id) : Lingotek_Term_actions::uploaded_icon($id); } elseif ($type == 'term' && !isset($document->translations[$language->locale]) && $document->source != $object_id) { return parent::term_column('', $column, $object_id); } elseif (isset($document->translations[$language->locale]) || isset($document->source) && 'current' == $document->status) { return Lingotek_Actions::translation_icon($document, $language); } elseif (empty($document->source)) { return $object_id == $id && !$disabled ? $actions->upload_icon($object_id, true) : ('post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id)); } else { return '<div class="lingotek-color dashicons dashicons-no"></div>'; } }