| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Entries; |
| 4 |
|
| 5 |
use FluentForm\App\Modules\Form\FormDataParser; |
| 6 |
use FluentForm\App\Modules\Form\FormFieldsParser; |
| 7 |
|
| 8 |
/** |
| 9 |
* @deprecated Use SubmissionService or direct wpFluent() queries instead. |
| 10 |
* Backward-compatible stub kept for third-party plugins (Ninja Tables, etc.) |
| 11 |
* that resolve this class via wpFluentForm() container. |
| 12 |
* @todo Remove in next major version. |
| 13 |
*/ |
| 14 |
class Entries extends EntryQuery |
| 15 |
{ |
| 16 |
public function __construct() |
| 17 |
{ |
| 18 |
parent::__construct(); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* @deprecated Use direct queries or REST API instead. |
| 23 |
*/ |
| 24 |
public function _getEntries( |
| 25 |
$formId, |
| 26 |
$currentPage, |
| 27 |
$perPage, |
| 28 |
$sortBy, |
| 29 |
$entryType, |
| 30 |
$search, |
| 31 |
$wheres = [] |
| 32 |
) { |
| 33 |
$this->formId = $formId; |
| 34 |
$this->per_page = $perPage; |
| 35 |
$this->sort_by = $sortBy; |
| 36 |
$this->page_number = $currentPage; |
| 37 |
$this->search = $search; |
| 38 |
$this->wheres = $wheres; |
| 39 |
|
| 40 |
if ('favorite' == $entryType) { |
| 41 |
$this->is_favourite = true; |
| 42 |
} elseif ('all' != $entryType && $entryType) { |
| 43 |
$this->status = $entryType; |
| 44 |
} |
| 45 |
|
| 46 |
$dateRange = $this->request->get('date_range'); |
| 47 |
if ($dateRange) { |
| 48 |
$this->startDate = $dateRange[0]; |
| 49 |
$this->endDate = $dateRange[1]; |
| 50 |
} |
| 51 |
|
| 52 |
$form = $this->formModel->find($formId); |
| 53 |
$formMeta = $this->getFormInputsAndLabels($form); |
| 54 |
$formLabels = $formMeta['labels']; |
| 55 |
|
| 56 |
$formLabels = apply_filters('fluentform/entry_lists_labels', $formLabels, $form); |
| 57 |
$submissions = $this->getResponses(); |
| 58 |
$submissions['data'] = FormDataParser::parseFormEntries($submissions['data'], $form); |
| 59 |
|
| 60 |
return compact('submissions', 'formLabels'); |
| 61 |
} |
| 62 |
|
| 63 |
public function getFormInputsAndLabels($form, $with = ['admin_label', 'raw']) |
| 64 |
{ |
| 65 |
$formInputs = FormFieldsParser::getEntryInputs($form, $with); |
| 66 |
$inputLabels = FormFieldsParser::getAdminLabels($form, $formInputs); |
| 67 |
return [ |
| 68 |
'inputs' => $formInputs, |
| 69 |
'labels' => $inputLabels, |
| 70 |
]; |
| 71 |
} |
| 72 |
} |
| 73 |
|