@@ -125,7 +125,7 @@ discard block |
||
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 | /** |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | $tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' ); |
235 | 235 | |
236 | 236 | add_filter( 'query_vars', function( $query_vars ) { |
237 | - $query_vars[] = 'csv'; |
|
238 | - $query_vars[] = 'tsv'; |
|
237 | + $query_vars[ ] = 'csv'; |
|
238 | + $query_vars[ ] = 'tsv'; |
|
239 | 239 | return $query_vars; |
240 | 240 | } ); |
241 | 241 | |
242 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) { |
|
242 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) { |
|
243 | 243 | call_user_func_array( 'add_rewrite_rule', $csv_rule ); |
244 | 244 | call_user_func_array( 'add_rewrite_rule', $tsv_rule ); |
245 | 245 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
302 | 302 | |
303 | - $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 ) ) ); |
|
303 | + $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 ) ) ); |
|
304 | 304 | |
305 | 305 | return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' ); |
306 | 306 | } |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | return $content; |
327 | 327 | } |
328 | 328 | |
329 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
329 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Editing a single entry. |
333 | 333 | */ |
334 | 334 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
335 | - if ( $entry['status'] != 'active' ) { |
|
335 | + if ( $entry[ 'status' ] != 'active' ) { |
|
336 | 336 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
337 | 337 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
338 | 338 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
346 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
346 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
347 | 347 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
348 | 348 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
349 | 349 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | foreach ( $entryset as $e ) { |
368 | 368 | |
369 | - if ( 'active' !== $e['status'] ) { |
|
369 | + if ( 'active' !== $e[ 'status' ] ) { |
|
370 | 370 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
371 | 371 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
372 | 372 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
380 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
380 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
381 | 381 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
382 | 382 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
383 | 383 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
553 | 553 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
554 | 554 | |
555 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
555 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | return $joins; |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | foreach ( $_fields as $field ) { |
645 | - if ( ! empty( $field['unions'] ) ) { |
|
646 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
645 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
646 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
647 | 647 | if ( ! isset( $unions[ $form_id ] ) ) { |
648 | 648 | $unions[ $form_id ] = array(); |
649 | 649 | } |
650 | 650 | |
651 | - $unions[ $form_id ][ $field['id'] ] = |
|
651 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
652 | 652 | 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 ); |
653 | 653 | } |
654 | 654 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | if ( ! $view->form ) { |
704 | 704 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
705 | 705 | 'view_id' => $view->ID, |
706 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
706 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
707 | 707 | ) ); |
708 | 708 | } |
709 | 709 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | public function get_entries( $request = null ) { |
937 | 937 | static $entries; |
938 | 938 | |
939 | - if( $entries && ! gravityview()->request->is_entry() ) { |
|
939 | + if ( $entries && ! gravityview()->request->is_entry() ) { |
|
940 | 940 | return $entries; |
941 | 941 | } |
942 | 942 | |
@@ -953,11 +953,11 @@ discard block |
||
953 | 953 | * Remove multiple sorting before calling legacy filters. |
954 | 954 | * This allows us to fake it till we make it. |
955 | 955 | */ |
956 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
956 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
957 | 957 | $has_multisort = true; |
958 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
959 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
960 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
958 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
959 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
960 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
@@ -966,31 +966,30 @@ discard block |
||
966 | 966 | */ |
967 | 967 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
968 | 968 | |
969 | - $parameters['context_view_id'] = $this->ID; |
|
969 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
970 | 970 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
971 | 971 | |
972 | 972 | if ( ! is_array( $parameters ) ) { |
973 | 973 | $parameters = array(); |
974 | 974 | } |
975 | 975 | |
976 | - if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
977 | - $parameters['search_criteria'] = array(); |
|
976 | + if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
977 | + $parameters[ 'search_criteria' ] = array(); |
|
978 | 978 | } |
979 | 979 | |
980 | - if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
981 | - $parameters['search_criteria']['field_filters'] = array(); |
|
980 | + if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
981 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if ( $request instanceof REST\Request ) { |
985 | 985 | $atts = $this->settings->as_atts(); |
986 | 986 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
987 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
987 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
988 | 988 | ) ); |
989 | - $parameters['paging'] = $paging_parameters['paging']; |
|
989 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
990 | 990 | } |
991 | 991 | |
992 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
993 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
992 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
994 | 993 | |
995 | 994 | /** |
996 | 995 | * Cleanup duplicate field_filter parameters to simplify the query. |
@@ -998,14 +997,14 @@ discard block |
||
998 | 997 | $unique_field_filters = array(); |
999 | 998 | foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
1000 | 999 | if ( 'mode' === $key ) { |
1001 | - $unique_field_filters['mode'] = $filter; |
|
1000 | + $unique_field_filters[ 'mode' ] = $filter; |
|
1002 | 1001 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
1003 | - $unique_field_filters[] = $filter; |
|
1002 | + $unique_field_filters[ ] = $filter; |
|
1004 | 1003 | } |
1005 | 1004 | } |
1006 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
1005 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
1007 | 1006 | |
1008 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
1007 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
1009 | 1008 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
1010 | 1009 | } |
1011 | 1010 | |
@@ -1014,7 +1013,7 @@ discard block |
||
1014 | 1013 | $query_class = $this->get_query_class(); |
1015 | 1014 | |
1016 | 1015 | /** @type \GF_Query $query */ |
1017 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
1016 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1018 | 1017 | |
1019 | 1018 | /** |
1020 | 1019 | * Apply multisort. |
@@ -1025,15 +1024,15 @@ discard block |
||
1025 | 1024 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
1026 | 1025 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
1027 | 1026 | |
1028 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
1027 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1029 | 1028 | |
1030 | - if( $has_sort_query_param ) { |
|
1031 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
1029 | + if ( $has_sort_query_param ) { |
|
1030 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1032 | 1031 | } |
1033 | 1032 | |
1034 | 1033 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
1035 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1036 | - $sort_directions = array_values( $_GET['sort'] ); |
|
1034 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
1035 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1037 | 1036 | } else { |
1038 | 1037 | $sort_field_ids = $view_setting_sort_field_ids; |
1039 | 1038 | $sort_directions = $view_setting_sort_directions; |
@@ -1041,7 +1040,7 @@ discard block |
||
1041 | 1040 | |
1042 | 1041 | $skip_first = false; |
1043 | 1042 | |
1044 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
1043 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1045 | 1044 | |
1046 | 1045 | if ( ! $skip_first && ! $has_sort_query_param ) { |
1047 | 1046 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1071,18 +1070,18 @@ discard block |
||
1071 | 1070 | |
1072 | 1071 | $merged_time = false; |
1073 | 1072 | |
1074 | - foreach ( $q['order'] as $oid => $order ) { |
|
1073 | + foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1075 | 1074 | |
1076 | 1075 | $column = null; |
1077 | 1076 | |
1078 | - if ( $order[0] instanceof \GF_Query_Column ) { |
|
1079 | - $column = $order[0]; |
|
1080 | - } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1081 | - if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
1077 | + if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
1078 | + $column = $order[ 0 ]; |
|
1079 | + } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
1080 | + if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1082 | 1081 | $orders[ $oid ] = $order; |
1083 | 1082 | continue; // Need something that resembles a single sort |
1084 | 1083 | } |
1085 | - $column = $order[0]->columns[0]; |
|
1084 | + $column = $order[ 0 ]->columns[ 0 ]; |
|
1086 | 1085 | } |
1087 | 1086 | |
1088 | 1087 | if ( ! $column || ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
@@ -1096,7 +1095,7 @@ discard block |
||
1096 | 1095 | |
1097 | 1096 | $orders[ $oid ] = array( |
1098 | 1097 | new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
1099 | - $order[1] // Mock it! |
|
1098 | + $order[ 1 ] // Mock it! |
|
1100 | 1099 | ); |
1101 | 1100 | |
1102 | 1101 | $merged_time = true; |
@@ -1107,15 +1106,15 @@ discard block |
||
1107 | 1106 | * ORDER again. |
1108 | 1107 | */ |
1109 | 1108 | if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
1110 | - $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1109 | + $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1111 | 1110 | } |
1112 | 1111 | } |
1113 | 1112 | |
1114 | 1113 | return $sql; |
1115 | 1114 | } ); |
1116 | 1115 | |
1117 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1118 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1116 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1117 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1119 | 1118 | |
1120 | 1119 | /** |
1121 | 1120 | * Any joins? |
@@ -1138,7 +1137,7 @@ discard block |
||
1138 | 1137 | |
1139 | 1138 | $query_parameters = $query->_introspect(); |
1140 | 1139 | |
1141 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1140 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1142 | 1141 | } |
1143 | 1142 | |
1144 | 1143 | /** |
@@ -1172,7 +1171,7 @@ discard block |
||
1172 | 1171 | } |
1173 | 1172 | |
1174 | 1173 | $q = $query->_introspect(); |
1175 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1174 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1176 | 1175 | |
1177 | 1176 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1178 | 1177 | |
@@ -1197,7 +1196,7 @@ discard block |
||
1197 | 1196 | |
1198 | 1197 | $query_parameters = $query->_introspect(); |
1199 | 1198 | |
1200 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1199 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1201 | 1200 | } |
1202 | 1201 | } |
1203 | 1202 | |
@@ -1221,7 +1220,7 @@ discard block |
||
1221 | 1220 | $conditions = array(); |
1222 | 1221 | |
1223 | 1222 | foreach ( $condition->expressions as $_condition ) { |
1224 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1223 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1225 | 1224 | } |
1226 | 1225 | |
1227 | 1226 | return call_user_func_array( |
@@ -1250,10 +1249,10 @@ discard block |
||
1250 | 1249 | $q = new $query_class( $form_id ); |
1251 | 1250 | |
1252 | 1251 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1253 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1252 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1254 | 1253 | |
1255 | 1254 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1256 | - foreach ( $query_parameters['order'] as $order ) { |
|
1255 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1257 | 1256 | list( $column, $_order ) = $order; |
1258 | 1257 | |
1259 | 1258 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1267,15 +1266,15 @@ discard block |
||
1267 | 1266 | |
1268 | 1267 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1269 | 1268 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1270 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1269 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1271 | 1270 | |
1272 | 1271 | // Record the SQL |
1273 | - $unions_sql[] = array( |
|
1272 | + $unions_sql[ ] = array( |
|
1274 | 1273 | // Remove columns, we'll rebuild them |
1275 | 1274 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1276 | - 'from' => $sql['from'], |
|
1277 | - 'join' => $sql['join'], |
|
1278 | - 'where' => $sql['where'], |
|
1275 | + 'from' => $sql[ 'from' ], |
|
1276 | + 'join' => $sql[ 'join' ], |
|
1277 | + 'where' => $sql[ 'where' ], |
|
1279 | 1278 | // Remove order and limit |
1280 | 1279 | ); |
1281 | 1280 | |
@@ -1292,11 +1291,11 @@ discard block |
||
1292 | 1291 | |
1293 | 1292 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1294 | 1293 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1295 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1294 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1296 | 1295 | |
1297 | 1296 | // Remove columns, we'll rebuild them |
1298 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1299 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1297 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1298 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1300 | 1299 | |
1301 | 1300 | $unions = array(); |
1302 | 1301 | |
@@ -1307,30 +1306,30 @@ discard block |
||
1307 | 1306 | }; |
1308 | 1307 | |
1309 | 1308 | // Add all the order columns into the selects, so we can order by the whole union group |
1310 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1309 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1311 | 1310 | |
1312 | 1311 | $columns = array( |
1313 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1312 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1314 | 1313 | ); |
1315 | 1314 | |
1316 | 1315 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1317 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1316 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1318 | 1317 | |
1319 | 1318 | // Rewrite the order columns to the shared aliases |
1320 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1319 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1321 | 1320 | } |
1322 | 1321 | |
1323 | 1322 | $columns = array_unique( $columns ); |
1324 | 1323 | |
1325 | 1324 | // Add the columns to every UNION |
1326 | 1325 | foreach ( $unions_sql as $union_sql ) { |
1327 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1328 | - $unions []= implode( ' ', $union_sql ); |
|
1326 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1327 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1329 | 1328 | } |
1330 | 1329 | |
1331 | 1330 | // Add the columns to the main SELECT, but only grab the entry id column |
1332 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1333 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1331 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1332 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1334 | 1333 | |
1335 | 1334 | return $sql; |
1336 | 1335 | } ); |
@@ -1375,20 +1374,20 @@ discard block |
||
1375 | 1374 | } ); |
1376 | 1375 | } else { |
1377 | 1376 | $entries = $this->form->entries |
1378 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1377 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1379 | 1378 | ->offset( $this->settings->get( 'offset' ) ) |
1380 | - ->limit( $parameters['paging']['page_size'] ) |
|
1379 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1381 | 1380 | ->page( $page ); |
1382 | 1381 | |
1383 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1382 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1384 | 1383 | // Pluck off multisort arrays |
1385 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1384 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1386 | 1385 | } |
1387 | 1386 | |
1388 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1387 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1389 | 1388 | $field = new \GV\Field(); |
1390 | - $field->ID = $parameters['sorting']['key']; |
|
1391 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1389 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1390 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1392 | 1391 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1393 | 1392 | } |
1394 | 1393 | } |
@@ -1472,7 +1471,7 @@ discard block |
||
1472 | 1471 | $allowed = $headers = array(); |
1473 | 1472 | |
1474 | 1473 | foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
1475 | - $allowed[] = $field; |
|
1474 | + $allowed[ ] = $field; |
|
1476 | 1475 | } |
1477 | 1476 | |
1478 | 1477 | $renderer = new Field_Renderer(); |
@@ -1494,17 +1493,17 @@ discard block |
||
1494 | 1493 | } ); |
1495 | 1494 | |
1496 | 1495 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1497 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1496 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1498 | 1497 | } |
1499 | 1498 | |
1500 | 1499 | foreach ( $allowed as $field ) { |
1501 | 1500 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1502 | 1501 | |
1503 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1502 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1504 | 1503 | |
1505 | 1504 | if ( ! $headers_done ) { |
1506 | 1505 | $label = $field->get_label( $view, $source, $entry ); |
1507 | - $headers[] = $label ? $label : $field->ID; |
|
1506 | + $headers[ ] = $label ? $label : $field->ID; |
|
1508 | 1507 | } |
1509 | 1508 | } |
1510 | 1509 |