Skip to content

Commit

Permalink
Merge branch '4.8'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	calendar-bundle/composer.json
#	comments-bundle/composer.json
#	composer.json
#	core-bundle/composer.json
#	core-bundle/src/Resources/contao/config/constants.php
#	core-bundle/src/Resources/contao/languages/cs/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/de/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/es/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/fa/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/fr/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/it/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/ja/default.xlf
#	core-bundle/src/Resources/contao/languages/ja/tl_files.xlf
#	core-bundle/src/Resources/contao/languages/ja/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/lv/default.xlf
#	core-bundle/src/Resources/contao/languages/lv/tl_form_field.xlf
#	core-bundle/src/Resources/contao/languages/nl/default.xlf
#	core-bundle/src/Resources/contao/languages/nl/tl_content.xlf
#	core-bundle/src/Resources/contao/languages/nl/tl_files.xlf
#	core-bundle/src/Resources/contao/languages/nl/tl_form_field.xlf
#	core-bundle/src/Resources/contao/languages/nl/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/nl/tl_templates.xlf
#	core-bundle/src/Resources/contao/languages/pl/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/pt/exception.xlf
#	core-bundle/src/Resources/contao/languages/ru/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/sl/tl_form.xlf
#	core-bundle/src/Resources/contao/languages/sl/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/sr/tl_page.xlf
#	core-bundle/src/Resources/contao/languages/zh/tl_page.xlf
#	faq-bundle/composer.json
#	installation-bundle/composer.json
#	installation-bundle/src/Resources/translations/messages.pt.xlf
#	installation-bundle/src/Resources/translations/messages.sr.xlf
#	installation-bundle/src/Resources/translations/messages.tr.xlf
#	listing-bundle/composer.json
#	manager-bundle/composer.json
#	news-bundle/composer.json
#	newsletter-bundle/composer.json
  • Loading branch information
leofeyer committed Aug 22, 2019
2 parents 75e6eb0 + fd40881 commit 94773be
Show file tree
Hide file tree
Showing 52 changed files with 352 additions and 214 deletions.
22 changes: 11 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:

cache:
directories:
- $HOME/.composer/cache
- $HOME/.composer
- $HOME/.monorepo-split-cache

env:
Expand All @@ -30,7 +30,6 @@ jobs:
name: 'Test installing the lowest dependencies'
php: 7.3
install:
- phpenv config-rm xdebug.ini || true
- composer update --prefer-lowest --prefer-stable --no-interaction --no-suggest
script:
- run_tests
Expand All @@ -40,7 +39,6 @@ jobs:
- stage: test
php: 7.1
install:
- phpenv config-rm xdebug.ini || true
- composer update --no-interaction --no-suggest
script:
- run_tests
Expand All @@ -50,7 +48,6 @@ jobs:
- stage: test
php: 7.2
install:
- phpenv config-rm xdebug.ini || true
- composer update --no-interaction --no-suggest
script:
- run_tests
Expand All @@ -60,7 +57,6 @@ jobs:
- stage: test
php: 7.3
install:
- phpenv config-rm xdebug.ini || true
- composer update --no-interaction --no-suggest
script:
- phpdbg -qrr vendor/bin/phpunit -c calendar-bundle --coverage-clover=calendar-bundle.xml
Expand All @@ -78,7 +74,6 @@ jobs:
if: 'type = cron'
php: 7.4snapshot
install:
- phpenv config-rm xdebug.ini || true
- composer update --no-interaction --no-suggest
script:
- run_tests
Expand All @@ -90,7 +85,6 @@ jobs:
if: 'type = cron'
php: nightly
install:
- phpenv config-rm xdebug.ini || true
- composer update --ignore-platform-reqs --no-interaction --no-suggest
script:
- run_tests
Expand All @@ -102,11 +96,9 @@ jobs:
name: 'Split the monorepo'
if: 'type = push AND (branch =~ /^(master|\d+\.\d+)$/ OR tag IS present)'
php: 7.3
before_install: true
install:
- phpenv config-rm xdebug.ini || true
- rm composer.json
- composer require contao/monorepo-tools:dev-master --no-interaction --no-suggest
- update_composer_json
- composer update --no-interaction --no-suggest
script:
- php vendor/bin/monorepo-tools split $TRAVIS_BRANCH --cache-dir $HOME/.monorepo-split-cache

