PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 2.05.09
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v2.05.09
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmEntryFormat.php

FrmEntryFormat.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 2.05.09, at classes/models/FrmEntryFormat.php

265 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class FrmEntryFormat {
4
5 /***********************************************************************
6 * Deprecated Functions
7 ************************************************************************/
8
9 /**
10 * @deprecated 2.03.04
11 */
12 public static function textarea_display_value() {
13 _deprecated_function( __FUNCTION__, '2.03.04', 'custom code' );
14 }
15
16 /**
17 * @deprecated 2.04
18 */
19 public static function single_html_row( $atts, &$content ) {
20 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
21 }
22
23 /**
24 * @deprecated 2.04
25 *
26 * @param stdClass $field
27 * @param array|string $val
28 */
29 public static function flatten_multi_file_upload( $field, &$val ) {
30 if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) {
31 $val = FrmAppHelper::array_flatten( $val );
32 }
33
34 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
35 }
36
37 /**
38 * @deprecated 2.04
39 */
40 public static function fill_entry_user_info() {
41 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
42 }
43
44 /**
45 * @deprecated 2.04
46 */
47 public static function get_entry_description_data() {
48 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
49
50 return array();
51 }
52
53 /**
54 * @deprecated 2.04
55 */
56 public static function single_plain_text_row() {
57 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
58 }
59
60 /**
61 * @deprecated 2.04
62 */
63 public static function html_field_row() {
64 _deprecated_function( __FUNCTION__, '2.04', 'custom code' );
65 }
66
67 /**
68 * @deprecated 2.04
69 */
70 public static function fill_entry_values( $atts, $f, array &$values ) {
71 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
72
73 $no_save_field = FrmField::is_no_save_field( $f->type );
74 if ( $no_save_field ) {
75 if ( ! in_array( $f->type, $atts['include_extras'] ) ) {
76 return;
77 }
78 $atts['include_blank'] = true;
79 }
80
81 if ( $atts['default_email'] ) {
82 self::get_field_shortcodes_for_default_email( $f, $values );
83 return;
84 }
85
86 $atts['field'] = $f;
87
88 self::fill_missing_fields( $atts, $values );
89
90 $val = '';
91 self::get_field_value( $atts, $val );
92
93 // Don't include blank values
94 if ( ! $atts['include_blank'] && FrmAppHelper::is_empty_value( $val ) ) {
95 return;
96 }
97
98 self::prepare_field_output( $atts, $val );
99
100 if ( $atts['format'] != 'text' ) {
101 $values[ $f->field_key ] = $val;
102 if ( $atts['entry'] && $f->type != 'textarea' ) {
103 $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
104 if ( $prev_val != $val ) {
105 $values[ $f->field_key . '-value' ] = $prev_val;
106 }
107 }
108 } else {
109 $values[ $f->id ] = array(
110 'label' => $f->name,
111 'val' => $val,
112 'type' => $f->type,
113 );
114 }
115 }
116
117 /**
118 * @deprecated 2.04
119 */
120 private static function fill_missing_fields( $atts, &$values ) {
121 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
122
123 if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
124 // In case include_blank is set
125 $atts['entry']->metas[ $atts['field']->id ] = '';
126 $atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
127 self::fill_values_from_entry( $atts, $values );
128 }
129 }
130
131 /**
132 * @deprecated 2.04
133 */
134 public static function fill_values_from_entry( $atts, &$values ) {
135 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
136
137 $values = apply_filters( 'frm_prepare_entry_array', $values, $atts );
138 }
139
140 /**
141 * @deprecated 2.04
142 */
143 public static function get_field_shortcodes_for_default_email( $f, &$values ) {
144 // TODO: adjust this message
145 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
146
147 $field_shortcodes = array(
148 'label' => '[' . $f->id . ' show=field_label]',
149 'val' => '[' . $f->id . ']',
150 'type' => $f->type,
151 );
152
153 $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
154 }
155
156 /**
157 * @deprecated 2.04
158 */
159 private static function get_field_value( $atts, &$val ) {
160 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
161
162 $f = $atts['field'];
163 if ( $atts['entry'] ) {
164 $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
165 $meta = array(
166 'item_id' => $atts['id'],
167 'field_id' => $f->id,
168 'meta_value' => $prev_val,
169 'field_type' => $f->type,
170 );
171
172 //This filter applies to the default-message shortcode and frm-show-entry shortcode only
173 if ( in_array( $f->type, array( 'html', 'divider', 'break' ) ) ) {
174 $val = apply_filters( 'frm_content', $f->description, $atts['form_id'], $atts['entry'] );
175 } elseif ( isset( $atts['filter'] ) && $atts['filter'] == false ) {
176 $val = $prev_val;
177 } else {
178 $email_value_atts = array(
179 'field' => $f,
180 'format' => $atts['format'],
181 );
182 $val = apply_filters( 'frm_email_value', $prev_val, (object) $meta, $atts['entry'], $email_value_atts );
183 }
184 }
185 }
186
187 /**
188 * @since 2.03.02
189 *
190 * @deprecated 2.04
191 */
192 public static function prepare_field_output( $atts, &$val ) {
193 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
194
195 $val = apply_filters( 'frm_display_' . $atts['field']->type . '_value_custom', $val, array(
196 'field' => $atts['field'],
197 'atts' => $atts,
198 ) );
199
200 self::flatten_array_value( $atts, $val );
201 self::maybe_strip_html( $atts['plain_text'], $val );
202 }
203
204 /**
205 * @since 2.03.02
206 *
207 * @deprecated 2.04
208 */
209 private static function flatten_array_value( $atts, &$val ) {
210 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
211
212 if ( is_array( $val ) ) {
213 if ( $atts['format'] == 'text' ) {
214 $val = implode( ', ', $val );
215 } else if ( $atts['field']->type == 'checkbox' ) {
216 $val = array_values( $val );
217 }
218 }
219 }
220
221 /**
222 * Strip HTML if from email value if plain text is selected
223 *
224 * @since 2.0.21
225 * @param boolean $plain_text
226 * @param mixed $val
227 *
228 * @deprecated 2.04
229 */
230 private static function maybe_strip_html( $plain_text, &$val ) {
231 _deprecated_function( __FUNCTION__, '2.04', 'instance of FrmEntryValues or FrmProEntryValues' );
232
233 if ( $plain_text && ! is_array( $val ) ) {
234 if ( strpos( $val, '<img' ) !== false ) {
235 $val = str_replace( array( '<img', 'src=', '/>', '"' ), '', $val );
236 $val = trim( $val );
237 }
238 $val = strip_tags( $val );
239 }
240 }
241
242 /**
243 * @deprecated 2.04
244 */
245 public static function get_browser( $u_agent ) {
246 _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesHelper::get_browser' );
247 return FrmEntriesHelper::get_browser( $u_agent );
248 }
249
250 /**
251 * @deprecated 2.04
252 */
253 public static function show_entry( $atts ) {
254 _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesController::show_entry_shortcode' );
255 return FrmEntriesController::show_entry_shortcode( $atts );
256 }
257
258 /**
259 * @deprecated 2.04
260 */
261 public static function convert_entry_to_content() {
262 _deprecated_function( __FUNCTION__, '2.04', 'FrmEntriesController::show_entry_shortcode' );
263 }
264 }
265