@@ -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 | /** |
@@ -229,12 +229,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | |
@@ -937,11 +937,11 @@ discard block |
||
937 | 937 | * Remove multiple sorting before calling legacy filters. |
938 | 938 | * This allows us to fake it till we make it. |
939 | 939 | */ |
940 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
940 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
941 | 941 | $has_multisort = true; |
942 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
943 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
944 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
942 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
943 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
944 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
945 | 945 | } |
946 | 946 | } |
947 | 947 | |
@@ -950,31 +950,30 @@ discard block |
||
950 | 950 | */ |
951 | 951 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
952 | 952 | |
953 | - $parameters['context_view_id'] = $this->ID; |
|
953 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
954 | 954 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
955 | 955 | |
956 | 956 | if ( ! is_array( $parameters ) ) { |
957 | 957 | $parameters = array(); |
958 | 958 | } |
959 | 959 | |
960 | - if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
961 | - $parameters['search_criteria'] = array(); |
|
960 | + if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
961 | + $parameters[ 'search_criteria' ] = array(); |
|
962 | 962 | } |
963 | 963 | |
964 | - if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
965 | - $parameters['search_criteria']['field_filters'] = array(); |
|
964 | + if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
965 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | if ( $request instanceof REST\Request ) { |
969 | 969 | $atts = $this->settings->as_atts(); |
970 | 970 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
971 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
971 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
972 | 972 | ) ); |
973 | - $parameters['paging'] = $paging_parameters['paging']; |
|
973 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
974 | 974 | } |
975 | 975 | |
976 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
977 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
976 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
978 | 977 | |
979 | 978 | /** |
980 | 979 | * Cleanup duplicate field_filter parameters to simplify the query. |
@@ -982,14 +981,14 @@ discard block |
||
982 | 981 | $unique_field_filters = array(); |
983 | 982 | foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
984 | 983 | if ( 'mode' === $key ) { |
985 | - $unique_field_filters['mode'] = $filter; |
|
984 | + $unique_field_filters[ 'mode' ] = $filter; |
|
986 | 985 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
987 | - $unique_field_filters[] = $filter; |
|
986 | + $unique_field_filters[ ] = $filter; |
|
988 | 987 | } |
989 | 988 | } |
990 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
989 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
991 | 990 | |
992 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
991 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
993 | 992 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
994 | 993 | } |
995 | 994 | |
@@ -998,7 +997,7 @@ discard block |
||
998 | 997 | $query_class = $this->get_query_class(); |
999 | 998 | |
1000 | 999 | /** @type \GF_Query $query */ |
1001 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
1000 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1002 | 1001 | |
1003 | 1002 | /** |
1004 | 1003 | * Apply multisort. |
@@ -1009,15 +1008,15 @@ discard block |
||
1009 | 1008 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
1010 | 1009 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
1011 | 1010 | |
1012 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
1011 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1013 | 1012 | |
1014 | - if( $has_sort_query_param ) { |
|
1015 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
1013 | + if ( $has_sort_query_param ) { |
|
1014 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1016 | 1015 | } |
1017 | 1016 | |
1018 | 1017 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
1019 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1020 | - $sort_directions = array_values( $_GET['sort'] ); |
|
1018 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
1019 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1021 | 1020 | } else { |
1022 | 1021 | $sort_field_ids = $view_setting_sort_field_ids; |
1023 | 1022 | $sort_directions = $view_setting_sort_directions; |
@@ -1025,7 +1024,7 @@ discard block |
||
1025 | 1024 | |
1026 | 1025 | $skip_first = false; |
1027 | 1026 | |
1028 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
1027 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1029 | 1028 | |
1030 | 1029 | if ( ! $skip_first && ! $has_sort_query_param ) { |
1031 | 1030 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1055,15 +1054,15 @@ discard block |
||
1055 | 1054 | |
1056 | 1055 | $merged_time = false; |
1057 | 1056 | |
1058 | - foreach ( $q['order'] as $oid => $order ) { |
|
1059 | - if ( $order[0] instanceof \GF_Query_Column ) { |
|
1060 | - $column = $order[0]; |
|
1061 | - } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1062 | - if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
1057 | + foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1058 | + if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
1059 | + $column = $order[ 0 ]; |
|
1060 | + } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
1061 | + if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1063 | 1062 | $orders[ $oid ] = $order; |
1064 | 1063 | continue; // Need something that resembles a single sort |
1065 | 1064 | } |
1066 | - $column = $order[0]->columns[0]; |
|
1065 | + $column = $order[ 0 ]->columns[ 0 ]; |
|
1067 | 1066 | } |
1068 | 1067 | |
1069 | 1068 | if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
@@ -1077,7 +1076,7 @@ discard block |
||
1077 | 1076 | |
1078 | 1077 | $orders[ $oid ] = array( |
1079 | 1078 | new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
1080 | - $order[1] // Mock it! |
|
1079 | + $order[ 1 ] // Mock it! |
|
1081 | 1080 | ); |
1082 | 1081 | |
1083 | 1082 | $merged_time = true; |
@@ -1088,15 +1087,15 @@ discard block |
||
1088 | 1087 | * ORDER again. |
1089 | 1088 | */ |
1090 | 1089 | if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
1091 | - $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1090 | + $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1092 | 1091 | } |
1093 | 1092 | } |
1094 | 1093 | |
1095 | 1094 | return $sql; |
1096 | 1095 | } ); |
1097 | 1096 | |
1098 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1099 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1097 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1098 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1100 | 1099 | |
1101 | 1100 | /** |
1102 | 1101 | * Any joins? |
@@ -1119,7 +1118,7 @@ discard block |
||
1119 | 1118 | |
1120 | 1119 | $query_parameters = $query->_introspect(); |
1121 | 1120 | |
1122 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1121 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1123 | 1122 | } |
1124 | 1123 | |
1125 | 1124 | /** |
@@ -1153,7 +1152,7 @@ discard block |
||
1153 | 1152 | } |
1154 | 1153 | |
1155 | 1154 | $q = $query->_introspect(); |
1156 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1155 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1157 | 1156 | |
1158 | 1157 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1159 | 1158 | |
@@ -1178,7 +1177,7 @@ discard block |
||
1178 | 1177 | |
1179 | 1178 | $query_parameters = $query->_introspect(); |
1180 | 1179 | |
1181 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1180 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1182 | 1181 | } |
1183 | 1182 | } |
1184 | 1183 | |
@@ -1202,7 +1201,7 @@ discard block |
||
1202 | 1201 | $conditions = array(); |
1203 | 1202 | |
1204 | 1203 | foreach ( $condition->expressions as $_condition ) { |
1205 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1204 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1206 | 1205 | } |
1207 | 1206 | |
1208 | 1207 | return call_user_func_array( |
@@ -1231,10 +1230,10 @@ discard block |
||
1231 | 1230 | $q = new $query_class( $form_id ); |
1232 | 1231 | |
1233 | 1232 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1234 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1233 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1235 | 1234 | |
1236 | 1235 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1237 | - foreach ( $query_parameters['order'] as $order ) { |
|
1236 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1238 | 1237 | list( $column, $_order ) = $order; |
1239 | 1238 | |
1240 | 1239 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1248,15 +1247,15 @@ discard block |
||
1248 | 1247 | |
1249 | 1248 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1250 | 1249 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1251 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1250 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1252 | 1251 | |
1253 | 1252 | // Record the SQL |
1254 | - $unions_sql[] = array( |
|
1253 | + $unions_sql[ ] = array( |
|
1255 | 1254 | // Remove columns, we'll rebuild them |
1256 | 1255 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1257 | - 'from' => $sql['from'], |
|
1258 | - 'join' => $sql['join'], |
|
1259 | - 'where' => $sql['where'], |
|
1256 | + 'from' => $sql[ 'from' ], |
|
1257 | + 'join' => $sql[ 'join' ], |
|
1258 | + 'where' => $sql[ 'where' ], |
|
1260 | 1259 | // Remove order and limit |
1261 | 1260 | ); |
1262 | 1261 | |
@@ -1273,11 +1272,11 @@ discard block |
||
1273 | 1272 | |
1274 | 1273 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1275 | 1274 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1276 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1275 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1277 | 1276 | |
1278 | 1277 | // Remove columns, we'll rebuild them |
1279 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1280 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1278 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1279 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1281 | 1280 | |
1282 | 1281 | $unions = array(); |
1283 | 1282 | |
@@ -1288,30 +1287,30 @@ discard block |
||
1288 | 1287 | }; |
1289 | 1288 | |
1290 | 1289 | // Add all the order columns into the selects, so we can order by the whole union group |
1291 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1290 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1292 | 1291 | |
1293 | 1292 | $columns = array( |
1294 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1293 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1295 | 1294 | ); |
1296 | 1295 | |
1297 | 1296 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1298 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1297 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1299 | 1298 | |
1300 | 1299 | // Rewrite the order columns to the shared aliases |
1301 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1300 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1302 | 1301 | } |
1303 | 1302 | |
1304 | 1303 | $columns = array_unique( $columns ); |
1305 | 1304 | |
1306 | 1305 | // Add the columns to every UNION |
1307 | 1306 | foreach ( $unions_sql as $union_sql ) { |
1308 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1309 | - $unions []= implode( ' ', $union_sql ); |
|
1307 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1308 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1310 | 1309 | } |
1311 | 1310 | |
1312 | 1311 | // Add the columns to the main SELECT, but only grab the entry id column |
1313 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1314 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1312 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1313 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1315 | 1314 | |
1316 | 1315 | return $sql; |
1317 | 1316 | } ); |
@@ -1356,20 +1355,20 @@ discard block |
||
1356 | 1355 | } ); |
1357 | 1356 | } else { |
1358 | 1357 | $entries = $this->form->entries |
1359 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1358 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1360 | 1359 | ->offset( $this->settings->get( 'offset' ) ) |
1361 | - ->limit( $parameters['paging']['page_size'] ) |
|
1360 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1362 | 1361 | ->page( $page ); |
1363 | 1362 | |
1364 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1363 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1365 | 1364 | // Pluck off multisort arrays |
1366 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1365 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1367 | 1366 | } |
1368 | 1367 | |
1369 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1368 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1370 | 1369 | $field = new \GV\Field(); |
1371 | - $field->ID = $parameters['sorting']['key']; |
|
1372 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1370 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1371 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1373 | 1372 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1374 | 1373 | } |
1375 | 1374 | } |
@@ -1454,7 +1453,7 @@ discard block |
||
1454 | 1453 | $allowed = $headers = array(); |
1455 | 1454 | |
1456 | 1455 | foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
1457 | - $allowed[] = $field; |
|
1456 | + $allowed[ ] = $field; |
|
1458 | 1457 | } |
1459 | 1458 | |
1460 | 1459 | $renderer = new Field_Renderer(); |
@@ -1476,17 +1475,17 @@ discard block |
||
1476 | 1475 | } ); |
1477 | 1476 | |
1478 | 1477 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1479 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1478 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1480 | 1479 | } |
1481 | 1480 | |
1482 | 1481 | foreach ( $allowed as $field ) { |
1483 | 1482 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1484 | 1483 | |
1485 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1484 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1486 | 1485 | |
1487 | 1486 | if ( ! $headers_done ) { |
1488 | 1487 | $label = $field->get_label( $view, $source, $entry ); |
1489 | - $headers[] = $label ? $label : $field->ID; |
|
1488 | + $headers[ ] = $label ? $label : $field->ID; |
|
1490 | 1489 | } |
1491 | 1490 | } |
1492 | 1491 |