progress_ui() public method

Show progress_ui.
public progress_ui ( float $progress, boolean $echo = true ) : string
$progress float
$echo boolean
return string $progress_ui
示例#1
0
 public function usage_widget()
 {
     $usage_details = get_site_option('rtmedia-encoding-usage');
     $content = '';
     if ($usage_details && isset($usage_details[$this->api_key]->status) && $usage_details[$this->api_key]->status) {
         if (isset($usage_details[$this->api_key]->plan->name)) {
             $content .= '<p><strong>' . __('Current Plan', 'buddypress-media') . ':</strong> ' . $usage_details[$this->api_key]->plan->name . ($usage_details[$this->api_key]->sub_status ? '' : ' (' . __('Unsubscribed', 'buddypress-media') . ')') . '</p>';
         }
         if (isset($usage_details[$this->api_key]->used)) {
             $content .= '<p><span class="encoding-used"></span><strong>' . __('Used', 'buddypress-media') . ':</strong> ' . (($used_size = size_format($usage_details[$this->api_key]->used, 2)) ? $used_size : '0MB') . '</p>';
         }
         if (isset($usage_details[$this->api_key]->remaining)) {
             $content .= '<p><span class="encoding-remaining"></span><strong>' . __('Remaining', 'buddypress-media') . ':</strong> ' . (($remaining_size = size_format($usage_details[$this->api_key]->remaining, 2)) ? $remaining_size : '0MB') . '</p>';
         }
         if (isset($usage_details[$this->api_key]->total)) {
             $content .= '<p><strong>' . __('Total', 'buddypress-media') . ':</strong> ' . size_format($usage_details[$this->api_key]->total, 2) . '</p>';
         }
         $usage = new rtProgress();
         $content .= $usage->progress_ui($usage->progress($usage_details[$this->api_key]->used, $usage_details[$this->api_key]->total), false);
         if ($usage_details[$this->api_key]->remaining <= 0) {
             $content .= '<div class="error below-h2"><p>' . __('Your usage limit has been reached. Upgrade your plan.', 'buddypress-media') . '</p></div>';
         }
     } else {
         $content .= '<div class="error below-h2"><p>' . __('Your API key is not valid or is expired.', 'buddypress-media') . '</p></div>';
     }
     new RTMediaAdminWidget('rtmedia-encoding-usage', __('Encoding Usage', 'buddypress-media'), $content);
 }
    function init()
    {
        $prog = new rtProgress();
        $pending = $this->get_pending_count();
        $total = $this->get_total_count();
        $done = $total - $pending;
        ?>
		<div class="wrap">
			<h2>rtMedia: Import Media Size</h2>
			<?php 
        wp_nonce_field('rtmedia_media_size_import_nonce', 'rtmedia_media_size_import_nonce');
        echo '<span class="pending">' . rtmedia_migrate_formatseconds($total - $done) . ' (estimated)</span><br />';
        echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
        echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
        $temp = $prog->progress($done, $total);
        $prog->progress_ui($temp, true);
        ?>
			<script type="text/javascript">
				var fail_id = new Array();
				var ajax_data;
				jQuery( document ).ready( function ( e ) {
					jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-has-current-submenu" )
					jQuery( "#toplevel_page_rtmedia-settings" ).removeClass( "wp-not-current-submenu" )
					jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-menu-open" )
					jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-menu-open" )
					jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-has-current-submenu" )
					if ( db_total < 1 )
						jQuery( "#submit" ).attr( 'disabled', "disabled" );
				} )
				function db_start_migration( db_done, db_total, last_id ) {

					if ( db_done < db_total ) {
						jQuery( "#rtMediaSyncing" ).show();
						ajax_data = {
							"action": "rtmedia_media_size_import",
							"done": db_done,
							"last_id": last_id,
							"nonce" : jQuery.trim( jQuery( '#rtmedia_media_size_import_nonce' ).val() )
						}
						jQuery.ajax( {
							url: rtmedia_admin_ajax,
							type: 'post',
							data: ajax_data,
							success: function ( sdata ) {

								try {
									data = JSON.parse( sdata );
								} catch ( e ) {
									jQuery( "#submit" ).attr( 'disabled', "" );
								}
								if ( data.status ) {
									done = parseInt( data.done );
									total = parseInt( data.total );
									var progw = Math.ceil( (done / total) * 100 );
									if ( progw > 100 ) {
										progw = 100;
									}
									;
									jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
									jQuery( 'span.finished' ).html( done );
									jQuery( 'span.total' ).html( total );
									jQuery( 'span.pending' ).html( data.pending );
									if ( data.imported === false ) {
										fail_id.push( data.media_id );
									}
									db_start_migration( done, total, parseInt( data.media_id ) );
								} else {
									alert( "Migration completed." );
									jQuery( "#rtMediaSyncing" ).hide();
								}
							},
							error: function () {
								alert( "Error During Migration, Please Refresh Page then try again" );
								jQuery( "#submit" ).removeAttr( 'disabled' );
							}
						} );
					} else {
						alert( "Migration completed." );
						if ( fail_id.length > 0 ) {
							rtm_show_file_error();
						}
						jQuery( "#rtMediaSyncing" ).hide();
					}
				}
				function rtm_show_file_error() {
					jQuery( 'span.pending' ).html( "Media with ID: " + fail_id.join( ', ' ) + " can not be imported. Please check your server error log for more details. Don't worry, you can end importing media size now :)" );
		//			var data = {action: 'rtmedia_hide_media_size_import_notice'};
		//			jQuery.post( ajaxurl, data, function ( response ) { } );
		//			jQuery( "#rtMediaSyncing" ).hide();
				}
				var db_done = <?php 
        echo $done;
        ?>
;
				var db_total = <?php 
        echo $total;
        ?>
;
				jQuery( document ).on( 'click', '#submit', function ( e ) {
					e.preventDefault();
					db_start_migration( db_done, db_total, 0 );
					jQuery( this ).attr( 'disabled', 'disabled' );
				} );
			</script>
			<hr/>
			<?php 
        if (!(isset($rtmedia_error) && true === $rtmedia_error)) {
            ?>
				<input type="button" id="submit" value="start" class="button button-primary"/>
			<?php 
        }
        ?>
		</div>
	<?php 
    }
