|
@@ -134,7 +134,7 @@ discard block |
|
|
block discarded – undo |
|
134
|
134
|
$supports = array( 'title', 'revisions' ); |
|
135
|
135
|
|
|
136
|
136
|
if ( $is_hierarchical ) { |
|
137
|
|
- $supports[] = 'page-attributes'; |
|
|
137
|
+ $supports[ ] = 'page-attributes'; |
|
138
|
138
|
} |
|
139
|
139
|
|
|
140
|
140
|
/** |
|
@@ -243,12 +243,12 @@ discard block |
|
|
block discarded – undo |
|
243
|
243
|
$tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' ); |
|
244
|
244
|
|
|
245
|
245
|
add_filter( 'query_vars', function( $query_vars ) { |
|
246
|
|
- $query_vars[] = 'csv'; |
|
247
|
|
- $query_vars[] = 'tsv'; |
|
|
246
|
+ $query_vars[ ] = 'csv'; |
|
|
247
|
+ $query_vars[ ] = 'tsv'; |
|
248
|
248
|
return $query_vars; |
|
249
|
249
|
} ); |
|
250
|
250
|
|
|
251
|
|
- if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) { |
|
|
251
|
+ if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) { |
|
252
|
252
|
call_user_func_array( 'add_rewrite_rule', $csv_rule ); |
|
253
|
253
|
call_user_func_array( 'add_rewrite_rule', $tsv_rule ); |
|
254
|
254
|
} |
|
@@ -309,7 +309,7 @@ discard block |
|
|
block discarded – undo |
|
309
|
309
|
|
|
310
|
310
|
$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gk-gravityview' ); |
|
311
|
311
|
|
|
312
|
|
- $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gk-gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
|
312
|
+ $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gk-gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
313
|
313
|
|
|
314
|
314
|
return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' ); |
|
315
|
315
|
} |
|
@@ -335,13 +335,13 @@ discard block |
|
|
block discarded – undo |
|
335
|
335
|
return $content; |
|
336
|
336
|
} |
|
337
|
337
|
|
|
338
|
|
- $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
|
338
|
+ $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
339
|
339
|
|
|
340
|
340
|
/** |
|
341
|
341
|
* Editing a single entry. |
|
342
|
342
|
*/ |
|
343
|
343
|
if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
|
344
|
|
- if ( $entry['status'] != 'active' ) { |
|
|
344
|
+ if ( $entry[ 'status' ] != 'active' ) { |
|
345
|
345
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
|
346
|
346
|
return __( 'You are not allowed to view this content.', 'gk-gravityview' ); |
|
347
|
347
|
} |
|
@@ -352,7 +352,7 @@ discard block |
|
|
block discarded – undo |
|
352
|
352
|
} |
|
353
|
353
|
|
|
354
|
354
|
if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
|
355
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
355
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
356
|
356
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
|
357
|
357
|
return __( 'You are not allowed to view this content.', 'gk-gravityview' ); |
|
358
|
358
|
} |
|
@@ -375,7 +375,7 @@ discard block |
|
|
block discarded – undo |
|
375
|
375
|
|
|
376
|
376
|
foreach ( $entryset as $e ) { |
|
377
|
377
|
|
|
378
|
|
- if ( 'active' !== $e['status'] ) { |
|
|
378
|
+ if ( 'active' !== $e[ 'status' ] ) { |
|
379
|
379
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
|
380
|
380
|
return __( 'You are not allowed to view this content.', 'gk-gravityview' ); |
|
381
|
381
|
} |
|
@@ -386,7 +386,7 @@ discard block |
|
|
block discarded – undo |
|
386
|
386
|
} |
|
387
|
387
|
|
|
388
|
388
|
if ( $show_only_approved && ! $is_admin_and_can_view ) { |
|
389
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
389
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
390
|
390
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
|
391
|
391
|
return __( 'You are not allowed to view this content.', 'gk-gravityview' ); |
|
392
|
392
|
} |
|
@@ -561,7 +561,7 @@ discard block |
|
|
block discarded – undo |
|
561
|
561
|
$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
|
562
|
562
|
$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
|
563
|
563
|
|
|
564
|
|
- $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
|
564
|
+ $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
565
|
565
|
} |
|
566
|
566
|
|
|
567
|
567
|
return $joins; |
|
@@ -651,13 +651,13 @@ discard block |
|
|
block discarded – undo |
|
651
|
651
|
} |
|
652
|
652
|
|
|
653
|
653
|
foreach ( $_fields as $field ) { |
|
654
|
|
- if ( ! empty( $field['unions'] ) ) { |
|
655
|
|
- foreach ( $field['unions'] as $form_id => $field_id ) { |
|
|
654
|
+ if ( ! empty( $field[ 'unions' ] ) ) { |
|
|
655
|
+ foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
656
|
656
|
if ( ! isset( $unions[ $form_id ] ) ) { |
|
657
|
657
|
$unions[ $form_id ] = array(); |
|
658
|
658
|
} |
|
659
|
659
|
|
|
660
|
|
- $unions[ $form_id ][ $field['id'] ] = |
|
|
660
|
+ $unions[ $form_id ][ $field[ 'id' ] ] = |
|
661
|
661
|
is_numeric( $field_id ) ? \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
662
|
662
|
} |
|
663
|
663
|
} |
|
@@ -710,10 +710,10 @@ discard block |
|
|
block discarded – undo |
|
710
|
710
|
/** Get connected form. */ |
|
711
|
711
|
$view->form = GF_Form::by_id( $view->_gravityview_form_id ); |
|
712
|
712
|
global $pagenow; |
|
713
|
|
- if ( ! $view->form && 'post-new.php' !== $pagenow ) { |
|
|
713
|
+ if ( ! $view->form && 'post-new.php' !== $pagenow ) { |
|
714
|
714
|
gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
|
715
|
715
|
'view_id' => $view->ID, |
|
716
|
|
- 'form_id' => $view->_gravityview_form_id ? : 0, |
|
|
716
|
+ 'form_id' => $view->_gravityview_form_id ?: 0, |
|
717
|
717
|
) ); |
|
718
|
718
|
} |
|
719
|
719
|
|
|
@@ -843,7 +843,7 @@ discard block |
|
|
block discarded – undo |
|
843
|
843
|
* @since 2.0 |
|
844
|
844
|
* @return bool Whether the offset exists or not, limited to GravityView_View_Data::$views element keys. |
|
845
|
845
|
*/ |
|
846
|
|
- #[\ReturnTypeWillChange] |
|
|
846
|
+ #[\ReturnTypeWillChange ] |
|
847
|
847
|
public function offsetExists( $offset ) { |
|
848
|
848
|
$data_keys = array( 'id', 'view_id', 'form_id', 'template_id', 'atts', 'fields', 'widgets', 'form' ); |
|
849
|
849
|
return in_array( $offset, $data_keys ); |
|
@@ -860,7 +860,7 @@ discard block |
|
|
block discarded – undo |
|
860
|
860
|
* |
|
861
|
861
|
* @return mixed The value of the requested view data key limited to GravityView_View_Data::$views element keys. If offset not found, return null. |
|
862
|
862
|
*/ |
|
863
|
|
- #[\ReturnTypeWillChange] |
|
|
863
|
+ #[\ReturnTypeWillChange ] |
|
864
|
864
|
public function offsetGet( $offset ) { |
|
865
|
865
|
|
|
866
|
866
|
gravityview()->log->notice( 'This is a \GV\View object should not be accessed as an array.' ); |
|
@@ -897,7 +897,7 @@ discard block |
|
|
block discarded – undo |
|
897
|
897
|
* |
|
898
|
898
|
* @return void |
|
899
|
899
|
*/ |
|
900
|
|
- #[\ReturnTypeWillChange] |
|
|
900
|
+ #[\ReturnTypeWillChange ] |
|
901
|
901
|
public function offsetSet( $offset, $value ) { |
|
902
|
902
|
gravityview()->log->error( 'The old view data is no longer mutable. This is a \GV\View object should not be accessed as an array.' ); |
|
903
|
903
|
} |
|
@@ -910,7 +910,7 @@ discard block |
|
|
block discarded – undo |
|
910
|
910
|
* @since 2.0 |
|
911
|
911
|
* @return void |
|
912
|
912
|
*/ |
|
913
|
|
- #[\ReturnTypeWillChange] |
|
|
913
|
+ #[\ReturnTypeWillChange ] |
|
914
|
914
|
public function offsetUnset( $offset ) { |
|
915
|
915
|
gravityview()->log->error( 'The old view data is no longer mutable. This is a \GV\View object should not be accessed as an array.' ); |
|
916
|
916
|
} |
|
@@ -961,11 +961,11 @@ discard block |
|
|
block discarded – undo |
|
961
|
961
|
* Remove multiple sorting before calling legacy filters. |
|
962
|
962
|
* This allows us to fake it till we make it. |
|
963
|
963
|
*/ |
|
964
|
|
- if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
|
964
|
+ if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
965
|
965
|
$has_multisort = true; |
|
966
|
|
- $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
967
|
|
- if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
968
|
|
- $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
|
966
|
+ $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
|
967
|
+ if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
|
968
|
+ $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
969
|
969
|
} |
|
970
|
970
|
} |
|
971
|
971
|
|
|
@@ -974,31 +974,30 @@ discard block |
|
|
block discarded – undo |
|
974
|
974
|
*/ |
|
975
|
975
|
$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
|
976
|
976
|
|
|
977
|
|
- $parameters['context_view_id'] = $this->ID; |
|
|
977
|
+ $parameters[ 'context_view_id' ] = $this->ID; |
|
978
|
978
|
$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
|
979
|
979
|
|
|
980
|
980
|
if ( ! is_array( $parameters ) ) { |
|
981
|
981
|
$parameters = array(); |
|
982
|
982
|
} |
|
983
|
983
|
|
|
984
|
|
- if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
985
|
|
- $parameters['search_criteria'] = array(); |
|
|
984
|
+ if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
|
985
|
+ $parameters[ 'search_criteria' ] = array(); |
|
986
|
986
|
} |
|
987
|
987
|
|
|
988
|
|
- if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
989
|
|
- $parameters['search_criteria']['field_filters'] = array(); |
|
|
988
|
+ if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
|
989
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
990
|
990
|
} |
|
991
|
991
|
|
|
992
|
992
|
if ( $request instanceof REST\Request ) { |
|
993
|
993
|
$atts = $this->settings->as_atts(); |
|
994
|
994
|
$paging_parameters = wp_parse_args( $request->get_paging(), array( |
|
995
|
|
- 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
|
995
|
+ 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
996
|
996
|
) ); |
|
997
|
|
- $parameters['paging'] = $paging_parameters['paging']; |
|
|
997
|
+ $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
998
|
998
|
} |
|
999
|
999
|
|
|
1000
|
|
- $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
1001
|
|
- : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
|
1000
|
+ $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
1002
|
1001
|
|
|
1003
|
1002
|
/** |
|
1004
|
1003
|
* Cleanup duplicate field_filter parameters to simplify the query. |
|
@@ -1006,14 +1005,14 @@ discard block |
|
|
block discarded – undo |
|
1006
|
1005
|
$unique_field_filters = array(); |
|
1007
|
1006
|
foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
|
1008
|
1007
|
if ( 'mode' === $key ) { |
|
1009
|
|
- $unique_field_filters['mode'] = $filter; |
|
|
1008
|
+ $unique_field_filters[ 'mode' ] = $filter; |
|
1010
|
1009
|
} else if ( ! in_array( $filter, $unique_field_filters ) ) { |
|
1011
|
|
- $unique_field_filters[] = $filter; |
|
|
1010
|
+ $unique_field_filters[ ] = $filter; |
|
1012
|
1011
|
} |
|
1013
|
1012
|
} |
|
1014
|
|
- $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
|
1013
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
1015
|
1014
|
|
|
1016
|
|
- if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
|
1015
|
+ if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
1017
|
1016
|
gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
|
1018
|
1017
|
} |
|
1019
|
1018
|
|
|
@@ -1022,7 +1021,7 @@ discard block |
|
|
block discarded – undo |
|
1022
|
1021
|
$query_class = $this->get_query_class(); |
|
1023
|
1022
|
|
|
1024
|
1023
|
/** @type \GF_Query $query */ |
|
1025
|
|
- $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
|
1024
|
+ $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1026
|
1025
|
|
|
1027
|
1026
|
/** |
|
1028
|
1027
|
* Apply multisort. |
|
@@ -1033,15 +1032,15 @@ discard block |
|
|
block discarded – undo |
|
1033
|
1032
|
$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
|
1034
|
1033
|
$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
|
1035
|
1034
|
|
|
1036
|
|
- $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
|
1035
|
+ $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1037
|
1036
|
|
|
1038
|
|
- if( $has_sort_query_param ) { |
|
1039
|
|
- $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
|
1037
|
+ if ( $has_sort_query_param ) { |
|
|
1038
|
+ $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1040
|
1039
|
} |
|
1041
|
1040
|
|
|
1042
|
1041
|
if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
|
1043
|
|
- $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1044
|
|
- $sort_directions = array_values( $_GET['sort'] ); |
|
|
1042
|
+ $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
|
1043
|
+ $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1045
|
1044
|
} else { |
|
1046
|
1045
|
$sort_field_ids = $view_setting_sort_field_ids; |
|
1047
|
1046
|
$sort_directions = $view_setting_sort_directions; |
|
@@ -1049,7 +1048,7 @@ discard block |
|
|
block discarded – undo |
|
1049
|
1048
|
|
|
1050
|
1049
|
$skip_first = false; |
|
1051
|
1050
|
|
|
1052
|
|
- foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
|
1051
|
+ foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1053
|
1052
|
|
|
1054
|
1053
|
if ( ! $skip_first && ! $has_sort_query_param ) { |
|
1055
|
1054
|
$skip_first = true; // Skip the first one, it's already in the query |
|
@@ -1079,18 +1078,18 @@ discard block |
|
|
block discarded – undo |
|
1079
|
1078
|
|
|
1080
|
1079
|
$merged_time = false; |
|
1081
|
1080
|
|
|
1082
|
|
- foreach ( $q['order'] as $oid => $order ) { |
|
|
1081
|
+ foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1083
|
1082
|
|
|
1084
|
1083
|
$column = null; |
|
1085
|
1084
|
|
|
1086
|
|
- if ( $order[0] instanceof \GF_Query_Column ) { |
|
1087
|
|
- $column = $order[0]; |
|
1088
|
|
- } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1089
|
|
- if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
|
1085
|
+ if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
|
1086
|
+ $column = $order[ 0 ]; |
|
|
1087
|
+ } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
|
1088
|
+ if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1090
|
1089
|
$orders[ $oid ] = $order; |
|
1091
|
1090
|
continue; // Need something that resembles a single sort |
|
1092
|
1091
|
} |
|
1093
|
|
- $column = $order[0]->columns[0]; |
|
|
1092
|
+ $column = $order[ 0 ]->columns[ 0 ]; |
|
1094
|
1093
|
} |
|
1095
|
1094
|
|
|
1096
|
1095
|
if ( ! $column || ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
|
@@ -1104,7 +1103,7 @@ discard block |
|
|
block discarded – undo |
|
1104
|
1103
|
|
|
1105
|
1104
|
$orders[ $oid ] = array( |
|
1106
|
1105
|
new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
|
1107
|
|
- $order[1] // Mock it! |
|
|
1106
|
+ $order[ 1 ] // Mock it! |
|
1108
|
1107
|
); |
|
1109
|
1108
|
|
|
1110
|
1109
|
$merged_time = true; |
|
@@ -1115,15 +1114,15 @@ discard block |
|
|
block discarded – undo |
|
1115
|
1114
|
* ORDER again. |
|
1116
|
1115
|
*/ |
|
1117
|
1116
|
if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
|
1118
|
|
- $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
|
1117
|
+ $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1119
|
1118
|
} |
|
1120
|
1119
|
} |
|
1121
|
1120
|
|
|
1122
|
1121
|
return $sql; |
|
1123
|
1122
|
} ); |
|
1124
|
1123
|
|
|
1125
|
|
- $query->limit( $parameters['paging']['page_size'] ) |
|
1126
|
|
- ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
|
1124
|
+ $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
|
1125
|
+ ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1127
|
1126
|
|
|
1128
|
1127
|
/** |
|
1129
|
1128
|
* Any joins? |
|
@@ -1143,7 +1142,7 @@ discard block |
|
|
block discarded – undo |
|
1143
|
1142
|
|
|
1144
|
1143
|
$query_parameters = $query->_introspect(); |
|
1145
|
1144
|
|
|
1146
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
1145
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1147
|
1146
|
} |
|
1148
|
1147
|
|
|
1149
|
1148
|
// Filter to active entries only |
|
@@ -1161,7 +1160,7 @@ discard block |
|
|
block discarded – undo |
|
1161
|
1160
|
); |
|
1162
|
1161
|
|
|
1163
|
1162
|
$q = $query->_introspect(); |
|
1164
|
|
- $query->where( \GF_Query_Condition::_and( $q['where'], $status_conditions ) ); |
|
|
1163
|
+ $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $status_conditions ) ); |
|
1165
|
1164
|
|
|
1166
|
1165
|
/** |
|
1167
|
1166
|
* Applies legacy modifications to Query for is_approved settings. |
|
@@ -1189,7 +1188,7 @@ discard block |
|
|
block discarded – undo |
|
1189
|
1188
|
$conditions = array(); |
|
1190
|
1189
|
|
|
1191
|
1190
|
foreach ( $condition->expressions as $_condition ) { |
|
1192
|
|
- $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
|
1191
|
+ $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1193
|
1192
|
} |
|
1194
|
1193
|
|
|
1195
|
1194
|
return call_user_func_array( |
|
@@ -1218,10 +1217,10 @@ discard block |
|
|
block discarded – undo |
|
1218
|
1217
|
$q = new $query_class( $form_id ); |
|
1219
|
1218
|
|
|
1220
|
1219
|
// Copy the WHERE clauses but substitute the field_ids to the respective ones |
|
1221
|
|
- $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
|
1220
|
+ $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1222
|
1221
|
|
|
1223
|
1222
|
// Copy the ORDER clause and substitute the field_ids to the respective ones |
|
1224
|
|
- foreach ( $query_parameters['order'] as $order ) { |
|
|
1223
|
+ foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1225
|
1224
|
[ $column, $_order ] = $order; |
|
1226
|
1225
|
|
|
1227
|
1226
|
if ( $column && $column instanceof \GF_Query_Column ) { |
|
@@ -1235,15 +1234,15 @@ discard block |
|
|
block discarded – undo |
|
1235
|
1234
|
|
|
1236
|
1235
|
add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
|
1237
|
1236
|
// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
|
1238
|
|
- $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
|
1237
|
+ $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1239
|
1238
|
|
|
1240
|
1239
|
// Record the SQL |
|
1241
|
|
- $unions_sql[] = array( |
|
|
1240
|
+ $unions_sql[ ] = array( |
|
1242
|
1241
|
// Remove columns, we'll rebuild them |
|
1243
|
1242
|
'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
|
1244
|
|
- 'from' => $sql['from'], |
|
1245
|
|
- 'join' => $sql['join'], |
|
1246
|
|
- 'where' => $sql['where'], |
|
|
1243
|
+ 'from' => $sql[ 'from' ], |
|
|
1244
|
+ 'join' => $sql[ 'join' ], |
|
|
1245
|
+ 'where' => $sql[ 'where' ], |
|
1247
|
1246
|
// Remove order and limit |
|
1248
|
1247
|
); |
|
1249
|
1248
|
|
|
@@ -1260,11 +1259,11 @@ discard block |
|
|
block discarded – undo |
|
1260
|
1259
|
|
|
1261
|
1260
|
add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
|
1262
|
1261
|
// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
|
1263
|
|
- $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
|
1262
|
+ $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1264
|
1263
|
|
|
1265
|
1264
|
// Remove columns, we'll rebuild them |
|
1266
|
|
- preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1267
|
|
- $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
|
1265
|
+ preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
|
1266
|
+ $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1268
|
1267
|
|
|
1269
|
1268
|
$unions = array(); |
|
1270
|
1269
|
|
|
@@ -1275,30 +1274,30 @@ discard block |
|
|
block discarded – undo |
|
1275
|
1274
|
}; |
|
1276
|
1275
|
|
|
1277
|
1276
|
// Add all the order columns into the selects, so we can order by the whole union group |
|
1278
|
|
- preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
|
1277
|
+ preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1279
|
1278
|
|
|
1280
|
1279
|
$columns = array( |
|
1281
|
|
- sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
|
1280
|
+ sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1282
|
1281
|
); |
|
1283
|
1282
|
|
|
1284
|
1283
|
foreach ( array_slice( $order_matches, 1 ) as $match ) { |
|
1285
|
|
- $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
|
1284
|
+ $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1286
|
1285
|
|
|
1287
|
1286
|
// Rewrite the order columns to the shared aliases |
|
1288
|
|
- $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
|
1287
|
+ $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1289
|
1288
|
} |
|
1290
|
1289
|
|
|
1291
|
1290
|
$columns = array_unique( $columns ); |
|
1292
|
1291
|
|
|
1293
|
1292
|
// Add the columns to every UNION |
|
1294
|
1293
|
foreach ( $unions_sql as $union_sql ) { |
|
1295
|
|
- $union_sql['select'] .= implode( ', ', $columns ); |
|
1296
|
|
- $unions []= implode( ' ', $union_sql ); |
|
|
1294
|
+ $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
|
1295
|
+ $unions [ ] = implode( ' ', $union_sql ); |
|
1297
|
1296
|
} |
|
1298
|
1297
|
|
|
1299
|
1298
|
// Add the columns to the main SELECT, but only grab the entry id column |
|
1300
|
|
- $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1301
|
|
- $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
|
1299
|
+ $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
|
1300
|
+ $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1302
|
1301
|
|
|
1303
|
1302
|
return $sql; |
|
1304
|
1303
|
} ); |
|
@@ -1343,20 +1342,20 @@ discard block |
|
|
block discarded – undo |
|
1343
|
1342
|
} ); |
|
1344
|
1343
|
} else { |
|
1345
|
1344
|
$entries = $this->form->entries |
|
1346
|
|
- ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
|
1345
|
+ ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1347
|
1346
|
->offset( $this->settings->get( 'offset' ) ) |
|
1348
|
|
- ->limit( $parameters['paging']['page_size'] ) |
|
|
1347
|
+ ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1349
|
1348
|
->page( $page ); |
|
1350
|
1349
|
|
|
1351
|
|
- if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
|
1350
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1352
|
1351
|
// Pluck off multisort arrays |
|
1353
|
|
- $parameters['sorting'] = $parameters['sorting'][0]; |
|
|
1352
|
+ $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1354
|
1353
|
} |
|
1355
|
1354
|
|
|
1356
|
|
- if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
|
1355
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1357
|
1356
|
$field = new \GV\Field(); |
|
1358
|
|
- $field->ID = $parameters['sorting']['key']; |
|
1359
|
|
- $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
|
1357
|
+ $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
|
1358
|
+ $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1360
|
1359
|
$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
|
1361
|
1360
|
} |
|
1362
|
1361
|
} |
|
@@ -1440,7 +1439,7 @@ discard block |
|
|
block discarded – undo |
|
1440
|
1439
|
$allowed = $headers = array(); |
|
1441
|
1440
|
|
|
1442
|
1441
|
foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
|
1443
|
|
- $allowed[] = $field; |
|
|
1442
|
+ $allowed[ ] = $field; |
|
1444
|
1443
|
} |
|
1445
|
1444
|
|
|
1446
|
1445
|
$renderer = new Field_Renderer(); |
|
@@ -1462,17 +1461,17 @@ discard block |
|
|
block discarded – undo |
|
1462
|
1461
|
} ); |
|
1463
|
1462
|
|
|
1464
|
1463
|
foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
|
1465
|
|
- $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
|
1464
|
+ $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1466
|
1465
|
} |
|
1467
|
1466
|
|
|
1468
|
1467
|
foreach ( $allowed as $field ) { |
|
1469
|
1468
|
$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
|
1470
|
1469
|
|
|
1471
|
|
- $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
|
1470
|
+ $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1472
|
1471
|
|
|
1473
|
1472
|
if ( ! $headers_done ) { |
|
1474
|
1473
|
$label = $field->get_label( $view, $source, $entry ); |
|
1475
|
|
- $headers[] = $label ? $label : $field->ID; |
|
|
1474
|
+ $headers[ ] = $label ? $label : $field->ID; |
|
1476
|
1475
|
} |
|
1477
|
1476
|
} |
|
1478
|
1477
|
|
|
@@ -1570,7 +1569,7 @@ discard block |
|
|
block discarded – undo |
|
1570
|
1569
|
* @return void |
|
1571
|
1570
|
*/ |
|
1572
|
1571
|
public function set_anchor_id( $counter = 1 ) { |
|
1573
|
|
- $this->anchor_id = sprintf( 'gv-view-%d-%d', $this->ID, (int) $counter ); |
|
|
1572
|
+ $this->anchor_id = sprintf( 'gv-view-%d-%d', $this->ID, (int)$counter ); |
|
1574
|
1573
|
} |
|
1575
|
1574
|
|
|
1576
|
1575
|
/** |
|
@@ -1630,7 +1629,7 @@ discard block |
|
|
block discarded – undo |
|
1630
|
1629
|
* @param Join $join Which join we are dealing with. |
|
1631
|
1630
|
* @param self $view Instance of the view we are dealing with. |
|
1632
|
1631
|
*/ |
|
1633
|
|
- $should_apply = (bool) apply_filters( 'gravityview/view/get_entries/should_apply_legacy_join_is_approved_query_conditions', true, $query, $join, $this ); |
|
|
1632
|
+ $should_apply = (bool)apply_filters( 'gravityview/view/get_entries/should_apply_legacy_join_is_approved_query_conditions', true, $query, $join, $this ); |
|
1634
|
1633
|
if ( ! $should_apply ) { |
|
1635
|
1634
|
return; |
|
1636
|
1635
|
} |
|
@@ -1660,6 +1659,6 @@ discard block |
|
|
block discarded – undo |
|
1660
|
1659
|
|
|
1661
|
1660
|
$query_parameters = $query->_introspect(); |
|
1662
|
1661
|
|
|
1663
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
1662
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1664
|
1663
|
} |
|
1665
|
1664
|
} |