Completed
Pull Request — develop (#1487)
by Gennady
07:54
created

View_Table_Template::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace GV;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6
	die();
7
}
8
9
/**
10
 * The View Table Template class .
11
 *
12
 * Renders a \GV\View and a \GV\Entry_Collection via a \GV\View_Renderer.
13
 */
14
class View_Table_Template extends View_Template {
15
	/**
16
	 * @var string The template slug to be loaded (like "table", "list")
17
	 */
18
	public static $slug = 'table';
19
20
21
	/**
22
     * Constructor. Add filters to modify output.
23
     *
24
	 * @since 2.0.4
25
	 *
26
	 * @param View $view
27
	 * @param Entry_Collection $entries
28
	 * @param Request $request
29
	 */
30 20
	public function __construct( View $view, Entry_Collection $entries, Request $request ) {
31
32 20
	    add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 );
33
34 20
		parent::__construct( $view, $entries, $request );
35 20
	}
36
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
     *
45
	 * @param string $column_label Label for the table column
46
	 * @param \GV\Template_Context $context
47
	 *
48
	 * @return string
49
	 */
50 30
	static public function add_columns_sort_links( $column_label, $context = null ) {
51
52 30
		$sort_columns = $context->view->settings->get( 'sort_columns' );
53
54 30
		if ( empty( $sort_columns ) ) {
55 29
            return $column_label;
56
		}
57
58 1
		if ( 'custom' === $context->field->type ) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<GV\Field>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
59
			$field_id = 'custom_' . $context->field->UID;
60
		} else {
61 1
			$field_id = $context->field->ID;
62
		}
63
64 1
		if ( ! \GravityView_frontend::getInstance()->is_field_sortable( $context->field->ID, $context->view->form->form ) ) {
65
			return $column_label;
66
		}
67
68 1
		$sorting = array();
69
70 1
		$directions = $context->view->settings->get( 'sort_direction' );
71
72 1
		$sorts = Utils::_GET( 'sort' );
73
74 1
		if ( $sorts ) {
75 1
			if ( is_array( $sorts ) ) {
76 1
				foreach ( (array)$sorts as $key => $direction ) {
77 1
					if ( $key == $field_id ) {
78 1
						$sorting['key'] = $field_id;
79 1
						$sorting['direction'] = strtolower( $direction );
80 1
						break;
81
					}
82
				}
83
			} else {
84
				if ( $sorts == $field_id ) {
85
					$sorting['key'] = $context_id;
0 ignored issues
show
Bug introduced by
The variable $context_id does not exist. Did you mean $context?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
86 1
					$sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) );
87
				}
88
			}
89
		} else {
90
			foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) {
91
				if ( $sort_field == $field_id ) {
92
					$sorting['key'] = $sort_field;
93
					$sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) );
94
					break; // Only get the first sort
95
				}
96
			}
97
		}
98
99 1
		$class = 'gv-sort';
100
101 1
		$sort_field_id = \GravityView_frontend::_override_sorting_id_by_field_type( $context->field->ID, $context->view->form->ID );
102 1
		if ( 'custom' === $context->field->type ) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<GV\Field>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
103
			$sort_field_id = 'custom_' . $context->field->UID;
104
		}
105
106
		$sort_args = array(
107 1
			sprintf( 'sort[%s]', $field_id ),
108 1
			'asc'
109
		);
110
111
		// If we are already sorting by the current field...
112 1
		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
113
114 1
		    switch( $sorting['direction'] ) {
115
		        // No sort
116 1
                case '':
117 1
	                $sort_args[1] = 'asc';
118 1
	                $class .= ' gv-icon-caret-up-down';
119 1
                    break;
120 1
                case 'desc':
121 1
	                $sort_args[1] = '';
122 1
	                $class .= ' gv-icon-sort-asc';
123 1
	                break;
124 1
                case 'asc':
125
                default:
126 1
                    $sort_args[1] = 'desc';
127 1
                    $class .= ' gv-icon-sort-desc';
128 1
                    break;
129
            }
130
131
		} else {
132
			$class .= ' gv-icon-caret-up-down';
133
		}
134
135 1
		$url = remove_query_arg( array( 'pagenum' ) );
136 1
		$url = remove_query_arg( 'sort', $url );
137 1
		$multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field );
138
139 1
    	$url = add_query_arg( $sort_args[0], $sort_args[1], $url );
140
141 1
		$return = '<a href="'. esc_url_raw( $url ) .'"';
142
143 1
		if ( ! empty( $multisort_url ) ) {
144 1
			$return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"';
145
		}
146
147 1
		$return .= ' class="'. $class .'" ></a>&nbsp;'. $column_label;
148
149 1
		return $return;
150
	}
151
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
160
	 * @param string $url Single-sort URL
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
165
	 */
