GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes | Static Private Attributes
View Class Reference

If this file is called directly, abort. More...

Inheritance diagram for View:

Public Member Functions

 __construct ()
 The constructor. More...
 
 __get ( $key)
 
 as_data ()
 Be compatible with the old data object. More...
 
 can_render ( $context=null, $request=null)
 Checks whether this view can be accessed or not. More...
 
 get_entries ( $request=null)
 Retrieve the entries for the current view and request. More...
 
 offsetExists ( $offset)
 ArrayAccess compatibility layer with GravityView_View_Data::$views. More...
 
 offsetGet ( $offset)
 ArrayAccess compatibility layer with GravityView_View_Data::$views. More...
 
 offsetSet ( $offset, $value)
 ArrayAccess compatibility layer with GravityView_View_Data::$views. More...
 
 offsetUnset ( $offset)
 ArrayAccess compatibility layer with GravityView_View_Data::$views. More...
 

Static Public Member Functions

static _flush_cache ( $view_id=null)
 Flush the view cache. More...
 
static add_rewrite_endpoint ()
 Add extra rewrite endpoints. More...
 
static by_id ( $post_id)
 Construct a instance from a post ID. More...
 
static content ( $content)
 A renderer filter for the View post type content. More...
 
static exists ( $view)
 Determines if a view exists to begin with. More...
 
static from_post ( $post)
 Construct a instance from a . More...
 
static get_joined_forms ( $post_id=0)
 Get joined forms associated with a view. More...
 
static get_joins ( $post)
 Get joins associated with a view. More...
 
static register_post_type ()
 Register the gravityview WordPress Custom Post Type. More...
 
static template_redirect ()
 Last chance to configure the output. More...
 

Data Fields

 $fields
 
 $form
 
 $joins = array()
 
 $settings
 
 $widgets
 

Private Attributes

 $post
 

Static Private Attributes

static $cache = array()
 

Detailed Description

If this file is called directly, abort.

The default GravityView View class.

Houses all base View functionality.

Can be accessed as an array for old compatibility's sake in line with the elements inside the ::$views array.

Definition at line 17 of file class-gv-view.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

The constructor.

Definition at line 81 of file class-gv-view.php.

Member Function Documentation

◆ __get()

__get (   $key)

Definition at line 1026 of file class-gv-view.php.

◆ _flush_cache()

static _flush_cache (   $view_id = null)
static

Flush the view cache.

Parameters
int$view_idThe View to reset cache for. Optional. Default: resets everything.

Definition at line 667 of file class-gv-view.php.

References $view_id.

◆ add_rewrite_endpoint()

static add_rewrite_endpoint ( )
static

Add extra rewrite endpoints.

Returns
void

CSV.

Definition at line 203 of file class-gv-view.php.

◆ as_data()

as_data ( )

Be compatible with the old data object.

Some external code expects an array (doing things like foreach on this, or array_keys) so let's return an array in the old format for such cases. Do not use unless using for back-compatibility.

Definition at line 790 of file class-gv-view.php.

References gravityview_get_form().

◆ by_id()

static by_id (   $post_id)
static

◆ can_render()

can_render (   $context = null,
  $request = null 
)

Checks whether this view can be accessed or not.

Parameters
string[]$context The context we're asking for access from. Can any and as many of one of: edit An edit context. single A single context. cpt The custom post type single page acessed. shortcode Embedded as a shortcode. oembed Embedded as an oEmbed. rest A REST call.
\GV\Request$requestThe request
Returns
bool| An error if this View shouldn't be rendered here.
Runs Filter:
gravityview/view/can_render Whether the view can be rendered or not.
Parameters
bool | \WP_Error$resultThe result. Default: null.
\GV\View$viewThe view.
string[]$context See ::can_render
\GV\Request$requestThe request.

This View is password protected. Nothing to do here.

Is this View directly accessible via a post URL?

See also
https://codex.wordpress.org/Function_Reference/register_post_type#public
Runs Filter:
gravityview_direct_access Should Views be directly accessible, or only visible using the shortcode?
Parameters
[in,out]booleantrue: allow Views to be accessible directly. false: Only allow Views to be embedded. Default: true
int$view_idThe ID of the View currently being requested. 0 for general setting
Runs Filter:
gravityview/request/output/direct Should this View be directly accessbile?
Since
2.0
Parameters
[in,out]booleanAccessible or not. Default: accessbile.
\GV\View$viewThe View we're trying to directly render here.
\GV\Request$requestThe current request.

Is this View an embed-only View? If so, don't allow rendering here, as this is a direct request.

Private, pending, draft, etc.

Definition at line 366 of file class-gv-view.php.

