Skip to content

Commit

Permalink
Merge tag '2.2.0'
Browse files Browse the repository at this point in the history
New version 2.2.0

- Bump the requirements for the new release
- Add the phpspec fix to the build configuration
- Update the travis configuration
- Add the option for normalize the extended folder path
- Add the option for normalize the filename
- Change the html markup of the edit buttons
  • Loading branch information
stefanheimes committed Jun 21, 2022
2 parents 5f6caa0 + e7aa0bb commit 46dcfe9
Show file tree
Hide file tree
Showing 10 changed files with 772 additions and 44 deletions.
32 changes: 16 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# OS
.DS_Store
Thumbs.db

# IDEs
.buildpath
.project
.settings/
.build/
.external*/
.idea/
nbproject/

# composer related
vendor/
composer.lock
# OS
.DS_Store
Thumbs.db

# IDEs
.buildpath
.project
.settings/
.build/
.external*/
.idea/
nbproject/

# composer related
vendor/
composer.lock
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ php:
- "7.4"
- "7.3"
- "7.2"
- "7.1"

env:
- CONTAO_VERSION=~4.8.0
- CONTAO_VERSION=~4.4.0
- CONTAO_VERSION='contao/core-bundle ~4.9.0'
- CONTAO_VERSION='contao/core-bundle ~4.10.0@dev'

# Exclude impossible Contao Version combinations.
matrix:
fast_finish: true
allow_failures:
- php: "7.4"
- env: CONTAO_VERSION=~4.8.0
- php: "7.4"
- env: CONTAO_VERSION='contao/core-bundle ~4.10.0@dev'