166 2
	static public function _get_multisort_url( $url, $sort_args, $field ) {
167
168 2
		$sorts = Utils::_GET( 'sort' );
169
170 2
		if ( ! is_array( $sorts ) ) {
171 1
            return $url;
172
		}
173
174 2
        $multisort_url = $url;
175
176 2
		if ( ! $field ) {
177
			return $url;
178
		}
179
180 2
		if ( 'custom' === $field->type ) {
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<GV\Field>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
181
			$field_id = 'custom_' . $field->UID;
182
		} else {
183 2
			$field_id = $field->ID;
184
		}
185
186
		// If the field has already been sorted by, add the field to the URL
187 2
        if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
188 1
            if ( count( $keys ) ) {
189 1
                $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url );
190 1
                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
191
            } else {
192 1
                $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 2
            if( '' === $sort_args[1] ) {
200 1
	            unset( $sorts[ $field_id ] );
201
            } else {
202 2
	            $sorts[ $field_id ] = $sort_args[1];
203
            }
204
205 2
            $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
206
        }
207
208 2
		return $multisort_url;
209
	}
210
211
	/**
212
	 * Output the table column names.
213
	 *
214
	 * @return void
215
	 */
216 21
	public function the_columns() {
217 21
		$fields = $this->view->fields->by_position( 'directory_table-columns' );
218
219 21
		foreach ( $fields->by_visible( $this->view )->all() as $field ) {
220 21
			$context = Template_Context::from_template( $this, compact( 'field' ) );
221
222
			$args = array(
223 21
				'field' => is_numeric( $field->ID ) ? $field->as_configuration() : null,
224
				'hide_empty' => false,
225 21
				'zone_id' => 'directory_table-columns',
226 21
				'markup' => '<th id="{{ field_id }}" class="{{ class }}" style="{{width:style}}" data-label="{{label_value:data-label}}">{{label}}</th>',
227 21
				'label_markup' => '<span class="gv-field-label">{{ label }}</span>',
228 21
				'label' => self::get_field_column_label( $field, $context ),
229
			);
230
231 21
			echo \gravityview_field_output( $args, $context );
232
		}
233 21
	}
234
235
	/**
236
     * Returns the label for a column, with support for all deprecated filters
237
     *
238
     * @since 2.1
239
     *
240
	 * @param \GV\Field $field
241
	 * @param \GV\Template_Context $context
242
	 */
243 20
	protected static function get_field_column_label( $field, $context = null ) {
244
245 20
		$form = $field->form_id ? GF_Form::by_id( $field->form_id ) : $context->view->form;
0 ignored issues
show
Documentation introduced by
The property form_id does not exist on object<GV\Field>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
246
247
		/**
248
		 * @deprecated Here for back-compatibility.
249
		 */
250 20
		$column_label = apply_filters( 'gravityview_render_after_label', $field->get_label( $context->view, $form ), $field->as_configuration() );
251 20
		$column_label = apply_filters( 'gravityview/template/field_label', $column_label, $field->as_configuration(), ( $form && $form->form ) ? $form->form : null, null );
252
253
		/**
254
		 * @filter `gravityview/template/field/label` Override the field label.
255
		 * @since 2.0
256
		 * @param[in,out] string $column_label The label to override.
257
		 * @param \GV\Template_Context $context The context. Does not have entry set here.
258
		 */
259 20
		$column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context );
260
261 20
		return $column_label;
262
    }
263
264
	/**
265
	 * Output the entry row.
266
	 *
267
	 * @param \GV\Entry $entry The entry to be rendered.
268
	 * @param array $attributes The attributes for the <tr> tag
269
	 *
270
	 * @return void
271
	 */
