This commit is contained in:
Jürgen Mummert
2026-03-06 21:25:18 +01:00
commit d10c160ae9
25 changed files with 903 additions and 0 deletions

48
contao/dca/tl_form.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use Contao\CoreBundle\DataContainer\PaletteManipulator;
PaletteManipulator::create()
->addLegend('timed_download_legend', 'store_legend', PaletteManipulator::POSITION_AFTER)
->addField('timedDownloadEnabled', 'timed_download_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default', 'tl_form')
;
$GLOBALS['TL_DCA']['tl_form']['palettes']['__selector__'][] = 'timedDownloadEnabled';
$GLOBALS['TL_DCA']['tl_form']['subpalettes']['timedDownloadEnabled'] = 'timedDownloadFile,timedDownloadDuration,timedDownloadUnit';
$GLOBALS['TL_DCA']['tl_form']['fields']['timedDownloadEnabled'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form']['timedDownloadEnabled'],
'exclude' => true,
'inputType' => 'checkbox',
'eval' => ['submitOnChange' => true, 'tl_class' => 'w50 m12'],
'sql' => ['type' => 'boolean', 'default' => false],
];
$GLOBALS['TL_DCA']['tl_form']['fields']['timedDownloadFile'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form']['timedDownloadFile'],
'exclude' => true,
'inputType' => 'fileTree',
'eval' => ['fieldType' => 'radio', 'files' => true, 'mandatory' => true, 'tl_class' => 'w50'],
'sql' => ['type' => 'binary', 'length' => 16, 'notnull' => false],
];
$GLOBALS['TL_DCA']['tl_form']['fields']['timedDownloadDuration'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form']['timedDownloadDuration'],
'exclude' => true,
'inputType' => 'text',
'eval' => ['mandatory' => true, 'rgxp' => 'digit', 'maxlength' => 6, 'tl_class' => 'w50'],
'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 7],
];
$GLOBALS['TL_DCA']['tl_form']['fields']['timedDownloadUnit'] = [
'label' => &$GLOBALS['TL_LANG']['tl_form']['timedDownloadUnit'],
'exclude' => true,
'inputType' => 'select',
'options' => ['hours', 'days', 'weeks', 'months'],
'reference' => &$GLOBALS['TL_LANG']['tl_form']['timedDownloadUnitOptions'],
'eval' => ['mandatory' => true, 'chosen' => true, 'tl_class' => 'w50'],
'sql' => "varchar(16) NOT NULL default 'days'",
];

13
contao/dca/tl_module.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
$GLOBALS['TL_DCA']['tl_module']['palettes']['timed_download_link'] = '{title_legend},name,headline,type;{timed_download_legend},timedDownloadText;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['fields']['timedDownloadText'] = [
'label' => &$GLOBALS['TL_LANG']['tl_module']['timedDownloadText'],
'exclude' => true,
'inputType' => 'textarea',
'eval' => ['rte' => 'tinyMCE', 'tl_class' => 'clr'],
'sql' => 'text NULL',
];

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
use Contao\DC_Table;
$GLOBALS['TL_DCA']['tl_timed_download'] = [
'config' => [
'dataContainer' => DC_Table::class,
'sql' => [
'keys' => [
'id' => 'primary',
'token' => 'unique',
'expires_at' => 'index',
'form_id' => 'index',
],
],
],
'fields' => [
'id' => [
'sql' => 'int(10) unsigned NOT NULL auto_increment',
],
'tstamp' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'token' => [
'sql' => "varchar(64) NOT NULL default ''",
],
'file_uuid' => [
'sql' => 'binary(16) NOT NULL',
],
'expires_at' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'form_id' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'last_download_at' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'download_count' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
],
];