Responsive Lightbox & Gallery - Version 2.2.3

Version Description

  • Fix: Media Folders js and CSS issues in Media Library
  • Fix: Empty src attribute in Remote Library inserted images
  • Tweak: Remove featured image thumbnail from Media Library access
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Responsive Lightbox & Gallery
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

includes/class-folders.php CHANGED
@@ -289,7 +289,7 @@ class Responsive_Lightbox_Folders {
289
)
290
);
291
292
- echo ( $html === '' ? '<select name="' . $taxonomy . '" id="media-attachment-rl-folders-filters" class="postform"><option>' . __( 'All Files', 'responsive-lightbox' ) . '</option></select>' : $html );
293
}
294
}
295
289
)
290
);
291
292
+ echo ( $html === '' ? '<select name="' . $taxonomy . '" id="media-attachment-rl-folders-filters" class="postform"><option>' . __( 'All Files', 'responsive-lightbox' ) . '</option></select> ' : $html );
293
}
294
}
295
includes/class-frontend.php CHANGED
@@ -1482,6 +1482,9 @@ class Responsive_Lightbox_Frontend {
1482
// get main instance
1483
$rl = Responsive_Lightbox();
1484
1485
// is there rl_gallery ID?
1486
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1487
@@ -1694,6 +1697,9 @@ class Responsive_Lightbox_Frontend {
1694
// get main instance
1695
$rl = Responsive_Lightbox();
1696
1697
// is there rl_gallery ID?
1698
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1699
@@ -1882,6 +1888,9 @@ class Responsive_Lightbox_Frontend {
1882
// get main instance
1883
$rl = Responsive_Lightbox();
1884
1885
// is there rl_gallery ID?
1886
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1887
1482
// get main instance
1483
$rl = Responsive_Lightbox();
1484
1485
+ if ( ! is_array( $shortcode_atts ) )
1486
+ $shortcode_atts = wp_parse_args( $shortcode_atts, $defaults );
1487
+
1488
// is there rl_gallery ID?
1489
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1490
1697
// get main instance
1698
$rl = Responsive_Lightbox();
1699
1700
+ if ( ! is_array( $shortcode_atts ) )
1701
+ $shortcode_atts = wp_parse_args( $shortcode_atts, $defaults );
1702
+
1703
// is there rl_gallery ID?
1704
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1705
1888
// get main instance
1889
$rl = Responsive_Lightbox();
1890
1891
+ if ( ! is_array( $shortcode_atts ) )
1892
+ $shortcode_atts = wp_parse_args( $shortcode_atts, $defaults );
1893
+
1894
// is there rl_gallery ID?
1895
$rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1896
includes/class-galleries.php CHANGED
@@ -2958,15 +2958,18 @@ class Responsive_Lightbox_Galleries {
2958
$featured_image = get_post_meta( $gallery_id, '_rl_featured_image', true );
2959
2960
switch ( $featured_image_type ) {
2961
case 'url':
2962
$image = esc_url( $featured_image );
2963
break;
2964
2965
case 'id':
2966
$featured_image = (int) $featured_image;
2967
$image = wp_attachment_is_image( $featured_image ) ? $featured_image : $this->maybe_generate_thumbnail();
2968
break;
2969
2970
case 'image':
2971
default:
2972
// get gallery images
@@ -3304,7 +3307,7 @@ class Responsive_Lightbox_Galleries {
3304
* @return int Thumbnail ID
3305
*/
3306
public function maybe_generate_thumbnail() {
3307
- // get attachment
3308
$thumbnail_id = get_posts(
3309
array(
3310
'name' => 'responsive-lightbox-thumbnail',
@@ -3317,52 +3320,95 @@ class Responsive_Lightbox_Galleries {
3317
3318
// no attachment?
3319
if ( empty( $thumbnail_id ) ) {
3320
- // get upload directory data
3321
- $wp_upload_dir = wp_upload_dir();
3322
3323
- // get file path
3324
- $filepath = str_replace( '\\', '/', RESPONSIVE_LIGHTBOX_PATH . 'images/responsive-lightbox-thumbnail.png' );
3325
3326
- // get file name
3327
- $filename = basename( $filepath );
3328
3329
- // new filepath in upload dir
3330
- $new_filepath = $wp_upload_dir['path'] . '/' . $filename;
3331
3332
- // copty file to upload dir
3333
- copy( $filepath, $new_filepath );
3334
3335
- // get type of file
3336
- $filetype = wp_check_filetype( $filename );
3337
3338
- // insert attachment
3339
- $thumbnail_id = wp_insert_attachment(
3340
array(
3341
- 'guid' => $wp_upload_dir['url'] . '/' . $filename,
3342
- 'post_mime_type' => $filetype['type'],
3343
- 'post_title' => preg_replace( '/\.[^.]+#x2F;', '', $filename ),
3344
- 'post_content' => '',
3345
- 'post_parent' => 0,
3346
- 'post_status' => 'inherit'
3347
- ),
3348
- $new_filepath,
3349
- 0
3350
);
3351
3352
- // success?
3353
- if ( $thumbnail_id ) {
3354
- // make sure that this file is included
3355
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
3356
-
3357
- // update database with generated metadata for the attachment
3358
- wp_update_attachment_metadata( $thumbnail_id, wp_generate_attachment_metadata( $thumbnail_id, $new_filepath ) );
3359
- }
3360
- } else
3361
- $thumbnail_id = $thumbnail_id[0];
3362
3363
return (int) $thumbnail_id;
3364
}
3365
3366
/**
3367
* Prepare values option list.
3368
*
@@ -3710,18 +3756,19 @@ class Responsive_Lightbox_Galleries {
3710
$featured_image_type = ! empty( $post_data['rl_gallery_featured_image'] ) && in_array( $post_data['rl_gallery_featured_image'], array( 'id', 'url', 'image' ), true ) ? $post_data['rl_gallery_featured_image'] : 'id';
3711
3712
switch ( $featured_image_type ) {
3713
case 'url':
3714
$thumbnail_id = $this->maybe_generate_thumbnail();
3715
-
3716
$featured_image = isset( $post_data['_rl_thumbnail_url'] ) ? esc_url( $post_data['_rl_thumbnail_url'] ) : '';
3717
break;
3718
3719
case 'image':
3720
$thumbnail_id = $this->maybe_generate_thumbnail();
3721
-
3722
$featured_image = '';
3723
break;
3724
3725
case 'id':
3726
default:
3727
$featured_image = $thumbnail_id = isset( $post_data['_thumbnail_id'] ) ? (int) $post_data['_thumbnail_id'] : 0;
2958
$featured_image = get_post_meta( $gallery_id, '_rl_featured_image', true );
2959
2960
switch ( $featured_image_type ) {
2961
+ // custom url
2962
case 'url':
2963
$image = esc_url( $featured_image );
2964
break;
2965
2966
+ // attachment id
2967
case 'id':
2968
$featured_image = (int) $featured_image;
2969
$image = wp_attachment_is_image( $featured_image ) ? $featured_image : $this->maybe_generate_thumbnail();
2970
break;
2971
2972
+ // first image
2973
case 'image':
2974
default:
2975
// get gallery images
3307
* @return int Thumbnail ID
3308
*/
3309
public function maybe_generate_thumbnail() {
3310
+ // get old attachment
3311
$thumbnail_id = get_posts(
3312
array(
3313
'name' => 'responsive-lightbox-thumbnail',
3320
3321
// no attachment?
3322
if ( empty( $thumbnail_id ) ) {
3323
+ // get new attachment
3324
+ $thumbnail_id = get_posts(
3325
+ array(
3326
+ 'name' => 'responsive-lightbox-thumbnail',
3327
+ 'post_type' => 'attachment',
3328
+ 'post_status' => 'pending',
3329
+ 'numberposts' => 1,
3330
+ 'fields' => 'ids'
3331
+ )
3332
+ );
3333
+
3334
+ // no attachment?
3335
+ if ( empty( $thumbnail_id ) ) {
3336
+ // get upload directory data
3337
+ $wp_upload_dir = wp_upload_dir();
3338
+
3339
+ // get file path
3340
+ $filepath = str_replace( '\\', '/', RESPONSIVE_LIGHTBOX_PATH . 'images/responsive-lightbox-thumbnail.png' );
3341
+
3342
+ // get file name
3343
+ $filename = basename( $filepath );
3344
+
3345
+ // new filepath in upload dir
3346
+ $new_filepath = $wp_upload_dir['path'] . '/' . $filename;
3347
+
3348
+ // copty file to upload dir
3349
+ copy( $filepath, $new_filepath );
3350
3351
+ // get type of file
3352
+ $filetype = wp_check_filetype( $filename );
3353
3354
+ // force pending status for the attachment
3355
+ add_filter( 'wp_insert_attachment_data', array( $this, 'set_attachment_post_status' ) );
3356
3357
+ // insert attachment
3358
+ $thumbnail_id = wp_insert_attachment(
3359
+ array(
3360
+ 'guid' => $wp_upload_dir['url'] . '/' . $filename,
3361
+ 'post_mime_type' => $filetype['type'],
3362
+ 'post_title' => preg_replace( '/\.[^.]+#x2F;', '', $filename ),
3363
+ 'post_content' => '',
3364
+ 'post_parent' => 0,
3365
+ 'post_status' => 'inherit'
3366
+ ),
3367
+ $new_filepath,
3368
+ 0
3369
+ );
3370
+
3371
+ remove_filter( 'wp_insert_attachment_data', array( $this, 'set_attachment_post_status' ) );
3372
3373
+ // success?
3374
+ if ( $thumbnail_id ) {
3375
+ // make sure that this file is included
3376
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
3377
3378
+ // update database with generated metadata for the attachment
3379
+ wp_update_attachment_metadata( $thumbnail_id, wp_generate_attachment_metadata( $thumbnail_id, $new_filepath ) );
3380
+ }
3381
+ } else
3382
+ $thumbnail_id = $thumbnail_id[0];
3383
+ } else {
3384
+ // force pending status for the attachment
3385
+ add_filter( 'wp_insert_attachment_data', array( $this, 'set_attachment_post_status' ) );
3386
3387
+ $thumbnail_id = wp_update_post(
3388
array(
3389
+ 'ID' => $thumbnail_id[0],
3390
+ 'post_status' => 'pending'
3391
+ )
3392
);
3393
3394
+ remove_filter( 'wp_insert_attachment_data', array( $this, 'set_attachment_post_status' ) );
3395
+ }
3396
3397
return (int) $thumbnail_id;
3398
}
3399
3400
+ /**
3401
+ * Change status of new attachment thumbnail replacement.
3402
+ *
3403
+ * @param array $data Post data
3404
+ * @return array
3405
+ */
3406
+ function set_attachment_post_status( $data ) {
3407
+ $data['post_status'] = 'pending';
3408
+
3409
+ return $data;
3410
+ }
3411
+
3412
/**
3413
* Prepare values option list.
3414
*
3756
$featured_image_type = ! empty( $post_data['rl_gallery_featured_image'] ) && in_array( $post_data['rl_gallery_featured_image'], array( 'id', 'url', 'image' ), true ) ? $post_data['rl_gallery_featured_image'] : 'id';
3757
3758
switch ( $featured_image_type ) {
3759
+ // custom url
3760
case 'url':
3761
$thumbnail_id = $this->maybe_generate_thumbnail();
3762
$featured_image = isset( $post_data['_rl_thumbnail_url'] ) ? esc_url( $post_data['_rl_thumbnail_url'] ) : '';
3763
break;
3764
3765
+ // first image
3766
case 'image':
3767
$thumbnail_id = $this->maybe_generate_thumbnail();
3768
$featured_image = '';
3769
break;
3770
3771
+ // attachment id
3772
case 'id':
3773
default:
3774
$featured_image = $thumbnail_id = isset( $post_data['_thumbnail_id'] ) ? (int) $post_data['_thumbnail_id'] : 0;
includes/class-remote-library.php CHANGED
@@ -86,7 +86,7 @@ class Responsive_Lightbox_Remote_Library {
86
$attachment = wp_unslash( $_POST['attachment'] );
87
88
if ( isset( $attachment['remote_library_image'], $attachment['width'], $attachment['height'] ) ) {
89
- $html = preg_replace( '/src=(\'|")(.*?)(\'|")/', 'src="' . $url . '"', $html );
90
$html = preg_replace( '/width=(\'|")(.*?)(\'|")/', 'width="' . ( (int) $attachment['width'] ) . '"', $html );
91
$html = preg_replace( '/height=(\'|")(.*?)(\'|")/', 'height="' . ( (int) $attachment['height'] ) . '"', $html );
92
$html = preg_replace( '/(\s)?id="attachment_' . $id . '"/', '', $html );
86
$attachment = wp_unslash( $_POST['attachment'] );
87
88
if ( isset( $attachment['remote_library_image'], $attachment['width'], $attachment['height'] ) ) {
89
+ $html = preg_replace( '/src=(\'|")(.*?)(\'|")/', 'src="' . ( ! empty( $attachment['rl_url'] ) ? $attachment['rl_url'] : $url ) . '"', $html );
90
$html = preg_replace( '/width=(\'|")(.*?)(\'|")/', 'width="' . ( (int) $attachment['width'] ) . '"', $html );
91
$html = preg_replace( '/height=(\'|")(.*?)(\'|")/', 'height="' . ( (int) $attachment['height'] ) . '"', $html );
92
$html = preg_replace( '/(\s)?id="attachment_' . $id . '"/', '', $html );
js/admin-folders.js CHANGED
@@ -22,8 +22,7 @@
22
} );
23
}
24
25
- // are we ready?
26
- $( document ).ready( function() {
27
var RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post;
28
29
// extend media frame
@@ -84,8 +83,9 @@
84
if ( rlFoldersArgs.terms !== '' && terms.length > 0 ) {
85
filters[0] = root;
86
87
- $( $.parseHTML( rlFoldersArgs.terms ) ).find('option').each( function( i, option ) {
88
- term_id = parseInt( $(option).val() );
89
term_id = ( term_id === 0 ? 'all' : term_id );
90
last_priority = i + 2;
91
@@ -195,9 +195,14 @@
195
this.$el.closest( '.attachment-details' ).addClass( 'save-ready' ).removeClass( 'save-waiting' );
196
}
197
} );
198
199
// do nothing for wp_enqueue_media
200
if ( rlFoldersArgs.page === 'media' ) {
201
// folder change
202
$( document ).on( 'change', '#media-attachment-rl-folders-filters', function() {
203
$( '#rl_folders_upload_files' ).val( $( this ).val() );
@@ -223,6 +228,8 @@
223
} else {
224
// add tree
225
$( '#wp-media-grid .error' ).after( rlFoldersArgs.template );
226
}
227
228
// activate wholerow plugin if needed
@@ -519,7 +526,10 @@
519
$( '#rl_folders_upload_files' ).val( term_id === 'all' ? 0 : term_id );
520
521
// update term_id in uploader parameters
522
- rl_folder_id = parseInt( term_id ) || 0;
523
524
// enable/disable icons for folders
525
if ( term_id === 'all' )
@@ -709,7 +719,10 @@
709
// change uploading folder
710
$( document ).on( 'change', '#rl_folders_upload_files', function() {
711
// update term_id in uploader parameters
712
- rl_folder_id = parseInt( $( this ).val() ) || 0;
713
} );
714
715
//
@@ -877,16 +890,23 @@
877
drop: function( event, ui ) {
878
var node = $( event.target ).closest( 'li' ).find( 'a.jstree-anchor' ),
879
old_node = $( '#' + $( '#rl-folders-tree' ).jstree().get_selected().toString() + '_anchor' ),
880
- old_term_id = parseInt( old_node.data( 'term_id' ) ) || -1,
881
attachments = [],
882
- ids = $( '#the-list .check-column input[type="checkbox"]:checked' );
883
884
toggle_spinner( true );
885
886
// dropped single unchecked attachment?
887
- if ( ids.length === 0 ) {
888
attachments.push( ui.draggable.find( '.check-column input[type="checkbox"]' ).val() );
889
- } else {
890
ids.each( function( i, item ) {
891
attachments.push( parseInt( $( item ).val() ) );
892
} );
@@ -896,7 +916,7 @@
896
action: 'rl-folders-move-attachments',
897
attachment_ids: attachments,
898
old_term_id: old_term_id,
899
- new_term_id: parseInt( node.data( 'term_id' ) ) || -1,
900
nonce: rlFoldersArgs.nonce
901
} ).done( function( response ) {
902
try {
@@ -923,7 +943,6 @@
923
update_node_number( node, response.data, true );
924
}
925
} catch( e ) {
926
-
927
}
928
929
// hide spinner
@@ -977,9 +996,8 @@
977
$( this ).remove();
978
979
// display 'no media' text
980
- if ( $( 'ul.attachments li' ).length === 0 ) {
981
$( '.no-media' ).removeClass( 'hidden' );
982
- }
983
} );
984
}
985
@@ -994,7 +1012,6 @@
994
grid_frame.controller.deactivateMode( 'select' ).activateMode( 'edit' );
995
}
996
} catch( e ) {
997
-
998
}
999
1000
// hide spinner
@@ -1209,7 +1226,6 @@
1209
}
1210
};
1211
}
1212
-
1213
} else {
1214
// rename node
1215
$( '#media-attachment-rl-folders-filters option[value="' + term_id + '"]' ).text( response.data.name );
@@ -1234,6 +1250,9 @@
1234
1235
// force to update view
1236
$( '#media-attachment-rl-folders-filters' ).val( response.data.term_id ).change();
1237
}
1238
1239
// update upload select
22
} );
23
}
24
25
+ function initFolders() {
26
var RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post;
27
28
// extend media frame
83
if ( rlFoldersArgs.terms !== '' && terms.length > 0 ) {
84
filters[0] = root;
85
86
+ $( $.parseHTML( rlFoldersArgs.terms ) ).find( 'option' ).each( function( i, option ) {
87
+ term_id = parseInt( $( option ).val() );
88
+ console.log( term_id );
89
term_id = ( term_id === 0 ? 'all' : term_id );
90
last_priority = i + 2;
91
195
this.$el.closest( '.attachment-details' ).addClass( 'save-ready' ).removeClass( 'save-waiting' );
196
}
197
} );
198
+ }
199
200
+ // are we ready?
201
+ $( document ).ready( function() {
202
// do nothing for wp_enqueue_media
203
if ( rlFoldersArgs.page === 'media' ) {
204
+ initFolders();
205
+
206
// folder change
207
$( document ).on( 'change', '#media-attachment-rl-folders-filters', function() {
208
$( '#rl_folders_upload_files' ).val( $( this ).val() );
228
} else {
229
// add tree
230
$( '#wp-media-grid .error' ).after( rlFoldersArgs.template );
231
+
232
+ initFolders();
233
}
234
235
// activate wholerow plugin if needed
526
$( '#rl_folders_upload_files' ).val( term_id === 'all' ? 0 : term_id );
527
528
// update term_id in uploader parameters
529
+ rl_folder_id = parseInt( term_id );
530
+
531
+ if ( isNaN( rl_folder_id ) )
532
+ rl_folder_id = 0;
533
534
// enable/disable icons for folders
535
if ( term_id === 'all' )
719
// change uploading folder
720
$( document ).on( 'change', '#rl_folders_upload_files', function() {
721
// update term_id in uploader parameters
722
+ rl_folder_id = parseInt( $( this ).val() );
723
+
724
+ if ( isNaN( rl_folder_id ) )
725
+ rl_folder_id = 0;
726
} );
727
728
//
890
drop: function( event, ui ) {
891
var node = $( event.target ).closest( 'li' ).find( 'a.jstree-anchor' ),
892
old_node = $( '#' + $( '#rl-folders-tree' ).jstree().get_selected().toString() + '_anchor' ),
893
attachments = [],
894
+ ids = $( '#the-list .check-column input[type="checkbox"]:checked' ),
895
+ old_term_id = parseInt( old_node.data( 'term_id' ) ),
896
+ new_term_id = parseInt( node.data( 'term_id' ) );
897
+
898
+ if ( isNaN( old_term_id ) )
899
+ old_term_id = -1;
900
+
901
+ if ( isNaN( new_term_id ) )
902
+ new_term_id = -1;
903
904
toggle_spinner( true );
905
906
// dropped single unchecked attachment?
907
+ if ( ids.length === 0 )
908
attachments.push( ui.draggable.find( '.check-column input[type="checkbox"]' ).val() );
909
+ else {
910
ids.each( function( i, item ) {
911
attachments.push( parseInt( $( item ).val() ) );
912
} );
916
action: 'rl-folders-move-attachments',
917
attachment_ids: attachments,
918
old_term_id: old_term_id,
919
+ new_term_id: new_term_id,
920
nonce: rlFoldersArgs.nonce
921
} ).done( function( response ) {
922
try {
943
update_node_number( node, response.data, true );
944
}
945
} catch( e ) {
946
}
947
948
// hide spinner
996
$( this ).remove();
997
998
// display 'no media' text
999
+ if ( $( 'ul.attachments li' ).length === 0 )
1000
$( '.no-media' ).removeClass( 'hidden' );
1001
} );
1002
}
1003
1012
grid_frame.controller.deactivateMode( 'select' ).activateMode( 'edit' );
1013
}
1014
} catch( e ) {
1015
}
1016
1017
// hide spinner
1226
}
1227
};
1228
}
1229
} else {
1230
// rename node
1231
$( '#media-attachment-rl-folders-filters option[value="' + term_id + '"]' ).text( response.data.name );
1250
1251
// force to update view
1252
$( '#media-attachment-rl-folders-filters' ).val( response.data.term_id ).change();
1253
+
1254
+ if ( active_mode === 'list' )
1255
+ window.location.replace( response.data.url );
1256
}
1257
1258
// update upload select
js/admin-media.js CHANGED
@@ -81,7 +81,8 @@
81
RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post,
82
attachment_defaults = {
83
width: 0,
84
- height: 0
85
};
86
87
// add new attributes
@@ -131,9 +132,11 @@
131
if ( props.size === 'thumbnail' ) {
132
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.thumbnail_width;
133
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.thumbnail_height;
134
} else {
135
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.width;
136
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.height;
137
}
138
}
139
@@ -167,6 +170,9 @@
167
168
// restore defaulkt behavior
169
RLWPMediaViewMediaFramePost.remoteLibraryImage = false;
170
}
171
172
// return original function
81
RLWPMediaViewMediaFramePost = wp.media.view.MediaFrame.Post,
82
attachment_defaults = {
83
width: 0,
84
+ height: 0,
85
+ url: ''
86
};
87
88
// add new attributes
132
if ( props.size === 'thumbnail' ) {
133
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.thumbnail_width;
134
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.thumbnail_height;
135
+ RLWPMediaViewMediaFramePost.currentAttachment.url = attachment.thumbnail_url;
136
} else {
137
RLWPMediaViewMediaFramePost.currentAttachment.width = attachment.width;
138
RLWPMediaViewMediaFramePost.currentAttachment.height = attachment.height;
139
+ RLWPMediaViewMediaFramePost.currentAttachment.url = attachment.url;
140
}
141
}
142
170
171
// restore defaulkt behavior
172
RLWPMediaViewMediaFramePost.remoteLibraryImage = false;
173
+
174
+ if ( typeof data.attachment.url === 'undefined' )
175
+ data.attachment.rl_url = RLWPMediaViewMediaFramePost.currentAttachment.url;
176
}
177
178
// return original function
languages/responsive-lightbox.pot CHANGED
@@ -2,7 +2,7 @@
2
msgid ""
3
msgstr ""
4
"Project-Id-Version: Responsive Lightbox\n"
5
- "POT-Creation-Date: 2019-11-11 22:57+0100\n"
6
"PO-Revision-Date: 2015-05-12 12:06+0100\n"
7
"Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
8
"Language-Team: dFactory <info@dfactory.eu>\n"
@@ -16,65 +16,66 @@ msgstr ""
16
"X-Poedit-SourceCharset: UTF-8\n"
17
"X-Poedit-SearchPath-0: ..\n"
18
19
- #: ../includes/class-folders.php:165 ../includes/class-folders.php:193
20
- #: ../includes/class-folders.php:377 ../includes/class-folders.php:982
21
- #: ../includes/class-folders.php:1007
22
msgid "Root Folder"
23
msgstr ""
24
25
- #: ../includes/class-folders.php:189
26
msgid "Upload files to"
27
msgstr ""
28
29
- #: ../includes/class-folders.php:244 ../includes/class-folders.php:256
30
- #: ../includes/class-folders.php:979 ../includes/class-folders.php:1006
31
- #: ../includes/class-folders.php:1016 ../responsive-lightbox.php:1007
32
msgid "All Files"
33
msgstr ""
34
35
- #: ../includes/class-folders.php:1008
36
msgid "New Folder"
37
msgstr ""
38
39
- #: ../includes/class-folders.php:1009
40
msgid "Are you sure you want to delete this folder?"
41
msgstr ""
42
43
- #: ../includes/class-folders.php:1010
44
msgid "Are you sure you want to delete this folder with all subfolders?"
45
msgstr ""
46
47
- #: ../includes/class-folders.php:1032
48
#, php-format
49
msgid "Save new %s"
50
msgstr ""
51
52
- #: ../includes/class-folders.php:1033
53
#, php-format
54
msgid "Cancel adding new %s"
55
msgstr ""
56
57
- #: ../includes/class-folders.php:1035
58
#, php-format
59
msgid "Save %s"
60
msgstr ""
61
62
- #: ../includes/class-folders.php:1036
63
#, php-format
64
msgid "Cancel renaming %s"
65
msgstr ""
66
67
- #: ../includes/class-folders.php:1037
68
#, php-format
69
msgid "Delete %s"
70
msgstr ""
71
72
- #: ../includes/class-folders.php:1038
73
#, php-format
74
msgid "Expand %s"
75
msgstr ""
76
77
- #: ../includes/class-folders.php:1039
78
#, php-format
79
msgid "Collapse %s"
80
msgstr ""
@@ -104,10 +105,9 @@ msgid "Media File"
104
msgstr ""
105
106
#: ../includes/class-frontend.php:581 ../includes/class-galleries.php:164
107
- #: ../includes/class-galleries.php:1163 ../includes/class-settings.php:150
108
- #: ../includes/class-settings.php:626 ../includes/class-settings.php:685
109
- #: ../includes/class-widgets.php:93 ../includes/class-widgets.php:340
110
- #: ../includes/class-widgets.php:347
111
msgid "None"
112
msgstr ""
113
@@ -169,15 +169,15 @@ msgstr ""
169
msgid "Specify the number of columns."
170
msgstr ""
171
172
- #: ../includes/class-galleries.php:85 ../includes/class-galleries.php:3487
173
msgid "Status"
174
msgstr ""
175
176
- #: ../includes/class-galleries.php:86 ../src/gutenberg.js:57
177
msgid "Edit image"
178
msgstr ""
179
180
- #: ../includes/class-galleries.php:87 ../responsive-lightbox.php:1166
181
msgid "Remove image"
182
msgstr ""
183
@@ -194,7 +194,7 @@ msgstr ""
194
msgid "The settings below adjust the contents of the gallery."
195
msgstr ""
196
197
- #: ../includes/class-galleries.php:117 ../includes/class-galleries.php:3898
198
msgid "Media Library"
199
msgstr ""
200
@@ -699,7 +699,7 @@ msgid ""
699
"button below."
700
msgstr ""
701
702
- #: ../includes/class-galleries.php:1050 ../src/gutenberg.js:159
703
msgid "Edit gallery"
704
msgstr ""
705
@@ -707,7 +707,7 @@ msgstr ""
707
msgid "Insert gallery into post"
708
msgstr ""
709
710
- #: ../includes/class-galleries.php:1061 ../src/gutenberg.js:194
711
msgid "Select gallery"
712
msgstr ""
713
@@ -716,7 +716,7 @@ msgid "Cancel"
716
msgstr ""
717
718
#: ../includes/class-galleries.php:1277 ../includes/class-widgets.php:140
719
- #: ../responsive-lightbox.php:1068 ../responsive-lightbox.php:1167
720
msgid "Select images"
721
msgstr ""
722
@@ -765,109 +765,109 @@ msgstr ""
765
msgid "No data"
766
msgstr ""
767
768
- #: ../includes/class-galleries.php:2421
769
msgid "&laquo; Previous"
770
msgstr ""
771
772
- #: ../includes/class-galleries.php:2422
773
msgid "Next &raquo;"
774
msgstr ""
775
776
- #: ../includes/class-galleries.php:2552
777
msgid "(no title)"
778
msgstr ""
779
780
- #: ../includes/class-galleries.php:2566
781
msgid "Deselect"
782
msgstr ""
783
784
- #: ../includes/class-galleries.php:3404
785
msgid "Untitled"
786
msgstr ""
787
788
- #: ../includes/class-galleries.php:3479
789
msgid "Aside"
790
msgstr ""
791
792
- #: ../includes/class-galleries.php:3480
793
msgid "Audio"
794
msgstr ""
795
796
- #: ../includes/class-galleries.php:3481
797
msgid "Chat"
798
msgstr ""
799
800
- #: ../includes/class-galleries.php:3482 ../includes/class-galleries.php:3761
801
#: ../includes/class-widgets.php:57 ../includes/class-widgets.php:65
802
- #: ../responsive-lightbox.php:802 ../src/gutenberg.js:115
803
msgid "Gallery"
804
msgstr ""
805
806
- #: ../includes/class-galleries.php:3483
807
msgid "Link"
808
msgstr ""
809
810
- #: ../includes/class-galleries.php:3484
811
msgid "Photo"
812
msgstr ""
813
814
- #: ../includes/class-galleries.php:3485
815
msgid "Quote"
816
msgstr ""
817
818
- #: ../includes/class-galleries.php:3486
819
msgid "Standard"
820
msgstr ""
821
822
- #: ../includes/class-galleries.php:3488
823
msgid "Video"
824
msgstr ""
825
826
- #: ../includes/class-galleries.php:3567
827
msgid "Default Template"
828
msgstr ""
829
830
- #: ../includes/class-galleries.php:3741
831
msgid ""
832
"You can place this gallery anywhere into your posts, pages, custom post "
833
"types or widgets by using the shortcode below"
834
msgstr ""
835
836
- #: ../includes/class-galleries.php:3743
837
msgid ""
838
"You can also place this gallery into your template files by using the "
839
"template tag below"
840
msgstr ""
841
842
- #: ../includes/class-galleries.php:3770
843
msgid "Shortcode"
844
msgstr ""
845
846
- #: ../includes/class-galleries.php:3771
847
msgid "Type"
848
msgstr ""
849
850
- #: ../includes/class-galleries.php:3772
851
msgid "Source"
852
msgstr ""
853
854
- #: ../includes/class-galleries.php:3896
855
msgid "Select gallery featured image source:"
856
msgstr ""
857
858
- #: ../includes/class-galleries.php:3897
859
msgid "First gallery image"
860
msgstr ""
861
862
- #: ../includes/class-galleries.php:3899 ../includes/class-widgets.php:343
863
msgid "Custom URL"
864
msgstr ""
865
866
- #: ../includes/class-galleries.php:3905
867
msgid "Custom featured image URL"
868
msgstr ""
869
870
- #: ../includes/class-galleries.php:3907
871
msgid "Dynamically generated first gallery image"
872
msgstr ""
873
@@ -904,10 +904,14 @@ msgid "Upload and Insert"
904
msgstr ""
905
906
#: ../includes/class-remote-library.php:167
907
msgid "Filter by remote library"
908
msgstr ""
909
910
- #: ../includes/class-remote-library.php:344
911
msgid "F j Y"
912
msgstr ""
913
@@ -1162,7 +1166,6 @@ msgid "Display single post images as a gallery."
1162
msgstr ""
1163
1164
#: ../includes/class-settings.php:235 ../includes/class-settings.php:973
1165
- #: ../src/gutenberg.js:116
1166
msgid "Galleries"
1167
msgstr ""
1168
@@ -2923,8 +2926,7 @@ msgstr ""
2923
msgid "Justify"
2924
msgstr ""
2925
2926
- #: ../includes/class-widgets.php:462 ../responsive-lightbox.php:1168
2927
- #: ../src/gutenberg.js:88
2928
msgid "Select image"
2929
msgstr ""
2930
@@ -3232,110 +3234,62 @@ msgstr ""
3232
msgid "No tags found."
3233
msgstr ""
3234
3235
- #: ../responsive-lightbox.php:1006
3236
msgid "Search Folders"
3237
msgstr ""
3238
3239
- #: ../responsive-lightbox.php:1008
3240
msgid "Parent Folder"
3241
msgstr ""
3242
3243
- #: ../responsive-lightbox.php:1009
3244
msgid "Parent Folder:"
3245
msgstr ""
3246
3247
- #: ../responsive-lightbox.php:1010
3248
msgid "Edit Folder"
3249
msgstr ""
3250
3251
- #: ../responsive-lightbox.php:1011
3252
msgid "Update Folder"
3253
msgstr ""
3254
3255
- #: ../responsive-lightbox.php:1012
3256
msgid "Add New Folder"
3257
msgstr ""
3258
3259
- #: ../responsive-lightbox.php:1013
3260
msgid "New Folder Name"
3261
msgstr ""
3262
3263
- #: ../responsive-lightbox.php:1014
3264
msgid "No folders found."
3265
msgstr ""
3266
3267
- #: ../responsive-lightbox.php:1046
3268
msgid "Are you sure you want to reset these settings to defaults?"
3269
msgstr ""
3270
3271
- #: ../responsive-lightbox.php:1047
3272
msgid "Are you sure you want to reset this script settings to defaults?"
3273
msgstr ""
3274
3275
- #: ../responsive-lightbox.php:1048
3276
msgid "Are you sure you want to reset this gallery settings to defaults?"
3277
msgstr ""
3278
3279
- #: ../responsive-lightbox.php:1069 ../responsive-lightbox.php:1169
3280
msgid "Use these images"
3281
msgstr ""
3282
3283
- #: ../responsive-lightbox.php:1070
3284
msgid "Edit attachment"
3285
msgstr ""
3286
3287
- #: ../responsive-lightbox.php:1071
3288
msgid "Save attachment"
3289
msgstr ""
3290
3291
- #: ../responsive-lightbox.php:1170
3292
msgid "Use this image"
3293
msgstr ""
3294
-
3295
- #: ../src/gutenberg.js:8
3296
- msgid "Remote Library Image"
3297
- msgstr ""
3298
-
3299
- #: ../src/gutenberg.js:9
3300
- msgid "Remote Library images"
3301
- msgstr ""
3302
-
3303
- #: ../src/gutenberg.js:12
3304
- msgid "image"
3305
- msgstr ""
3306
-
3307
- #: ../src/gutenberg.js:12
3308
- msgid "photo"
3309
- msgstr ""
3310
-
3311
- #: ../src/gutenberg.js:47 ../src/gutenberg.js:71
3312
- msgid "Remote Library Images"
3313
- msgstr ""
3314
-
3315
- #: ../src/gutenberg.js:67
3316
- msgid "Responsive Lightbox | Remote Library Image"
3317
- msgstr ""
3318
-
3319
- #: ../src/gutenberg.js:68
3320
- msgid "Select a file from your remote libraries."
3321
- msgstr ""
3322
-
3323
- #: ../src/gutenberg.js:119
3324
- msgid "images"
3325
- msgstr ""
3326
-
3327
- #: ../src/gutenberg.js:119
3328
- msgid "photos"
3329
- msgstr ""
3330
-
3331
- #: ../src/gutenberg.js:119
3332
- msgid "gallery"
3333
- msgstr ""
3334
-
3335
- #: ../src/gutenberg.js:177
3336
- msgid "Responsive Lightbox | Gallery"
3337
- msgstr ""
3338
-
3339
- #: ../src/gutenberg.js:178
3340
- msgid "Select a gallery."
3341
- msgstr ""
2
msgid ""
3
msgstr ""
4
"Project-Id-Version: Responsive Lightbox\n"
5
+ "POT-Creation-Date: 2019-12-16 23:44+0100\n"
6
"PO-Revision-Date: 2015-05-12 12:06+0100\n"
7
"Last-Translator: Bartosz Arendt <info@dfactory.eu>\n"
8
"Language-Team: dFactory <info@dfactory.eu>\n"
16
"X-Poedit-SourceCharset: UTF-8\n"
17
"X-Poedit-SearchPath-0: ..\n"
18
19
+ #: ../includes/class-folders.php:176 ../includes/class-folders.php:190
20
+ #: ../includes/class-folders.php:221 ../includes/class-folders.php:235
21
+ #: ../includes/class-folders.php:413 ../includes/class-folders.php:1031
22
+ #: ../includes/class-folders.php:1056 ../includes/class-galleries.php:1163
23
msgid "Root Folder"
24
msgstr ""
25
26
+ #: ../includes/class-folders.php:240
27
msgid "Upload files to"
28
msgstr ""
29
30
+ #: ../includes/class-folders.php:280 ../includes/class-folders.php:292
31
+ #: ../includes/class-folders.php:1028 ../includes/class-folders.php:1055
32
+ #: ../includes/class-folders.php:1065 ../responsive-lightbox.php:1009
33
msgid "All Files"
34
msgstr ""
35
36
+ #: ../includes/class-folders.php:1057
37
msgid "New Folder"
38
msgstr ""
39
40
+ #: ../includes/class-folders.php:1058
41
msgid "Are you sure you want to delete this folder?"
42
msgstr ""
43
44
+ #: ../includes/class-folders.php:1059
45
msgid "Are you sure you want to delete this folder with all subfolders?"
46
msgstr ""
47
48
+ #: ../includes/class-folders.php:1081
49
#, php-format
50
msgid "Save new %s"
51
msgstr ""
52
53
+ #: ../includes/class-folders.php:1082
54
#, php-format
55
msgid "Cancel adding new %s"
56
msgstr ""
57
58
+ #: ../includes/class-folders.php:1084
59
#, php-format
60
msgid "Save %s"
61
msgstr ""
62
63
+ #: ../includes/class-folders.php:1085
64
#, php-format
65
msgid "Cancel renaming %s"
66
msgstr ""
67
68
+ #: ../includes/class-folders.php:1086
69
#, php-format
70
msgid "Delete %s"
71
msgstr ""
72
73
+ #: ../includes/class-folders.php:1087
74
#, php-format
75
msgid "Expand %s"
76
msgstr ""
77
78
+ #: ../includes/class-folders.php:1088
79
#, php-format
80
msgid "Collapse %s"
81
msgstr ""
105
msgstr ""
106
107
#: ../includes/class-frontend.php:581 ../includes/class-galleries.php:164
108
+ #: ../includes/class-settings.php:150 ../includes/class-settings.php:626
109
+ #: ../includes/class-settings.php:685 ../includes/class-widgets.php:93
110
+ #: ../includes/class-widgets.php:340 ../includes/class-widgets.php:347
111
msgid "None"
112
msgstr ""
113
169
msgid "Specify the number of columns."
170
msgstr ""
171
172
+ #: ../includes/class-galleries.php:85 ../includes/class-galleries.php:3579
173
msgid "Status"
174
msgstr ""
175
176
+ #: ../includes/class-galleries.php:86
177
msgid "Edit image"
178
msgstr ""
179
180
+ #: ../includes/class-galleries.php:87 ../responsive-lightbox.php:1168
181
msgid "Remove image"
182
msgstr ""
183
194
msgid "The settings below adjust the contents of the gallery."
195
msgstr ""
196
197
+ #: ../includes/class-galleries.php:117 ../includes/class-galleries.php:3991
198
msgid "Media Library"
199
msgstr ""
200
699
"button below."
700
msgstr ""
701
702
+ #: ../includes/class-galleries.php:1050
703
msgid "Edit gallery"
704
msgstr ""
705
707
msgid "Insert gallery into post"
708
msgstr ""
709
710
+ #: ../includes/class-galleries.php:1061
711
msgid "Select gallery"
712
msgstr ""
713
716
msgstr ""
717
718
#: ../includes/class-galleries.php:1277 ../includes/class-widgets.php:140
719
+ #: ../responsive-lightbox.php:1070 ../responsive-lightbox.php:1169
720
msgid "Select images"
721
msgstr ""
722
765
msgid "No data"
766
msgstr ""
767
768
+ #: ../includes/class-galleries.php:2466
769
msgid "&laquo; Previous"
770
msgstr ""
771
772
+ #: ../includes/class-galleries.php:2467
773
msgid "Next &raquo;"
774
msgstr ""
775
776
+ #: ../includes/class-galleries.php:2597
777
msgid "(no title)"
778
msgstr ""
779
780
+ #: ../includes/class-galleries.php:2611
781
msgid "Deselect"
782
msgstr ""
783
784
+ #: ../includes/class-galleries.php:3496
785
msgid "Untitled"
786
msgstr ""
787
788
+ #: ../includes/class-galleries.php:3571
789
msgid "Aside"
790
msgstr ""
791
792
+ #: ../includes/class-galleries.php:3572
793
msgid "Audio"
794
msgstr ""
795
796
+ #: ../includes/class-galleries.php:3573
797
msgid "Chat"
798
msgstr ""
799
800
+ #: ../includes/class-galleries.php:3574 ../includes/class-galleries.php:3854
801
#: ../includes/class-widgets.php:57 ../includes/class-widgets.php:65
802
+ #: ../responsive-lightbox.php:802
803
msgid "Gallery"
804
msgstr ""
805
806
+ #: ../includes/class-galleries.php:3575
807
msgid "Link"
808
msgstr ""
809
810
+ #: ../includes/class-galleries.php:3576
811
msgid "Photo"
812
msgstr ""
813
814
+ #: ../includes/class-galleries.php:3577
815
msgid "Quote"
816
msgstr ""
817
818
+ #: ../includes/class-galleries.php:3578
819
msgid "Standard"
820
msgstr ""
821
822
+ #: ../includes/class-galleries.php:3580
823
msgid "Video"
824
msgstr ""
825
826
+ #: ../includes/class-galleries.php:3659
827
msgid "Default Template"
828
msgstr ""
829
830
+ #: ../includes/class-galleries.php:3834
831
msgid ""
832
"You can place this gallery anywhere into your posts, pages, custom post "
833
"types or widgets by using the shortcode below"
834
msgstr ""
835
836
+ #: ../includes/class-galleries.php:3836
837
msgid ""
838
"You can also place this gallery into your template files by using the "
839
"template tag below"
840
msgstr ""
841
842
+ #: ../includes/class-galleries.php:3863
843
msgid "Shortcode"
844
msgstr ""
845
846
+ #: ../includes/class-galleries.php:3864
847
msgid "Type"
848
msgstr ""
849
850
+ #: ../includes/class-galleries.php:3865
851
msgid "Source"
852
msgstr ""
853
854
+ #: ../includes/class-galleries.php:3989
855
msgid "Select gallery featured image source:"
856
msgstr ""
857
858
+ #: ../includes/class-galleries.php:3990
859
msgid "First gallery image"
860
msgstr ""
861
862
+ #: ../includes/class-galleries.php:3992 ../includes/class-widgets.php:343
863
msgid "Custom URL"
864
msgstr ""
865
866
+ #: ../includes/class-galleries.php:3998
867
msgid "Custom featured image URL"
868
msgstr ""
869
870
+ #: ../includes/class-galleries.php:4000
871
msgid "Dynamically generated first gallery image"
872
msgstr ""
873
904
msgstr ""
905
906
#: ../includes/class-remote-library.php:167
907
+ msgid "Upload and Select"
908
+ msgstr ""
909
+
910
+ #: ../includes/class-remote-library.php:168
911
msgid "Filter by remote library"
912
msgstr ""
913
914
+ #: ../includes/class-remote-library.php:345
915
msgid "F j Y"
916
msgstr ""
917
1166
msgstr ""
1167
1168
#: ../includes/class-settings.php:235 ../includes/class-settings.php:973
1169
msgid "Galleries"
1170
msgstr ""
1171
2926
msgid "Justify"
2927
msgstr ""
2928
2929
+ #: ../includes/class-widgets.php:462 ../responsive-lightbox.php:1170
2930
msgid "Select image"
2931
msgstr ""
2932
3234
msgid "No tags found."
3235
msgstr ""
3236
3237
+ #: ../responsive-lightbox.php:1008
3238
msgid "Search Folders"
3239
msgstr ""
3240
3241
+ #: ../responsive-lightbox.php:1010
3242
msgid "Parent Folder"
3243
msgstr ""
3244
3245
+ #: ../responsive-lightbox.php:1011
3246
msgid "Parent Folder:"
3247
msgstr ""
3248
3249
+ #: ../responsive-lightbox.php:1012
3250
msgid "Edit Folder"
3251
msgstr ""
3252
3253
+ #: ../responsive-lightbox.php:1013
3254
msgid "Update Folder"
3255
msgstr ""
3256
3257
+ #: ../responsive-lightbox.php:1014
3258
msgid "Add New Folder"
3259
msgstr ""
3260
3261
+ #: ../responsive-lightbox.php:1015
3262
msgid "New Folder Name"
3263
msgstr ""
3264
3265
+ #: ../responsive-lightbox.php:1016
3266
msgid "No folders found."
3267
msgstr ""
3268
3269
+ #: ../responsive-lightbox.php:1048
3270
msgid "Are you sure you want to reset these settings to defaults?"
3271
msgstr ""
3272
3273
+ #: ../responsive-lightbox.php:1049
3274
msgid "Are you sure you want to reset this script settings to defaults?"
3275
msgstr ""
3276
3277
+ #: ../responsive-lightbox.php:1050
3278
msgid "Are you sure you want to reset this gallery settings to defaults?"
3279
msgstr ""
3280
3281
+ #: ../responsive-lightbox.php:1071 ../responsive-lightbox.php:1171
3282
msgid "Use these images"
3283
msgstr ""
3284
3285
+ #: ../responsive-lightbox.php:1072
3286
msgid "Edit attachment"
3287
msgstr ""
3288
3289
+ #: ../responsive-lightbox.php:1073
3290
msgid "Save attachment"
3291
msgstr ""
3292
3293
+ #: ../responsive-lightbox.php:1172
3294
msgid "Use this image"
3295
msgstr ""
library/simplehtmldom/simplehtmldom.php ADDED
@@ -0,0 +1,1742 @@
1
+ <?php
2
+ /**
3
+ * Website: http://sourceforge.net/projects/simplehtmldom/
4
+ * Additional projects that may be used: http://sourceforge.net/projects/debugobject/
5
+ * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
6
+ * Contributions by:
7
+ * Yousuke Kumakura (Attribute filters)
8
+ * Vadim Voituk (Negative indexes supports of "find" method)
9
+ * Antcs (Constructor with automatically load contents either text or file/url)
10
+ *
11
+ * all affected sections have comments starting with "PaperG"
12
+ *
13
+ * Paperg - Added case insensitive testing of the value of the selector.
14
+ * Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
15
+ * This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
16
+ * it will almost always be smaller by some amount.
17
+ * We use this to determine how far into the file the tag in question is. This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
18
+ * but for most purposes, it's a really good estimation.
19
+ * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
20
+ * Allow the user to tell us how much they trust the html.
21
+ * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
22
+ * This allows for us to find tags based on the text they contain.
23
+ * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
24
+ * Paperg: added parse_charset so that we know about the character set of the source document.
25
+ * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
26
+ * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
27
+ *
28
+ * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
29
+ * PaperG (John Schlick) Added get_display_size for "IMG" tags.
30
+ *
31
+ * Licensed under The MIT License
32
+ * Redistributions of files must retain the above copyright notice.
33
+ *
34
+ * @author S.C. Chen <me578022@gmail.com>
35
+ * @author John Schlick
36
+ * @author Rus Carroll
37
+ * @version 1.5 ($Rev: 210 $)
38
+ * @package PlaceLocalInclude
39
+ * @subpackage simple_html_dom
40
+ */
41
+
42
+ /**
43
+ * All of the Defines for the classes below.
44
+ * @author S.C. Chen <me578022@gmail.com>
45
+ */
46
+ define('HDOM_TYPE_ELEMENT', 1);
47
+ define('HDOM_TYPE_COMMENT', 2);
48
+ define('HDOM_TYPE_TEXT', 3);
49
+ define('HDOM_TYPE_ENDTAG', 4);
50
+ define('HDOM_TYPE_ROOT', 5);
51
+ define('HDOM_TYPE_UNKNOWN', 6);
52
+ define('HDOM_QUOTE_DOUBLE', 0);
53
+ define('HDOM_QUOTE_SINGLE', 1);
54
+ define('HDOM_QUOTE_NO', 3);
55
+ define('HDOM_INFO_BEGIN', 0);
56
+ define('HDOM_INFO_END', 1);
57
+ define('HDOM_INFO_QUOTE', 2);
58
+ define('HDOM_INFO_SPACE', 3);
59
+ define('HDOM_INFO_TEXT', 4);
60
+ define('HDOM_INFO_INNER', 5);
61
+ define('HDOM_INFO_OUTER', 6);
62
+ define('HDOM_INFO_ENDSPACE',7);
63
+ define('DEFAULT_TARGET_CHARSET', 'UTF-8');
64
+ define('DEFAULT_BR_TEXT', "\r\n");
65
+ define('DEFAULT_SPAN_TEXT', " ");
66
+ define('MAX_FILE_SIZE', 600000);
67
+ // helper functions
68
+ // -----------------------------------------------------------------------------
69
+ // get html dom from file
70
+ // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
71
+ function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
72
+ {
73
+ // We DO force the tags to be terminated.
74
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
75
+ // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
76
+ $contents = file_get_contents($url, $use_include_path, $context, $offset);
77
+ // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
78
+ //$contents = retrieve_url_contents($url);
79
+ if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
80
+ {
81
+ return false;
82
+ }
83
+ // The second parameter can force the selectors to all be lowercase.
84
+ $dom->load($contents, $lowercase, $stripRN);
85
+ return $dom;
86
+ }
87
+
88
+ // get html dom from string
89
+ function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
90
+ {
91
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
92
+ if (empty($str) || strlen($str) > MAX_FILE_SIZE)
93
+ {
94
+ $dom->clear();
95
+ return false;
96
+ }
97
+ $dom->load($str, $lowercase, $stripRN);
98
+ return $dom;
99
+ }
100
+
101
+ // dump html dom tree
102
+ function dump_html_tree($node, $show_attr=true, $deep=0)
103
+ {
104
+ $node->dump($node);
105
+ }
106
+
107
+
108
+ /**
109
+ * simple html dom node
110
+ * PaperG - added ability for "find" routine to lowercase the value of the selector.
111
+ * PaperG - added $tag_start to track the start position of the tag in the total byte index
112
+ *
113
+ * @package PlaceLocalInclude
114
+ */
115
+ class simple_html_dom_node
116
+ {
117
+ public $nodetype = HDOM_TYPE_TEXT;
118
+ public $tag = 'text';
119
+ public $attr = array();
120
+ public $children = array();
121
+ public $nodes = array();
122
+ public $parent = null;
123
+ // The "info" array - see HDOM_INFO_... for what each element contains.
124
+ public $_ = array();
125
+ public $tag_start = 0;
126
+ private $dom = null;
127
+
128
+ function __construct($dom)
129
+ {
130
+ $this->dom = $dom;
131
+ $dom->nodes[] = $this;
132
+ }
133
+
134
+ function __destruct()
135
+ {
136
+ $this->clear();
137
+ }
138
+
139
+ function __toString()
140
+ {
141
+ return $this->outertext();
142
+ }
143
+
144
+ // clean up memory due to php5 circular references memory leak...
145
+ function clear()
146
+ {
147
+ $this->dom = null;
148
+ $this->nodes = null;
149
+ $this->parent = null;
150
+ $this->children = null;
151
+ }
152
+
153
+ // dump node's tree
154
+ function dump($show_attr=true, $deep=0)
155
+ {
156
+ $lead = str_repeat(' ', $deep);
157
+
158
+ echo $lead.$this->tag;
159
+ if ($show_attr && count($this->attr)>0)
160
+ {
161
+ echo '(';
162
+ foreach ($this->attr as $k=>$v)
163
+ echo "[$k]=>\"".$this->$k.'", ';
164
+ echo ')';
165
+ }
166
+ echo "\n";
167
+
168
+ if ($this->nodes)
169
+ {
170
+ foreach ($this->nodes as $c)
171
+ {
172
+ $c->dump($show_attr, $deep+1);
173
+ }
174
+ }
175
+ }
176
+
177
+
178
+ // Debugging function to dump a single dom node with a bunch of information about it.
179
+ function dump_node($echo=true)
180
+ {
181
+
182
+ $string = $this->tag;
183
+ if (count($this->attr)>0)
184
+ {
185
+ $string .= '(';
186
+ foreach ($this->attr as $k=>$v)
187
+ {
188
+ $string .= "[$k]=>\"".$this->$k.'", ';
189
+ }
190
+ $string .= ')';
191
+ }
192
+ if (count($this->_)>0)
193
+ {
194
+ $string .= ' $_ (';
195
+ foreach ($this->_ as $k=>$v)
196
+ {
197
+ if (is_array($v))
198
+ {
199
+ $string .= "[$k]=>(";
200
+ foreach ($v as $k2=>$v2)
201
+ {
202
+ $string .= "[$k2]=>\"".$v2.'", ';
203
+ }
204
+ $string .= ")";
205
+ } else {
206
+ $string .= "[$k]=>\"".$v.'", ';
207
+ }
208
+ }
209
+ $string .= ")";
210
+ }
211
+
212
+ if (isset($this->text))
213
+ {
214
+ $string .= " text: (" . $this->text . ")";
215
+ }
216
+
217
+ $string .= " HDOM_INNER_INFO: '";
218
+ if (isset($node->_[HDOM_INFO_INNER]))
219
+ {
220
+ $string .= $node->_[HDOM_INFO_INNER] . "'";
221
+ }
222
+ else
223
+ {
224
+ $string .= ' NULL ';
225
+ }
226
+
227
+ $string .= " children: " . count($this->children);
228
+ $string .= " nodes: " . count($this->nodes);
229
+ $string .= " tag_start: " . $this->tag_start;
230
+ $string .= "\n";
231
+
232
+ if ($echo)
233
+ {
234
+ echo $string;
235
+ return;
236
+ }
237
+ else
238
+ {
239
+ return $string;
240
+ }
241
+ }
242
+
243
+ // returns the parent of node
244
+ // If a node is passed in, it will reset the parent of the current node to that one.
245
+ function parent($parent=null)
246
+ {
247
+ // I am SURE that this doesn't work properly.
248
+ // It fails to unset the current node from it's current parents nodes or children list first.
249
+ if ($parent !== null)
250
+ {
251
+ $this->parent = $parent;
252
+ $this->parent->nodes[] = $this;
253
+ $this->parent->children[] = $this;
254
+ }
255
+
256
+ return $this->parent;
257
+ }
258
+
259
+ // verify that node has children
260
+ function has_child()
261
+ {
262
+ return !empty($this->children);
263
+ }
264
+
265
+ // returns children of node
266
+ function children($idx=-1)
267
+ {
268
+ if ($idx===-1)
269
+ {
270
+ return $this->children;
271
+ }
272
+ if (isset($this->children[$idx]))
273
+ {
274
+ return $this->children[$idx];
275
+ }
276
+ return null;
277
+ }
278
+
279
+ // returns the first child of node
280
+ function first_child()
281
+ {
282
+ if (count($this->children)>0)
283
+ {
284
+ return $this->children[0];
285
+ }
286
+ return null;
287
+ }
288
+
289
+ // returns the last child of node
290
+ function last_child()
291
+ {
292
+ if (($count=count($this->children))>0)
293
+ {
294
+ return $this->children[$count-1];
295
+ }
296
+ return null;
297
+ }
298
+
299
+ // returns the next sibling of node
300
+ function next_sibling()
301
+ {
302
+ if ($this->parent===null)
303
+ {
304
+ return null;
305
+ }
306
+
307
+ $idx = 0;
308
+ $count = count($this->parent->children);
309
+ while ($idx<$count && $this!==$this->parent->children[$idx])
310
+ {
311
+ ++$idx;
312
+ }
313
+ if (++$idx>=$count)
314
+ {
315
+ return null;
316
+ }
317
+ return $this->parent->children[$idx];
318
+ }
319
+
320
+ // returns the previous sibling of node
321
+ function prev_sibling()
322
+ {
323
+ if ($this->parent===null) return null;
324
+ $idx = 0;
325
+ $count = count($this->parent->children);
326
+ while ($idx<$count && $this!==$this->parent->children[$idx])
327
+ ++$idx;
328
+ if (--$idx<0) return null;
329
+ return $this->parent->children[$idx];
330
+ }
331
+
332
+ // function to locate a specific ancestor tag in the path to the root.
333
+ function find_ancestor_tag($tag)
334
+ {
335
+ global $debug_object;
336
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
337
+
338
+ // Start by including ourselves in the comparison.
339
+ $returnDom = $this;
340
+
341
+ while (!is_null($returnDom))
342
+ {
343
+ if (is_object($debug_object)) { $debug_object->debug_log(2, "Current tag is: " . $returnDom->tag); }
344
+
345
+ if ($returnDom->tag == $tag)
346
+ {
347
+ break;
348
+ }
349
+ $returnDom = $returnDom->parent;
350
+ }
351
+ return $returnDom;
352
+ }
353
+
354
+ // get dom node's inner html
355
+ function innertext()
356
+ {
357
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
358
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
359
+
360
+ $ret = '';
361
+ foreach ($this->nodes as $n)
362
+ $ret .= $n->outertext();
363
+ return $ret;
364
+ }
365
+
366
+ // get dom node's outer text (with tag)
367
+ function outertext()
368
+ {
369
+ global $debug_object;
370
+ if (is_object($debug_object))
371
+ {
372
+ $text = '';
373
+ if ($this->tag == 'text')
374
+ {
375
+ if (!empty($this->text))
376
+ {
377
+ $text = " with text: " . $this->text;
378
+ }
379
+ }
380
+ $debug_object->debug_log(1, 'Innertext of tag: ' . $this->tag . $text);
381
+ }
382
+
383
+ if ($this->tag==='root') return $this->innertext();
384
+
385
+ // trigger callback
386
+ if ($this->dom && $this->dom->callback!==null)
387
+ {
388
+ call_user_func_array($this->dom->callback, array($this));
389
+ }
390
+
391
+ if (isset($this->_[HDOM_INFO_OUTER])) return $this->_[HDOM_INFO_OUTER];
392
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
393
+
394
+ // render begin tag
395
+ if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]])
396
+ {
397
+ $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
398
+ } else {
399
+ $ret = "";
400
+ }
401
+
402
+ // render inner text
403
+ if (isset($this->_[HDOM_INFO_INNER]))
404
+ {
405
+ // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
406
+ if ($this->tag != "br")
407
+ {
408
+ $ret .= $this->_[HDOM_INFO_INNER];
409
+ }
410
+ } else {
411
+ if ($this->nodes)
412
+ {
413
+ foreach ($this->nodes as $n)
414
+ {
415
+ $ret .= $this->convert_text($n->outertext());
416
+ }
417
+ }
418
+ }
419
+
420
+ // render end tag
421
+ if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0)
422
+ $ret .= '</'.$this->tag.'>';
423
+ return $ret;
424
+ }
425
+
426
+ // get dom node's plain text
427
+ function text()
428
+ {
429
+ if (isset($this->_[HDOM_INFO_INNER])) return $this->_[HDOM_INFO_INNER];
430
+ switch ($this->nodetype)
431
+ {
432
+ case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
433
+ case HDOM_TYPE_COMMENT: return '';
434
+ case HDOM_TYPE_UNKNOWN: return '';
435
+ }
436
+ if (strcasecmp($this->tag, 'script')===0) return '';
437
+ if (strcasecmp($this->tag, 'style')===0) return '';
438
+
439
+ $ret = '';
440
+ // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
441
+ // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
442
+ // WHY is this happening?
443
+ if (!is_null($this->nodes))
444
+ {
445
+ foreach ($this->nodes as $n)
446
+ {
447
+ $ret .= $this->convert_text($n->text());
448
+ }
449
+
450
+ // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
451
+ if ($this->tag == "span")
452
+ {
453
+ $ret .= $this->dom->default_span_text;
454
+ }
455
+
456
+
457
+ }
458
+ return $ret;
459
+ }
460
+
461
+ function xmltext()
462
+ {
463
+ $ret = $this->innertext();
464
+ $ret = str_ireplace('<![CDATA[', '', $ret);
465
+ $ret = str_replace(']]>', '', $ret);
466
+ return $ret;
467
+ }
468
+
469
+ // build node's text with tag
470
+ function makeup()
471
+ {
472
+ // text, comment, unknown
473
+ if (isset($this->_[HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
474
+
475
+ $ret = '<'.$this->tag;
476
+ $i = -1;
477
+
478
+ foreach ($this->attr as $key=>$val)
479
+ {
480
+ ++$i;
481
+
482
+ // skip removed attribute
483
+ if ($val===null || $val===false)
484
+ continue;
485
+
486
+ $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
487
+ //no value attr: nowrap, checked selected...
488
+ if ($val===true)
489
+ $ret .= $key;
490
+ else {
491
+ switch ($this->_[HDOM_INFO_QUOTE][$i])
492
+ {
493
+ case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
494
+ case HDOM_QUOTE_SINGLE: $quote = '\''; break;
495
+ default: $quote = '';
496
+ }
497
+ $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
498
+ }
499
+ }
500
+ $ret = $this->dom->restore_noise($ret);
501
+ return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
502
+ }
503
+
504
+ // find elements by css selector
505
+ //PaperG - added ability for find to lowercase the value of the selector.
506
+ function find($selector, $idx=null, $lowercase=false)
507
+ {
508
+ $selectors = $this->parse_selector($selector);
509
+ if (($count=count($selectors))===0) return array();
510
+ $found_keys = array();
511
+
512
+ // find each selector
513
+ for ($c=0; $c<$count; ++$c)
514
+ {
515
+ // The change on the below line was documented on the sourceforge code tracker id 2788009
516
+ // used to be: if (($levle=count($selectors[0]))===0) return array();
517
+ if (($levle=count($selectors[$c]))===0) return array();
518
+ if (!isset($this->_[HDOM_INFO_BEGIN])) return array();
519
+
520
+ $head = array($this->_[HDOM_INFO_BEGIN]=>1);
521
+
522
+ // handle descendant selectors, no recursive!
523
+ for ($l=0; $l<$levle; ++$l)
524
+ {
525
+ $ret = array();
526
+ foreach ($head as $k=>$v)
527
+ {
528
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
529
+ //PaperG - Pass this optional parameter on to the seek function.
530
+ $n->seek($selectors[$c][$l], $ret, $lowercase);
531
+ }
532
+ $head = $ret;
533
+ }
534
+
535
+ foreach ($head as $k=>$v)
536
+ {
537
+ if (!isset($found_keys[$k]))
538
+ {
539
+ $found_keys[$k] = 1;
540
+ }
541
+ }
542
+ }
543
+
544
+ // sort keys
545
+ ksort($found_keys);
546
+
547
+ $found = array();
548
+ foreach ($found_keys as $k=>$v)
549
+ $found[] = $this->dom->nodes[$k];
550
+
551
+ // return nth-element or array
552
+ if (is_null($idx)) return $found;
553
+ else if ($idx<0) $idx = count($found) + $idx;
554
+ return (isset($found[$idx])) ? $found[$idx] : null;
555
+ }
556
+
557
+ // seek for given conditions
558
+ // PaperG - added parameter to allow for case insensitive testing of the value of a selector.
559
+ protected function seek($selector, &$ret, $lowercase=false)
560
+ {
561
+ global $debug_object;
562
+ if (is_object($debug_object)) { $debug_object->debug_log_entry(1); }
563
+
564
+ list($tag, $key, $val, $exp, $no_key) = $selector;
565
+
566
+ // xpath index
567
+ if ($tag && $key && is_numeric($key))
568
+ {
569
+ $count = 0;
570
+ foreach ($this->children as $c)
571
+ {
572
+ if ($tag==='*' || $tag===$c->tag) {
573
+ if (++$count==$key) {
574
+ $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
575
+ return;
576
+ }
577
+ }
578
+ }
579
+ return;
580
+ }
581
+
582
+ $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
583
+ if ($end==0) {
584
+ $parent = $this->parent;
585
+ while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
586
+ $end -= 1;
587
+ $parent = $parent->parent;
588
+ }
589
+ $end += $parent->_[HDOM_INFO_END];
590
+ }
591
+
592
+ for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
593
+ $node = $this->dom->nodes[$i];
594
+
595
+ $pass = true;
596
+
597
+ if ($tag==='*' && !$key) {
598
+ if (in_array($node, $this->children, true))
599
+ $ret[$i] = 1;
600
+ continue;
601
+ }
602
+
603
+ // compare tag
604
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
605
+ // compare key
606
+ if ($pass && $key) {
607
+ if ($no_key) {
608
+ if (isset($node->attr[$key])) $pass=false;
609
+ } else {
610
+ if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
611
+ }
612
+ }
613
+ // compare value
614
+ if ($pass && $key && $val && $val!=='*') {
615
+ // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
616
+ if ($key == "plaintext") {
617
+ // $node->plaintext actually returns $node->text();
618
+ $nodeKeyValue = $node->text();
619
+ } else {
620
+ // this is a normal search, we want the value of that attribute of the tag.
621
+ $nodeKeyValue = $node->attr[$key];
622
+ }
623
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
624
+
625
+ //PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
626
+ if ($lowercase) {
627
+ $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
628
+ } else {
629
+ $check = $this->match($exp, $val, $nodeKeyValue);
630
+ }
631
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "after match: " . ($check ? "true" : "false"));}
632
+
633
+ // handle multiple class
634
+ if (!$check && strcasecmp($key, 'class')===0) {
635
+ foreach (explode(' ',$node->attr[$key]) as $k) {
636
+ // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
637
+ if (!empty($k)) {
638
+ if ($lowercase) {
639
+ $check = $this->match($exp, strtolower($val), strtolower($k));
640
+ } else {
641
+ $check = $this->match($exp, $val, $k);
642
+ }
643
+ if ($check) break;
644
+ }
645
+ }
646
+ }
647
+ if (!$check) $pass = false;
648
+ }
649
+ if ($pass) $ret[$i] = 1;
650
+ unset($node);
651
+ }
652
+ // It's passed by reference so this is actually what this function returns.
653
+ if (is_object($debug_object)) {$debug_object->debug_log(1, "EXIT - ret: ", $ret);}
654
+ }
655
+
656
+ protected function match($exp, $pattern, $value) {
657
+ global $debug_object;
658
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
659
+
660
+ switch ($exp) {
661
+ case '=':
662
+ return ($value===$pattern);
663
+ case '!=':
664
+ return ($value!==$pattern);
665
+ case '^=':
666
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
667
+ case '$=':
668
+ return preg_match("/".preg_quote($pattern,'/')."#x2F;", $value);
669
+ case '*=':
670
+ if ($pattern[0]=='/') {
671
+ return preg_match($pattern, $value);
672
+ }
673
+ return preg_match("/".$pattern."/i", $value);
674
+ }
675
+ return false;
676
+ }
677
+
678
+ protected function parse_selector($selector_string) {
679
+ global $debug_object;
680
+ if (is_object($debug_object)) {$debug_object->debug_log_entry(1);}
681
+
682
+ // pattern of CSS selectors, modified from mootools
683
+ // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
684
+ // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
685
+ // Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
686
+ // This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
687
+ // farther study is required to determine of this should be documented or removed.
688
+ // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
689
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
690
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
691
+ if (is_object($debug_object)) {$debug_object->debug_log(2, "Matches Array: ", $matches);}
692
+
693
+ $selectors = array();
694
+ $result = array();
695
+ //print_r($matches);
696
+
697
+ foreach ($matches as $m) {
698
+ $m[0] = trim($m[0]);
699
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
700
+ // for browser generated xpath
701
+ if ($m[1]==='tbody') continue;
702
+
703
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
704
+ if (!empty($m[2])) {$key='id'; $val=$m[2];}
705
+ if (!empty($m[3])) {$key='class'; $val=$m[3];}
706
+ if (!empty($m[4])) {$key=$m[4];}
707
+ if (!empty($m[5])) {$exp=$m[5];}
708
+ if (!empty($m[6])) {$val=$m[6];}
709
+
710
+ // convert to lowercase
711
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
712
+ //elements that do NOT have the specified attribute
713
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
714
+