芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/public_html/wp-content/plugins/fluentform/app/Modules/Form/FormDataParser.php
user_inputs = static::parseData( json_decode($entry->response), $fields, $form->id, $isHtml ); return $entry; } public static function parseFormSubmission($submission, $form, $fields, $isHtml = false) { // Sometimes submission will change inside loop. So we need to parse submission data for new one $newSubmission = $submission->id != static::$submissionId; if (is_null(static::$data) || $newSubmission) { static::$data = static::parseData( json_decode($submission->response), $fields, $form->id, $isHtml ); static::$submissionId = $submission->id; } $submission->user_inputs = static::$data; return $submission; } public static function parseData($response, $fields, $formId, $isHtml = false) { $trans = []; foreach ($fields as $field_key => $field) { if (isset($response->{$field_key})) { $value = $response->{$field_key}; $value = apply_filters_deprecated( 'fluentform_response_render_' . $field['element'], [ $value, $field, $formId, $isHtml ], FLUENTFORM_FRAMEWORK_UPGRADE, 'fluentform/response_render_' . $field['element'], 'Use fluentform/response_render_' . $field['element'] . ' instead of fluentform_response_render_' . $field['element'] ); $value = apply_filters( 'fluentform/response_render_' . $field['element'], $value, $field, $formId, $isHtml ); $trans[$field_key] = $value; } else { $trans[$field_key] = ''; } } return $trans; } public static function formatValue($value) { if (is_array($value) || is_object($value)) { return fluentImplodeRecursive(', ', array_filter(array_values((array) $value))); } return $value; } public static function formatFileValues($values, $isHtml, $form_id = null) { if (!$values) { return $values; } if (is_string($values)) { return $values; } if (!$isHtml) { return fluentImplodeRecursive(', ', array_filter(array_values((array) $values))); } if ($form_id && \FluentForm\App\Helpers\Helper::isEntryAutoDeleteEnabled($form_id)) { return ''; } $html = '
'; foreach ($values as $value) { if (!$value) { continue; } $html .= '
' . basename($value) . '
'; } $html .= '
'; return $html; } public static function formatImageValues($values, $isHtml, $form_id = null) { if (!$values) { return $values; } if (is_string($values)) { return $values; } $isHtml = apply_filters('fluentform/render_field_as_html', $isHtml, $values, $form_id); if (!$isHtml) { return fluentImplodeRecursive(', ', array_filter(array_values((array) $values))); } if ($form_id && \FluentForm\App\Helpers\Helper::isEntryAutoDeleteEnabled($form_id)) { return ''; } if (1 == count($values)) { $value = $values[0]; if (!$value) { return ''; } return '
'; } $html = '
'; foreach ($values as $value) { if (!$value) { continue; } $html .= '
'; } $html .= '
'; return $html; } public static function formatRepeatFieldValue($value, $field, $form_id) { if (defined('FLUENTFORM_RENDERING_ENTRIES')) { return __('....', 'fluentform'); } if (is_string($value)) { return $value; } try { $repeatColumns = ArrayHelper::get($field, 'raw.fields'); $rows = count($value[0]); $columns = count($value); ob_start(); if ($repeatColumns) { ?>
', array_values($columnLabels)); $elMarkup = "
{$columnHeaders}
"; foreach (static::makeTabularData($field['raw']) as $row) { $elMarkup .= '
'; $elMarkup .= "
{$row['label']}
"; foreach ($row['columns'] as $column) { $isChecked = ''; if ('radio' == $fieldType) { if (isset($value->{$row['name']})) { $isChecked = $value->{$row['name']} == $column['name'] ? 'checked' : ''; } } else { if (isset($value->{$row['name']})) { $isChecked = in_array($column['name'], $value->{$row['name']}) ? 'checked' : ''; } } $icon = "
"; if ($isChecked) { $icon = '✔'; } $elMarkup .= "
" . $icon . '
'; } $elMarkup .= '
'; } $elMarkup .= '
'; return $elMarkup; } catch (\Exception $e) { } return ''; } public static function makeTabularData($data) { $table = []; $rows = $data['settings']['grid_rows']; $columns = $data['settings']['grid_columns']; foreach ($rows as $rowKey => $rowValue) { $table[$rowKey] = [ 'name' => $rowKey, 'label' => $rowValue, 'columns' => [], ]; foreach ($columns as $columnKey => $columnValue) { $table[$rowKey]['columns'][] = [ 'name' => $columnKey, 'label' => $columnValue, ]; } } return $table; } /** * Format input_name field value by concatenating all name fields. * * @param array|object $value * * @return string $value */ public static function formatName($value) { if (is_array($value) || is_object($value)) { $value = (array) $value; $order = ['first_name', 'middle_name', 'last_name']; uksort($value, function($a, $b) use ($order) { $posA = array_search($a, $order); $posB = array_search($b, $order); return $posA - $posB; }); return fluentImplodeRecursive(' ', array_filter(array_values($value))); } return $value; } public static function formatCheckBoxValues($values, $field, $isHtml = false) { if (!$isHtml) { return self::formatValue($values); } if (!is_array($values)) { return $values; } if (empty($values)) { return ''; } if (!isset($field['options'])) { $field['options'] = []; foreach (ArrayHelper::get($field, 'raw.settings.advanced_options', []) as $option) { $field['options'][$option['value']] = $option['label']; } } $html = '
'; foreach ($values as $value) { $item = $value; if ($itemLabel = ArrayHelper::get($field, 'options.' . $item)) { $item = $itemLabel; } $html .= '
' . $item . '
'; } return $html . '
'; } public static function resetData() { static::$data = null; } }