Example #1
0
 public function add_profile_column_data($column_name, $post_id)
 {
     if ($column_name == 'profile') {
         $document = $this->lgtm->get_group('post', $post_id);
         if (isset($document->source)) {
             $post_id = $document->source;
         }
         $profiles = Lingotek::get_profiles();
         $content_profiles = get_option('lingotek_content_type');
         $post_profile = Lingotek_Post_actions::get_post_profile($post_id);
         $post_language = $this->pllm->get_post_language($post_id);
         $post_type = 'post';
         if (isset($_REQUEST['post_type'])) {
             $post_type = $_REQUEST['post_type'];
         }
         if ($post_profile) {
             echo $profiles[$post_profile->description]['name'] . sprintf('<a title="%s">%s</a>', __('Not set to the content default profile', 'wp-lingotek'), '*');
         } else {
             if ($post_language && isset($content_profiles[$post_type]['sources'][$post_language->slug])) {
                 $profile = $content_profiles[$post_type]['sources'][$post_language->slug];
                 echo $profiles[$profile]['name'];
             } else {
                 if (!empty($content_profiles)) {
                     echo $profiles[$content_profiles[$post_type]['profile']]['name'];
                 } else {
                     if ($post_type == 'post') {
                         _e('Automatic', 'wp-lingotek');
                     } else {
                         if ($post_type == 'page') {
                             _e('Manual', 'wp-lingotek');
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
 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>';
     }
 }