Expand Down Expand Up @@ -144,4 +136,12 @@ before_install:
composer update --no-interaction --no-suggest
php vendor/bin/phpunit --colors=always
}
update_composer_json () {
php -r '
$data = ["require" => ["contao/monorepo-tools" => "dev-master"]];
file_put_contents(__DIR__."/composer.json", json_encode($data, JSON_UNESCAPED_SLASHES));
'
}
- phpenv config-rm xdebug.ini || true
- composer global require symfony/flex
- mysql -e "CREATE database contao_test"
4 changes: 2 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ The following templates have been consolidated:
* `mod_eventmenu_year` -> `mod_eventmenu`
* `mod_newsmenu_day` -> `mod_newsmenu`
* `mod_newsmenu_year` -> `mod_newsmenu`
* `nl_list` -> `newsletterlist`
* `nl_reader` -> `newsletterreader`
* `nl_list` -> `mod_newsletterlist`
* `nl_reader` -> `mod_newsletterreader`

Generally, we now require the template names to match the content element or
module keys, so if your module has the key `taskList`, the corresponding
Expand Down
5 changes: 4 additions & 1 deletion calendar-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"branch-alias": {
"dev-master": "4.9.x-dev"
},
"contao-manager-plugin": "Contao\\CalendarBundle\\ContaoManager\\Plugin"
"contao-manager-plugin": "Contao\\CalendarBundle\\ContaoManager\\Plugin",
"symfony": {
"require": "^4.2"
}
},
"autoload": {
"psr-4": {
Expand Down
47 changes: 9 additions & 38 deletions calendar-bundle/src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
* @license LGPL-3.0-or-later
*/

// Add a palette selector
$GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'cal_format';

// Add palettes to tl_module
$GLOBALS['TL_DCA']['tl_module']['palettes']['calendar'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_startDay,cal_noSpan;{redirect_legend},jumpTo;{template_legend:hide},cal_ctemplate,customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_format,cal_noSpan,cal_order,cal_readerModule,cal_limit,perPage,cal_ignoreDynamic,cal_hideRunning;{template_legend:hide},cal_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_hideRunning;{template_legend:hide},cal_template,customTpl;{image_legend},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventmenu'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_format,cal_noSpan,cal_order,cal_startDay,cal_showQuantity;{redirect_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['calendar'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_startDay,cal_noSpan;{redirect_legend},jumpTo;{template_legend:hide},cal_ctemplate,customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_format,cal_noSpan,cal_order,cal_readerModule,cal_limit,perPage,cal_ignoreDynamic,cal_hideRunning;{template_legend:hide},cal_template,customTpl;{image_legend:hide},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventreader'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_hideRunning;{template_legend:hide},cal_template,customTpl;{image_legend},imgSize;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventmenu'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_format,cal_noSpan,cal_order,cal_showQuantity;{redirect_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventmenucal_day'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_format,cal_noSpan,cal_startDay,cal_showQuantity;{redirect_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';

// Add fields to tl_module
$GLOBALS['TL_DCA']['tl_module']['fields']['cal_calendar'] = array
Expand Down Expand Up @@ -56,11 +60,7 @@
'inputType' => 'select',
'options_callback' => array('tl_module_calendar', 'getFormats'),
'reference' => &$GLOBALS['TL_LANG']['tl_module'],
'eval' => array('tl_class'=>'w50', 'addWizardClass'=>false),
'wizard' => array
(
array('tl_module_calendar', 'hideStartDay')
),
'eval' => array('tl_class'=>'w50', 'submitOnChange'=>true),
'sql' => "varchar(32) NOT NULL default 'cal_month'"
);

Expand Down Expand Up @@ -217,35 +217,6 @@ public function getFormats(Contao\DataContainer $dc)
);
}

/**
* Hide the start day drop-down if not applicable
*
* @return string
*/
public function hideStartDay()
{
return '
<script>
var enableStartDay = function() {
var e1 = $("ctrl_cal_startDay").getParent("div");
var e2 = $("ctrl_cal_order").getParent("div");
if ($("ctrl_cal_format").value == "cal_day") {
e1.setStyle("display", "block");
e2.setStyle("display", "none");
} else {
e1.setStyle("display", "none");
e2.setStyle("display", "block");
}
};
window.addEvent("domready", function() {
if ($("ctrl_cal_startDay")) {
enableStartDay();
$("ctrl_cal_format").addEvent("change", enableStartDay);
}
});
</script>';
}

/**
* Return all event templates as array
*
Expand Down
5 changes: 4 additions & 1 deletion comments-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"branch-alias": {
"dev-master": "4.9.x-dev"
},
"contao-manager-plugin": "Contao\\CommentsBundle\\ContaoManager\\Plugin"
"contao-manager-plugin": "Contao\\CommentsBundle\\ContaoManager\\Plugin",
"symfony": {
"require": "^4.2"
}
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion comments-bundle/src/Resources/contao/classes/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function renderCommentForm(FrontendTemplate $objTemplate, \stdClass $o
$objPage->cache = 0;

$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
$_SESSION['TL_COMMENT_ADDED'] = false;
unset($_SESSION['TL_COMMENT_ADDED']);
}

// Store the comment
Expand Down
2 changes: 1 addition & 1 deletion comments-bundle/src/Resources/contao/dca/tl_comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public function listComments($arrRow)
return '
<div class="comment_wrap">
<div class="cte_type ' . $key . '"><a href="mailto:' . Contao\Idna::decodeEmail($arrRow['email']) . '" title="' . Contao\StringUtil::specialchars(Contao\Idna::decodeEmail($arrRow['email'])) . '">' . $arrRow['name'] . '</a>' . (($arrRow['website'] != '') ? ' (<a href="' . $arrRow['website'] . '" title="' . Contao\StringUtil::specialchars($arrRow['website']) . '" target="_blank" rel="noreferrer noopener">' . $GLOBALS['TL_LANG']['MSC']['com_website'] . '</a>)' : '') . ' – ' . Contao\Date::parse(Contao\Config::get('datimFormat'), $arrRow['date']) . ' – IP ' . Contao\StringUtil::specialchars($arrRow['ip']) . '<br>' . $title . '</div>
<div class="limit_height mark_links' . (!Contao\Config::get('doNotCollapse') ? ' h38' : '') . '">
<div class="limit_height mark_links' . (!Contao\Config::get('doNotCollapse') ? ' h40' : '') . '">
' . $arrRow['comment'] . '
</div>
</div>' . "\n ";
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@
"twig/twig": "^2.7"
},
"replace": {
"contao/core-bundle": "self.version",
"contao/calendar-bundle": "self.version",
"contao/comments-bundle": "self.version",
"contao/core-bundle": "self.version",
"contao/faq-bundle": "self.version",
"contao/installation-bundle": "self.version",
"contao/listing-bundle": "self.version",
Expand All @@ -132,7 +132,7 @@
"ext-fileinfo": "*",
"composer/composer": "^1.0",
"contao/monorepo-tools": "dev-master",
"contao/phpstan": "^0.7",
"contao/phpstan": "^0.8",
"contao/test-case": "^3.0",
"doctrine/doctrine-migrations-bundle": "^1.1",
"doctrine/event-manager": "^1.0",
Expand All @@ -148,9 +148,6 @@
"symfony/phpunit-bridge": "^4.3"
},
"extra": {
"symfony": {
"require": "^4.2"
},
"branch-alias": {
"dev-master": "4.9.x-dev"
},
Expand All @@ -164,6 +161,9 @@
"contao/manager-bundle": "Contao\\ManagerBundle\\ContaoManager\\Plugin",
"contao/news-bundle": "Contao\\NewsBundle\\ContaoManager\\Plugin",
"contao/newsletter-bundle": "Contao\\NewsletterBundle\\ContaoManager\\Plugin"
},
"symfony": {
"require": "^4.2"
}
},
"autoload": {
Expand Down
7 changes: 5 additions & 2 deletions core-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"symfony/config": "4.2.* || 4.3.*",
"symfony/console": "4.2.* || 4.3.*",
"symfony/dependency-injection": "4.2.* || 4.3.*",
"symfony/expression-language": "4.2.* || 4.3.*",
"symfony/event-dispatcher": "4.2.* || 4.3.*",
"symfony/expression-language": "4.2.* || 4.3.*",
"symfony/filesystem": "4.2.* || 4.3.*",
"symfony/finder": "4.2.* || 4.3.*",
"symfony/framework-bundle": "4.2.* || 4.3.*",
Expand Down Expand Up @@ -126,7 +126,10 @@
"branch-alias": {
"dev-master": "4.9.x-dev"
},
"contao-manager-plugin": "Contao\\CoreBundle\\ContaoManager\\Plugin"
"contao-manager-plugin": "Contao\\CoreBundle\\ContaoManager\\Plugin",
"symfony": {
"require": "^4.2"
}
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 12 additions & 1 deletion core-bundle/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
<arguments>
<array>
<element key="time-sensitive">
<array>
<element key="0"><string>Contao\CoreBundle\Command</string></element>
<element key="1"><string>Contao\CoreBundle\Tests\Command</string></element>
</array>
</element>
</array>
</arguments>
</listener>
</listeners>
</phpunit>
9 changes: 9 additions & 0 deletions core-bundle/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ static function (array $value): array {
)
);
}

if (preg_match('/[^a-z0-9_]/', (string) $name)) {
throw new \InvalidArgumentException(
sprintf(
'The image size name "%s" must consist of lowercase letters, digits and underscores only',
$name
)
);
}
}

return $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ public function preHandle(CacheEvent $event): void
{
$request = $event->getRequest();

// Not a cacheable request anyway? Then we don't care.
if (!$request->isMethodCacheable()) {
return;
}

if (!$request->cookies->count()) {
return;
}
Expand Down
42 changes: 41 additions & 1 deletion core-bundle/src/Image/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Contao\CoreBundle\Image;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\Monolog\ContaoContext;
use Contao\FilesModel;
use Contao\Image\DeferredResizerInterface;
use Contao\Image\Image;
Expand All @@ -23,6 +24,7 @@
use Contao\Image\ResizerInterface;
use Contao\ImageSizeModel;
use Imagine\Image\ImagineInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Filesystem\Filesystem;

class ImageFactory implements ImageFactoryInterface
Expand Down Expand Up @@ -77,7 +79,12 @@ class ImageFactory implements ImageFactoryInterface
*/
private $predefinedSizes = [];

public function __construct(ResizerInterface $resizer, ImagineInterface $imagine, ImagineInterface $imagineSvg, Filesystem $filesystem, ContaoFramework $framework, bool $bypassCache, array $imagineOptions, array $validExtensions, string $uploadDir)
/**
* @var ?LoggerInterface
*/
private $logger;

public function __construct(ResizerInterface $resizer, ImagineInterface $imagine, ImagineInterface $imagineSvg, Filesystem $filesystem, ContaoFramework $framework, bool $bypassCache, array $imagineOptions, array $validExtensions, string $uploadDir, ?LoggerInterface $logger = null)
{
$this->resizer = $resizer;
$this->imagine = $imagine;
Expand All @@ -88,6 +95,7 @@ public function __construct(ResizerInterface $resizer, ImagineInterface $imagine
$this->imagineOptions = $imagineOptions;
$this->validExtensions = $validExtensions;
$this->uploadDir = $uploadDir;
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -309,6 +317,38 @@ private function createImportantPart(ImageInterface $image): ?ImportantPart
return null;
}

if (
(float) $file->importantPartX + (float) $file->importantPartWidth > 1
|| (float) $file->importantPartY + (float) $file->importantPartHeight > 1
) {
if ($this->logger) {
$this->logger->warning(
sprintf(
'Invalid important part x=%s, y=%s, width=%s, height=%s for image "%s".',
$file->importantPartX,
$file->importantPartY,
$file->importantPartWidth,
$file->importantPartHeight,
$image->getPath()
),
['contao' => new ContaoContext(__METHOD__, ContaoContext::ERROR)]
);
}

try {
$size = $image->getDimensions()->getSize();

return new ImportantPart(
(float) $file->importantPartX / $size->getWidth(),
(float) $file->importantPartY / $size->getHeight(),
(float) $file->importantPartWidth / $size->getWidth(),
(float) $file->importantPartHeight / $size->getHeight()
);
} catch (\Throwable $exception) {
return new ImportantPart();
}
}

return new ImportantPart(
(float) $file->importantPartX,
(float) $file->importantPartY,
Expand Down
1 change: 1 addition & 0 deletions core-bundle/src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ services:
- '%contao.image.imagine_options%'
- '%contao.image.valid_extensions%'
- '%kernel.project_dir%/%contao.upload_path%'
- '@?logger'
public: true

contao.image.image_sizes:
Expand Down

0 comments on commit 94773be

Please sign in to comment.