示例#3
0
        /**
         * Define regenerate thumbnail functionality.
         *
         * @access public
         *
         * @param  void
         *
         * @return void
         */
        public function rt_regenerate_thumbnail()
        {
            $prog = new rtProgress();
            $done = 0;
            ?>
			<div class="wrap">
				<h2> rtMedia: <?php 
            esc_html_e('Regenerate Video Thumbnails', 'buddypress-media');
            ?>
 </h2>
				<?php 
            if (isset($_REQUEST['media_ids']) && trim($_REQUEST['media_ids']) != '') {
                $requested = false;
                $media_ids = explode(',', $_REQUEST['media_ids']);
                $total = count($media_ids);
            } else {
                $media_ids = $this->get_video_without_thumbs();
                $total = count($media_ids);
            }
            ?>
				<script>
					var rt_thumb_all_media = <?php 
            echo json_encode($media_ids);
            ?>
;
				</script>
				<?php 
            if (!isset($requested)) {
                ?>
					<br/>
					<p>You can see this page because you have <a href="<?php 
                echo esc_url(admin_url('admin.php?page=rtmedia-addons'));
                ?>
">subscribed</a> for <a href="https://rtcamp.com/rtmedia/docs/admin/addons/audio-video-encoding/" target="_blank">rtMedia audio/video encoding service</a>.</p> <p>You can regenerate thumbnails of a specific video by visiting <a href="<?php 
                echo esc_url(admin_url('upload.php?post_mime_type=video'));
                ?>
">media page</a> and clicking the <b>Regenerate Thumbnail</b> option for that particular video.</p> <p>Click <b>Regenerate Pending Thumbnails</b> to regenerate thumbnails of pending videos.</p> <p><input type="button" class="button button-primary" id="rt-start-media-regenerate" value="<?php 
                echo esc_html__('Regenerate Pending Thumbnails', 'buddypress-media') . ' (' . $total . ')';
                ?>
"/> </p>
					<?php 
            }
            ?>
				<div id="rt-migration-progress">
					<br/> <br/>
					<?php 
            $temp = $prog->progress($done, $total);
            $prog->progress_ui($temp, true);
            ?>
					<p> <?php 
            esc_html_e('Total Videos', 'buddypress-media');
            ?>
 : <span class='rt-total'><?php 
            echo esc_html($total);
            ?>
</span>
					</p>

					<p> <?php 
            esc_html_e('Sent of regenerate thumbails', 'buddypress-media');
            ?>
 : <span class='rt-done'>0</span></p>

					<p> <?php 
            esc_html_e('Fail to regenerate thumbails', 'buddypress-media');
            ?>
 : <span class='rt-fail'>0</span></p>

				</div>
				<script>

					var db_done = 0;
					var db_fail = 0;
					var db_total = <?php 
            echo esc_html($total);
            ?>
;
					var indx = 0;
					function db_start_regenrate() {
						if ( indx < db_total ) {
							jQuery.ajax( {
								url: rtmedia_admin_ajax,
								type: 'post',
								data: {
									"action": "rt_media_regeneration",
									"media_id": rt_thumb_all_media[indx ++]
								},
								success: function ( data ) {
									data = JSON.parse( data );

									if ( data.status == false ) {
										handle_regenrate_fail();
									} else {
										db_done ++;
										var progw = Math.ceil( ( db_done / db_total ) * 100 );
										if ( progw > 100 ) {
											progw = 100;
										}
										jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
										jQuery( 'span.rt-done' ).html( db_done );
										db_start_regenrate();
									}
								},
								error: function () {
									handle_regenrate_fail();
								}
							} );
						} else {
							alert( "<?php 
            esc_html_e('Regenerate Video Thumbnails Done', 'buddypress-media');
            ?>
" );
						}
					}
					function handle_regenrate_fail() {
						db_fail ++;
						jQuery( 'span.rt-fail' ).html( db_fail );
						db_start_regenrate();
					}
					if ( jQuery( "#rt-start-media-regenerate" ).length > 0 ) {
						jQuery( "#rt-migration-progress" ).hide()
						jQuery( "#rt-start-media-regenerate" ).click( function () {
							jQuery( this ).hide();
							jQuery( "#rt-migration-progress" ).show()
							db_start_regenrate();
						} )
					} else {
						db_start_regenrate();
					}

				</script>


			</div> <?php 
        }
    function test()
    {
        if (!$this->table_exists($this->bmp_table)) {
            $obj = new RTDBUpdate(false, RTMEDIA_PATH . 'index.php', RTMEDIA_PATH . 'app/schema/', true);
            $obj->install_db_version = '0';
            $obj->do_upgrade(true);
        }
        global $rtmedia_error;
        if (isset($rtmedia_error) && true === $rtmedia_error) {
            ?>
			<div class="error"><p> Please Resolve create database error before migration.</p></div>
		<?php 
        }
        $prog = new rtProgress();
        $total = $this->get_total_count();
        $done = $this->get_done_count();
        if ($done >= $total) {
            $done = $total;
        } else {
            ?>
			<div class="error">
				<p><?php 
            _e('Please Backup your <strong>DATABASE</strong> and <strong>UPLOAD</strong> folder before Migration.', 'buddypress-media');
            ?>
</p>
			</div>
		<?php 
        }
        ?>

		<div class="wrap">

			<h2><?php 
        _e('rtMedia Migration', 'buddypress-media');
        ?>
</h2>

			<h3><?php 
        _e('It will migrate following things', 'buddypress-media');
        ?>
 </h3>
			User Albums : <?php 
        echo $_SESSION['migration_user_album'];
        ?>
<br/>
			<?php 
        if (isset($_SESSION['migration_group_album'])) {
            ?>
				Groups Albums : <?php 
            echo $_SESSION['migration_group_album'];
            ?>
<br/>
			<?php 
        }
        ?>
			Media : <?php 
        echo $_SESSION['migration_media'];
        ?>
<br/>
			<?php 
        if (isset($_SESSION['migration_activity'])) {
            ?>
				Comments : <?php 
            echo $_SESSION['migration_activity'];
            ?>
<br/>
			<?php 
        }
        ?>
			<hr/>

			<?php 
        echo '<span class="pending">' . $this->formatSeconds($total - $done) . '</span><br />';
        echo '<span class="finished">' . $done . '</span>/<span class="total">' . $total . '</span>';
        echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
        $temp = $prog->progress($done, $total);
        $prog->progress_ui($temp, true);
        ?>
			<script type="text/javascript">
				jQuery( document ).ready( function ( e ) {
					jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-has-current-submenu" )
					jQuery( "#toplevel_page_rtmedia-settings" ).removeClass( "wp-not-current-submenu" )
					jQuery( "#toplevel_page_rtmedia-settings" ).addClass( "wp-menu-open" )
					jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-menu-open" )
					jQuery( "#toplevel_page_rtmedia-settings>a" ).addClass( "wp-has-current-submenu" )

					if ( db_total < 1 )
						jQuery( "#submit" ).attr( 'disabled', "disabled" );
				} )
				function db_start_migration( db_done, db_total ) {


					if ( db_done < db_total ) {
						jQuery( "#rtMediaSyncing" ).show();
						jQuery.ajax( {
							url: rtmedia_admin_ajax,
							type: 'post',
							data: {
								"action": "bp_media_rt_db_migration",
								"done": db_done
							},
							success: function ( sdata ) {

								try {
									data = JSON.parse( sdata );
								} catch ( e ) {
									jQuery( "#submit" ).attr( 'disabled', "" );
								}
								if ( data.status ) {
									done = parseInt( data.done );
									total = parseInt( data.total );
									var progw = Math.ceil( (done / total) * 100 );
									if ( progw > 100 ) {
										progw = 100;
									}
									;
									jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
									jQuery( 'span.finished' ).html( done );
									jQuery( 'span.total' ).html( total );
									jQuery( 'span.pending' ).html( data.pending );
									db_start_migration( done, total );
								} else {
									alert( "Migration completed." );
									jQuery( "#rtMediaSyncing" ).hide();
								}
							},
							error: function () {
								alert( "<?php 
        _e('Error During Migration, Please Refresh Page then try again', 'buddypress-media');
        ?>
" );
								jQuery( "#submit" ).removeAttr( 'disabled' );
							}
						} );
					} else {
						alert( "Migration completed." );
						jQuery( "#rtMediaSyncing" ).hide();
					}
				}
				var db_done = <?php 
        echo $done;
        ?>
;
				var db_total = <?php 
        echo $total;
        ?>
;
				jQuery( document ).on( 'click', '#submit', function ( e ) {
					e.preventDefault();

					db_start_migration( db_done, db_total );
					jQuery( this ).attr( 'disabled', 'disabled' );
				} );
			</script>
			<hr/>
			<?php 
        if (!(isset($rtmedia_error) && true === $rtmedia_error)) {
            ?>
				<input type="button" id="submit" value="<?php 
            esc_attr_e('Start', 'buddypress-media');
            ?>
"
					   class="button button-primary"/>
			<?php 
        }
        ?>

		</div>
	<?php 
    }
 /**
  *
  * @param array $instance An array with the name to be used for id and the progress percentage
  * @return string The progress ui html
  */
 function progress_ui($instance = array())
 {
     $progress = new rtProgress();
     $instance = wp_parse_args($instance, array('name' => 'general', 'progress' => 0));
     $ui = '<div class="rt-wufoo-progress" id="' . $instance['name'] . '">' . $progress->progress_ui($instance['progress'], false) . '</div>';
     return $ui;
 }
示例#6
0
    function init()
    {
        $prog = new rtProgress();
        $pending = $this->get_pending_count();
        $total = $this->get_total_count();
        $last_id = $this->get_last_imported();
        $done = $total - $pending;
        $admin_ajax = admin_url('admin-ajax.php');
        ?>
		<div class="wrap">
			<h2><?php 
        esc_html_e('rtMedia: Upgrade rtMedia activity', 'buddypress-media');
        ?>
</h2>
			<?php 
        wp_nonce_field('rtmedia_media_activity_upgrade_nonce', 'rtmedia_media_activity_upgrade_nonce');
        echo '<span class="pending">' . sprintf(esc_html__('%s (estimated)', 'buddypress-media'), esc_html(rtmedia_migrate_formatseconds($total - $done))) . '</span><br />';
        echo '<span class="finished">' . esc_html($done) . '</span>/<span class="total">' . esc_html($total) . '</span>';
        echo '<img src="images/loading.gif" alt="syncing" id="rtMediaSyncing" style="display:none" />';
        $temp = $prog->progress($done, $total);
        $prog->progress_ui($temp, true);
        ?>
			<style type="text/css">
				#rtprogressbar {
					background-color: #444;
					border-radius: 13px;
					margin-bottom: 10px;
					padding: 3px;
				}

				#rtprogressbar div {
					background-color: #fb6003;
					border-radius: 10px;
					height: 20px;
					width: 0;
				}
			</style>
			<script type="text/javascript">
				var fail_id = new Array();
				var ajax_data;
				jQuery(document).ready(function (e) {
					jQuery("#toplevel_page_rtmedia-settings").addClass("wp-has-current-submenu")
					jQuery("#toplevel_page_rtmedia-settings").removeClass("wp-not-current-submenu")
					jQuery("#toplevel_page_rtmedia-settings").addClass("wp-menu-open")
					jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-menu-open")
					jQuery("#toplevel_page_rtmedia-settings>a").addClass("wp-has-current-submenu")
					if (db_total < 1)
						jQuery("#submit").attr('disabled', "disabled");
				});
				function db_start_migration(db_done, db_total, last_id) {

					if (db_done < db_total) {
						jQuery("#rtMediaSyncing").show();
						ajax_data = {
							"action": "rtmedia_activity_upgrade",
							"done": db_done,
							"last_id": last_id,
							"nonce": jQuery.trim(jQuery('#rtmedia_media_activity_upgrade_nonce').val())
						};
						jQuery.ajax({
							url: '<?php 
        echo esc_url($admin_ajax);
        ?>
',
							type: 'post',
							data: ajax_data,
							success: function (sdata) {

								try {
									data = JSON.parse(sdata);
								} catch (e) {
									jQuery("#submit").attr('disabled', "");
								}
								if (data.status) {
									done = parseInt(data.done);
									total = parseInt(data.total);
									var progw = Math.ceil((done / total) * 100);
									if (progw > 100) {
										progw = 100;
									}
									jQuery('#rtprogressbar>div').css('width', progw + '%');
									jQuery('span.finished').html(done);
									jQuery('span.total').html(total);
									jQuery('span.pending').html(data.pending);
									if (data.imported === false) {
										fail_id.push(data.activity_id);
									}
									db_start_migration(done, total, parseInt(data.activity_id));
								} else {
									alert("Migration completed.");
									jQuery("#rtMediaSyncing").hide();
								}
							},
							error: function () {
								alert("Error During Migration, Please Refresh Page then try again");
								jQuery("#submit").removeAttr('disabled');
							}
						});
					} else {
						data = {
							action: 'rtmedia_activity_done_upgrade'
						};
						jQuery.post('<?php 
        echo esc_sql($admin_ajax);
        ?>
', data, function () {
							alert("Database upgrade completed.");
						});
						if (fail_id.length > 0) {
							rtm_show_file_error();
						}
						jQuery("#rtMediaSyncing").hide();
					}
				}
				function rtm_show_file_error() {
					jQuery('span.pending').html("Some activities are failed to upgrade, Don't worry about that.");
				}
				var db_done = <?php 
        echo esc_js($done);
        ?>
