-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9751811
Showing
26 changed files
with
605 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\UploadWidgetExample\Controller; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use GAYA\UploadWidget\Service\UploadService; | ||
use GAYA\UploadWidgetExample\Domain\Repository\ExampleRepository; | ||
use GAYA\UploadWidgetExample\Domain\Model\Example; | ||
use GAYA\UploadWidgetExample\Domain\Model\Dto\ExampleForm; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Annotation as Extbase; | ||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; | ||
|
||
class ExampleController extends ActionController | ||
{ | ||
public function __construct( | ||
private ExampleRepository $exampleRepository, | ||
private UploadService $uploadService | ||
) { | ||
} | ||
|
||
public function editAction(ExampleForm $candidatureForm = null): ResponseInterface | ||
{ | ||
if ($candidatureForm === null) { | ||
$candidatureForm = new ExampleForm(); | ||
} | ||
|
||
$this->view->assign('candidatureForm', $candidatureForm); | ||
$this->view->assign('civiliteOptions', [ | ||
1 => LocalizationUtility::translate('LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:civilite.1'), | ||
2 => LocalizationUtility::translate('LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:civilite.2'), | ||
3 => LocalizationUtility::translate('LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:civilite.3'), | ||
]); | ||
return $this->htmlResponse(); | ||
} | ||
|
||
public function createAction(ExampleForm $exampleForm) | ||
{ | ||
/** @var Example $example */ | ||
$example = GeneralUtility::makeInstance(Example::class); | ||
|
||
$example->setFirstname($exampleForm->getFirstname()); | ||
$example->setLastname($exampleForm->getLastname()); | ||
$example->setFile( | ||
$this->uploadService->createExtbaseFileReferenceFromFile( | ||
$this->uploadService->getFile($exampleForm->getFile()), | ||
'tx_uploadwidgetexample_domain_model_example' | ||
) | ||
); | ||
|
||
$this->exampleRepository->add($example); | ||
|
||
$this->redirect('confirmation'); | ||
} | ||
|
||
public function confirmationAction(): ResponseInterface | ||
{ | ||
return $this->htmlResponse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\UploadWidgetExample\Domain\Model\Dto; | ||
|
||
use TYPO3\CMS\Extbase\Annotation as Extbase; | ||
|
||
class ExampleForm | ||
{ | ||
/** | ||
* @var string | ||
* @Extbase\Validate("NotEmpty") | ||
* @Extbase\Validate("stringLength", options={"maximum": 255}) | ||
*/ | ||
protected string $firstname = ''; | ||
|
||
/** | ||
* @var string | ||
* @Extbase\Validate("NotEmpty") | ||
* @Extbase\Validate("stringLength", options={"maximum": 255}) | ||
*/ | ||
protected string $lastname = ''; | ||
|
||
/** | ||
* @var string | ||
* @Extbase\Validate("NotEmpty") | ||
* @Extbase\Validate("\GAYA\UploadWidget\Validation\Validator\ProtectedFileUidValidator") | ||
*/ | ||
protected string $file = ''; | ||
|
||
public function getFirstname(): string | ||
{ | ||
return $this->firstname; | ||
} | ||
|
||
public function setFirstname(string $firstname): void | ||
{ | ||
$this->firstname = $firstname; | ||
} | ||
|
||
public function getLastname(): string | ||
{ | ||
return $this->lastname; | ||
} | ||
|
||
public function setLastname(string $lastname): void | ||
{ | ||
$this->lastname = $lastname; | ||
} | ||
|
||
public function getFile(): string | ||
{ | ||
return $this->file; | ||
} | ||
|
||
public function setFile(string $file): void | ||
{ | ||
$this->file = $file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\UploadWidgetExample\Domain\Model; | ||
|
||
use TYPO3\CMS\Extbase\Domain\Model\FileReference; | ||
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; | ||
|
||
class Example extends AbstractEntity | ||
{ | ||
protected string $firstname = ''; | ||
|
||
protected string $lastname = ''; | ||
|
||
protected ?FileReference $file; | ||
|
||
public function getFirstname(): string | ||
{ | ||
return $this->firstname; | ||
} | ||
|
||
public function setFirstname(string $firstname): void | ||
{ | ||
$this->firstname = $firstname; | ||
} | ||
|
||
public function getLastname(): string | ||
{ | ||
return $this->lastname; | ||
} | ||
|
||
public function setLastname(string $lastname): void | ||
{ | ||
$this->lastname = $lastname; | ||
} | ||
|
||
public function getFile(): ?FileReference | ||
{ | ||
return $this->file; | ||
} | ||
|
||
public function setFile(?FileReference $file): void | ||
{ | ||
$this->file = $file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GAYA\UploadWidgetExample\Domain\Repository; | ||
|
||
use TYPO3\CMS\Extbase\Persistence\Repository; | ||
|
||
class ExampleRepository extends Repository | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
|
||
GAYA\UploadWidgetExample\: | ||
resource: '../Classes/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
|
||
defined('TYPO3') or die(); | ||
|
||
ExtensionManagementUtility::addStaticFile( | ||
'upload_widget_example', | ||
'Configuration/TypoScript', | ||
'Widget Upload - Example' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use TYPO3\CMS\Extbase\Utility\ExtensionUtility; | ||
|
||
defined('TYPO3') or die(); | ||
|
||
ExtensionUtility::registerPlugin( | ||
'UploadWidgetExample', | ||
'Example', | ||
'Form upload example' | ||
); | ||
|
||
$GLOBALS['TCA']['tt_content']['types']['uploadwidgetexample_example']['showitem'] = ' | ||
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, | ||
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general, | ||
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, | ||
--palette--;;hidden, | ||
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access | ||
'; |
59 changes: 59 additions & 0 deletions
59
Configuration/TCA/tx_uploadwidgetexample_domain_model_example.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
|
||
return [ | ||
'ctrl' => [ | ||
'title' => 'LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:example', | ||
'label' => 'lastname', | ||
'label_alt' => 'firstname', | ||
'label_alt_force' => true, | ||
'tstamp' => 'tstamp', | ||
'crdate' => 'crdate', | ||
'delete' => 'deleted', | ||
'default_sortby' => 'tstamp desc', | ||
'searchFields' => 'firstname,lastname', | ||
'typeicon_classes' => [ | ||
'default' => 'mimetypes-x-content-login', | ||
], | ||
], | ||
'types' => [ | ||
'1' => [ | ||
'showitem' => 'firstname,lastname,file', | ||
], | ||
], | ||
'columns' => [ | ||
'firstname' => [ | ||
'label' => 'LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:firstname', | ||
'config' => [ | ||
'type' => 'input', | ||
'width' => 200, | ||
'eval' => 'trim,required', | ||
'max' => 255, | ||
], | ||
], | ||
'lastname' => [ | ||
'label' => 'LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:lastname', | ||
'config' => [ | ||
'type' => 'input', | ||
'width' => 200, | ||
'eval' => 'trim,required', | ||
'max' => 255, | ||
], | ||
], | ||
'file' => [ | ||
'label' => 'LLL:EXT:upload_widget_example/Resources/Private/Language/locallang_db.xlf:file', | ||
'config' => ExtensionManagementUtility::getFileFieldTCAConfig('file', [ | ||
'appearance' => [ | ||
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:media.addFileReference', | ||
], | ||
// Used by DataHandler / RelationHandler to create a valid FileReference | ||
'foreign_match_fields' => [ | ||
'fieldname' => 'file', | ||
'tablenames' => 'tx_uploadwidgetexample_domain_model_example', | ||
'table_local' => 'sys_file', | ||
], | ||
], 'pdf'), | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# customcategory=plugin.tx_uploadwidgetexample=Upload Widget Example | ||
plugin.tx_uploadwidgetexample { | ||
view { | ||
# cat=plugin.tx_uploadwidgetexample/file; type=string; label=Path to template root (FE) | ||
templateRootPath = EXT:upload_widget_example/Resources/Private/Templates/ | ||
# cat=plugin.tx_uploadwidgetexample/file; type=string; label=Path to template partials (FE) | ||
partialRootPath = EXT:upload_widget_example/Resources/Private/Partials/ | ||
# cat=plugin.tx_uploadwidgetexample/file; type=string; label=Path to template layouts (FE) | ||
layoutRootPath = EXT:upload_widget_example/Resources/Private/Layouts/ | ||
} | ||
|
||
persistence { | ||
# cat=plugin.tx_uploadwidgetexample/settings; type=string; label=Default storage PID | ||
storagePid = 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
plugin.tx_uploadwidgetexample { | ||
view { | ||
templateRootPath = {$plugin.tx_uploadwidgetexample.view.templateRootPath} | ||
partialRootPath = {$plugin.tx_uploadwidgetexample.view.partialRootPath} | ||
layoutRootPath = {$plugin.tx_uploadwidgetexample.view.layoutRootPath} | ||
} | ||
persistence { | ||
storagePid = {$plugin.tx_uploadwidgetexample.persistence.storagePid} | ||
} | ||
settings { | ||
uploadTypeNum = {$plugin.tx_uploadwidget.settings.uploadTypeNum} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# TYPO3 Extension upload_widget_example | ||
|
||
This extension provides an example of upload_widget usage. | ||
|
||
This includes: | ||
|
||
- a stored model with a file field | ||
- a form to create a record for this model by using a DTO | ||
|
||
## Installation | ||
|
||
Intall upload_widget with Composer: | ||
|
||
`composer require gaya/upload_widget` | ||
|
||
## Configuration | ||
|
||
- In your root template, include the TypoScript "Upload Widget - Example" | ||
- In a page, add a new page content of type (CType) "Form upload example" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff"> | ||
<file t3:id="1663332442" source-language="en" datatype="plaintext"> | ||
<header/> | ||
<body> | ||
<trans-unit id="firstname"> | ||
<source>Firstname</source> | ||
</trans-unit> | ||
<trans-unit id="lastname"> | ||
<source>Lastname</source> | ||
</trans-unit> | ||
<trans-unit id="file"> | ||
<source>File</source> | ||
</trans-unit> | ||
|
||
<trans-unit id="form.send"> | ||
<source>Send</source> | ||
</trans-unit> | ||
|
||
<trans-unit id="form.error.1221560718"> | ||
<source>Veuillez remplir ce champ.</source> | ||
</trans-unit> | ||
<trans-unit id="form.error.1238108069"> | ||
<source>Veuillez saisir au maximum %d caractères.</source> | ||
</trans-unit> | ||
<trans-unit id="form.error.1221559976"> | ||
<source>Adresse email invalide.</source> | ||
</trans-unit> | ||
<trans-unit id="form.error.1519982125"> | ||
<source>Veuillez répondre au captcha.</source> | ||
</trans-unit> | ||
<trans-unit id="form.error.1663339886"> | ||
<source>Les adresses emails ne correspondent pas.</source> | ||
</trans-unit> | ||
<trans-unit id="form.error.1361959228"> | ||
<source>Veuillez cocher la case.</source> | ||
</trans-unit> | ||
|
||
<trans-unit id="confirmation_message"> | ||
<source>Thanks for using gaya/upload-widget extension. Don't hesitate to contribute.</source> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
Oops, something went wrong.