Skip to content

Commit

Permalink
Merge pull request #1216 from gravityview/develop
Browse files Browse the repository at this point in the history
Version 2.2.2
  • Loading branch information
zackkatz authored Dec 11, 2018
2 parents 9b310a6 + fe18cb5 commit 05ab62d
Show file tree
Hide file tree
Showing 41 changed files with 3,476 additions and 701 deletions.
2 changes: 1 addition & 1 deletion assets/css/admin-views.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions assets/css/scss/admin-views.scss
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ hr {

.button-secondary {
float: right;
margin-right: .5em;

&:first-child {
margin: 0;
}
}

}
Expand Down
3 changes: 2 additions & 1 deletion future/_mocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) {
}

if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) {
$multientry = \GV\Multi_Entry::from_entries( array_map( '\GV\GF_Entry::from_entry', $entry['_multi'] ) );
$entry = $entry['_multi'][ $field_settings['form_id'] ];
}

Expand Down Expand Up @@ -196,7 +197,7 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) {
$field->update_configuration( $field_settings );

$renderer = new \GV\Field_Renderer();
return $renderer->render( $field, gravityview()->views->get(), $source == \GV\Source::BACKEND_GRAVITYFORMS ? $form : null, $entry, gravityview()->request );
return $renderer->render( $field, gravityview()->views->get(), $source == \GV\Source::BACKEND_GRAVITYFORMS ? $form : null, isset( $multientry ) ? $multientry : $entry, gravityview()->request );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions future/includes/class-gv-form-join.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class Join {
/**
* @var Field
*/
private $join_column;
public $join_column;

/**
* @var Field
*/
private $join_on_column;
public $join_on_column;

/**
* Construct a JOIN container.
Expand Down
8 changes: 7 additions & 1 deletion future/includes/class-gv-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ final class Plugin {
*/
const FEATURE_JOINS = 'joins';

/**
* @var string The unions functionality identifier.
*/
const FEATURE_UNIONS = 'unions';

/**
* @var string The REST API functionality identifier.
*/
Expand Down Expand Up @@ -471,7 +476,8 @@ public function supports( $feature ) {
switch ( $feature ):
case self::FEATURE_GFQUERY:
case self::FEATURE_JOINS:
return class_exists( '\GF_Query' );
case self::FEATURE_UNIONS:
return apply_filters( 'gravityview/query/class', false ) === '\GF_Patched_Query';
case self::FEATURE_REST:
return class_exists( '\WP_REST_Controller' );
default:
Expand Down
1 change: 1 addition & 0 deletions future/includes/class-gv-renderer-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function render( Field $field, View $view = null, Source $source = null,
return null;
}

/** @var \GV\Field_Template $class */
$renderer = new $class( $field, $view, $source, $entry, $request );
ob_start();
$renderer->render();
Expand Down
19 changes: 8 additions & 11 deletions future/includes/class-gv-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,28 @@ public function is_entry( $form_id = 0 ) {
if ( $view && ( $joins = $view->joins ) ) {
$forms = array_merge( wp_list_pluck( $joins, 'join' ), wp_list_pluck( $joins, 'join_on' ) );
$valid_forms = array_unique( wp_list_pluck( $forms, 'ID' ) );
$needs_forms = array_flip( $valid_forms );

$multientry = array();
foreach ( $ids = explode( ',', $id ) as $i => $id ) {
if ( ! $e = GF_Entry::by_id( $id, $forms[ $i ] ) ) {

$valid_form = \GV\Utils::get( $valid_forms, $i, 0 );

if ( ! $e = GF_Entry::by_id( $id, $valid_form ) ) {
return false;
}

if ( ! in_array( $e['form_id'], $valid_forms ) ) {
return false;
}

unset( $needs_forms[ $e['form_id'] ] );

array_push( $multientry, $e );
}

/**
* Not all forms have been requested.
*/
if ( count( $needs_forms ) ) {
return false;
}
// Allow Edit Entry to only edit a single entry on a multi-entry
$is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );

if ( ( count( $multientry ) - 1 ) != count( $joins ) ) {
// Edit entry links are single-entry based
if ( $is_edit_entry && 1 !== count( $multientry ) ) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions future/includes/class-gv-template-entry-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public function the_field( \GV\Field $field, $extras = null ) {
$form = \GV\GF_Form::by_id( $field->form_id ) ? : $this->view->form;
$entry = $this->entry->from_field( $field );

if ( ! $entry ) {
return '';
}

$renderer = new Field_Renderer();
$source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ? : $this->view->form ) : new Internal_Source();

Expand Down
4 changes: 4 additions & 0 deletions future/includes/class-gv-template-entry-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function the_entry() {
$form = \GV\GF_Form::by_id( $field->form_id ) ? : $this->view->form;
$entry = $this->entry->from_field( $field );

if ( ! $entry ) {
continue;
}

/**
* @deprecated Here for back-compatibility.
*/
Expand Down
17 changes: 9 additions & 8 deletions future/includes/class-gv-template-view-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@ class View_List_Template extends View_Template {
public function the_field( \GV\Field $field, \GV\Entry $entry, $extras = null ) {
$form = $this->view->form;

if ( $entry->is_multi() ) {
if ( ! $single_entry = $entry->from_field( $field ) ) {
return;
}
$form = GF_Form::by_id( $field->form_id );
}

/**
* Push legacy entry context.
*/
\GV\Mocks\Legacy_Context::load( array(
'entry' => $entry,
'form' => $form,
) );

if ( $entry->is_multi() ) {
if ( ! $entry = $entry->from_field( $field ) ) {
return;
}
$form = GF_Form::by_id( $field->form_id );
}

$context = Template_Context::from_template( $this, compact( 'field', 'entry' ) );

$renderer = new Field_Renderer();
$source = is_numeric( $field->ID ) ? $form : new Internal_Source();

$value = $renderer->render( $field, $this->view, $source, $entry, $this->request );

/**
Expand Down
1 change: 1 addition & 0 deletions future/includes/class-gv-template-view-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public function the_field( \GV\Field $field, \GV\Entry $entry ) {

if ( $entry->is_multi() ) {
if ( ! $single_entry = $entry->from_field( $field ) ) {
echo '<td></td>';
return;
}
$form = GF_Form::by_id( $field->form_id );
Expand Down
Loading

0 comments on commit 05ab62d

Please sign in to comment.