GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
class-gv-template-entry-table.php
Go to the documentation of this file.
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 Entry Table Template class .
11  *
12  * Renders a \GV\Entry using a \GV\Entry_Renderer.
13  */
15  /**
16  * @var string The template slug to be loaded (like "table", "list")
17  */
18  public static $slug = 'table';
19 
20  /**
21  * Output a field cell.
22  *
23  * @param \GV\Field $field The field to be ouput.
24  *
25  * @return string|false The field output or false if "hide_empty" is set.
26  */
27  public function the_field( \GV\Field $field ) {
28  $renderer = new Field_Renderer();
29  $source = is_numeric( $field->ID ) ? $this->view->form : new Internal_Source();
30 
31  return $renderer->render( $field, $this->view, $source, $this->entry, $this->request );
32  }
33 
34  /**
35  * Out the single entry table body.
36  *
37  * @return void
38  */
39  public function the_entry() {
40 
41  /** @var \GV\Field_Collection $fields */
42  $fields = $this->view->fields->by_position( 'single_table-columns' )->by_visible();
43  $form = $this->view->form;
44 
45  $context = Template_Context::from_template( $this, compact( 'fields' ) );
46 
47  /**
48  * @filter `gravityview_table_cells` Modify the fields displayed in a table
49  * @param array $fields
50  * @param \GravityView_View $this
51  * @deprecated Use `gravityview/template/table/fields`
52  */
53  $fields = apply_filters( 'gravityview_table_cells', $fields->as_configuration(), \GravityView_View::getInstance() );
54  $fields = Field_Collection::from_configuration( $fields );
55 
56  /**
57  * @filter `gravityview/template/table/fields` Modify the fields displayed in this tables.
58  * @param \GV\Field_Collection $fields The fields.
59  * @param \GV\Template_Context $context The context.
60  * @since 2.0
61  */
62  $fields = apply_filters( 'gravityview/template/table/fields', $fields, $context );
63 
64  foreach ( $fields->all() as $field ) {
65  $context = Template_Context::from_template( $this, compact( 'field' ) );
66 
67  /**
68  * @deprecated Here for back-compatibility.
69  */
70  $column_label = apply_filters( 'gravityview_render_after_label', $field->get_label( $this->view, $form, $this->entry ), $field->as_configuration() );
71  $column_label = apply_filters( 'gravityview/template/field_label', $column_label, $field->as_configuration(), $form->form ? $form->form : null, $this->entry->as_entry() );
72 
73  /**
74  * @filter `gravityview/template/field/label` Override the field label.
75  * @since 2.0
76  * @param[in,out] string $column_label The label to override.
77  * @param \GV\Template_Context $context The context.
78  */
79  $column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context );
80 
81  /**
82  * @filter `gravityview/template/table/entry/hide_empty`
83  * @param boolean $hide_empty Should the row be hidden if the value is empty? Default: don't hide.
84  * @param \GV\Template_Context $context The context ;) Love it, cherish it. And don't you dare modify it!
85  */
86  $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', $this->view->settings->get( 'hide_empty', false ), $context );
87 
89  'entry' => $this->entry->as_entry(),
90  'field' => is_numeric( $field->ID ) ? $field->as_configuration() : null,
91  'label' => $column_label,
92  'value' => $this->the_field( $field ),
93  'markup' => '<tr id="{{ field_id }}" class="{{ class }}"><th scope="row">{{ label }}</th><td>{{ value }}</td></tr>',
94  'hide_empty' => $hide_empty,
95  'zone_id' => 'single_table-columns',
96  ), $context );
97  }
98  }
99 }
If this file is called directly, abort.
static getInstance( $passed_post=NULL)
the_field(\GV\Field $field)
Output a field cell.
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
gravityview_field_output( $passed_args, $context=null)
Output field based on a certain html markup.
Definition: class-api.php:1272
$field
Definition: gquiz_grade.php:11