Completed
Pull Request — develop (#1487)
by Gennady
07:21
created
future/includes/class-gv-collection-field.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
 	 * @api
112 112
 	 * @since
113 113
 	 *
114
-	 * @param $view \GV\View The view!
114
+	 * @param View $view \GV\View The view!
115 115
 	 *
116 116
 	 * @return \GV\Field_Collection A filtered collection of \GV\Fields, filtered by visibility.
117 117
 	 */
Please login to merge, or discard this patch.
future/includes/class-gv-template-view-table.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      *
159 159
      * @see add_columns_sort_links
160 160
 	 * @param string $url Single-sort URL
161
-	 * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format
161
+	 * @param string[] $sort_args Single sorting for rules, in [ field_id, dir ] format
162 162
      * @param \GV\Field $field The current field
163 163
      *
164 164
      * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * Output a field cell.
370 370
 	 *
371 371
 	 * @param \GV\Field $field The field to be ouput.
372
-	 * @param \GV\Field $entry The entry this field is for.
372
+	 * @param Entry $entry The entry this field is for.
373 373
 	 *
374 374
 	 * @return void
375 375
 	 */
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 			if ( is_array( $sorts ) ) {
76 76
 				foreach ( (array)$sorts as $key => $direction ) {
77 77
 					if ( $key == $field_id ) {
78
-						$sorting['key'] = $field_id;
79
-						$sorting['direction'] = strtolower( $direction );
78
+						$sorting[ 'key' ] = $field_id;
79
+						$sorting[ 'direction' ] = strtolower( $direction );
80 80
 						break;
81 81
 					}
82 82
 				}
83 83
 			} else {
84 84
 				if ( $sorts == $field_id ) {
85
-					$sorting['key'] = $context_id;
86
-					$sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) );
85
+					$sorting[ 'key' ] = $context_id;
86
+					$sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) );
87 87
 				}
88 88
 			}
89 89
 		} else {
90 90
 			foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) {
91 91
 				if ( $sort_field == $field_id ) {
92
-					$sorting['key'] = $sort_field;
93
-					$sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) );
92
+					$sorting[ 'key' ] = $sort_field;
93
+					$sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) );
94 94
 					break; // Only get the first sort
95 95
 				}
96 96
 			}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 		);
110 110
 
111 111
 		// If we are already sorting by the current field...
112
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
112
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
113 113
 
114
-		    switch( $sorting['direction'] ) {
114
+		    switch ( $sorting[ 'direction' ] ) {
115 115
 		        // No sort
116 116
                 case '':
117
-	                $sort_args[1] = 'asc';
117
+	                $sort_args[ 1 ] = 'asc';
118 118
 	                $class .= ' gv-icon-caret-up-down';
119 119
                     break;
120 120
                 case 'desc':
121
-	                $sort_args[1] = '';
121
+	                $sort_args[ 1 ] = '';
122 122
 	                $class .= ' gv-icon-sort-asc';
123 123
 	                break;
124 124
                 case 'asc':
125 125
                 default:
126
-                    $sort_args[1] = 'desc';
126
+                    $sort_args[ 1 ] = 'desc';
127 127
                     $class .= ' gv-icon-sort-desc';
128 128
                     break;
129 129
             }
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 		$url = remove_query_arg( 'sort', $url );
137 137
 		$multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field );
138 138
 
139
-    	$url = add_query_arg( $sort_args[0], $sort_args[1], $url );
139
+    	$url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $url );
140 140
 
141
-		$return = '<a href="'. esc_url_raw( $url ) .'"';
141
+		$return = '<a href="' . esc_url_raw( $url ) . '"';
142 142
 
143 143
 		if ( ! empty( $multisort_url ) ) {
144
-			$return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"';
144
+			$return .= ' data-multisort-href="' . esc_url_raw( $multisort_url ) . '"';
145 145
 		}
146 146
 
147
-		$return .= ' class="'. $class .'" ></a>&nbsp;'. $column_label;
147
+		$return .= ' class="' . $class . '" ></a>&nbsp;' . $column_label;
148 148
 
149 149
 		return $return;
150 150
 	}
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
         if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
184 184
             if ( count( $keys ) ) {
185 185
                 $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url );
186
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
186
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
187 187
             } else {
188
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
188
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
189 189
             }
190 190
         }
191 191
         // Otherwise, we are just updating the sort order