272 17
	public function the_entry( \GV\Entry $entry, $attributes ) {
273
274 17
		$fields = $this->view->fields->by_position( 'directory_table-columns' )->by_visible( $this->view );
275
276 17
		$context = Template_Context::from_template( $this, compact( 'entry', 'fields' ) );
277
278
		/**
279
		 * Push legacy entry context.
280
		 */
281 17
		\GV\Mocks\Legacy_Context::load( array(
282 17
			'entry' => $entry,
283
		) );
284
285
		/**
286
		 * @filter `gravityview_table_cells` Modify the fields displayed in a table
287
		 * @param array $fields
288
		 * @param \GravityView_View $this
289
		 * @deprecated Use `gravityview/template/table/fields`
290
		 */
291 17
		$fields = apply_filters( 'gravityview_table_cells', $fields->as_configuration(), \GravityView_View::getInstance() );
292 17
		$fields = Field_Collection::from_configuration( $fields );
293
294
		/**
295
		 * @filter `gravityview/template/table/fields` Modify the fields displayed in this tables.
296
		 * @param \GV\Field_Collection $fields The fields.
297
		 * @param \GV\Template_Context $context The context.
298
		 * @since 2.0
299
		 */
300 17
		$fields = apply_filters( 'gravityview/template/table/fields', $fields, $context );
301
302 17
		$context = Template_Context::from_template( $this, compact( 'entry', 'fields' ) );
303
304
		/**
305
		 * @filter `gravityview/template/table/entry/row/attributes` Filter the row attributes for the row in table view.
306
		 *
307
		 * @param array $attributes The HTML attributes.
308
		 * @param \GV\Template_Context The context.
309
		 *
310
		 * @since 2.0
311
		 */
312 17
		$attributes = apply_filters( 'gravityview/template/table/entry/row/attributes', $attributes, $context );
313
314
		/** Glue the attributes together. */
315 17
		foreach ( $attributes as $attribute => $value ) {
316 17
			$attributes[ $attribute ] = sprintf( "$attribute=\"%s\"", esc_attr( $value ) );
317
		}
318 17
		$attributes = implode( ' ', $attributes );
319
320
		?>
321
			<tr<?php echo $attributes ? " $attributes" : ''; ?>>
322
                <?php
323
324
				/**
325
				 * @action `gravityview/template/table/cells/before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
326
				 * @since 2.0
327
				 * @param \GV\Template_Context The context.
328
				 */
329 17
				do_action( 'gravityview/template/table/cells/before', $context );
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
334
				 * @param \GravityView_View $this Current GravityView_View object
335
				 * @deprecated Use `gravityview/template/table/cells/before`
336
                 */
337 17
                do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
338
339 17
                foreach ( $fields->all() as $field ) {
340 17
					if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) {
341
						if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) {
342
							$field = $this->view->unions[ $entry['form_id'] ][ $field->ID ];
343
						} else {
344
							if ( ! $field instanceof Internal_Field ) {
345
								$field = Internal_Field::from_configuration( array( 'id' => 'custom' ) );
346
							}
347
						}
348
					}
349 17
					$this->the_field( $field, $entry );
350
				}
351
352
				/**
353
				 * @action `gravityview/template/table/cells/after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
354
				 * @since 2.0
355
				 * @param \GV\Template_Context The context.
356
				 */
357 17
				do_action( 'gravityview/template/table/cells/after', $context );
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
362
				 * @param \GravityView_View $this Current GravityView_View object
363
				 * @deprecated Use `gravityview/template/table/cells/after`
364
                 */
365 17
                do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() );
366
367
				?>
368 17
			</tr>
369
		<?php
370 17
	}
371
372
	/**
373
	 * Output a field cell.
374
	 *
375
	 * @param \GV\Field $field The field to be ouput.
376
	 * @param \GV\Field $entry The entry this field is for.
377
	 *
378
	 * @return void
379
	 */
380 16
	public function the_field( \GV\Field $field, \GV\Entry $entry ) {
381 16
		$form = $this->view->form;
382 16
		$single_entry = $entry;
383
384
		/**
385
		 * Push legacy entry context.
386
		 */
387 16
		\GV\Mocks\Legacy_Context::load( array(
388 16
			'field' => $field,
389
		) );
390
391 16
		if ( $entry->is_multi() ) {
392 3
			if ( ! $single_entry = $entry->from_field( $field ) ) {
393
				echo '<td></td>';
394
				return;
395
			}
396 3
			$form = GF_Form::by_id( $field->form_id );
0 ignored issues
show
Documentation introduced by
The property form_id does not exist on object<GV\Field>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
397
		}
398
399 16
		$renderer = new Field_Renderer();
400 16
		$source = is_numeric( $field->ID ) ? $form : new Internal_Source();
401
402 16
		$value = $renderer->render( $field, $this->view, $source, $entry, $this->request );
403
404 16
		$context = Template_Context::from_template( $this, compact( 'field' ) );
405 16
		$context->entry = $single_entry;
406
407
		$args = array(
408 16
			'entry' => $entry->as_entry(),
409 16
			'field' => is_numeric( $field->ID ) ? $field->as_configuration() : null,
410 16
			'value' => $value,
411
			'hide_empty' => false,
412 16
			'zone_id' => 'directory_table-columns',
413 16
            'label' => self::get_field_column_label( $field, $context ),
414 16
			'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>',
415 16
            'form' => $form,
416
		);
417
418
		/** Output. */
419 16
		echo \gravityview_field_output( $args, $context );
420 16
	}
421
422
	/**
423
	 * `gravityview_table_body_before` and `gravityview/template/table/body/before` actions.
424
	 *
425
	 * Output inside the `tbody` of the table.
426
	 *
427
	 * @param $context \GV\Template_Context The 2.0 context.
428
	 *
429
	 * @return void
430
	 */