;
				var db_total = <?php 
        echo esc_js($total);
        ?>
;
				var last_id = <?php 
        echo esc_js($last_id);
        ?>
;
				jQuery(document).on('click', '#submit', function (e) {
					e.preventDefault();
					db_start_migration(db_done, db_total, last_id);
					jQuery(this).attr('disabled', 'disabled');
				});
			</script>
			<hr/>
			<?php 
        if (!(isset($rtmedia_error) && true === $rtmedia_error)) {
            ?>
				<input type="button" id="submit" value="start" class="button button-primary"/>
			<?php 
        }
        ?>
		</div>
		<?php 
    }
        function rt_regenerate_thumbnail()
        {
            $prog = new rtProgress();
            $done = 0;
            ?>
			<div class="wrap">
				<h2> <?php 
            _e('Regenerate Video Thumbnails', 'rtmedia');
            ?>
 </h2>
				<?php 
            if (isset($_REQUEST["media_ids"]) && trim($_REQUEST["media_ids"]) != "") {
                $requested = false;
                $media_ids = explode(',', $_REQUEST["media_ids"]);
                $total = count($media_ids);
            } else {
                $media_ids = $this->get_video_without_thumbs();
                $total = count($media_ids);
            }
            ?>
				<script>
					var rt_thumb_all_media = <?php 
            echo json_encode($media_ids);
            ?>
;
				</script>
				<?php 
            if (!isset($requested)) {
                ?>
					<br/> <br/>
					<input type="button" class="button button-primary" id="rt-start-media-regenerate"
						   value="<?php 
                _e('Regenerate Pending Thumbnails', 'rtmedia');
                ?>
"/>
				<?php 
            }
            ?>
				<div id="rt-migration-progress">
					<br/> <br/>
					<?php 
            $temp = $prog->progress($done, $total);
            $prog->progress_ui($temp, true);
            ?>
					<p> <?php 
            _e('Total Videos', 'rtmedia');
            ?>
 : <span class='rt-total'><?php 
            echo $total;
            ?>
</span>
					</p>

					<p> <?php 
            _e('Sent of regenerate thumbails', 'rtmedia');
            ?>
 : <span class='rt-done'>0</span></p>

					<p> <?php 
            _e('Fail to regenerate thumbails', 'rtmedia');
            ?>
 : <span class='rt-fail'>0</span></p>

				</div>
				<?php 
            ?>
				<script>

					var db_done = 0;
					var db_fail = 0;
					var db_total = <?php 
            echo $total;
            ?>
;
					var indx = 0;
					function db_start_regenrate() {
						if ( indx < db_total ) {
							jQuery.ajax( {
								url: rtmedia_admin_ajax,
								type: 'post',
								data: {
									"action": "rt_media_regeneration",
									"media_id": rt_thumb_all_media[indx++]
								},
								success: function ( data ) {
									data = JSON.parse( data );

									if ( data.status == false ) {
										handle_regenrate_fail();
									} else {
										db_done++;
										var progw = Math.ceil( (db_done / db_total) * 100 );
										if ( progw > 100 ) {
											progw = 100;
										}
										jQuery( '#rtprogressbar>div' ).css( 'width', progw + '%' );
										jQuery( 'span.rt-done' ).html( db_done );
										db_start_regenrate();
									}
								},
								error: function () {
									handle_regenrate_fail();
								}
							} );
						} else {
							alert( "<?php 
            _e('Regenerate Video Thumbnails Done', 'rtmedia');
            ?>
" );
						}
					}
					function handle_regenrate_fail() {
						db_fail++;
						jQuery( 'span.rt-fail' ).html( db_fail );
						db_start_regenrate();
					}
					if ( jQuery( "#rt-start-media-regenerate" ).length > 0 ) {
						jQuery( "#rt-migration-progress" ).hide()
						jQuery( "#rt-start-media-regenerate" ).click( function () {
							jQuery( this ).hide();
							jQuery( "#rt-migration-progress" ).show()
							db_start_regenrate();
						} )
					} else {
						db_start_regenrate();
					}

				</script>


			</div> <?php 
        }