192 192
         else {
193 193
 
194 194
             // Pass empty value to unset
195
-            if( '' === $sort_args[1] ) {
195
+            if ( '' === $sort_args[ 1 ] ) {
196 196
 	            unset( $sorts[ $field_id ] );
197 197
             } else {
198
-	            $sorts[ $field_id ] = $sort_args[1];
198
+	            $sorts[ $field_id ] = $sort_args[ 1 ];
199 199
             }
200 200
 
201 201
             $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
                 do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
334 334
 
335 335
                 foreach ( $fields->all() as $field ) {
336
-					if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) {
337
-						if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) {
338
-							$field = $this->view->unions[ $entry['form_id'] ][ $field->ID ];
336
+					if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) {
337
+						if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) {
338
+							$field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ];
339 339
 						} else {
340 340
 							if ( ! $field instanceof Internal_Field ) {
341 341
 								$field = Internal_Field::from_configuration( array( 'id' => 'custom' ) );
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 ( 'custom' === $context->field->type ) {
@@ -111,22 +111,22 @@  discard block
 block discarded – undo
111 111
 		// If we are already sorting by the current field...
112 112
 		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
113 113
 
114
-		    switch( $sorting['direction'] ) {
115
-		        // No sort
116
-                case '':
117
-	                $sort_args[1] = 'asc';
118
-	                $class .= ' gv-icon-caret-up-down';
119
-                    break;
120
-                case 'desc':
121
-	                $sort_args[1] = '';
122
-	                $class .= ' gv-icon-sort-asc';
123
-	                break;
124
-                case 'asc':
125
-                default:
126
-                    $sort_args[1] = 'desc';
127
-                    $class .= ' gv-icon-sort-desc';
128
-                    break;
129
-            }
114
+			switch( $sorting['direction'] ) {
115
+				// No sort
116
+				case '':
117
+					$sort_args[1] = 'asc';
118
+					$class .= ' gv-icon-caret-up-down';
119
+					break;
120
+				case 'desc':
121
+					$sort_args[1] = '';
122
+					$class .= ' gv-icon-sort-asc';
123
+					break;
124
+				case 'asc':
125
+				default:
126
+					$sort_args[1] = 'desc';
127
+					$class .= ' gv-icon-sort-desc';
128
+					break;
129
+			}
130 130
 
131 131
 		} else {
132 132
 			$class .= ' gv-icon-caret-up-down';
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$url = remove_query_arg( 'sort', $url );
137 137
 		$multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field );
138 138
 
139
-    	$url = add_query_arg( $sort_args[0], $sort_args[1], $url );
139
+		$url = add_query_arg( $sort_args[0], $sort_args[1], $url );
140 140
 
141 141
 		$return = '<a href="'. esc_url_raw( $url ) .'"';
142 142
 
@@ -150,28 +150,28 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	/**
153
-     * Get the multi-sort URL used in the sorting links
154
-     *
155
-     * @todo Consider moving to Utils?
156
-     *
157
-     * @since 2.3
158
-     *
159
-     * @see add_columns_sort_links
153
+	 * Get the multi-sort URL used in the sorting links
154
+	 *
155
+	 * @todo Consider moving to Utils?
156
+	 *
157
+	 * @since 2.3
158
+	 *
159
+	 * @see add_columns_sort_links
160 160
 	 * @param string $url Single-sort URL
161 161
 	 * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format
162
-     * @param \GV\Field $field The current field
163
-     *
164
-     * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url
162
+	 * @param \GV\Field $field The current field
163
+	 *
164
+	 * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url
165 165
 	 */
166 166
 	static public function _get_multisort_url( $url, $sort_args, $field ) {
167 167
 
168 168
 		$sorts = Utils::_GET( 'sort' );
169 169
 
170 170
 		if ( ! is_array( $sorts ) ) {
171
-            return $url;
171
+			return $url;
172 172
 		}
173 173
 
174
-        $multisort_url = $url;
174
+		$multisort_url = $url;
175 175
 
176 176
 		if ( ! $field ) {
177 177
 			return $url;
@@ -184,26 +184,26 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		// If the field has already been sorted by, add the field to the URL
187
-        if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
188
-            if ( count( $keys ) ) {
189
-                $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url );
190
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
191
-            } else {
192
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
193
-            }
194
-        }
195
-        // Otherwise, we are just updating the sort order
196
-        else {
197
-
198
-            // Pass empty value to unset
199
-            if( '' === $sort_args[1] ) {
200
-	            unset( $sorts[ $field_id ] );
201
-            } else {
202
-	            $sorts[ $field_id ] = $sort_args[1];
203
-            }
204
-
205
-            $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
206
-        }
187
+		if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
188
+			if ( count( $keys ) ) {
189
+				$multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url );
190
+				$multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
191
+			} else {
192
+				$multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
193
+			}
194
+		}
195
+		// Otherwise, we are just updating the sort order
196
+		else {
197
+
198
+			// Pass empty value to unset
199
+			if( '' === $sort_args[1] ) {
200
+				unset( $sorts[ $field_id ] );
201
+			} else {
202
+				$sorts[ $field_id ] = $sort_args[1];
203
+			}
204
+
205
+			$multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
206
+		}
207 207
 
208 208
 		return $multisort_url;
209 209
 	}
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 
235 235
 	/**
236
-     * Returns the label for a column, with support for all deprecated filters
237
-     *
238
-     * @since 2.1
239
-     *
236
+	 * Returns the label for a column, with support for all deprecated filters
237
+	 *
238
+	 * @since 2.1
239
+	 *
240 240
 	 * @param \GV\Field $field
241 241
 	 * @param \GV\Template_Context $context
242 242
 	 */
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context );
260 260
 
