Changeset 491
- Timestamp:
- 08/08/2010 03:42:53 AM (18 months ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 4 edited
-
js/transposhcontrol.js (modified) (3 diffs)
-
wp/transposh_admin.php (modified) (2 diffs)
-
wp/transposh_ajax.php (modified) (1 diff)
-
wp/transposh_db.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposhcontrol.js
r387 r491 121 121 }); 122 122 123 jQuery.ajaxSetup({ 124 cache: false 125 }); 126 123 127 // backup button 124 128 backupclick = function () { 125 jQuery("#transposh-backup"). click(function(){129 jQuery("#transposh-backup").unbind('click').click(function(){ 126 130 return false 127 }).text("Backup In Progress");128 jQuery.get(t_jp.post_url + "?backup =" + Math.random(),function(data) {131 }).text("Backup In Progress"); 132 jQuery.get(t_jp.post_url + "?backup",function(data) { 129 133 var color = 'red'; 130 134 if (data[0] == '2') color = 'green'; 131 135 jQuery('#backup_result').html(data).css('color',color); 132 jQuery("#transposh-backup"). click(backupclick).text("Do Backup Now");136 jQuery("#transposh-backup").unbind('click').click(backupclick).text("Do Backup Now"); 133 137 }); 134 138 return false; 135 139 }; 136 140 jQuery("#transposh-backup").click(backupclick); 141 142 // cleanup button 143 cleanautoclick = function (days,button) { 144 if (!confirm("Are you sure you want to do this?")) return false; 145 if (days == 0 && !confirm("Are you REALLY sure you want to do this?")) return false; 146 //var button = jQuery(this); 147 console.log(button); 148 var prevtext = button.text(); 149 button.unbind('click').click(function(){ 150 return false 151 }).text("Cleanup in progress"); 152 jQuery.get(t_jp.post_url + "?nonce="+button.attr('nonce')+"&days="+days+"&cleanup",function(data) { 153 button.unbind('click').click(function() { 154 cleanautoclick(days,button); 155 return false; 156 }).text(prevtext); 157 }); 158 return false; 159 }; 160 jQuery("#transposh-clean-auto").click(function() { 161 cleanautoclick(0,jQuery(this)); 162 return false; 163 }); 164 jQuery("#transposh-clean-auto14").click(function() { 165 cleanautoclick(14,jQuery(this)); 166 return false; 167 }); 137 168 138 169 // translate all button … … 181 212 }); 182 213 jQuery("#transposh-translate").text("Stop translate") 183 jQuery("#transposh-translate"). click(stop_translate);214 jQuery("#transposh-translate").unbind('click').click(stop_translate); 184 215 return false; 185 216 } … … 189 220 stop_translate_var = true; 190 221 jQuery("#transposh-translate").text("Translate All Now") 191 jQuery("#transposh-translate"). click(do_translate_all);222 jQuery("#transposh-translate").unbind('click').click(do_translate_all); 192 223 return false; 193 224 } -
trunk/WordPress/plugin/transposh/wp/transposh_admin.php
r488 r491 202 202 add_meta_box('transposh-contentbox-autotranslation', 'Automatic translation settings', array(&$this, 'on_contentbox_auto_translation_content'), $this->pagehook, 'normal', 'core'); 203 203 add_meta_box('transposh-contentbox-general', 'Generic settings', array(&$this, 'on_contentbox_generic_content'), $this->pagehook, 'normal', 'core'); 204 add_meta_box('transposh-contentbox-database', 'Database maintenance', array(&$this, 'on_contentbox_database_content'), $this->pagehook, 'normal', 'core'); 204 205 } 205 206 … … 535 536 } 536 537 538 function on_contentbox_database_content($data) { 539 /* 540 * Insert two buttons allowing removal of automated translations from database 541 */ 542 echo '<div style="margin:10px 0"><a id="transposh-clean-auto" href="#" nonce="'. wp_create_nonce('transposh-clean').'" class="button">Clean all automated translations</a></div>'; 543 echo '<div style="margin:10px 0"><a id="transposh-clean-auto14" href="#" nonce="'. wp_create_nonce('transposh-clean').'" class="button">Clean automated translations older than 14 days</a></div>'; 544 } 545 537 546 function on_contentbox_community_content($data) { 538 547 echo '<h4>Backup service for human translation</h4>'; -
trunk/WordPress/plugin/transposh/wp/transposh_ajax.php
r488 r491 101 101 $my_transposh_plugin->run_backup(); 102 102 } 103 // Start cleanup on demand 104 elseif (isset($_GET['cleanup'])) { 105 // just make sure the admin started this... recently enough 106 check_ajax_referer('transposh-clean','nonce'); 107 $my_transposh_plugin->database->cleanup($_GET['days']); 108 } 109 103 110 ?> -
trunk/WordPress/plugin/transposh/wp/transposh_db.php
r488 r491 488 488 } 489 489 490 /** 491 * Provides some stats about our database 492 */ 490 493 function db_stats() { 491 494 echo "<h4>Database stats</h4>"; … … 558 561 } 559 562 563 /** 564 * This function removes translations and translation logs from the database, only 565 * when the last translation is automated 566 * @param int $days 567 */ 568 function cleanup($days = 0) { 569 $days = intval($days); // some security 570 $cleanup = 'DELETE ' . $GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE . ' ,' . $GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG . 571 ' FROM ' . $GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE . 572 ' INNER JOIN '. $GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG. 573 ' ON '.$GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE .'.original = '.$GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG .'.original'. 574 ' AND '.$GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE .'.lang = '.$GLOBALS['wpdb']->prefix . TRANSLATIONS_LOG .'.lang'. 575 ' WHERE '. $GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE.'.source > 0'. 576 " AND timestamp < SUBDATE(NOW(),$days)"; 577 apc_clear_cache('user'); // clean up cache so that results will actually show 578 $result = $GLOBALS['wpdb']->query($cleanup); 579 exit; 580 } 581 560 582 } 561 583 ?>
Note: See TracChangeset
for help on using the changeset viewer.
