WP Photo Album Plus - Version 8.2.05.003

Version Description

= 8.1.08 =

  • This version addresses various bug fixes, feature requests and security fixes.
Download this release

Release Info

Developer opajaap
Plugin Icon wp plugin WP Photo Album Plus
Version 8.2.05.003
Comparing to
See all releases

Code changes from version 8.2.05.002 to 8.2.05.003

changelog.txt CHANGED
@@ -8,6 +8,7 @@ WP Photo Album Plus Changelog
8
  * Removed obsolete debuggig code.
9
  * Reduced number of queries by better cacing option data.
10
  * Added Timstamp descending to the sub-album sequence methods.
 
11
 
12
  = 8.2.04 =
13
 
8
  * Removed obsolete debuggig code.
9
  * Reduced number of queries by better cacing option data.
10
  * Added Timstamp descending to the sub-album sequence methods.
11
+ * Added import from realmedialibrary plugin categorized wp media.
12
 
13
  = 8.2.04 =
14
 
wppa-import.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the import pages and functions
6
- * Version 8.2.05.002
7
  *
8
  */
9
 
@@ -23,6 +23,20 @@ global $wppa_session;
23
  $ngg_opts = wppa_get_option( 'ngg_options', false );
24
  $user = wppa_get_user();
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  // Update watermark settings for the user if new values supplied
27
  if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
28
 
@@ -108,15 +122,15 @@ global $wppa_session;
108
  }
109
 
110
  // Set local / remote
111
- if ( wppa_get( 'local-remote' ) && in_array( wppa_get( 'local-remote' ), array( 'local', 'remote' ) ) ) {
112
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
113
  wppa_update_option( 'wppa_import_source_type_'.$user, wppa_get( 'local-remote' ) );
114
  }
115
 
116
  // Set import source dir ( when local )
117
- if ( wppa_get( 'import-set-source-dir' ) && wppa_is_dir( wppa_get( 'source' ) ) ) {
118
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
119
- if ( wppa_get( 'source' ) ) {
120
  wppa_update_option( 'wppa_import_source_'.$user, wppa_get( 'source' ) );
121
  }
122
  }
@@ -133,7 +147,14 @@ global $wppa_session;
133
  }
134
 
135
  // Hit the submit button
