|
@@ -125,7 +125,7 @@ discard block |
|
|
block discarded – undo |
|
125
|
125
|
$supports = array( 'title', 'revisions' ); |
|
126
|
126
|
|
|
127
|
127
|
if ( $is_hierarchical ) { |
|
128
|
|
- $supports[] = 'page-attributes'; |
|
|
128
|
+ $supports[ ] = 'page-attributes'; |
|
129
|
129
|
} |
|
130
|
130
|
|
|
131
|
131
|
/** |
|
@@ -229,12 +229,12 @@ discard block |
|
|
block discarded – undo |
|
229
|
229
|
$tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' ); |
|
230
|
230
|
|
|
231
|
231
|
add_filter( 'query_vars', function( $query_vars ) { |
|
232
|
|
- $query_vars[] = 'csv'; |
|
233
|
|
- $query_vars[] = 'tsv'; |
|
|
232
|
+ $query_vars[ ] = 'csv'; |
|
|
233
|
+ $query_vars[ ] = 'tsv'; |
|
234
|
234
|
return $query_vars; |
|
235
|
235
|
} ); |
|
236
|
236
|
|
|
237
|
|
- if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) { |
|
|
237
|
+ if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) { |
|
238
|
238
|
call_user_func_array( 'add_rewrite_rule', $csv_rule ); |
|
239
|
239
|
call_user_func_array( 'add_rewrite_rule', $tsv_rule ); |
|
240
|
240
|
} |
|
@@ -295,7 +295,7 @@ discard block |
|
|
block discarded – undo |
|
295
|
295
|
|
|
296
|
296
|
$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
|
297
|
297
|
|
|
298
|
|
- $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
|
298
|
+ $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
299
|
299
|
|
|
300
|
300
|
return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' ); |
|
301
|
301
|
} |
|
@@ -321,13 +321,13 @@ discard block |
|
|
block discarded – undo |
|
321
|
321
|
return $content; |
|
322
|
322
|
} |
|
323
|
323
|
|
|
324
|
|
- $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
|
324
|
+ $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
325
|
325
|
|
|
326
|
326
|
/** |
|
327
|
327
|
* Editing a single entry. |
|
328
|
328
|
*/ |
|
329
|
329
|
if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
|
330
|
|
- if ( $entry['status'] != 'active' ) { |
|
|
330
|
+ if ( $entry[ 'status' ] != 'active' ) { |
|
331
|
331
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
|
332
|
332
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
333
|
333
|
} |
|
@@ -338,7 +338,7 @@ discard block |
|
|
block discarded – undo |
|
338
|
338
|
} |
|
339
|
339
|
|
|
340
|
340
|
if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
|
341
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
341
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
342
|
342
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
|
343
|
343
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
344
|
344
|
} |
|
@@ -361,7 +361,7 @@ discard block |
|
|
block discarded – undo |
|
361
|
361
|
|
|
362
|
362
|
foreach ( $entryset as $e ) { |
|
363
|
363
|
|
|
364
|
|
- if ( 'active' !== $e['status'] ) { |
|
|
364
|
+ if ( 'active' !== $e[ 'status' ] ) { |
|
365
|
365
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
|
366
|
366
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
367
|
367
|
} |
|
@@ -372,7 +372,7 @@ discard block |
|
|
block discarded – undo |
|
372
|
372
|
} |
|
373
|
373
|
|
|
374
|
374
|
if ( $show_only_approved && ! $is_admin_and_can_view ) { |
|
375
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
375
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
376
|
376
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
|
377
|
377
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
378
|
378
|
} |
|
@@ -547,7 +547,7 @@ discard block |
|
|
block discarded – undo |
|
547
|
547
|
$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
|
548
|
548
|
$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
|
549
|
549
|
|
|
550
|
|
- $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
|
550
|
+ $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
551
|
551
|
} |
|
552
|
552
|
|
|
553
|
553
|
return $joins; |
|
@@ -637,13 +637,13 @@ discard block |
|
|
block discarded – undo |
|
637
|
637
|
} |
|
638
|
638
|
|
|
639
|
639
|
foreach ( $_fields as $field ) { |
|
640
|
|
- if ( ! empty( $field['unions'] ) ) { |
|
641
|
|
- foreach ( $field['unions'] as $form_id => $field_id ) { |
|
|
640
|
+ if ( ! empty( $field[ 'unions' ] ) ) { |
|
|
641
|
+ foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
642
|
642
|
if ( ! isset( $unions[ $form_id ] ) ) { |
|
643
|
643
|
$unions[ $form_id ] = array(); |
|
644
|
644
|
} |
|
645
|
645
|
|
|
646
|
|
- $unions[ $form_id ][ $field['id'] ] = |
|
|
646
|
+ $unions[ $form_id ][ $field[ 'id' ] ] = |
|
647
|
647
|
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 ); |
|
648
|
648
|
} |
|
649
|
649
|
} |
|
@@ -698,7 +698,7 @@ discard block |
|
|
block discarded – undo |
|
698
|
698
|
if ( ! $view->form ) { |
|
699
|
699
|
gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
|
700
|
700
|
'view_id' => $view->ID, |
|
701
|
|
- 'form_id' => $view->_gravityview_form_id ? : 0, |
|
|
701
|
+ 'form_id' => $view->_gravityview_form_id ?: 0, |
|
702
|
702
|
) ); |
|
703
|
703
|
} |
|
704
|
704
|
|
|
@@ -942,11 +942,11 @@ discard block |
|
|
block discarded – undo |
|
942
|
942
|
* Remove multiple sorting before calling legacy filters. |
|
943
|
943
|
* This allows us to fake it till we make it. |
|
944
|
944
|
*/ |
|
945
|
|
- if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
|
945
|
+ if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
946
|
946
|
$has_multisort = true; |
|
947
|
|
- $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
948
|
|
- if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
949
|
|
- $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
|
947
|
+ $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
|
948
|
+ if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
|
949
|
+ $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
950
|
950
|
} |
|
951
|
951
|
} |
|
952
|
952
|
|
|
@@ -955,31 +955,30 @@ discard block |
|
|
block discarded – undo |
|
955
|
955
|
*/ |
|
956
|
956
|
$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
|
957
|
957
|
|
|
958
|
|
- $parameters['context_view_id'] = $this->ID; |
|
|
958
|
+ $parameters[ 'context_view_id' ] = $this->ID; |
|
959
|
959
|
$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
|
960
|
960
|
|
|
961
|
961
|
if ( ! is_array( $parameters ) ) { |
|
962
|
962
|
$parameters = array(); |
|
963
|
963
|
} |
|
964
|
964
|
|
|
965
|
|
- if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
966
|
|
- $parameters['search_criteria'] = array(); |
|
|
965
|
+ if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
|
966
|
+ $parameters[ 'search_criteria' ] = array(); |
|
967
|
967
|
} |
|
968
|
968
|
|
|
969
|
|
- if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
970
|
|
- $parameters['search_criteria']['field_filters'] = array(); |
|
|
969
|
+ if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
|
970
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
971
|
971
|
} |
|
972
|
972
|
|
|
973
|
973
|
if ( $request instanceof REST\Request ) { |
|
974
|
974
|
$atts = $this->settings->as_atts(); |
|
975
|
975
|
$paging_parameters = wp_parse_args( $request->get_paging(), array( |
|
976
|
|
- 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
|
976
|
+ 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
977
|
977
|
) ); |
|
978
|
|
- $parameters['paging'] = $paging_parameters['paging']; |
|
|
978
|
+ $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
979
|
979
|
} |
|
980
|
980
|
|
|
981
|
|
- $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
982
|
|
- : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
|
981
|
+ $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
983
|
982
|
|
|
984
|
983
|
/** |
|
985
|
984
|
* Cleanup duplicate field_filter parameters to simplify the query. |
|
@@ -987,14 +986,14 @@ discard block |
|
|
block discarded – undo |
|
987
|
986
|
$unique_field_filters = array(); |
|
988
|
987
|
foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
|
989
|
988
|
if ( 'mode' === $key ) { |
|
990
|
|
- $unique_field_filters['mode'] = $filter; |
|
|
989
|
+ $unique_field_filters[ 'mode' ] = $filter; |
|
991
|
990
|
} else if ( ! in_array( $filter, $unique_field_filters ) ) { |
|
992
|
|
- $unique_field_filters[] = $filter; |
|
|
991
|
+ $unique_field_filters[ ] = $filter; |
|
993
|
992
|
} |
|
994
|
993
|
} |
|
995
|
|
- $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
|
994
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
996
|
995
|
|
|
997
|
|
- if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
|
996
|
+ if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
998
|
997
|
gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
|
999
|
998
|
} |
|
1000
|
999
|
|
|
@@ -1003,7 +1002,7 @@ discard block |
|
|
block discarded – undo |
|
1003
|
1002
|
$query_class = $this->get_query_class(); |
|
1004
|
1003
|
|
|
1005
|
1004
|
/** @type \GF_Query $query */ |
|
1006
|
|
- $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
|
1005
|
+ $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1007
|
1006
|
|
|
1008
|
1007
|
/** |
|
1009
|
1008
|
* Apply multisort. |
|
@@ -1014,15 +1013,15 @@ discard block |
|
|
block discarded – undo |
|
1014
|
1013
|
$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
|
1015
|
1014
|
$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
|
1016
|
1015
|
|
|
1017
|
|
- $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
|
1016
|
+ $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1018
|
1017
|
|
|
1019
|
|
- if( $has_sort_query_param ) { |
|
1020
|
|
- $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
|
1018
|
+ if ( $has_sort_query_param ) { |
|
|
1019
|
+ $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1021
|
1020
|
} |
|
1022
|
1021
|
|
|
1023
|
1022
|
if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
|
1024
|
|
- $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1025
|
|
- $sort_directions = array_values( $_GET['sort'] ); |
|
|
1023
|
+ $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
|
1024
|
+ $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1026
|
1025
|
} else { |
|
1027
|
1026
|
$sort_field_ids = $view_setting_sort_field_ids; |
|
1028
|
1027
|
$sort_directions = $view_setting_sort_directions; |
|
@@ -1030,7 +1029,7 @@ discard block |
|
|
block discarded – undo |
|
1030
|
1029
|
|
|
1031
|
1030
|
$skip_first = false; |
|
1032
|
1031
|
|
|
1033
|
|
- foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
|
1032
|
+ foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1034
|
1033
|
|
|
1035
|
1034
|
if ( ! $skip_first && ! $has_sort_query_param ) { |
|
1036
|
1035
|
$skip_first = true; // Skip the first one, it's already in the query |
|
@@ -1060,15 +1059,15 @@ discard block |
|
|
block discarded – undo |
|
1060
|
1059
|
|
|
1061
|
1060
|
$merged_time = false; |
|
1062
|
1061
|
|
|
1063
|
|
- foreach ( $q['order'] as $oid => $order ) { |
|
1064
|
|
- if ( $order[0] instanceof \GF_Query_Column ) { |
|
1065
|
|
- $column = $order[0]; |
|
1066
|
|
- } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1067
|
|
- if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
|
1062
|
+ foreach ( $q[ 'order' ] as $oid => $order ) { |
|
|
1063
|
+ if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
|
1064
|
+ $column = $order[ 0 ]; |
|
|
1065
|
+ } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
|
1066
|
+ if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1068
|
1067
|
$orders[ $oid ] = $order; |
|
1069
|
1068
|
continue; // Need something that resembles a single sort |
|
1070
|
1069
|
} |
|
1071
|
|
- $column = $order[0]->columns[0]; |
|
|
1070
|
+ $column = $order[ 0 ]->columns[ 0 ]; |
|
1072
|
1071
|
} |
|
1073
|
1072
|
|
|
1074
|
1073
|
if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
|
@@ -1082,7 +1081,7 @@ discard block |
|
|
block discarded – undo |
|
1082
|
1081
|
|
|
1083
|
1082
|
$orders[ $oid ] = array( |
|
1084
|
1083
|
new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
|
1085
|
|
- $order[1] // Mock it! |
|
|
1084
|
+ $order[ 1 ] // Mock it! |
|
1086
|
1085
|
); |
|
1087
|
1086
|
|
|
1088
|
1087
|
$merged_time = true; |
|
@@ -1093,15 +1092,15 @@ discard block |
|
|
block discarded – undo |
|
1093
|
1092
|
* ORDER again. |
|
1094
|
1093
|
*/ |
|
1095
|
1094
|
if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
|
1096
|
|
- $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
|
1095
|
+ $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1097
|
1096
|
} |
|
1098
|
1097
|
} |
|
1099
|
1098
|
|
|
1100
|
1099
|
return $sql; |
|
1101
|
1100
|
} ); |
|
1102
|
1101
|
|
|
1103
|
|
- $query->limit( $parameters['paging']['page_size'] ) |
|
1104
|
|
- ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
|
1102
|
+ $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
|
1103
|
+ ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1105
|
1104
|
|
|
1106
|
1105
|
/** |
|
1107
|
1106
|
* Any joins? |
|
@@ -1124,7 +1123,7 @@ discard block |
|
|
block discarded – undo |
|
1124
|
1123
|
|
|
1125
|
1124
|
$query_parameters = $query->_introspect(); |
|
1126
|
1125
|
|
|
1127
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
1126
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1128
|
1127
|
} |
|
1129
|
1128
|
|
|
1130
|
1129
|
/** |
|
@@ -1158,7 +1157,7 @@ discard block |
|
|
block discarded – undo |
|
1158
|
1157
|
} |
|
1159
|
1158
|
|
|
1160
|
1159
|
$q = $query->_introspect(); |
|
1161
|
|
- $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
|
1160
|
+ $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1162
|
1161
|
|
|
1163
|
1162
|
if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
|
1164
|
1163
|
|
|
@@ -1183,7 +1182,7 @@ discard block |
|
|
block discarded – undo |
|
1183
|
1182
|
|
|
1184
|
1183
|
$query_parameters = $query->_introspect(); |
|
1185
|
1184
|
|
|
1186
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
1185
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1187
|
1186
|
} |
|
1188
|
1187
|
} |
|
1189
|
1188
|
|
|
@@ -1207,7 +1206,7 @@ discard block |
|
|
block discarded – undo |
|
1207
|
1206
|
$conditions = array(); |
|
1208
|
1207
|
|
|
1209
|
1208
|
foreach ( $condition->expressions as $_condition ) { |
|
1210
|
|
- $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
|
1209
|
+ $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1211
|
1210
|
} |
|
1212
|
1211
|
|
|
1213
|
1212
|
return call_user_func_array( |
|
@@ -1236,10 +1235,10 @@ discard block |
|
|
block discarded – undo |
|
1236
|
1235
|
$q = new $query_class( $form_id ); |
|
1237
|
1236
|
|
|
1238
|
1237
|
// Copy the WHERE clauses but substitute the field_ids to the respective ones |
|
1239
|
|
- $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
|
1238
|
+ $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1240
|
1239
|
|
|
1241
|
1240
|
// Copy the ORDER clause and substitute the field_ids to the respective ones |
|
1242
|
|
- foreach ( $query_parameters['order'] as $order ) { |
|
|
1241
|
+ foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1243
|
1242
|
list( $column, $_order ) = $order; |
|
1244
|
1243
|
|
|
1245
|
1244
|
if ( $column && $column instanceof \GF_Query_Column ) { |
|
@@ -1253,15 +1252,15 @@ discard block |
|
|
block discarded – undo |
|
1253
|
1252
|
|
|
1254
|
1253
|
add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
|
1255
|
1254
|
// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
|
1256
|
|
- $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
|
1255
|
+ $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1257
|
1256
|
|
|
1258
|
1257
|
// Record the SQL |
|
1259
|
|
- $unions_sql[] = array( |
|
|
1258
|
+ $unions_sql[ ] = array( |
|
1260
|
1259
|
// Remove columns, we'll rebuild them |
|
1261
|
1260
|
'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
|
1262
|
|
- 'from' => $sql['from'], |
|
1263
|
|
- 'join' => $sql['join'], |
|
1264
|
|
- 'where' => $sql['where'], |
|
|
1261
|
+ 'from' => $sql[ 'from' ], |
|
|
1262
|
+ 'join' => $sql[ 'join' ], |
|
|
1263
|
+ 'where' => $sql[ 'where' ], |
|
1265
|
1264
|
// Remove order and limit |
|
1266
|
1265
|
); |
|
1267
|
1266
|
|
|
@@ -1278,11 +1277,11 @@ discard block |
|
|
block discarded – undo |
|
1278
|
1277
|
|
|
1279
|
1278
|
add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
|
1280
|
1279
|
// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
|
1281
|
|
- $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
|
1280
|
+ $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1282
|
1281
|
|
|
1283
|
1282
|
// Remove columns, we'll rebuild them |
|
1284
|
|
- preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1285
|
|
- $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
|
1283
|
+ preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
|
1284
|
+ $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1286
|
1285
|
|
|
1287
|
1286
|
$unions = array(); |
|
1288
|
1287
|
|
|
@@ -1293,30 +1292,30 @@ discard block |
|
|
block discarded – undo |
|
1293
|
1292
|
}; |
|
1294
|
1293
|
|
|
1295
|
1294
|
// Add all the order columns into the selects, so we can order by the whole union group |
|
1296
|
|
- preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
|
1295
|
+ preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1297
|
1296
|
|
|
1298
|
1297
|
$columns = array( |
|
1299
|
|
- sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
|
1298
|
+ sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1300
|
1299
|
); |
|
1301
|
1300
|
|
|
1302
|
1301
|
foreach ( array_slice( $order_matches, 1 ) as $match ) { |
|
1303
|
|
- $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
|
1302
|
+ $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1304
|
1303
|
|
|
1305
|
1304
|
// Rewrite the order columns to the shared aliases |
|
1306
|
|
- $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
|
1305
|
+ $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1307
|
1306
|
} |
|
1308
|
1307
|
|
|
1309
|
1308
|
$columns = array_unique( $columns ); |
|
1310
|
1309
|
|
|
1311
|
1310
|
// Add the columns to every UNION |
|
1312
|
1311
|
foreach ( $unions_sql as $union_sql ) { |
|
1313
|
|
- $union_sql['select'] .= implode( ', ', $columns ); |
|
1314
|
|
- $unions []= implode( ' ', $union_sql ); |
|
|
1312
|
+ $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
|
1313
|
+ $unions [ ] = implode( ' ', $union_sql ); |
|
1315
|
1314
|
} |
|
1316
|
1315
|
|
|
1317
|
1316
|
// Add the columns to the main SELECT, but only grab the entry id column |
|
1318
|
|
- $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1319
|
|
- $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
|
1317
|
+ $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
|
1318
|
+ $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1320
|
1319
|
|
|
1321
|
1320
|
return $sql; |
|
1322
|
1321
|
} ); |
|
@@ -1361,20 +1360,20 @@ discard block |
|
|
block discarded – undo |
|
1361
|
1360
|
} ); |
|
1362
|
1361
|
} else { |
|
1363
|
1362
|
$entries = $this->form->entries |
|
1364
|
|
- ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
|
1363
|
+ ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1365
|
1364
|
->offset( $this->settings->get( 'offset' ) ) |
|
1366
|
|
- ->limit( $parameters['paging']['page_size'] ) |
|
|
1365
|
+ ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1367
|
1366
|
->page( $page ); |
|
1368
|
1367
|
|
|
1369
|
|
- if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
|
1368
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1370
|
1369
|
// Pluck off multisort arrays |
|
1371
|
|
- $parameters['sorting'] = $parameters['sorting'][0]; |
|
|
1370
|
+ $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1372
|
1371
|
} |
|
1373
|
1372
|
|
|
1374
|
|
- if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
|
1373
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1375
|
1374
|
$field = new \GV\Field(); |
|
1376
|
|
- $field->ID = $parameters['sorting']['key']; |
|
1377
|
|
- $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
|
1375
|
+ $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
|
1376
|
+ $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1378
|
1377
|
$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
|
1379
|
1378
|
} |
|
1380
|
1379
|
} |
|
@@ -1458,7 +1457,7 @@ discard block |
|
|
block discarded – undo |
|
1458
|
1457
|
$allowed = $headers = array(); |
|
1459
|
1458
|
|
|
1460
|
1459
|
foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
|
1461
|
|
- $allowed[] = $field; |
|
|
1460
|
+ $allowed[ ] = $field; |
|
1462
|
1461
|
} |
|
1463
|
1462
|
|
|
1464
|
1463
|
$renderer = new Field_Renderer(); |
|
@@ -1480,17 +1479,17 @@ discard block |
|
|
block discarded – undo |
|
1480
|
1479
|
} ); |
|
1481
|
1480
|
|
|
1482
|
1481
|
foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
|
1483
|
|
- $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
|
1482
|
+ $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1484
|
1483
|
} |
|
1485
|
1484
|
|
|
1486
|
1485
|
foreach ( $allowed as $field ) { |
|
1487
|
1486
|
$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
|
1488
|
1487
|
|
|
1489
|
|
- $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
|
1488
|
+ $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1490
|
1489
|
|
|
1491
|
1490
|
if ( ! $headers_done ) { |
|
1492
|
1491
|
$label = $field->get_label( $view, $source, $entry ); |
|
1493
|
|
- $headers[] = $label ? $label : $field->ID; |
|
|
1492
|
+ $headers[ ] = $label ? $label : $field->ID; |
|
1494
|
1493
|
} |
|
1495
|
1494
|
} |
|
1496
|
1495
|
|