@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * Constructor. Add filters to modify output. |
|
23 | - * |
|
22 | + * Constructor. Add filters to modify output. |
|
23 | + * |
|
24 | 24 | * @since 2.0.4 |
25 | 25 | * |
26 | 26 | * @param View $view |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct( View $view, Entry_Collection $entries, Request $request ) { |
31 | 31 | |
32 | - add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
32 | + add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
33 | 33 | |
34 | 34 | parent::__construct( $view, $entries, $request ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Add sorting links to HTML columns that support sorting |
|
39 | - * |
|
40 | - * @since 2.0.4 |
|
41 | - * @since 2.0.5 Made static |
|
42 | - * |
|
43 | - * @static |
|
44 | - * |
|
38 | + * Add sorting links to HTML columns that support sorting |
|
39 | + * |
|
40 | + * @since 2.0.4 |
|
41 | + * @since 2.0.5 Made static |
|
42 | + * |
|
43 | + * @static |
|
44 | + * |
|
45 | 45 | * @param string $column_label Label for the table column |
46 | 46 | * @param \GV\Template_Context $context |
47 | 47 | * |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $sort_columns = $context->view->settings->get( 'sort_columns' ); |
53 | 53 | |
54 | 54 | if ( empty( $sort_columns ) ) { |
55 | - return $column_label; |
|
55 | + return $column_label; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ( ! \GravityView_frontend::getInstance()->is_field_sortable( $context->field->ID, $context->view->form->form ) ) { |
@@ -102,22 +102,22 @@ discard block |
||
102 | 102 | // If we are already sorting by the current field... |
103 | 103 | if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
104 | 104 | |
105 | - switch( $sorting['direction'] ) { |
|
106 | - // No sort |
|
107 | - case '': |
|
108 | - $sort_args[1] = 'asc'; |
|
109 | - $class .= ' gv-icon-caret-up-down'; |
|
110 | - break; |
|
111 | - case 'desc': |
|
112 | - $sort_args[1] = ''; |
|
113 | - $class .= ' gv-icon-sort-asc'; |
|
114 | - break; |
|
115 | - case 'asc': |
|
116 | - default: |
|
117 | - $sort_args[1] = 'desc'; |
|
118 | - $class .= ' gv-icon-sort-desc'; |
|
119 | - break; |
|
120 | - } |
|
105 | + switch( $sorting['direction'] ) { |
|
106 | + // No sort |
|
107 | + case '': |
|
108 | + $sort_args[1] = 'asc'; |
|
109 | + $class .= ' gv-icon-caret-up-down'; |
|
110 | + break; |
|
111 | + case 'desc': |
|
112 | + $sort_args[1] = ''; |
|
113 | + $class .= ' gv-icon-sort-asc'; |
|
114 | + break; |
|
115 | + case 'asc': |
|
116 | + default: |
|
117 | + $sort_args[1] = 'desc'; |
|
118 | + $class .= ' gv-icon-sort-desc'; |
|
119 | + break; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | } else { |
123 | 123 | $class .= ' gv-icon-caret-up-down'; |
@@ -127,56 +127,56 @@ discard block |
||
127 | 127 | $url = remove_query_arg( 'sort', $url ); |
128 | 128 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field->ID ); |
129 | 129 | |
130 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
130 | + $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
131 | 131 | |
132 | 132 | return '<a href="'. esc_url_raw( $url ) .'" data-multisort-href="'. esc_url_raw( $multisort_url ) . '" class="'. $class .'" ></a> '. $column_label; |
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Get the multi-sort URL used in the sorting links |
|
137 | - * |
|
138 | - * @todo Consider moving to Utils? |
|
139 | - * |
|
140 | - * @since 2.3 |
|
141 | - * |
|
142 | - * @see add_columns_sort_links |
|
136 | + * Get the multi-sort URL used in the sorting links |
|
137 | + * |
|
138 | + * @todo Consider moving to Utils? |
|
139 | + * |
|
140 | + * @since 2.3 |
|
141 | + * |
|
142 | + * @see add_columns_sort_links |
|
143 | 143 | * @param string $url Single-sort URL |
144 | 144 | * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
145 | - * @param string|int $field_id ID of the current field being displayed |
|
146 | - * |
|
147 | - * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
145 | + * @param string|int $field_id ID of the current field being displayed |
|
146 | + * |
|
147 | + * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
148 | 148 | */ |
149 | 149 | static public function _get_multisort_url( $url, $sort_args, $field_id ) { |
150 | 150 | |
151 | 151 | $sorts = Utils::_GET( 'sort' ); |
152 | 152 | |
153 | 153 | if ( ! is_array( $sorts ) ) { |
154 | - return $url; |
|
154 | + return $url; |
|
155 | 155 | } |
156 | 156 | |
157 | - $multisort_url = $url; |
|
157 | + $multisort_url = $url; |
|
158 | 158 | |
159 | 159 | // If the field has already been sorted by, add the field to the URL |
160 | - if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
161 | - if ( count( $keys ) ) { |
|
162 | - $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
163 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
164 | - } else { |
|
165 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
166 | - } |
|
167 | - } |
|
168 | - // Otherwise, we are just updating the sort order |
|
169 | - else { |
|
170 | - |
|
171 | - // Pass empty value to unset |
|
172 | - if( '' === $sort_args[1] ) { |
|
173 | - unset( $sorts[ $field_id ] ); |
|
174 | - } else { |
|
175 | - $sorts[ $field_id ] = $sort_args[1]; |
|
176 | - } |
|
177 | - |
|
178 | - $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
179 | - } |
|
160 | + if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
161 | + if ( count( $keys ) ) { |
|
162 | + $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
163 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
164 | + } else { |
|
165 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
166 | + } |
|
167 | + } |
|
168 | + // Otherwise, we are just updating the sort order |
|
169 | + else { |
|
170 | + |
|
171 | + // Pass empty value to unset |
|
172 | + if( '' === $sort_args[1] ) { |
|
173 | + unset( $sorts[ $field_id ] ); |
|
174 | + } else { |
|
175 | + $sorts[ $field_id ] = $sort_args[1]; |
|
176 | + } |
|
177 | + |
|
178 | + $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
179 | + } |
|
180 | 180 | |
181 | 181 | return $multisort_url; |
182 | 182 | } |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * Returns the label for a column, with support for all deprecated filters |
|
210 | - * |
|
211 | - * @since 2.1 |
|
212 | - * |
|
209 | + * Returns the label for a column, with support for all deprecated filters |
|
210 | + * |
|
211 | + * @since 2.1 |
|
212 | + * |
|
213 | 213 | * @param \GV\Field $field |
214 | 214 | * @param \GV\Template_Context $context |
215 | 215 | */ |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context ); |
233 | 233 | |
234 | 234 | return $column_label; |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Output the entry row. |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | */ |
302 | 302 | do_action( 'gravityview/template/table/cells/before', $context ); |
303 | 303 | |
304 | - /** |
|
305 | - * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
306 | - * @since 1.0.7 |
|
304 | + /** |
|
305 | + * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
306 | + * @since 1.0.7 |
|
307 | 307 | * @param \GravityView_View $this Current GravityView_View object |
308 | 308 | * @deprecated Use `gravityview/template/table/cells/before` |
309 | - */ |
|
310 | - do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
309 | + */ |
|
310 | + do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
311 | 311 | |
312 | - foreach ( $fields->all() as $field ) { |
|
312 | + foreach ( $fields->all() as $field ) { |
|
313 | 313 | if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
314 | 314 | if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
315 | 315 | $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | */ |
330 | 330 | do_action( 'gravityview/template/table/cells/after', $context ); |
331 | 331 | |
332 | - /** |
|
333 | - * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
334 | - * @since 1.0.7 |
|
332 | + /** |
|
333 | + * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
334 | + * @since 1.0.7 |
|
335 | 335 | * @param \GravityView_View $this Current GravityView_View object |
336 | 336 | * @deprecated Use `gravityview/template/table/cells/after` |
337 | - */ |
|
338 | - do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
337 | + */ |
|
338 | + do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
339 | 339 | |
340 | 340 | ?> |
341 | 341 | </tr> |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | 'value' => $value, |
377 | 377 | 'hide_empty' => false, |
378 | 378 | 'zone_id' => 'directory_table-columns', |
379 | - 'label' => self::get_field_column_label( $field, $context ), |
|
379 | + 'label' => self::get_field_column_label( $field, $context ), |
|
380 | 380 | 'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>', |
381 | - 'form' => $form, |
|
381 | + 'form' => $form, |
|
382 | 382 | ); |
383 | 383 | |
384 | 384 | /** Output. */ |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | do_action( 'gravityview/template/table/body/before', $context ); |
404 | 404 | |
405 | 405 | /** |
406 | - * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
407 | - * @deprecated Use `gravityview/template/table/body/before` |
|
408 | - * @since 1.0.7 |
|
409 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
410 | - */ |
|
406 | + * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
407 | + * @deprecated Use `gravityview/template/table/body/before` |
|
408 | + * @since 1.0.7 |
|
409 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
410 | + */ |
|
411 | 411 | do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ ); |
412 | 412 | } |
413 | 413 | |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | do_action( 'gravityview/template/table/body/after', $context ); |
430 | 430 | |
431 | 431 | /** |
432 | - * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
433 | - * @deprecated Use `gravityview/template/table/body/after` |
|
434 | - * @since 1.0.7 |
|
435 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
436 | - */ |
|
432 | + * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
433 | + * @deprecated Use `gravityview/template/table/body/after` |
|
434 | + * @since 1.0.7 |
|
435 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
436 | + */ |
|
437 | 437 | do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ ); |
438 | 438 | } |
439 | 439 |