PluginProbe
FV Player 8 / 8.1
FV Player 8 v8.1
trunk 8.0.18 8.0.19 8.0.20 8.0.21 8.0.25 8.0.27 8.1 8.1.3
fv-player / models / migration-wizard.class.php

migration-wizard.class.php in FV Player 8 8.1, at models/migration-wizard.class.php

174 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 // TODO: These should only be loaded on the wizard screen
8 require_once( dirname(__FILE__).'/../includes/class.fv-player-wizard-base.php' );
9 require_once( dirname(__FILE__).'/../includes/class.fv-player-wizard-step-base.php' );
10
11 class FV_Player_Migration_Wizard extends FV_Player_Wizard_Base_Class {
12
13 static $instance = null;
14
15 private $dos_check_result = false;
16
17 public static function _get_instance() {
18 if( !self::$instance ) {
19 self::$instance = new self();
20 }
21
22 return self::$instance;
23 }
24
25 public function __construct() {
26
27 if ( ! defined( 'ABSPATH' ) ) {
28 exit;
29 }
30
31 parent::__construct( array(
32 'id' => 'fv_player_migration_wizard',
33 'page' => 'fv_player_migration',
34 'steps_path' => dirname(__FILE__).'/migration-wizard',
35 'title' => 'FV Player Migration Wizard'
36 ) );
37 }
38
39 public static function list_videos( $videos, $from, $to, $color ) {
40 ?>
41 <p>Videos found: <?php echo count($videos); ?></p>
42 <table class="wp-list-table widefat striped">
43 <thead>
44 <tr>
45 <td>Player ID</td>
46 <td>Video ID</td>
47 <td>URL</td>
48 <td>Alternative URL</td>
49 <td>Alternative URL 2</td>
50 <td>Splash</td>
51 <td>Mobile</td>
52 <td>RTMP</td>
53 <td>RTMP Path</td>
54 </tr>
55 </thead>
56 <?php foreach($videos as $video) : ?>
57 <tr>
58 <td><?php if( isset($video->player_id) ) echo intval( $video->player_id ) ?></td>
59 <td><?php echo intval( $video->id ) ?></td>
60 <?php foreach( array('src', 'src1', 'src2', 'splash', 'mobile', 'rtmp', 'rtmp_path' ) AS $field ) : ?>
61 <td><?php echo wp_kses( self::hilight( $video->$field, $from, $to, $color ), array( 'span' => array( 'style' => array() ) ) ); ?></td>
62 <?php endforeach; ?>
63 </tr>
64 <?php endforeach; ?>
65 </table>
66 <?php
67 }
68
69 public static function list_meta_data( $videos, $from, $to, $color ) {
70 ?>
71 <p>Video meta found: </p>
72 <table class="wp-list-table widefat striped">
73 <thead>
74 <tr>
75 <td>Player ID</td>
76 <td>Video ID</td>
77 <td>Meta Key</td>
78 <td>Meta Value</td>
79 </tr>
80 </thead>
81 <?php foreach($videos as $video) : ?>
82 <tr>
83 <td><?php if( isset( $video->player_id) ) echo intval( $video->player_id ); ?></td>
84 <td><?php echo intval( $video->id ); ?></td>
85 <?php foreach( array( 'meta_key', 'meta_value' ) AS $field ) : ?>
86 <td><?php echo wp_kses( self::hilight( $video->$field, $from, $to, $color ), array( 'span' => array( 'style' => array() ) ) ); ?></td>
87 <?php endforeach; ?>
88 </tr>
89 <?php endforeach; ?>
90 </table>
91 <?php
92 }
93
94 public static function hilight( $string, $from, $to, $color ) {
95 $phrase = $to ? $to : $from;
96
97 $string = str_replace( $from, '<span style="background: '.$color.'">'.$phrase.'</span>', $string );
98 return $string;
99 }
100
101 public static function search_video( $phrase ) {
102 global $wpdb;
103
104 $like = '%' . $wpdb->esc_like($phrase) . '%';
105
106 $videos_data = $wpdb->get_results( $wpdb->prepare(
107 "SELECT id, src, src1, src2, splash, mobile, rtmp, rtmp_path FROM `{$wpdb->prefix}fv_player_videos` WHERE src LIKE %s OR src1 LIKE %s OR src2 LIKE %s OR splash LIKE %s OR mobile LIKE %s OR rtmp LIKE %s OR rtmp_path LIKE %s",
108 $like,
109 $like,
110 $like,
111 $like,
112 $like,
113 $like,
114 $like
115 ) );
116
117 $videos_data = self::add_player_id( $videos_data );
118
119 return $videos_data;
120 }
121
122 public static function search_meta( $phrase ) {
123 global $wpdb;
124
125 $like = '%' . $wpdb->esc_like($phrase) . '%';
126
127 $videos_data = $wpdb->get_results( $wpdb->prepare(
128 "SELECT id_video as id , meta_key, meta_value FROM `{$wpdb->prefix}fv_player_videometa` WHERE meta_value LIKE %s AND meta_value NOT REGEXP '^(a|s|O):[0-9]:'",
129 $like
130 ) );
131
132 $videos_data = self::add_player_id( $videos_data );
133
134 return $videos_data;
135 }
136
137 public function view() {
138 ?>
139 <style>
140 /* Make sure the SVG images have some spacing and background */
141 .fv-player-wizard-step img[src$="svg"] {
142 background-color: white;
143 padding: 1em;
144 max-width: calc( 100% - 2em );
145 }
146 </style>
147 <?php
148 $this->show();
149
150 }
151
152 private static function add_player_id( $videos_data ) {
153 global $wpdb;
154
155 $players = $wpdb->get_results( "SELECT id , videos FROM `{$wpdb->prefix}fv_player_players`" );
156
157 foreach ($videos_data as $kv => $video) {
158 foreach($players as $kp => $player) {
159 $videos = explode( ',', $player->videos );
160 if( in_array( $video->id, $videos ) ) {
161 $videos_data[$kv]->player_id = $player->id;
162 }
163 }
164 }
165
166 return $videos_data;
167 }
168 }
169
170 function FV_Player_Migration_Wizard() {
171 return FV_Player_Migration_Wizard::_get_instance();
172 }
173
174 FV_Player_Migration_Wizard();