431 20
	public static function body_before( $context ) {
432
		/**
433
		 * @action `gravityview/template/table/body/before` Output inside the `tbody` of the table.
434
		 * @since 2.0
435
		 * @param \GV\Template_Context $context The template context.
436
		 */
437 20
		do_action( 'gravityview/template/table/body/before', $context );
438
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
		*/
445 20
		do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ );
446 20
	}
447
448
	/**
449
	 * `gravityview_table_body_after` and `gravityview/template/table/body/after` actions.
450
	 *
451
	 * Output inside the `tbody` of the table.
452
	 *
453
	 * @param $context \GV\Template_Context The 2.0 context.
454
	 *
455
	 * @return void
456
	 */
457 20
	public static function body_after( $context ) {
458
		/**
459
		 * @action `gravityview/template/table/body/after` Output inside the `tbody` of the table at the end.
460
		 * @since 2.0
461
		 * @param \GV\Template_Context $context The template context.
462
		 */
463 20
		do_action( 'gravityview/template/table/body/after', $context );
464
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
		*/
471 20
		do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ );
472 20
	}
473
474
	/**
475
	 * `gravityview_table_tr_before` and `gravityview/template/table/tr/after` actions.
476
	 *
477
	 * Output inside the `tr` of the table.
478
	 *
479
	 * @param $context \GV\Template_Context The 2.0 context.
480
	 *
481
	 * @return void
482
	 */
483 7
	public static function tr_before( $context ) {
484
		/**
485
		 * @action `gravityview/template/table/tr/before` Output inside the `tr` of the table when there are no results.
486
		 * @since 2.0
487
		 * @param \GV\Template_Context $context The template context.
488
		 */
489 7
		do_action( 'gravityview/template/table/tr/before', $context );
490
491
		/**
492
		 * @action `gravityview_table_tr_before` Before the `tr` while rendering each entry in the loop. Can be used to insert additional table rows.
493
		 * @since 1.0.7
494
		 * @deprecated USe `gravityview/template/table/tr/before`
495
		 * @param \GravityView_View $gravityview_view Current GraivtyView_View object.
496
		 */
497 7
		do_action( 'gravityview_table_tr_before', \GravityView_View::getInstance() /** ugh! */ );
498 7
	}
499
500
	/**
501
	 * `gravityview_table_tr_after` and `gravityview/template/table/tr/after` actions.
502
	 *
503
	 * Output inside the `tr` of the table.
504
	 *
505
	 * @param $context \GV\Template_Context The 2.0 context.
506
	 *
507
	 * @return void
508
	 */
509 7
	public static function tr_after( $context ) {
510
		/**
511
		 * @action `gravityview/template/table/tr/after` Output inside the `tr` of the table when there are no results.
512
		 * @since 2.0
513
		 * @param \GV\Template_Context $context The template context.
514
		 */
515 7
		do_action( 'gravityview/template/table/tr/after', $context );
516
517
		/**
518
		 * @action `gravityview_table_tr_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
519
		 * @since 1.0.7
520
		 * @deprecated USe `gravityview/template/table/tr/after`
521
		 * @param \GravityView_View $gravityview_view Current GravityView_View object.
522
		 */
523 7
		do_action( 'gravityview_table_tr_after', \GravityView_View::getInstance() /** ugh! */ );
524 7
	}
525
526
	/**
527
	 * `gravityview_entry_class` and `gravityview/template/table/entry/class` filters.
528
	 *
529
	 * Modify of the class of a row.
530
	 *
531
	 * @param string $class The class.
532
	 * @param \GV\Entry $entry The entry.
533
	 * @param \GV\Template_Context The context.
534
	 *
535
	 * @return string The classes.
536
	 */
537 16
	public static function entry_class( $class, $entry, $context ) {
538
		/**
539
		 * @filter `gravityview_entry_class` Modify the class applied to the entry row.
540
		 * @param string $class Existing class.
541
		 * @param array $entry Current entry being displayed
542
		 * @param \GravityView_View $this Current GravityView_View object
543
		 * @deprecated Use `gravityview/template/table/entry/class`
544
		 * @return string The modified class.
545
		 */
546 16
		$class = apply_filters( 'gravityview_entry_class', $class, $entry->as_entry(), \GravityView_View::getInstance() );
547
548
		/**
549
		 * @filter `gravityview/template/table/entry/class` Modify the class aplied to the entry row.
550
		 * @param string $class The existing class.
551
		 * @param \GV\Template_Context The context.
552
		 * @return string The modified class.
553
		 */
554 16
		return apply_filters( 'gravityview/template/table/entry/class', $class, Template_Context::from_template( $context->template, compact( 'entry' ) ) );
555
	}
556
}
557