PluginProbe
Repeater Fields for Gravity Forms / 2.3.2
Repeater Fields for Gravity Forms v2.3.2
3.2.0 3.1.1 3.1.0 3.0.4 3.0.3 3.0.2 3.0.1 3.0.0 2.5.1 2.5.0 2.4.6 trunk 2.0.5 2.0.9 2.1.0 2.3.2 2.3.7 2.4.1 2.4.3 2.4.4 2.4.5
← All changes | fields/repeater_field.php +0 -783 2.4.62.3.2 View file →
@@ -1,783 +1,0 @@
1 -<?php
2 -// If Gravity Forms isn't loaded, bail.
3 -if (!class_exists('GFForms')) {
4 - die();
5 -}
6 -/**
7 - * Class GF_Field_Phone
8 - *
9 - * Handles the behavior of Phone fields.
10 - *
11 - * @since Unknown
12 - */
13 -class Superaddons_GFRepeater_Field extends GF_Field
14 -{
15 - private $lead_id = null;
16 - /**
17 - * Defines the field type.
18 - *
19 - * @since Unknown
20 - * @access public
21 - *
22 - * @var string The field type.
23 - */
24 - public $type = 'repeater_end';
25 - public $list_fields_validate = array();
26 - /**
27 - * Defines the field title to be used in the form editor.
28 - *
29 - * @since Unknown
30 - * @access public
31 - *
32 - * @used-by GFCommon::get_field_type_title()
33 - *
34 - * @return string The field title. Translatable and escaped.
35 - */
36 - public function get_form_editor_field_title()
37 - {
38 - return esc_attr__('Repeater end', 'repeater-for-gravity-forms');
39 - }
40 - public function get_form_editor_button()
41 - {
42 - return array(
43 - 'group' => 'advanced_fields',
44 - 'text' => $this->get_form_editor_field_title()
45 - );
46 - }
47 - /**
48 - * Defines the field settings available within the field editor.
49 - *
50 - * @since Unknown
51 - * @access public
52 - *
53 - * @return array The field settings available for the field.
54 - */
55 - function get_form_editor_field_settings()
56 - {
57 - return array(
58 - 'conditional_logic_field_setting',
59 - 'prepopulate_field_setting',
60 - 'error_message_setting',
61 - 'label_setting',
62 - 'field_field_repeater_end_text_setting',
63 - 'field_field_repeater_initial_rows_setting',
64 - 'field_field_repeater_max_setting',
65 - 'label_placement_setting',
66 - 'admin_label_setting',
67 - 'size_setting',
68 - 'rules_setting',
69 - 'visibility_setting',
70 - 'duplicate_setting',
71 - 'placeholder_setting',
72 - 'description_setting',
73 - 'css_class_setting',
74 - );
75 - }
76 - /**
77 - * Defines if conditional logic is supported in this field type.
78 - *
79 - * @since Unknown
80 - * @access public
81 - *
82 - * @used-by GFFormDetail::inline_scripts()
83 - * @used-by GFFormSettings::output_field_scripts()
84 - *
85 - * @return bool true
86 - */
87 - public function is_conditional_logic_supported()
88 - {
89 - return false;
90 - }
91 - /**
92 - * Returns the field input.
93 - *
94 - * @since Unknown
95 - * @access public
96 - *
97 - * @used-by GFCommon::get_field_input()
98 - * @uses GF_Field::is_entry_detail()
99 - * @uses GF_Field::is_form_editor()
100 - * @uses GF_Field_Phone::$failed_validation
101 - * @uses GF_Field_Phone::get_phone_format()
102 - * @uses GFFormsModel::is_html5_enabled()
103 - * @uses GF_Field::get_field_placeholder_attribute()
104 - * @uses GF_Field_Phone::$isRequired
105 - * @uses GF_Field::get_tabindex()
106 - *
107 - * @param array $form The Form Object.
108 - * @param string $value The value of the input. Defaults to empty string.
109 - * @param null|array $entry The Entry Object. Defaults to null.
110 - *
111 - * @return string The HTML markup for the field.
112 - */
113 - public function get_field_input($form, $value = '', $entry = null)
114 - {
115 - if (is_array($value)) {
116 - $value = '';
117 - }
118 - $is_entry_detail = $this->is_entry_detail();
119 - $is_form_editor = $this->is_form_editor();
120 - $form_id = $form['id'];
121 - $id = intval($this->id);
122 - $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id";
123 - $size = $this->size;
124 - $disabled_text = $is_form_editor ? "disabled='disabled'" : '';
125 - $class_suffix = $is_entry_detail ? '_admin' : '';
126 - $class = $size . $class_suffix . " gf-field-repeater-data hidden";
127 - $class = esc_attr($class);
128 - $instruction_div = '';
129 - $html_input_type = 'hidden';
130 - $placeholder_attribute = $this->get_field_placeholder_attribute();
131 - $required_attribute = $this->isRequired ? 'aria-required="true"' : '';
132 - $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
133 - $aria_describedby = $this->get_aria_describedby();
134 - $tabindex = $this->get_tabindex();
135 - $repeater_add_button = $this->field_repeater_end_text;
136 - if ($repeater_add_button == "") {
137 - $repeater_add_button = esc_attr__("Add more", "gravityforms-repeater");
138 - }
139 - $initial_rows = $this->repeater_initial_rows;
140 - if ($initial_rows == "") {
141 - $initial_rows = 1;
142 - }
143 - $limit = $this->repeater_max;
144 - if ($limit == "" or $limit < 1) {
145 - $limit = 9999;
146 - }
147 - $limit = apply_filters("yeeaddons_gf_repeater_limit", 5, $limit);
148 - $initial_rows = apply_filters("yeeaddons_gf_repeater_initial_rows", 1, $initial_rows);
149 - $input = "<input data-initial_rows_map_check='" . $this->repeater_initial_rows_map . "' data-initial_rows_map='input_{$form_id}_" . $this->repeater_initial_rows_map . "' data-map_id='field_" . $form_id . "_" . $id . "' name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>";
150 - $html = '<div data-initial_rows_map_check="' . $this->repeater_initial_rows_map . '" class="repeater-field-warp-item-data" data-initial_rows="' . $initial_rows . '" data-limit="' . $limit . '" data-initial_rows_map="input_' . $form_id . '_' . $this->repeater_initial_rows_map . '" data-map_id="field_' . $form_id . '_' . $id . '">
151 - <div class="repeater-field-warp-item">
152 - </div>
153 - <div class="repeater-field-footer"><a href="#"" class="gf-repeater-field-button-add" >' . $repeater_add_button . '</a></div>
154 - ' . $input . '
155 - <input type="hidden" class="gf-field-repeater-data-html hidden" />
156 - </div>';
157 - if (is_admin()) {
158 - $html = '<hr>End Repeater<hr>';
159 - return sprintf("<div class='ginput_container1'>%s</div>", $html);
160 - } else {
161 - return sprintf("<div class='ginput_container'>%s</div>", $html);
162 - }
163 - }
164 - public static function remove_validation($form)
165 - {
166 - $zo = false;
167 - $zo_datas = array();
168 - foreach ($form["fields"] as $field) {
169 - $type = $field->type;
170 - if ($type == "repeater_start") {
171 - $zo = true;
172 - continue;
173 - }
174 - if ($type == "repeater_end") {
175 - $zo = false;
176 - continue;
177 - }
178 - if ($zo) {
179 - if (!isset($field->repeater_validate)) {
180 - $field->repeater_validate = array("isRequired" => $field->isRequired);
181 - }
182 - $field->isRequired = false;
183 - }
184 - }
185 - return $form;
186 - }
187 - function validate($value, $form)
188 - {
189 - $datas = json_decode($value, true);
190 - $list_fields_validate = array();
191 - $failedValidation = false;
192 - foreach ($form["fields"] as $field) {
193 - if (is_array($field->repeater_validate)) {
194 - foreach ($field->repeater_validate as $k => $v) {
195 - if ($k == "isRequired" && $v == true) {
196 - $list_fields_validate["input_" . $field->id] = $field->type;
197 - }
198 - }
199 - }
200 - }
201 - if (isset($datas["id"]) && is_array($datas["id"])) {
202 - // Check if file upload is attempted without the Pro version activated
203 - if (!class_exists('Yeeaddons_Upgrade_GF_Repeater_Plugin')) {
204 - $is_fileupload_attempt = false;
205 - foreach ($datas["id"] as $id) {
206 - foreach ($datas["fields"] as $field) {
207 - if ($field == "") {
208 - continue;
209 - }
210 - $field = str_replace('[]', '', $field);
211 - $input_name = $field . "__" . $id;
212 - // Standard file upload
213 - if (isset($_FILES[$input_name]) && !empty($_FILES[$input_name]['name']) && (is_array($_FILES[$input_name]['name']) ? !empty(array_filter($_FILES[$input_name]['name'])) : true)) {
214 - $is_fileupload_attempt = true;
215 - break 2;
216 - }
217 - // Multi-file upload (Ajax/plupload)
218 - if (strpos($field, 'gform_multifile_upload_') === 0 && !empty($_POST[$input_name])) {
219 - $is_fileupload_attempt = true;
220 - break 2;
221 - }
222 - }
223 - }
224 - if ($is_fileupload_attempt) {
225 - $this->failed_validation = true;
226 - $this->validation_message = esc_html__('File upload in repeater is only supported in the Pro version.', 'repeater-for-gravity-forms');
227 - return;
228 - }
229 - }
230 -
231 - foreach ($datas["id"] as $id) {
232 - foreach ($datas["fields"] as $field) {
233 - if ($field == "") {
234 - continue;
235 - }
236 - $field = str_replace('[]', '', $field);
237 - if (isset($list_fields_validate[$field])) {
238 - $getInputData = rgpost($field . "__" . $id);
239 - switch ($list_fields_validate[$field]) {
240 - case "name":
241 - $first_name = rgpost($field . "_3__" . $id);
242 - $last_name = rgpost($field . "_6__" . $id);
243 - if (empty($first_name) || empty($last_name)) {
244 - $failedValidation = true;
245 - }
246 - break;
247 - case 'address':
248 - $address = rgpost($field . "_1__" . $id);
249 - if (empty($address)) {
250 - $failedValidation = true;
251 - }
252 - break;
253 - case 'fileupload':
254 - if (isset($_FILES[$field . "__" . $id]) && $_FILES[$field . "__" . $id]['name'][0]) {
255 - //file uploaded
256 - } else {
257 - $failedValidation = true;
258 - }
259 - break;
260 - default:
261 - if (is_array($getInputData)) {
262 - foreach ($getInputData as $vl) {
263 - if (empty($vl)) {
264 - $failedValidation = true;
265 - }
266 - }
267 - } else {
268 - if (empty($getInputData)) {
269 - $failedValidation = true;
270 - }
271 - }
272 - break;
273 - }
274 - }
275 - }
276 - }
277 - if ($failedValidation) {
278 - $this->failed_validation = true;
279 - if ($this->errorMessage) {
280 - $this->validation_message = $this->errorMessage;
281 - } else {
282 - $this->validation_message = esc_html__('This field is required.', 'gravityforms');
283 - }
284 - return;
285 - } else {
286 - $this->failed_validation = false;
287 - }
288 - }
289 - }
290 - function custom_validation($form)
291 - {
292 - $dataRepeater = array();
293 - $zo = false;
294 - $zo_datas = array();
295 - foreach ($form["fields"] as $field) {
296 - $type = $field->type;
297 - if ($type == "repeater_start") {
298 - $zo = true;
299 - continue;
300 - }
301 - if ($zo) {
302 - $zo_datas[$field->id] = array("isRequired" => $field->isRequired);
303 - $field->isRequired = false;
304 - }
305 - if ($type == "repeater_end") {
306 - $zo = false;
307 - $zo_datas = array();
308 - continue;
309 - }
310 - }
311 - return $form;
312 - }
313 - /**
314 - * Gets the value of the submitted field.
315 - *
316 - * @since Unknown
317 - * @access public
318 - *
319 - * @used-by GFFormsModel::get_field_value()
320 - * @uses GF_Field::get_value_submission()
321 - * @uses GF_Field_Phone::sanitize_entry_value()
322 - *
323 - * @param array $field_values The dynamic population parameter names with their corresponding values to be populated.
324 - * @param bool $get_from_post_global_var Whether to get the value from the $_POST array as opposed to $field_values. Defaults to true.
325 - *
326 - * @return array|string
327 - */
328 - public function get_value_submission($field_values, $get_from_post_global_var = true)
329 - {
330 - $value = parent::get_value_submission($field_values, $get_from_post_global_var);
331 - $value = $this->sanitize_entry_value($value, $this->formId);
332 - return $value;
333 - }
334 - /**
335 - * Sanitizes the entry value.
336 - *
337 - * @since Unknown
338 - * @access public
339 - *
340 - * @used-by GF_Field_Phone::get_value_save_entry()
341 - * @used-by GF_Field_Phone::get_value_submission()
342 - *
343 - * @param string $value The value to be sanitized.
344 - * @param int $form_id The form ID of the submitted item.
345 - *
346 - * @return string The sanitized value.
347 - */
348 - public function sanitize_entry_value($value, $form_id)
349 - {
350 - $value = is_array($value) ? array_map('sanitize_text_field', $value) : sanitize_text_field($value);
351 - return $value;
352 - }
353 - /**
354 - * Gets the field value when an entry is being saved.
355 - *
356 - * @since Unknown
357 - * @access public
358 - *
359 - * @used-by GFFormsModel::prepare_value()
360 - * @uses GF_Field_Phone::sanitize_entry_value()
361 - * @uses GF_Field_Phone::$phoneFormat
362 - *
363 - * @param string $value The input value.
364 - * @param array $form The Form Object.
365 - * @param string $input_name The input name.
366 - * @param int $lead_id The Entry ID.
367 - * @param array $lead The Entry Object.
368 - *
369 - * @return string The field value.
370 - */
371 - public function get_value_save_entry($value, $form, $input_name, $lead_id, $lead)
372 - {
373 - $this->lead_id = $lead_id;
374 - $datas = json_decode($value, true);
375 - //var_dump($value);
376 - $values = array();
377 - $form_id = $this->formId;
378 - $get_form = GFFormsModel::get_form_meta_by_id($form_id);
379 - $form = $get_form[0];
380 - $fields = array();
381 - foreach ($datas["fields"] as $f) {
382 - $datas_f = explode(".", $f);
383 - $fields[] = $datas_f[0];
384 - }
385 - $fields = array_unique($fields);
386 - foreach ($datas["id"] as $id_rand) {
387 - $datas_step = array();
388 - foreach ($fields as $field) {
389 - $field = str_replace("[]", "", $field);
390 - $inputs = $this->get_inputs($form, $field);
391 - if (is_array($inputs)) {
392 - $getInputData = array();
393 - foreach ($inputs as $child_input) {
394 - $getInputName = "input_" . $child_input["id"] . "__" . $id_rand;
395 - $vl = rgpost(str_replace('.', '_', strval($getInputName)));
396 - if ($vl != "") {
397 - $getInputData[$child_input["id"]] = $vl;
398 - }
399 - }
400 - $datas_step[$getInputName] = $getInputData;
401 - } else {
402 - $getInputName = $field . "__" . $id_rand;
403 - if (isset($_FILES[$getInputName])) {
404 - $datas_step[$getInputName] = apply_filters("yeeaddons_gf_repeater_file", "Upgrade to pro version", $form_id, $_FILES[$getInputName]);
405 - } else if (isset($_POST[$getInputName])) {
406 - $datas_step[$getInputName] = rgpost(str_replace('.', '_', strval($getInputName)));
407 - } else {
408 - $getInputData = rgpost(str_replace('.', '_', strval($getInputName)));
409 - $datas_step[$getInputName] = $getInputData;
410 - }
411 - }
412 - }
413 - $values[$id_rand] = $datas_step;
414 - }
415 - return maybe_serialize($values);
416 - }
417 - public function upload_file($form_id, $file)
418 - {
419 - $target = GFFormsModel::get_file_upload_path($form_id, $file['name']);
420 - if (!$target) {
421 - return 'FAILED (Upload folder could not be created.)';
422 - }
423 - if (move_uploaded_file($file['tmp_name'], $target['path'])) {
424 - $this->set_permissions($target['path']);
425 - return $target['url'];
426 - } else {
427 - return 'FAILED (Temporary file could not be copied.)';
428 - }
429 - }
430 - function set_permissions($path)
431 - {
432 - GFFormsModel::set_permissions($path);
433 - }
434 - public function get_value_entry_list($value, $entry, $field_id, $columns, $form)
435 - {
436 - if (empty($value)) {
437 - return '';
438 - } else {
439 - $dataArray = GFFormsModel::unserialize($value);
440 - $arrayCount = count($dataArray);
441 - if ($arrayCount > 1) {
442 - $returnText = $arrayCount . ' entries';
443 - } else {
444 - $returnText = $arrayCount . ' entry';
445 - }
446 - return $returnText;
447 - }
448 - }
449 - function get_datas_field($format = "html", $value = '', $form_id = "")
450 - {
451 - global $wpdb;
452 - $dataArray = GFFormsModel::unserialize($value);
453 - $get_form = GFFormsModel::get_form_meta_by_id($form_id);
454 - $form = $get_form[0];
455 - if (isset($_GET['lid'])) {
456 - $result = GFAPI::get_entry($_GET['lid']);
457 - } else {
458 - $table = $wpdb->prefix . "gf_entry";
459 - $mylink = $wpdb->get_row("SELECT id FROM $table ORDER BY id DESC");
460 - $result = GFAPI::get_entry($mylink->id);
461 - }
462 - if ($format === 'html') {
463 - $html = '<ol>';
464 - foreach ($dataArray as $step_datas) {
465 - $html .= '<li><ul>';
466 - foreach ($step_datas as $name => $vl) {
467 - $type = $this->get_type($form, $name, $form_id);
468 - $lb = $this->get_field_label($form, $name, $type, false, $form_id);
469 - if (is_array($vl)) {
470 - switch ($type) {
471 - case "address":
472 - $vl_data = "";
473 - foreach ($vl as $k => $v) {
474 - $child_lb = $this->get_field_label($form, "input_" . $k, $type, true);
475 - $vl_data .= $child_lb . ": " . $v . "<br>";
476 - }
477 - $html .= '<li>' . $lb . ": <br>" . $vl_data . "</li>";
478 - break;
479 - default:
480 - $vl_data = implode(", ", $vl);
481 - $html .= '<li>' . $lb . ": " . $vl_data . "</li>";
482 - break;
483 - }
484 - } else {
485 - $vl_data = $vl;
486 - switch ($type) {
487 - case "fileupload":
488 - if ($vl_data == "Upgrade to pro version") {
489 - $html .= '<li>' . $lb . ": " . $vl_data . "</li>";
490 - } else {
491 - if (filter_var($vl_data, FILTER_VALIDATE_URL) === FALSE) {
492 - $content = array();
493 - $parts = array_map('trim', explode(",", $vl_data));
494 - $is_urls = true;
495 - foreach ($parts as $part) {
496 - if (empty($part) || filter_var($part, FILTER_VALIDATE_URL) === FALSE) {
497 - $is_urls = false;
498 - break;
499 - }
500 - }
501 - if ($is_urls) {
502 - foreach ($parts as $part) {
503 - $filename = basename($part);
504 - $content[] = '<a href="' . esc_url($part) . '" download>' . esc_html($filename) . '</a>';
505 - }
506 - $html .= '<li>' . $lb . ': ' . implode(" | ", $content) . "</li>";
507 - } else {
508 - $main_name = explode("__", $name);
509 - $main_name = explode("_", $main_name[0]);
510 - if (isset($main_name[4])) {
511 - $main_name_id = $main_name[4];
512 - } else {
513 - $main_name_id = $main_name[1];
514 - }
515 - if (isset($result[$main_name_id])) {
516 - $data_uploads = json_decode($result[$main_name_id], true);
517 - if (!is_array($data_uploads)) {
518 - $data_uploads = explode(",", $data_uploads);
519 - }
520 - if (!is_array($data_uploads)) {
521 - $data_uploads = array();
522 - }
523 - foreach ($parts as $n) {
524 - $n = sanitize_file_name($n);
525 - foreach ($data_uploads as $name) {
526 - $name_s = explode(".", $n);
527 - $name_s = $name_s[0];
528 - $re = "/" . $name_s . "\.|" . $name_s . "[\d]\./";
529 - if (preg_match($re, $name)) {
530 - $content[] = '<a href="' . $name . '" download>' . $n . "</a> ";
531 - break;
532 - }
533 - }
534 - }
535 - }
536 - $html .= '<li>' . $lb . ': ' . implode(" | ", $content) . "</li>";
537 - }
538 - } else {
539 - $html .= '<li>' . $lb . ': <a href="' . $vl_data . '" download>' . $vl_data . "</a></li>";
540 - }
541 - }
542 - break;
543 - default:
544 - $html .= '<li>' . $lb . ": " . $vl_data . "</li>";
545 - break;
546 - }
547 - }
548 - }
549 - $html .= '</ul></li>';
550 - }
551 - $html .= '<ol>';
552 - $html = apply_filters("yeeadons_gravity_forms_repeater_html", $html, $dataArray, $form);
553 - return $html;
554 - } else {
555 - $html = '';
556 - foreach ($dataArray as $step_datas) {
557 - foreach ($step_datas as $name => $vl) {
558 - $type = $this->get_type($form, $name, $form_id);
559 - $lb = $this->get_field_label($form, $name, $type, false, $form_id);
560 - if (is_array($vl)) {
561 - switch ($type) {
562 - case "address":
563 - $vl_data = "";
564 - foreach ($vl as $k => $v) {
565 - $child_lb = $this->get_field_label($form, "input_" . $k, $type, true);
566 - $vl_data .= $child_lb . ": " . $v . "\n";
567 - }
568 - $html .= $lb . " : " . $vl_data . "\n";
569 - break;
570 - default:
571 - $vl_data = implode(", ", $vl);
572 - $html .= $lb . ": " . $vl_data . "\n";
573 - break;
574 - }
575 - } else {
576 - $vl_data = $vl;
577 - switch ($type) {
578 - case "fileupload":
579 - if (filter_var($vl_data, FILTER_VALIDATE_URL) === FALSE) {
580 - $content = array();
581 - $parts = array_map('trim', explode(",", $vl_data));
582 - $is_urls = true;
583 - foreach ($parts as $part) {
584 - if (empty($part) || filter_var($part, FILTER_VALIDATE_URL) === FALSE) {
585 - $is_urls = false;
586 - break;
587 - }
588 - }
589 - if ($is_urls) {
590 - foreach ($parts as $part) {
591 - $filename = basename($part);
592 - $content[] = '<a href="' . esc_url($part) . '" download>' . esc_html($filename) . '</a>';
593 - }
594 - $html .= $lb . ': ' . implode(" | ", $content) . "\n";
595 - } else {
596 - $main_name = explode("__", $name);
597 - $main_name = explode("_", $main_name[0]);
598 - $main_name_id = $main_name[4];
599 - if (isset($result[$main_name_id])) {
600 - $data_uploads = json_decode($result[$main_name_id], true);
601 - foreach ($parts as $n) {
602 - $n = sanitize_file_name($n);
603 - foreach ($data_uploads as $name) {
604 - $name_s = explode(".", $n);
605 - $name_s = $name_s[0];
606 - $re = "/" . $name_s . "\.|" . $name_s . "[\d]\./";
607 - if (preg_match($re, $name)) {
608 - $content[] = '<a href="' . $name . '" download>' . $n . "</a> ";
609 - break;
610 - }
611 - }
612 - }
613 - }
614 - $html .= $lb . ': ' . implode(" | ", $content) . "\n";
615 - }
616 - } else {
617 - $html .= $lb . ':' . $vl_data . "\n";
618 - }
619 - break;
620 - default:
621 - $html .= $lb . ": " . $vl_data . "\n";
622 - break;
623 - }
624 - }
625 - }
626 - $html .= "\n";
627 - }
628 - $html = apply_filters("yeeadons_gravity_forms_repeater_text", $html, $dataArray, $form);
629 - return $html;
630 - }
631 - }
632 - public function get_value_export($entry, $input_id = '', $use_text = false, $is_csv = false)
633 - {
634 - //Export doesn’t require encoding, but field data may require some manipulation or formatting before it is exported
635 - $form_id = $entry["form_id"];
636 - $return = $this->get_datas_field("text", rgar($entry, $input_id), $form_id);
637 - return $return;
638 - }
639 - public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
640 - {
641 - if (empty($value)) {
642 - return '';
643 - }
644 - $form_id = isset($form['id']) ? absint($form['id']) : null;
645 - $return = $this->get_datas_field($format, $value, $form_id);
646 - return $return;
647 - }
648 - public function get_value_entry_detail($value, $currency = '', $use_text = false, $format = 'html', $media = 'screen')
649 - {
650 - global $wpdb;
651 - if (empty($value)) {
652 - return '';
653 - } else {
654 - $form_id = $this->formId;
655 - $return = $this->get_datas_field($format, $value, $form_id);
656 - return $return;
657 - }
658 - }
659 - function get_field_label($form, $name = '', $type = '', $child = false, $form_id = '')
660 - {
661 - if (is_array($form)) {
662 - if (!array_key_exists('fields', $form)) {
663 - return false;
664 - }
665 - } else {
666 - return false;
667 - }
668 - $name = str_replace("gform_multifile_upload_" . $form_id, "input", $name);
669 - $names = explode("__", $name);
670 - $names = explode("_", $names[0]);
671 - $name = $names[1];
672 - foreach ($form['fields'] as $field_key => $field_value) {
673 - if (is_array($field_value->inputs)) {
674 - foreach ($field_value->inputs as $children_id) {
675 - if ($children_id["id"] == $name) {
676 - if ($child) {
677 - return $children_id["label"];
678 - } else {
679 - return $field_value->label;
680 - }
681 - }
682 - }
683 - } else {
684 - if ($field_value->id == $name) {
685 - return $field_value->label;
686 - }
687 - }
688 - }
689 - return "";
690 - }
691 - function get_inputs($form, $name = '')
692 - {
693 - if (is_array($form)) {
694 - if (!array_key_exists('fields', $form)) {
695 - return false;
696 - }
697 - } else {
698 - return false;
699 - }
700 - $names = explode("__", $name);
701 - $names = explode("_", $names[0]);
702 - $name = $names[1];
703 - foreach ($form['fields'] as $field_key => $field_value) {
704 - if ($field_value->id == $name) {
705 - if ($field_value->type == "date") {
706 - return $name;
707 - }
708 - if (is_array($field_value->inputs)) {
709 - return $field_value->inputs;
710 - }
711 - }
712 - }
713 - return false;
714 - }
715 - function get_type($form, $name = '', $form_id = "")
716 - {
717 - if (is_array($form)) {
718 - if (!array_key_exists('fields', $form)) {
719 - return false;
720 - }
721 - } else {
722 - return false;
723 - }
724 - $name = str_replace("gform_multifile_upload_" . $form_id, "input", $name);
725 - $names = explode("__", $name);
726 - $names = explode("_", $names[0]);
727 - $name = $names[1];
728 - foreach ($form['fields'] as $field_key => $field_value) {
729 - if (is_array($field_value->inputs)) {
730 - foreach ($field_value->inputs as $children_id) {
731 - if ($children_id["id"] == $name) {
732 - return $field_value->type;
733 - }
734 - }
735 - } else {
736 - if ($field_value->id == $name) {
737 - return $field_value->type;
738 - }
739 - }
740 - }
741 - return "";
742 - }
743 -
744 - public static function remove_child_fields($form)
745 - {
746 - if (!is_admin()) {
747 - return $form;
748 - }
749 -
750 - $page = isset($_GET['page']) ? $_GET['page'] : '';
751 - $gf_page = isset($_GET['gf_page']) ? $_GET['gf_page'] : '';
752 -
753 - $target_pages = array('gf_entries', 'gf_export');
754 - $target_gf_pages = array('select_columns', 'print-entry');
755 -
756 - if (in_array($page, $target_pages) || in_array($gf_page, $target_gf_pages)) {
757 - $fields = array();
758 - $zo = false;
759 - foreach ($form["fields"] as $field) {
760 - $type = $field->type;
761 - if ($type == "repeater_start") {
762 - $zo = true;
763 - $fields[] = $field;
764 - continue;
765 - }
766 - if ($type == "repeater_end") {
767 - $zo = false;
768 - $fields[] = $field;
769 - continue;
770 - }
771 - if ($zo) {
772 - continue;
773 - }
774 - $fields[] = $field;
775 - }
776 - $form["fields"] = $fields;
777 - }
778 -
779 - return $form;
780 - }
781 -}
782 -// Register the phone field with the field framework.
783 -GF_Fields::register(new Superaddons_GFRepeater_Field());