Changeset 142
- Timestamp:
- 03/30/2009 10:07:47 PM (3 years ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 2 edited
-
core/parser.php (modified) (6 diffs)
-
transposh_db.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/core/parser.php
r140 r142 566 566 567 567 //Don't break on ` so for our use we don't consider it an entity 568 //e.g. Jack`s apple. 569 //Exception: don't break when we there is a white space after the apostrophe. e.g. `uncategorized` 570 if(($entity == "’" || $entity == "'" || $entity == "'") 568 //e.g. Jack`s apple. 569 //Exception: don't break when we there is a white space after the apostrophe. e.g. `uncategorized` 570 if(($entity == "’" || $entity == "'" || $entity == "'") 571 571 && $page[$end_pos + 1] != " ") 572 572 { … … 577 577 $is_breaker = TRUE; 578 578 } 579 579 580 580 581 581 //It is an html entity. … … 738 738 { 739 739 logger("Enter " . __METHOD__ . " : $start", 4); 740 global $page, $pos ;740 global $page, $pos, $lang; 741 741 742 742 //trim white space from the start position going forward … … 765 765 } 766 766 767 list($translated_text, $source) = fetch_translation($original_text );767 list($translated_text, $source) = fetch_translation($original_text, $lang); 768 768 769 769 insert_translation($original_text, $translated_text, $source, $start, $end); … … 905 905 $use_params = !$enable_permalinks_rewrite; 906 906 907 //Allow specific override for url rewriting . 907 //Allow specific override for url rewriting . 908 908 if($enable_permalinks_rewrite && function_exists('is_url_excluded_from_permalink_rewrite') && 909 909 is_url_excluded_from_permalink_rewrite($href)) … … 911 911 $use_params = TRUE; 912 912 } 913 913 914 914 $href = rewrite_url_lang_param($href, $lang, $is_edit_mode, $use_params); 915 915 -
trunk/WordPress/plugin/transposh/transposh_db.php
r141 r142 47 47 * Will return NULL if no translation is available. 48 48 */ 49 function fetch_translation($original )50 { 51 global $wpdb , $lang;49 function fetch_translation($original, $lang) 50 { 51 global $wpdb; 52 52 $translated = NULL; 53 53 logger("Enter " . __METHOD__ . ": $original", 4); … … 91 91 if($rc === TRUE) 92 92 { 93 logger("Stored in cache: $original => $translated", 3);93 logger("Stored in cache: $original => {$translated[0]},{$translated[1]}", 3); 94 94 } 95 95 } … … 112 112 $source = $_POST['source']; 113 113 114 logger("Enter " . __FILE__ . " Params: $original , $translation, $lang, " . $ref, 3);114 logger("Enter " . __FILE__ . " Params: $original , $translation, $lang, $ref", 3); 115 115 if(!isset($original) || !isset($translation) || !isset($lang)) 116 116 { … … 118 118 return; 119 119 } 120 121 //add our own custom header - so we will know that we got here 122 header("Transposh: version_". DB_VERSION); 123 120 121 $table_name = $wpdb->prefix . TRANSLATIONS_TABLE; 122 123 //Decode & remove already escaped character to avoid double escaping 124 $translation = $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translation)))); 125 126 //The original content is encoded as base64 before it is sent (i.e. token), after we 127 //decode it should just the same after it was parsed. 128 $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8')); 129 130 //add our own custom header - so we will know that we got here 131 header("Transposh: ver-<%VERSION%> db_version-". DB_VERSION); 132 133 list($translated_text, $old_source) = fetch_translation($original, $lang); 134 if ($translated_text) { 135 if ($source == 1) { 136 logger("Warning " . __METHOD__ . " auto-translation for already translated: $original", 0); 137 return; 138 } 139 if ($translation == $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translated_text)))) && $old_source == $source) { 140 logger("Warning " . __METHOD__ . " attempt to retranslate with same text: $original, $translation", 0); 141 return; 142 } 143 } 144 124 145 //Check permissions, first the lanugage must be on the edit list. Then either the user 125 //is a translator or automatic translation if it is enabled. 126 if(!(is_editable_lang($lang) && 146 //is a translator or automatic translation if it is enabled. 147 if(!(is_editable_lang($lang) && 127 148 (is_translator() || ($source == 1 && get_option(ENABLE_AUTO_TRANSLATE))))) 128 149 { … … 131 152 exit; 132 153 } 133 134 $table_name = $wpdb->prefix . TRANSLATIONS_TABLE;135 136 //Decode & remove already escaped character to avoid double escaping137 $translation = $wpdb->escape(htmlspecialchars(stripslashes(urldecode($translation))));138 139 //The original content is encoded as base64 before it is sent (i.e. token), after we140 //decode it should just the same after it was parsed.141 $original = $wpdb->escape(html_entity_decode($original, ENT_NOQUOTES, 'UTF-8'));142 154 143 155 $update = "REPLACE INTO $table_name (original, translated, lang, source)
Note: See TracChangeset
for help on using the changeset viewer.