References gravityview(), and GVCommon\has_cap().

◆ content()

static content (   $content)
static

A renderer filter for the View post type content.

Parameters
string$contentShould be empty, as we don't store anything there.
Returns
string $content The view content as output by the renderers.

This is not a View. Bail.

Shortcodes and oEmbeds and whatnot will be handled elsewhere.

Check permissions.

This View has no data source. There's nothing to show really. ...apart from a nice message if the user can do anything about it.

Editing a single entry.

Viewing a single entry.

Plain old View.

Definition at line 229 of file class-gv-view.php.

References $content, $entry, GVCommon\check_entry_display(), gravityview(), GVCommon\has_cap(), GravityView_Entry_Approval_Status\is_approved(), and GravityView_Entry_Approval\meta_key.

◆ exists()

static exists (   $view)
static

Determines if a view exists to begin with.

Parameters
int | \WP_Post | null$viewThe WordPress post ID, a object or null for global $post;
Since
2.0
Returns
bool Whether the post exists or not.

Definition at line 700 of file class-gv-view.php.

Referenced by GravityView_View_Data\maybe_get_view_id().

◆ from_post()

static from_post (   $post)
static

Construct a instance from a .

Parameters
\WP_Post$postThe instance to wrap.
Since
2.0
Returns
|null An instance around this if valid, null otherwise.
Runs Filter:
gravityview/view/get Override View.
Parameters
\GV\View$viewThe View instance pointer.
Since
2.1

Get connected form.

Runs Filter:
gravityview/configuration/fields Filter the View fields' configuration array.
Since
1.6.5
Parameters
$fieldsarray Multi-array of fields with first level being the field zones.
$view_idint The View the fields are being pulled for.
Runs Filter:
gravityview/view/configuration/fields Filter the View fields' configuration array.
Since
2.0
Parameters
array$fieldsMulti-array of fields with first level being the field zones.
\GV\View$viewThe View the fields are being pulled for.
Runs Filter:
gravityview/view/fields Filter the Field Collection for this View.
Since
2.0
Parameters
\GV\Field_Collection$fieldsA collection of fields.
\GV\View$viewThe View the fields are being pulled for.
Runs Filter:
gravityview/view/configuration/widgets Filter the View widgets' configuration array.
Since
2.0
Parameters
array$fieldsMulti-array of widgets with first level being the field zones.
\GV\View$viewThe View the widgets are being pulled for.
Runs Filter:
gravityview/view/widgets Filter the Widget Collection for this View.
Since
2.0
Parameters
\GV\Widget_Collection$widgetsA collection of widgets.
\GV\View$viewThe View the widgets are being pulled for.

View configuration.

Add the template name into the settings.

View basics.

Runs Filter:
gravityview/view/get Override View.
Parameters
\GV\View$viewThe View instance pointer.
Since
2.1

Definition at line 558 of file class-gv-view.php.

References $post, GV\get(), gravityview(), gravityview_get_template_id(), and gravityview_get_template_settings().

Referenced by oEmbed\parse_matches(), Views_Route\prepare_view_for_response(), GravityView_Admin_Views\render_active_areas(), and GravityView_Admin_Metaboxes\render_view_configuration_metabox().

◆ get_entries()

get_entries (   $request = null)

Retrieve the entries for the current view and request.

Parameters

Cleanup duplicate field_filter parameters to simplify the query.

New stuff :)

Any joins?

Runs Actions:
gravityview/view/query Override the before the get() call.
Parameters
\GF_Query$queryThe current query object reference
\GV\View$thisThe current view object
\GV\Request$requestThe request object

Map from Gravity Forms entries arrays to an Entry_Collection.

Add total count callback.

Runs Filter:
gravityview/view/entries Modify the entry fetching filters, sorts, offsets, limits.
Parameters
\GV\Entry_Collection$entriesThe entries for this view.
\GV\View$viewThe view.
\GV\Request$requestThe request.

Definition at line 810 of file class-gv-view.php.

References $entries, $entry, $field, $filter, Entry_Sort\ASC, GVCommon\calculate_get_entries_criteria(), Entry_Sort\DESC, GV\get(), and gravityview().

Referenced by View_Renderer\render().

◆ get_joined_forms()

static get_joined_forms (   $post_id = 0)
static

Get joined forms associated with a view.

Since
2.0.11
Parameters
int$post_idID of the View
Returns
[] Array of instances

Definition at line 516 of file class-gv-view.php.

References gravityview().

Referenced by GravityView_Welcome\getting_started_screen().

◆ get_joins()

static get_joins (   $post)
static

Get joins associated with a view.

