Changeset 1200571
- Timestamp:
- 07/16/2015 10:46:16 PM (11 years ago)
- Location:
- lingotek-translation/trunk
- Files:
-
- 1 added
- 7 edited
-
admin/actions.php (modified) (1 diff)
-
admin/admin.php (modified) (4 diffs)
-
admin/filters-columns.php (modified) (5 diffs)
-
admin/manage/view-string-groups.php (modified) (2 diffs)
-
admin/post-actions.php (modified) (1 diff)
-
js/progress.js (modified) (1 diff)
-
js/updater.js (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lingotek-translation/trunk/admin/actions.php
r1193542 r1200571 87 87 88 88 'current' => array( 89 'title' => __(' current', 'wp-lingotek'),89 'title' => __('Current', 'wp-lingotek'), 90 90 'icon' => 'edit' 91 91 ), -
lingotek-translation/trunk/admin/admin.php
r1193542 r1200571 9 9 */ 10 10 public function __construct() { 11 12 11 $plugin = Lingotek::get_instance(); 13 12 $this->plugin_slug = $plugin->get_plugin_slug(); … … 27 26 add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3); 28 27 29 add_action('wp_ajax_'.$this->ajax_dashboard_language_endpoint, array(&$this->dashboard, 'ajax_language_dashboard'));30 28 add_action('wp_ajax_'.$this->ajax_dashboard_language_endpoint, array(&$this->dashboard, 'ajax_language_dashboard')); 29 add_action('wp_ajax_get_current_status', array($this,'ajax_get_current_status')); 31 30 //Network admin menu 32 31 add_action('network_admin_menu', array($this, 'add_network_admin_menu')); 33 32 } 33 public function ajax_get_current_status(){ 34 global $wpdb; 35 $languages = pll_languages_list(array('fields' => 'locale')); 36 $object_ids = $_POST['check_ids']; 37 if($object_ids === null){ 38 return; 39 } 40 $terms = isset($_POST['terms_translations']); 41 $taxonomy = $terms ? 'term_translations' 42 : 'post_translations'; 43 //this function allows for sanitization of a variable amount of sql IN values 44 $relationship_placeholders = $this->lingotek_get_placeholders($object_ids); 45 46 $terms_query = $wpdb->prepare("SELECT term_tax.*, terms.name AS doc_id, wp_tr.object_id FROM wp_term_taxonomy term_tax " 47 . "INNER JOIN wp_terms terms ON term_tax.term_id = terms.term_id " 48 . "INNER JOIN wp_term_relationships wp_tr ON term_tax.term_taxonomy_id = wp_tr.term_taxonomy_id " 49 . "WHERE taxonomy = '$taxonomy' " 50 . "AND wp_tr.object_id in ($relationship_placeholders)", $object_ids); 51 $results = $wpdb->get_results($terms_query); 52 53 //package up the db results into an associative array. The main array consists of 54 //ids and nonces. Each id has a source language, languages with statuses, and a workbench link 55 $content_metadata = []; 56 foreach($results as $group => $result){ 57 $id = $result->object_id; 58 $post_data = unserialize($result->description)['lingotek']; 59 60 $source_language = $terms ? pll_get_term_language($post_data['source'], 'locale') 61 : pll_get_post_language($post_data['source'], 'locale'); 62 63 $content_metadata[$id]['source'] = $source_language; 64 $content_metadata[$id]['doc_id'] = $result->doc_id; 65 $content_metadata[$id][$source_language]['status'] = $post_data['status']; 66 foreach($post_data['translations']as $locale => $translation_status){ 67 $content_metadata[$id][$locale]['status'] = $translation_status; 68 $workbench_link = Lingotek_Actions::workbench_link($result->doc_id, $locale); 69 $content_metadata[$id][$locale]['workbench_link'] = $workbench_link; 70 } 71 } 72 73 //fills in missing languages to be able to update all the ones listed on Wordpress 74 foreach($languages as $language){ 75 foreach($content_metadata as $group => $status){ 76 if(!isset($status[$language])){ 77 $content_metadata[$group][$language]['status'] = "none"; 78 } 79 } 80 } 81 //get the nonces associated with the different actions 82 $content_metadata['request_nonce'] = $this->lingotek_get_matching_nonce('lingotek-request'); 83 $content_metadata['download_nonce'] = $this->lingotek_get_matching_nonce('lingotek-download'); 84 $content_metadata['upload_nonce'] = $this->lingotek_get_matching_nonce('lingotek-upload'); 85 $content_metadata['status_nonce'] = $this->lingotek_get_matching_nonce('lingotek-status'); 86 87 wp_send_json($content_metadata); 88 } 89 90 public function lingotek_get_matching_nonce($action){ 91 $upload_link = wp_nonce_url(add_query_arg(array( 92 'action' => $action)), 93 $action); 94 $nonce_begin = strpos($upload_link, 'wpnonce=') + 8; 95 $nonce = substr($upload_link,$nonce_begin); 96 return $nonce; 97 } 98 99 public function lingotek_get_placeholders($items){ 100 foreach($items as $item){ 101 $placeholders .= '%s,'; 102 } 103 $placeholders = rtrim($placeholders, ','); 104 return $placeholders; 105 } 34 106 35 107 public function get_dashboard_endpoint(){ … … 56 128 $scripts = array( 57 129 'progress' => array(array('edit', 'upload', 'edit-tags', 'translation_page_wp-lingotek_manage', 'translation_page_wp-lingotek_settings'), array('jquery-ui-progressbar', 'jquery-ui-dialog', 'wp-ajax-response'), 1), 130 'updater' => array(array('edit', 'upload', 'edit-tags'), array('jquery-ui-progressbar', 'jquery-ui-dialog', 'wp-ajax-response'), 1), 58 131 ); 59 132 … … 410 483 */ 411 484 public function set_screen_option($status, $option, $value) { 412 if ('lingotek_strings_per_page' == $option) 485 if ('lingotek_strings_per_page' == $option) { 413 486 return $value; 487 } 414 488 return $status; 415 489 } -
lingotek-translation/trunk/admin/filters-columns.php
r1193542 r1200571 44 44 45 45 foreach ($this->model->get_languages_list() as $language) { 46 $columns['language_'.$language-> slug] = $language->flag ? $language->flag :46 $columns['language_'.$language->locale] = $language->flag ? $language->flag : 47 47 sprintf('<a href="" title="%s">%s</a>', 48 48 esc_html("$language->name ($language->locale)"), … … 71 71 call_user_func(array($this->model, 'get_' . $type . '_language'), $object_id); 72 72 73 if (false === strpos($column, 'language_') || !$lang) 73 if (false === strpos($column, 'language_') || !$lang) { 74 74 return ''; 75 } 75 76 76 77 $language = $this->model->get_language(substr($column, 9)); … … 79 80 // yes for uploaded posts, but I will need js as the field is built for all posts 80 81 // /!\ also take care not add this field two times when translations are managed by Polylang 81 82 82 // hidden field containing the post language for quick edit (used to filter categories since Polylang 1.7) 83 if ($column == $this->get_first_language_column() /*&& !$this->model->get_translation_id('post', $post_id)*/)83 if ($column == $this->get_first_language_column() /*&& !$this->model->get_translation_id('post', $post_id)*/) { 84 84 printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($object_id), esc_html($lang->slug)); 85 } 85 86 86 87 $id = ($inline && $lang->slug != $this->model->get_language($_POST['old_lang'])->slug) ? … … 97 98 98 99 // post ready for upload 99 if ($this->lgtm->can_upload($type, $object_id) && $object_id == $id) 100 if ($this->lgtm->can_upload($type, $object_id) && $object_id == $id) { 100 101 return $disabled ? 101 ('post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id)) : 102 $actions->upload_icon($object_id); 102 ('post' == $type ? parent::post_column($column, $object_id) 103 : parent::term_column('', $column, $object_id)) 104 : $actions->upload_icon($object_id); 105 } 103 106 104 107 // translation disabled 105 elseif (isset($document->source) && $document->is_disabled_target($language)) 108 elseif (isset($document->source) && $document->is_disabled_target($language)) { 106 109 return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id); 110 } 107 111 108 112 // source post is uploaded 109 113 elseif (isset($document->source) && $document->source == $id) { 110 114 // source ready for upload 111 if ($this->lgtm->can_upload($type, $id)) 115 if ($this->lgtm->can_upload($type, $id)) { 112 116 return $actions->upload_icon($id); 117 } 113 118 114 119 // importing source 115 if ($id == $object_id && 'importing' == $document->status) 120 if ($id == $object_id && 'importing' == $document->status) { 116 121 return Lingotek_Actions::importing_icon($document); 122 } 117 123 118 124 // uploaded … … 121 127 122 128 // translations 123 elseif (isset($document->translations[$language->locale]) || (isset($document->source) && 'current' == $document->status)) 129 elseif (isset($document->translations[$language->locale]) || (isset($document->source) && 'current' == $document->status)){ 124 130 return Lingotek_Actions::translation_icon($document, $language); 131 } 125 132 126 133 // translations exist but are not managed by Lingotek TMS 127 elseif (empty($document->source)) 128 return $object_id == $id && !$disabled ? 129 $actions->upload_icon($object_id, true) : 130 ('post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id)); 134 elseif (empty($document->source)) { 135 return $object_id == $id && !$disabled ? $actions->upload_icon($object_id, true) 136 : ('post' == $type ? parent::post_column($column, $object_id) 137 : parent::term_column('', $column, $object_id)); 138 } 131 139 132 140 // no translation 133 else 141 else { 134 142 return '<div class="lingotek-color dashicons dashicons-no"></div>'; 143 } 135 144 } 136 145 -
lingotek-translation/trunk/admin/manage/view-string-groups.php
r1193542 r1200571 17 17 $table = new Lingotek_Strings_Table($string_actions); 18 18 $action = $table->current_action(); 19 if (!empty($action)) 19 if (!empty($action)) { 20 20 $string_actions->manage_actions($action); 21 } 21 22 22 23 $data = Lingotek_Model::get_strings(); 23 foreach ($data as $key => $row) 24 foreach ($data as $key => $row) { 24 25 $data[$key]['row'] = $key; // store the row number for convenience 26 } 25 27 26 28 $table->prepare_items($data); ?> … … 31 33 32 34 foreach (Lingotek_String_actions::$actions as $action => $strings) { 33 if (!empty($_GET['bulk-lingotek-' . $action])) 35 if (!empty($_GET['bulk-lingotek-' . $action])) { 34 36 printf('<div id="lingotek-progressdialog" title="%s"><div id="lingotek-progressbar"></div></div>', $strings['progress']); 37 } 35 38 } 36 39 } -
lingotek-translation/trunk/admin/post-actions.php
r1193542 r1200571 95 95 public function manage_actions() { 96 96 global $typenow; 97 printf('<div id="auto-update" class="hidden"></div>'); 97 98 $post_type = 'load-upload.php' == current_filter() ? 'attachment' : $typenow; 98 99 -
lingotek-translation/trunk/js/progress.js
r1193542 r1200571 1 1 jQuery(document).ready(function($) { 2 3 2 function lingotek_progress(i) { 4 3 if (i < lingotek_data.ids.length) { -
lingotek-translation/trunk/readme.txt
r1199446 r1200571 5 5 Requires at least: 3.8 6 6 Tested up to: 4.2 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 116 116 == Changelog == 117 117 118 = 1.0.2 (2015-07-16) = 119 120 * Real-time translation status updates! 121 118 122 = 1.0.1 (2015-07-14) = 119 123
Note: See TracChangeset
for help on using the changeset viewer.