Completed
Push — develop ( d53d64...92f117 )
by Zack
18:11 queued 14:25
created
future/includes/class-gv-template-view-table.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
      *
142 142
      * @see add_columns_sort_links
143 143
 	 * @param string $url Single-sort URL
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
144
+	 * @param string[] $sort_args Single sorting for rules, in [ field_id, dir ] format
145
+     * @param string $field_id ID of the current field being displayed
146 146
      *
147 147
      * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url
148 148
 	 */
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 * Output a field cell.
347 347
 	 *
348 348
 	 * @param \GV\Field $field The field to be ouput.
349
-	 * @param \GV\Field $entry The entry this field is for.
349
+	 * @param Entry $entry The entry this field is for.
350 350
 	 *
351 351
 	 * @return void
352 352
 	 */
Please login to merge, or discard this patch.
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>&nbsp;'. $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 			if ( is_array( $sorts ) ) {
70 70
 				foreach ( (array)$sorts as $key => $direction ) {
71 71
 					if ( $key == $context->field->ID ) {
72
-						$sorting['key'] = $context->field->ID;
73
-						$sorting['direction'] = strtolower( $direction );
72
+						$sorting[ 'key' ] = $context->field->ID;
73
+						$sorting[ 'direction' ] = strtolower( $direction );
74 74
 						break;
75 75
 					}
76 76
 				}
77 77
 			} else {
78 78
 				if ( $sorts == $context->field->ID ) {
79
-					$sorting['key'] = $context->field->ID;
80
-					$sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) );
79
+					$sorting[ 'key' ] = $context->field->ID;
80
+					$sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) );
81 81
 				}
82 82
 			}
83 83
 		} else {
84 84
 			foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) {
85 85
 				if ( $sort_field == $context->field->ID ) {
86
-					$sorting['key'] = $sort_field;
87
-					$sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) );
86
+					$sorting[ 'key' ] = $sort_field;
87
+					$sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) );
88 88
 					break; // Only get the first sort
89 89
 				}
90 90
 			}
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 
102 102
 		// If we are already sorting by the current field...
103
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
103
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
104 104
 
105
-		    switch( $sorting['direction'] ) {
105
+		    switch ( $sorting[ 'direction' ] ) {
106 106
 		        // No sort
107 107
                 case '':
108
-	                $sort_args[1] = 'asc';
108
+	                $sort_args[ 1 ] = 'asc';
109 109
 	                $class .= ' gv-icon-caret-up-down';
110 110
                     break;
111 111
                 case 'desc':
112
-	                $sort_args[1] = '';
112
+	                $sort_args[ 1 ] = '';
113 113
 	                $class .= ' gv-icon-sort-asc';
114 114
 	                break;
115 115
                 case 'asc':
116 116
                 default:
117
-                    $sort_args[1] = 'desc';
117
+                    $sort_args[ 1 ] = 'desc';
118 118
                     $class .= ' gv-icon-sort-desc';
119 119
                     break;
120 120
             }
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
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
-		return '<a href="'. esc_url_raw( $url ) .'" data-multisort-href="'. esc_url_raw( $multisort_url ) . '" class="'. $class .'" ></a>&nbsp;'. $column_label;
132
+		return '<a href="' . esc_url_raw( $url ) . '" data-multisort-href="' . esc_url_raw( $multisort_url ) . '" class="' . $class . '" ></a>&nbsp;' . $column_label;
133 133
 	}
134 134
 
135 135
 	/**
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
         if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
161 161
             if ( count( $keys ) ) {
162 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 );
163
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
164 164
             } else {
165
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
165
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
166 166
             }
167 167
         }
168 168
         // Otherwise, we are just updating the sort order
169 169
         else {
170 170
 
171 171
             // Pass empty value to unset
172
-            if( '' === $sort_args[1] ) {
172
+            if ( '' === $sort_args[ 1 ] ) {
173 173
 	            unset( $sorts[ $field_id ] );
174 174
             } else {
175
-	            $sorts[ $field_id ] = $sort_args[1];
175
+	            $sorts[ $field_id ] = $sort_args[ 1 ];
176 176
             }
177 177
 
178 178
             $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
                 do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
311 311
 
312 312
                 foreach ( $fields->all() as $field ) {
313
-					if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) {
314
-						if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) {
315
-							$field = $this->view->unions[ $entry['form_id'] ][ $field->ID ];
313
+					if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) {
314
+						if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) {
315
+							$field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ];
316 316
 						} else {
317 317
 							if ( ! $field instanceof Internal_Field ) {
318 318
 								$field = Internal_Field::from_configuration( array( 'id' => 'custom' ) );
Please login to merge, or discard this patch.