136
- if ( wppa_get( 'import-submit' ) ) {
 
 
 
 
 
 
 
137
  if ( wppa( 'ajax' ) ) {
138
  if ( ! wp_verify_nonce( wppa_get( 'update-check' ), '$wppa_nonce' ) ) {
139
  wppa_echo( __( 'Security check failure', 'wp-photo-album-plus' ) );
@@ -247,6 +268,22 @@ global $wppa_session;
247
  $remote_max = wppa_get_option( 'wppa_import_remote_max_'.$user, '10' );
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  // The form
251
  wppa_echo( '
252
  <form
@@ -268,7 +305,8 @@ global $wppa_session;
268
  onchange="jQuery(\'#rem-rem-0\').show();jQuery(\'#wppa-import-set-source\').trigger(\'click\');"
269
  >
270
  <option value="local" ' . ( $source_type == 'local' ? 'selected' : '' ) . '>' . __( 'Local', 'wp-photo-album-plus' ) . '</option>
271
- <option value="remote" ' . ( $source_type == 'remote' ? 'selected' : '' ) . '>' . __( 'Remote' ,'wp-photo-album-plus' ) . '</option>
 
272
  </select>
273
  <span id="rem-rem-0" style="display:none">' .
274
  __( 'Working, please wait...', 'wp-photo-album-plus' ) . '
@@ -311,7 +349,7 @@ global $wppa_session;
311
  }
312
 
313
  // Remote: url
314
- else {
315
  if ( wppa_is_mobile() ) {
316
  wppa_echo( '
317
  <br>
@@ -358,1259 +396,1308 @@ global $wppa_session;
358
  <br>' .
359
  __( 'You can enter a full url to an image file like <i>http://mysite.com/wp-content/uploads/wppa/4711.jpg</i>', 'wp-photo-album-plus' ) );
360
  }
 
 
 
 
 
 
 
 
361
  wppa_echo( '</div>' );
362
  }
363
  wppa_echo( '</form>' );
364
 
365
- // check if albums exist or will be made before allowing upload
366
- if ( ! wppa_has_albums() && ! $albumcount && ! $dircount && ! $csvcount ) {
367
- $url = get_admin_url() . 'admin.php?page=wppa_admin_menu';
368
- wppa_echo( '
369
- <p>' .
370
- __( 'No albums exist. You must', 'wp-photo-album-plus' ) . '
371
- <a href="' . $url . '" >' .
372
- __( 'create one', 'wp-photo-album-plus' ) . '
373
- </a> ' .
374
- __( 'before you can import your photos.', 'wp-photo-album-plus' ) . '
375
- </p>' );
376
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  }
378
 
379
- // Something to import?
380
- if ( $photocount || $albumcount || $zipcount || $dircount || $videocount || $audiocount || $csvcount || $documentcount ) {
381
 
382
- // Open the form
383
- wppa_echo( '
384
- <form
385
- action="' . get_admin_url() . 'admin.php?page=wppa_import_photos"
386
- method="post"
387
- >' .
388
- wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) );
389
-
390
- // Display the zips
391
- if ( PHP_VERSION_ID >= 50207 && $zipcount > '0' ) {
392
  wppa_echo( '
393
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">
394
- <p><b>' .
395
- sprintf( _n( 'There is %d zipfile in the depot', 'There are %d zipfiles in the depot', $zipcount, 'wp-photo-album-plus' ), $zipcount ) . '
396
- </b></p>
397
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
398
- <thead>
399
- <tr>
400
- <td>
401
- <input
402
- type="checkbox"
403
- id="all-zip"
404
- checked="checked"
405
- onchange="checkAll( \'all-zip\', \'.wppa-zip\' )"
406
- />
407
- <b>&nbsp;&nbsp;' .
408
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
409
- </b>
410
- </td>' );
411
- if ( $is_sub_depot ) {
412
- wppa_echo( '
 
 
 
 
 
 
 
 
 
 
 
413
  <td>
414
  <input
415
  type="checkbox"
416
- id="del-after-z"
417
- name="del-after-z"
418
  checked="checked"
 
419
  />
420
  <b>&nbsp;&nbsp;' .
421
- __( 'Delete after successful extraction.', 'wp-photo-album-plus' ) . '
422
  </b>
423
  </td>' );
424
- }
425
- wppa_echo( '
426
- </tr>
427
- </thead>
428
- </table>
429
- <table
430
- class="form-table wppa-table widefat"
431
- style="margin-top:0;"
432
- >
433
- <tr>' );
434
- $ct = 0;
435
- $idx = '0';
436
- foreach ( $files as $file ) {
437
-
438
- $ext = wppa_get_ext( $file );
439
- if ( $ext == 'zip' ) {
440
- wppa_echo( '
441
- <td>
442
- <input
443
- type="checkbox"
444
- id="file-' . $idx . '"
445
- name="file-' . $idx . '"
446
- class="wppa-zip"
447
- checked="checked"
448
- />&nbsp;&nbsp;' .
449
- htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) . '
450
- </td>' );
451
- if ( $ct == 3 ) {
452
- wppa_echo( '</tr><tr>' );
453
- $ct = 0;
454
  }
455
- else {
456
- $ct++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  }
 
458
  }
459
- $idx++;
460
- }
461
- wppa_echo( '
462
- </tr>
463
- </table>
464
- </div>' );
465
- }
466
 
467
- // Dispay the albums ( .amf files )
468
- if ( $albumcount ) {
469
- wppa_echo( '
470
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">
471
- <p>
472
- <b>' .
473
- sprintf( _n( 'There is %d albumdefinition in the depot', 'There are %d albumdefinitions in the depot', $albumcount, 'wp-photo-album-plus' ), $albumcount ) . '
474
- </b>
475
- </p>
476
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
477
- <thead>
478
- <tr>
479
- <td>
480
- <input
481
- type="checkbox"
482
- id="all-amf"
483
- checked="checked"
484
- onchange="checkAll( \'all-amf\', \'.wppa-amf\' )"
485
- />
486
- <b>&nbsp;&nbsp;' .
487
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
488
- </b>
489
- </td>' );
490
- if ( $is_sub_depot ) {
491
- wppa_echo( '
492
  <td>
493
  <input
494
  type="checkbox"
495
- id="del-after-a"
496
- name="del-after-a"
497
  checked="checked"
 
498
  />
499
  <b>&nbsp;&nbsp;' .
500
- __( 'Remove from depot after successful import, or if the album already exists.', 'wp-photo-album-plus' ) . '
501
  </b>
502
  </td>' );
503
- }
504
- wppa_echo( '
505
- </tr>
506
- </thead>
507
- </table>
508
- <table
509
- class="form-table wppa-table widefat"
510
- style="margin-top:0;"
511
- >
512
- <tr>' );
513
- $ct = 0;
514
- $idx = '0';
515
- foreach ( $files as $file ) {
516
- $ext = wppa_get_ext( $file );
517
- if ( $ext == 'amf' ) {
518
- wppa_echo( '
519
- <td>
520
- <input
521
- type="checkbox"
522
- id="file-' . $idx . '"
523
- name="file-' . $idx . '"
524
- class="wppa-amf"
525
- checked="checked"
526
- />
527
- &nbsp;&nbsp;' .
528
- sanitize_text_field( basename( $file ) . '&nbsp;' . wppa_get_meta_name( $file, '( ' ) ) . '
529
- </td>' );
530
- if ( $ct == 3 ) {
531
- wppa_echo( '</tr><tr>' );
532
- $ct = 0;
533
  }
534
- else {
535
- $ct++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  }
 
537
  }
538
- $idx++;
539
- }
540
- wppa_echo( '
541
- </tr>
542
- </table>
543
- </div>' );
544
- }
545
 
546
- // Display the single photos
547
- if ( $photocount ) {
548
- wppa_echo( '
549
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">
550
- <p><b>' );
551
 
552
- // Local
553
- if ( $source_type == 'local' ) {
554
- if ( $is_ngg ) {
555
- wppa_echo( '<br><b>' . sprintf( _n( 'There is %d photo in the ngg gallery', 'There are %d photos in the ngg gallery', $photocount, 'wp-photo-album-plus' ), $photocount ) . '</b>' );
 
 
 
 
556
  }
 
 
557
  else {
558
- wppa_echo( '<br><b>' . sprintf( _n( 'There is %d photo in the depot', 'There are %d photos in the depot', $photocount, 'wp-photo-album-plus' ), $photocount ) . '</b>' );
559
  }
560
- }
561
 
562
- // Remote
563
- else {
564
- wppa_echo( sprintf( _n( 'There is %d possible photo found remote', 'There are %d possible photos found remote', $photocount, 'wp-photo-album-plus' ), $photocount ) );
565
- }
566
 
567
- wppa_echo( '
568
- </b></p>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
 
570
- // The album selection
571
- wppa_echo( '
572
- <p class="hideifupdate" >' .
573
- __( 'Default album for import:', 'wp-photo-album-plus' ) .
574
- wppa_album_select_a( array( 'path' => true,
575
- 'selected' => wppa_get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' ),
576
- 'addpleaseselect' => true,
577
- 'checkowner' => true,
578
- 'checkupload' => true,
579
- 'sort' => true,
580
- 'optionclass' => '',
581
- 'tagopen' => '<select name="wppa-photo-album" id="wppa-photo-album" >',
582
- 'tagname' => 'wppa-photo-album',
583
- 'tagid' => 'wppa-photo-album',
584
- 'tagonchange' => '',
585
- 'multiple' => false,
586
- 'tagstyle' => '',
587
- ) ) .
588
- wppa_edit_album_link_button( 'wppa-photo-album' ) .
589
- __( 'Photos that have (<em>name</em>)[<em>album</em>] will be imported by that <em>name</em> in that <em>album</em>.', 'wp-photo-album-plus' ) . '
590
- </p>
591
- <p>' );
592
-
593
- // Watermark
594
- if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
595
  wppa_echo(
596
- __( 'Apply watermark file:', 'wp-photo-album-plus' ) .
597
- '<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
598
- wppa_watermark_file_select( 'user' ) .
599
- '</select>' .
600
- __( 'Position:', 'wp-photo-album-plus' ) .
601
- '<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
602
- wppa_watermark_pos_select( 'user' ) .
603
- '</select>' );
604
- }
605
-
606
- // Delay
607
- $delays = array( '0', '1', '2', '5', '10', '20', '50', '100' );
608
- wppa_echo(
609
- __( 'Delay', 'wp-photo-album-plus' ) .
610
- '<select id="wppa-delay" >' );
611
- foreach ( $delays as $d ) {
612
- wppa_echo( '<option value="' . ( $d * 1000 ) . '" ' . ( $d == '1' ? 'selected ' : '' ) . '>' . $d . '</option>' );
613
- }
614
  wppa_echo( '
615
- </select> s.
616
- <img
617
- id="wppa-spinner"
618
- src="' . wppa_get_imgdir( 'spinner.gif' ) . '"
619
- style="vertical-align:middle;display:none;"
620
- />
621
- </p>' );
622
-
623
- // Header of photo list
624
- wppa_echo( '
625
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
626
- <thead>
627
- <tr>
628
- <td>
629
- <input
630
- type="checkbox"
631
- id="all-pho"' .
632
- ( $is_sub_depot ? ' checked="checked"' : ' ' ) . '
633
- onchange="checkAll( \'all-pho\', \'.wppa-pho\' )"
634
- />
635
- <b>
636
- &nbsp;&nbsp;' .
637
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
638
- </b>
639
- </td>' );
640
-
641
- // Depot specific switches
642
- if ( $is_sub_depot ) {
643
- wppa_echo( '
644
- <td>
645
- <input
646
- type="checkbox"
647
- id="del-after-p"
648
- name="del-after-p"
649
- checked="checked"
650
- />
651
- <b>
652
- &nbsp;&nbsp;' .
653
- __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
654
- </b>
655
- </td>
656
  <td>
657
  <input
658
  type="checkbox"
659
- id="del-after-f"
660
- name="del-after-f"
 
661
  />
662
  <b>
663
  &nbsp;&nbsp;' .
664
- __( 'Remove from depot after failed import.', 'wp-photo-album-plus' ) . '
665
  </b>
666
  </td>' );
667
- }
668
 
669
- // Nextgen import specific switches
670
- if ( $is_ngg ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
671
  wppa_echo( '
672
  <td>
673
  <input
674
  type="checkbox"
675
- id="cre-album"
676
- name="cre-album"
677
- checked="checked"
678
- value="' . esc_attr( basename( $source ) ) .'"
679
  />
680
  <b>
681
  &nbsp;&nbsp;' .
682
- __( 'Import into album', 'wp-photo-album-plus' ) . ' ' . basename( $source ) . '
683
  </b>
684
- <small>' .
685
- __( 'The album will be created if it does not exist', 'wp-photo-album-plus' ) . '
686
- </small>
687
- </td>
688
- <td>
 
 
 
 
 
 
 
 
 
 
689
  <input
690
  type="checkbox"
691
- id="use-backup"
692
- name="use-backup"
693
  checked="checked"
694
  />
695
  <b>
696
  &nbsp;&nbsp;' .
697
- __( 'Use backup if available', 'wp-photo-album-plus' ) . '
698
- </b>
699
- </td>' );
700
- }
701
 
702
- // Update existing switch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
  wppa_echo( '
704
- <td>
705
- <input
706
- type="checkbox"
707
- id="wppa-update"
708
- onchange="impUpd( this, \'#submit\' )"
709
- name="wppa-update"
710
- />
711
- <b>
712
- &nbsp;&nbsp;' .
713
- __( 'Update existing photos', 'wp-photo-album-plus' ) . '
714
- </b>
715
- </td>' );
716
-
717
- // Void dups switch
718
- wppa_echo( '<td>' );
719
- if ( wppa_switch( 'void_dups' ) ) {
720
- wppa_echo( '
721
- <input
722
- type="hidden"
723
- id="wppa-nodups"
724
- name="wppa-nodups"
725
- value="1"
726
- />' );
727
- }
728
- else {
729
- wppa_echo( '
730
- <input
731
- type="checkbox"
732
- id="wppa-nodups"
733
- name="wppa-nodups"
734
- checked="checked"
735
- />
736
- <b>
737
- &nbsp;&nbsp;' .
738
- __( 'Do not create duplicates', 'wp-photo-album-plus' ) . '
739
- </b>' );
740
- }
741
- wppa_echo( '</td>' );
742
-
743
- // Import preview zoomable switch
744
- if ( wppa_switch( 'import_preview' ) ) {
745
- wppa_echo( '
746
- <td>
747
- <input
748
- type="checkbox"
749
- id="wppa-zoom"
750
- onclick="wppa_setCookie(\'zoompreview\', this.checked, \'365\')"' .
751
- ( wppa_get_cookie( 'zoompreview' ) == 'true' ? ' checked="checked"' : '' ) . '
752
- />
753
- <b>
754
- &nbsp;&nbsp;' .
755
- __( 'Zoom previews', 'wp-photo-album-plus' ) . '
756
- </b>
757
- </td>' );
758
- }
759
- wppa_echo( '
760
- </tr>
761
- </thead>
762
- </table>' );
763
 
764
- // Photo list
765
- wppa_echo( '
766
- <table class="form-table wppa-table widefat" style="margin-top:0">
767
- <tr>' );
768
- $ct = 0;
769
- $idx = '0';
770
- if ( is_array( $files ) ) foreach ( $files as $file ) {
771
- $ext = wppa_get_ext( $file );
772
- $meta = wppa_strip_ext( $file ).'.PMF';
773
- if ( ! wppa_is_file( $meta ) ) {
774
- $meta = wppa_strip_ext( $file ).'.pmf';
775
- }
776
- if ( ! wppa_is_file( $meta ) ) {
777
- $meta = false;
778
- }
779
- if ( in_array( strtolower($ext), $wppa_supported_photo_extensions ) ) {
780
- wppa_echo( '
781
- <td id="td-file-' . $idx . '" >
782
- <input
783
- type="checkbox"
784
- id="file-' . $idx . '"
785
- name="file-' . $idx . '"
786
- title="' . esc_attr( $file ) . '"
787
- class="wppa-pho" ' .
788
- ( $is_sub_depot ? 'checked="checked"' : '' ) . '
789
- />
790
- <span
791
- id="name-file-' . $idx . '"
792
- >
793
- &nbsp;&nbsp;' );
794
-
795
- if ( wppa( 'is_wppa_tree' ) ) {
796
- $t = explode( 'uploads/wppa/', $file );
797
- wppa_echo( wppa_sanitize_file_name( basename( str_replace( '/', '', $t[1] ) ) ) );
798
- }
799
- else {
800
- wppa_echo( wppa_sanitize_file_name( basename( $file ) ) );
801
- }
802
 
803
- if ( $meta ) {
804
- wppa_echo( '
805
- &nbsp;' .
806
- stripslashes( wppa_get_meta_name( $meta, '( ' ) ) .
807
- stripslashes( wppa_get_meta_album( $meta, '[' ) ) );
808
- }
809
- wppa_echo( '</span>' );
810
 
811
- if ( wppa_switch( 'import_preview' ) ) {
812
- if ( wppa( 'is_remote' ) ) {
813
- if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
814
- $img_url = dirname( $file ) . '/h_144/' . basename( $file );
 
 
 
 
815
  }
816
  else {
817
- $img_url = $file;
818
- }
819
- }
820
- else {
821
- $img_url = str_replace( ABSPATH, home_url().'/', $file );
822
- if ( is_ssl() ) {
823
- $img_url = str_replace( 'http://', 'https://', $img_url );
824
  }
 
 
 
 
 
 
 
825
  }
826
- wppa_echo( '
827
- <img src="' . esc_url( $img_url ) . '"
828
- alt="' . esc_attr( __( 'n.a.', 'wp-photo-album-plus' ) ) . '"
829
- style="max-height:48px;"
830
- onmouseover="if (jQuery(\'#wppa-zoom\').prop(\'checked\')) jQuery(this).css(\'max-height\', \'144px\')"
831
- onmouseout="if (jQuery(\'#wppa-zoom\').prop(\'checked\')) jQuery(this).css(\'max-height\', \'48px\')"
832
- />' );
833
- }
834
 
835
- wppa_echo( '</td>' );
836
 
837
- if ( $ct == 3 ) {
838
- wppa_echo( '</tr><tr>' );
839
- $ct = 0;
840
- }
841
- else {
842
- $ct++;
 
843
  }
 
844
  }
845
- $idx++;
846
- }
847
- wppa_echo( '
848
- </tr>
849
- </table>
850
- </div>' );
851
- }
852
-
853
- // Display the videos
854
- if ( $videocount && wppa_switch( 'enable_video' ) ) {
855
- wppa_echo( '
856
- <div
857
- style="border:1px solid gray; padding:4px; margin: 3px 0;"
858
- >' );
859
 
860
- // Display available files
 
861
  wppa_echo( '
862
- <p><b>' .
863
- sprintf( _n( 'There is %d video in the depot', 'There are %d videos in the depot', $videocount, 'wp-photo-album-plus' ), $videocount ) . '
864
- </b></p>' );
865
 
866
- // Album to import to
867
- wppa_echo( '
868
- <p class="hideifupdate" >' .
869
- __( 'Album to import to:', 'wp-photo-album-plus' ) .
870
- wppa_album_select_a( array( 'path' => true,
871
- 'selected' => wppa_get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' ),
872
- 'addpleaseselect' => true,
873
- 'checkowner' => true,
874
- 'checkupload' => true,
875
- 'sort' => true,
876
- 'optionclass' => '',
877
- 'tagopen' => '<select name="wppa-video-album" id="wppa-video-album" >',
878
- 'tagname' => 'wppa-video-album',
879
- 'tagid' => 'wppa-video-album',
880
- 'tagonchange' => '',
881
- 'multiple' => false,
882
- 'tagstyle' => '',
883
- ) ) .
884
- wppa_edit_album_link_button( 'wppa-video-album' ) .
885
- '</p>' );
886
-
887
- // Header of video list
888
- wppa_echo( '
889
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
890
- <thead>
891
- <tr>
892
- <td>
893
- <input
894
- type="checkbox"
895
- id="all-video"
896
- checked="checked"
897
- onchange="checkAll( \'all-video\', \'.wppa-video\' )"
898
- />
899
- <b>
900
- &nbsp;&nbsp;' .
901
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
902
- </b>
903
- </td>' );
904
- if ( $is_sub_depot ) {
905
- wppa_echo( '
906
  <td>
907
  <input
908
  type="checkbox"
909
- id="del-after-v"
910
- name="del-after-v"
911
  checked="checked"
 
912
  />
913
  <b>
914
  &nbsp;&nbsp;' .
915
- __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
916
- <small> ' .
917
- __( 'Files larger than 64MB will always be removed after successful import.', 'wp-photo-album-plus' ) . '
918
- </small>
919
  </b>
920
  </td>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
921
  }
922
  wppa_echo( '
923
  </tr>
924
- </thead>
925
- </table>' );
 
926
 
927
- // Video list
 
928
  wppa_echo( '
929
- <table class="form-table wppa-table widefat" style="margin-top:0">
930
- <tr>' );
931
- $ct = 0;
932
- $idx = '0';
933
- if ( is_array( $files ) ) foreach ( $files as $file ) {
934
- $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
935
- if ( in_array( strtolower($ext), $wppa_supported_video_extensions ) ) {
936
- wppa_echo( '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  <td>
938
  <input
939
  type="checkbox"
940
- id="file-' . $idx . '"
941
- name="file-' . $idx . '"
942
- title="' . esc_attr( htmlspecialchars( $file ) ) . '"
943
- class="wppa-video"
944
  checked="checked"
 
945
  />
946
- <span
947
- id="name-file-' . $idx . '"
948
- >
949
  &nbsp;&nbsp;' .
950
- htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) .
951
- ' (' . sprintf( '%3.1f', wppa_filesize( $file ) / 1024 ) . ' kb)' . '
952
- </span>
953
  </td>' );
954
- if ( $ct == 3 ) {
955
- wppa_echo( '</tr><tr>' );
956
- $ct = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
957
  }
958
- else {
959
- $ct++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
960
  }
 
961
  }
962
- $idx++;
963
- }
964
- wppa_echo( '
965
- </tr>
966
- </table>
967
- </div>' );
968
- }
969
-
970
- // Display the audios
971
- if ( $audiocount && wppa_switch( 'enable_audio' ) ) {
972
- wppa_echo( '
973
- <div
974
- style="border:1px solid gray;padding:4px;margin: 3px 0;"
975
- >' );
976
 
977
- // Display available files
 
978
  wppa_echo( '
979
- <p><b>' .
980
- sprintf( _n( 'There is %d audio in the depot', 'There are %d audios in the depot', $audiocount, 'wp-photo-album-plus' ), $audiocount ) . '
981
- </b></p>' );
982
 
983
- // Album to import to
984
- wppa_echo( '
985
- <p class="hideifupdate" >' .
986
- __( 'Album to import to:', 'wp-photo-album-plus' ) .
987
- wppa_album_select_a( array( 'path' => true,
988
- 'selected' => wppa_get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' ),
989
- 'addpleaseselect' => true,
990
- 'checkowner' => true,
991
- 'checkupload' => true,
992
- 'sort' => true,
993
- 'optionclass' => '',
994
- 'tagopen' => '<select name="wppa-audio-album" id="wppa-audio-album" >',
995
- 'tagname' => 'wppa-audio-album',
996
- 'tagid' => 'wppa-audio-album',
997
- 'tagonchange' => '',
998
- 'multiple' => false,
999
- 'tagstyle' => '',
1000
- ) ) .
1001
- wppa_edit_album_link_button( 'wppa-audio-album' ) . '
1002
- </p>' );
1003
-
1004
- // Header of audio list
1005
- wppa_echo( '
1006
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
1007
- <thead>
1008
- <tr>
1009
- <td>
1010
- <input
1011
- type="checkbox"
1012
- id="all-audio"
1013
- checked="checked"
1014
- onchange="checkAll( \'all-audio\', \'.wppa-audio\' )"
1015
- />
1016
- <b>
1017
- &nbsp;&nbsp;' .
1018
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1019
- </b>
1020
- </td>' );
1021
-
1022
- // The remove box
1023
- if ( $is_sub_depot ) {
1024
- wppa_echo( '
1025
  <td>
1026
  <input
1027
  type="checkbox"
1028
- id="del-after-u"
1029
- name="del-after-u"
1030
  checked="checked"
 
1031
  />
1032
  <b>
1033
  &nbsp;&nbsp;' .
1034
- __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1035
  </b>
1036
- </td>' );
1037
- }
1038
- wppa_echo( '
1039
- </tr>
1040
- </thead>
1041
- </table>' );
1042
-
1043
- // Audio list
1044
- wppa_echo( '
1045
- <table class="form-table wppa-table widefat" style="margin-top:0">
1046
- <tr>' );
1047
- $ct = 0;
1048
- $idx = '0';
1049
- if ( is_array( $files ) ) foreach ( $files as $file ) {
1050
- $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1051
- if ( in_array( strtolower($ext), $wppa_supported_audio_extensions ) ) {
1052
- wppa_echo( '
1053
  <td>
1054
  <input
1055
  type="checkbox"
1056
- id="file-' . $idx . '"
1057
- name="file-' . $idx . '"
1058
- title="' . esc_attr( htmlspecialchars( $file ) ) . '"
1059
- class="wppa-audio"
1060
  checked="checked"
 
1061
  />
1062
- <span
1063
- id="name-file-' . $idx . '"
1064
- >
1065
  &nbsp;&nbsp;' .
1066
- htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) .
1067
- ' (' . sprintf( '%3.1f', wppa_filesize( $file ) / 1024 ) . ' kb)' . '
1068
- </span>
1069
- </td>' );
1070
- if ( $ct == 3 ) {
1071
- wppa_echo( '</tr><tr>' );
1072
- $ct = 0;
1073
- }
1074
- else {
1075
- $ct++;
1076
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1077
  }
1078
  $idx++;
1079
  }
1080
  wppa_echo( '
1081
- </tr>
1082
- </table>
1083
- </div>' );
1084
- }
1085
-
1086
- // Display the csv files
1087
- if ( $is_depot && $csvcount ) {
1088
- wppa_echo( '
1089
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
1090
 
1091
- // Display number of files
 
1092
  wppa_echo( '
1093
- <p><b>' .
1094
- sprintf( _n( 'There is %d .csv file in the depot', 'There are %d .csv files in the depot', $csvcount, 'wp-photo-album-plus' ), $csvcount ) . '
1095
- </b></p>' );
1096
 
1097
- // Header of .csv file list
1098
- wppa_echo( '
1099
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
1100
- <thead>
1101
- <tr>
1102
- <td>
1103
- <input
1104
- type="checkbox"
1105
- id="all-csv"
1106
- checked="checked"
1107
- onchange="checkAll( \'all-csv\', \'.wppa-csv\' )"
1108
- />
1109
- <b>
1110
- &nbsp;&nbsp;' .
1111
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1112
- </b>
1113
- </td>
1114
- <td>
1115
- <input
1116
- type="checkbox"
1117
- id="del-after-c"
1118
- name="del-after-c"
1119
- checked="checked"
1120
- disabled
1121
- />
1122
- <b>
1123
- &nbsp;&nbsp;' .
1124
- __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1125
- </b>
1126
- </td>
1127
- </tr>
1128
- </thead>
1129
- </table>' );
1130
 
1131
- // CSV file list
1132
- wppa_echo( '
1133
- <table class="form-table wppa-table widefat" style="margin-top:0">' );
1134
- $ct = 0;
1135
- $idx = '0';
1136
- if ( is_array( $files ) ) foreach( $files as $csv ) {
1137
- if ( wppa_is_file( $csv ) && strtolower( wppa_get_ext( $csv ) ) == 'csv' ) {
1138
- wppa_echo( '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
  <tr>
1140
  <td>
1141
  <input
1142
  type="checkbox"
1143
- id="file-' . $idx . '"
1144
- name="file-' . $idx . '"
1145
- class="wppa-csv"
1146
  checked="checked"
 
1147
  />
1148
  <b>
1149
  &nbsp;&nbsp;' .
1150
- wppa_sanitize_file_name( basename( $csv ) ) .
1151
- ' (' . sprintf( '%3.1f', wppa_filesize( $csv ) / 1024 ) . ' kb)' . '
1152
  </b>
1153
- </td>
1154
- </tr>' );
1155
- }
1156
- $idx++;
1157
- }
1158
- wppa_echo( '
1159
- </table>
1160
- </div>' );
1161
- }
1162
-
1163
- // Display the document files
1164
- if ( $is_depot && $documentcount ) {
1165
- wppa_echo( '
1166
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
1167
-
1168
- // Display number of files
1169
- wppa_echo( '
1170
- <p><b>' .
1171
- sprintf( _n( 'There is %d document file in the depot', 'There are %d document files in the depot', $documentcount, 'wp-photo-album-plus' ), $documentcount ) . '
1172
- </b></p>' );
1173
-
1174
- // Album to import to
1175
- wppa_echo( '
1176
- <p class="hideifupdate" >' .
1177
- __( 'Album to import to:', 'wp-photo-album-plus' ) .
1178
- wppa_album_select_a( array( 'path' => true,
1179
- 'selected' => wppa_get_option( 'wppa-document-album-import-'.wppa_get_user(), '0' ),
1180
- 'addpleaseselect' => true,
1181
- 'checkowner' => true,
1182
- 'checkupload' => true,
1183
- 'sort' => true,
1184
- 'optionclass' => '',
1185
- 'tagopen' => '<select name="wppa-document-album" id="wppa-document-album" >',
1186
- 'tagname' => 'wppa-document-album',
1187
- 'tagid' => 'wppa-document-album',
1188
- 'tagonchange' => '',
1189
- 'multiple' => false,
1190
- 'tagstyle' => '',
1191
- ) ) .
1192
- wppa_edit_album_link_button( 'wppa-document-album' ) . '
1193
- </p>' );
1194
-
1195
- // Header of .pdf file list
1196
- wppa_echo( '
1197
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
1198
- <thead>
1199
- <tr>
1200
- <td>
1201
- <input
1202
- type="checkbox"
1203
- id="all-pdf"
1204
- checked="checked"
1205
- onchange="checkAll( \'all-pdf\', \'.wppa-pdf\' )"
1206
- />
1207
- <b>
1208
- &nbsp;&nbsp;' .
1209
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1210
- </b>
1211
- </td>
1212
- <td>
1213
- <input
1214
- type="checkbox"
1215
- id="del-after-d"
1216
- name="del-after-d"
1217
- checked="checked"
1218
- />
1219
- <b>
1220
- &nbsp;&nbsp;' .
1221
- __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1222
- </b>
1223
- </td>
1224
- </tr>
1225
- </thead>
1226
- </table>' );
1227
-
1228
- // pdf file list
1229
- wppa_echo( '
1230
- <table class="form-table wppa-table widefat" style="margin-top:0">
1231
- <tr>' );
1232
- $ct = 0;
1233
- $idx = '0';
1234
- if ( is_array( $files ) ) foreach( $files as $pdf ) {
1235
- if ( wppa_is_file( $pdf ) && strtolower( wppa_get_ext( $pdf ) ) == 'pdf' ) {
1236
- wppa_echo( '
1237
  <td>
1238
  <input
1239
  type="checkbox"
1240
- id="file-' . $idx . '"
1241
- name="file-' . $idx . '"
1242
- title="' . esc_attr( $pdf ) . '"
1243
- class="wppa-pdf"
1244
  checked="checked"
1245
  />
1246
- &nbsp;&nbsp;
1247
- <span
1248
- id="name-file-' . $idx . '"
1249
- >
1250
  &nbsp;&nbsp;' .
1251
- wppa_sanitize_file_name( basename( $pdf ) ) .
1252
- ' (' . sprintf( '%3.1f', wppa_filesize( $pdf ) / 1024 ) . ' kb)' . '
1253
- </span>
1254
- </td>' );
1255
- if ( $ct == 3 ) {
1256
- wppa_echo( '</tr><tr>' );
1257
- $ct = 0;
1258
- }
1259
- else {
1260
- $ct++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1261
  }
 
1262
  }
1263
- $idx++;
1264
- }
1265
- wppa_echo( '
1266
- </tr>
1267
- </table>
1268
- </div>' );
1269
- }
1270
-
1271
- // Display the directories to be imported as albums. Do this in the depot only!!
1272
- if ( $is_depot && $dircount ) {
1273
- wppa_echo( '
1274
- <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
1275
 
1276
- // Display number of dirs
 
1277
  wppa_echo( '
1278
- <p><b>' .
1279
- sprintf( _n( 'There is %d albumdirectory in the depot', 'There are %d albumdirectories in the depot', $dircount, 'wp-photo-album-plus' ), $dircount ) . '
1280
- </b></p>' );
1281
 
1282
- // Header of dirlist
1283
- wppa_echo( '
1284
- <table class="form-table wppa-table widefat" style="margin-bottom:0">
1285
- <thead>
1286
- <tr>
1287
- <td>
1288
- <input
1289
- type="checkbox"
1290
- id="all-dir"
1291
- checked="checked"
1292
- onchange="checkAll( \'all-dir\', \'.wppa-dir\' )"
1293
- />
1294
- <b>
1295
- &nbsp;&nbsp;' .
1296
- __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1297
- </b>
1298
- </td>
1299
- <td>
1300
- <input
1301
- type="checkbox"
1302
- id="del-dir"
1303
- name="del-dir"
1304
- onchange="wppa_setCookie(\'removeemptydirs\', this.checked, \'365\')"' .
1305
- ( wppa_get_cookie( 'removeemptydirs' ) == 'true' ? ' checked="checked"' : '' ) . '
1306
- />
1307
- <b>
1308
- &nbsp;&nbsp;' .
1309
- __( 'Remove empty dirs', 'wp-photo-album-plus' ) .
1310
- '</b>
1311
- </td>
1312
- </tr>
1313
- </thead>
1314
- </table>' );
1315
 
1316
- // Dirlist
1317
- wppa_echo( '
1318
- <table class="form-table wppa-table widefat" style="margin-top:0">' );
1319
- $ct = 0;
1320
- $idx = '0';
1321
- foreach( $files as $dir ) {
1322
- if ( basename( $dir ) != '.' &&
1323
- basename( $dir ) != '..' &&
1324
- wppa_is_dir( $dir ) ) {
1325
- wppa_echo( '
1326
  <tr>
1327
  <td>
1328
  <input
1329
  type="checkbox"
1330
- id="file-' . $idx . '"
1331
- name="file-' . $idx .'"
1332
- class= "wppa-dir"
1333
  checked="checked"
 
1334
  />
1335
- &nbsp;&nbsp;
1336
- <b>' .
1337
- htmlspecialchars( wppa_sanitize_file_name( basename( $dir ) ) ) . '
1338
- </b>' );
1339
- $subdirs = wppa_glob( $dir.'/*', WPPA_ONLYDIRS );
1340
- $subfiles = wppa_glob( $dir.'/*', WPPA_ONLYFILES );
1341
- $subdircount = count( $subdirs );
1342
- $subfilecount = count( $subfiles );
1343
-
1344
- wppa_echo( ' ' .
1345
- sprintf( _n( 'Contains %d file', 'Contains %d files', $subfilecount, 'wp-photo-album-plus' ), $subfilecount ) );
1346
- if ( $subdircount ) {
1347
- wppa_echo( ' ' .
1348
- sprintf( _n( 'and %d subdirectory', 'and %d subdirectories', $subdircount, 'wp-photo-album-plus' ), $subdircount ) );
1349
- }
1350
- wppa_echo( '
 
1351
  </td>
1352
- </tr>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1353
  }
1354
- $idx++;
1355
- }
1356
- wppa_echo( '
1357
- </table>
1358
- </div>' );
1359
- }
1360
 
1361
- $the_js = '
1362
- function wppaVfyAlbum() {
1363
- var csvs = jQuery( ".wppa-csv" );
1364
- if ( ! jQuery( "#wppa-update" ).prop( "checked" ) ) {
1365
- if ( ! parseInt( jQuery( "#wppa-photo-album" ).val() ) &&
1366
- ! parseInt( jQuery( "#wppa-video-album" ).val() ) &&
1367
- ! parseInt( jQuery( "#wppa-audio-album" ).val() ) &&
1368
- ! parseInt( jQuery( "#wppa-document-album" ).val() ) &&
1369
- csvs.length == 0
1370
- ) {
1371
- alert( "Please select an album first" );
1372
- return false;
 
1373
  }
 
1374
  }
1375
- return true;
1376
- }
1377
- function wppaCheckInputVars() {
1378
- var checks = jQuery( ":checked" );
1379
- var nChecks = checks.length;
1380
- var nMax = ' . ini_get( "max_input_vars" ) . ';
1381
- if ( nMax == 0 ) nMax = 100;
1382
- if ( nChecks > nMax ) {
1383
- alert ( "There are "+nChecks+" boxes checked or selected, that is more than the maximum allowed number of "+nMax );
1384
- return false;
1385
- }
1386
- var dirs = jQuery( ".wppa-dir" );
1387
- var nDirsChecked = 0;
1388
- if ( dirs.length > 0 ) {
1389
- var i = 0;
1390
- while ( i < dirs.length ) {
1391
- if ( jQuery( dirs[i] ).prop( "checked" ) ) {
1392
- nDirsChecked++;
1393
  }
1394
- i++;
1395
  }
1396
- }
1397
- var zips = jQuery( ".wppa-zip" );
1398
- var nZipsChecked = 0;
1399
- if ( zips.length > 0 ) {
1400
- var i = 0;
1401
- while ( i < zips.length ) {
1402
- if ( jQuery( zips[i] ).prop( "checked" ) ) {
1403
- nZipsChecked++;
 
1404
  }
1405
- i++;
1406
  }
 
 
 
1407
  }
1408
- // If no dirs to import checked, there must be an album selected
1409
- if ( 0 == nDirsChecked && 0 == nZipsChecked && ! wppaVfyAlbum() ) return false;
1410
- return true;
1411
- }
1412
 
1413
- var wppaImportRuns = false;
1414
- var wppaTimer;
1415
- function wppaDoAjaxImport() {
1416
- jQuery( "#wppa-spinner" ).css( "display", "none" );
1417
-
1418
- var data = "";
1419
- data += "wppa-update-check="+jQuery( "#wppa-update-check" ).val();
1420
- data += "&wppa-photo-album="+jQuery( "#wppa-photo-album" ).val();
1421
- data += "&wppa-video-album="+jQuery( "#wppa-video-album" ).val();
1422
- data += "&wppa-audio-album="+jQuery( "#wppa-audio-album" ).val();
1423
- data += "&wppa-document-album="+jQuery( "#wppa-document-album" ).val();
1424
- data += "&wppa-watermark-file="+jQuery( "#wppa-watermark-file" ).val();
1425
- data += "&wppa-watermark-pos="+jQuery( "#wppa-watermark-pos" ).val();
1426
- if ( jQuery( "#cre-album" ).prop( "checked" ) ) data += "&cre-album="+jQuery( "#cre-album" ).val();
1427
- if ( jQuery( "#use-backup" ).prop( "checked" ) ) data += "&use-backup=1";
1428
- if ( jQuery( "#wppa-update" ).prop( "checked" ) ) data += "&wppa-update=1";
1429
- if ( jQuery( "#wppa-nodups" ).prop( "checked" ) ) data += "&wppa-nodups=1";
1430
- if ( jQuery( "#del-after-p" ).prop( "checked" ) ) data += "&del-after-p=1";
1431
- if ( jQuery( "#del-after-f" ).prop( "checked" ) ) data += "&del-after-f=1";
1432
- if ( jQuery( "#del-after-v" ).prop( "checked" ) ) data += "&del-after-v=1";
1433
- if ( jQuery( "#del-after-u" ).prop( "checked" ) ) data += "&del-after-u=1";
1434
- if ( jQuery( "#del-after-d" ).prop( "checked" ) ) data += "&del-after-d=1";
1435
- data += "&wppa-import-submit=ajax";
1436
-
1437
- var files = jQuery( ":checked" );
1438
- var found = false;
1439
- var i=0;
1440
- var elm;
1441
- var fulldata;
1442
- for ( i=0; i<files.length; i++ ) {
1443
- found = false; // assume done
1444
- elm = files[i];
1445
- // Is it a file checkbox?
1446
- var temp = elm.id.split( "-" );
1447
- if ( temp[0] != "file" ) continue; // no
1448
- fulldata = data+"&import-ajax-file="+elm.title;
1449
- found = true;
1450
- break;
1451
- }
1452
- // alert( data );
1453
- if ( ! found ) {
1454
- wppaStopAjaxImport();
1455
- return; // nothing left
1456
- }
1457
- // found one, do it
1458
- var oldhtml=jQuery( "#name-"+elm.id ).html();
1459
- var xmlhttp = wppaGetXmlHttp();
1460
- xmlhttp.onreadystatechange = function() {
1461
- if ( xmlhttp.readyState == 4 ) {
1462
- if ( xmlhttp.status!=404 ) {
1463
- var resp = xmlhttp.responseText;
1464
-
1465
- //
1466
- if ( resp.length == 0 ) {
1467
- jQuery( "#name-"+elm.id ).html("<span style=\'color:red\'>Timeout</span>" );
1468
- wppaStopAjaxImport();
1469
- return;
1470
- }
1471
- //
1472
- if ( resp.indexOf( "Server" ) != -1 && resp.indexOf( "Error" ) != -1 ) {
1473
- resp = "<span style=\'color:red\'>Server error</span>";
1474
- }
1475
- jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b>"+resp+"</b>" );
1476
- elm.checked = "";
1477
- if ( jQuery( "#del-after-p" ).prop( "checked" ) ||
1478
- jQuery( "#del-after-f" ).prop( "checked" ) ) {
1479
- elm.disabled = "disabled";
1480
- elm.title = "";
 
 
 
 
 
1481
  }
1482
- if ( wppaImportRuns ) {
1483
- wppaTimer = setTimeout( "wppaDoAjaxImport()", jQuery( "#wppa-delay" ).val() ); // was 100
1484
- jQuery( "#wppa-spinner" ).css( "display", "inline" );
1485
  }
1486
  }
1487
- else {
1488
- jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b>Not found</b>" );
1489
- }
 
 
 
 
 
 
1490
  }
1491
  }
1492
- var url = wppaAjaxUrl+"?action=wppa&wppa-action=import";
1493
- xmlhttp.open( "POST",url,true );
1494
- xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
1495
- xmlhttp.send( fulldata );
1496
- jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b style=\'color:blue\' >" + "' . __( "Working...", "wp-photo-album-plus" ) . '" + "</b>" );
1497
- if ( wppaImportRuns ) {
1498
- jQuery( "#wppa-start-ajax" ).css( "display", "none" );
1499
- jQuery( "#wppa-stop-ajax" ).css( "display", "inline" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1500
  }
1501
- }
1502
- function wppaStopAjaxImport() {
1503
- wppaImportRuns = false;
1504
- clearTimeout( wppaTimer );
1505
- jQuery( "#wppa-start-ajax" ).css( "display", "inline" );
1506
- jQuery( "#wppa-stop-ajax" ).css( "display", "none" );
1507
- jQuery( "#wppa-spinner" ).css( "display", "none" );
1508
- }';
1509
-
1510
- wppa_add_inline_script( 'wppa-admin', $the_js );
1511
-
1512
- // The submit button
1513
- wppa_echo( '<p>' );
1514
- if ( $albumcount || $dircount || $zipcount || $csvcount ) {
1515
- wppa_echo( '
1516
- <input
1517
- type="submit"
1518
- onclick="return wppaCheckInputVars()"
1519
- class="button-primary"
1520
- id="submit"
1521
- name="wppa-import-submit"
1522
- value="' . __( 'Import', 'wp-photo-album-plus' ) . '"
1523
  />' );
1524
- }
1525
- if ( ( $photocount || $videocount || $audiocount || $documentcount ) && ! $albumcount && ! $dircount && ! $zipcount && ! $csvcount ) {
1526
  wppa_echo( '
1527
- <input
1528
- id="wppa-start-ajax"
1529
- type="button"
1530
- onclick="if (wppaVfyAlbum()) {wppaImportRuns=true;wppaDoAjaxImport()}"
1531
- class="button-primary"
1532
- value="' . esc_attr( __( 'Start Import', 'wp-photo-album-plus' ) ) . '"
1533
- />
1534
- <input
1535
- id="wppa-stop-ajax"
1536
- style="display:none;"
1537
- type="button"
1538
- onclick="wppaStopAjaxImport()"
1539
- class="button-primary"
1540
- value="' . esc_attr( __( 'Stop Import', 'wp-photo-album-plus' ) ) . '"
1541
- />' );
1542
- }
1543
- wppa_echo( '
1544
- </p>
1545
- </form>' );
1546
- }
1547
- else {
1548
- if ( $source_type == 'local' ) {
1549
- wppa_ok_message( __( 'There are no importable files found in directory:', 'wp-photo-album-plus' ).' '.$source );
1550
  }
1551
  else {
1552
- wppa_ok_message( __( 'There are no photos found or left to process at url:', 'wp-photo-album-plus' ).' '.$source_url );
 
 
 
 
 
1553
  }
1554
- }
1555
- wppa_echo( '
1556
- <br><b>' .
1557
- __( 'You can import the following file types:', 'wp-photo-album-plus' ) . '
1558
- </b><br>' );
1559
- if ( wppa_get_option( 'wppa_import_source_type_' . $user, 'local' ) == 'remote' ) {
1560
  wppa_echo( '
1561
- <br>' .
1562
- __( 'Photo file types:', 'wp-photo-album-plus' ) . '
1563
- .jpg .jpeg .png' );
1564
- }
1565
- else {
1566
- if ( PHP_VERSION_ID >= 50207 ) {
1567
- wppa_echo( '<br>' .
1568
- __( 'Compressed file types: .zip', 'wp-photo-album-plus' ) );
1569
- }
1570
-
1571
- wppa_echo( '<br>' .
1572
- __( 'Photo file types:', 'wp-photo-album-plus' ) );
1573
- foreach ( $wppa_supported_photo_extensions as $ext ) {
1574
- wppa_echo( ' .' . $ext );
1575
  }
 
 
 
 
 
1576
 
1577
- if ( wppa_switch( 'enable_video' ) ) {
1578
  wppa_echo( '<br>' .
1579
- __( 'Video file types:', 'wp-photo-album-plus' ) );
1580
- foreach ( $wppa_supported_video_extensions as $ext ) {
1581
  wppa_echo( ' .' . $ext );
1582
  }
1583
- }
1584
- if ( wppa_switch( 'enable_audio' ) ) {
1585
- wppa_echo( '<br>' .
1586
- __( 'Audio file types:', 'wp-photo-album-plus' ) );
1587
- foreach ( $wppa_supported_audio_extensions as $ext ) {
1588
- wppa_echo( ' .' . $ext );
 
1589
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1590
  }
1591
- if ( in_array( 'pdf', wppa_get_supported_extensions() ) ) {
1592
- wppa_echo( '<br>' .
1593
- __( 'Document file type: .pdf', 'wp-photo-album-plus' ) );
1594
- }
1595
- wppa_echo( '
1596
- <br>' . __( 'WPPA+ file types: .amf .pmf', 'wp-photo-album-plus' ) . '
1597
- <br>' . __( 'Custom data files of type .csv', 'wp-photo-album-plus' ) . '
1598
- <br>' . __( 'Directories with optional subdirs containig photos', 'wp-photo-album-plus' ) . '
1599
- <br><br>' . __( 'Your depot directory is:', 'wp-photo-album-plus' ) . '
1600
- <b> .../' . WPPA_DEPOT . '/</b>' );
1601
- }
1602
 
1603
- if ( wppa( 'continue' ) ) {
1604
- wppa_warning_message( __( 'Trying to continue...', 'wp-photo-album-plus' ) );
1605
- $the_js = 'document.location=\'' . get_admin_url() . 'admin.php?page=wppa_import_photos&continue=1&nonce=' . wp_create_nonce( 'dirimport' ) . '\';';
1606
- wppa_add_inline_script( 'wppa-admin', $the_js );
1607
- }
1608
 
1609
- wppa_echo( '<br><br>' );
1610
 
1611
- wppa_echo( wppa_album_admin_footer() );
1612
 
1613
- wppa_echo( '</div><!-- .wrap -->' );
 
1614
 
1615
  }
1616
 
@@ -1759,7 +1846,6 @@ global $wppa_session;
1759
  return $files;
1760
  }
1761
 
1762
-
1763
  // Do the import photos
1764
  function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false, $delf = false, $deld = false ) {
1765
  global $wpdb;
@@ -2892,7 +2978,6 @@ function wppa_get_documentcount( $files ) {
2892
  return $result;
2893
  }
2894
 
2895
-
2896
  // Find dir is new album candidates
2897
  function wppa_get_dircount( $files ) {
2898
  $result = 0;
@@ -2937,7 +3022,6 @@ function wppa_get_meta_linkurl( $file, $opt = '' ) {
2937
  function wppa_get_meta_linktitle( $file, $opt = '' ) {
2938
  return wppa_get_meta_data( $file, 'lnkt', $opt );
2939
  }
2940
-
2941
  function wppa_get_meta_data( $file, $item, $opt ) {
2942
  $result = '';
2943
  $opt2 = '';
@@ -2959,7 +3043,6 @@ function wppa_get_meta_data( $file, $item, $opt ) {
2959
  return $result;
2960
  }
2961
 
2962
-
2963
  function wppa_extract( $xpath, $delz ) {
2964
  // There are two reasons that we do not allow the directory structure from the zipfile to be restored.
2965
  // 1. we may have no create dir access rights.
@@ -3295,4 +3378,274 @@ function wppa_edit_album_link_button( $tagid ) {
3295
  /> ';
3296
 
3297
  return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3298
  }
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the import pages and functions
6
+ * Version 8.2.05.003
7
  *
8
  */
9
 
23
  $ngg_opts = wppa_get_option( 'ngg_options', false );
24
  $user = wppa_get_user();
25
 
26
+ // Init for real media library plugin import
27
+ if ( is_multisite() && WPPA_MULTISITE_GLOBAL ) {
28
+ $wppa_prefix = $wpdb->base_prefix;
29
+ }
30
+ else {
31
+ $wppa_prefix = $wpdb->prefix;
32
+ }
33
+ $pl = implode( ',', wppa_get_option( 'active_plugins' ) );
34
+ $real_media = strpos( $pl, 'real-media-library' ) !== false;
35
+ define( 'WPPA_REALMEDIA', $wppa_prefix . 'realmedialibrary' );
36
+ $wpdb->wppa_realmedialibrary = WPPA_REALMEDIA;
37
+ define( 'WPPA_REALMEDIA_POSTS', $wppa_prefix . 'realmedialibrary_posts' );
38
+ $wpdb->wppa_realmedialibrary_posts = WPPA_REALMEDIA_POSTS;
39
+
40
  // Update watermark settings for the user if new values supplied
41
  if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
42
 
122
  }
123
 
124
  // Set local / remote
125
+ if ( wppa_get( 'local-remote' ) && in_array( wppa_get( 'local-remote' ), array( 'local', 'remote', 'realmedia' ) ) ) {
126
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
127
  wppa_update_option( 'wppa_import_source_type_'.$user, wppa_get( 'local-remote' ) );
128
  }
129
 
130
  // Set import source dir ( when local )
131
+ if ( wppa_get( 'import-set-source-dir', '', 'text' ) && wppa_get( 'source', '', 'text' ) != 'realmedialibrary' && wppa_is_dir( wppa_get( 'source', '', 'text' ) ) ) {
132
  check_admin_referer( '$wppa_nonce', WPPA_NONCE );
133
+ if ( wppa_get( 'source', '', 'text' ) ) {
134
  wppa_update_option( 'wppa_import_source_'.$user, wppa_get( 'source' ) );
135
  }
136
  }
147
  }
148
 
149
  // Hit the submit button
150
+ if ( wppa_get( 'import-realmedia', '', 'text' ) ) {
151
+ check_admin_referer( '$wppa_nonce', WPPA_NONCE );
152
+
153
+ wppa_import_from_realmedia();
154
+ }
155
+
156
+ // Not from realmedia
157
+ elseif ( wppa_get( 'import-submit' ) ) {
158
  if ( wppa( 'ajax' ) ) {
159
  if ( ! wp_verify_nonce( wppa_get( 'update-check' ), '$wppa_nonce' ) ) {
160
  wppa_echo( __( 'Security check failure', 'wp-photo-album-plus' ) );
268
  $remote_max = wppa_get_option( 'wppa_import_remote_max_'.$user, '10' );
269
  }
270
 
271
+ if ( $source_type == 'realmedia' ) {
272
+
273
+ // See what's in there
274
+ $filecount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_realmedialibrary_posts" );//wppa_get_import_files();
275
+ $filesdone = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE rml_id <> ''" );
276
+ // $zipcount = '0';//wppa_get_zipcount( $files );
277
+ $albumcount = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_realmedialibrary" );//wppa_get_albumcount( $files );
278
+ $albumsdone = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE rml_id <> ''" );
279
+ // $photocount = '0';//wppa_get_photocount( $files );
280
+ // $videocount = '0';//wppa_get_video_count( $files );
281
+ // $audiocount = '0';//wppa_get_audio_count( $files );
282
+ // $dircount = '0';//$is_depot ? wppa_get_dircount( $files ) : '0';
283
+ // $csvcount = '0';//$is_depot ? wppa_get_csvcount( $files ) : '0';
284
+ // $documentcount = '0';//wppa_get_documentcount( $files );
285
+ }
286
+
287
  // The form
288
  wppa_echo( '
289
  <form
305
  onchange="jQuery(\'#rem-rem-0\').show();jQuery(\'#wppa-import-set-source\').trigger(\'click\');"
306
  >
307
  <option value="local" ' . ( $source_type == 'local' ? 'selected' : '' ) . '>' . __( 'Local', 'wp-photo-album-plus' ) . '</option>
308
+ <option value="remote" ' . ( $source_type == 'remote' ? 'selected' : '' ) . '>' . __( 'Remote' ,'wp-photo-album-plus' ) . '</option>' .
309
+ ( $real_media ? '<option value="realmedia" ' . ( $source_type == 'realmedia' ? 'selected' : '' ) . '>' . __( 'From realmedia plugin', 'wp-photo-album-plus' ) . '</option>' : '' ) . '
310
  </select>
311
  <span id="rem-rem-0" style="display:none">' .
312
  __( 'Working, please wait...', 'wp-photo-album-plus' ) . '
349
  }
350
 
351
  // Remote: url
352
+ if ( $source_type == 'remote' ) {
353
  if ( wppa_is_mobile() ) {
354
  wppa_echo( '
355
  <br>
396
  <br>' .
397
  __( 'You can enter a full url to an image file like <i>http://mysite.com/wp-content/uploads/wppa/4711.jpg</i>', 'wp-photo-album-plus' ) );
398
  }
399
+
400
+ elseif( $source_type == 'realmedia' ) {
401
+ wppa_echo( ' '. __( 'Real media plugin defined albums', 'wp-photo-album-plus' ) );
402
+ }
403
+
404
+ else {
405
+ wppa_echo( 'Unimplemented source type', 'wp-photo-album-plus' );
406
+ }
407
  wppa_echo( '</div>' );
408
  }
409
  wppa_echo( '</form>' );
410
 
411
+ // The from realmedia display
412
+ if ( $source_type == 'realmedia' ) {
413
+
414
+ // Something to import?
415
+ if ( $filecount || $albumcount ) {
416
+
417
+ // Open the form
418
+ wppa_echo( '
419
+ <form
420
+ action="' . get_admin_url() . 'admin.php?page=wppa_import_photos"
421
+ method="post"
422
+ >' .
423
+ wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) );
424
+ wppa_echo( '<p>' );
425
+
426
+ wppa_echo( __( 'Number of available realmedia albums', 'wp-photo-album-plus' ) . ': ' . $albumcount . '<br>' );
427
+ wppa_echo( __( 'Number of imported realmeda albums', 'wp-photo-album-plus' ) . ': ' . $albumsdone . '<br>' );
428
+ wppa_echo( __( 'Number of available realmedia files', 'wp-photo-album-plus' ) . ': ' . $filecount . '<br>' );
429
+ wppa_echo( __( 'Number of imported realmeda files', 'wp-photo-album-plus' ) . ': ' . $filesdone . '<br>' );
430
+
431
+ wppa_echo( '</p>' );
432
+ wppa_echo( '
433
+ <input
434
+ type="submit"
435
+ class="button-primary"
436
+ id="submit"
437
+ name="wppa-import-realmedia"
438
+ value="' . __( 'Import Realmeadia albums and files', 'wp-photo-album-plus' ) . '"
439
+ />
440
+ </form>' );
441
+ }
442
+
443
+ // Nothing
444
+ else {
445
+ }
446
  }
447
 
448
+ // Not from realmedia
449
+ else {
450
 
451
+ // check if albums exist or will be made before allowing upload
452
+ if ( ! wppa_has_albums() && ! $albumcount && ! $dircount && ! $csvcount ) {
453
+ $url = get_admin_url() . 'admin.php?page=wppa_admin_menu';
 
 
 
 
 
 
 
454
  wppa_echo( '
455
+ <p>' .
456
+ __( 'No albums exist. You must', 'wp-photo-album-plus' ) . '
457
+ <a href="' . $url . '" >' .
458
+ __( 'create one', 'wp-photo-album-plus' ) . '
459
+ </a> ' .
460
+ __( 'before you can import your photos.', 'wp-photo-album-plus' ) . '
461
+ </p>' );
462
+ return;
463
+ }
464
+
465
+ // Something to import?
466
+ if ( $photocount || $albumcount || $zipcount || $dircount || $videocount || $audiocount || $csvcount || $documentcount ) {
467
+
468
+ // Open the form
469
+ wppa_echo( '
470
+ <form
471
+ action="' . get_admin_url() . 'admin.php?page=wppa_import_photos"
472
+ method="post"
473
+ >' .
474
+ wp_nonce_field( '$wppa_nonce', WPPA_NONCE, true, false ) );
475
+
476
+ // Display the zips
477
+ if ( PHP_VERSION_ID >= 50207 && $zipcount > '0' ) {
478
+ wppa_echo( '
479
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">
480
+ <p><b>' .
481
+ sprintf( _n( 'There is %d zipfile in the depot', 'There are %d zipfiles in the depot', $zipcount, 'wp-photo-album-plus' ), $zipcount ) . '
482
+ </b></p>
483
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
484
+ <thead>
485
+ <tr>
486
  <td>
487
  <input
488
  type="checkbox"
489
+ id="all-zip"
 
490
  checked="checked"
491
+ onchange="checkAll( \'all-zip\', \'.wppa-zip\' )"
492
  />
493
  <b>&nbsp;&nbsp;' .
494
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
495
  </b>
496
  </td>' );
497
+ if ( $is_sub_depot ) {
498
+ wppa_echo( '
499
+ <td>
500
+ <input
501
+ type="checkbox"
502
+ id="del-after-z"
503
+ name="del-after-z"
504
+ checked="checked"
505
+ />
506
+ <b>&nbsp;&nbsp;' .
507
+ __( 'Delete after successful extraction.', 'wp-photo-album-plus' ) . '
508
+ </b>
509
+ </td>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  }
511
+ wppa_echo( '
512
+ </tr>
513
+ </thead>
514
+ </table>
515
+ <table
516
+ class="form-table wppa-table widefat"
517
+ style="margin-top:0;"
518
+ >
519
+ <tr>' );
520
+ $ct = 0;
521
+ $idx = '0';
522
+ foreach ( $files as $file ) {
523
+
524
+ $ext = wppa_get_ext( $file );
525
+ if ( $ext == 'zip' ) {
526
+ wppa_echo( '
527
+ <td>
528
+ <input
529
+ type="checkbox"
530
+ id="file-' . $idx . '"
531
+ name="file-' . $idx . '"
532
+ class="wppa-zip"
533
+ checked="checked"
534
+ />&nbsp;&nbsp;' .
535
+ htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) . '
536
+ </td>' );
537
+ if ( $ct == 3 ) {
538
+ wppa_echo( '</tr><tr>' );
539
+ $ct = 0;
540
+ }
541
+ else {
542
+ $ct++;
543
+ }
544
  }
545
+ $idx++;
546
  }
547
+ wppa_echo( '
548
+ </tr>
549
+ </table>
550
+ </div>' );
551
+ }
 
 
552
 
553
+ // Dispay the albums ( .amf files )
554
+ if ( $albumcount ) {
555
+ wppa_echo( '
556
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">
557
+ <p>
558
+ <b>' .
559
+ sprintf( _n( 'There is %d albumdefinition in the depot', 'There are %d albumdefinitions in the depot', $albumcount, 'wp-photo-album-plus' ), $albumcount ) . '
560
+ </b>
561
+ </p>
562
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
563
+ <thead>
564
+ <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  <td>
566
  <input
567
  type="checkbox"
568
+ id="all-amf"
 
569
  checked="checked"
570
+ onchange="checkAll( \'all-amf\', \'.wppa-amf\' )"
571
  />
572
  <b>&nbsp;&nbsp;' .
573
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
574
  </b>
575
  </td>' );
576
+ if ( $is_sub_depot ) {
577
+ wppa_echo( '
578
+ <td>
579
+ <input
580
+ type="checkbox"
581
+ id="del-after-a"
582
+ name="del-after-a"
583
+ checked="checked"
584
+ />
585
+ <b>&nbsp;&nbsp;' .
586
+ __( 'Remove from depot after successful import, or if the album already exists.', 'wp-photo-album-plus' ) . '
587
+ </b>
588
+ </td>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  }
590
+ wppa_echo( '
591
+ </tr>
592
+ </thead>
593
+ </table>
594
+ <table
595
+ class="form-table wppa-table widefat"
596
+ style="margin-top:0;"
597
+ >
598
+ <tr>' );
599
+ $ct = 0;
600
+ $idx = '0';
601
+ foreach ( $files as $file ) {
602
+ $ext = wppa_get_ext( $file );
603
+ if ( $ext == 'amf' ) {
604
+ wppa_echo( '
605
+ <td>
606
+ <input
607
+ type="checkbox"
608
+ id="file-' . $idx . '"
609
+ name="file-' . $idx . '"
610
+ class="wppa-amf"
611
+ checked="checked"
612
+ />
613
+ &nbsp;&nbsp;' .
614
+ sanitize_text_field( basename( $file ) . '&nbsp;' . wppa_get_meta_name( $file, '( ' ) ) . '
615
+ </td>' );
616
+ if ( $ct == 3 ) {
617
+ wppa_echo( '</tr><tr>' );
618
+ $ct = 0;
619
+ }
620
+ else {
621
+ $ct++;
622
+ }
623
  }
624
+ $idx++;
625
  }
626
+ wppa_echo( '
627
+ </tr>
628
+ </table>
629
+ </div>' );
630
+ }
 
 
631
 
632
+ // Display the single photos
633
+ if ( $photocount ) {
634
+ wppa_echo( '
635
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">
636
+ <p><b>' );
637
 
638
+ // Local
639
+ if ( $source_type == 'local' ) {
640
+ if ( $is_ngg ) {
641
+ wppa_echo( '<br><b>' . sprintf( _n( 'There is %d photo in the ngg gallery', 'There are %d photos in the ngg gallery', $photocount, 'wp-photo-album-plus' ), $photocount ) . '</b>' );
642
+ }
643
+ else {
644
+ wppa_echo( '<br><b>' . sprintf( _n( 'There is %d photo in the depot', 'There are %d photos in the depot', $photocount, 'wp-photo-album-plus' ), $photocount ) . '</b>' );
645
+ }
646
  }
647
+
648
+ // Remote
649
  else {
650
+ wppa_echo( sprintf( _n( 'There is %d possible photo found remote', 'There are %d possible photos found remote', $photocount, 'wp-photo-album-plus' ), $photocount ) );
651
  }
 
652
 
653
+ wppa_echo( '
654
+ </b></p>' );
 
 
655
 
656
+ // The album selection
657
+ wppa_echo( '
658
+ <p class="hideifupdate" >' .
659
+ __( 'Default album for import:', 'wp-photo-album-plus' ) .
660
+ wppa_album_select_a( array( 'path' => true,
661
+ 'selected' => wppa_get_option( 'wppa-photo-album-import-'.wppa_get_user(), '0' ),
662
+ 'addpleaseselect' => true,
663
+ 'checkowner' => true,
664
+ 'checkupload' => true,
665
+ 'sort' => true,
666
+ 'optionclass' => '',
667
+ 'tagopen' => '<select name="wppa-photo-album" id="wppa-photo-album" >',
668
+ 'tagname' => 'wppa-photo-album',
669
+ 'tagid' => 'wppa-photo-album',
670
+ 'tagonchange' => '',
671
+ 'multiple' => false,
672
+ 'tagstyle' => '',
673
+ ) ) .
674
+ wppa_edit_album_link_button( 'wppa-photo-album' ) .
675
+ __( 'Photos that have (<em>name</em>)[<em>album</em>] will be imported by that <em>name</em> in that <em>album</em>.', 'wp-photo-album-plus' ) . '
676
+ </p>
677
+ <p>' );
678
+
679
+ // Watermark
680
+ if ( wppa_switch( 'watermark_on' ) && ( wppa_switch( 'watermark_user' ) || current_user_can( 'wppa_settings' ) ) ) {
681
+ wppa_echo(
682
+ __( 'Apply watermark file:', 'wp-photo-album-plus' ) .
683
+ '<select name="wppa-watermark-file" id="wppa-watermark-file" >' .
684
+ wppa_watermark_file_select( 'user' ) .
685
+ '</select>' .
686
+ __( 'Position:', 'wp-photo-album-plus' ) .
687
+ '<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' .
688
+ wppa_watermark_pos_select( 'user' ) .
689
+ '</select>' );
690
+ }
691
 
692
+ // Delay
693
+ $delays = array( '0', '1', '2', '5', '10', '20', '50', '100' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
694
  wppa_echo(
695
+ __( 'Delay', 'wp-photo-album-plus' ) .
696
+ '<select id="wppa-delay" >' );
697
+ foreach ( $delays as $d ) {
698
+ wppa_echo( '<option value="' . ( $d * 1000 ) . '" ' . ( $d == '1' ? 'selected ' : '' ) . '>' . $d . '</option>' );
699
+ }
700
+ wppa_echo( '
701
+ </select> s.
702
+ <img
703
+ id="wppa-spinner"
704
+ src="' . wppa_get_imgdir( 'spinner.gif' ) . '"
705
+ style="vertical-align:middle;display:none;"
706
+ />
707
+ </p>' );
708
+
709
+ // Header of photo list
 
 
 
710
  wppa_echo( '
711
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
712
+ <thead>
713
+ <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714
  <td>
715
  <input
716
  type="checkbox"
717
+ id="all-pho"' .
718
+ ( $is_sub_depot ? ' checked="checked"' : ' ' ) . '
719
+ onchange="checkAll( \'all-pho\', \'.wppa-pho\' )"
720
  />
721
  <b>
722
  &nbsp;&nbsp;' .
723
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
724
  </b>
725
  </td>' );
 
726
 
727
+ // Depot specific switches
728
+ if ( $is_sub_depot ) {
729
+ wppa_echo( '
730
+ <td>
731
+ <input
732
+ type="checkbox"
733
+ id="del-after-p"
734
+ name="del-after-p"
735
+ checked="checked"
736
+ />
737
+ <b>
738
+ &nbsp;&nbsp;' .
739
+ __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
740
+ </b>
741
+ </td>
742
+ <td>
743
+ <input
744
+ type="checkbox"
745
+ id="del-after-f"
746
+ name="del-after-f"
747
+ />
748
+ <b>
749
+ &nbsp;&nbsp;' .
750
+ __( 'Remove from depot after failed import.', 'wp-photo-album-plus' ) . '
751
+ </b>
752
+ </td>' );
753
+ }
754
+
755
+ // Nextgen import specific switches
756
+ if ( $is_ngg ) {
757
+ wppa_echo( '
758
+ <td>
759
+ <input
760
+ type="checkbox"
761
+ id="cre-album"
762
+ name="cre-album"
763
+ checked="checked"
764
+ value="' . esc_attr( basename( $source ) ) .'"
765
+ />
766
+ <b>
767
+ &nbsp;&nbsp;' .
768
+ __( 'Import into album', 'wp-photo-album-plus' ) . ' ' . basename( $source ) . '
769
+ </b>
770
+ <small>' .
771
+ __( 'The album will be created if it does not exist', 'wp-photo-album-plus' ) . '
772
+ </small>
773
+ </td>
774
+ <td>
775
+ <input
776
+ type="checkbox"
777
+ id="use-backup"
778
+ name="use-backup"
779
+ checked="checked"
780
+ />
781
+ <b>
782
+ &nbsp;&nbsp;' .
783
+ __( 'Use backup if available', 'wp-photo-album-plus' ) . '
784
+ </b>
785
+ </td>' );
786
+ }
787
+
788
+ // Update existing switch
789
  wppa_echo( '
790
  <td>
791
  <input
792
  type="checkbox"
793
+ id="wppa-update"
794
+ onchange="impUpd( this, \'#submit\' )"
795
+ name="wppa-update"
 
796
  />
797
  <b>
798
  &nbsp;&nbsp;' .
799
+ __( 'Update existing photos', 'wp-photo-album-plus' ) . '
800
  </b>
801
+ </td>' );
802
+
803
+ // Void dups switch
804
+ wppa_echo( '<td>' );
805
+ if ( wppa_switch( 'void_dups' ) ) {
806
+ wppa_echo( '
807
+ <input
808
+ type="hidden"
809
+ id="wppa-nodups"
810
+ name="wppa-nodups"
811
+ value="1"
812
+ />' );
813
+ }
814
+ else {
815
+ wppa_echo( '
816
  <input
817
  type="checkbox"
818
+ id="wppa-nodups"
819
+ name="wppa-nodups"
820
  checked="checked"
821
  />
822
  <b>
823
  &nbsp;&nbsp;' .
824
+ __( 'Do not create duplicates', 'wp-photo-album-plus' ) . '
825
+ </b>' );
826
+ }
827
+ wppa_echo( '</td>' );
828
 
829
+ // Import preview zoomable switch
830
+ if ( wppa_switch( 'import_preview' ) ) {
831
+ wppa_echo( '
832
+ <td>
833
+ <input
834
+ type="checkbox"
835
+ id="wppa-zoom"
836
+ onclick="wppa_setCookie(\'zoompreview\', this.checked, \'365\')"' .
837
+ ( wppa_get_cookie( 'zoompreview' ) == 'true' ? ' checked="checked"' : '' ) . '
838
+ />
839
+ <b>
840
+ &nbsp;&nbsp;' .
841
+ __( 'Zoom previews', 'wp-photo-album-plus' ) . '
842
+ </b>
843
+ </td>' );
844
+ }
845
  wppa_echo( '
846
+ </tr>
847
+ </thead>
848
+ </table>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
849
 
850
+ // Photo list
851
+ wppa_echo( '
852
+ <table class="form-table wppa-table widefat" style="margin-top:0">
853
+ <tr>' );
854
+ $ct = 0;
855
+ $idx = '0';
856
+ if ( is_array( $files ) ) foreach ( $files as $file ) {
857
+ $ext = wppa_get_ext( $file );
858
+ $meta = wppa_strip_ext( $file ).'.PMF';
859
+ if ( ! wppa_is_file( $meta ) ) {
860
+ $meta = wppa_strip_ext( $file ).'.pmf';
861
+ }
862
+ if ( ! wppa_is_file( $meta ) ) {
863
+ $meta = false;
864
+ }
865
+ if ( in_array( strtolower($ext), $wppa_supported_photo_extensions ) ) {
866
+ wppa_echo( '
867
+ <td id="td-file-' . $idx . '" >
868
+ <input
869
+ type="checkbox"
870
+ id="file-' . $idx . '"
871
+ name="file-' . $idx . '"
872
+ title="' . esc_attr( $file ) . '"
873
+ class="wppa-pho" ' .
874
+ ( $is_sub_depot ? 'checked="checked"' : '' ) . '
875
+ />
876
+ <span
877
+ id="name-file-' . $idx . '"
878
+ >
879
+ &nbsp;&nbsp;' );
880
+
881
+ if ( wppa( 'is_wppa_tree' ) ) {
882
+ $t = explode( 'uploads/wppa/', $file );
883
+ wppa_echo( wppa_sanitize_file_name( basename( str_replace( '/', '', $t[1] ) ) ) );
884
+ }
885
+ else {
886
+ wppa_echo( wppa_sanitize_file_name( basename( $file ) ) );
887
+ }
888
 
889
+ if ( $meta ) {
890
+ wppa_echo( '
891
+ &nbsp;' .
892
+ stripslashes( wppa_get_meta_name( $meta, '( ' ) ) .
893
+ stripslashes( wppa_get_meta_album( $meta, '[' ) ) );
894
+ }
895
+ wppa_echo( '</span>' );
896
 
897
+ if ( wppa_switch( 'import_preview' ) ) {
898
+ if ( wppa( 'is_remote' ) ) {
899
+ if ( strpos( $file, '//res.cloudinary.com/' ) !== false ) {
900
+ $img_url = dirname( $file ) . '/h_144/' . basename( $file );
901
+ }
902
+ else {
903
+ $img_url = $file;
904
+ }
905
  }
906
  else {
907
+ $img_url = str_replace( ABSPATH, home_url().'/', $file );
908
+ if ( is_ssl() ) {
909
+ $img_url = str_replace( 'http://', 'https://', $img_url );
910
+ }
 
 
 
911
  }
912
+ wppa_echo( '
913
+ <img src="' . esc_url( $img_url ) . '"
914
+ alt="' . esc_attr( __( 'n.a.', 'wp-photo-album-plus' ) ) . '"
915
+ style="max-height:48px;"
916
+ onmouseover="if (jQuery(\'#wppa-zoom\').prop(\'checked\')) jQuery(this).css(\'max-height\', \'144px\')"
917
+ onmouseout="if (jQuery(\'#wppa-zoom\').prop(\'checked\')) jQuery(this).css(\'max-height\', \'48px\')"
918
+ />' );
919
  }
 
 
 
 
 
 
 
 
920
 
921
+ wppa_echo( '</td>' );
922
 
923
+ if ( $ct == 3 ) {
924
+ wppa_echo( '</tr><tr>' );
925
+ $ct = 0;
926
+ }
927
+ else {
928
+ $ct++;
929
+ }
930
  }
931
+ $idx++;
932
  }
933
+ wppa_echo( '
934
+ </tr>
935
+ </table>
936
+ </div>' );
937
+ }
 
 
 
 
 
 
 
 
 
938
 
939
+ // Display the videos
940
+ if ( $videocount && wppa_switch( 'enable_video' ) ) {
941
  wppa_echo( '
942
+ <div
943
+ style="border:1px solid gray; padding:4px; margin: 3px 0;"
944
+ >' );
945
 
946
+ // Display available files
947
+ wppa_echo( '
948
+ <p><b>' .
949
+ sprintf( _n( 'There is %d video in the depot', 'There are %d videos in the depot', $videocount, 'wp-photo-album-plus' ), $videocount ) . '
950
+ </b></p>' );
951
+
952
+ // Album to import to
953
+ wppa_echo( '
954
+ <p class="hideifupdate" >' .
955
+ __( 'Album to import to:', 'wp-photo-album-plus' ) .
956
+ wppa_album_select_a( array( 'path' => true,
957
+ 'selected' => wppa_get_option( 'wppa-video-album-import-'.wppa_get_user(), '0' ),
958
+ 'addpleaseselect' => true,
959
+ 'checkowner' => true,
960
+ 'checkupload' => true,
961
+ 'sort' => true,
962
+ 'optionclass' => '',
963
+ 'tagopen' => '<select name="wppa-video-album" id="wppa-video-album" >',
964
+ 'tagname' => 'wppa-video-album',
965
+ 'tagid' => 'wppa-video-album',
966
+ 'tagonchange' => '',
967
+ 'multiple' => false,
968
+ 'tagstyle' => '',
969
+ ) ) .
970
+ wppa_edit_album_link_button( 'wppa-video-album' ) .
971
+ '</p>' );
972
+
973
+ // Header of video list
974
+ wppa_echo( '
975
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
976
+ <thead>
977
+ <tr>
 
 
 
 
 
 
 
 
978
  <td>
979
  <input
980
  type="checkbox"
981
+ id="all-video"
 
982
  checked="checked"
983
+ onchange="checkAll( \'all-video\', \'.wppa-video\' )"
984
  />
985
  <b>
986
  &nbsp;&nbsp;' .
987
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
 
 
 
988
  </b>
989
  </td>' );
990
+ if ( $is_sub_depot ) {
991
+ wppa_echo( '
992
+ <td>
993
+ <input
994
+ type="checkbox"
995
+ id="del-after-v"
996
+ name="del-after-v"
997
+ checked="checked"
998
+ />
999
+ <b>
1000
+ &nbsp;&nbsp;' .
1001
+ __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1002
+ <small> ' .
1003
+ __( 'Files larger than 64MB will always be removed after successful import.', 'wp-photo-album-plus' ) . '
1004
+ </small>
1005
+ </b>
1006
+ </td>' );
1007
+ }
1008
+ wppa_echo( '
1009
+ </tr>
1010
+ </thead>
1011
+ </table>' );
1012
+
1013
+ // Video list
1014
+ wppa_echo( '
1015
+ <table class="form-table wppa-table widefat" style="margin-top:0">
1016
+ <tr>' );
1017
+ $ct = 0;
1018
+ $idx = '0';
1019
+ if ( is_array( $files ) ) foreach ( $files as $file ) {
1020
+ $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1021
+ if ( in_array( strtolower($ext), $wppa_supported_video_extensions ) ) {
1022
+ wppa_echo( '
1023
+ <td>
1024
+ <input
1025
+ type="checkbox"
1026
+ id="file-' . $idx . '"
1027
+ name="file-' . $idx . '"
1028
+ title="' . esc_attr( htmlspecialchars( $file ) ) . '"
1029
+ class="wppa-video"
1030
+ checked="checked"
1031
+ />
1032
+ <span
1033
+ id="name-file-' . $idx . '"
1034
+ >
1035
+ &nbsp;&nbsp;' .
1036
+ htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) .
1037
+ ' (' . sprintf( '%3.1f', wppa_filesize( $file ) / 1024 ) . ' kb)' . '
1038
+ </span>
1039
+ </td>' );
1040
+ if ( $ct == 3 ) {
1041
+ wppa_echo( '</tr><tr>' );
1042
+ $ct = 0;
1043
+ }
1044
+ else {
1045
+ $ct++;
1046
+ }
1047
+ }
1048
+ $idx++;
1049
  }
1050
  wppa_echo( '
1051
  </tr>
1052
+ </table>
1053
+ </div>' );
1054
+ }
1055
 
1056
+ // Display the audios
1057
+ if ( $audiocount && wppa_switch( 'enable_audio' ) ) {
1058
  wppa_echo( '
1059
+ <div
1060
+ style="border:1px solid gray;padding:4px;margin: 3px 0;"
1061
+ >' );
1062
+
1063
+ // Display available files
1064
+ wppa_echo( '
1065
+ <p><b>' .
1066
+ sprintf( _n( 'There is %d audio in the depot', 'There are %d audios in the depot', $audiocount, 'wp-photo-album-plus' ), $audiocount ) . '
1067
+ </b></p>' );
1068
+
1069
+ // Album to import to
1070
+ wppa_echo( '
1071
+ <p class="hideifupdate" >' .
1072
+ __( 'Album to import to:', 'wp-photo-album-plus' ) .
1073
+ wppa_album_select_a( array( 'path' => true,
1074
+ 'selected' => wppa_get_option( 'wppa-audio-album-import-'.wppa_get_user(), '0' ),
1075
+ 'addpleaseselect' => true,
1076
+ 'checkowner' => true,
1077
+ 'checkupload' => true,
1078
+ 'sort' => true,
1079
+ 'optionclass' => '',
1080
+ 'tagopen' => '<select name="wppa-audio-album" id="wppa-audio-album" >',
1081
+ 'tagname' => 'wppa-audio-album',
1082
+ 'tagid' => 'wppa-audio-album',
1083
+ 'tagonchange' => '',
1084
+ 'multiple' => false,
1085
+ 'tagstyle' => '',
1086
+ ) ) .
1087
+ wppa_edit_album_link_button( 'wppa-audio-album' ) . '
1088
+ </p>' );
1089
+
1090
+ // Header of audio list
1091
+ wppa_echo( '
1092
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
1093
+ <thead>
1094
+ <tr>
1095
  <td>
1096
  <input
1097
  type="checkbox"
1098
+ id="all-audio"
 
 
 
1099
  checked="checked"
1100
+ onchange="checkAll( \'all-audio\', \'.wppa-audio\' )"
1101
  />
1102
+ <b>
 
 
1103
  &nbsp;&nbsp;' .
1104
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1105
+ </b>
 
1106
  </td>' );
1107
+
1108
+ // The remove box
1109
+ if ( $is_sub_depot ) {
1110
+ wppa_echo( '
1111
+ <td>
1112
+ <input
1113
+ type="checkbox"
1114
+ id="del-after-u"
1115
+ name="del-after-u"
1116
+ checked="checked"
1117
+ />
1118
+ <b>
1119
+ &nbsp;&nbsp;' .
1120
+ __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1121
+ </b>
1122
+ </td>' );
1123
  }
1124
+ wppa_echo( '
1125
+ </tr>
1126
+ </thead>
1127
+ </table>' );
1128
+
1129
+ // Audio list
1130
+ wppa_echo( '
1131
+ <table class="form-table wppa-table widefat" style="margin-top:0">
1132
+ <tr>' );
1133
+ $ct = 0;
1134
+ $idx = '0';
1135
+ if ( is_array( $files ) ) foreach ( $files as $file ) {
1136
+ $ext = strtolower( substr( strrchr( $file, "." ), 1 ) );
1137
+ if ( in_array( strtolower($ext), $wppa_supported_audio_extensions ) ) {
1138
+ wppa_echo( '
1139
+ <td>
1140
+ <input
1141
+ type="checkbox"
1142
+ id="file-' . $idx . '"
1143
+ name="file-' . $idx . '"
1144
+ title="' . esc_attr( htmlspecialchars( $file ) ) . '"
1145
+ class="wppa-audio"
1146
+ checked="checked"
1147
+ />
1148
+ <span
1149
+ id="name-file-' . $idx . '"
1150
+ >
1151
+ &nbsp;&nbsp;' .
1152
+ htmlspecialchars( wppa_sanitize_file_name( basename( $file ) ) ) .
1153
+ ' (' . sprintf( '%3.1f', wppa_filesize( $file ) / 1024 ) . ' kb)' . '
1154
+ </span>
1155
+ </td>' );
1156
+ if ( $ct == 3 ) {
1157
+ wppa_echo( '</tr><tr>' );
1158
+ $ct = 0;
1159
+ }
1160
+ else {
1161
+ $ct++;
1162
+ }
1163
  }
1164
+ $idx++;
1165
  }
1166
+ wppa_echo( '
1167
+ </tr>
1168
+ </table>
1169
+ </div>' );
1170
+ }
 
 
 
 
 
 
 
 
 
1171
 
1172
+ // Display the csv files
1173
+ if ( $is_depot && $csvcount ) {
1174
  wppa_echo( '
1175
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
 
 
1176
 
1177
+ // Display number of files
1178
+ wppa_echo( '
1179
+ <p><b>' .
1180
+ sprintf( _n( 'There is %d .csv file in the depot', 'There are %d .csv files in the depot', $csvcount, 'wp-photo-album-plus' ), $csvcount ) . '
1181
+ </b></p>' );
1182
+
1183
+ // Header of .csv file list
1184
+ wppa_echo( '
1185
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
1186
+ <thead>
1187
+ <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1188
  <td>
1189
  <input
1190
  type="checkbox"
1191
+ id="all-csv"
 
1192
  checked="checked"
1193
+ onchange="checkAll( \'all-csv\', \'.wppa-csv\' )"
1194
  />
1195
  <b>
1196
  &nbsp;&nbsp;' .
1197
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1198
  </b>
1199
+ </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1200
  <td>
1201
  <input
1202
  type="checkbox"
1203
+ id="del-after-c"
1204
+ name="del-after-c"
 
 
1205
  checked="checked"
1206
+ disabled
1207
  />
1208
+ <b>
 
 
1209
  &nbsp;&nbsp;' .
1210
+ __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1211
+ </b>
1212
+ </td>
1213
+ </tr>
1214
+ </thead>
1215
+ </table>' );
1216
+
1217
+ // CSV file list
1218
+ wppa_echo( '
1219
+ <table class="form-table wppa-table widefat" style="margin-top:0">' );
1220
+ $ct = 0;
1221
+ $idx = '0';
1222
+ if ( is_array( $files ) ) foreach( $files as $csv ) {
1223
+ if ( wppa_is_file( $csv ) && strtolower( wppa_get_ext( $csv ) ) == 'csv' ) {
1224
+ wppa_echo( '
1225
+ <tr>
1226
+ <td>
1227
+ <input
1228
+ type="checkbox"
1229
+ id="file-' . $idx . '"
1230
+ name="file-' . $idx . '"
1231
+ class="wppa-csv"
1232
+ checked="checked"
1233
+ />
1234
+ <b>
1235
+ &nbsp;&nbsp;' .
1236
+ wppa_sanitize_file_name( basename( $csv ) ) .
1237
+ ' (' . sprintf( '%3.1f', wppa_filesize( $csv ) / 1024 ) . ' kb)' . '
1238
+ </b>
1239
+ </td>
1240
+ </tr>' );
1241
  }
1242
  $idx++;
1243
  }
1244
  wppa_echo( '
1245
+ </table>
1246
+ </div>' );
1247
+ }
 
 
 
 
 
 
1248
 
1249
+ // Display the document files
1250
+ if ( $is_depot && $documentcount ) {
1251
  wppa_echo( '
1252
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
 
 
1253
 
1254
+ // Display number of files
1255
+ wppa_echo( '
1256
+ <p><b>' .
1257
+ sprintf( _n( 'There is %d document file in the depot', 'There are %d document files in the depot', $documentcount, 'wp-photo-album-plus' ), $documentcount ) . '
1258
+ </b></p>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1259
 
1260
+ // Album to import to
1261
+ wppa_echo( '
1262
+ <p class="hideifupdate" >' .
1263
+ __( 'Album to import to:', 'wp-photo-album-plus' ) .
1264
+ wppa_album_select_a( array( 'path' => true,
1265
+ 'selected' => wppa_get_option( 'wppa-document-album-import-'.wppa_get_user(), '0' ),
1266
+ 'addpleaseselect' => true,
1267
+ 'checkowner' => true,
1268
+ 'checkupload' => true,
1269
+ 'sort' => true,
1270
+ 'optionclass' => '',
1271
+ 'tagopen' => '<select name="wppa-document-album" id="wppa-document-album" >',
1272
+ 'tagname' => 'wppa-document-album',
1273
+ 'tagid' => 'wppa-document-album',
1274
+ 'tagonchange' => '',
1275
+ 'multiple' => false,
1276
+ 'tagstyle' => '',
1277
+ ) ) .
1278
+ wppa_edit_album_link_button( 'wppa-document-album' ) . '
1279
+ </p>' );
1280
+
1281
+ // Header of .pdf file list
1282
+ wppa_echo( '
1283
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
1284
+ <thead>
1285
  <tr>
1286
  <td>
1287
  <input
1288
  type="checkbox"
1289
+ id="all-pdf"
 
 
1290
  checked="checked"
1291
+ onchange="checkAll( \'all-pdf\', \'.wppa-pdf\' )"
1292
  />
1293
  <b>
1294
  &nbsp;&nbsp;' .
1295
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
 
1296
  </b>
1297
+ </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1298
  <td>
1299
  <input
1300
  type="checkbox"
1301
+ id="del-after-d"
1302
+ name="del-after-d"
 
 
1303
  checked="checked"
1304
  />
1305
+ <b>
 
 
 
1306
  &nbsp;&nbsp;' .
1307
+ __( 'Remove from depot after successful import.', 'wp-photo-album-plus' ) . '
1308
+ </b>
1309
+ </td>
1310
+ </tr>
1311
+ </thead>
1312
+ </table>' );
1313
+
1314
+ // pdf file list
1315
+ wppa_echo( '
1316
+ <table class="form-table wppa-table widefat" style="margin-top:0">
1317
+ <tr>' );
1318
+ $ct = 0;
1319
+ $idx = '0';
1320
+ if ( is_array( $files ) ) foreach( $files as $pdf ) {
1321
+ if ( wppa_is_file( $pdf ) && strtolower( wppa_get_ext( $pdf ) ) == 'pdf' ) {
1322
+ wppa_echo( '
1323
+ <td>
1324
+ <input
1325
+ type="checkbox"
1326
+ id="file-' . $idx . '"
1327
+ name="file-' . $idx . '"
1328
+ title="' . esc_attr( $pdf ) . '"
1329
+ class="wppa-pdf"
1330
+ checked="checked"
1331
+ />
1332
+ &nbsp;&nbsp;
1333
+ <span
1334
+ id="name-file-' . $idx . '"
1335
+ >
1336
+ &nbsp;&nbsp;' .
1337
+ wppa_sanitize_file_name( basename( $pdf ) ) .
1338
+ ' (' . sprintf( '%3.1f', wppa_filesize( $pdf ) / 1024 ) . ' kb)' . '
1339
+ </span>
1340
+ </td>' );
1341
+ if ( $ct == 3 ) {
1342
+ wppa_echo( '</tr><tr>' );
1343
+ $ct = 0;
1344
+ }
1345
+ else {
1346
+ $ct++;
1347
+ }
1348
  }
1349
+ $idx++;
1350
  }
1351
+ wppa_echo( '
1352
+ </tr>
1353
+ </table>
1354
+ </div>' );
1355
+ }
 
 
 
 
 
 
 
1356
 
1357
+ // Display the directories to be imported as albums. Do this in the depot only!!
1358
+ if ( $is_depot && $dircount ) {
1359
  wppa_echo( '
1360
+ <div style="border:1px solid gray; padding:4px; margin: 3px 0">' );
 
 
1361
 
1362
+ // Display number of dirs
1363
+ wppa_echo( '
1364
+ <p><b>' .
1365
+ sprintf( _n( 'There is %d albumdirectory in the depot', 'There are %d albumdirectories in the depot', $dircount, 'wp-photo-album-plus' ), $dircount ) . '
1366
+ </b></p>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1367
 
1368
+ // Header of dirlist
1369
+ wppa_echo( '
1370
+ <table class="form-table wppa-table widefat" style="margin-bottom:0">
1371
+ <thead>
 
 
 
 
 
 
1372
  <tr>
1373
  <td>
1374
  <input
1375
  type="checkbox"
1376
+ id="all-dir"
 
 
1377
  checked="checked"
1378
+ onchange="checkAll( \'all-dir\', \'.wppa-dir\' )"
1379
  />
1380
+ <b>
1381
+ &nbsp;&nbsp;' .
1382
+ __( 'Check/uncheck all', 'wp-photo-album-plus' ) . '
1383
+ </b>
1384
+ </td>
1385
+ <td>
1386
+ <input
1387
+ type="checkbox"
1388
+ id="del-dir"
1389
+ name="del-dir"
1390
+ onchange="wppa_setCookie(\'removeemptydirs\', this.checked, \'365\')"' .
1391
+ ( wppa_get_cookie( 'removeemptydirs' ) == 'true' ? ' checked="checked"' : '' ) . '
1392
+ />
1393
+ <b>
1394
+ &nbsp;&nbsp;' .
1395
+ __( 'Remove empty dirs', 'wp-photo-album-plus' ) .
1396
+ '</b>
1397
  </td>
1398
+ </tr>
1399
+ </thead>
1400
+ </table>' );
1401
+
1402
+ // Dirlist
1403
+ wppa_echo( '
1404
+ <table class="form-table wppa-table widefat" style="margin-top:0">' );
1405
+ $ct = 0;
1406
+ $idx = '0';
1407
+ foreach( $files as $dir ) {
1408
+ if ( basename( $dir ) != '.' &&
1409
+ basename( $dir ) != '..' &&
1410
+ wppa_is_dir( $dir ) ) {
1411
+ wppa_echo( '
1412
+ <tr>
1413
+ <td>
1414
+ <input
1415
+ type="checkbox"
1416
+ id="file-' . $idx . '"
1417
+ name="file-' . $idx .'"
1418
+ class= "wppa-dir"
1419
+ checked="checked"
1420
+ />
1421
+ &nbsp;&nbsp;
1422
+ <b>' .
1423
+ htmlspecialchars( wppa_sanitize_file_name( basename( $dir ) ) ) . '
1424
+ </b>' );
1425
+ $subdirs = wppa_glob( $dir.'/*', WPPA_ONLYDIRS );
1426
+ $subfiles = wppa_glob( $dir.'/*', WPPA_ONLYFILES );
1427
+ $subdircount = count( $subdirs );
1428
+ $subfilecount = count( $subfiles );
1429
+
1430
+ wppa_echo( ' ' .
1431
+ sprintf( _n( 'Contains %d file', 'Contains %d files', $subfilecount, 'wp-photo-album-plus' ), $subfilecount ) );
1432
+ if ( $subdircount ) {
1433
+ wppa_echo( ' ' .
1434
+ sprintf( _n( 'and %d subdirectory', 'and %d subdirectories', $subdircount, 'wp-photo-album-plus' ), $subdircount ) );
1435
+ }
1436
+ wppa_echo( '
1437
+ </td>
1438
+ </tr>' );
1439
+ }
1440
+ $idx++;
1441
  }
1442
+ wppa_echo( '
1443
+ </table>
1444
+ </div>' );
1445
+ }
 
 
1446
 
1447
+ $the_js = '
1448
+ function wppaVfyAlbum() {
1449
+ var csvs = jQuery( ".wppa-csv" );
1450
+ if ( ! jQuery( "#wppa-update" ).prop( "checked" ) ) {
1451
+ if ( ! parseInt( jQuery( "#wppa-photo-album" ).val() ) &&
1452
+ ! parseInt( jQuery( "#wppa-video-album" ).val() ) &&
1453
+ ! parseInt( jQuery( "#wppa-audio-album" ).val() ) &&
1454
+ ! parseInt( jQuery( "#wppa-document-album" ).val() ) &&
1455
+ csvs.length == 0
1456
+ ) {
1457
+ alert( "Please select an album first" );
1458
+ return false;
1459
+ }
1460
  }
1461
+ return true;
1462
  }
1463
+ function wppaCheckInputVars() {
1464
+ var checks = jQuery( ":checked" );
1465
+ var nChecks = checks.length;
1466
+ var nMax = ' . ini_get( "max_input_vars" ) . ';
1467
+ if ( nMax == 0 ) nMax = 100;
1468
+ if ( nChecks > nMax ) {
1469
+ alert ( "There are "+nChecks+" boxes checked or selected, that is more than the maximum allowed number of "+nMax );
1470
+ return false;
1471
+ }
1472
+ var dirs = jQuery( ".wppa-dir" );
1473
+ var nDirsChecked = 0;
1474
+ if ( dirs.length > 0 ) {
1475
+ var i = 0;
1476
+ while ( i < dirs.length ) {
1477
+ if ( jQuery( dirs[i] ).prop( "checked" ) ) {
1478
+ nDirsChecked++;
1479
+ }
1480
+ i++;
1481
  }
 
1482
  }
1483
+ var zips = jQuery( ".wppa-zip" );
1484
+ var nZipsChecked = 0;
1485
+ if ( zips.length > 0 ) {
1486
+ var i = 0;
1487
+ while ( i < zips.length ) {
1488
+ if ( jQuery( zips[i] ).prop( "checked" ) ) {
1489
+ nZipsChecked++;
1490
+ }
1491
+ i++;
1492
  }
 
1493
  }
1494
+ // If no dirs to import checked, there must be an album selected
1495
+ if ( 0 == nDirsChecked && 0 == nZipsChecked && ! wppaVfyAlbum() ) return false;
1496
+ return true;
1497
  }
 
 
 
 
1498
 
1499
+ var wppaImportRuns = false;
1500
+ var wppaTimer;
1501
+ function wppaDoAjaxImport() {
1502
+ jQuery( "#wppa-spinner" ).css( "display", "none" );
1503
+
1504
+ var data = "";
1505
+ data += "wppa-update-check="+jQuery( "#wppa-update-check" ).val();
1506
+ data += "&wppa-photo-album="+jQuery( "#wppa-photo-album" ).val();
1507
+ data += "&wppa-video-album="+jQuery( "#wppa-video-album" ).val();
1508
+ data += "&wppa-audio-album="+jQuery( "#wppa-audio-album" ).val();
1509
+ data += "&wppa-document-album="+jQuery( "#wppa-document-album" ).val();
1510
+ data += "&wppa-watermark-file="+jQuery( "#wppa-watermark-file" ).val();
1511
+ data += "&wppa-watermark-pos="+jQuery( "#wppa-watermark-pos" ).val();
1512
+ if ( jQuery( "#cre-album" ).prop( "checked" ) ) data += "&cre-album="+jQuery( "#cre-album" ).val();
1513
+ if ( jQuery( "#use-backup" ).prop( "checked" ) ) data += "&use-backup=1";
1514
+ if ( jQuery( "#wppa-update" ).prop( "checked" ) ) data += "&wppa-update=1";
1515
+ if ( jQuery( "#wppa-nodups" ).prop( "checked" ) ) data += "&wppa-nodups=1";
1516
+ if ( jQuery( "#del-after-p" ).prop( "checked" ) ) data += "&del-after-p=1";
1517
+ if ( jQuery( "#del-after-f" ).prop( "checked" ) ) data += "&del-after-f=1";
1518
+ if ( jQuery( "#del-after-v" ).prop( "checked" ) ) data += "&del-after-v=1";
1519
+ if ( jQuery( "#del-after-u" ).prop( "checked" ) ) data += "&del-after-u=1";
1520
+ if ( jQuery( "#del-after-d" ).prop( "checked" ) ) data += "&del-after-d=1";
1521
+ data += "&wppa-import-submit=ajax";
1522
+
1523
+ var files = jQuery( ":checked" );
1524
+ var found = false;
1525
+ var i=0;
1526
+ var elm;
1527
+ var fulldata;
1528
+ for ( i=0; i<files.length; i++ ) {
1529
+ found = false; // assume done
1530
+ elm = files[i];
1531
+ // Is it a file checkbox?
1532
+ var temp = elm.id.split( "-" );
1533
+ if ( temp[0] != "file" ) continue; // no
1534
+ fulldata = data+"&import-ajax-file="+elm.title;
1535
+ found = true;
1536
+ break;
1537
+ }
1538
+ // alert( data );
1539
+ if ( ! found ) {
1540
+ wppaStopAjaxImport();
1541
+ return; // nothing left
1542
+ }
1543
+ // found one, do it
1544
+ var oldhtml=jQuery( "#name-"+elm.id ).html();
1545
+ var xmlhttp = wppaGetXmlHttp();
1546
+ xmlhttp.onreadystatechange = function() {
1547
+ if ( xmlhttp.readyState == 4 ) {
1548
+ if ( xmlhttp.status!=404 ) {
1549
+ var resp = xmlhttp.responseText;
1550
+
1551
+ //
1552
+ if ( resp.length == 0 ) {
1553
+ jQuery( "#name-"+elm.id ).html("<span style=\'color:red\'>Timeout</span>" );
1554
+ wppaStopAjaxImport();
1555
+ return;
1556
+ }
1557
+ //
1558
+ if ( resp.indexOf( "Server" ) != -1 && resp.indexOf( "Error" ) != -1 ) {
1559
+ resp = "<span style=\'color:red\'>Server error</span>";
1560
+ }
1561
+ jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b>"+resp+"</b>" );
1562
+ elm.checked = "";
1563
+ if ( jQuery( "#del-after-p" ).prop( "checked" ) ||
1564
+ jQuery( "#del-after-f" ).prop( "checked" ) ) {
1565
+ elm.disabled = "disabled";
1566
+ elm.title = "";
1567
+ }
1568
+ if ( wppaImportRuns ) {
1569
+ wppaTimer = setTimeout( "wppaDoAjaxImport()", jQuery( "#wppa-delay" ).val() ); // was 100
1570
+ jQuery( "#wppa-spinner" ).css( "display", "inline" );
1571
+ }
1572
  }
1573
+ else {
1574
+ jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b>Not found</b>" );
 
1575
  }
1576
  }
1577
+ }
1578
+ var url = wppaAjaxUrl+"?action=wppa&wppa-action=import";
1579
+ xmlhttp.open( "POST",url,true );
1580
+ xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
1581
+ xmlhttp.send( fulldata );
1582
+ jQuery( "#name-"+elm.id ).html( "&nbsp;&nbsp;<b style=\'color:blue\' >" + "' . __( "Working...", "wp-photo-album-plus" ) . '" + "</b>" );
1583
+ if ( wppaImportRuns ) {
1584
+ jQuery( "#wppa-start-ajax" ).css( "display", "none" );
1585
+ jQuery( "#wppa-stop-ajax" ).css( "display", "inline" );
1586
  }
1587
  }
1588
+ function wppaStopAjaxImport() {
1589
+ wppaImportRuns = false;
1590
+ clearTimeout( wppaTimer );
1591
+ jQuery( "#wppa-start-ajax" ).css( "display", "inline" );
1592
+ jQuery( "#wppa-stop-ajax" ).css( "display", "none" );
1593
+ jQuery( "#wppa-spinner" ).css( "display", "none" );
1594
+ }';
1595
+
1596
+ wppa_add_inline_script( 'wppa-admin', $the_js );
1597
+
1598
+ // The submit button
1599
+ wppa_echo( '<p>' );
1600
+ if ( $albumcount || $dircount || $zipcount || $csvcount ) {
1601
+ wppa_echo( '
1602
+ <input
1603
+ type="submit"
1604
+ onclick="return wppaCheckInputVars()"
1605
+ class="button-primary"
1606
+ id="submit"
1607
+ name="wppa-import-submit"
1608
+ value="' . __( 'Import', 'wp-photo-album-plus' ) . '"
1609
+ />' );
1610
  }
1611
+ if ( ( $photocount || $videocount || $audiocount || $documentcount ) && ! $albumcount && ! $dircount && ! $zipcount && ! $csvcount ) {
1612
+ wppa_echo( '
1613
+ <input
1614
+ id="wppa-start-ajax"
1615
+ type="button"
1616
+ onclick="if (wppaVfyAlbum()) {wppaImportRuns=true;wppaDoAjaxImport()}"
1617
+ class="button-primary"
1618
+ value="' . esc_attr( __( 'Start Import', 'wp-photo-album-plus' ) ) . '"
1619
+ />
1620
+ <input
1621
+ id="wppa-stop-ajax"
1622
+ style="display:none;"
1623
+ type="button"
1624
+ onclick="wppaStopAjaxImport()"
1625
+ class="button-primary"
1626
+ value="' . esc_attr( __( 'Stop Import', 'wp-photo-album-plus' ) ) . '"
 
 
 
 
 
 
1627
  />' );
1628
+ }
 
1629
  wppa_echo( '
1630
+ </p>
1631
+ </form>' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1632
  }
1633
  else {
1634
+ if ( $source_type == 'local' ) {
1635
+ wppa_ok_message( __( 'There are no importable files found in directory:', 'wp-photo-album-plus' ).' '.$source );
1636
+ }
1637
+ else {
1638
+ wppa_ok_message( __( 'There are no photos found or left to process at url:', 'wp-photo-album-plus' ).' '.$source_url );
1639
+ }
1640
  }
 
 
 
 
 
 
1641
  wppa_echo( '
1642
+ <br><b>' .
1643
+ __( 'You can import the following file types:', 'wp-photo-album-plus' ) . '
1644
+ </b><br>' );
1645
+ if ( wppa_get_option( 'wppa_import_source_type_' . $user, 'local' ) == 'remote' ) {
1646
+ wppa_echo( '
1647
+ <br>' .
1648
+ __( 'Photo file types:', 'wp-photo-album-plus' ) . '
1649
+ .jpg .jpeg .png' );
 
 
 
 
 
 
1650
  }
1651
+ else {
1652
+ if ( PHP_VERSION_ID >= 50207 ) {
1653
+ wppa_echo( '<br>' .
1654
+ __( 'Compressed file types: .zip', 'wp-photo-album-plus' ) );
1655
+ }
1656
 
 
1657
  wppa_echo( '<br>' .
1658
+ __( 'Photo file types:', 'wp-photo-album-plus' ) );
1659
+ foreach ( $wppa_supported_photo_extensions as $ext ) {
1660
  wppa_echo( ' .' . $ext );
1661
  }
1662
+
1663
+ if ( wppa_switch( 'enable_video' ) ) {
1664
+ wppa_echo( '<br>' .
1665
+ __( 'Video file types:', 'wp-photo-album-plus' ) );
1666
+ foreach ( $wppa_supported_video_extensions as $ext ) {
1667
+ wppa_echo( ' .' . $ext );
1668
+ }
1669
  }
1670
+ if ( wppa_switch( 'enable_audio' ) ) {
1671
+ wppa_echo( '<br>' .
1672
+ __( 'Audio file types:', 'wp-photo-album-plus' ) );
1673
+ foreach ( $wppa_supported_audio_extensions as $ext ) {
1674
+ wppa_echo( ' .' . $ext );
1675
+ }
1676
+ }
1677
+ if ( in_array( 'pdf', wppa_get_supported_extensions() ) ) {
1678
+ wppa_echo( '<br>' .
1679
+ __( 'Document file type: .pdf', 'wp-photo-album-plus' ) );
1680
+ }
1681
+ wppa_echo( '
1682
+ <br>' . __( 'WPPA+ file types: .amf .pmf', 'wp-photo-album-plus' ) . '
1683
+ <br>' . __( 'Custom data files of type .csv', 'wp-photo-album-plus' ) . '
1684
+ <br>' . __( 'Directories with optional subdirs containig photos', 'wp-photo-album-plus' ) . '
1685
+ <br><br>' . __( 'Your depot directory is:', 'wp-photo-album-plus' ) . '
1686
+ <b> .../' . WPPA_DEPOT . '/</b>' );
1687
  }
 
 
 
 
 
 
 
 
 
 
 
1688
 
1689
+ if ( wppa( 'continue' ) ) {
1690
+ wppa_warning_message( __( 'Trying to continue...', 'wp-photo-album-plus' ) );
1691
+ $the_js = 'document.location=\'' . get_admin_url() . 'admin.php?page=wppa_import_photos&continue=1&nonce=' . wp_create_nonce( 'dirimport' ) . '\';';
1692
+ wppa_add_inline_script( 'wppa-admin', $the_js );
1693
+ }
1694
 
1695
+ wppa_echo( '<br><br>' );
1696
 
1697
+ wppa_echo( wppa_album_admin_footer() );
1698
 
1699
+ wppa_echo( '</div><!-- .wrap -->' );
1700
+ }
1701
 
1702
  }
1703
 
1846
  return $files;
1847
  }
1848
 
 
1849
  // Do the import photos
1850
  function wppa_import_photos( $delp = false, $dela = false, $delz = false, $delv = false, $delu = false, $delc = false, $delf = false, $deld = false ) {
1851
  global $wpdb;
2978
  return $result;
2979
  }
2980
 
 
2981
  // Find dir is new album candidates
2982
  function wppa_get_dircount( $files ) {
2983
  $result = 0;
3022
  function wppa_get_meta_linktitle( $file, $opt = '' ) {
3023
  return wppa_get_meta_data( $file, 'lnkt', $opt );
3024
  }
 
3025
  function wppa_get_meta_data( $file, $item, $opt ) {
3026
  $result = '';
3027
  $opt2 = '';
3043
  return $result;
3044
  }
3045
 
 
3046
  function wppa_extract( $xpath, $delz ) {
3047
  // There are two reasons that we do not allow the directory structure from the zipfile to be restored.
3048
  // 1. we may have no create dir access rights.
3378
  /> ';
3379
 
3380
  return $result;
3381
+ }
3382
+
3383
+ // Do the import from realmedia
3384
+ function wppa_import_from_realmedia() {
3385
+ global $wpdb;
3386
+
3387
+ // Make sure source dir exists
3388
+ $sourcedir = wppa_get_source_dir();
3389
+ if ( ! wppa_is_dir( $sourcedir ) ) {
3390
+ @ wppa_mktree( $sourcedir );
3391
+ if ( ! wppa_is_dir( $sourcedir ) ) {
3392
+ wppa_log( 'err', 'Could not create wppa source directory' );
3393
+ wppa_echo( '<p style="color:red" >Fatal error: Could not create wppa source directory</p>' );
3394
+ return;
3395
+ }
3396
+ }
3397
+
3398
+ // Phase 1 create the albums
3399
+ $rml_albums = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_realmedialibrary", ARRAY_A );
3400
+ $done = true;
3401
+ foreach( $rml_albums as $rml_album ) {
3402
+
3403
+ // Get the rml album id
3404
+ $rml_id = $rml_album['id'];
3405
+
3406
+ // Already created?
3407
+ if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_albums WHERE rml_id = $rml_id" ) ) {
3408
+
3409
+ // Already exists, get its id to make sure album source dir exists
3410
+ $album = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums WHERE rml_id = $rml_id LIMIT 1" );
3411
+ $albdir = wppa_get_source_album_dir( $album );
3412
+ if ( ! wppa_is_dir( $albdir ) ) {
3413
+ @ wppa_mktree( $albdir );
3414
+ }
3415
+ }
3416
+
3417
+ // Not yet, create it
3418
+ else {
3419
+
3420
+ $rml_parent = $rml_album['parent'];
3421
+ $name = $rml_album['name'];
3422
+ $rml_album_id = $rml_album['id'];
3423
+
3424
+ if ( $rml_parent > '0' ) {
3425
+ $parent = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums WHERE rml_id = $rml_parent" );
3426
+ if ( ! $parent ) {
3427
+ wppa_log( 'err', 'Could not find parent when converting rml album #'.$rml_id );
3428
+ wppa_echo( '<p style="color:red" >Could not find parent when converting rml album #'.$rml_id.'</p>' );
3429
+ $parent = '0';
3430
+ $done = false;
3431
+ }
3432
+ }
3433
+ else {
3434
+ $parent = '0';
3435
+ }
3436
+
3437
+ $iret = wppa_create_album_entry( ['name' => $name, 'a_parent' => $parent, 'rml_id' => $rml_album_id ] );
3438
+ if ( $iret ) {
3439
+
3440
+ // Make sure album source dir exists
3441
+ $albdir = wppa_get_source_album_dir( $iret );
3442
+ if ( ! wppa_is_dir( $albdir ) ) {
3443
+ @ wppa_mktree( $albdir );
3444
+ }
3445
+
3446
+ // Tell whats done
3447
+ wppa_echo("<br>Created album $name with parent id $parent from rml album id $rml_album_id as wppa album id $iret");
3448
+ wppa_log( 'obs', "Album $iret created by conversion from realmedialibrary proc" );
3449
+ }
3450
+ }
3451
+
3452
+ // Time up?
3453
+ if ( wppa_is_time_up() ) {
3454
+ wppa_echo( '<h3 style="color:red;" >' . __( 'Time up, please restart', 'wp-photo-album-plus' ) . '</h3>' );
3455
+ return;
3456
+ }
3457
+ }
3458
+
3459
+ if ( ! $done ) {
3460
+ wppa_echo( '<h3 style="color:red;" >' . __( 'Could not create all albums yet, please restart', 'wp-photo-album-plus' ) . '</h3>' );
3461
+ return;
3462
+ }
3463
+
3464
+ // Phase 2 import the media
3465
+ $rml_posts = $wpdb->get_results( "SELECT * FROM $wpdb->wppa_realmedialibrary_posts", ARRAY_A );
3466
+ $done = true;
3467
+ foreach( $rml_posts as $rml_post ) {
3468
+
3469
+ $post_id = $rml_post['attachment'];
3470
+ $wp_post = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE ID = $post_id", ARRAY_A );
3471
+
3472
+ // Post found?
3473
+ if ( ! $wp_post ) {
3474
+ wppa_log( 'err', "Attachment $post_id not found while converting file from ealmedialibrary" );
3475
+ wppa_echo( '<p style="color:red" >Attachment ' . $post_id . ' not found while convering file from ealmedialibrary</p>' );
3476
+ $done = false;
3477
+ }
3478
+
3479
+ // Found
3480
+ else {
3481
+
3482
+ // Already converted?
3483
+ $entry_found = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE rml_id = $post_id" );
3484
+
3485
+ // Get the id to see if the files are there
3486
+ $files_only = false;
3487
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE rml_id = $post_id LIMIT 1" );
3488
+ $display_file = wppa_get_photo_path( $id );
3489
+ if ( $entry_found && wppa_is_file( $display_file ) ) {
3490
+ // Do nothing
3491
+ }
3492
+
3493
+ // Is a new one
3494
+ else {
3495
+
3496
+ $url = $wp_post['guid'];
3497
+ $path = str_replace( WPPA_CONTENT_URL, WPPA_CONTENT_PATH, $url );
3498
+ $file = basename( $path );
3499
+ $mime = $wp_post['post_mime_type'];
3500
+ $wp_post_id = $wp_post['ID'];
3501
+ $rml_album = $rml_post['fid'];
3502
+ $album = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_albums WHERE rml_id = $rml_album" );
3503
+ $desc = $wp_post['post_content'];
3504
+ $ext = strtolower( wppa_get_ext( $file ) );
3505
+
3506
+ if ( $album ) {
3507
+ wppa_echo( "<br>Importing $path of type $mime in post $wp_post_id from rml album $rml_album to wppa album $album" );
3508
+
3509
+ // Dispatch on filetype
3510
+ switch ( $ext ) {
3511
+
3512
+ case 'pdf':
3513
+
3514
+ // Files only?
3515
+ if ( $entry_found ) {
3516
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE rml_id = $post_id LIMIT 1" );
3517
+ }
3518
+
3519
+ // Create db entry. Assume poster image will be creted by imagick or uploaded, so set ext to jpg. wppa_is_pdf looks at filename extension.
3520
+ else {
3521
+ $id = wppa_create_photo_entry( array( 'album' => $album,
3522
+ 'ext' => 'jpg',
3523
+ 'filename' => wppa_strip_ext( $file ) . '.pdf',
3524
+ 'rml_id' => $post_id,
3525
+ ) );
3526
+ }
3527
+
3528
+ // Success
3529
+ if ( $id ) {
3530
+
3531
+ // Copy source file
3532
+ wppa_copy( $path, wppa_get_source_album_dir( $album ) . '/' . wppa_strip_ext( $file ) . '.pdf' );
3533
+
3534
+ // Make the photo files will creatre poster .jpg if imagick is active
3535
+ wppa_make_the_photo_files( wppa_get_source_album_dir( $album ) . '/' . wppa_strip_ext( $file ) . '.pdf', $id, 'pdf' );
3536
+ }
3537
+
3538
+ // Failed
3539
+ else {
3540
+ wppa_log( 'err', "Could not import $file" );
3541
+ wppa_echo( '<p style="color:red">' . "Could not import $file" . '</p>');
3542
+ }
3543
+ break;
3544
+
3545
+ case 'jpg':
3546
+ case 'jpeg':
3547
+ case 'png':
3548
+ case 'gif':
3549
+
3550
+ // Files only?
3551
+ if ( $entry_found ) {
3552
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE rml_id = $post_id LIMIT 1" );
3553
+ }
3554
+
3555
+ // Create db entry.
3556
+ else {
3557
+ $id = wppa_create_photo_entry( array( 'album' => $album,
3558
+ 'ext' => $ext,
3559
+ 'filename' => wppa_strip_ext( $file ) . '.' . $ext,
3560
+ 'rml_id' => $post_id,
3561
+ ) );
3562
+ }
3563
+
3564
+ // Success
3565
+ if ( $id ) {
3566
+
3567
+ // Copy source file
3568
+ wppa_copy( $path, wppa_get_source_album_dir( $album ) . '/' . wppa_strip_ext( $file ) . '.' . $ext );
3569
+
3570
+ // Make the photo files
3571
+ wppa_make_the_photo_files( wppa_get_source_album_dir( $album ) . '/' . wppa_strip_ext( $file ) . '.' . $ext, $id, $ext );
3572
+ }
3573
+
3574
+ // Failed
3575
+ else {
3576
+ wppa_log( 'err', "Could not import $file" );
3577
+ wppa_echo( '<p style="color:red">' . "Could not import $file" . '</p>');
3578
+ }
3579
+ break;
3580
+
3581
+ case 'mp4':
3582
+ case 'ogv':
3583
+ case 'webm':
3584
+ case 'mp3':
3585
+ case 'wav':
3586
+ case 'ogg':
3587
+
3588
+ // Files only?
3589
+ if ( $entry_found ) {
3590
+ $id = $wpdb->get_var( "SELECT id FROM $wpdb->wppa_photos WHERE rml_id = $post_id LIMIT 1" );
3591
+ }
3592
+
3593
+ // Create db entry.
3594
+ else {
3595
+ $id = wppa_create_photo_entry( array( 'album' => $album,
3596
+ 'ext' => 'xxx',
3597
+ 'filename' => wppa_strip_ext( $file ) . '.' . $ext,
3598
+ 'rml_id' => $post_id,
3599
+ ) );
3600
+ }
3601
+
3602
+ // Success
3603
+ if ( $id ) {
3604
+
3605
+ // Add file
3606
+ $newpath = wppa_strip_ext( wppa_get_photo_path( $id, false ) ) . '.' . $ext;
3607
+ wppa_copy( $path, $newpath );
3608
+
3609
+ // Make sure ext is set to xxx after adding audio or video
3610
+ wppa_update_photo( array( 'id' => $id,
3611
+ 'filename' => wppa_strip_ext( $file ) . '.xxx',
3612
+ 'ext' => 'xxx',
3613
+ ) );
3614
+
3615
+ }
3616
+
3617
+ // Failed
3618
+ else {
3619
+ wppa_log( 'err', "Could not import $file" );
3620
+ wppa_echo( '<p style="color:red">' . "Could not import $file" . '</p>');
3621
+ }
3622
+ break;
3623
+
3624
+ default:
3625
+ wppa_log( 'err', 'Unsupported filetype encountered: ' . $ext );
3626
+ }
3627
+ }
3628
+
3629
+ else {
3630
+ $done = false;
3631
+ }
3632
+
3633
+ }
3634
+ }
3635
+
3636
+ // Time up?
3637
+ if ( wppa_is_time_up() ) {
3638
+ wppa_echo( '<h3 style="color:red;" >' . __( 'Time up, please restart', 'wp-photo-album-plus' ) . '</h3>' );
3639
+ wppa_invalidate_treecounts();
3640
+ return;
3641
+ }
3642
+ }
3643
+
3644
+ if ( ! $done ) {
3645
+ wppa_echo( '<h3 style="color:red;" >' . __( 'Could not import all media items, please restart', 'wp-photo-album-plus' ) . '</h3>' );
3646
+ wppa_invalidate_treecounts();
3647
+ return;
3648
+ }
3649
+
3650
+ wppa_invalidate_treecounts();
3651
  }
wppa-settings-autosave.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
- * Version 8.2.05.002
7
  *
8
  */
9
 
@@ -345,6 +345,7 @@ global $wppa_subtab_names;
345
  'amp/amp.php',
346
  );
347
  $plugins = wppa_get_option('active_plugins');
 
348
  $matches = array_intersect($blacklist_plugins, $plugins);
349
  foreach ( $matches as $bad ) {
350
  wppa_error_message(__('Please de-activate plugin <i style="font-size:14px;">', 'wp-photo-album-plus' ).substr($bad, 0, strpos($bad, '/')).__('. </i>This plugin will cause wppa+ to function not properly.', 'wp-photo-album-plus' ));
3
  * Package: wp-photo-album-plus
4
  *
5
  * manage all options
6
+ * Version 8.2.05.003
7
  *
8
  */
9
 
345
  'amp/amp.php',
346
  );
347
  $plugins = wppa_get_option('active_plugins');
348
+
349
  $matches = array_intersect($blacklist_plugins, $plugins);
350
  foreach ( $matches as $bad ) {
351
  wppa_error_message(__('Please de-activate plugin <i style="font-size:14px;">', 'wp-photo-album-plus' ).substr($bad, 0, strpos($bad, '/')).__('. </i>This plugin will cause wppa+ to function not properly.', 'wp-photo-album-plus' ));
wppa-setup.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
- * Version 8.2.05.002
7
  *
8
  */
9
 
@@ -75,6 +75,7 @@ global $wppa_error;
75
  scheduledel tinytext NOT NULL,
76
  status tinytext NOT NULL,
77
  max_children tinytext NOT NULL,
 
78
  PRIMARY KEY (id),
79
  KEY parentkey (a_parent)
80
  ) DEFAULT CHARACTER SET utf8;";
@@ -122,6 +123,7 @@ global $wppa_error;
122
  dlcount bigint(20) NOT NULL default '0',
123
  thumblock smallint(5) default '0',
124
  duration tinytext NOT NULL,
 
125
  PRIMARY KEY (id),
126
  KEY albumkey (album),
127
  KEY statuskey (status(6))
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains all the setup stuff
6
+ * Version 8.2.05.003
7
  *
8
  */
9
 
75
  scheduledel tinytext NOT NULL,
76
  status tinytext NOT NULL,
77
  max_children tinytext NOT NULL,
78
+ rml_id tinytext NOT NULL,
79
  PRIMARY KEY (id),
80
  KEY parentkey (a_parent)
81
  ) DEFAULT CHARACTER SET utf8;";
123
  dlcount bigint(20) NOT NULL default '0',
124
  thumblock smallint(5) default '0',
125
  duration tinytext NOT NULL,
126
+ rml_id tinytext NOT NULL,
127
  PRIMARY KEY (id),
128
  KEY albumkey (album),
129
  KEY statuskey (status(6))
wppa-wpdb-insert.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
- * Version 8.2.05.002
7
  *
8
  */
9
 
@@ -317,6 +317,7 @@ global $wpdb;
317
  'dlcount' => '0',
318
  'thumblock' => '0',
319
  'duration' => '',
 
320
  ) );
321
 
322
  $args = apply_filters( 'wppa_photo_entry', $args );
@@ -375,9 +376,10 @@ global $wpdb;
375
  sname,
376
  dlcount,
377
  thumblock,
378
- duration
 
379
  )
380
- VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
381
  $args['id'],
382
  $args['album'],
383
  $args['ext'],
@@ -419,7 +421,8 @@ global $wpdb;
419
  $args['sname'],
420
  $args['dlcount'],
421
  $args['thumblock'],
422
- $args['duration']
 
423
  );
424
  $iret = $wpdb->query( $query );
425
 
@@ -474,6 +477,7 @@ global $wpdb;
474
  'scheduledel' => '',
475
  'status' => 'publish',
476
  'max_children' => '0',
 
477
  ) );
478
 
479
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
@@ -511,9 +515,10 @@ global $wpdb;
511
  upload_limit_tree,
512
  scheduledel,
513
  status,
514
- max_children
 
515
  )
516
- VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
517
  $args['id'],
518
  trim( $args['name'] ),
519
  trim( $args['description'] ),
@@ -547,7 +552,8 @@ global $wpdb;
547
  $args['upload_limit_tree'],
548
  $args['scheduledel'],
549
  $args['status'],
550
- $args['max_children']
 
551
  );
552
  $iret = $wpdb->query( $query );
553
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that add new records
6
+ * Version 8.2.05.003
7
  *
8
  */
9
 
317
  'dlcount' => '0',
318
  'thumblock' => '0',
319
  'duration' => '',
320
+ 'rml_id' => '',
321
  ) );
322
 
323
  $args = apply_filters( 'wppa_photo_entry', $args );
376
  sname,
377
  dlcount,
378
  thumblock,
379
+ duration,
380
+ rml_id
381
  )
382
+ VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
383
  $args['id'],
384
  $args['album'],
385
  $args['ext'],
421
  $args['sname'],
422
  $args['dlcount'],
423
  $args['thumblock'],
424
+ $args['duration'],
425
+ $args['rml_id']
426
  );
427
  $iret = $wpdb->query( $query );
428
 
477
  'scheduledel' => '',
478
  'status' => 'publish',
479
  'max_children' => '0',
480
+ 'rml_id' => '',
481
  ) );
482
 
483
  if ( ! wppa_is_id_free( WPPA_ALBUMS, $args['id'] ) ) $args['id'] = wppa_nextkey( WPPA_ALBUMS );
515
  upload_limit_tree,
516
  scheduledel,
517
  status,
518
+ max_children,
519
+ rml_id
520
  )
521
+ VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",
522
  $args['id'],
523
  trim( $args['name'] ),
524
  trim( $args['description'] ),
552
  $args['upload_limit_tree'],
553
  $args['scheduledel'],
554
  $args['status'],
555
+ $args['max_children'],
556
+ $args['rml_id']
557
  );
558
  $iret = $wpdb->query( $query );
559
 
wppa-wpdb-update.php CHANGED
@@ -3,7 +3,7 @@
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that update records
6
- * Version 8.2.04.005
7
  *
8
  */
9
 
@@ -127,6 +127,10 @@ global $wpdb;
127
  if ( is_numeric( $itemvalue ) ) {
128
  $doit = true;
129
  }
 
 
 
 
130
  default:
131
  wppa_log( 'Error', 'Not implemented in wppa_update_album(): '.$itemname );
132
  return false;
@@ -266,6 +270,10 @@ global $wpdb;
266
  $itemvalue = sprintf( '%4.2f', $itemvalue );
267
  $doit = true;
268
  break;
 
 
 
 
269
 
270
  default:
271
 
3
  * Package: wp-photo-album-plus
4
  *
5
  * Contains low-level wpdb routines that update records
6
+ * Version 8.2.05.003
7
  *
8
  */
9
 
127
  if ( is_numeric( $itemvalue ) ) {
128
  $doit = true;
129
  }
130
+ case 'rml_id':
131
+ if ( is_numeric( $itemvalue ) ) {
132
+ $doit = true;
133
+ }
134
  default:
135
  wppa_log( 'Error', 'Not implemented in wppa_update_album(): '.$itemname );
136
  return false;
270
  $itemvalue = sprintf( '%4.2f', $itemvalue );
271
  $doit = true;
272
  break;
273
+ case 'rml_id':
274
+ if ( is_numeric( $itemvalue ) ) {
275
+ $doit = true;
276
+ }
277
 
278
  default:
279
 
wppa.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
- * Version: 8.2.05.002
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
@@ -24,7 +24,7 @@ global $wp_version;
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
- $wppa_api_version = '8.2.05.002'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30
 
2
  /*
3
  * Plugin Name: WP Photo Album Plus
4
  * Description: Easily manage and display your photo albums and slideshows within your WordPress site.
5
+ * Version: 8.2.05.003
6
  * Author: J.N. Breetvelt a.k.a. OpaJaap
7
  * Author URI: http://wppa.opajaap.nl/
8
  * Plugin URI: http://wordpress.org/extend/plugins/wp-photo-album-plus/
24
 
25
  /* WPPA GLOBALS */
26
  global $wppa_api_version;
27
+ $wppa_api_version = '8.2.05.003'; // WPPA software version
28
  global $wppa_revno;
29
  $wppa_revno = str_replace( '.', '', $wppa_api_version ); // WPPA db version
30