Parameters
\WP_Post$postGravityView CPT to get joins for
Since
2.0.11
Returns
[] Array of instances

Definition at line 468 of file class-gv-view.php.

References $post, and gravityview().

Referenced by GravityView_Welcome\getting_started_screen().

◆ offsetExists()

offsetExists (   $offset)

ArrayAccess compatibility layer with GravityView_View_Data::$views.

Definition at line 712 of file class-gv-view.php.

◆ offsetGet()

offsetGet (   $offset)

ArrayAccess compatibility layer with GravityView_View_Data::$views.

Maps the old keys to the new data;

Definition at line 728 of file class-gv-view.php.

References GV\$form, and gravityview().

◆ offsetSet()

offsetSet (   $offset,
  $value 
)

ArrayAccess compatibility layer with GravityView_View_Data::$views.

Definition at line 762 of file class-gv-view.php.

References gravityview().

◆ offsetUnset()

offsetUnset (   $offset)

ArrayAccess compatibility layer with GravityView_View_Data::$views.

Definition at line 774 of file class-gv-view.php.

References gravityview().

◆ register_post_type()

static register_post_type ( )
static

Register the gravityview WordPress Custom Post Type.

Register only once

Runs Filter:
gravityview_is_hierarchical Make GravityView Views hierarchical by returning TRUE This will allow for Views to be nested with Parents and also allows for menu order to be set in the Page Attributes metabox
Since
1.13
Parameters
boolean$is_hierarchicalDefault: false
Runs Filter:
gravityview_post_type_supports Modify post type support values for gravityview post type
See also
add_post_type_support()
Since
1.15.2
Parameters
array$supportsArray of features associated with a functional area of the edit screen. Default: 'title', 'revisions'. If $is_hierarchical, also 'page-attributes'
[in]boolean$is_hierarchicalDo Views support parent/child relationships? See gravityview_is_hierarchical filter.

Register Custom Post Type - gravityview

Runs Filter:
gravityview_direct_access Should Views be directly accessible, or only visible using the shortcode?
See also
https://codex.wordpress.org/Function_Reference/register_post_type#public
Since
1.15.2
Parameters
[in,out]booleantrue: allow Views to be accessible directly. false: Only allow Views to be embedded via shortcode. Default: true
int$view_idThe ID of the View currently being requested. 0 for general setting
Runs Filter:
gravityview_has_archive Enable Custom Post Type archive?
Since
1.7.3
Parameters
booleanFalse: don't have frontend archive; True: yes, have archive. Default: false
Runs Filter:
gravityview_slug Modify the url part for a View.
See also
https://docs.gravityview.co/article/62-changing-the-view-slug
Parameters
string$slugThe slug shown in the URL
Runs Filter:
gravityview/post_type/with_front Should the permalink structure be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/view/, true->/blog/view/). Defaults to true.
See also
https://codex.wordpress.org/Function_Reference/register_post_type
Since
2.0
Parameters
bool$with_front

Definition at line 93 of file class-gv-view.php.

References $labels, gravityview(), and GravityView_Admin\no_views_text().

◆ template_redirect()

static template_redirect ( )
static

Last chance to configure the output.

Used for CSV output, for example.

Returns
void

CSV output.

Modify the name of the generated CSV file. Name will be sanitized using sanitize_file_name() before output.

See also
sanitize_file_name()
Since
2.1
Parameters
string$filenameFile name used when downloading a CSV. Default is "{View title}.csv"
\GV\View$viewCurrent View being rendered

Add da' BOM if GF uses it

See also
GFExport::start_export()
Runs Filter:
gravityview/csv/entry/fields Whitelist more entry fields that are output in CSV requests.
Parameters
[in,out]array$allowedThe allowed ones, default by_visible, by_position( "context_*" ), i.e. as set in the View.
\GV\View$viewThe view.
\GV\Entry$entryWordPress representation of the item.

Definition at line 927 of file class-gv-view.php.

References $entries, $entry, $field, $field_id, $label, Internal_Field\by_id(), GF_Field\by_id(), and gravityview().

Field Documentation

◆ $cache

$cache = array()
staticprivate

Definition at line 68 of file class-gv-view.php.

◆ $fields

$fields

Definition at line 58 of file class-gv-view.php.

◆ $form

$form

Definition at line 48 of file class-gv-view.php.

◆ $joins

$joins = array()

Definition at line 76 of file class-gv-view.php.

◆ $post

$post
private

Definition at line 22 of file class-gv-view.php.

◆ $settings

$settings

Definition at line 30 of file class-gv-view.php.

◆ $widgets

$widgets

Definition at line 38 of file class-gv-view.php.


The documentation for this class was generated from the following file: