Changeset 6681
- Timestamp:
- 09/07/2017 08:24:05 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
-
bbpress.php (modified) (1 diff)
-
includes/admin/assets/css/admin.css (modified) (2 diffs)
-
includes/admin/assets/js/converter.js (modified) (3 diffs)
-
includes/admin/classes/class-bbp-converter-base.php (modified) (10 diffs)
-
includes/admin/classes/class-bbp-converter.php (modified) (25 diffs)
-
includes/admin/settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bbpress.php
r6677 r6681 204 204 /** Versions **********************************************************/ 205 205 206 $this->version = '2.6-rc-66 77';206 $this->version = '2.6-rc-6682'; 207 207 $this->db_version = '262'; 208 208 -
trunk/src/includes/admin/assets/css/admin.css
r6677 r6681 429 429 /* Converter */ 430 430 431 #bbp-converter-monitor h2 { 432 position: relative; 433 } 434 431 435 #bbp-converter-monitor .inside { 432 436 margin-bottom: 0; … … 468 472 text-align: right; 469 473 font-weight: 600; 474 } 475 476 div.bbp-converter-log .output { 477 margin: 0 5px; 478 } 479 480 div.bbp-converter-log .mini-step { 481 padding: 3px 5px; 482 vertical-align: middle; 483 font-size: 8px; 484 font-weight: 600; 485 border-radius: 6px; 486 background-color: #aaa; 487 color: white; 488 } 489 490 #bbp-converter-monitor .bbp-progress-bar { 491 position: absolute; 492 left: 0; 493 height: 1px; 494 width: 0; 495 background-color: #00b9eb; 496 transition-property: width; 497 transition-timing-function: ease-out; 498 transition-duration: 1s; 499 } 500 501 #bbp-converter-monitor #bbp-converter-step-percentage { 502 bottom: 1px; 503 } 504 505 #bbp-converter-monitor #bbp-converter-total-percentage { 506 bottom: 0; 470 507 } 471 508 -
trunk/src/includes/admin/assets/js/converter.js
r6677 r6681 12 12 settings = $( '#bbp-converter-settings' ), 13 13 password = $( '#_bbp_converter_db_pass' ), 14 toggle = $( '.bbp-db-pass-toggle' ); 14 toggle = $( '.bbp-db-pass-toggle' ), 15 step_p = $( '#bbp-converter-step-percentage' ), 16 total_p = $( '#bbp-converter-total-percentage' ); 15 17 16 18 /** … … 156 158 // Do the step 157 159 bbp_converter_log( data.progress ); 160 bbp_converter_percentages( data.step_percent, data.total_percent ); 158 161 bbp_converter_status( data ); 159 162 bbp_converter_wait(); … … 318 321 message.prepend( text ); 319 322 } 323 324 /** 325 * Prepend some text to the import monitor 326 * 327 * @since 2.6.0 bbPress (r6470) 328 * 329 * @returns {void} 330 */ 331 function bbp_converter_percentages( step_percent, total_percent ) { 332 step_p.width( step_percent + '%' ); 333 total_p.width( total_percent + '%' ); 334 } 320 335 } ); -
trunk/src/includes/admin/classes/class-bbp-converter-base.php
r6679 r6681 414 414 // We have a $from_tablename, so we want to get some data to convert 415 415 if ( ! empty( $from_tablename ) ) { 416 417 // Update rows 418 $this->count_rows_by_table( "{$this->opdb->prefix}{$from_tablename}" ); 416 419 417 420 // Get some data from the old forums … … 663 666 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_forum_parent_id' ); 664 667 665 foreach ( $this-> get_results( $query ) as $row ) {668 foreach ( $this->count_rows_by_results( $query ) as $row ) { 666 669 $parent_id = $this->callback_forumid( $row->meta_value ); 667 670 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->posts} SET post_parent = %d WHERE ID = %d LIMIT 1", $parent_id, $row->value_id ) ); … … 683 686 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'sticky' ); 684 687 685 foreach ( $this-> get_results( $query ) as $row ) {688 foreach ( $this->count_rows_by_results( $query ) as $row ) { 686 689 bbp_stick_topic( $row->value_id ); 687 690 $has_update = true; … … 702 705 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_sticky_status_id', 'super-sticky' ); 703 706 704 foreach ( $this-> get_results( $query ) as $row ) {707 foreach ( $this->count_rows_by_results( $query ) as $row ) { 705 708 $super = true; 706 709 bbp_stick_topic( $row->value_id, $super ); … … 722 725 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s LIMIT {$start}, {$this->max_rows}", '_bbp_old_closed_status_id', 'closed' ); 723 726 724 foreach ( $this-> get_results( $query ) as $row ) {727 foreach ( $this->count_rows_by_results( $query ) as $row ) { 725 728 bbp_close_topic( $row->value_id ); 726 729 $has_update = true; … … 741 744 : $this->wpdb->prepare( "SELECT post_id AS value_id, meta_value FROM {$this->wpdb->postmeta} WHERE meta_key = %s AND meta_value > 0 LIMIT {$start}, {$this->max_rows}", '_bbp_old_reply_to_id' ); 742 745 743 foreach ( $this-> get_results( $query ) as $row ) {746 foreach ( $this->count_rows_by_results( $query ) as $row ) { 744 747 $reply_to = $this->callback_reply_to( $row->meta_value ); 745 748 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND post_id = %d LIMIT 1", $reply_to, '_bbp_reply_to', $row->value_id ) ); … … 777 780 } 778 781 779 foreach ( $this-> get_results( $query ) as $row ) {782 foreach ( $this->count_rows_by_results( $query ) as $row ) { 780 783 $anonymous_topic_author_id = 0; 781 784 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->posts} SET post_author = %d WHERE ID = %d LIMIT 1", $anonymous_topic_author_id, $row->topic_id ) ); … … 816 819 } 817 820 818 foreach ( $this-> get_results( $query ) as $row ) {821 foreach ( $this->count_rows_by_results( $query ) as $row ) { 819 822 $anonymous_reply_author_id = 0; 820 823 $this->query( $this->wpdb->prepare( "UPDATE {$this->wpdb->posts} SET post_author = %d WHERE ID = %d LIMIT 1", $anonymous_reply_author_id, $row->reply_id ) ); … … 891 894 892 895 if ( ! empty( $converted ) ) { 893 894 896 foreach ( $converted as $value ) { 895 897 if ( is_serialized( $value['meta_value'] ) ) { … … 990 992 } 991 993 994 /** 995 * Update the number of rows in the current step 996 * 997 * @since 2.6.0 bbPress (r6637) 998 * 999 * @param string $query The literal MySQL query 1000 * @return bool 1001 */ 1002 private function count_rows_by_results( $query = '' ) { 1003 $results = $this->get_results( $query ); 1004 1005 update_option( '_bbp_converter_rows_in_step', count( $results ) ); 1006 1007 return $results; 1008 } 1009 1010 /** 1011 * Update the number of rows in the current step 1012 * 1013 * @since 2.6.0 bbPress (r6637) 1014 * 1015 * @param string $table_name The literal MySQL query 1016 * @return bool 1017 */ 1018 private function count_rows_by_table( $table_name = '' ) { 1019 $count = (int) $this->opdb->get_var( "SELECT COUNT(*) FROM {$table_name}" ); 1020 1021 return update_option( '_bbp_converter_rows_in_step', $count ); 1022 } 1023 992 1024 /** Callbacks *************************************************************/ 993 1025 -
trunk/src/includes/admin/classes/class-bbp-converter.php
r6666 r6681 43 43 */ 44 44 public $max_steps = 17; 45 46 /** 47 * @var int Number of rows in the current step 48 */ 49 public $rows_in_step = 0; 50 51 /** 52 * @var int Percent complete of current step 53 */ 54 public $step_percentage = 0; 55 56 /** 57 * @var int Percent complete of all step 58 */ 59 public $total_percentage = 0; 45 60 46 61 /** … … 133 148 // UI State 134 149 'state' => array( 135 'delay' => (int) get_option( '_bbp_converter_delay_time', 2 ), 136 'started' => (bool) get_option( '_bbp_converter_step', 0 ), 137 'running' => false, 138 'status' => false 150 'delay' => (int) get_option( '_bbp_converter_delay_time', 2 ), 151 'started' => (bool) get_option( '_bbp_converter_step', 0 ), 152 'running' => false, 153 'status' => false, 154 'step_percent' => $this->step_percentage, 155 'total_percent' => $this->total_percentage 139 156 ), 140 157 … … 195 212 private function converter_response( $output = '' ) { 196 213 214 // Sanitize output 215 $output = wp_kses_data( $output ); 216 197 217 // Maybe prepend the step 198 $ output= ! empty( $this->step )199 ? sprintf( '<span class="step">%s :</span> %s', $this->step, $output)218 $progress = ! empty( $this->step ) 219 ? sprintf( '<span class="step">%s.</span><span class="output">%s</span><span class="mini-step">%s</span>', $this->step, $output, $this->step_percentage . '%' ) 200 220 : $output; 201 221 202 222 // Output 203 223 wp_send_json_success( array( 204 'query' => get_option( '_bbp_converter_query', '' ), 205 'current_step' => $this->step, 206 'final_step' => $this->max_steps, 207 'progress' => $output 224 'query' => get_option( '_bbp_converter_query', '' ), 225 'current_step' => $this->step, 226 'final_step' => $this->max_steps, 227 'rows_in_step' => $this->rows_in_step, 228 'step_percent' => $this->step_percentage, 229 'total_percent' => $this->total_percentage, 230 'progress' => $progress 208 231 ) ); 209 232 } … … 232 255 // Save step and count so that it can be restarted. 233 256 if ( ! get_option( '_bbp_converter_step' ) || ! empty( $_POST['_bbp_converter_restart'] ) ) { 234 $this->step = 1; 235 $this->start = 0; 257 $this->step = 1; 258 $this->start = 0; 259 $this->step_percentage = 0; 260 $this->total_percentage = 0; 261 $this->rows_in_step = 0; 236 262 $this->maybe_update_options(); 237 263 } … … 249 275 250 276 // Step & Start 251 '_bbp_converter_step' => $this->step, 252 '_bbp_converter_start' => $this->start, 277 '_bbp_converter_step' => $this->step, 278 '_bbp_converter_start' => $this->start, 279 '_bbp_converter_rows_in_step' => $this->rows_in_step, 253 280 254 281 // Halt … … 317 344 318 345 // Set starting point & rows 319 $this->step = (int) get_option( '_bbp_converter_step', 1 ); 320 $this->start = (int) get_option( '_bbp_converter_start', 0 ); 321 $this->rows = (int) get_option( '_bbp_converter_rows', 100 ); 346 $this->step = (int) get_option( '_bbp_converter_step', 1 ); 347 $this->start = (int) get_option( '_bbp_converter_start', 0 ); 348 $this->rows = (int) get_option( '_bbp_converter_rows', 100 ); 349 $this->rows_in_step = (int) get_option( '_bbp_converter_rows_in_step', 0 ); 322 350 323 351 // Set boundaries 324 $this->max = ( $this->start + $this->rows ) - 1;352 $this->max = ( $this->start + $this->rows ) - 1; 325 353 326 354 // Set platform 327 $this->platform = get_option( '_bbp_converter_platform' ); 355 $this->platform = get_option( '_bbp_converter_platform' ); 356 357 // Total percentage 358 $this->total_percentage = round( ( $this->step / $this->max_steps ) * 100, 2 ); 359 360 // Total mini steps 361 if ( $this->rows_in_step > 0 ) { 362 $total_mini_steps = ceil( $this->rows_in_step / $this->rows ); 363 $current_mini_step = ceil( $this->start / $this->rows ); 364 $this->step_percentage = round( ( $current_mini_step / $total_mini_steps ) * 100, 2 ); 365 } else { 366 $this->step_percentage = 0; 367 } 328 368 329 369 // Maybe include the appropriate converter. … … 355 395 */ 356 396 private function reset() { 357 update_option( '_bbp_converter_step', 0 ); 358 update_option( '_bbp_converter_start', 0 ); 359 update_option( '_bbp_converter_query', '' ); 397 update_option( '_bbp_converter_step', 0 ); 398 update_option( '_bbp_converter_start', 0 ); 399 update_option( '_bbp_converter_rows_in_step', 0 ); 400 update_option( '_bbp_converter_query', '' ); 360 401 } 361 402 … … 376 417 377 418 // Update step and start at 0 378 update_option( '_bbp_converter_step', $step ); 379 update_option( '_bbp_converter_start', 0 ); 419 update_option( '_bbp_converter_step', $step ); 420 update_option( '_bbp_converter_start', 0 ); 421 update_option( '_bbp_converter_rows_in_step', 0 ); 380 422 } 381 423 … … 425 467 } else { 426 468 $this->bump_start(); 427 $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );469 $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step) ); 428 470 } 429 471 … … 451 493 } else { 452 494 $this->bump_start(); 453 $this->converter_response( sprintf( esc_html__( 'Converting users (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );495 $this->converter_response( sprintf( esc_html__( 'Converting users (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 454 496 } 455 497 } else { … … 474 516 } else { 475 517 $this->bump_start(); 476 $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );518 $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 477 519 } 478 520 } else { … … 496 538 } else { 497 539 $this->bump_start(); 498 $this->converter_response( sprintf( esc_html__( 'Converting forums (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );540 $this->converter_response( sprintf( esc_html__( 'Converting forums (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 499 541 } 500 542 } … … 514 556 } else { 515 557 $this->bump_start(); 516 $this->converter_response( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );558 $this->converter_response( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 517 559 } 518 560 } … … 532 574 } else { 533 575 $this->bump_start(); 534 $this->converter_response( sprintf( esc_html__( 'Converting forum subscriptions (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );576 $this->converter_response( sprintf( esc_html__( 'Converting forum subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 535 577 } 536 578 } … … 550 592 } else { 551 593 $this->bump_start(); 552 $this->converter_response( sprintf( esc_html__( 'Converting topics (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );594 $this->converter_response( sprintf( esc_html__( 'Converting topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 553 595 } 554 596 } … … 568 610 } else { 569 611 $this->bump_start(); 570 $this->converter_response( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );612 $this->converter_response( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 571 613 } 572 614 } … … 586 628 } else { 587 629 $this->bump_start(); 588 $this->converter_response( sprintf( esc_html__( 'Calculating topic stickies (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );630 $this->converter_response( sprintf( esc_html__( 'Calculating topic stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 589 631 } 590 632 } … … 604 646 } else { 605 647 $this->bump_start(); 606 $this->converter_response( sprintf( esc_html__( 'Calculating topic super stickies (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );648 $this->converter_response( sprintf( esc_html__( 'Calculating topic super stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 607 649 } 608 650 } … … 622 664 } else { 623 665 $this->bump_start(); 624 $this->converter_response( sprintf( esc_html__( 'Calculating closed topics (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );666 $this->converter_response( sprintf( esc_html__( 'Calculating closed topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 625 667 } 626 668 } … … 640 682 } else { 641 683 $this->bump_start(); 642 $this->converter_response( sprintf( esc_html__( 'Converting topic tags (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );684 $this->converter_response( sprintf( esc_html__( 'Converting topic tags (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 643 685 } 644 686 } … … 658 700 } else { 659 701 $this->bump_start(); 660 $this->converter_response( sprintf( esc_html__( 'Converting topic subscriptions (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );702 $this->converter_response( sprintf( esc_html__( 'Converting topic subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 661 703 } 662 704 } … … 676 718 } else { 677 719 $this->bump_start(); 678 $this->converter_response( sprintf( esc_html__( 'Converting favorites (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );720 $this->converter_response( sprintf( esc_html__( 'Converting favorites (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 679 721 } 680 722 } … … 694 736 } else { 695 737 $this->bump_start(); 696 $this->converter_response( sprintf( esc_html__( 'Converting replies (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );738 $this->converter_response( sprintf( esc_html__( 'Converting replies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 697 739 } 698 740 } … … 712 754 } else { 713 755 $this->bump_start(); 714 $this->converter_response( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );756 $this->converter_response( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 715 757 } 716 758 } … … 730 772 } else { 731 773 $this->bump_start(); 732 $this->converter_response( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s - %2$s)', 'bbpress' ), $this->start, $this->max) );774 $this->converter_response( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 733 775 } 734 776 } -
trunk/src/includes/admin/settings.php
r6678 r6681 1806 1806 <span><?php esc_html_e( 'Import Monitor', 'bbpress' ); ?></span> 1807 1807 <span id="bbp-converter-status"><?php echo esc_html( $status_text ); ?></span> 1808 <span id="bbp-converter-step-percentage" class="bbp-progress-bar"></span> 1809 <span id="bbp-converter-total-percentage" class="bbp-progress-bar"></span> 1808 1810 </h2> 1809 1811 <div class="inside">
Note: See TracChangeset
for help on using the changeset viewer.