Changeset 742


Ignore:
Timestamp:
11/14/12 01:18:07 (2 years ago)
Author:
ofer
Message:

Grand revision of the way options are defined, should enable adding of options quicker and with less effort (hopefully), many mistakes were found in the process and corrected,

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

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/transposh.php

    r737 r742  
    140140        add_filter('query_vars', array(&$this, 'parameter_queryvars')); 
    141141        add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); 
    142         if ($this->options->get_enable_url_translate()) { 
     142        if ($this->options->enable_url_translate) { 
    143143            add_filter('request', array(&$this, 'request_filter')); 
    144144        } 
     
    192192        //TODO comment_row_actions (filter) 
    193193        // Intergrating with the gettext interface 
    194         if ($this->options->get_transposh_gettext_integration()) { 
     194        if ($this->options->transposh_gettext_integration) { 
    195195            add_filter('gettext', array(&$this, 'transposh_gettext_filter'), 10, 3); 
    196196            add_filter('gettext_with_context', array(&$this, 'transposh_gettext_filter'), 10, 3); 
     
    271271        $this->clean_url = transposh_utils::cleanup_url($_SERVER['REQUEST_URI'], $this->home_url, true); 
    272272        // we need this if we are using url translations 
    273         if ($this->options->get_enable_url_translate()) { 
     273        if ($this->options->enable_url_translate) { 
    274274            $this->clean_url = transposh_utils::get_original_url($this->clean_url, '', $this->target_language, array($this->database, 'fetch_original')); 
    275275        } 
     
    322322        } 
    323323        // Don't translate the default language unless specifically allowed to... 
    324         elseif ($this->options->is_default_language($this->target_language) && !$this->options->get_enable_default_translate()) { 
     324        elseif ($this->options->is_default_language($this->target_language) && !$this->options->enable_default_translate) { 
    325325            logger("Skipping translation for default language {$this->target_language}", 3); 
    326326        } else { 
     
    349349            $parse->might_json = $this->attempt_json; 
    350350            $parse->is_auto_translate = $this->is_auto_translate_permitted(); 
    351             $parse->allow_ad = $this->options->get_widget_remove_logo(); 
     351            $parse->allow_ad = $this->options->widget_remove_logo; 
    352352            // TODO - check this! 
    353353            if (stripos($_SERVER['REQUEST_URI'], '/feed/') !== FALSE) { 
     
    379379        // the wp_rewrite is not available earlier so we can only set the enable_permalinks here 
    380380        if (is_object($GLOBALS['wp_rewrite'])) { 
    381             if ($GLOBALS['wp_rewrite']->using_permalinks() && $this->options->get_enable_permalinks()) { 
     381            if ($GLOBALS['wp_rewrite']->using_permalinks() && $this->options->enable_permalinks) { 
    382382                logger("enabling permalinks"); 
    383383                $this->enable_permalinks_rewrite = TRUE; 
     
    415415        logger("Enter update_rewrite_rules"); 
    416416 
    417         if (!$this->options->get_enable_permalinks()) { 
     417        if (!$this->options->enable_permalinks) { 
    418418            logger("Not touching rewrite rules - permalinks modification disabled by admin"); 
    419419            return $rules; 
     
    456456    } 
    457457 
     458    //function flush_transposh_rewrite_rules() { 
     459        //add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); 
     460//        $GLOBALS['wp_rewrite']->flush_rules();         
     461    //} 
     462     
     463     
    458464    /** 
    459465     * Let WordPress know which parameters are of interest to us. 
     
    483489        /*        $this->target_language = (isset($wp->query_vars[LANG_PARAM])) ? $wp->query_vars[LANG_PARAM] : ''; 
    484490          if (!$this->target_language) 
    485           $this->target_language = $this->options->get_default_language(); 
     491          $this->target_language = $this->options->default_language; 
    486492          logger("requested language: {$this->target_language}"); */ 
    487493        // TODO TOCHECK!!!!!!!!!!!!!!!!!!!!!!!!!!1 
     
    494500        } 
    495501        if (!$this->target_language) 
    496                 $this->target_language = $this->options->get_default_language(); 
     502                $this->target_language = $this->options->default_language; 
    497503        logger("requested language: {$this->target_language}"); 
    498504 
     
    507513        //  and this is not a special page or one that is refered by our site 
    508514        // bots can skip this altogether 
    509         if (($this->options->get_enable_detect_language() || $this->options->get_widget_allow_set_default_language()) && 
     515        if (($this->options->enable_detect_redirect || $this->options->widget_allow_set_deflang) && 
    510516                !($this->is_special_page($_SERVER['REQUEST_URI']) || (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $this->home_url) !== false)) && 
    511517                !(transposh_utils::is_bot())) { 
     
    518524                $_SESSION['TR_REDIRECTED'] = true; 
    519525                // redirect according to stored lng cookie, and than according to detection 
    520                 if (isset($_COOKIE['TR_LNG']) && $this->options->get_widget_allow_set_default_language()) { 
     526                if (isset($_COOKIE['TR_LNG']) && $this->options->widget_allow_set_deflang) { 
    521527                    if ($_COOKIE['TR_LNG'] != $this->target_language) { 
    522528                        $url = transposh_utils::rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, $_COOKIE['TR_LNG'], $this->edit_mode); 
     
    529535                    } 
    530536                } else { 
    531                     $bestlang = transposh_utils::prefered_language(explode(',', $this->options->get_viewable_langs()), $this->options->get_default_language()); 
     537                    $bestlang = transposh_utils::prefered_language(explode(',', $this->options->viewable_languages), $this->options->default_language); 
    532538                    // we won't redirect if we should not, or this is a presumable bot 
    533                     if ($bestlang && $bestlang != $this->target_language && $this->options->get_enable_detect_language()) { 
     539                    if ($bestlang && $bestlang != $this->target_language && $this->options->enable_detect_redirect) { 
    534540                        $url = transposh_utils::rewrite_url_lang_param($_SERVER['REQUEST_URI'], $this->home_url, $this->enable_permalinks_rewrite, $bestlang, $this->edit_mode); 
    535541                        if ($this->options->is_default_language($bestlang)) 
     
    548554        // TODO - it has a bug of returning to original language following search, which can be resolved by removing search from widget urls, but maybe later... 
    549555        if (isset($wp->query_vars['s'])) { 
    550             if ($this->options->get_enable_search_translate()) { 
     556            if ($this->options->enable_search_translate) { 
    551557                add_action('pre_get_posts', array(&$this, 'pre_post_search')); 
    552558                add_action('posts_where_request', array(&$this, 'posts_where_request')); 
     
    581587    function is_translator() { 
    582588        //if anonymous translation is allowed - let anyone enjoy it 
    583         if ($this->options->get_anonymous_translation()) { 
     589        if ($this->options->allow_anonymous_translation) { 
    584590            return TRUE; 
    585591        } 
     
    597603 
    598604        $this->database->setup_db(); 
    599         // is it needed? the filter is already there? // TODO 
    600         add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); 
     605        // this handles the permalink rewrite 
    601606        $GLOBALS['wp_rewrite']->flush_rules(); 
    602607 
     
    617622        logger("plugin_deactivate enter: " . dirname(__FILE__)); 
    618623 
    619         // is it needed? the filter is already there? // TODO 
    620         add_filter('rewrite_rules_array', array(&$this, 'update_rewrite_rules')); 
     624        // this handles the permalink rewrite 
    621625        $GLOBALS['wp_rewrite']->flush_rules(); 
    622626 
     
    714718    function add_transposh_js() { 
    715719        //not in any translation mode - no need for any js. 
    716         if (!($this->edit_mode || $this->is_auto_translate_permitted() || is_admin() || $this->options->get_widget_allow_set_default_language())) 
     720        if (!($this->edit_mode || $this->is_auto_translate_permitted() || is_admin() || $this->options->widget_allow_set_deflang)) 
    717721            // TODO: need to include if allowing of setting default language - but smaller! 
    718722                return; // TODO, check just for settings page admin and pages with our translate 
    719         wp_register_script('transposh', $this->transposh_plugin_url . '/' . TRANSPOSH_DIR_JS . '/transposh.js', array('jquery'), TRANSPOSH_PLUGIN_VER); 
     723        wp_register_script('transposh', $this->transposh_plugin_url . '/' . TRANSPOSH_DIR_JS . '/transposh.js', array('jquery'), TRANSPOSH_PLUGIN_VER, $this->options->enable_footer_scripts); 
    720724        // true -> 1, false -> nothing 
    721725        $script_params = array( 
     
    723727            'plugin_url' => $this->transposh_plugin_url, 
    724728            'lang' => $this->target_language, 
    725             'olang' => $this->options->get_default_language(), 
     729            'olang' => $this->options->default_language, 
    726730            // those two options show if the script can support said engines 
    727731            'prefix' => SPAN_PREFIX, 
    728             'preferred' => $this->options->get_preferred_translator() 
     732            'preferred' => $this->options->preferred_translator, 
    729733        ); 
    730734 
     
    732736        if (!$this->target_language || in_array($this->target_language, transposh_consts::$bing_languages)) { 
    733737            $script_params['msn'] = 1; 
    734             if ($this->options->get_msn_key()) { 
    735                 $script_params['msn_key'] = $this->options->get_msn_key(); 
     738            if ($this->options->msn_key) { 
     739                $script_params['msn_key'] = $this->options->msn_key; 
    736740            } 
    737741        } 
    738742        // FIX BACKEND 
    739743        if (!$this->target_language || in_array($this->target_language, transposh_consts::$google_languages)) { 
    740             if ($this->options->get_google_key()) { 
    741                 $script_params['google_key'] = $this->options->get_google_key(); 
    742             } 
    743             if ($this->options->get_google_key() || function_exists('curl_init')) 
     744            if ($this->options->google_key) { 
     745                $script_params['google_key'] = $this->options->google_key; 
     746            } 
     747            if ($this->options->google_key || function_exists('curl_init')) 
    744748                    $script_params['google'] = 1; 
    745749        } 
    746750        if (in_array($this->target_language, transposh_consts::$apertium_languages)) 
    747751                $script_params['apertium'] = 1; 
    748         if ($this->options->get_oht_id() && $this->options->get_oht_key() && in_array($this->target_language, transposh_consts::$oht_languages) && current_user_can('manage_options')) 
     752        if ($this->options->oht_id && $this->options->oht_key && in_array($this->target_language, transposh_consts::$oht_languages) && current_user_can('manage_options')) 
    749753                $script_params['oht'] = 1; 
    750         if ($this->options->get_widget_progressbar()) 
     754        if ($this->options->widget_progressbar) 
    751755                $script_params['progress'] = 1; 
    752         if (!$this->options->get_enable_auto_translate()) 
     756        if (!$this->options->enable_autotranslate) 
    753757                $script_params['noauto'] = 1; 
    754758 
     
    761765        } 
    762766        // set theme when it is needed 
    763         if ($this->options->get_widget_progressbar() || $this->edit_mode) { 
    764             $script_params['theme'] = $this->options->get_widget_theme(); 
     767        if ($this->options->widget_progressbar || $this->edit_mode) { 
     768            $script_params['theme'] = $this->options->widget_theme; 
    765769        } 
    766770 
     
    768772        wp_localize_script('transposh', 't_jp', $script_params); 
    769773        // only enqueue on real pages, other admin scripts that need this will register a dependency 
    770         if (($this->edit_mode || $this->is_auto_translate_permitted() || $this->options->get_widget_allow_set_default_language()) && !is_admin()) { 
     774        if (($this->edit_mode || $this->is_auto_translate_permitted() || $this->options->widget_allow_set_deflang) && !is_admin()) { 
    771775            wp_enqueue_script('transposh'); 
    772776        } 
     
    798802        if (!$this->is_translator()) return false; 
    799803        // and only on the non-default lang (unless strictly specified) 
    800         if (!$this->options->get_enable_default_translate() && $this->options->is_default_language($this->target_language)) 
     804        if (!$this->options->enable_default_translate && $this->options->is_default_language($this->target_language)) 
    801805                return false; 
    802806 
     
    814818        logger("checking auto translatability", 4); 
    815819 
    816         if (!$this->options->get_enable_auto_translate()) return false; 
     820        if (!$this->options->enable_autotranslate) return false; 
    817821        // auto translate is not enabled for default target language when enable default is disabled 
    818         if (!$this->options->get_enable_default_translate() && $this->options->is_default_language($this->target_language)) 
     822        if (!$this->options->enable_default_translate && $this->options->is_default_language($this->target_language)) 
    819823                return false; 
    820824 
     
    891895 
    892896        // we don't really know, but we sometime rewrite urls when we are in the default language (canonicals?), so just clean them up 
    893         if ($this->target_language == $this->options->get_default_language())  
     897 //       if ($this->target_language == $this->options->default_language)  
     898        if ($this->options->is_default_language($this->target_language))  
    894899        { 
    895900            $href = transposh_utils::cleanup_url($href, $this->home_url); 
     
    899904        // some hackery needed for url translations 
    900905        // first cut home 
    901         if ($this->options->get_enable_url_translate()) { 
     906        if ($this->options->enable_url_translate) { 
    902907            $href = transposh_utils::translate_url($href, $this->home_url, $this->target_language, array(&$this->database, 'fetch_translation')); 
    903908        } 
     
    10351040            $text = "<span lang =\"$comment_lang\">" . $text . "</span>"; 
    10361041            if (strpos($text, '<a href="' . $this->home_url) !== FALSE) { 
    1037                 $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->get_default_language() . '" href="' . $this->home_url, $text); 
     1042                $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->default_language . '" href="' . $this->home_url, $text); 
    10381043            } 
    10391044        } 
     
    10541059            $text = "<span lang =\"$lang\">" . $text . "</span>"; 
    10551060            if (strpos($text, '<a href="' . $this->home_url) !== FALSE) { 
    1056                 $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->get_default_language() . '" href="' . $this->home_url, $text); 
     1061                $text = str_replace('<a href="' . $this->home_url, '<a lang="' . $this->options->default_language . '" href="' . $this->home_url, $text); 
    10571062            } 
    10581063        } 
     
    11141119     */ 
    11151120    function transposh_gettext_filter($translation, $orig, $domain) { 
    1116         if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->get_enable_default_translate())) { 
     1121        if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->enable_default_translate)) { 
    11171122            return $translation; 
    11181123        } 
     
    11361141     */ 
    11371142    function transposh_ngettext_filter($translation, $single, $plural, $domain) { 
    1138         if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->get_enable_default_translate())) 
     1143        if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->enable_default_translate)) 
    11391144                return $translation; 
    11401145        logger("($translation, $single, $plural, $domain)"); 
     
    11591164        } 
    11601165        if (!$lang) { 
    1161             if (!$this->options->get_transposh_default_locale_override()) { 
     1166            if (!$this->options->transposh_locale_override) { 
    11621167                return $locale; 
    11631168            } 
    1164             $lang = $this->options->get_default_language(); 
     1169            $lang = $this->options->default_language; 
    11651170        } 
    11661171        list ($l, $n, $f, $locale) = explode(',', transposh_consts::$languages[$lang]); 
     
    13791384        $oht = get_option(TRANSPOSH_OPTIONS_OHT, array()); 
    13801385        if (!isset($_GET['orglang'])) 
    1381                 $_GET['orglang'] = $this->options->get_default_language(); 
     1386                $_GET['orglang'] = $this->options->default_language; 
    13821387        $key = $_GET['token'] . '@' . $_GET['lang'] . '@' . $_GET['orglang']; 
    13831388        if (isset($oht[$key])) { 
     
    14181423        } 
    14191424        $ohtbody['pid'] = $projectid; 
    1420         $ohtbody['id'] = $this->options->get_oht_id(); 
    1421         $ohtbody['key'] = $this->options->get_oht_key(); 
     1425        $ohtbody['id'] = $this->options->oht_id; 
     1426        $ohtbody['key'] = $this->options->oht_key; 
    14221427        $ohtbody['callback'] = admin_url('admin-ajax.php'); 
    14231428        $ohtbody['homeurl'] = $this->home_url; 
  • trunk/WordPress/plugin/transposh/wp/transposh_3rdparty.php

    r653 r742  
    4343 
    4444        // google analyticator 
    45         if ($this->transposh->options->get_transposh_collect_stats()) { 
     45        if ($this->transposh->options->transposh_collect_stats) { 
    4646            add_action('google_analyticator_extra_js_after', array(&$this, 'add_analyticator_tracking')); 
    4747        } 
     
    102102        //TODO - check using get_clean_url 
    103103        $uri = transposh_utils::cleanup_url($uri, $this->transposh->home_url); 
    104         if ($this->transposh->options->get_enable_url_translate()) { 
     104        if ($this->transposh->options->enable_url_translate) { 
    105105            $uri = transposh_utils::get_original_url($uri, '', $lang, array($this->transposh->database, 'fetch_original')); 
    106106        } 
     
    186186        $sm_page->SetProprity(max($sm_page->GetPriority() - 0.2, 0)); 
    187187 
    188         $viewable_langs = explode(',', $this->transposh->options->get_viewable_langs()); 
     188        /* <xhtml:link  
     189          rel="alternate" 
     190          hreflang="de" 
     191          href="http://www.example.com/de" /> */ 
     192 
     193        $viewable_langs = explode(',', $this->transposh->options->viewable_languages()); 
    189194        $orig_url = $sm_page->GetUrl(); 
    190195        foreach ($viewable_langs as $lang) { 
    191196            if (!$this->transposh->options->is_default_language($lang)) { 
    192197                $newloc = $orig_url; 
    193                 if ($this->transposh->options->get_enable_url_translate()) { 
     198                if ($this->transposh->options->enable_url_translate) { 
    194199                    $newloc = transposh_utils::translate_url($newloc, $this->transposh->home_url, $lang, array(&$this->transposh->database, 'fetch_translation')); 
    195200                } 
  • trunk/WordPress/plugin/transposh/wp/transposh_admin.php

    r741 r742  
    7575        if ($role_name != 'anonymous') { 
    7676            $role = $GLOBALS['wp_roles']->get_role($role_name); 
    77             if (isset($role) && $role->has_cap(TRANSLATOR)) 
    78                     return 'checked="checked"'; 
    79         } 
    80         else 
    81                 return ($this->transposh->options->get_anonymous_translation()) ? 'checked="checked"' : ''; 
     77            if (isset($role) && $role->has_cap(TRANSLATOR)) return true; 
     78        } 
     79        else return $this->transposh->options->allow_anonymous_translation; 
    8280    } 
    8381 
     
    9492                $editable_langs = array(); 
    9593 
    96                 //update roles and capabilities 
    97                 foreach ($GLOBALS['wp_roles']->get_names() as $role_name => $something) { 
    98                     $role = $GLOBALS['wp_roles']->get_role($role_name); 
    99                     if ($_POST[$role_name] == "1") $role->add_cap(TRANSLATOR); 
    100                     else $role->remove_cap(TRANSLATOR); 
    101                 } 
    102  
    103                 // anonymous needs to be handled differently as it does not have a role 
    104                 $this->transposh->options->set_anonymous_translation($_POST['anonymous']); 
    105  
     94                logger($$_POST['anonymous']); 
    10695                // first set the default language 
    10796                list ($langcode, $viewable, $translateable) = explode(",", $_POST['languages'][0]); 
    108                 $this->transposh->options->set_default_language($langcode); 
     97                $this->transposh->options->default_language = $langcode; 
    10998                unset($_POST['languages'][0]); 
    11099 
     
    125114                } 
    126115 
    127                 $this->transposh->options->set_viewable_langs(implode(',', $viewable_langs)); 
    128                 $this->transposh->options->set_editable_langs(implode(',', $editable_langs)); 
    129                 $this->transposh->options->set_sorted_langs(implode(',', $sorted_langs)); 
     116                $this->transposh->options->viewable_languages = implode(',', $viewable_langs); 
     117                $this->transposh->options->editable_languages = implode(',', $editable_langs); 
     118                $this->transposh->options->sorted_languages = implode(',', $sorted_langs); 
    130119                break; 
    131120            case "tp_settings": 
    132                 if ($this->transposh->options->get_enable_permalinks() != $_POST[ENABLE_PERMALINKS]) { 
    133                     $this->transposh->options->set_enable_permalinks($_POST[ENABLE_PERMALINKS]); 
    134                     // rewrite rules - refresh. - because we want them set or unset upon this change 
    135                     // TODO - need to check if its even needed 
    136                     add_filter('rewrite_rules_array', array(&$this->transposh, 'update_rewrite_rules')); 
     121                //update roles and capabilities 
     122                foreach ($GLOBALS['wp_roles']->get_names() as $role_name => $something) { 
     123                    $role = $GLOBALS['wp_roles']->get_role($role_name); 
     124                    if ($_POST[$role_name] == "1") $role->add_cap(TRANSLATOR); 
     125                    else $role->remove_cap(TRANSLATOR); 
     126                } 
     127 
     128                // anonymous needs to be handled differently as it does not have a role 
     129                $this->transposh->options->allow_anonymous_translation = $_POST['anonymous']; 
     130 
     131                $this->transposh->options->enable_default_translate = TP_FROM_POST; 
     132                $this->transposh->options->enable_search_translate = TP_FROM_POST; 
     133                $this->transposh->options->transposh_gettext_integration = TP_FROM_POST; 
     134                $this->transposh->options->transposh_locale_override = TP_FROM_POST; 
     135 
     136                // We will need to refresh rewrite rules for the case someone enabled in wordpress first after transposh 
     137                // install and then went on to transposh and enabled, and this keeps us safe ;) 
     138                if ($this->transposh->options->enable_permalinks != $_POST[$this->transposh->options->enable_permalinks->get_name()]) { 
     139                    $this->transposh->options->enable_permalinks = TP_FROM_POST; 
    137140                    $GLOBALS['wp_rewrite']->flush_rules(); 
    138141                } 
    139142 
    140                 $this->transposh->options->set_enable_footer_scripts($_POST[ENABLE_FOOTER_SCRIPTS]); 
    141                 $this->transposh->options->set_enable_detect_language($_POST[ENABLE_DETECT_LANG_AND_REDIRECT]); 
    142                 $this->transposh->options->set_transposh_collect_stats($_POST[TRANSPOSH_COLLECT_STATS]); 
    143                 $this->transposh->options->set_enable_default_translate($_POST[ENABLE_DEFAULT_TRANSLATE]); 
    144                 $this->transposh->options->set_enable_search_translate($_POST[ENABLE_SEARCH_TRANSLATE]); 
    145                 $this->transposh->options->set_transposh_gettext_integration($_POST[TRANSPOSH_GETTEXT_INTEGRATION]); 
    146                 $this->transposh->options->set_transposh_default_locale_override($_POST[TRANSPOSH_DEFAULT_LOCALE_OVERRIDE]); 
    147                 $this->transposh->options->set_transposh_key($_POST[TRANSPOSH_KEY]); 
    148                 // frontend stuff 
    149                 // handle change of schedule for backup to daily 
    150                 //if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] != $this->transposh->options->get_transposh_backup_schedule()) { 
     143                $this->transposh->options->enable_footer_scripts = TP_FROM_POST; 
     144                $this->transposh->options->enable_detect_redirect = TP_FROM_POST; 
     145                $this->transposh->options->transposh_collect_stats = TP_FROM_POST; 
     146 
     147                $this->transposh->options->transposh_backup_schedule = TP_FROM_POST; 
     148 
     149                // handle the backup change, create the hook 
    151150                wp_clear_scheduled_hook('transposh_backup_event'); 
    152                 if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] == 1 || $_POST[TRANSPOSH_BACKUP_SCHEDULE] == 2) 
     151                if ($this->transposh->options->transposh_backup_schedule) 
    153152                        wp_schedule_event(time(), 'daily', 'transposh_backup_event'); 
    154                 //} 
    155                 $this->transposh->options->set_transposh_backup_schedule($_POST[TRANSPOSH_BACKUP_SCHEDULE]); 
     153 
     154                $this->transposh->options->transposh_key = TP_FROM_POST; 
    156155                break; 
    157156            case "tp_engines": 
    158                 $this->transposh->options->set_enable_auto_translate($_POST[ENABLE_AUTO_TRANSLATE]); 
    159                 $this->transposh->options->set_enable_auto_post_translate($_POST[ENABLE_AUTO_POST_TRANSLATE]); 
    160                 $this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]); 
    161                 $this->transposh->options->set_google_key($_POST[GOOGLE_TRANSLATE_KEY]); 
    162                 $this->transposh->options->set_preferred_translator($_POST[PREFERRED_TRANSLATOR]); 
    163                 $this->transposh->options->set_oht_id($_POST[OHT_TRANSLATE_ID]); 
    164                 $this->transposh->options->set_oht_key($_POST[OHT_TRANSLATE_KEY]); 
     157                $this->transposh->options->enable_autotranslate = TP_FROM_POST; 
     158                $this->transposh->options->enable_autoposttranslate = TP_FROM_POST; 
     159                $this->transposh->options->msn_key = TP_FROM_POST; 
     160                $this->transposh->options->google_key = TP_FROM_POST; 
     161                $this->transposh->options->preferred_translator = TP_FROM_POST; 
     162                $this->transposh->options->oht_id = TP_FROM_POST; 
     163                $this->transposh->options->oht_key = TP_FROM_POST; 
    165164                break; 
    166165            case "tp_widget": 
    167                 $this->transposh->options->set_widget_progressbar($_POST[WIDGET_PROGRESSBAR]); 
    168                 $this->transposh->options->set_widget_allow_set_default_language($_POST[WIDGET_ALLOW_SET_DEFLANG]); 
    169                 $this->transposh->options->set_widget_remove_logo($_POST[WIDGET_REMOVE_LOGO_FOR_AD]); 
    170                 $this->transposh->options->set_widget_theme($_POST[WIDGET_THEME]); 
     166                $this->transposh->options->widget_progressbar = TP_FROM_POST; 
     167                $this->transposh->options->widget_allow_set_deflang = TP_FROM_POST; 
     168                $this->transposh->options->widget_remove_logo = TP_FROM_POST; 
     169                $this->transposh->options->widget_theme = TP_FROM_POST; 
    171170                break; 
    172171            case "tp_advanced": 
    173                 $this->transposh->options->set_enable_url_translate($_POST[ENABLE_URL_TRANSLATE]); 
     172                $this->transposh->options->enable_url_translate = TP_FROM_POST; 
    174173                break; 
    175174        } 
     
    336335 
    337336    // extend the admin menu 
    338    // function on_admin_menu() { 
    339         //add our own option page, you can also add it to different sections or use your own one 
     337    // function on_admin_menu() { 
     338    //add our own option page, you can also add it to different sections or use your own one 
    340339//        $this->pagehook = add_options_page(__('Transposh control center', TRANSPOSH_TEXT_DOMAIN), __('Transposh', TRANSPOSH_TEXT_DOMAIN), 'manage_options', TRANSPOSH_ADMIN_PAGE_NAME, array(&$this, 'on_show_page')); 
    341         // register callback gets call prior your own page gets rendered 
     340    // register callback gets call prior your own page gets rendered 
    342341//        add_action('load-' . $this->pagehook, array(&$this, 'on_load_page')); 
    343    // } 
     342    // } 
    344343 
    345344    function on_load_comments_page() { 
     
    508507 
    509508        // this is the default language location 
    510         list ($langname, $langorigname, $flag) = explode(",", transposh_consts::$languages[$this->transposh->options->get_default_language()]); 
     509        list ($langname, $langorigname, $flag) = explode(",", transposh_consts::$languages[$this->transposh->options->default_language]); 
    511510        echo '<div id="default_lang" style="overflow:auto;padding-bottom:10px;"><h3>'; 
    512511        echo __('Default Language (drag another language here to make it default)', TRANSPOSH_TEXT_DOMAIN); 
    513         echo '</h3><ul id="default_list"><li id="' . $this->transposh->options->get_default_language() . '" class="languages">' 
     512        echo '</h3><ul id="default_list"><li id="' . $this->transposh->options->default_language . '" class="languages">' 
    514513        . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname, false/* $this->transposh->options->get_widget_css_flags() */) 
    515         . '<input type="hidden" name="languages[]" value="' . $this->transposh->options->get_default_language() . '" />' 
     514        . '<input type="hidden" name="languages[]" value="' . $this->transposh->options->default_language . '" />' 
    516515        . '&nbsp;<span class="langname">' . $langorigname . '</span><span class="langname hidden">' . $langname . '</span></li>'; 
    517516        echo '</ul></div>'; 
     
    547546        echo '<li><a href="#" id="sortname">' . __('Sort by language name', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 
    548547        echo '<li><a href="#" id="sortiso">' . __('Sort by lSO code', TRANSPOSH_TEXT_DOMAIN) . '</a></li></ul>'; 
    549         echo __('Legend:', TRANSPOSH_TEXT_DOMAIN) . ' ' . __('Green - active', TRANSPOSH_TEXT_DOMAIN) . ', <span id="yellowcolor"' . ($this->transposh->options->get_anonymous_translation() ? ' class ="hidden"' : '') . '>' . __('Yellow - translateable (only translators will see this language)', TRANSPOSH_TEXT_DOMAIN) . ', </span>' . __('blank - inactive', TRANSPOSH_TEXT_DOMAIN); 
     548        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); 
    550549        echo '</div>'; 
    551550    } 
     
    563562        //display known roles and their permission to translate 
    564563        foreach ($GLOBALS['wp_roles']->get_names() as $role_name => $something) { 
    565             echo '<input type="checkbox" value="1" name="' . $role_name . '" ' . $this->can_translate($role_name) . 
     564            echo '<input type="checkbox" value="1" name="' . $role_name . '" ' . checked($this->can_translate($role_name), true, false) . 
    566565            '/> ' . _x(ucfirst($role_name), 'User role') . '&nbsp;&nbsp;&nbsp;'; 
    567566        } 
    568567        //Add our own custom role 
    569         echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" ' . $this->can_translate('anonymous') . '/> ' . __('Anonymous', TRANSPOSH_TEXT_DOMAIN); 
     568        echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" ' . checked($this->can_translate('anonymous'), true, false) . '/> ' . __('Anonymous', TRANSPOSH_TEXT_DOMAIN); 
    570569 
    571570        /* 
     
    573572         * Disabled by default. 
    574573         */ 
    575         $this->checkbox(ENABLE_DEFAULT_TRANSLATE, $this->transposh->options->get_enable_default_translate(), __('Enable default language translation', TRANSPOSH_TEXT_DOMAIN), __('Allow translation of default language - useful for sites with more than one major language', TRANSPOSH_TEXT_DOMAIN)); 
     574        $this->checkbox($this->transposh->options->enable_default_translate_o, __('Enable default language translation', TRANSPOSH_TEXT_DOMAIN), __('Allow translation of default language - useful for sites with more than one major language', TRANSPOSH_TEXT_DOMAIN)); 
    576575 
    577576        /** 
     
    580579         * @since 0.3.6 
    581580         */ 
    582         $this->checkbox(ENABLE_SEARCH_TRANSLATE, $this->transposh->options->get_enable_search_translate(), __('Enable search in translated languages', TRANSPOSH_TEXT_DOMAIN), __('Allow search of translated languages (and the original language)', TRANSPOSH_TEXT_DOMAIN)); 
     581        $this->checkbox($this->transposh->options->enable_search_translate_o, __('Enable search in translated languages', TRANSPOSH_TEXT_DOMAIN), __('Allow search of translated languages (and the original language)', TRANSPOSH_TEXT_DOMAIN)); 
    583582 
    584583 
     
    588587         * @since 0.6.4 
    589588         */ 
    590         $this->checkbox(TRANSPOSH_GETTEXT_INTEGRATION, $this->transposh->options->get_transposh_gettext_integration(), __('Enable gettext integration', TRANSPOSH_TEXT_DOMAIN), __('Enable integration of Transposh with existing gettext interface (.po/.mo files)', TRANSPOSH_TEXT_DOMAIN)); 
     589        $this->checkbox($this->transposh->options->transposh_gettext_integration_o, __('Enable gettext integration', TRANSPOSH_TEXT_DOMAIN), __('Enable integration of Transposh with existing gettext interface (.po/.mo files)', TRANSPOSH_TEXT_DOMAIN)); 
    591590 
    592591        /** 
     
    595594         * @since 0.7.5 
    596595         */ 
    597         $this->checkbox(TRANSPOSH_DEFAULT_LOCALE_OVERRIDE, $this->transposh->options->get_transposh_default_locale_override(), __('Enable override for default locale', TRANSPOSH_TEXT_DOMAIN), __('Enable overriding the default locale that is set in WP_LANG on default languages pages (such as untranslated pages and admin pages)', TRANSPOSH_TEXT_DOMAIN)); 
     596        $this->checkbox($this->transposh->options->transposh_locale_override_o, __('Enable override for default locale', TRANSPOSH_TEXT_DOMAIN), __('Enable overriding the default locale that is set in WP_LANG on default languages pages (such as untranslated pages and admin pages)', TRANSPOSH_TEXT_DOMAIN)); 
    598597        echo '</div>'; 
    599598        echo '<h2>' . __('General settings', TRANSPOSH_TEXT_DOMAIN) . '</h2>'; 
     
    603602         * When disabled only parameters will be used to identify the current language. 
    604603         */ 
    605         $this->checkbox(ENABLE_PERMALINKS, $this->transposh->options->get_enable_permalinks(), __('Rewrite URLs', TRANSPOSH_TEXT_DOMAIN), __('Rewrite URLs to be search engine friendly, ' . 
     604        $this->checkbox($this->transposh->options->enable_permalinks_o, __('Rewrite URLs', TRANSPOSH_TEXT_DOMAIN), __('Rewrite URLs to be search engine friendly, ' . 
    606605                        'e.g.  (http://transposh.org/<strong>en</strong>). ' . 
    607606                        'Requires that permalinks will be enabled.', TRANSPOSH_TEXT_DOMAIN)); 
     
    611610         * Works on wordpress 2.8 and up (but we no longer care...) 
    612611         */ 
    613         $this->checkbox(ENABLE_FOOTER_SCRIPTS, $this->transposh->options->get_enable_footer_scripts(), __('Add scripts to footer', TRANSPOSH_TEXT_DOMAIN), __('Push transposh scripts to footer of page instead of header, makes pages load faster. ' . 
     612        $this->checkbox($this->transposh->options->enable_footer_scripts_o, __('Add scripts to footer', TRANSPOSH_TEXT_DOMAIN), __('Push transposh scripts to footer of page instead of header, makes pages load faster. ' . 
    614613                        'Requires that your theme should have proper footer support.', TRANSPOSH_TEXT_DOMAIN)); 
    615614 
     
    617616         * Insert the option to enable/disable language auto-detection 
    618617         * @since 0.3.8 */ 
    619         $this->checkbox(ENABLE_DETECT_LANG_AND_REDIRECT, $this->transposh->options->get_enable_detect_language(), __('Auto detect language for users', TRANSPOSH_TEXT_DOMAIN), __('This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. ' . 
     618        $this->checkbox($this->transposh->options->enable_detect_redirect_o, __('Auto detect language for users', TRANSPOSH_TEXT_DOMAIN), __('This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. ' . 
    620619                        'This will redirect the first page accessed in the session to the same page with the detected language.', TRANSPOSH_TEXT_DOMAIN)); 
    621620 
     
    623622         * Insert the option to enable/disable statics collection 
    624623         * @since 0.7.6 */ 
    625         $this->checkbox(TRANSPOSH_COLLECT_STATS, $this->transposh->options->get_transposh_collect_stats(), __('Allow collecting usage statistics', TRANSPOSH_TEXT_DOMAIN), __('This option enables collection of statistics by transposh that will be used to improve the product.', TRANSPOSH_TEXT_DOMAIN)); 
     624        $this->checkbox($this->transposh->options->transposh_collect_stats_o, __('Allow collecting usage statistics', TRANSPOSH_TEXT_DOMAIN), __('This option enables collection of statistics by transposh that will be used to improve the product.', TRANSPOSH_TEXT_DOMAIN)); 
    626625 
    627626        /* WIP2 
     
    630629        echo '<h2>' . __('Backup service settings', TRANSPOSH_TEXT_DOMAIN) . '</h2>'; 
    631630        echo '<div class="col-wrap">'; 
    632         echo '<input type="radio" value="1" name="' . TRANSPOSH_BACKUP_SCHEDULE . '" ' . $this->checked($this->transposh->options->get_transposh_backup_schedule() == 1) . '/>' . __('Enable daily backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
    633         echo '<input type="radio" value="2" name="' . TRANSPOSH_BACKUP_SCHEDULE . '" ' . $this->checked($this->transposh->options->get_transposh_backup_schedule() == 2) . '/>' . __('Enable live backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
    634         echo '<input type="radio" value="0" name="' . TRANSPOSH_BACKUP_SCHEDULE . '" ' . $this->checked($this->transposh->options->get_transposh_backup_schedule() == 0) . '/>' . __('Disable backup (Can be run manually by clicking the button below)', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
    635         echo __('Service Key:', TRANSPOSH_TEXT_DOMAIN) . ' <input type="text" size="32" class="regular-text" value="' . $this->transposh->options->get_transposh_key() . '" id="' . TRANSPOSH_KEY . '" name="' . TRANSPOSH_KEY . '"/> <a target="_blank" href="http://transposh.org/faq/#restore">' . __('How to restore?', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'; 
     631        echo '<input type="radio" value="1" name="' . $this->transposh->options->transposh_backup_schedule_o->get_name() . '" ' . checked($this->transposh->options->transposh_backup_schedule, 1, false) . '/>' . __('Enable daily backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
     632        echo '<input type="radio" value="2" name="' . $this->transposh->options->transposh_backup_schedule_o->get_name() . '" ' . checked($this->transposh->options->transposh_backup_schedule, 2, false) . '/>' . __('Enable live backup', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
     633        echo '<input type="radio" value="0" name="' . $this->transposh->options->transposh_backup_schedule_o->get_name() . '" ' . checked($this->transposh->options->transposh_backup_schedule, 0, false) . '/>' . __('Disable backup (Can be run manually by clicking the button below)', TRANSPOSH_TEXT_DOMAIN) . '<br/>'; 
     634        echo __('Service Key:', TRANSPOSH_TEXT_DOMAIN) . ' <input type="text" size="32" class="regular-text" ' . $this->transposh->options->transposh_key_o->post_value_id_name() . '/><a target="_blank" href="http://transposh.org/faq/#restore">' . __('How to restore?', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'; 
    636635        echo '</div>'; 
    637636    } 
     
    646645         * Enabled by default. 
    647646         */ 
    648         $this->checkbox(ENABLE_AUTO_TRANSLATE, $this->transposh->options->get_enable_auto_translate(), __('Enable automatic translation', TRANSPOSH_TEXT_DOMAIN), __('Allow automatic translation of pages', TRANSPOSH_TEXT_DOMAIN)); 
     647        $this->checkbox($this->transposh->options->enable_autotranslate_o, __('Enable automatic translation', TRANSPOSH_TEXT_DOMAIN), __('Allow automatic translation of pages', TRANSPOSH_TEXT_DOMAIN)); 
    649648 
    650649        /** 
     
    652651         * Disabled by default. 
    653652         *  @since 0.3.5 */ 
    654         $this->checkbox(ENABLE_AUTO_POST_TRANSLATE, $this->transposh->options->get_enable_auto_post_translate(), __('Enable automatic translation after posting', TRANSPOSH_TEXT_DOMAIN), __('Do automatic translation immediately after a post has been published', TRANSPOSH_TEXT_DOMAIN)); 
     653        $this->checkbox($this->transposh->options->enable_autoposttranslate_o, __('Enable automatic translation after posting', TRANSPOSH_TEXT_DOMAIN), __('Do automatic translation immediately after a post has been published', TRANSPOSH_TEXT_DOMAIN)); 
    655654 
    656655        /** 
     
    658657         */ 
    659658        echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/bingicon.png\"> " . __('MSN API key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    660         echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_msn_key() . '" id="' . MSN_TRANSLATE_KEY . '" name="' . MSN_TRANSLATE_KEY . '"/>'; 
     659        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->msn_key_o->post_value_id_name() . '/>'; 
    661660 
    662661        /** 
     
    664663         */ 
    665664        echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/googleicon.png\"> " . __('Google API key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    666         echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_google_key() . '" id="' . GOOGLE_TRANSLATE_KEY . '" name="' . GOOGLE_TRANSLATE_KEY . '"/>'; 
     665        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->google_key_o->post_value_id_name() . '/>'; 
    667666 
    668667        /* 
     
    670669         */ 
    671670        echo '<h3>' . __('Select preferred auto translation engine', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    672         echo '<label for="' . PREFERRED_TRANSLATOR . '">' . __('Translation engine:', TRANSPOSH_TEXT_DOMAIN) . 
    673         '<select name="' . PREFERRED_TRANSLATOR . '">' . 
    674         '<option value="1"' . ($this->transposh->options->get_preferred_translator() == 1 ? ' selected="selected"' : '') . '>' . __('Google', TRANSPOSH_TEXT_DOMAIN) . '</option>' . 
    675         '<option value="2"' . ($this->transposh->options->get_preferred_translator() == 2 ? ' selected="selected"' : '') . '>' . __('Bing', TRANSPOSH_TEXT_DOMAIN) . '</option>' . 
     671        echo '<label for="' . $this->transposh->options->preferred_translator_o->get_name() . '">' . __('Translation engine:', TRANSPOSH_TEXT_DOMAIN) . 
     672        '<select name="' . $this->transposh->options->preferred_translator_o->get_name() . '">' . 
     673        '<option value="1"' . selected($this->transposh->options->preferred_translator, 1, false) . '>' . __('Google', TRANSPOSH_TEXT_DOMAIN) . '</option>' . 
     674        '<option value="2"' . selected($this->transposh->options->preferred_translator, 2, false) . '>' . __('Bing', TRANSPOSH_TEXT_DOMAIN) . '</option>' . 
    676675        '</select>' . 
    677676        '</label>'; 
     
    685684        echo __('One Hour Translation provides high-quality, fast professional translation to/from any language, and has specific domain expertise in SW localization, technical, business, and legal translations.', TRANSPOSH_TEXT_DOMAIN); 
    686685        echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation account ID', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    687         echo __('Account ID', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_oht_id() . '" id="' . OHT_TRANSLATE_ID . '" name="' . OHT_TRANSLATE_ID . '"/>'; 
     686        echo __('Account ID', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->oht_id_o->post_value_id_name() . '/>'; 
    688687 
    689688        /** 
     
    691690         */ 
    692691        echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation secret key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    693         echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" value="' . $this->transposh->options->get_oht_key() . '" id="' . OHT_TRANSLATE_KEY . '" name="' . OHT_TRANSLATE_KEY . '"/>'; 
     692        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->oht_key_o->post_value_id_name() . '/>'; 
    694693 
    695694        $oht = get_option(TRANSPOSH_OPTIONS_OHT, array()); 
     
    710709        $this->contains_settings = true; 
    711710 
    712         $this->checkbox(WIDGET_PROGRESSBAR, $this->transposh->options->get_widget_progressbar(), __('Show progress bar', TRANSPOSH_TEXT_DOMAIN), __('Show progress bar when a client triggers automatic translation', TRANSPOSH_TEXT_DOMAIN)); 
    713  
    714         $this->checkbox(WIDGET_ALLOW_SET_DEFLANG, $this->transposh->options->get_widget_allow_set_default_language(), __('Allow user to set current language as default', TRANSPOSH_TEXT_DOMAIN), __('Widget will allow setting this language as user default', TRANSPOSH_TEXT_DOMAIN)); 
    715  
    716         $this->checkbox(WIDGET_REMOVE_LOGO_FOR_AD, $this->transposh->options->get_widget_remove_logo(), __('Remove transposh logo (see <a href="http://transposh.org/logoterms">terms</a>)', TRANSPOSH_TEXT_DOMAIN), __('Transposh logo will not appear on widget', TRANSPOSH_TEXT_DOMAIN)); 
     711        $this->checkbox($this->transposh->options->widget_progressbar_o, __('Show progress bar', TRANSPOSH_TEXT_DOMAIN), __('Show progress bar when a client triggers automatic translation', TRANSPOSH_TEXT_DOMAIN)); 
     712 
     713        $this->checkbox($this->transposh->options->widget_allow_set_deflang_o, __('Allow user to set current language as default', TRANSPOSH_TEXT_DOMAIN), __('Widget will allow setting this language as user default', TRANSPOSH_TEXT_DOMAIN)); 
     714 
     715        $this->checkbox($this->transposh->options->widget_remove_logo_o, __('Remove transposh logo (see <a href="http://transposh.org/logoterms">terms</a>)', TRANSPOSH_TEXT_DOMAIN), __('Transposh logo will not appear on widget', TRANSPOSH_TEXT_DOMAIN)); 
    717716 
    718717        echo '<h3>' . __('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
    719         echo '<label for="' . WIDGET_THEME . '">' . __('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN) . 
    720         '<select id="transposh-style" name="' . WIDGET_THEME . '">'; 
     718        echo '<label for="' . $this->transposh->options->widget_theme_o->get_name() . '">' . __('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN) . 
     719        '<select id="transposh-style" name="' . $this->transposh->options->widget_theme_o->get_name() . '">'; 
    721720        foreach (transposh_consts::$jqueryui_themes as $theme) { 
    722             $selected = ($this->transposh->options->get_widget_theme() == $theme) ? ' selected="selected"' : ''; 
    723             echo "<option value=\"$theme\"$selected>{$theme}</option>"; 
     721          //  $selected = ($this->transposh->options->widget_theme == $theme) ? ' selected="selected"' : ''; 
     722            echo '<option value="' . $theme . '" ' . selected($this->transposh->options->widget_theme, $theme, false) . '>' . $theme . '</option>'; 
    724723        } 
    725724        echo '</select>' . 
     
    734733         * @since 0.5.3 
    735734         */ 
    736         $this->checkbox(ENABLE_URL_TRANSLATE, $this->transposh->options->get_enable_url_translate(), __('Enable url translation', TRANSPOSH_TEXT_DOMAIN) . ' (' . __('experimental', TRANSPOSH_TEXT_DOMAIN) . ')', __('Allow translation of permalinks and urls', TRANSPOSH_TEXT_DOMAIN)); 
     735        $this->checkbox($this->transposh->options->enable_url_translate_o, __('Enable url translation', TRANSPOSH_TEXT_DOMAIN) . ' (' . __('experimental', TRANSPOSH_TEXT_DOMAIN) . ')', __('Allow translation of permalinks and urls', TRANSPOSH_TEXT_DOMAIN)); 
    737736    } 
    738737 
     
    855854     * @return string used for checkboxes 
    856855     */ 
    857  
    858856    /** UTILITY FUNCTIONS * */ 
    859     private function checked($eval) { 
    860         return $eval ? 'checked="checked"' : ''; 
    861     } 
    862  
    863     private function checkbox($id, $value, $head, $text) { 
     857    //private function checked($eval) { 
     858//        return $eval ? 'checked="checked"' : ''; 
     859//    } 
     860 
     861    /*    private function checkbox($id, $value, $head, $text) { 
     862      echo '<h3>' . $head . '</h3>'; 
     863      echo '<input type="checkbox" value="1" name="' . $id . '" ' . checked($value, true, false) . '/> ' . $text; 
     864      } */ 
     865 
     866    /** 
     867     * @param transposh_option $tpo A transposh option boolean object 
     868     */ 
     869    private function checkbox($tpo, $head, $text) { 
    864870        echo '<h3>' . $head . '</h3>'; 
    865         echo '<input type="checkbox" value="1" name="' . $id . '" ' . $this->checked($value) . '/> ' . $text; 
     871        echo '<input type="checkbox" value="1" name="' . $tpo->get_name() . '" ' . checked($tpo->get_value(), true, false) . '/> ' . $text; 
    866872    } 
    867873 
     
    945951 
    946952} 
    947  
    948953?> 
  • trunk/WordPress/plugin/transposh/wp/transposh_backup.php

    r725 r742  
    3434        $body = array(); 
    3535        $body['home_url'] = $this->transposh->home_url; 
    36         $body['key'] = $this->transposh->options->get_transposh_key(); 
     36        $body['key'] = $this->transposh->options->transposh_key; 
    3737        $body['v'] = '2'; 
    3838        $body['tpv'] = '%VERSION%'; 
     
    5959            return; 
    6060        } 
    61         if ($this->transposh->options->get_transposh_key() == "") { 
    62             $this->transposh->options->set_transposh_key($result['headers']['transposh-key']); 
     61        if ($this->transposh->options->transposh_key == "") { 
     62            $this->transposh->options->transposh_key = $result['headers']['transposh-key']; 
    6363            // TODO: deliever new gottenkey to client side? 
    64             //echo $this->transposh->options->get_transposh_key(); 
    6564            $this->transposh->options->update_options(); 
    6665        } 
     
    119118        $body['to'] = time(); //TODO: fix this to get from DB 
    120119        $body['home_url'] = $this->transposh->home_url; 
    121         $body['key'] = $this->transposh->options->get_transposh_key(); 
     120        $body['key'] = $this->transposh->options->transposh_key; 
    122121        $result = wp_remote_get(TRANSPOSH_RESTORE_SERVICE_URL . "?to={$body['to']}&key={$body['key']}&home_url={$body['home_url']}"); // gotta be a better way... 
    123122        $lines = split("[\n|\r]", $result['body']); 
  • trunk/WordPress/plugin/transposh/wp/transposh_db.php

    r727 r742  
    328328        } 
    329329        if (!$by && !($all_editable && 
    330                 ($this->transposh->is_translator() || ($source > 0 && $this->transposh->options->get_enable_auto_translate())))) { 
     330                ($this->transposh->is_translator() || ($source > 0 && $this->transposh->options->enable_autotranslate)))) { 
    331331            logger("Unauthorized translation attempt " . $_SERVER['REMOTE_ADDR'], 1); 
    332332            header("HTTP/1.0 401 Unauthorized translation"); 
     
    448448        // TODO: move this to an action 
    449449        // Should we backup now? 
    450         if ($backup_immidiate_possible && $this->transposh->options->get_transposh_backup_schedule() == 2) { 
     450        if ($backup_immidiate_possible && $this->transposh->options->transposh_backup_schedule == 2) { 
    451451            $this->transposh->run_backup(); 
    452452        } 
  • trunk/WordPress/plugin/transposh/wp/transposh_options.php

    r740 r742  
    1212 */ 
    1313 
    14 // OLD Options - To be removed 
    15 // removed real old options support, no migration from 0.3.9 anymore 
    16 // @since 0.5.6 
    17 //Option defining transposh widget appearance 
    18 define('OLD_WIDGET_STYLE', 'widget_style'); 
    19 //Use CSS sprites for flags if available 
    20 define('OLD_WIDGET_CSS_FLAGS', 'widget_css_flags'); 
    21 //Wrap widget elements in an unordered list per #63 @since 0.3.7 
    22 define('OLD_WIDGET_IN_LIST', 'widget_in_list'); 
    23 //Option to enable/disable msn translation 
    24 define('OLD_ENABLE_MSN_TRANSLATE', 'enable_msntranslate'); 
    25 //Option defining transposh widget file used @since 0.5.6 
    26 define('OLD_WIDGET_FILE', 'widget_file'); //unset!!! 
    27 //Option to store the msn API key 
    28 define('MSN_TRANSLATE_KEY', 'msn_key'); 
    29 //Option to store the msn API key 
    30 define('GOOGLE_TRANSLATE_KEY', 'google_key'); 
    31 //Option to store the msn API key 
    32 define('OHT_TRANSLATE_ID', 'oht_id'); 
    33 //Option to store the msn API key 
    34 define('OHT_TRANSLATE_KEY', 'oht_key'); 
    35  
    36 //defines are used to avoid typos 
    37 //Option defining whether anonymous translation is allowed. 
    38 define('ANONYMOUS_TRANSLATION', 'allow_anonymous_translation'); 
    39 //Option defining the list of currentlly viewable languages 
    40 define('VIEWABLE_LANGS', 'viewable_languages'); 
    41 //Option defining the list of currentlly editable languages 
    42 define('EDITABLE_LANGS', 'editable_languages'); 
    43 //Option defining the ordered list of languages @since 0.3.9 
    44 define('SORTED_LANGS', 'sorted_languages'); 
    45 //Option to enable/disable auto translation 
    46 define('ENABLE_AUTO_TRANSLATE', 'enable_autotranslate'); 
    47 //Option to enable/disable auto translation 
    48 define('ENABLE_AUTO_POST_TRANSLATE', 'enable_autoposttranslate'); 
    49 //Option to store translator preference @since 0.4.2 
    50 define('PREFERRED_TRANSLATOR', 'preferred_translator'); 
    51 //Option to enable/disable default language translation 
    52 define('ENABLE_DEFAULT_TRANSLATE', 'enable_default_translate'); 
    53 //Option to enable/disable default language translation @since 0.3.6 
    54 define('ENABLE_SEARCH_TRANSLATE', 'enable_search_translate'); 
    55 //Option to enable/disable url translation @since 0.5.3 
    56 define('ENABLE_URL_TRANSLATE', 'enable_url_translate'); 
    57 //Make the gettext interface optional (@since 0.6.4) 
    58 define('TRANSPOSH_GETTEXT_INTEGRATION', 'transposh_gettext_integration'); 
    59 //Allow override for default locale (@since 0.7.5) 
    60 define('TRANSPOSH_DEFAULT_LOCALE_OVERRIDE', 'transposh_locale_override'); 
    61 //Option to enable/disable rewrite of permalinks 
    62 define('ENABLE_PERMALINKS', 'enable_permalinks'); 
    63 //Option to enable/disable footer scripts (2.8 and up) 
    64 define('ENABLE_FOOTER_SCRIPTS', 'enable_footer_scripts'); 
    65 //Option to enable detect and redirect language @since 0.3.8 
    66 define('ENABLE_DETECT_LANG_AND_REDIRECT', 'enable_detect_redirect'); 
    67 //Option defining the default language 
    68 define('DEFAULT_LANG', 'default_language'); 
    69 //Option allowing progress bar display 
    70 define('WIDGET_PROGRESSBAR', 'widget_progressbar'); 
    71 //Allows user to set his default language per #63 @since 0.3.8 
    72 define('WIDGET_ALLOW_SET_DEFLANG', 'widget_allow_set_deflang'); 
    73 //Allows removing of transposh logo in exchange for an ad @since 0.6.0 
    74 define('WIDGET_REMOVE_LOGO_FOR_AD', 'widget_remove_logo'); 
    75 //Allows theming of the progressbar and edit window @since 0.7.0 
    76 define('WIDGET_THEME', 'widget_theme'); 
    77 //Stores the site key to transposh services (backup @since 0.5.0) 
    78 define('TRANSPOSH_KEY', 'transposh_key'); 
    79 //Stores the site key to transposh services (backup @since 0.5.0) 
    80 define('TRANSPOSH_BACKUP_SCHEDULE', 'transposh_backup_schedule'); 
    81 //Stores hidden warnings (@since 0.7.6) 
    82 define('TRANSPOSH_ADMIN_HIDE_WARNINGS', 'transposh_admin_hide_warnings'); 
    83 //Should I allow collecting of anonymous stats (@since 0.7.6) 
    84 define('TRANSPOSH_COLLECT_STATS', 'transposh_admin_hide_warnings'); 
    85  
     14// This magic value will cause the option to be set from post 
     15define('TP_FROM_POST', 'tp_post_1x'); 
     16// types of options 
     17define('TP_OPT_BOOLEAN', 0); 
     18define('TP_OPT_STRING', 1); 
     19define('TP_OPT_OTHER', 2); 
     20 
     21/** 
     22 * @property string $desc Description 
     23 */ 
     24class transposh_option { 
     25 
     26    private $name; 
     27    private $value; 
     28    private $type; 
     29 
     30    public function __construct($name, $value = '', $type = '') { 
     31        $this->name = $name; 
     32        $this->value = $value; 
     33        $this->type = $type; 
     34    } 
     35 
     36    function __toString() { 
     37        return (string) $this->value; 
     38    } 
     39 
     40    function set_value($value) { 
     41        $this->value = $value; 
     42    } 
     43 
     44    function from_post() { 
     45        $this->value = $_POST[$this->name]; 
     46    } 
     47 
     48    function get_name() { 
     49        return $this->name; 
     50    } 
     51 
     52    function get_value() { 
     53        return $this->value; 
     54    } 
     55 
     56    function get_type() { 
     57        return $this->type; 
     58    } 
     59 
     60    function post_value_id_name() { 
     61        return 'value="' . $this->value . '" id="' . $this->name . '" name="' . $this->name . '"'; 
     62    } 
     63 
     64} 
     65 
     66/** 
     67 * Used properties for code completion - we'll try to keep them in same order as admin screens 
     68 *  
     69 * Language tab 
     70 * @property string           $default_language      Option defining the default language 
     71 * @property transposh_option $default_language_o  
     72 * @property string           $viewable_languages    Option defining the list of currently viewable languages 
     73 * @property transposh_option $viewable_languages_o  
     74 * @property string           $editable_languages    Option defining the list of currently editable languages 
     75 * @property transposh_option $editable_languages_o  
     76 * @property string           $sorted_languages      Option defining the ordered list of languages @since 0.3.9 
     77 * @property transposh_option $sorted_languages_o  
     78 *  
     79 * Settings 
     80 *  
     81 * @property boolean          $allow_anonymous_translation   Option defining whether anonymous translation is allowed 
     82 * @property transposh_option $allow_anonymous_translation_o 
     83 * @property boolean          $enable_default_translate      Option to enable/disable default language translation 
     84 * @property transposh_option $enable_default_translate_o 
     85 * @property boolean          $enable_search_translate       Option to enable/disable default language translation @since 0.3.6 
     86 * @property transposh_option $enable_search_translate_o 
     87 * @property boolean          $transposh_gettext_integration Make the gettext interface optional (@since 0.6.4) 
     88 * @property transposh_option $transposh_gettext_integration_o 
     89 * @property boolean          $transposh_locale_override     Allow override for default locale (@since 0.7.5) 
     90 * @property transposh_option $transposh_locale_override_o 
     91 *  
     92 * @property boolean          $enable_permalinks             Option to enable/disable rewrite of permalinks 
     93 * @property transposh_option $enable_permalinks_o 
     94 * @property boolean          $enable_footer_scripts         Option to enable/disable footer scripts (2.8 and up) 
     95 * @property transposh_option $enable_footer_scripts_o 
     96 * @property boolean          $enable_detect_redirect        Option to enable detect and redirect language @since 0.3.8 
     97 * @property transposh_option $enable_detect_redirect_o 
     98 * @property boolean          $transposh_collect_stats       Should I allow collecting of anonymous stats (@since 0.7.6) 
     99 * @property transposh_option $transposh_collect_stats_o 
     100 *  
     101 * @property int              $transposh_backup_schedule     Stores the schedule for the backup service, 0-none, 1-daily, 2-live (backup @since 0.5.0) 
     102 * @property transposh_option $transposh_backup_schedule_o   
     103 * @property string           $transposh_key                 Stores the site key to transposh services (backup @since 0.5.0) 
     104 * @property transposh_option $transposh_key_o 
     105 *  
     106 * Engines 
     107 *  
     108 * @property boolean          $enable_autotranslate          Option to enable/disable auto translation 
     109 * @property transposh_option $enable_autotranslate_o 
     110 * @property boolean          $enable_autoposttranslate      Option to enable/disable auto translation of posts 
     111 * @property transposh_option $enable_autoposttranslate_o 
     112 * @property string           $msn_key                       Option to store the msn API key 
     113 * @property transposh_option $msn_key_o 
     114 * @property string           $google_key                    Option to store the msn Google key 
     115 * @property transposh_option $google_key_o 
     116 * @property int              $preferred_translator          Option to store translator preference @since 0.4.2 
     117 * @property transposh_option $preferred_translator_o 
     118 * @property string           $oht_id                        Option to store the oht ID 
     119 * @property transposh_option $oht_id_o 
     120 * @property string           $oht_key                       Option to store the oht key; 
     121 * @property transposh_option $oht_key_o 
     122 *  
     123 * Widget 
     124 *  
     125 * @property boolean          $widget_progressbar            Option allowing progress bar display 
     126 * @property transposh_option $widget_progressbar_o 
     127 * @property boolean          $widget_allow_set_deflang      Allows user to set his default language per #63 @since 0.3.8 
     128 * @property transposh_option $widget_allow_set_deflang_o 
     129 * @property boolean          $widget_remove_logo            Allows removing of transposh logo in exchange for an ad @since 0.6.0 
     130 * @property transposh_option $widget_remove_logo_o 
     131 * @property string           $widget_theme                  Allows theming of the progressbar and edit window @since 0.7.0 
     132 * @property transposh_option $widget_theme_o 
     133 *  
     134 * Advanced 
     135 *  
     136 * @property boolean          $enable_url_translate          Option to enable/disable url translation @since 0.5.3 
     137 * @property transposh_option $enable_url_translate_o 
     138 *  
     139 * Hidden 
     140 *  
     141 * @property transposh_option $transposh_admin_hide_warnings Stores hidden warnings (@since 0.7.6) 
     142 *  
     143 */ 
    86144class transposh_plugin_options { 
    87145 
     
    91149    /** @var boolean set to true if any option was changed */ 
    92150    private $changed = false; 
     151    private $vars = array(); 
    93152 
    94153    function set_default_option_value($option, $value = '') { 
     
    96155    } 
    97156 
    98     function transposh_plugin_options() { 
     157    // private $vars array() = (1,2,3); 
     158 
     159    function register_option($name, $type, $default_value = '') { 
     160        if (!isset($this->options[$name])) 
     161                $this->options[$name] = $default_value; 
     162        logger($name . ' ' . $this->options[$name]); 
     163        $this->vars[$name] = new transposh_option($name, $this->options[$name], $type); 
     164    } 
     165 
     166    function __get($name) { 
     167        if (substr($name, -2) === "_o") 
     168                return $this->vars[substr($name, 0, -2)]; 
     169//        logger($this->vars[$name]->get_value()); 
     170        return $this->vars[$name]->get_value(); 
     171    } 
     172 
     173    function __set($name, $value) { 
     174        if ($value == TP_FROM_POST) { 
     175            $value = $_POST[$name]; 
     176        } 
     177 
     178        if (TP_OPT_BOOLEAN == $this->vars[$name]->get_type()) { 
     179            $value = ($value) ? 1 : 0; 
     180        } 
     181 
     182        if ($this->vars[$name]->get_value() != $value) { 
     183            logger("option '$name' value set: $value"); 
     184            $this->vars[$name]->set_value($value); 
     185            $this->changed = true; 
     186        } 
     187    } 
     188 
     189    function __construct() { 
     190 
     191 
    99192        logger("creating options"); 
    100193        // load them here 
    101194        $this->options = get_option(TRANSPOSH_OPTIONS); 
    102         $this->set_default_option_value(ANONYMOUS_TRANSLATION, 1); 
    103         $this->set_default_option_value(ENABLE_SEARCH_TRANSLATE, 1); 
    104         $this->set_default_option_value(ENABLE_AUTO_TRANSLATE, 1); 
    105         $this->set_default_option_value(PREFERRED_TRANSLATOR, 1); 
    106         $this->set_default_option_value(TRANSPOSH_GETTEXT_INTEGRATION, 1); 
    107         $this->set_default_option_value(TRANSPOSH_DEFAULT_LOCALE_OVERRIDE, 1); 
    108         $this->set_default_option_value(VIEWABLE_LANGS); 
    109         $this->set_default_option_value(EDITABLE_LANGS); 
    110         //$this->set_default_option_value(SORTED_LANGS); 
    111         $this->set_default_option_value(ENABLE_AUTO_POST_TRANSLATE); 
    112         $this->set_default_option_value(ENABLE_DEFAULT_TRANSLATE); 
    113         $this->set_default_option_value(ENABLE_SEARCH_TRANSLATE); 
    114         $this->set_default_option_value(ENABLE_URL_TRANSLATE); 
    115         $this->set_default_option_value(ENABLE_PERMALINKS); 
    116         $this->set_default_option_value(ENABLE_FOOTER_SCRIPTS); 
    117         $this->set_default_option_value(ENABLE_DETECT_LANG_AND_REDIRECT); 
    118         $this->set_default_option_value(DEFAULT_LANG); 
    119         $this->set_default_option_value(WIDGET_PROGRESSBAR); 
    120         $this->set_default_option_value(WIDGET_ALLOW_SET_DEFLANG); 
    121         $this->set_default_option_value(WIDGET_REMOVE_LOGO_FOR_AD); 
    122         $this->set_default_option_value(WIDGET_THEME, 'ui-lightness'); 
    123         $this->set_default_option_value(MSN_TRANSLATE_KEY); 
    124         $this->set_default_option_value(GOOGLE_TRANSLATE_KEY); 
    125         $this->set_default_option_value(OHT_TRANSLATE_ID); 
    126         $this->set_default_option_value(OHT_TRANSLATE_KEY); 
    127         $this->set_default_option_value(TRANSPOSH_KEY); 
    128         $this->set_default_option_value(TRANSPOSH_BACKUP_SCHEDULE, 2); 
    129         $this->set_default_option_value(TRANSPOSH_ADMIN_HIDE_WARNINGS); 
    130         $this->set_default_option_value(TRANSPOSH_COLLECT_STATS, 1); 
    131         $this->migrate_old_config(); 
     195//        logger($this->options); 
     196 
     197        $this->register_option('default_language', TP_OPT_STRING); // default? 
     198        $this->register_option('viewable_languages', TP_OPT_STRING); 
     199        $this->register_option('editable_languages', TP_OPT_STRING); 
     200        $this->register_option('sorted_languages', TP_OPT_STRING); 
     201 
     202        $this->register_option('allow_anonymous_translation', TP_OPT_BOOLEAN, 1); 
     203        $this->register_option('enable_default_translate', TP_OPT_BOOLEAN, 0); 
     204        $this->register_option('enable_search_translate', TP_OPT_BOOLEAN, 1); 
     205        $this->register_option('transposh_gettext_integration', TP_OPT_BOOLEAN, 1); 
     206        $this->register_option('transposh_locale_override', TP_OPT_BOOLEAN, 1); 
     207 
     208        $this->register_option('enable_permalinks', TP_OPT_BOOLEAN, 0); 
     209        $this->register_option('enable_footer_scripts', TP_OPT_BOOLEAN, 0); 
     210        $this->register_option('enable_detect_redirect', TP_OPT_BOOLEAN, 0); 
     211        $this->register_option('transposh_collect_stats', TP_OPT_BOOLEAN, 1); 
     212 
     213        $this->register_option('transposh_backup_schedule', TP_OPT_OTHER, 2); 
     214        $this->register_option('transposh_key', TP_OPT_STRING); 
     215 
     216        $this->register_option('enable_autotranslate', TP_OPT_BOOLEAN, 1); 
     217        $this->register_option('enable_autoposttranslate', TP_OPT_BOOLEAN, 1); 
     218        $this->register_option('msn_key', TP_OPT_STRING); 
     219        $this->register_option('google_key', TP_OPT_STRING); 
     220        $this->register_option('preferred_translator', TP_OPT_OTHER, 1); // 1 is Google, 2 is MSN 
     221        $this->register_option('oht_id', TP_OPT_STRING); 
     222        $this->register_option('oht_key', TP_OPT_STRING); 
     223 
     224 
     225        $this->register_option('widget_progressbar', TP_OPT_BOOLEAN); 
     226        $this->register_option('widget_allow_set_deflang', TP_OPT_BOOLEAN); 
     227        $this->register_option('widget_remove_logo', TP_OPT_BOOLEAN); 
     228        $this->register_option('widget_theme', TP_OPT_STRING, 'ui-lightness'); 
     229 
     230        $this->register_option('enable_url_translate', TP_OPT_BOOLEAN); 
     231 
     232        $this->register_option('transposh_admin_hide_warnings', TP_OPT_OTHER); 
     233 
     234 
     235        // Fix default language if needed, only done once now, and since this was being done constantly, we gain 
     236        //logger($this->default_language->get_value()); 
     237 
     238        if (!isset(transposh_consts::$languages[$this->default_language])) { 
     239            if (defined('WPLANG') && isset(transposh_consts::$languages[WPLANG])) { 
     240                $this->default_language = WPLANG; 
     241            } else { 
     242                $this->default_language = "en"; 
     243            } 
     244        } 
     245 
    132246        logger($this->options, 4); 
    133     } 
    134  
    135     // TODO: remove this function in a few versions (fix css, db version..., css flag 
    136     private function migrate_old_config() { 
    137         logger("in migration"); 
    138         if (isset($this->options[OLD_WIDGET_STYLE])) {           
    139             unset($this->options[OLD_WIDGET_CSS_FLAGS]); 
    140             unset($this->options[OLD_WIDGET_IN_LIST]); 
    141             unset($this->options[OLD_WIDGET_STYLE]); 
    142             unset($this->options[OLD_ENABLE_MSN_TRANSLATE]); 
    143             logger($this->options); 
    144             update_option(TRANSPOSH_OPTIONS, $this->options); 
    145         } 
    146     } 
    147  
    148     function get_anonymous_translation() { 
    149         return $this->options[ANONYMOUS_TRANSLATION]; 
    150     } 
    151  
    152     function get_viewable_langs() { 
    153         return $this->options[VIEWABLE_LANGS]; 
    154     } 
    155  
    156     function get_editable_langs() { 
    157         return $this->options[EDITABLE_LANGS]; 
    158247    } 
    159248 
     
    164253     */ 
    165254    function get_sorted_langs() { 
    166         if (isset($this->options[SORTED_LANGS])) 
    167                 return array_merge(array_flip(explode(",", $this->options[SORTED_LANGS])), transposh_consts::$languages); 
     255        if (isset($this->sorted_languages)) 
     256                return array_merge(array_flip(explode(",", $this->sorted_languages)), transposh_consts::$languages); 
    168257        return transposh_consts::$languages; 
    169258    } 
    170259 
    171     function get_widget_progressbar() { 
    172         return $this->options[WIDGET_PROGRESSBAR]; 
    173     } 
    174  
    175     function get_widget_remove_logo() { 
    176         return $this->options[WIDGET_REMOVE_LOGO_FOR_AD]; 
    177     } 
    178  
    179     /** 
    180      * return theme 
    181      * @since 0.7.0 
    182      * @return string  
    183      */ 
    184     function get_widget_theme() { 
    185         return $this->options[WIDGET_THEME]; 
    186     } 
    187  
    188     function get_widget_allow_set_default_language() { 
    189         return $this->options[WIDGET_ALLOW_SET_DEFLANG]; 
    190     } 
    191  
    192     function get_enable_permalinks() { 
    193         return $this->options[ENABLE_PERMALINKS]; 
    194     } 
    195  
    196     function get_enable_footer_scripts() { 
    197         return $this->options[ENABLE_FOOTER_SCRIPTS]; 
    198     } 
    199  
    200     function get_enable_detect_language() { 
    201         return $this->options[ENABLE_DETECT_LANG_AND_REDIRECT]; 
    202     } 
    203  
    204     function get_enable_default_translate() { 
    205         return $this->options[ENABLE_DEFAULT_TRANSLATE]; 
    206     } 
    207  
    208     function get_enable_search_translate() { 
    209         return $this->options[ENABLE_SEARCH_TRANSLATE]; 
    210     } 
    211  
    212     function get_enable_url_translate() { 
    213         return $this->options[ENABLE_URL_TRANSLATE]; 
    214     } 
    215  
    216     function get_enable_auto_translate() { 
    217         // default is true 
    218         return $this->options[ENABLE_AUTO_TRANSLATE]; 
    219     } 
    220  
    221     function get_msn_key() { 
    222         return $this->options[MSN_TRANSLATE_KEY]; 
    223     } 
    224  
    225     function get_google_key() { 
    226         return $this->options[GOOGLE_TRANSLATE_KEY]; 
    227     } 
    228  
    229     function get_oht_id() { 
    230         return $this->options[OHT_TRANSLATE_ID]; 
    231     } 
    232  
    233     function get_oht_key() { 
    234         return $this->options[OHT_TRANSLATE_KEY]; 
    235     } 
    236  
    237     function get_enable_auto_post_translate() { 
    238         return $this->options[ENABLE_AUTO_POST_TRANSLATE]; 
    239     } 
    240  
    241     function get_preferred_translator() { 
    242         // default is google(1) (2 is msn) 
    243         return $this->options[PREFERRED_TRANSLATOR]; 
    244     } 
    245  
    246     /** 
    247      * Gets the default language setting, i.e. the source language which normally should not be translated. 
    248      * @return string Default language 
    249      */ 
    250     function get_default_language() { 
    251         $default = $this->options[DEFAULT_LANG]; 
    252         if (!isset(transposh_consts::$languages[$default])) { 
    253             if (defined('WPLANG') && isset(transposh_consts::$languages[WPLANG])) { 
    254                 $default = WPLANG; 
    255             } else { 
    256                 $default = "en"; 
    257             } 
    258         } 
    259         return $default; 
    260     } 
    261  
    262     function get_transposh_key() { 
    263         return $this->options[TRANSPOSH_KEY]; 
    264     } 
    265  
    266     function get_transposh_backup_schedule() { 
    267         return $this->options[TRANSPOSH_BACKUP_SCHEDULE]; 
    268     } 
    269  
    270     function get_transposh_gettext_integration() { 
    271         return $this->options[TRANSPOSH_GETTEXT_INTEGRATION]; 
    272     } 
    273  
    274     function get_transposh_default_locale_override() { 
    275         return $this->options[TRANSPOSH_DEFAULT_LOCALE_OVERRIDE]; 
    276     } 
    277  
    278260    function get_transposh_admin_hide_warning($id) { 
    279         return strpos($this->options[TRANSPOSH_ADMIN_HIDE_WARNINGS], $id . ',') !== false; 
    280     } 
    281  
    282     function get_transposh_collect_stats() { 
    283         return $this->options[TRANSPOSH_COLLECT_STATS]; 
    284     } 
    285  
    286     /** 
    287      * Sets a value at the options array 
    288      * @param mixed $val 
    289      * @param pointer $option Points to the option in the options array 
    290      */ 
    291     private function set_value($val, &$option) { 
    292         if ($val !== $option) { 
    293             $option = $val; 
    294             $this->changed = true; 
    295         } 
    296     } 
    297  
    298     function set_anonymous_translation($val) { 
    299         $val = ($val) ? 1 : 0; 
    300         $this->set_value($val, $this->options[ANONYMOUS_TRANSLATION]); 
    301     } 
    302  
    303     function set_viewable_langs($val) { 
    304         $this->set_value($val, $this->options[VIEWABLE_LANGS]); 
    305     } 
    306  
    307     function set_editable_langs($val) { 
    308         $this->set_value($val, $this->options[EDITABLE_LANGS]); 
    309     } 
    310  
    311     function set_sorted_langs($val) { 
    312         $this->set_value($val, $this->options[SORTED_LANGS]); 
    313     } 
    314  
    315     function set_widget_progressbar($val) { 
    316         $val = ($val) ? 1 : 0; 
    317         $this->set_value($val, $this->options[WIDGET_PROGRESSBAR]); 
    318     } 
    319  
    320     function set_widget_remove_logo($val) { 
    321         $val = ($val) ? 1 : 0; 
    322         $this->set_value($val, $this->options[WIDGET_REMOVE_LOGO_FOR_AD]); 
    323     } 
    324  
    325     /** 
    326      * Set the widget theme 
    327      * @since 0.7.0 
    328      * @param string $val 
    329      */ 
    330     function set_widget_theme($val) { 
    331         $this->set_value($val, $this->options[WIDGET_THEME]); 
    332     } 
    333  
    334     function set_widget_allow_set_default_language($val) { 
    335         $val = ($val) ? 1 : 0; 
    336         $this->set_value($val, $this->options[WIDGET_ALLOW_SET_DEFLANG]); 
    337     } 
    338  
    339     function set_enable_permalinks($val) { 
    340         $val = ($val) ? 1 : 0; 
    341         $this->set_value($val, $this->options[ENABLE_PERMALINKS]); 
    342     } 
    343  
    344     function set_enable_detect_language($val) { 
    345         $val = ($val) ? 1 : 0; 
    346         $this->set_value($val, $this->options[ENABLE_DETECT_LANG_AND_REDIRECT]); 
    347     } 
    348  
    349     function set_enable_footer_scripts($val) { 
    350         $val = ($val) ? 1 : 0; 
    351         $this->set_value($val, $this->options[ENABLE_FOOTER_SCRIPTS]); 
    352     } 
    353  
    354     function set_enable_default_translate($val) { 
    355         $val = ($val) ? 1 : 0; 
    356         $this->set_value($val, $this->options[ENABLE_DEFAULT_TRANSLATE]); 
    357     } 
    358  
    359     function set_enable_search_translate($val) { 
    360         $val = ($val) ? 1 : 0; 
    361         $this->set_value($val, $this->options[ENABLE_SEARCH_TRANSLATE]); 
    362     } 
    363  
    364     function set_enable_url_translate($val) { 
    365         $val = ($val) ? 1 : 0; 
    366         $this->set_value($val, $this->options[ENABLE_URL_TRANSLATE]); 
    367     } 
    368  
    369     function set_enable_auto_translate($val) { 
    370         $val = ($val) ? 1 : 0; 
    371         $this->set_value($val, $this->options[ENABLE_AUTO_TRANSLATE]); 
    372     } 
    373  
    374     function set_msn_key($val) { 
    375         $this->set_value($val, $this->options[MSN_TRANSLATE_KEY]); 
    376     } 
    377  
    378     function set_google_key($val) { 
    379         $this->set_value($val, $this->options[GOOGLE_TRANSLATE_KEY]); 
    380     } 
    381  
    382     function set_oht_id($val) { 
    383         $this->set_value($val, $this->options[OHT_TRANSLATE_ID]); 
    384     } 
    385  
    386     function set_oht_key($val) { 
    387         $this->set_value($val, $this->options[OHT_TRANSLATE_KEY]); 
    388     } 
    389  
    390     function set_enable_auto_post_translate($val) { 
    391         $val = ($val) ? 1 : 0; 
    392         $this->set_value($val, $this->options[ENABLE_AUTO_POST_TRANSLATE]); 
    393     } 
    394  
    395     function set_preferred_translator($val) { 
    396         $this->set_value($val, $this->options[PREFERRED_TRANSLATOR]); 
    397     } 
    398  
    399     /** 
    400      * Sets the default language setting, i.e. the source language which 
    401      * should not be translated. 
    402      * @param string $val Language set as default 
    403      */ 
    404     function set_default_language($val) { 
    405         if (!transposh_consts::$languages[$val]) { 
    406             $val = "en"; 
    407         } 
    408         $this->set_value($val, $this->options[DEFAULT_LANG]); 
    409     } 
    410  
    411     function set_transposh_key($val) { 
    412         $this->set_value($val, $this->options[TRANSPOSH_KEY]); 
    413     } 
    414  
    415     function set_transposh_backup_schedule($val) { 
    416         $this->set_value($val, $this->options[TRANSPOSH_BACKUP_SCHEDULE]); 
    417     } 
    418  
    419     function set_transposh_gettext_integration($val) { 
    420         $val = ($val) ? 1 : 0; 
    421         $this->set_value($val, $this->options[TRANSPOSH_GETTEXT_INTEGRATION]); 
    422     } 
    423  
    424     function set_transposh_default_locale_override($val) { 
    425         $val = ($val) ? 1 : 0; 
    426         $this->set_value($val, $this->options[TRANSPOSH_DEFAULT_LOCALE_OVERRIDE]); 
     261        return strpos($this->transposh_admin_hide_warnings, $id . ',') !== false; 
    427262    } 
    428263 
    429264    function set_transposh_admin_hide_warning($id) { 
    430265        if (!$this->get_transposh_admin_hide_warning($id)) { 
    431             $this->set_value($this->options[TRANSPOSH_ADMIN_HIDE_WARNINGS] . $id . ',', $this->options[TRANSPOSH_ADMIN_HIDE_WARNINGS]); 
    432         } 
    433     } 
    434  
    435     function set_transposh_collect_stats($val) { 
    436         $val = ($val) ? 1 : 0; 
    437         $this->set_value($val, $this->options[TRANSPOSH_COLLECT_STATS]); 
     266            $this->transposh_admin_hide_warnings = $this->transposh_admin_hide_warnings . $id . ','; 
     267        } 
    438268    } 
    439269 
     
    443273    function update_options() { 
    444274        if ($this->changed) { 
     275            foreach ($this->vars as $name => $var) { 
     276                $this->options[$name] = $var->get_value(); 
     277            } 
    445278            update_option(TRANSPOSH_OPTIONS, $this->options); 
     279            $this->changed = false; 
    446280        } else { 
    447281            logger("no changes and no updates done"); 
    448282        } 
    449         $this->changed = false; 
    450283    } 
    451284 
     
    455288     * @return boolean Is this the default language? 
    456289     */ 
    457     function is_default_language($language) { 
    458         return ($this->get_default_language() == $language || '' == $language); 
     290    function is_default_language($language) { // XXXX 
     291        return ($this->default_language == $language || '' == $language); 
    459292    } 
    460293 
     
    465298    function is_editable_language($language) { 
    466299        if ($this->is_default_language($language)) return true; 
    467         return (strpos($this->get_editable_langs().',', $language.',') !== false); 
     300        return (strpos($this->editable_languages . ',', $language . ',') !== false); 
    468301    } 
    469302 
     
    474307    function is_viewable_language($language) { 
    475308        if ($this->is_default_language($language)) return true; 
    476         return (strpos($this->get_viewable_langs().',', $language.',') !== false); 
     309        return (strpos($this->viewable_languages . ',', $language . ',') !== false); 
    477310    } 
    478311 
  • trunk/WordPress/plugin/transposh/wp/transposh_postpublish.php

    r698 r742  
    3535        $this->transposh = &$transposh; 
    3636        // we'll only do something if so configured to do 
    37         if ($this->transposh->options->get_enable_auto_post_translate()) { 
     37        if ($this->transposh->options->enable_autoposttranslate) { 
    3838            add_action('edit_post', array(&$this, 'on_edit')); 
    3939            // add_action('publish_post',array(&$this, 'on_publish')); 
     
    124124 
    125125            // Add phrases from permalink 
    126             if ($this->transposh->options->get_enable_url_translate()) { 
     126            if ($this->transposh->options->enable_url_translate) { 
    127127                $permalink = get_permalink($postID); 
    128128                $permalink = substr($permalink, strlen($this->transposh->home_url) + 1); 
     
    141141 
    142142        foreach ($phrases as $key) { 
    143             foreach (explode(',', $this->transposh->options->get_editable_langs()) as $lang) { 
     143            foreach (explode(',', $this->transposh->options->editable_languages) as $lang) { 
    144144                // if this isn't the default language or we specifically allow default language translation, we will seek this out... 
    145145                // as we don't normally want to auto-translate the default language -FIX THIS to include only correct stuff, how? 
    146                 if (!$this->transposh->options->is_default_language($lang) || $this->transposh->options->get_enable_default_translate()) { 
     146                if (!$this->transposh->options->is_default_language($lang) || $this->transposh->options->enable_default_translate) { 
    147147                    // There is no point in returning phrases, languages pairs that cannot be translated 
    148148                    if (in_array($lang, transposh_consts::$bing_languages) || 
     
    217217            update_post_meta($postID, 'tp_language', $_POST['transposh_tp_language']); 
    218218            // if a language is set for a post, default language translate must be enabled, so we enable it 
    219             if (!$this->transposh->options->get_enable_default_translate()) { 
    220                 $this->transposh->options->set_enable_default_translate(true); 
     219            if (!$this->transposh->options->enable_default_translate) { 
     220                $this->transposh->options->enable_default_translate = true; 
    221221                $this->transposh->options->update_options(); 
    222222            } 
  • trunk/WordPress/plugin/transposh/wp/transposh_widget.php

    r738 r742  
    219219                    ($this->transposh->options->is_default_language($code))) { 
    220220                // now we alway do this... maybe cache this to APC/Memcache 
    221                 if ($this->transposh->options->get_enable_url_translate() && !$this->transposh->options->is_default_language($code)) { 
     221                if ($this->transposh->options->enable_url_translate && !$this->transposh->options->is_default_language($code)) { 
    222222                    $page_url = transposh_utils::translate_url($clean_page_url, '', $code, array(&$this->transposh->database, 'fetch_translation')); 
    223223                } else { 
Note: See TracChangeset for help on using the changeset viewer.