Changeset 753


Ignore:
Timestamp:
12/08/12 03:29:13 (2 years ago)
Author:
ofer
Message:

Removed distinction between editable and viewable languages, now only active languages exist

Location:
trunk/WordPress/plugin/transposh
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/css/admin.css

    r752 r753  
    11/*  
    2     Document   : admin 
    3     Created on : 24/11/2012, 04:12:31 
    4     Author     : root 
    5     Description: 
    6         Purpose of the stylesheet follows. 
     2    Document   : admin.css 
     3    Created on : 24/11/2012 
     4    Description: Style sheet for admin pages         
    75*/ 
    86 
    97#icon-transposh-logo { 
    10     background: url(../img/tplogo32.png) no-repeat; 
     8    background: url('../img/tplogo32.png') no-repeat; 
    119    /*float: left;*/ 
    1210} 
     
    3836    background: #FFE45C; 
    3937} 
    40 .active { 
     38.lng_active { 
    4139    background: #45FF51; 
    42 } 
    43 .translateable { 
    44     background: #FFFF51; 
    4540} 
    4641.hidden { 
  • trunk/WordPress/plugin/transposh/js/admin/languages.js

    r752 r753  
    1818(function ($) { // closure 
    1919    $(function() { 
    20         // clicking anonymous will make translatables active 
    21         $("#tr_anon").click(function() { 
    22             if ($("#tr_anon").attr("checked")) { 
    23                 $(".translateable").addClass("active").removeClass("translateable"); 
    24                 $("#sortable .active").each(function () { 
    25                     $("input",this).val($(this).attr("id")+",v,t"); 
    26                 }) 
    27             } 
    28             $("#yellowcolor").toggleClass("hidden"); 
    29         }); 
    30  
    3120        // makes the languages sortable, with placeholder, also prevent unneeded change after sort 
    3221        $("#sortable").sortable({ 
     
    5039        // enable all languages 
    5140        $("#selectall").click(function(){ 
    52             $("#sortable .languages").addClass("active").removeClass("translateable"); 
    53             $("#sortable .active").each(function () { 
    54                 $("input",this).val($(this).attr("id")+",v,t"); 
     41            $("#sortable .languages").addClass("lng_active"); 
     42            $("#sortable .lng_active").each(function () { 
     43                $("input",this).val($(this).attr("id")+",v"); 
    5544            }) 
    5645            return false; 
     
    6049        clickfunction = function () { 
    6150            if ($(this).attr("id") == $("#default_list li").attr("id")) return; 
    62             if ($("#tr_anon").attr("checked")) { 
    63                 $(this).toggleClass("active"); 
    64             } else { 
    65                 if ($(this).hasClass("active")) { 
    66                     $(this).removeClass("active"); 
    67                     $(this).addClass("translateable") 
    68                 } 
    69                 else { 
    70                     if ($(this).hasClass("translateable")) { 
    71                         $(this).removeClass("translateable"); 
    72                     } 
    73                     else { 
    74                         $(this).addClass("active") 
    75                     } 
    76                 } 
    77             } 
     51            $(this).toggleClass("lng_active"); 
    7852            // set new value 
    79             $("input",this).val($(this).attr("id")+($(this).hasClass("active") ? ",v":",")+($(this).hasClass("translateable") ? ",t":",")); 
     53            $("input",this).val($(this).attr("id")+($(this).hasClass("lng_active") ? ",v":",")); 
    8054        } 
    8155        $(".languages").dblclick(clickfunction).click(clickfunction); 
     
    8761            drop: function(ev, ui) { 
    8862                $("#default_list").empty(); 
    89                 $(ui.draggable.clone().removeAttr("style").removeClass("active").removeClass("translateable")).appendTo("#default_list").show("slow"); 
     63                $(ui.draggable.clone().removeAttr("style").removeClass("lng_active")).appendTo("#default_list").show("slow"); 
    9064                $("#default_list .logoicon").remove(); 
    91                 $("#sortable").find("#"+ui.draggable.attr("id")).addClass("active"); 
     65                $("#sortable").find("#"+ui.draggable.attr("id")).addClass("lng_active"); 
    9266            } 
    9367        }); 
  • trunk/WordPress/plugin/transposh/transposh.php

    r752 r753  
    148148                tp_logger(preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), 4); // includes transposh dir and php 
    149149             
    150         // TODO: get_class_methods to replace said mess, other way? 
     150// TODO: get_class_methods to replace said mess, other way? 
    151151        add_filter('plugin_action_links_' . preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), array(&$this, 'plugin_action_links')); 
    152152        add_filter('query_vars', array(&$this, 'parameter_queryvars')); 
     
    222222        // CHECK TODO!!!!!!!!!!!! 
    223223        $this->tgl = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 
    224         if (!$this->options->is_viewable_language($this->tgl) && !$this->options->is_editable_language($this->tgl)) { 
     224        if (!$this->options->is_active_language($this->tgl)) { 
    225225            $this->tgl = ''; 
    226226        } 
     
    503503        // TODO TOCHECK!!!!!!!!!!!!!!!!!!!!!!!!!!1 
    504504        $this->target_language = $this->tgl; 
    505         // avoid viewing of editable languages which are not viewable by non translators 
    506         if (!$this->options->is_viewable_language($this->target_language) && 
    507                 $this->options->is_editable_language($this->target_language) && 
    508                 !$this->is_translator()) { 
    509             $this->target_language = ''; 
    510         } 
    511505        if (!$this->target_language) 
    512506                $this->target_language = $this->options->default_language; 
     
    813807                return false; 
    814808 
    815         return $this->options->is_editable_language($this->target_language); 
     809        return $this->options->is_active_language($this->target_language); 
    816810    } 
    817811 
     
    831825                return false; 
    832826 
    833         return $this->options->is_editable_language($this->target_language); 
     827        return $this->options->is_active_language($this->target_language); 
    834828    } 
    835829 
     
    11661160    function transposh_locale_filter($locale) { 
    11671161        $lang = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 
    1168         if (!$this->options->is_viewable_language($lang)) { 
     1162        if (!$this->options->is_active_language($lang)) { 
    11691163            $lang = ''; 
    11701164        } 
     
    12321226    } 
    12331227 
    1234     // Proxyed google translate suggestions 
     1228    // Proxied google translate suggestions 
    12351229    function on_ajax_nopriv_tp_gsp() { 
    12361230        $i = 0; 
     
    12401234        $tl = $_GET['tl']; 
    12411235        // we want to avoid unneeded work or dos attacks on languages we don't support 
    1242         if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_editable_language($tl)) 
     1236        if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) 
    12431237                return; 
    12441238        $sl = 'auto'; 
     
    12811275    } 
    12821276 
    1283     // Proxyed translation for google translate 
     1277    // Proxied translation for google translate 
    12841278    function on_ajax_nopriv_tp_gp() { 
    12851279        // we need curl for this proxy 
     
    12891283        $tl = $_GET['tl']; 
    12901284        // we want to avoid unneeded work or dos attacks on languages we don't support 
    1291         if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_editable_language($tl)) 
     1285        if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) 
    12921286                return; 
    12931287        // source language 
  • trunk/WordPress/plugin/transposh/wp/transposh_admin.php

    r752 r753  
    8787            case 'tp_langs': 
    8888                $viewable_langs = array(); 
    89                 $editable_langs = array(); 
    9089 
    9190                tp_logger($_POST['anonymous']); 
    9291                // first set the default language 
    93                 list ($langcode, $viewable, $translateable) = explode(",", $_POST['languages'][0]); 
     92                list ($langcode, ) = explode(",", $_POST['languages'][0]); 
    9493                $this->transposh->options->default_language = $langcode; 
    9594                unset($_POST['languages'][0]); 
     
    9796                // update the list of supported/editable/sortable languages 
    9897                tp_logger($_POST['languages']); 
    99                 foreach ($_POST['languages'] as $code => $lang) { 
    100                     list ($langcode, $viewable, $translateable) = explode(",", $lang); 
     98                foreach ($_POST['languages'] as $lang) { 
     99                    list ($langcode, $viewable) = explode(",", $lang); 
    101100                    $sorted_langs[$langcode] = $langcode; 
    102101                    if ($viewable) { 
    103102                        $viewable_langs[$langcode] = $langcode; 
    104                         // force that every viewable lang is editable 
    105                         $editable_langs[$langcode] = $langcode; 
    106                     } 
    107  
    108                     if ($translateable) { 
    109                         $editable_langs[$langcode] = $langcode; 
    110103                    } 
    111104                } 
    112105 
    113106                $this->transposh->options->viewable_languages = implode(',', $viewable_langs); 
    114                 $this->transposh->options->editable_languages = implode(',', $editable_langs); 
    115107                $this->transposh->options->sorted_languages = implode(',', $sorted_langs); 
    116108                break; 
     
    189181                '<p>' . __('For further help and assistance, please look at the following resources:', TRANSPOSH_TEXT_DOMAIN) . '</p>' . 
    190182                '<a href="http://transposh.org/">' . __('Plugin homepage', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' . 
    191                 '<a href="http://transposh.org/faq/">' . __('Frequently asked questions', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'. 
    192                 '<a href="http://trac.transposh.org/">' . __('Development website', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' ; 
     183                '<a href="http://transposh.org/faq/">' . __('Frequently asked questions', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' . 
     184                '<a href="http://trac.transposh.org/">' . __('Development website', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'; 
    193185        return $text; 
    194186    } 
     
    215207                add_action('admin_print_scripts-' . $submenu_page, array(&$this, 'admin_print_scripts')); 
    216208            } 
    217  
    218209        } 
    219210        // DOC 
     
    275266            $this->localeright = 'left'; 
    276267        } 
    277          
     268 
    278269        // the followings are integrations with the wordpress admin interface 
    279270        $screen = get_current_screen(); 
     
    359350 
    360351        echo '<div class="clear"></div>'; 
    361  
    362352    } 
    363353 
     
    395385            tp_logger($langcode, 5); 
    396386            list ($langname, $langorigname, $flag) = explode(",", $langrecord); 
    397             echo '<li id="' . $langcode . '" class="languages ' . ($this->transposh->options->is_viewable_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "active" : "") 
    398             . (!$this->transposh->options->is_viewable_language($langcode) && $this->transposh->options->is_editable_language($langcode) ? "translateable" : "") . '"><div style="float:' . $this->localeleft . '">' 
     387            echo '<li id="' . $langcode . '" class="languages ' . ($this->transposh->options->is_active_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "lng_active" : "") 
     388            . '"><div style="float:' . $this->localeleft . '">' 
    399389            . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, false /* $langorigname,$this->transposh->options->get_widget_css_flags() */) 
    400390            // DOC THIS BUGBUG fix! 
    401             . '<input type="hidden" name="languages[]" value="' . $langcode . ($this->transposh->options->is_viewable_language($langcode) ? ",v" : ",") . ($this->transposh->options->is_editable_language($langcode) ? ",t" : ",") . '" />' 
     391            . '<input type="hidden" name="languages[]" value="' . $langcode . ($this->transposh->options->is_active_language($langcode) ? ",v" : ",") . '" />' 
    402392            . '&nbsp;<span class="langname">' . $langorigname . '</span><span class="langname hidden">' . $langname . '</span></div>'; 
    403393            if (in_array($langcode, transposh_consts::$google_languages)) 
     
    420410        echo '<li><a href="#" id="sortname">' . __('Sort by language name', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 
    421411        echo '<li><a href="#" id="sortiso">' . __('Sort by lSO code', TRANSPOSH_TEXT_DOMAIN) . '</a></li></ul>'; 
    422         echo __('Legend:', TRANSPOSH_TEXT_DOMAIN) . ' ' . __('Green - active', TRANSPOSH_TEXT_DOMAIN) . ', <span id="yellowcolor"' . ($this->transposh->options->allow_anonymous_translation ? ' class ="hidden"' : '') . '>' . __('Yellow - translateable (only translators will see this language)', TRANSPOSH_TEXT_DOMAIN) . ', </span>' . __('blank - inactive', TRANSPOSH_TEXT_DOMAIN); 
    423412        echo '</div>'; 
    424413    } 
  • trunk/WordPress/plugin/transposh/wp/transposh_db.php

    r745 r753  
    198198        } 
    199199        // make sure $lang is reasonable, unless someone is messing with us, it will be ok 
    200         if (!($this->transposh->options->is_editable_language($lang))) return; 
     200        if (!($this->transposh->options->is_active_language($lang))) return; 
    201201 
    202202        // If we have nothing, we will do nothing 
     
    239239        } else { 
    240240            // make sure $lang is reasonable, unless someone is messing with us, it will be ok 
    241             if (!($this->transposh->options->is_editable_language($lang))) 
    242                     return; 
     241            if (!($this->transposh->options->is_active_language($lang))) return; 
    243242            $query = "SELECT * FROM {$this->translation_table} WHERE original = '$original' and lang = '$lang' "; 
    244243            $row = $GLOBALS['wpdb']->get_row($query); 
     
    324323        for ($i = 0; $i < $items; $i++) { 
    325324            if (isset($_POST["ln$i"])) { 
    326                 if (!$this->transposh->options->is_editable_language($_POST["ln$i"])) { 
     325                if (!$this->transposh->options->is_active_language($_POST["ln$i"])) { 
    327326                    $all_editable = false; 
    328327                    break; 
     
    478477        // Check permissions, first the lanugage must be on the edit list. Then either the user 
    479478        // is a translator or automatic translation if it is enabled. 
    480         if (!($this->transposh->options->is_editable_language($lang) && $this->transposh->is_translator())) { 
     479        if (!($this->transposh->options->is_active_language($lang) && $this->transposh->is_translator())) { 
    481480            tp_logger("Unauthorized history request " . $_SERVER['REMOTE_ADDR'], 1); 
    482481            header('HTTP/1.0 401 Unauthorized history'); 
  • trunk/WordPress/plugin/transposh/wp/transposh_options.php

    r752 r753  
    7373 * @property string           $viewable_languages    Option defining the list of currently viewable languages 
    7474 * @property transposh_option $viewable_languages_o  
    75  * @property string           $editable_languages    Option defining the list of currently editable languages 
    76  * @property transposh_option $editable_languages_o  
    7775 * @property string           $sorted_languages      Option defining the ordered list of languages @since 0.3.9 
    7876 * @property transposh_option $sorted_languages_o  
     
    212210        $this->register_option('default_language', TP_OPT_STRING); // default? 
    213211        $this->register_option('viewable_languages', TP_OPT_STRING); 
    214         $this->register_option('editable_languages', TP_OPT_STRING); 
    215212        $this->register_option('sorted_languages', TP_OPT_STRING); 
    216213 
     
    318315 
    319316    /** 
    320      * Determine if the given language in on the list of editable languages 
    321      * @return boolean Is this language editable? 
    322      */ 
    323     function is_editable_language($language) { 
    324         if ($this->is_default_language($language)) return true; 
    325         return (strpos($this->editable_languages . ',', $language . ',') !== false); 
    326     } 
    327  
    328     /** 
    329      * Determine if the given language in on the list of viewable languages 
     317     * Determine if the given language in on the list of active languages 
    330318     * @return boolean Is this language viewable? 
    331319     */ 
    332     function is_viewable_language($language) { 
     320    function is_active_language($language) { 
    333321        if ($this->is_default_language($language)) return true; 
    334322        return (strpos($this->viewable_languages . ',', $language . ',') !== false); 
  • trunk/WordPress/plugin/transposh/wp/transposh_postpublish.php

    r752 r753  
    146146 
    147147        foreach ($phrases as $key) { 
    148             foreach (explode(',', $this->transposh->options->editable_languages) as $lang) { 
     148            foreach (explode(',', $this->transposh->options->viewable_languages) as $lang) { 
    149149                // if this isn't the default language or we specifically allow default language translation, we will seek this out... 
    150150                // as we don't normally want to auto-translate the default language -FIX THIS to include only correct stuff, how? 
  • trunk/WordPress/plugin/transposh/wp/transposh_widget.php

    r745 r753  
    214214            list ($langname, $language, $flag) = explode(',', $langrecord); 
    215215 
    216             // Only send languages which are viewable or (editable and the user is a translator) 
    217             if ($this->transposh->options->is_viewable_language($code) || 
    218                     ($this->transposh->options->is_editable_language($code) && $this->transposh->is_translator()) || 
     216            // Only send languages which are active 
     217            if ($this->transposh->options->is_active_language($code) || 
    219218                    ($this->transposh->options->is_default_language($code))) { 
    220219                // now we alway do this... maybe cache this to APC/Memcache 
Note: See TracChangeset for help on using the changeset viewer.