before_script:
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
"source":"https://github.com/contao-community-alliance/dc-general-contao-frontend"
},
"require": {
"php":"^7.1",
"contao-community-alliance/dc-general": "^2.1.3",
"php":"^7.2",
"contao-community-alliance/dc-general": "^2.2",
"contao-community-alliance/url-builder": "~1.1",
"contao-community-alliance/translator": "^2.1",
"contao/core-bundle": "^4.4",
"symfony/event-dispatcher": "^3.3 || ^4.0"
"contao-community-alliance/translator": "^2.2",
"contao/core-bundle": "^4.9",
"symfony/event-dispatcher": "4.4.*"
},
"require-dev": {
"contao/manager-plugin": "^2.1",
"phpcq/all-tasks": "~1.1",
"contao/manager-plugin": "^2.8",
"phpcq/all-tasks": "~1.2",
"phpmd/phpmd": "~2.8.2"
},
"autoload": {
Expand All @@ -46,8 +46,8 @@
"extra":{
"contao-manager-plugin": "ContaoCommunityAlliance\\DcGeneral\\ContaoFrontend\\ContaoManager\\Plugin",
"branch-alias": {
"dev-master": "2.1.x-dev",
"dev-support/2.0": "2.0.x-dev"
"dev-support/2.1.x": "2.1.x-dev",
"dev-master": "2.2.x-dev"
}
},
"config": {
Expand Down
23 changes: 23 additions & 0 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2016-2019 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package contao-community-alliance/dc-general-contao-frontend
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2016-2019 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/

use ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Widgets\UploadOnSteroids;

// Front end form widgets
$GLOBALS['TL_FFL']['uploadOnSteroids'] = UploadOnSteroids::class;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php /** @var ContaoCommunityAlliance\DcGeneral\ContaoFrontend\Widgets\UploadOnSteroids $this */ ?>
<?php $this->extend('form_row'); ?>

<?php $this->block('label'); ?>
<?php if ($this->label): ?>
<label for="ctrl_<?= $this->id ?>"<?php if ($this->class): ?> class="<?= $this->class ?>"<?php endif; ?>>
<?php if ($this->mandatory): ?>
<span class="invisible"><?= $this->mandatoryField ?> </span><?= $this->label ?><span class="mandatory">*</span>
<?php else: ?>
<?= $this->label ?>
<?php endif; ?>
</label>
<?php endif; ?>

<?php if ($this->files): ?>
<div class="file-container">
<ul id="files_<?= $this->id ?>" class="files">
<?php /** @var stdClass $file */ ?>
<?php foreach ($this->files as $key => $file): ?>
<li class="file-element ext-<?= $file->extension?>">
<?php if($this->showThumbnail): ?>
<img src="<?= $file->path ?>" title="<?= $file->name ?>" alt="<?= $file->name ?>" itemprop="image">
<p class="file-name"><?= $file->name ?></p>
<?php else: ?>
<span class="file-name"><?= $file->name ?></span>
<?php endif;?>

<div class="file-action">
<?php if($this->deselect): ?>
<div class="file-reset">
<label for="ctrl_reset_<?= $this->id ?>_<?= $key ?>"><?= $this->trans('MSC.reset')?></label>
<input type="checkbox" name="<?= $this->name ?>[reset][]" id="ctrl_reset_<?= $this->id ?>_<?= $key ?>" value="<?= \Contao\StringUtil::binToUuid($file->uuid) ?>">
</div>
<?php endif; ?>
<?php if($this->delete): ?>
<div class="file-delete">
<label for="ctrl_delete_<?= $this->id ?>_<?= $key ?>"><?= $this->trans('MSC.delete')?></label>
<input type="checkbox" name="<?= $this->name ?>[delete][]" id="ctrl_delete_<?= $this->id ?>_<?= $key ?>" value="<?= \Contao\StringUtil::binToUuid($file->uuid) ?>">
</div>
<?php endif; ?>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php $this->endblock(); ?>

<?php $this->block('field'); ?>
<?php if ($this->hasErrors()): ?>
<p class="error"><?= $this->getErrorAsString() ?></p>
<?php endif; ?>
<input type="hidden" name="<?= $this->name ?><?= $this->multiple ? '[]' : '' ?>" value="<?= $this->value ?>">
<input type="file" name="<?= $this->name ?><?= $this->multiple ? '[]' : '' ?>" id="ctrl_<?= $this->id ?>" class="upload<?php if ($this->class): ?> <?= $this->class ?><?php endif; ?>"<?= $this->getAttributes() ?>>
<?php $this->endblock(); ?>
13 changes: 10 additions & 3 deletions src/View/ActionHandler/CopyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2015-2018 Contao Community Alliance.
* (c) 2015-2022 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,13 +12,15 @@
*
* @package contao-community-alliance/dc-general-contao-frontend
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @copyright 2015-2018 Contao Community Alliance.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2015-2022 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0
* @filesource
*/

namespace ContaoCommunityAlliance\DcGeneral\ContaoFrontend\View\ActionHandler;

use Contao\CoreBundle\Exception\PageNotFoundException;
use Contao\CoreBundle\Exception\RedirectResponseException;
use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator;
use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminatorAwareTrait;
Expand Down Expand Up @@ -122,7 +124,12 @@ public function process(EnvironmentInterface $environment): void

$dataProvider = $environment->getDataProvider();
$model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
$copyModel = $environment->getController()->createClonedModel($model);

if (null === $model) {
throw new PageNotFoundException('Model not found: ' . $modelId->getSerialized());
}

$copyModel = $environment->getController()->createClonedModel($model);

// Dispatch pre duplicate event.
$copyEvent = new PreDuplicateModelEvent($environment, $copyModel, $model);
Expand Down
10 changes: 8 additions & 2 deletions src/View/ActionHandler/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2015-2018 Contao Community Alliance.
* (c) 2015-2022 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,13 +12,15 @@
*
* @package contao-community-alliance/dc-general-contao-frontend
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @copyright 2015-2018 Contao Community Alliance.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2015-2022 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0
* @filesource
*/

namespace ContaoCommunityAlliance\DcGeneral\ContaoFrontend\View\ActionHandler;

use Contao\CoreBundle\Exception\PageNotFoundException;
use Contao\CoreBundle\Exception\RedirectResponseException;
use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminator;
use ContaoCommunityAlliance\DcGeneral\Contao\RequestScopeDeterminatorAwareTrait;
Expand Down Expand Up @@ -115,6 +117,10 @@ public function process(EnvironmentInterface $environment): void
$dataProvider = $environment->getDataProvider();
$model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

if (null === $model) {
throw new PageNotFoundException('Model not found: ' . $modelId->getSerialized());
}

// Trigger event before the model will be deleted.
$event = new PreDeleteModelEvent($environment, $model);
$environment->getEventDispatcher()->dispatch($event::NAME, $event);
Expand Down
10 changes: 7 additions & 3 deletions src/View/ActionHandler/EditHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2015-2020 Contao Community Alliance.
* (c) 2015-2022 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,8 @@
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @author Sven Baumann <baumann.sv@gmail.com>
* @copyright 2015-2020 Contao Community Alliance.
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2015-2022 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -103,20 +104,23 @@ public function process(EnvironmentInterface $environment)
if (!$basicDefinition->isEditable()) {
throw new NotEditableException('DataContainer ' . $definition->getName() . ' is not editable');
}

// We only support flat tables, sorry.
if (BasicDefinitionInterface::MODE_HIERARCHICAL === $basicDefinition->getMode()) {
return false;
}

$modelId = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id'));

$dataProvider = $environment->getDataProvider();
$model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
$clone = clone $model;

if (null === $model) {
throw new PageNotFoundException('Model not found: ' . $modelId->getSerialized());
}

$clone = clone $model;

return (new EditMask($environment, $model, $clone, null, null))->execute();
}
}
23 changes: 17 additions & 6 deletions src/View/EditMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general-contao-frontend.
*
* (c) 2015-2018 Contao Community Alliance.
* (c) 2015-2020 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,9 @@
* @package contao-community-alliance/dc-general-contao-frontend
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @copyright 2015-2018 Contao Community Alliance.
* @author Sven Baumann <baumann.sv@gmail.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2015-2020 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general-contao-frontend/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -194,7 +196,8 @@ public function execute()
'table' => $this->definition->getName(),
'enctype' => 'multipart/form-data',
'error' => $this->errors,
'editButtons' => $buttons
'editButtons' => $buttons,
'model' => $this->model
]
);

Expand Down Expand Up @@ -315,17 +318,25 @@ private function translateLabel($transString, $parameters = [])
*/
private function getEditButtons()
{
$button = '<button type="submit" name="%s" id="%s" class="submit %s" accesskey="%s">%s</button>';
$buttons = [];

$buttons['save'] = sprintf(
'<input type="submit" name="save" class="submit save" accesskey="s" value="%s">',
$button,
'save',
'save',
'save',
's',
$this->translateLabel('save')
);

if ($this->definition->getBasicDefinition()->isCreatable()) {
$buttons['saveNcreate'] = sprintf(
'<input type="submit" name="saveNcreate" class="submit saveNcreate" accesskey="n" ' .
' value="%s">',
$button,
'saveNcreate',
'saveNcreate',
'saveNcreate',
'n',
$this->translateLabel('saveNcreate')
);
}
Expand Down
Loading

0 comments on commit 46dcfe9

Please sign in to comment.