Changeset 753
- Timestamp:
- 12/08/2012 03:29:13 AM (5 months ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 8 edited
-
css/admin.css (modified) (2 diffs)
-
js/admin/languages.js (modified) (4 diffs)
-
transposh.php (modified) (10 diffs)
-
wp/transposh_admin.php (modified) (8 diffs)
-
wp/transposh_db.php (modified) (4 diffs)
-
wp/transposh_options.php (modified) (3 diffs)
-
wp/transposh_postpublish.php (modified) (1 diff)
-
wp/transposh_widget.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/css/admin.css
r752 r753 1 1 /* 2 Document : admin 3 Created on : 24/11/2012, 04:12:31 4 Author : root 5 Description: 6 Purpose of the stylesheet follows. 2 Document : admin.css 3 Created on : 24/11/2012 4 Description: Style sheet for admin pages 7 5 */ 8 6 9 7 #icon-transposh-logo { 10 background: url( ../img/tplogo32.png) no-repeat;8 background: url('../img/tplogo32.png') no-repeat; 11 9 /*float: left;*/ 12 10 } … … 38 36 background: #FFE45C; 39 37 } 40 . active {38 .lng_active { 41 39 background: #45FF51; 42 }43 .translateable {44 background: #FFFF51;45 40 } 46 41 .hidden { -
trunk/WordPress/plugin/transposh/js/admin/languages.js
r752 r753 18 18 (function ($) { // closure 19 19 $(function() { 20 // clicking anonymous will make translatables active21 $("#tr_anon").click(function() {22 if ($("#tr_anon").attr("checked")) {23 $(".translateable").addClass("active").removeClass("translateable");24 $("#sortable .active").each(function () {25 $("input",this).val($(this).attr("id")+",v,t");26 })27 }28 $("#yellowcolor").toggleClass("hidden");29 });30 31 20 // makes the languages sortable, with placeholder, also prevent unneeded change after sort 32 21 $("#sortable").sortable({ … … 50 39 // enable all languages 51 40 $("#selectall").click(function(){ 52 $("#sortable .languages").addClass(" active").removeClass("translateable");53 $("#sortable . active").each(function () {54 $("input",this).val($(this).attr("id")+",v ,t");41 $("#sortable .languages").addClass("lng_active"); 42 $("#sortable .lng_active").each(function () { 43 $("input",this).val($(this).attr("id")+",v"); 55 44 }) 56 45 return false; … … 60 49 clickfunction = function () { 61 50 if ($(this).attr("id") == $("#default_list li").attr("id")) return; 62 if ($("#tr_anon").attr("checked")) { 63 $(this).toggleClass("active"); 64 } else { 65 if ($(this).hasClass("active")) { 66 $(this).removeClass("active"); 67 $(this).addClass("translateable") 68 } 69 else { 70 if ($(this).hasClass("translateable")) { 71 $(this).removeClass("translateable"); 72 } 73 else { 74 $(this).addClass("active") 75 } 76 } 77 } 51 $(this).toggleClass("lng_active"); 78 52 // set new value 79 $("input",this).val($(this).attr("id")+($(this).hasClass(" active") ? ",v":",")+($(this).hasClass("translateable") ? ",t":","));53 $("input",this).val($(this).attr("id")+($(this).hasClass("lng_active") ? ",v":",")); 80 54 } 81 55 $(".languages").dblclick(clickfunction).click(clickfunction); … … 87 61 drop: function(ev, ui) { 88 62 $("#default_list").empty(); 89 $(ui.draggable.clone().removeAttr("style").removeClass(" active").removeClass("translateable")).appendTo("#default_list").show("slow");63 $(ui.draggable.clone().removeAttr("style").removeClass("lng_active")).appendTo("#default_list").show("slow"); 90 64 $("#default_list .logoicon").remove(); 91 $("#sortable").find("#"+ui.draggable.attr("id")).addClass(" active");65 $("#sortable").find("#"+ui.draggable.attr("id")).addClass("lng_active"); 92 66 } 93 67 }); -
trunk/WordPress/plugin/transposh/transposh.php
r752 r753 148 148 tp_logger(preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), 4); // includes transposh dir and php 149 149 150 // TODO: get_class_methods to replace said mess, other way?150 // TODO: get_class_methods to replace said mess, other way? 151 151 add_filter('plugin_action_links_' . preg_replace('|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__), array(&$this, 'plugin_action_links')); 152 152 add_filter('query_vars', array(&$this, 'parameter_queryvars')); … … 222 222 // CHECK TODO!!!!!!!!!!!! 223 223 $this->tgl = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 224 if (!$this->options->is_ viewable_language($this->tgl) && !$this->options->is_editable_language($this->tgl)) {224 if (!$this->options->is_active_language($this->tgl)) { 225 225 $this->tgl = ''; 226 226 } … … 503 503 // TODO TOCHECK!!!!!!!!!!!!!!!!!!!!!!!!!!1 504 504 $this->target_language = $this->tgl; 505 // avoid viewing of editable languages which are not viewable by non translators506 if (!$this->options->is_viewable_language($this->target_language) &&507 $this->options->is_editable_language($this->target_language) &&508 !$this->is_translator()) {509 $this->target_language = '';510 }511 505 if (!$this->target_language) 512 506 $this->target_language = $this->options->default_language; … … 813 807 return false; 814 808 815 return $this->options->is_ editable_language($this->target_language);809 return $this->options->is_active_language($this->target_language); 816 810 } 817 811 … … 831 825 return false; 832 826 833 return $this->options->is_ editable_language($this->target_language);827 return $this->options->is_active_language($this->target_language); 834 828 } 835 829 … … 1166 1160 function transposh_locale_filter($locale) { 1167 1161 $lang = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 1168 if (!$this->options->is_ viewable_language($lang)) {1162 if (!$this->options->is_active_language($lang)) { 1169 1163 $lang = ''; 1170 1164 } … … 1232 1226 } 1233 1227 1234 // Prox yed google translate suggestions1228 // Proxied google translate suggestions 1235 1229 function on_ajax_nopriv_tp_gsp() { 1236 1230 $i = 0; … … 1240 1234 $tl = $_GET['tl']; 1241 1235 // we want to avoid unneeded work or dos attacks on languages we don't support 1242 if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_ editable_language($tl))1236 if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) 1243 1237 return; 1244 1238 $sl = 'auto'; … … 1281 1275 } 1282 1276 1283 // Prox yed translation for google translate1277 // Proxied translation for google translate 1284 1278 function on_ajax_nopriv_tp_gp() { 1285 1279 // we need curl for this proxy … … 1289 1283 $tl = $_GET['tl']; 1290 1284 // we want to avoid unneeded work or dos attacks on languages we don't support 1291 if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_ editable_language($tl))1285 if (!in_array($tl, transposh_consts::$google_languages) || !$this->options->is_active_language($tl)) 1292 1286 return; 1293 1287 // source language -
trunk/WordPress/plugin/transposh/wp/transposh_admin.php
r752 r753 87 87 case 'tp_langs': 88 88 $viewable_langs = array(); 89 $editable_langs = array();90 89 91 90 tp_logger($_POST['anonymous']); 92 91 // first set the default language 93 list ($langcode, $viewable, $translateable) = explode(",", $_POST['languages'][0]);92 list ($langcode, ) = explode(",", $_POST['languages'][0]); 94 93 $this->transposh->options->default_language = $langcode; 95 94 unset($_POST['languages'][0]); … … 97 96 // update the list of supported/editable/sortable languages 98 97 tp_logger($_POST['languages']); 99 foreach ($_POST['languages'] as $ code => $lang) {100 list ($langcode, $viewable , $translateable) = explode(",", $lang);98 foreach ($_POST['languages'] as $lang) { 99 list ($langcode, $viewable) = explode(",", $lang); 101 100 $sorted_langs[$langcode] = $langcode; 102 101 if ($viewable) { 103 102 $viewable_langs[$langcode] = $langcode; 104 // force that every viewable lang is editable105 $editable_langs[$langcode] = $langcode;106 }107 108 if ($translateable) {109 $editable_langs[$langcode] = $langcode;110 103 } 111 104 } 112 105 113 106 $this->transposh->options->viewable_languages = implode(',', $viewable_langs); 114 $this->transposh->options->editable_languages = implode(',', $editable_langs);115 107 $this->transposh->options->sorted_languages = implode(',', $sorted_langs); 116 108 break; … … 189 181 '<p>' . __('For further help and assistance, please look at the following resources:', TRANSPOSH_TEXT_DOMAIN) . '</p>' . 190 182 '<a href="http://transposh.org/">' . __('Plugin homepage', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' . 191 '<a href="http://transposh.org/faq/">' . __('Frequently asked questions', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' .192 '<a href="http://trac.transposh.org/">' . __('Development website', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' ;183 '<a href="http://transposh.org/faq/">' . __('Frequently asked questions', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>' . 184 '<a href="http://trac.transposh.org/">' . __('Development website', TRANSPOSH_TEXT_DOMAIN) . '</a><br/>'; 193 185 return $text; 194 186 } … … 215 207 add_action('admin_print_scripts-' . $submenu_page, array(&$this, 'admin_print_scripts')); 216 208 } 217 218 209 } 219 210 // DOC … … 275 266 $this->localeright = 'left'; 276 267 } 277 268 278 269 // the followings are integrations with the wordpress admin interface 279 270 $screen = get_current_screen(); … … 359 350 360 351 echo '<div class="clear"></div>'; 361 362 352 } 363 353 … … 395 385 tp_logger($langcode, 5); 396 386 list ($langname, $langorigname, $flag) = explode(",", $langrecord); 397 echo '<li id="' . $langcode . '" class="languages ' . ($this->transposh->options->is_ viewable_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "active" : "")398 . (!$this->transposh->options->is_viewable_language($langcode) && $this->transposh->options->is_editable_language($langcode) ? "translateable" : "") .'"><div style="float:' . $this->localeleft . '">'387 echo '<li id="' . $langcode . '" class="languages ' . ($this->transposh->options->is_active_language($langcode) || $this->transposh->options->is_default_language($langcode) ? "lng_active" : "") 388 . '"><div style="float:' . $this->localeleft . '">' 399 389 . transposh_utils::display_flag("{$this->transposh->transposh_plugin_url}/img/flags", $flag, false /* $langorigname,$this->transposh->options->get_widget_css_flags() */) 400 390 // DOC THIS BUGBUG fix! 401 . '<input type="hidden" name="languages[]" value="' . $langcode . ($this->transposh->options->is_ viewable_language($langcode) ? ",v" : ",") . ($this->transposh->options->is_editable_language($langcode) ? ",t" : ",") . '" />'391 . '<input type="hidden" name="languages[]" value="' . $langcode . ($this->transposh->options->is_active_language($langcode) ? ",v" : ",") . '" />' 402 392 . ' <span class="langname">' . $langorigname . '</span><span class="langname hidden">' . $langname . '</span></div>'; 403 393 if (in_array($langcode, transposh_consts::$google_languages)) … … 420 410 echo '<li><a href="#" id="sortname">' . __('Sort by language name', TRANSPOSH_TEXT_DOMAIN) . '</a></li>'; 421 411 echo '<li><a href="#" id="sortiso">' . __('Sort by lSO code', TRANSPOSH_TEXT_DOMAIN) . '</a></li></ul>'; 422 echo __('Legend:', TRANSPOSH_TEXT_DOMAIN) . ' ' . __('Green - active', TRANSPOSH_TEXT_DOMAIN) . ', <span id="yellowcolor"' . ($this->transposh->options->allow_anonymous_translation ? ' class ="hidden"' : '') . '>' . __('Yellow - translateable (only translators will see this language)', TRANSPOSH_TEXT_DOMAIN) . ', </span>' . __('blank - inactive', TRANSPOSH_TEXT_DOMAIN);423 412 echo '</div>'; 424 413 } -
trunk/WordPress/plugin/transposh/wp/transposh_db.php
r745 r753 198 198 } 199 199 // make sure $lang is reasonable, unless someone is messing with us, it will be ok 200 if (!($this->transposh->options->is_ editable_language($lang))) return;200 if (!($this->transposh->options->is_active_language($lang))) return; 201 201 202 202 // If we have nothing, we will do nothing … … 239 239 } else { 240 240 // make sure $lang is reasonable, unless someone is messing with us, it will be ok 241 if (!($this->transposh->options->is_editable_language($lang))) 242 return; 241 if (!($this->transposh->options->is_active_language($lang))) return; 243 242 $query = "SELECT * FROM {$this->translation_table} WHERE original = '$original' and lang = '$lang' "; 244 243 $row = $GLOBALS['wpdb']->get_row($query); … … 324 323 for ($i = 0; $i < $items; $i++) { 325 324 if (isset($_POST["ln$i"])) { 326 if (!$this->transposh->options->is_ editable_language($_POST["ln$i"])) {325 if (!$this->transposh->options->is_active_language($_POST["ln$i"])) { 327 326 $all_editable = false; 328 327 break; … … 478 477 // Check permissions, first the lanugage must be on the edit list. Then either the user 479 478 // is a translator or automatic translation if it is enabled. 480 if (!($this->transposh->options->is_ editable_language($lang) && $this->transposh->is_translator())) {479 if (!($this->transposh->options->is_active_language($lang) && $this->transposh->is_translator())) { 481 480 tp_logger("Unauthorized history request " . $_SERVER['REMOTE_ADDR'], 1); 482 481 header('HTTP/1.0 401 Unauthorized history'); -
trunk/WordPress/plugin/transposh/wp/transposh_options.php
r752 r753 73 73 * @property string $viewable_languages Option defining the list of currently viewable languages 74 74 * @property transposh_option $viewable_languages_o 75 * @property string $editable_languages Option defining the list of currently editable languages76 * @property transposh_option $editable_languages_o77 75 * @property string $sorted_languages Option defining the ordered list of languages @since 0.3.9 78 76 * @property transposh_option $sorted_languages_o … … 212 210 $this->register_option('default_language', TP_OPT_STRING); // default? 213 211 $this->register_option('viewable_languages', TP_OPT_STRING); 214 $this->register_option('editable_languages', TP_OPT_STRING);215 212 $this->register_option('sorted_languages', TP_OPT_STRING); 216 213 … … 318 315 319 316 /** 320 * Determine if the given language in on the list of editable languages 321 * @return boolean Is this language editable? 322 */ 323 function is_editable_language($language) { 324 if ($this->is_default_language($language)) return true; 325 return (strpos($this->editable_languages . ',', $language . ',') !== false); 326 } 327 328 /** 329 * Determine if the given language in on the list of viewable languages 317 * Determine if the given language in on the list of active languages 330 318 * @return boolean Is this language viewable? 331 319 */ 332 function is_ viewable_language($language) {320 function is_active_language($language) { 333 321 if ($this->is_default_language($language)) return true; 334 322 return (strpos($this->viewable_languages . ',', $language . ',') !== false); -
trunk/WordPress/plugin/transposh/wp/transposh_postpublish.php
r752 r753 146 146 147 147 foreach ($phrases as $key) { 148 foreach (explode(',', $this->transposh->options-> editable_languages) as $lang) {148 foreach (explode(',', $this->transposh->options->viewable_languages) as $lang) { 149 149 // if this isn't the default language or we specifically allow default language translation, we will seek this out... 150 150 // as we don't normally want to auto-translate the default language -FIX THIS to include only correct stuff, how? -
trunk/WordPress/plugin/transposh/wp/transposh_widget.php
r745 r753 214 214 list ($langname, $language, $flag) = explode(',', $langrecord); 215 215 216 // Only send languages which are viewable or (editable and the user is a translator) 217 if ($this->transposh->options->is_viewable_language($code) || 218 ($this->transposh->options->is_editable_language($code) && $this->transposh->is_translator()) || 216 // Only send languages which are active 217 if ($this->transposh->options->is_active_language($code) || 219 218 ($this->transposh->options->is_default_language($code))) { 220 219 // now we alway do this... maybe cache this to APC/Memcache
Note: See TracChangeset
for help on using the changeset viewer.
