Plugin Directory

Changeset 1907909


Ignore:
Timestamp:
07/11/2018 09:45:56 PM (8 years ago)
Author:
erichie
Message:

added document metadata to translation profiles, added ability to manually copy categories and tags

Location:
lingotek-translation
Files:
151 added
11 edited

Legend:

Unmodified
Added
Removed
  • lingotek-translation/trunk/admin/actions.php

    r1827884 r1907909  
    253253        self::$icons[ $name ]['icon'], self::$icons[ $name ]['title'] . "\n" . $api_error, $additional);
    254254    }
    255 
     255   
    256256    /**
    257257     * Outputs an upload icon
  • lingotek-translation/trunk/admin/filters-columns.php

    r1694568 r1907909  
    119119        // post ready for upload.
    120120        if ( $this->lgtm->can_upload( $type, $object_id ) && $object_id === $id ) {
     121       
    121122            return $disabled ? ('post' === $type ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id ))
    122123            : ($document && (count( $document->desc_array ) >= 3) ? $actions->upload_icon( $object_id, true ) : $actions->upload_icon( $object_id ));
    123124        } // if language is set to copy and profile is manual.
    124         elseif ( ('post' === $type) && ((isset( $source_profile['targets'][ $language->slug ] ) && 'copy' === $source_profile['targets'][ $language->slug ]) || (isset( $profile['targets'][ $language->slug ] ) && 'copy' === $profile['targets'][ $language->slug ] ) && isset( $document->source )) ) {
    125             if ( isset( $document->desc_array[ $language->slug ] ) ) {
    126                 return 'post' === $type ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id );
    127             } else {
    128                 if ( $document ) {
    129                     return $actions->copy_icon( $document->source, $language->slug );
    130                 } else {
    131                     return $actions->copy_icon( $object_id, $language->slug );
    132                 }
    133             }
     125         elseif ( ('post' === $type || 'term' === $type) && ((isset( $source_profile['targets'][ $language->slug ] ) && 'copy' === $source_profile['targets'][ $language->slug ]) || (isset( $profile['targets'][ $language->slug ] ) && 'copy' === $profile['targets'][ $language->slug ] ) && isset( $document->source )) ) {
     126
     127            if ( isset( $document->desc_array[ $language->slug ] )  ) {     
     128                return ('post' === $type) ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id );
     129            } else {
     130                if ( $document ) {
     131                    return $actions->copy_icon( $document->source, $language->slug );               
     132                } else {
     133                    return $actions->copy_icon( $object_id, $language->slug );
     134                }
     135            }
    134136        } // translation disabled.
    135137        elseif ( ( isset( $document->source ) && $document->is_disabled_target( $source_language, $language ) && ! isset( $document->translations[ $language->locale ] ) ) || !Lingotek::is_allowed_tms_locale($language->lingotek_locale) ) {
    136138            return 'post' === $type ? parent::post_column( $column, $object_id ) : parent::term_column( '', $column, $object_id );
    137139        } // source post is uploaded.
    138         elseif ( isset( $document->source ) && $document->source === $id ) {
    139             // source ready for upload.
    140             if ( $this->lgtm->can_upload( $type, $id ) ) {
    141                 return $actions->upload_icon( $id );
    142             }
    143 
    144             // importing source.
    145             if ( $id === $object_id && 'importing' === $document->status ) {
     140         elseif ( isset( $document->source ) && $document->source === $id ) {
     141            // source ready for upload.
     142            if ( $this->lgtm->can_upload( $type, $id ) ) {
     143                return $actions->upload_icon( $id );
     144         }
     145
     146            // importing source.
     147            if ( $id === $object_id && 'importing' === $document->status ) {
    146148                return Lingotek_Actions::importing_icon( $document );
    147149            }
    148150
    149             // uploaded.
    150             return 'post' === $type ? Lingotek_Post_actions::uploaded_icon( $id ) : Lingotek_Term_actions::uploaded_icon( $id );
    151         } // translations.
     151            // uploaded.
     152            return 'post' === $type ? Lingotek_Post_actions::uploaded_icon( $id ) : Lingotek_Term_actions::uploaded_icon( $id );
     153    } // translations.
    152154        elseif ( isset( $document->translations[ $language->locale ] ) || (isset( $document->source ) && 'current' === $document->status) ) {
    153155            return Lingotek_Actions::translation_icon( $document, $language );
    154         } elseif ( ( 'term' === $type && ! isset( $document->translations[ $language->locale ] ) && $document->source !== $object_id ) || !Lingotek::is_allowed_tms_locale($language->lingotek_locale) ) {
     156        } elseif ( ( 'term' === $type && ! isset( $document->translations[ $language->locale ] ) && $document->source !== $object_id ) || !Lingotek::is_allowed_tms_locale($language->lingotek_locale) ) { 
    155157            return parent::term_column( '', $column, $object_id );
    156158        } // translations exist but are not managed by Lingotek TMS.
  • lingotek-translation/trunk/admin/manage/view-edit-profile.php

    r1730742 r1907909  
    2323$profile = isset($_GET['profile']) && array_key_exists($_GET['profile'], $profiles) ? $profiles[$_GET['profile']] : array();
    2424$disabled = isset($profile['profile']) && in_array($profile['profile'], array('automatic', 'manual')) ? 'disabled="disabled"' : '';
    25 
    2625// Code to determine which filter scenario will be displayed. (Not configured, defaults, custom filters)
    2726$primary_filter_id = array_search('okf_json@with-html-subfilter.fprm', $settings['primary_filter_id']['options']);
     
    193192    </td>
    194193  </tr>
    195 
    196194  <?php
    197195    } ?>
    198 </table><?php submit_button(__('Save Changes', 'lingotek-translation'), 'primary', 'submit', false); ?>
    199 
     196</table>
     197
     198<?php $metadata = array(
     199    "author_email" => "Author Email",
     200    "author_name" => "Author Name",
     201    "division" => "Business Division",
     202    "unit" => "Business Unit",
     203    "campaign_id" => "Campaign ID",
     204    "channel" => "Channel",
     205    "contact_email" => "Contact Email",
     206    "contact_name" => "Contact Name",
     207    "description" => "Content Description",
     208    "domain" => "Domain",
     209    "style_id" => "External Style ID",
     210    "purchase_order" => "Purchase Order",
     211    "reference_url" => "Reference URL",
     212    "region" => "Region",
     213    "require_review" => "Require Review"
     214) ?>
     215<h3><?php _e('Document Metadata', 'lingotek-translation'); ?></h3>
     216<table class="form-table">
     217<?php
     218foreach ($metadata as $key => $data){
     219    $index = array_search($key,array_keys($metadata));
     220    if ($index == 0){
     221        printf('<tr>');
     222    }
     223    if ($index %3 == 0){
     224        printf('</tr>');
     225        printf('<tr>');
     226    }
     227    if (isset($profile[$key])){
     228        printf('<th>&nbsp; %s <br><input type="text" name="%s" value="%s"></th>', $data ,$key, $profile[$key]);
     229    }
     230    else{
     231        printf('<th>&nbsp; %s <br><input type="text" name="%s"></th>', $data, $key);
     232    }
     233}
     234?>
     235</table>   
     236
     237<?php submit_button(__('Save Changes', 'lingotek-translation'), 'primary', 'submit', false); ?>
    200238<?php
    201239if (!empty($profile['profile']) && !in_array($profile['profile'], array('automatic', 'manual', 'disabled')) && empty($profile['usage']))
  • lingotek-translation/trunk/admin/manage/view-profiles.php

    r1730742 r1907909  
    3434            $profiles[$profile_id]['name'] = strip_tags($_POST['name']);
    3535
    36         foreach (array('upload', 'download', 'project_id', 'workflow_id', 'primary_filter_id', 'secondary_filter_id') as $key) {
    37             if (isset($_POST[$key]) && in_array($_POST[$key], array_keys($settings[$key]['options'])))
     36        foreach (array('upload', 'download', 'project_id', 'workflow_id', 'primary_filter_id', 'secondary_filter_id','author_email', 'author_name','division','unit','campaign_id','channel','contact_email','contact_name','description','domain','style_id','purchase_order','reference_url','region','require_review') as $key) {
     37            if (isset($_POST[$key]) )
    3838                $profiles[$profile_id][$key] = $_POST[$key];
    3939
  • lingotek-translation/trunk/admin/strings-table.php

    r1694568 r1907909  
    102102            if ( isset( $errors[ $item['context'] ] ) ) {
    103103                $api_error = Lingotek_Actions::retrieve_api_error( $errors[ $item['context'] ] );
    104                 echo esc_html( Lingotek_Actions::display_error_icon( 'error', $api_error ) );
     104                echo  Lingotek_Actions::display_error_icon( 'error', $api_error );
    105105            }
    106106        }
  • lingotek-translation/trunk/admin/term-actions.php

    r1818525 r1907909  
    160160                break;
    161161
     162                case 'lingotek-copy':       
     163                check_admin_referer( 'lingotek-copy' );
     164                $term_to_copy = get_term( (int) filter_input( INPUT_GET, 'term' ) );
     165                $target = filter_input( INPUT_GET, 'target' );
     166                $this->lgtm->copy_term( $term_to_copy, $target, $taxnow);
     167                break;
     168
    162169            default:
    163170                if (!$this->_manage_actions($action))
  • lingotek-translation/trunk/include/group-string.php

    r1694568 r1907909  
    113113        }
    114114    }
    115 
     115 
    116116    /*
    117117     * returns the content to translate
     
    129129        return json_encode($arr);
    130130    }
    131 
     131 
    132132    /*
    133133     * requests translations to Lingotek TMS
  • lingotek-translation/trunk/include/group.php

    r1827884 r1907909  
    209209     */
    210210    protected function _request_translations($source_language) {
    211        
     211
    212212        $type_id;
    213213        $client = new Lingotek_API();
  • lingotek-translation/trunk/include/model.php

    r1818525 r1907909  
    231231                PLL()->model->post->set_language($new_post_id, $cp_lang);
    232232                wp_set_object_terms($new_post_id, $document->term_id, 'post_translations');
    233                 $GLOBALS['polylang']->sync->copy_taxonomies($document->source, $new_post_id, $cp_lang->slug);
    234                 $GLOBALS['polylang']->sync->copy_post_metas($document->source, $new_post_id, $cp_lang->slug);
     233                $GLOBALS['polylang']->sync->taxonomies->copy($document->source, $new_post_id, $cp_lang->slug);
     234                $GLOBALS['polylang']->sync->post_metas->copy($document->source, $new_post_id, $cp_lang->slug);
    235235                Lingotek_Group_Post::copy_or_ignore_metas($post->ID, $new_post_id);
    236236                $document->desc_array[$target] = $new_post_id;
     
    246246    public function copy_term($term, $target, $taxonomy) {
    247247        self::$copying_term = true;
    248         $document = $this->get_group('term', $term->term_id);
     248        $document = $this->get_group('term', $term->term_id);   
    249249        $cp_lang = $this->pllm->get_language($target);
    250250        $cp_term = (array) $term;
     
    318318            'external_url' => $external_url,
    319319        );
    320 
     320        foreach (array('author_email', 'author_name','division','unit','campaign_id','channel','contact_email','contact_name','description','domain','style_id','purchase_order','reference_url','region','require_review') as $key) {
     321            if (isset($profile[$key]) )
     322                $params[$key] = $profile[$key];
     323        }
    321324        $filter_ids = array();
    322325        if (self::get_profile_option('primary_filter_id', $post->post_type, $language, false, $post_id)) {
     
    407410                // If a translation profile has targets set to copy then copy them
    408411                $targets_to_copy = $this->targets_to_be_copied($profile);
    409                 if (!empty($targets_to_copy)) {
     412                if (!empty($targets_to_copy) && $upload == 'automatic') {
    410413                    foreach ($targets_to_copy as $target) {
    411414                        $this->copy_term($term, $target, $taxonomy);
  • lingotek-translation/trunk/lingotek.php

    r1827884 r1907909  
    33    Plugin name: Lingotek Translation
    44    Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
    5     Version: 1.3.7
     5    Version: 1.3.8
    66    Author: Lingotek and Frédéric Demarle
    77    Author uri: http://lingotek.com
     
    1717}
    1818
    19 define( 'LINGOTEK_VERSION', '1.3.7' ); // plugin version (should match above meta).
     19define( 'LINGOTEK_VERSION', '1.3.8' ); // plugin version (should match above meta).
    2020define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
    2121define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
  • lingotek-translation/trunk/readme.txt

    r1827884 r1907909  
    55Requires at least: 3.8
    66Tested up to: 4.9
    7 Stable tag: 1.3.7
     7Stable tag: 1.3.8
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1201203. Use translation profiles. One of the most time-consuming activities of any multilingual web-site project is managing the ongoing flow of changes and additions to site content and configurations. Translation profiles were created to allow you to create and save and re-use your translation settings.
    1211214. Content type profiles. Manually choosing which content to upload and download is rarely what a content administrator wants to do, and automating the upload of every change is not workable because there are various types of content. Each type of translatable content can be assigned to a customizable profile. For example, by default, we like to have Posts use an Automatic profile so that content will automatically be uploaded for translation and the resulting translations automatically be downloaded back into WordPress.
     1225. The Lingotek Translation plugin provides the ability to Copy, Translate, and Ignore each specific custom field. Our plugin supports Wordpress custom fields and advanced custom fields.
    122123
    123124== Changelog ==
     125
     126= 1.3.8 (2018-7-11) =
     127
     128* Added document metadata fields to translation profiles
     129* Added manual copying of categories and tags
     130* Fixed other minor bugs
    124131
    125132= 1.3.7 (2018-2-23) =
Note: See TracChangeset for help on using the changeset viewer.