1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
<?php $nextgen = new FooGallery_NextGen_Helper(); if ( isset( $_POST['foogallery_nextgen_reset'] ) ) {
if ( check_admin_referer( 'foogallery_nextgen_import_reset', 'foogallery_nextgen_import_reset' ) ) { $nextgen->reset_import(); } } else if ( isset( $_POST['foogallery_nextgen_reset_album'] ) ) {
if ( check_admin_referer( 'foogallery_nextgen_album_reset', 'foogallery_nextgen_album_reset' ) ) { $nextgen->reset_album_import(); } } ?> <style> .foo-nav-tabs a:focus { -webkit-box-shadow: none; box-shadow: none; }
.spinner.shown { display: inline !important; margin: 0; }
.nextgen-import-progress-error { color: #f00 !important; }
.nextgen-import-progress-not_started { color: #f60 !important; }
.nextgen-import-progress-started { color: #f80 !important; }
.nextgen-import-progress-completed { color: #080 !important; }
.nextgen-import-progressbar { margin-top: 10px; display: inline-block; width: 500px; height: 10px; background: #ddd; position: relative; }
.nextgen-import-progressbar span { position: absolute; height: 100%; left: 0; background: #888; }
#nextgen_import_form .dashicons-arrow-right { font-size: 2em; margin-top: -0.2em; }
.nextgen_import_container { margin-top: 10px; }
.tablenav .tablenav-pages a, .tablenav .tablenav-pages span { margin: 0 3px; padding: 5px; }
.tablenav-pages span { display: inline-block; min-width: 17px; border: 1px solid #d2d2d2; background: #e4e4e4; font-size: 16px; line-height: 1; font-weight: normal; text-align: center; }
.tablenav-pages span.selected-page { border-color: #5b9dd9; color: #fff; background: #00a0d2; -webkit-box-shadow: none; box-shadow: none; outline: none; }
.tablenav-pages span.disabled { color: #888; }
.foogallery-help { margin-bottom: 10px; }
</style> <script> jQuery(function ($) {
function nextgen_ajax(action, success_callback) { var data = jQuery("#nextgen_import_form").serialize();
$.ajax({ type: "POST", url: ajaxurl, data: data + "&action=" + action, success: success_callback, error: function() { //something went wrong! Alert the user and reload the page alert('<?php _e( 'Something went wrong with the import and the page will now reload. Once it has reloaded, click "Resume Import" to continue with the import.', 'foogallery' ); ?>'); location.reload(); } }); }
function nextgen_import_continue(dont_check_progress) { nextgen_ajax('foogallery_nextgen_import_refresh', function (data) { $('#nextgen_import_form').html(data);
if (dont_check_progress != true) { //check if we need to carry on polling var percentage = parseInt($('#nextgen_import_progress').val()); if (percentage < 100) { nextgen_import_continue(); } else { nextgen_import_continue(true); } } }); }
$('#nextgen_import_form').on('click', '.start_import', function (e) { e.preventDefault();
//show the spinner $('#nextgen_import_form .button').hide(); $('#import_spinner .spinner').addClass('is-active');
nextgen_ajax('foogallery_nextgen_import', function (data) { $('#nextgen_import_form').html(data); nextgen_import_continue(); }); });
$('#nextgen_import_form').on('click', '.continue_import', function (e) { e.preventDefault(); nextgen_import_continue(); });
$('#nextgen_import_form').on('click', '.cancel_import', function (e) { if (!confirm('<?php _e( 'Are you sure you want to cancel?', 'foogallery' ); ?>')) { e.preventDefault(); return false; } });
$('#nextgen_import_form').on('click', '.reset_import', function (e) { if (!confirm('<?php _e( 'Are you sure you want to reset all NextGen gallery import data? This may result in duplicate galleries and media attachments!', 'foogallery' ); ?>')) { e.preventDefault(); return false; } });
$('#nextgen_import_album_form').on('click', '.reset_album_import', function (e) { if (!confirm('<?php _e( 'Are you sure you want to reset all NextGen album import data? This may result in duplicate albums if you decide to import again!', 'foogallery' ); ?>')) { e.preventDefault(); return false; } });
$('#nextgen_import_album_form').on('click', '.start_album_import', function (e) { e.preventDefault();
//show the spinner $(this).hide(); var $tr = $(this).parents('tr:first'); $tr.find('.spinner:first').addClass('is-active');
var data = { action: 'foogallery_nextgen_album_import', foogallery_nextgen_album_import: $('#foogallery_nextgen_album_import').val(), nextgen_album_id: $tr.find('.foogallery-album-id').val(), foogallery_album_name: $tr.find('.foogallery-album-name').val() };
$.ajax({ type: "POST", url: ajaxurl, data: data, success: function(data) { $('#nextgen_import_album_form').html(data); }, error: function() { //something went wrong! Alert the user and reload the page alert('<?php _e( 'Something went wrong with the import and the page will now reload.', 'foogallery' ); ?>'); location.reload(); } }); });
$('#nextgen_import_shortcodes').on('click', '.find-shortcodes', function (e) { e.preventDefault();
//show the spinner $('#nextgen_import_shortcodes .spinner').addClass('is-active');
var data = { action: 'foogallery_nextgen_find_shortcodes', '_wpnonce' : $('#foogallery_nextgen_find_shortcodes').val() };
$.ajax({ type: "POST", url: ajaxurl, data: data, success: function(data) { $('#nextgen_import_shortcodes_container').html(data); }, complete: function() { $('#nextgen_import_shortcodes .spinner').removeClass('is-active'); }, error: function() { //something went wrong! Alert the user and reload the page alert('<?php _e( 'Something went wrong with finding shortcodes, so the page will now reload.', 'foogallery' ); ?>'); location.reload(); } }); });
$('#nextgen_import_shortcodes').on('click', '.replace-shortcodes', function (e) { e.preventDefault();
//show the spinner $('#nextgen_import_shortcodes .spinner').addClass('is-active');
var data = { action: 'foogallery_nextgen_replace_shortcodes', '_wpnonce' : $('#foogallery_nextgen_replace_shortcodes').val() };
$.ajax({ type: "POST", url: ajaxurl, data: data, success: function(data) { $('#nextgen_import_shortcodes_container').html(data); }, complete: function() { $('#nextgen_import_shortcodes .spinner').removeClass('is-active'); }, error: function() { //something went wrong! Alert the user and reload the page alert('<?php _e( 'Something went wrong with replacing shortcodes, so the page will now reload.', 'foogallery' ); ?>'); location.reload(); } }); });
$('.foo-nav-tabs').on('click', 'a', function (e) { $('.nextgen_import_container').hide(); var tab = $(this).data('tab'); $('#' + tab).show(); $('.nav-tab').removeClass('nav-tab-active'); $(this).addClass('nav-tab-active'); });
if (window.location.hash) { $('.foo-nav-tabs a[href="' + window.location.hash + '"]').click(); } }); </script> <div class="wrap about-wrap"> <?php $galleries = $nextgen->get_galleries(); $albums = $nextgen->get_albums(); $gallery_count = ''; if ( count( $galleries ) > 0 ) { $gallery_count = ' (' . count( $galleries ) . ')'; } $album_count = ''; if ( count( $albums ) > 0 ) { $album_count = ' (' . count( $albums ) . ')'; } ?>
<h2><?php _e( 'NextGen Gallery And Album Importer', 'foogallery' ); ?></h2>
<h2 class="foo-nav-tabs nav-tab-wrapper"> <a href="#galleries" data-tab="nextgen_import_galleries" class="nav-tab nav-tab-active"><?php _e('Galleries', 'foogallery'); ?><?php echo $gallery_count; ?></a> <a href="#albums" data-tab="nextgen_import_albums" class="nav-tab"><?php _e('Albums', 'foogallery'); ?><?php echo $album_count; ?></a> <a href="#shortcodes" data-tab="nextgen_import_shortcodes" class="nav-tab"><?php _e('Shortcodes', 'foogallery'); ?></a> </h2>
<div class="nextgen_import_container" id="nextgen_import_galleries"> <?php if ( ! $galleries ) { _e( 'There are no NextGen galleries to import!', 'foogallery' ); } else { ?> <div class="foogallery-help"> <?php _e( 'Importing galleries is really simple:', 'foogallery' ); ?> <ol> <li><?php printf( __( 'Choose the NextGen galleries you want to import into %s by checking their checkboxes.', 'foogallery' ), foogallery_plugin_name() ); ?></li> <li><?php _e( 'Click the Start Import button to start the import process.', 'foogallery' ); ?></li> <li><?php printf( __( 'Once a gallery is imported, you can click on the link under the %s Name column to edit the gallery.', 'foogallery' ), foogallery_plugin_name() ); ?></li> </ol> <?php _e('Please note: importing large galleries with lots of images can take a while!', 'foogallery' ); ?> </div>
<form id="nextgen_import_form" method="POST"> <?php $nextgen->render_import_form( $galleries ); ?> </form> <?php } ?> </div> <div class="nextgen_import_container" id="nextgen_import_albums" style="display: none"> <?php if ( ! $albums ) { _e( 'There are no NextGen albums to import!', 'foogallery' ); } else { ?> <div class="foogallery-help"> <?php _e( 'Importing albums is also really simple:', 'foogallery' ); ?> <ol> <li><?php _e( __( 'For all the albums you wish to import, make sure all the galleries have been imported FIRST. If not, then go back to the Galleries tab.', 'foogallery' )); ?></li> <li><?php _e( 'Click the Import Album button for each album to import the album and link all the galleries. If you do not see the button, then that means you first need to import the galleries.', 'foogallery' ); ?></li> <li><?php _e( 'Once an album is imported, you can click on the link under the Album Name column to edit the album.', 'foogallery'); ?></li> </ol> </div>
<form id="nextgen_import_album_form" method="POST"> <?php $nextgen->render_album_import_form( $albums ); ?> </form> <?php } ?> </div> <div class="nextgen_import_container" id="nextgen_import_shortcodes" style="display: none"> <div class="foogallery-help"> <?php _e('Replacing NextGen shortcodes will only work with galleries that have already been imported.', 'foogallery' ); ?> <br/> <?php _e('Supported NextGen shortcodes: [ngg_images], [nggallery], [slideshow], [imagebrowse]', 'foogallery' ); ?> </div> <div id="nextgen_import_shortcodes_container"> <input type="submit" class="button button-primary find-shortcodes" value="<?php _e( 'Find Shortcodes', 'foogallery' ); ?>"> <?php wp_nonce_field( 'foogallery_nextgen_find_shortcodes', 'foogallery_nextgen_find_shortcodes' ); ?> <div style="width:40px; position: absolute;"><span class="spinner"></span></div> </div> </div> </div>
|