261 261
 		return $column_label;
262
-    }
262
+	}
263 263
 
264 264
 	/**
265 265
 	 * Output the entry row.
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
 				 */
329 329
 				do_action( 'gravityview/template/table/cells/before', $context );
330 330
 
331
-                /**
332
-                 * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
333
-                 * @since 1.0.7
331
+				/**
332
+				 * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
333
+				 * @since 1.0.7
334 334
 				 * @param \GravityView_View $this Current GravityView_View object
335 335
 				 * @deprecated Use `gravityview/template/table/cells/before`
336
-                 */
337
-                do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
336
+				 */
337
+				do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
338 338
 
339
-                foreach ( $fields->all() as $field ) {
339
+				foreach ( $fields->all() as $field ) {
340 340
 					if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) {
341 341
 						if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) {
342 342
 							$field = $this->view->unions[ $entry['form_id'] ][ $field->ID ];
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
 				 */
357 357
 				do_action( 'gravityview/template/table/cells/after', $context );
358 358
 
359
-                /**
360
-                 * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
361
-                 * @since 1.0.7
359
+				/**
360
+				 * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
361
+				 * @since 1.0.7
362 362
 				 * @param \GravityView_View $this Current GravityView_View object
363 363
 				 * @deprecated Use `gravityview/template/table/cells/after`
364
-                 */
365
-                do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() );
364
+				 */
365
+				do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() );
366 366
 
367 367
 				?>
368 368
 			</tr>
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 			'value' => $value,
411 411
 			'hide_empty' => false,
412 412
 			'zone_id' => 'directory_table-columns',
413
-            'label' => self::get_field_column_label( $field, $context ),
413
+			'label' => self::get_field_column_label( $field, $context ),
414 414
 			'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>',
415
-            'form' => $form,
415
+			'form' => $form,
416 416
 		);
417 417
 
418 418
 		/** Output. */
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 		do_action( 'gravityview/template/table/body/before', $context );
438 438
 
439 439
 		/**
440
-		* @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows.
441
-		* @deprecated Use `gravityview/template/table/body/before`
442
-		* @since 1.0.7
443
-		* @param \GravityView_View $gravityview_view Current GravityView_View object.
444
-		*/
440
+		 * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows.
441
+		 * @deprecated Use `gravityview/template/table/body/before`
442
+		 * @since 1.0.7
443
+		 * @param \GravityView_View $gravityview_view Current GravityView_View object.
444
+		 */
445 445
 		do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ );
446 446
 	}
447 447
 
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 		do_action( 'gravityview/template/table/body/after', $context );
464 464
 
465 465
 		/**
466
-		* @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows.
467
-		* @deprecated Use `gravityview/template/table/body/after`
468
-		* @since 1.0.7
469
-		* @param \GravityView_View $gravityview_view Current GravityView_View object.
470
-		*/
466
+		 * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows.
467
+		 * @deprecated Use `gravityview/template/table/body/after`
468
+		 * @since 1.0.7
469
+		 * @param \GravityView_View $gravityview_view Current GravityView_View object.
470
+		 */
471 471
 		do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ );
472 472
 	}
473 473
 
Please login to merge, or discard this patch.