GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
class-gv-template-entry-list.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 List 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 = 'list';
19 
20  /**
21  * Output the field in the list view.
22  *
23  * @param \GV\Field $field The field to output.
24  * @param array $extras Extra stuff, like wpautop, etc.
25  *
26  * @return string
27  */
28  public function the_field( \GV\Field $field, $extras = null ) {
29  $form = $this->view->form;
30 
31  $renderer = new Field_Renderer();
32  $source = is_numeric( $field->ID ) ? $this->view->form : new Internal_Source();
33 
34  $value = $renderer->render( $field, $this->view, $source, $this->entry, $this->request );
35 
36  $context = Template_Context::from_template( $this, compact( 'field' ) );
37 
38  /**
39  * @deprecated Here for back-compatibility.
40  */
41  $label = apply_filters( 'gravityview_render_after_label', $field->get_label( $this->view, $form, $this->entry ), $field->as_configuration() );
42  $label = apply_filters( 'gravityview/template/field_label', $label, $field->as_configuration(), $form->form ? $form->form : null, $this->entry->as_entry() );
43 
44  /**
45  * @filter `gravityview/template/field/label` Override the field label.
46  * @since 2.0
47  * @param[in,out] string $label The label to override.
48  * @param \GV\Template_Context $context The context.
49  */
50  $label = apply_filters( 'gravityview/template/field/label', $label, $context );
51 
52  /**
53  * @filter `gravityview/template/table/entry/hide_empty`
54  * @param boolean $hide_empty Should the row be hidden if the value is empty? Default: don't hide.
55  * @param \GV\Template_Context $context The context ;) Love it, cherish it. And don't you dare modify it!
56  */
57  $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context );
58 
59  if ( is_numeric( $field->ID ) ) {
60  $extras['field'] = $field->as_configuration();
61  }
62 
63  $extras['entry'] = $this->entry->as_entry();
64  $extras['hide_empty'] = $hide_empty;
65  $extras['label'] = $label;
66  $extras['value'] = $value;
67 
68  return \gravityview_field_output( $extras, $context );
69  }
70 
71  /**
72  * Return an array of variables ready to be extracted.
73  *
74  * @param string|array $zones The field zones to grab.
75  *
76  * @return array An array ready to be extract()ed in the form of
77  * $zone => \GV\Field_Collection
78  * has_$zone => int
79  */
80  public function extract_zone_vars( $zones ) {
81  if ( ! is_array( $zones ) ) {
82  $zones = array( $zones );
83  }
84 
85  $vars = array();
86  foreach ( $zones as $zone ) {
87  $zone_var = str_replace( '-', '_', $zone );
88  $vars[ $zone_var ] = $this->view->fields->by_position( 'single_list-' . $zone )->by_visible();
89  $vars[ "has_$zone_var" ] = $vars[ $zone_var ]->count();
90  }
91 
92  return $vars;
93  }
94 }
If this file is called directly, abort.
the_field(\GV\Field $field, $extras=null)
Output the field in the list view.
get( $key, $default=null)
Retrieve a setting.
If this file is called directly, abort.
If this file is called directly, abort.
If this file is called directly, abort.
extract_zone_vars( $zones)
Return an array of variables ready to be extracted.
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