Changeset 387
- Timestamp:
- 03/19/2010 02:07:09 AM (23 months ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 1 added
- 6 edited
-
js/transposhcontrol.js (modified) (1 diff)
-
transposh.php (modified) (3 diffs)
-
wp/transposh_admin.php (modified) (3 diffs)
-
wp/transposh_ajax.php (modified) (1 diff)
-
wp/transposh_backup.php (added)
-
wp/transposh_db.php (modified) (2 diffs)
-
wp/transposh_options.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposhcontrol.js
r386 r387 122 122 123 123 // backup button 124 jQuery("#transposh-backup").click(function () { 125 jQuery.get(t_jp.post_url + "?backup=" + Math.random()); 124 backupclick = function () { 125 jQuery("#transposh-backup").click(function(){ 126 return false 127 }).text("Backup In Progress"); 128 jQuery.get(t_jp.post_url + "?backup=" + Math.random(),function(data) { 129 var color = 'red'; 130 if (data[0] == '2') color = 'green'; 131 jQuery('#backup_result').html(data).css('color',color); 132 jQuery("#transposh-backup").click(backupclick).text("Do Backup Now"); 133 }); 126 134 return false; 127 }); 135 }; 136 jQuery("#transposh-backup").click(backupclick); 128 137 129 138 // translate all button -
trunk/WordPress/plugin/transposh/transposh.php
r374 r387 44 44 require_once("wp/transposh_options.php"); 45 45 require_once("wp/transposh_postpublish.php"); 46 require_once("wp/transposh_backup.php"); 46 47 47 48 /** … … 118 119 // add_action('wp_head', array(&$this,'add_transposh_async')); 119 120 add_action("sm_addurl",array(&$this,'add_sm_transposh_urls')); 121 add_action('transposh_backup_event', array(&$this,'run_backup')); 122 120 123 register_activation_hook(__FILE__, array(&$this,'plugin_activate')); 121 124 register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate')); … … 701 704 } 702 705 } 706 707 /** 708 * Runs a scheduled backup 709 */ 710 function run_backup() { 711 logger ("backup run.."); 712 $my_transposh_backup = new transposh_backup($this); 713 $my_transposh_backup->do_backup(); 714 } 703 715 } 716 704 717 $my_transposh_plugin = new transposh_plugin(); 705 718 -
trunk/WordPress/plugin/transposh/wp/transposh_admin.php
r386 r387 119 119 $this->transposh->options->set_preferred_translator($_POST[PREFERRED_TRANSLATOR]); 120 120 $this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]); 121 $this->transposh->options->set_transposh_key($_POST[TRANSPOSH_KEY]); 122 123 // handle change of schedule for backup to daily 124 if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] != $this->transposh->options->get_transposh_backup_schedule()) { 125 wp_clear_scheduled_hook('transposh_backup_event'); 126 if ($_POST[TRANSPOSH_BACKUP_SCHEDULE] == 1) 127 wp_schedule_event(time(), 'daily', 'transposh_backup_event'); 128 } 129 $this->transposh->options->set_transposh_backup_schedule($_POST[TRANSPOSH_BACKUP_SCHEDULE]); 130 121 131 $this->transposh->options->update_options(); 122 132 } … … 201 211 //add a 3rd content box now for demonstration purpose, boxes added at start of page rendering can't be switched on/off, 202 212 //may be needed to ensure that a special box is always available 203 add_meta_box('transposh-contentbox-community', 'Transposh community features (upcoming)', array(&$this, 'on_contentbox_community_content'), $this->pagehook, 'normal', 'core');213 add_meta_box('transposh-contentbox-community', 'Transposh community features', array(&$this, 'on_contentbox_community_content'), $this->pagehook, 'normal', 'core'); 204 214 //define some data can be given to each metabox during rendering - not used now 205 215 //$data = array('My Data 1', 'My Data 2', 'Available Data 1'); … … 531 541 532 542 function on_contentbox_community_content($data) { 533 /* echo '<a tabindex="4" id="transposh-backup" href="/wp-admin/post-new.php?preview=true" class="button">Do Backup Now</a><br/>'; 534 // echo "<p id=\"backup\">Do backup.</p>"; 535 echo 'Service Key: <input type="text" size="32" class="regular-text" value="'.$this->transposh->options->get_transposh_key().'" id="'.TRANSPOSH_KEY.'" name="'.TRANSPOSH_KEY.'"/>'; 536 echo ' 537 <script type="text/javascript"> 538 //<![CDATA[ 539 jQuery(document).ready( function($) { 540 // close postboxes that should be closed 541 $("#backup").click(function () { 542 $.get("'.$this->transposh->post_url.'?backup=" + Math.random()); 543 //alert ("hi"); 544 }); 545 }); 546 //]]> 547 </script>';*/ 548 echo "<p>This space is reserved for the coming community features of Transposh that will help you find translators to help with your site.</p>"; 543 echo '<h4>Backup service for human translation</h4>'; 544 echo '<input type="radio" value="1" name="'.TRANSPOSH_BACKUP_SCHEDULE.'" '. $this->checked($this->transposh->options->get_transposh_backup_schedule() == 1) . '/>Enable daily backup<br/>'; 545 echo '<input type="radio" value="2" name="'.TRANSPOSH_BACKUP_SCHEDULE.'" '. $this->checked($this->transposh->options->get_transposh_backup_schedule() == 2) . '/>Enable live backup<br/>'; 546 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)<br/>'; 547 echo 'Service Key: <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?</a><br/>'; 548 echo '<div id="backup_result"></div>'; 549 echo '<div style="margin:10px 0"><a id="transposh-backup" href="#" class="button">Do Backup Now</a></div>'; 549 550 } 550 551 } -
trunk/WordPress/plugin/transposh/wp/transposh_ajax.php
r386 r387 90 90 } 91 91 // Start backup on demand 92 /*elseif (isset($_GET['backup'])) { 93 $my_transposh_backup = new transposh_backup($my_transposh_plugin); 94 $my_transposh_backup->do_backup(); 95 }*/ 92 elseif (isset($_GET['backup'])) { 93 $my_transposh_plugin->run_backup(); 94 } 96 95 97 96 ?> -
trunk/WordPress/plugin/transposh/wp/transposh_db.php
r382 r387 172 172 $source = $_POST["sr$i"]; 173 173 } 174 174 // should we backup? 175 if ($source ==0) $backup_immidiate_possible = true; 175 176 176 177 //Here we check we are not redoing stuff 177 178 list($translated_text, $old_source) = $this->fetch_translation($original, $lang); 178 179 if ($translated_text) { 179 if ($source == 1) {180 if ($source > 0) { 180 181 logger("Warning auto-translation for already translated: $original $lang", 0); 181 182 continue; … … 220 221 logger("Error !!! failed to insert to db $original , $translation, $lang," , 0); 221 222 header("HTTP/1.0 404 Failed to update language database ".mysql_error()); 223 } 224 225 // Should we backup now? 226 if ($backup_immidiate_possible && $this->transposh->options->get_transposh_backup_schedule() == 2) { 227 $this->transposh->run_backup(); 222 228 } 223 229 // this is a termination for the ajax sequence -
trunk/WordPress/plugin/transposh/wp/transposh_options.php
r364 r387 85 85 //Allows user to set his default language per #63 @since 0.3.8 86 86 define("WIDGET_ALLOW_SET_DEFLANG", "widget_allow_set_deflang"); 87 //Stores the site key to transposh services (backup @since 0.5.0) 88 define("TRANSPOSH_KEY","transposh_key"); 89 //Stores the site key to transposh services (backup @since 0.5.0) 90 define("TRANSPOSH_BACKUP_SCHEDULE","transposh_backup_schedule"); 87 91 88 92 … … 248 252 } 249 253 254 function get_transposh_key() { 255 return $this->options[TRANSPOSH_KEY]; 256 } 257 258 function get_transposh_backup_schedule() { 259 return $this->options[TRANSPOSH_BACKUP_SCHEDULE]; 260 } 261 250 262 /** 251 263 * Sets a value at the options array … … 361 373 } 362 374 375 function set_transposh_key($val) { 376 $this->set_value($val, $this->options[TRANSPOSH_KEY]); 377 } 378 379 function set_transposh_backup_schedule($val) { 380 $this->set_value($val, $this->options[TRANSPOSH_BACKUP_SCHEDULE]); 381 } 382 363 383 /** 364 384 * Updates options at the wordpress options table if there was a change
Note: See TracChangeset
for help on using the changeset viewer.
