diff --git a/src/console/controllers/ExportController.php b/src/console/controllers/ExportController.php index 139675d..c4b6285 100644 --- a/src/console/controllers/ExportController.php +++ b/src/console/controllers/ExportController.php @@ -44,7 +44,7 @@ public function actionDebug($id): bool $fields = $export->getHeadings(); $data[] = array_merge($attributes, $fields); - foreach ($query->limit(1)->all() as $element) { + foreach ($query->id(14263)->limit(1)->all() as $element) { d($element->id); $values = $element->toArray(array_keys($export->getAttributes())); // Convert values to strings @@ -54,7 +54,7 @@ public function actionDebug($id): bool // Fetch the custom field content, already prepped $fieldValues = $export->parseFieldValues($element); - d($fieldValues); + dd($fieldValues); $data[] = array_merge($row, $fieldValues); } diff --git a/src/controllers/ElementController.php b/src/controllers/ElementController.php index 65a2cbb..8dadaf8 100644 --- a/src/controllers/ElementController.php +++ b/src/controllers/ElementController.php @@ -84,7 +84,17 @@ public function actionGetDownload() $fileName = $this->request->getRequiredBodyParam('fileName'); $file = file_get_contents(Craft::$app->getPath()->getTempPath() . "/{$fileName}.{$settings['fileType']}"); - return $file; + if (file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="' . basename($file) . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + readfile($file); + exit; + } } public function actionWatch($elementId = null) diff --git a/src/fields/MultiOptionsFieldParser.php b/src/fields/MultiOptionsFieldParser.php new file mode 100644 index 0000000..e63fe1c --- /dev/null +++ b/src/fields/MultiOptionsFieldParser.php @@ -0,0 +1,22 @@ +getFieldValue($field['handle'])->getOptions() as $option) { + if($option->selected) { + $selected[] = $option->$property; + } + } + return $selected; + } +} diff --git a/src/fields/OptionsFieldParser.php b/src/fields/OptionsFieldParser.php new file mode 100644 index 0000000..c22889a --- /dev/null +++ b/src/fields/OptionsFieldParser.php @@ -0,0 +1,39 @@ +getFieldValue($field['handle'])->$property; + } + + public function getOptions(): array + { + return [ + 'label' => 'Label', + 'value' => 'Value' + ]; + } + + public function getOptionType(): string|bool + { + return "select"; + } + + public function getOptionLabel(): string|bool + { + return Craft::t('exporter', 'Select field property'); + + } + + public function getOptionDescription(): string|bool + { + return Craft::t('exporter', 'Select which property you want to export.'); + } +} diff --git a/src/fields/RelationFieldParser.php b/src/fields/RelationFieldParser.php index 80c71fc..989b6f7 100644 --- a/src/fields/RelationFieldParser.php +++ b/src/fields/RelationFieldParser.php @@ -24,6 +24,7 @@ public function getOptions(): array return [ 'title' => Craft::t('app', 'Title'), 'id' => Craft::t('app', 'ID'), + 'url' => Craft::t('app', 'URL'), ]; } diff --git a/src/fields/TimeParser.php b/src/fields/TimeParser.php new file mode 100644 index 0000000..dcdb80f --- /dev/null +++ b/src/fields/TimeParser.php @@ -0,0 +1,39 @@ +getFieldValue($field['handle']); + if ($value) { + return $value->format($field['property']); + } + } + + public function getOptionType(): string + { + return "select"; + } + + + public function getOptionLabel(): string|bool + { + return false; + } + + + public function getOptionDescription(): string|bool + { + return false; + } + + public function getOptions(): array + { + return [ + 'H:i:s' => 'H:i:s', + 'H:i' => 'H:i', + ]; + } +} diff --git a/src/helpers/FieldTypeHelper.php b/src/helpers/FieldTypeHelper.php index 2c1f17f..5dc1f69 100644 --- a/src/helpers/FieldTypeHelper.php +++ b/src/helpers/FieldTypeHelper.php @@ -7,36 +7,36 @@ use craft\base\FieldInterface; use craft\fields\Assets; use craft\fields\Categories; +use craft\fields\Checkboxes; use craft\fields\Color; use craft\fields\Date; +use craft\fields\Dropdown; use craft\fields\Email; use craft\fields\Entries; use craft\fields\Lightswitch; +use craft\fields\Money; +use craft\fields\MultiSelect; use craft\fields\Number; use craft\fields\PlainText; use craft\fields\RadioButtons; use craft\fields\Tags; +use craft\fields\Time; use craft\fields\Url; use studioespresso\exporter\events\RegisterExportableFieldTypes; use studioespresso\exporter\fields\BaseFieldParser; use studioespresso\exporter\fields\DateTimeParser; +use studioespresso\exporter\fields\LightswitchParser; +use studioespresso\exporter\fields\MultiOptionsFieldParser; +use studioespresso\exporter\fields\OptionsFieldParser; use studioespresso\exporter\fields\PlainTextParser; use studioespresso\exporter\fields\RelationFieldParser; +use studioespresso\exporter\fields\TimeParser; class FieldTypeHelper { public const EVENT_REGISTER_EXPORTABLE_FIELD_TYPES = 'registerExportableFieldTypes'; public const SUPPORTED_FIELD_TYPES = [ - PlainTextParser::class => [ - PlainText::class, - Number::class, - Lightswitch::class, - Email::class, - Color::class, - Url::class, - RadioButtons::class, - ], RelationFieldParser::class => [ Entries::class, Assets::class, @@ -46,6 +46,26 @@ class FieldTypeHelper DateTimeParser::class => [ Date::class, ], + TimeParser::class => [ + Time::class, + ], + OptionsFieldParser::class => [ + Dropdown::class, + RadioButtons::class, + ], + MultiOptionsFieldParser::class => [ + MultiSelect::class, + Checkboxes::class, + ], + PlainTextParser::class => [ + PlainText::class, + Number::class, + Email::class, + Color::class, + Url::class, + Money::class, + Lightswitch::class, + ], ]; diff --git a/src/models/ExportableFormieSubmissionModel.php b/src/models/ExportableFormieSubmissionModel.php index 0f00049..e6f07fc 100644 --- a/src/models/ExportableFormieSubmissionModel.php +++ b/src/models/ExportableFormieSubmissionModel.php @@ -25,5 +25,4 @@ public function getSubGroup(): bool|array { return false; } - } \ No newline at end of file diff --git a/src/templates/sprig/element/step_1.twig b/src/templates/sprig/element/step_1.twig index d101b97..09b187d 100644 --- a/src/templates/sprig/element/step_1.twig +++ b/src/templates/sprig/element/step_1.twig @@ -27,7 +27,7 @@ {% if export.id %} {% set settings = export.getSettings() %} - {% set elementType = export.elementType %} + {% set elementType = elementType ?? export.elementType %} {% set showSiteOptions = true %} {% else %} {% if elementType is not defined %} @@ -63,13 +63,10 @@ {% set group = '' %} {% set subGroup = '' %} {% endif %} - {% if elementType is defined %} {% set elementOptions = craft.exporter.getElementTypeSettings(elementType) %} - {% set subGroup = elementOptions.getSubGroup() %} {% if elementOptions.group is defined %} {% set groupOptions = elementOptions.getGroup() %} - {{ d(groupOptions) }}
+ Your export running, stay tuned. Depending on the size of your export, this could take a while. +
{% else %}