Skip to content

Commit

Permalink
Manual update from 1.9.5.12 to 1.9.9.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed May 28, 2015
1 parent a022b61 commit 3ea999e
Show file tree
Hide file tree
Showing 95 changed files with 4,690 additions and 2,858 deletions.
264 changes: 203 additions & 61 deletions change_log.txt

Large diffs are not rendered by default.

171 changes: 120 additions & 51 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static function format_number( $number, $number_format, $currency = '', $
}

public static function recursive_add_index_file( $dir ) {
if ( ! is_dir( $dir ) ) {
if ( ! is_dir( $dir ) || is_link( $dir ) ) {
return;
}

Expand Down Expand Up @@ -302,8 +302,8 @@ public static function is_valid_email_list( $email_list ) {
return true;
}

public static function get_label( $field, $input_id = 0, $input_only = false ) {
return RGFormsModel::get_label( $field, $input_id, $input_only );
public static function get_label( $field, $input_id = 0, $input_only = false, $allow_admin_label = true ) {
return RGFormsModel::get_label( $field, $input_id, $input_only, $allow_admin_label );
}

public static function get_input( $field, $id ) {
Expand Down Expand Up @@ -786,8 +786,11 @@ public static function format_variable_value( $value, $url_encode, $esc_html, $f
}

public static function replace_variables( $text, $form, $lead, $url_encode = false, $esc_html = true, $nl2br = true, $format = 'html' ) {

$text = $nl2br ? nl2br( $text ) : $text;

$text = apply_filters( 'gform_pre_replace_merge_tags', $text, $form, $lead, $url_encode, $esc_html, $nl2br, $format );

//Replacing field variables: {FIELD_LABEL:FIELD_ID} {My Field:2}
preg_match_all( '/{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER );
if ( is_array( $matches ) ) {
Expand All @@ -811,7 +814,7 @@ public static function replace_variables( $text, $form, $lead, $url_encode = fal

$modifier = strtolower( rgar( $match, 4 ) );

$value = $field->get_value_merge_tag( $value, $input_id, $lead, $form, $modifier, $raw_value, $url_encode, $esc_html, $format );
$value = $field->get_value_merge_tag( $value, $input_id, $lead, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br );

if ( $modifier == 'label' ) {
$value = empty( $value ) ? '' : $field->label;
Expand Down Expand Up @@ -863,21 +866,32 @@ public static function replace_variables( $text, $form, $lead, $url_encode = fal
}

//pricing fields
if ( strpos( $text, '{pricing_fields}' ) !== false ) {
$pricing_fields = self::get_submitted_pricing_fields( $form, $lead, $format );
if ( $format == 'html' ) {
$text = str_replace(
'{pricing_fields}', '<table width="99%" border="0" cellpadding="1" cellspacing="0" bgcolor="#EAEAEA">
<tr><td>
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">' .
$pricing_fields .
'</table>
</tr></td>
</table>',
$text
);
} else {
$text = str_replace( '{pricing_fields}', $pricing_fields, $text );
$pricing_matches = array();
preg_match_all( "/{pricing_fields(:(.*?))?}/", $text, $pricing_matches, PREG_SET_ORDER );
foreach ( $pricing_matches as $match ) {
$options = explode( ',', rgar( $match, 2 ) );
$use_value = in_array( 'value', $options );
$use_admin_label = in_array( 'admin', $options );

//all submitted pricing fields using text
if ( strpos( $text, $match[0] ) !== false ) {
$pricing_fields = self::get_submitted_pricing_fields( $form, $lead, $format, ! $use_value, $use_admin_label );

if ( $format == 'html' ) {
$text = str_replace(
$match[0], '<table width="99%" border="0" cellpadding="1" cellspacing="0" bgcolor="#EAEAEA">
<tr><td>
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">' .
$pricing_fields .
'</table>
</tr></td>
</table>',
$text
);
}
else {
$text = str_replace( $match[0], $pricing_fields, $text );
}
}
}

Expand Down Expand Up @@ -1091,7 +1105,7 @@ public static function get_submitted_fields( $form, $lead, $display_empty = fals
foreach ( $form['fields'] as $field ) {
$field_value = '';

$field_label = $use_admin_label && ! empty( $field->adminLabel ) ? $field->adminLabel : esc_html( GFCommon::get_label( $field ) );
$field_label = $use_admin_label && ! empty( $field->adminLabel ) ? $field->adminLabel : esc_html( GFCommon::get_label( $field, 0, false, $use_admin_label ) );

switch ( $field->type ) {
case 'captcha' :
Expand Down Expand Up @@ -2137,13 +2151,18 @@ public static function selection_display( $value, $field, $currency = '', $use_t
}
}

public static function date_display( $value, $format = 'mdy' ) {
$date = self::parse_date( $value, $format );
public static function date_display( $value, $input_format = 'mdy', $output_format = false ) {

if( ! $output_format ) {
$output_format = $input_format;
}

$date = self::parse_date( $value, $input_format );
if ( empty( $date ) ) {
return $value;
}

list( $position, $separator ) = rgexplode( '_', $format, 2 );
list( $position, $separator ) = rgexplode( '_', $output_format, 2 );
switch ( $separator ) {
case 'dash' :
$separator = '-';
Expand Down Expand Up @@ -2317,7 +2336,7 @@ public static function get_select_choices( $field, $value = '' ) {

if ( GFFormsModel::get_input_type( $field ) == 'select' && ! empty( $field->placeholder ) ) {
$selected = empty( $value ) ? "selected='selected'" : '';
$choices .= sprintf( "<option value='' %s>%s</option>", $selected, esc_html( $field->placeholder ) );
$choices .= sprintf( "<option value='' %s class='gf_placeholder'>%s</option>", $selected, esc_html( $field->placeholder ) );
}

foreach ( $field->choices as $choice ) {
Expand Down Expand Up @@ -2460,22 +2479,13 @@ public static function is_post_field( $field ) {
}

public static function get_fields_by_type( $form, $types ) {
$fields = array();
if ( ! is_array( rgar( $form, 'fields' ) ) ) {
return $fields;
}

foreach ( $form['fields'] as $field ) {
if ( in_array( $field->type, $types ) ) {
$fields[] = $field;
}
}
// TODO: Deprecate

return $fields;
return GFAPI::get_fields_by_type( $form, $types );
}

public static function has_pages( $form ) {
return sizeof( self::get_fields_by_type( $form, array( 'page' ) ) ) > 0;
return sizeof( GFAPI::get_fields_by_type( $form, array( 'page' ) ) ) > 0;
}

public static function get_product_fields_by_type( $form, $types, $product_id ) {
Expand Down Expand Up @@ -2643,7 +2653,7 @@ public static function clean_extensions( $extensions ) {
}

public static function get_disallowed_file_extensions() {
return array( 'php', 'asp', 'exe', 'com', 'htaccess', 'phtml', 'php3', 'php4', 'php5', 'php6' );
return array( 'php', 'asp', 'aspx', 'cmd', 'csh', 'bat', 'html', 'hta', 'jar', 'exe', 'com', 'js', 'lnk', 'htaccess', 'phtml', 'ps1', 'ps2', 'php3', 'php4', 'php5', 'php6', 'py', 'rb', 'tmp' );
}

public static function match_file_extension( $file_name, $extensions ) {
Expand Down Expand Up @@ -2824,7 +2834,7 @@ public static function get_product_fields( $form, $lead, $use_choice_text = fals
$products[ $id ]['name'] = $use_admin_label && ! rgempty( 'adminLabel', $field ) ? $field->adminLabel : $lead_value[ $id . '.1' ];
$products[ $id ]['price'] = rgar( $lead_value, $id . '.2' );
$products[ $id ]['quantity'] = $product_quantity;
} else if ( ! empty( $lead_value ) ) {
} elseif ( ! empty( $lead_value ) ) {

if ( empty( $quantity ) ) {
continue;
Expand All @@ -2841,8 +2851,8 @@ public static function get_product_fields( $form, $lead, $use_choice_text = fals
list( $name, $price ) = explode( '|', $lead_value );
}

$products[ $id ]['name'] = ! $use_choice_text ? $name : RGFormsModel::get_choice_text( $field, $name );
$include_field_label = apply_filters( 'gform_product_info_name_include_field_label', false );
$products[ $id ]['name'] = ! $use_choice_text ? $name : RGFormsModel::get_choice_text( $field, $name );
$include_field_label = apply_filters( 'gform_product_info_name_include_field_label', false );
if ( $field->inputType == ( 'radio' || 'select' ) && $include_field_label ) {
$products[ $id ]['name'] = $field->label . " ({$products[$id]['name']})";
}
Expand All @@ -2861,20 +2871,28 @@ public static function get_product_fields( $form, $lead, $use_choice_text = fals
foreach ( $option_value as $value ) {
$option_info = self::get_option_info( $value, $option, $use_choice_text );
if ( ! empty( $option_info ) ) {
$products[ $id ]['options'][] = array( 'field_label' => rgar( $option, 'label' ), 'option_name' => rgar( $option_info, 'name' ), 'option_label' => $option_label . ': ' . rgar( $option_info, 'name' ), 'price' => rgar( $option_info, 'price' ) );
$products[ $id ]['options'][] = array( 'field_label' => rgar( $option, 'label' ),
'option_name' => rgar( $option_info, 'name' ),
'option_label' => $option_label . ': ' . rgar( $option_info, 'name' ),
'price' => rgar( $option_info, 'price' )
);
}
}
} else if ( ! empty( $option_value ) ) {
$option_info = self::get_option_info( $option_value, $option, $use_choice_text );
$products[ $id ]['options'][] = array( 'field_label' => rgar( $option, 'label' ), 'option_name' => rgar( $option_info, 'name' ), 'option_label' => $option_label . ': ' . rgar( $option_info, 'name' ), 'price' => rgar( $option_info, 'price' ) );
} elseif ( ! empty( $option_value ) ) {
$option_info = self::get_option_info( $option_value, $option, $use_choice_text );
$products[ $id ]['options'][] = array( 'field_label' => rgar( $option, 'label' ),
'option_name' => rgar( $option_info, 'name' ),
'option_label' => $option_label . ': ' . rgar( $option_info, 'name' ),
'price' => rgar( $option_info, 'price' )
);
}
}
}
break;
}
}

$shipping_field = self::get_fields_by_type( $form, array( 'shipping' ) );
$shipping_field = GFAPI::get_fields_by_type( $form, array( 'shipping' ) );
$shipping_price = $shipping_name = '';
$shipping_field_id = '';
if ( ! empty( $shipping_field ) && ! RGFormsModel::is_field_hidden( $form, $shipping_field[0], array(), $lead ) ) {
Expand Down Expand Up @@ -3045,7 +3063,7 @@ private static function get_akismet_fields( $form, $lead ) {
}

private static function get_akismet_field( $field_type, $form, $lead ) {
$fields = GFCommon::get_fields_by_type( $form, array( $field_type ) );
$fields = GFAPI::get_fields_by_type( $form, array( $field_type ) );
if ( empty( $fields ) ) {
return '';
}
Expand Down Expand Up @@ -3987,7 +4005,7 @@ public static function get_field_filters_from_post( $form ) {
}

public static function has_multifile_fileupload_field( $form ) {
$fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload', 'post_custom_field' ) );
$fileupload_fields = GFAPI::get_fields_by_type( $form, array( 'fileupload', 'post_custom_field' ) );
if ( is_array( $fileupload_fields ) ) {
foreach ( $fileupload_fields as $field ) {
if ( $field->multipleFiles ) {
Expand Down Expand Up @@ -4030,6 +4048,7 @@ public static function send_resume_link( $message, $subject, $email, $embed_url,
$message_format = 'html';

$resume_url = add_query_arg( array( 'gf_token' => $resume_token ), $embed_url );
$resume_url = esc_url( $resume_url );
$resume_link = "<a href='{$resume_url}'>{$resume_url}</a>";
$message .= $resume_link;

Expand Down Expand Up @@ -4136,24 +4155,74 @@ public static function esc_like( $value ) {
}

public static function is_form_editor(){
return GFForms::get_page() == 'form_editor' || ( defined( 'DOING_AJAX' ) && DOING_AJAX && in_array( rgpost( 'action' ), array( 'rg_add_field', 'rg_refresh_field_preview', 'rg_duplicate_field', 'rg_delete_field', 'rg_change_input_type' ) ) );
$is_form_editor = GFForms::get_page() == 'form_editor' || ( defined( 'DOING_AJAX' ) && DOING_AJAX && in_array( rgpost( 'action' ), array( 'rg_add_field', 'rg_refresh_field_preview', 'rg_duplicate_field', 'rg_delete_field', 'rg_change_input_type' ) ) );
return apply_filters( 'gform_is_form_editor', $is_form_editor );
}

public static function is_entry_detail(){
return GFForms::get_page() == 'entry_detail_edit' || GFForms::get_page() == 'entry_detail' ;
$is_entry_detail = GFForms::get_page() == 'entry_detail_edit' || GFForms::get_page() == 'entry_detail' ;
return apply_filters( 'gform_is_entry_detail', $is_entry_detail );
}

public static function is_entry_detail_view(){
return GFForms::get_page() == 'entry_detail' ;
$is_entry_detail_view = GFForms::get_page() == 'entry_detail' ;
return apply_filters( 'gform_is_entry_detail_view', $is_entry_detail_view );
}

public static function is_entry_detail_edit(){
return GFForms::get_page() == 'entry_detail_edit';
$is_entry_detail_edit = GFForms::get_page() == 'entry_detail_edit';
return apply_filters( 'gform_is_entry_detail_edit', $is_entry_detail_edit );
}

public static function has_merge_tag( $string ) {
return preg_match( '/{.+}/', $string );
}

public static function get_upload_page_slug() {
$slug = get_option( 'gform_upload_page_slug' );
if ( empty( $slug ) ) {
$slug = substr( str_shuffle( wp_hash( microtime() ) ), 0, 15 );
update_option( 'gform_upload_page_slug', $slug );
}

return $slug;
}

/**
* Whitelists a value. Returns the value or the first value in the array.
*
* @param $value
* @param $whitelist
*
* @return mixed
*/
public static function whitelist( $value, $whitelist ) {

if ( ! in_array( $value, $whitelist ) ) {
$value = $whitelist[0];
}
return $value;
}

/**
* Forces an integer into a range of integers. Returns the value or the minimum if it's outside the range.
*
* @param $value
* @param $min
* @param $max
*
* @return int
*/
public static function int_range( $value, $min, $max ) {
$value = (int) $value;
$min = (int) $min;
$max = (int) $max;

return filter_var( $value, FILTER_VALIDATE_INT, array(
'min_range' => $min,
'max_range' => $max
) ) ? $value : $min;
}
}

class GFCategoryWalker extends Walker {
Expand Down
23 changes: 14 additions & 9 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -3088,6 +3088,19 @@ div.gf_entry_detail_pagination ul li.gf_entry_pagination a {
margin: 0;
}

div.gf_entry_wrap #poststuff .inside {
margin-top: 12px;
}

div.gf_entry_wrap #poststuff .inside .message,
div.gf_entry_wrap #poststuff .inside .updated {
margin: -12px -12px 12px -12px;
}

#notifications_container .message {
margin: -2px -15px 0 -15px;
}

/* entry paging ----------------------------------------------------*/

a.gf_entry_prev_link.gf_entry_pagination_link.gf_entry_pagination_link_inactive,
Expand Down Expand Up @@ -3682,6 +3695,7 @@ table.gforms_form_settings th {
padding: 8px 0;
}


.show_advanced_settings_container {
border-top: 1px solid #EEE;
padding: 5px;
Expand Down Expand Up @@ -4176,9 +4190,6 @@ li.gfield.gpage label.gfield_label {
overflow: hidden;
white-space: nowrap;
}
.message {
margin: 15px 0 0 !important;
}
.gform-filter-operator {
width: 100px;
}
Expand Down Expand Up @@ -4268,13 +4279,7 @@ span.ginput_right input.medium,
margin-right: 8px;
}

.gaddon-section .settings-field-map-table thead tr th {
border-bottom: 1px solid #ccc !important;
}

.gaddon-section .settings-field-map-table tbody tr td {
border-bottom: 1px dotted #eee !important;
}

/* resize the sub-settings tables for more verbose inputs ----------------------------------------------------*/

Expand Down
Loading

0 comments on commit 3ea999e

Please sign in to comment.