Changeset 743


Ignore:
Timestamp:
11/16/12 02:18:22 (2 years ago)
Author:
ofer
Message:

Add the options to change the parsing rules into the advanced tab, instead of using the top of parser.php

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

Legend:

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

    r721 r743  
    1717require_once("utils.php"); 
    1818 
    19 define('PUNCT_BREAKS', TRUE); // Will punctiations such as , . ( and such will break a phrase 
    20 define('NUM_BREAKS', TRUE); // Will a number break a phrase 
    21 define('ENT_BREAKS', TRUE); // Will an HTML entity break a phrase 
    2219 
    2320/** 
     
    10097class parser { 
    10198 
    102     // funnctions that need to be defined... // 
     99    private $punct_breaks = true; 
     100    private $num_breaks = true; 
     101    private $ent_breaks = true; 
     102 
     103    // functions that need to be defined... // 
    103104    public $url_rewrite_func = null; 
    104105    public $fetch_translate_func = null; 
     
    380381        while ($pos < strlen($string)) { 
    381382            // Some HTML entities make us break, almost all but apostrophies 
    382             if (ENT_BREAKS && $len_of_entity = $this->is_html_entity($string, $pos)) { 
     383            if ($this->ent_breaks && $len_of_entity = $this->is_html_entity($string, $pos)) { 
    383384                $entity = substr($string, $pos, $len_of_entity); 
    384385                if (($this->is_white_space(@$string[$pos + $len_of_entity]) || $this->is_entity_breaker($entity)) && !$this->is_entity_letter($entity)) { 
     
    421422            } 
    422423            // will break translation unit when there's a breaker ",.[]()..." 
    423             elseif (PUNCT_BREAKS && $senb_len = $this->is_sentence_breaker($string[$pos], @$string[$pos + 1], @$string[$pos + 2])) { 
     424            elseif ($this->punct_breaks && $senb_len = $this->is_sentence_breaker($string[$pos], @$string[$pos + 1], @$string[$pos + 2])) { 
    424425//                logger ("sentence breaker..."); 
    425426                $this->tag_phrase($string, $start, $pos); 
     
    429430            // Numbers also break, if they are followed by whitespace (or a sentence breaker) (don't break 42nd) // TODO: probably by breaking entities too... 
    430431            // also prefixed by whitespace? 
    431             elseif (NUM_BREAKS && $num_len = $this->is_number($string, $pos)) { 
     432            elseif ($this->num_breaks && $num_len = $this->is_number($string, $pos)) { 
    432433//                logger ("numnum... $num_len"); 
    433434                // this is the case of B2 or B2, 
     
    630631 
    631632    /** 
     633     * Allow changing of parsing rules, yeah, I caved 
     634     * @param type $puncts 
     635     * @param type $numbers 
     636     * @param type $entities 
     637     */ 
     638    function change_parsing_rules($puncts, $numbers, $entities) { 
     639        $this->punct_breaks = $puncts; 
     640        $this->num_breaks = $numbers; 
     641        $this->ent_breaks = $entities; 
     642    } 
     643     
     644    /** 
    632645     * Main function - actually translates a given HTML 
    633646     * @param string $string containing HTML 
     
    756769            if ($e->href) 
    757770                    $e->href = call_user_func_array($this->url_rewrite_func, array($e->href)); 
    758         } 
     771            } 
    759772        foreach ($this->otags as $e) { 
    760773            if ($e->value) 
  • trunk/WordPress/plugin/transposh/transposh.php

    r742 r743  
    357357                $parse->feed_fix = true; 
    358358            } 
     359            $parse->change_parsing_rules(!$this->options->parser_dont_break_puncts, !$this->options->parser_dont_break_numbers, !$this->options->parser_dont_break_entities); 
    359360            $buffer = $parse->fix_html($buffer); 
    360361 
     
    874875     */ 
    875876    function rewrite_url($href) { 
    876         $use_params = FALSE; 
    877877        logger("got: $href", 5); 
    878878        // fix what might be messed up -- TODO 
  • trunk/WordPress/plugin/transposh/wp/transposh_admin.php

    r742 r743  
    171171            case "tp_advanced": 
    172172                $this->transposh->options->enable_url_translate = TP_FROM_POST; 
     173                $this->transposh->options->parser_dont_break_puncts = TP_FROM_POST; 
     174                $this->transposh->options->parser_dont_break_numbers = TP_FROM_POST; 
     175                $this->transposh->options->parser_dont_break_entities = TP_FROM_POST; 
    173176                break; 
    174177        } 
     
    508511        // this is the default language location 
    509512        list ($langname, $langorigname, $flag) = explode(",", transposh_consts::$languages[$this->transposh->options->default_language]); 
    510         echo '<div id="default_lang" style="overflow:auto;padding-bottom:10px;"><h3>'; 
    511         echo __('Default Language (drag another language here to make it default)', TRANSPOSH_TEXT_DOMAIN); 
    512         echo '</h3><ul id="default_list"><li id="' . $this->transposh->options->default_language . '" class="languages">' 
     513        echo '<div id="default_lang" style="overflow:auto;padding-bottom:10px;">'; 
     514        $this->header(__('Default Language (drag another language here to make it default)', TRANSPOSH_TEXT_DOMAIN)); 
     515        echo '<ul id="default_list"><li id="' . $this->transposh->options->default_language . '" class="languages">' 
    513516        . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, $langorigname, false/* $this->transposh->options->get_widget_css_flags() */) 
    514517        . '<input type="hidden" name="languages[]" value="' . $this->transposh->options->default_language . '" />' 
     
    516519        echo '</ul></div>'; 
    517520        // list of languages 
    518         echo '<div style="overflow:auto; clear: both;"><h3>'; 
    519         echo __('Available Languages (Click to toggle language state - Drag to sort in the widget)', TRANSPOSH_TEXT_DOMAIN); 
    520         echo '</h3><ul id="sortable">'; 
     521        echo '<div style="overflow:auto; clear: both;">'; 
     522        $this->header(__('Available Languages (Click to toggle language state - Drag to sort in the widget)', TRANSPOSH_TEXT_DOMAIN)); 
     523        echo '<ul id="sortable">'; 
    521524        foreach ($this->transposh->options->get_sorted_langs() as $langcode => $langrecord) { 
    522525            list ($langname, $langorigname, $flag) = explode(",", $langrecord); 
     
    554557        $this->contains_settings = true; 
    555558 
    556         echo '<h2>' . __('Translation related settings', TRANSPOSH_TEXT_DOMAIN) . '</h2>'; 
    557         echo '<div class="col-wrap">'; 
     559        $this->section(__('Translation related settings', TRANSPOSH_TEXT_DOMAIN), ''); 
     560 
    558561        /* 
    559562         * Insert permissions section in the admin page 
    560563         */ 
    561         echo '<h3>' . __('Who can translate ?', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     564        $this->header(__('Who can translate ?', TRANSPOSH_TEXT_DOMAIN)); 
    562565        //display known roles and their permission to translate 
    563566        foreach ($GLOBALS['wp_roles']->get_names() as $role_name => $something) { 
     
    568571        echo '<input id="tr_anon" type="checkbox" value="1" name="anonymous" ' . checked($this->can_translate('anonymous'), true, false) . '/> ' . __('Anonymous', TRANSPOSH_TEXT_DOMAIN); 
    569572 
    570         /* 
    571          * Insert the option to enable/disable default language translation. 
    572          * Disabled by default. 
    573          */ 
    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)); 
    575  
    576         /** 
    577          * Insert the option to enable search in translated languages 
    578          * Enabled by default. 
    579          * @since 0.3.6 
    580          */ 
    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)); 
    582  
    583  
    584         /** 
    585          * Insert the option to enable gettext integration 
    586          * Enabled by default. 
    587          * @since 0.6.4 
    588          */ 
    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)); 
    590  
    591         /** 
    592          * Insert the option to enable default locale override 
    593          * Enabled by default. 
    594          * @since 0.7.5 
    595          */ 
    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)); 
    597         echo '</div>'; 
    598         echo '<h2>' . __('General settings', TRANSPOSH_TEXT_DOMAIN) . '</h2>'; 
    599         echo '<div class="col-wrap">'; 
    600         /* 
    601          * Insert the option to enable/disable rewrite of perlmalinks. 
    602          * When disabled only parameters will be used to identify the current language. 
    603          */ 
    604         $this->checkbox($this->transposh->options->enable_permalinks_o, __('Rewrite URLs', TRANSPOSH_TEXT_DOMAIN), __('Rewrite URLs to be search engine friendly, ' . 
     573        $this->checkbox($this->transposh->options->enable_default_translate_o, __('Enable default language translation', TRANSPOSH_TEXT_DOMAIN) 
     574                , __('Allow translation of default language - useful for sites with more than one major language', TRANSPOSH_TEXT_DOMAIN)); 
     575        $this->checkbox($this->transposh->options->enable_search_translate_o, __('Enable search in translated languages', TRANSPOSH_TEXT_DOMAIN) 
     576                , __('Allow search of translated languages (and the original language)', TRANSPOSH_TEXT_DOMAIN)); 
     577        $this->checkbox($this->transposh->options->transposh_gettext_integration_o, __('Enable gettext integration', TRANSPOSH_TEXT_DOMAIN) 
     578                , __('Enable integration of Transposh with existing gettext interface (.po/.mo files)', TRANSPOSH_TEXT_DOMAIN)); 
     579 
     580        $this->checkbox($this->transposh->options->transposh_locale_override_o, __('Enable override for default locale', TRANSPOSH_TEXT_DOMAIN) 
     581                , __('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)); 
     582        $this->sectionstop(); 
     583 
     584        $this->section(__('General settings', TRANSPOSH_TEXT_DOMAIN), ''); 
     585        $this->checkbox($this->transposh->options->enable_permalinks_o, __('Rewrite URLs', TRANSPOSH_TEXT_DOMAIN) 
     586                , __('Rewrite URLs to be search engine friendly, ' . 
    605587                        'e.g.  (http://transposh.org/<strong>en</strong>). ' . 
    606588                        'Requires that permalinks will be enabled.', TRANSPOSH_TEXT_DOMAIN)); 
    607  
    608         /* 
    609          * Insert the option to enable/disable pushing of scripts to footer. 
    610          * Works on wordpress 2.8 and up (but we no longer care...) 
    611          */ 
    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. ' . 
     589        $this->checkbox($this->transposh->options->enable_footer_scripts_o, __('Add scripts to footer', TRANSPOSH_TEXT_DOMAIN) 
     590                , __('Push transposh scripts to footer of page instead of header, makes pages load faster. ' . 
    613591                        'Requires that your theme should have proper footer support.', TRANSPOSH_TEXT_DOMAIN)); 
    614  
    615         /** 
    616          * Insert the option to enable/disable language auto-detection 
    617          * @since 0.3.8 */ 
    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. ' . 
     592        $this->checkbox($this->transposh->options->enable_detect_redirect_o, __('Auto detect language for users', TRANSPOSH_TEXT_DOMAIN) 
     593                , __('This enables auto detection of language used by the user as defined in the ACCEPT_LANGUAGES they send. ' . 
    619594                        'This will redirect the first page accessed in the session to the same page with the detected language.', TRANSPOSH_TEXT_DOMAIN)); 
    620  
    621         /** 
    622          * Insert the option to enable/disable statics collection 
    623          * @since 0.7.6 */ 
    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)); 
     595        $this->checkbox($this->transposh->options->transposh_collect_stats_o, __('Allow collecting usage statistics', TRANSPOSH_TEXT_DOMAIN) 
     596                , __('This option enables collection of statistics by transposh that will be used to improve the product.', TRANSPOSH_TEXT_DOMAIN)); 
    625597 
    626598        /* WIP2 
    627599          echo '<a href="http://transposh.org/services/index.php?flags='.$flags.'">Gen sprites</a>'; */ 
    628         echo '</div>'; 
    629         echo '<h2>' . __('Backup service settings', TRANSPOSH_TEXT_DOMAIN) . '</h2>'; 
    630         echo '<div class="col-wrap">'; 
     600        $this->sectionstop(); 
     601 
     602        $this->section(__('Backup service settings', TRANSPOSH_TEXT_DOMAIN), ''); 
    631603        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/>'; 
    632604        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/>'; 
    633605        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/>'; 
    634606        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/>'; 
    635         echo '</div>'; 
     607        $this->sectionstop(); 
    636608    } 
    637609 
     
    639611        $this->contains_settings = true; 
    640612 
    641         echo '<h2>Automatic Translation Settings</h2>'; 
    642         echo '<div class="col-wrap">'; 
    643         /* 
    644          * Insert the option to enable/disable automatic translation. 
    645          * Enabled by default. 
    646          */ 
    647         $this->checkbox($this->transposh->options->enable_autotranslate_o, __('Enable automatic translation', TRANSPOSH_TEXT_DOMAIN), __('Allow automatic translation of pages', TRANSPOSH_TEXT_DOMAIN)); 
    648  
    649         /** 
    650          * Insert the option to enable/disable automatic translation upon publishing. 
    651          * Disabled by default. 
    652          *  @since 0.3.5 */ 
    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)); 
    654  
    655         /** 
    656          * Allow users to insert their own API keys 
    657          */ 
    658         echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/bingicon.png\"> " . __('MSN API key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     613        $this->section(__('Automatic Translation Settings', TRANSPOSH_TEXT_DOMAIN), ''); 
     614        $this->checkbox($this->transposh->options->enable_autotranslate_o, __('Enable automatic translation', TRANSPOSH_TEXT_DOMAIN) 
     615                , __('Allow automatic translation of pages', TRANSPOSH_TEXT_DOMAIN)); 
     616        $this->checkbox($this->transposh->options->enable_autoposttranslate_o, __('Enable automatic translation after posting', TRANSPOSH_TEXT_DOMAIN) 
     617                , __('Do automatic translation immediately after a post has been published', TRANSPOSH_TEXT_DOMAIN)); 
     618        $this->header("<img src=\"{$this->transposh->transposh_plugin_url}/img/bingicon.png\"> " . __('MSN API key', TRANSPOSH_TEXT_DOMAIN)); 
    659619        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->msn_key_o->post_value_id_name() . '/>'; 
    660  
    661         /** 
    662          * Allow users to insert their own API keys 
    663          */ 
    664         echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/googleicon.png\"> " . __('Google API key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     620        $this->header("<img src=\"{$this->transposh->transposh_plugin_url}/img/googleicon.png\"> " . __('Google API key', TRANSPOSH_TEXT_DOMAIN)); 
    665621        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->google_key_o->post_value_id_name() . '/>'; 
    666  
    667         /* 
    668          * Choose default translator... TODO (explain better in wiki) 
    669          */ 
    670         echo '<h3>' . __('Select preferred auto translation engine', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     622        $this->header(__('Select preferred auto translation engine', TRANSPOSH_TEXT_DOMAIN)); 
    671623        echo '<label for="' . $this->transposh->options->preferred_translator_o->get_name() . '">' . __('Translation engine:', TRANSPOSH_TEXT_DOMAIN) . 
    672624        '<select name="' . $this->transposh->options->preferred_translator_o->get_name() . '">' . 
     
    675627        '</select>' . 
    676628        '</label>'; 
    677         echo '</div>'; 
    678  
    679         echo '<h2>Professional Translation Settings</h2>'; 
    680         echo '<div class="col-wrap">'; 
    681  
    682         echo __('<a href="http://transposh.org/redir/oht">One Hour Translation</a>, is the largest professional translation service online, with thousands of business customers, including 57% of the Fortune 500 companies, and over 15000 translators worldwide.', TRANSPOSH_TEXT_DOMAIN); 
    683         echo '<br/>'; 
    684         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); 
    685         echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation account ID', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     629        $this->sectionstop(); 
     630 
     631        $this->section(__('Professional Translation Settings', TRANSPOSH_TEXT_DOMAIN), __('<a href="http://transposh.org/redir/oht">One Hour Translation</a>, is the largest professional translation service online, with thousands of business customers, including 57% of the Fortune 500 companies, and over 15000 translators worldwide.', TRANSPOSH_TEXT_DOMAIN) . 
     632                '<br/>' . 
     633                __('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)); 
     634 
     635 
     636        $this->header("<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation account ID', TRANSPOSH_TEXT_DOMAIN)); 
    686637        echo __('Account ID', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->oht_id_o->post_value_id_name() . '/>'; 
    687638 
     
    689640         * Allow users to insert their own API keys 
    690641         */ 
    691         echo '<h3>' . "<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation secret key', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     642        $this->header("<img src=\"{$this->transposh->transposh_plugin_url}/img/ohticon.png\"> " . __('One Hour Translation secret key', TRANSPOSH_TEXT_DOMAIN)); 
    692643        echo __('API Key', TRANSPOSH_TEXT_DOMAIN) . ': <input type="text" size="35" class="regular-text" ' . $this->transposh->options->oht_key_o->post_value_id_name() . '/>'; 
    693644 
     
    696647            $timeforevent = floor((max(array(wp_next_scheduled('transposh_oht_event') - time(), 0))) / 60); 
    697648            if ((max(array(wp_next_scheduled('transposh_oht_event') - time(), 0)))) { 
    698                 printf('<h3>' . __('%d Phrases currently queued for next job in ~%d minutes', TRANSPOSH_TEXT_DOMAIN) . '</h3>', sizeof($oht), $timeforevent); 
     649                $this->header(sprintf(__('%d phrases currently queued for next job in ~%d minutes', TRANSPOSH_TEXT_DOMAIN), sizeof($oht), $timeforevent)); 
    699650            } 
    700651        } 
    701652        $ohtp = get_option(TRANSPOSH_OPTIONS_OHT_PROJECTS, array()); 
    702653        if (!empty($ohtp)) { 
    703             printf('<h3>' . __('%d projects have been submitted and waiting for completion', TRANSPOSH_TEXT_DOMAIN) . '</h3>', sizeof($ohtp)); 
    704         } 
    705         echo '</div>'; 
     654            $this->header(sprintf(__('%d projects have been submitted and waiting for completion', TRANSPOSH_TEXT_DOMAIN), sizeof($ohtp))); 
     655        } 
     656        $this->sectionstop(); 
    706657    } 
    707658 
     
    709660        $this->contains_settings = true; 
    710661 
    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)); 
    716  
    717         echo '<h3>' . __('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN) . '</h3>'; 
     662        $this->checkbox($this->transposh->options->widget_progressbar_o, __('Show progress bar', TRANSPOSH_TEXT_DOMAIN) 
     663                , __('Show progress bar when a client triggers automatic translation', TRANSPOSH_TEXT_DOMAIN)); 
     664 
     665        $this->checkbox($this->transposh->options->widget_allow_set_deflang_o, __('Allow user to set current language as default', TRANSPOSH_TEXT_DOMAIN) 
     666                , __('Widget will allow setting this language as user default', TRANSPOSH_TEXT_DOMAIN)); 
     667 
     668        $this->checkbox($this->transposh->options->widget_remove_logo_o, __('Remove transposh logo (see <a href="http://transposh.org/logoterms">terms</a>)', TRANSPOSH_TEXT_DOMAIN) 
     669                , __('Transposh logo will not appear on widget', TRANSPOSH_TEXT_DOMAIN)); 
     670 
     671        $this->header(__('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN)); 
    718672        echo '<label for="' . $this->transposh->options->widget_theme_o->get_name() . '">' . __('Edit interface (and progress bar) theme:', TRANSPOSH_TEXT_DOMAIN) . 
    719673        '<select id="transposh-style" name="' . $this->transposh->options->widget_theme_o->get_name() . '">'; 
    720674        foreach (transposh_consts::$jqueryui_themes as $theme) { 
    721           //  $selected = ($this->transposh->options->widget_theme == $theme) ? ' selected="selected"' : ''; 
     675            //  $selected = ($this->transposh->options->widget_theme == $theme) ? ' selected="selected"' : ''; 
    722676            echo '<option value="' . $theme . '" ' . selected($this->transposh->options->widget_theme, $theme, false) . '>' . $theme . '</option>'; 
    723677        } 
     
    734688         */ 
    735689        $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)); 
     690 
     691        $this->section(__('Parser related settings',TRANSPOSH_TEXT_DOMAIN) 
     692                , __('This is extremely dangerous, will break your current translations, and might cause severe hickups, only proceed if you really know what you are doing.',TRANSPOSH_TEXT_DOMAIN)); 
     693        $this->checkbox($this->transposh->options->parser_dont_break_puncts_o, __('Disable punctuations break', TRANSPOSH_TEXT_DOMAIN) 
     694                , __('The parser will not break text into phrases when encountering punctuations such as dots', TRANSPOSH_TEXT_DOMAIN)); 
     695        $this->checkbox($this->transposh->options->parser_dont_break_numbers_o, __('Disable numbers break', TRANSPOSH_TEXT_DOMAIN) 
     696                , __('The parser will not break text into phrases when encountering numbers', TRANSPOSH_TEXT_DOMAIN)); 
     697        $this->checkbox($this->transposh->options->parser_dont_break_entities_o, __('Disable html entities break', TRANSPOSH_TEXT_DOMAIN) 
     698                , __('The parser will not break text into phrases when encountering html entities', TRANSPOSH_TEXT_DOMAIN)); 
     699        $this->sectionstop(); 
    736700    } 
    737701 
     
    849813    } 
    850814 
    851     /** 
    852      * uses a boolean expression to make checkboxes check 
    853      * @param boolean $eval 
    854      * @return string used for checkboxes 
    855      */ 
    856815    /** UTILITY FUNCTIONS * */ 
    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       } */ 
     816    private function section($head, $text) { 
     817        echo '<h2>' . $head . '</h2>'; 
     818        echo '<div class="col-wrap">'; 
     819        if (isset($text)) echo '<p>' . $text . '</p>'; 
     820    } 
     821 
     822    private function sectionstop() { 
     823        echo '</div>'; 
     824    } 
     825 
     826    private function header($head) { 
     827        echo '<h3>' . $head . '</h3>'; 
     828    } 
    865829 
    866830    /** 
     
    868832     */ 
    869833    private function checkbox($tpo, $head, $text) { 
    870         echo '<h3>' . $head . '</h3>'; 
     834        $this->header($head); 
    871835        echo '<input type="checkbox" value="1" name="' . $tpo->get_name() . '" ' . checked($tpo->get_value(), true, false) . '/> ' . $text; 
    872836    } 
    873837 
     838    /** UTILITY FUNCTIONS  END * */ 
    874839    function add_warning($id, $message) { 
    875840        if (!$this->transposh->options->get_transposh_admin_hide_warning($id)) { 
  • trunk/WordPress/plugin/transposh/wp/transposh_options.php

    r742 r743  
    136136 * @property boolean          $enable_url_translate          Option to enable/disable url translation @since 0.5.3 
    137137 * @property transposh_option $enable_url_translate_o 
     138 * @property boolean          $parser_dont_break_puncts      Option to allow punctuations such as , . ( not to break @since 0.9.0 
     139 * @property transposh_option $$parser_dont_break_puncts_o 
     140 * @property boolean          $parser_dont_break_numbers     Option to allow numbers not to break @since 0.9.0 
     141 * @property transposh_option $$parser_dont_break_numbers_o 
     142 * @property boolean          $parser_dont_break_entities    Option to allow html entities not to break @since 0.9.0 
     143 * @property transposh_option $$parser_dont_break_entities_o 
    138144 *  
    139145 * Hidden 
     
    223229 
    224230 
    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); 
     231        $this->register_option('widget_progressbar', TP_OPT_BOOLEAN, 0); 
     232        $this->register_option('widget_allow_set_deflang', TP_OPT_BOOLEAN, 0); 
     233        $this->register_option('widget_remove_logo', TP_OPT_BOOLEAN, 0); 
    228234        $this->register_option('widget_theme', TP_OPT_STRING, 'ui-lightness'); 
    229235 
    230         $this->register_option('enable_url_translate', TP_OPT_BOOLEAN); 
     236        $this->register_option('enable_url_translate', TP_OPT_BOOLEAN, 0); 
     237        $this->register_option('parser_dont_break_puncts', TP_OPT_BOOLEAN, 0); 
     238        $this->register_option('parser_dont_break_numbers', TP_OPT_BOOLEAN, 0); 
     239        $this->register_option('parser_dont_break_entities', TP_OPT_BOOLEAN, 0); 
    231240 
    232241        $this->register_option('transposh_admin_hide_warnings', TP_OPT_OTHER); 
  • trunk/WordPress/plugin/transposh/wp/transposh_widget.php

    r742 r743  
    280280        if (!empty($widget_args)) { 
    281281            // this is the set default language line 
    282             if ($this->transposh->options->get_widget_allow_set_default_language()) { 
     282            if ($this->transposh->options->widget_allow_set_deflang) { 
    283283                If ((isset($_COOKIE['TR_LNG']) && $_COOKIE['TR_LNG'] != $this->transposh->target_language) || (!isset($_COOKIE['TR_LNG']) && !$this->transposh->options->is_default_language($this->transposh->target_language))) { 
    284284                    echo '<a id="' . SPAN_PREFIX . 'setdeflang' . self::$draw_calls . '" class="' . SPAN_PREFIX . 'setdeflang' . '" onClick="return false;" href="' . admin_url('admin-ajax.php') . '?action=tp_cookie_bck">' . __('Set as default language', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'; 
     
    308308        $plugpath = parse_url($this->transposh->transposh_plugin_url, PHP_URL_PATH); 
    309309 
    310         if (!$this->transposh->options->get_widget_remove_logo()) { 
     310        if (!$this->transposh->options->widget_remove_logo) { 
    311311            $tagline = esc_attr__('Transposh', TRANSPOSH_TEXT_DOMAIN) . ' - '; 
    312312            switch (ord(md5($_SERVER['REQUEST_URI'])) % 5) { 
     
    335335 
    336336        echo '<div id="' . SPAN_PREFIX . 'credit' . self::$draw_calls . '">'; 
    337         if (!$this->transposh->options->get_widget_remove_logo()) { 
     337        if (!$this->transposh->options->widget_remove_logo) { 
    338338            echo 'by <a href="http://tran' . 'sposh.org/' . $extralang . '"><img height="16" width="16" src="' . 
    339339            $plugpath . '/img/tplog' . 'o.png" style="padding:1px;border:0px" title="' . $tagline . '" alt="' . $tagline . '"/></a>'; 
Note: See TracChangeset for help on using the changeset viewer.