Skip to content

Commit

Permalink
Merge branch '4.x' of github.com:contao/contao into feature/language-…
Browse files Browse the repository at this point in the history
…dependent-module-configuration
  • Loading branch information
bytehead committed Jan 11, 2022
2 parents d1a508f + 7186d79 commit 873e440
Show file tree
Hide file tree
Showing 98 changed files with 2,649 additions and 1,052 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ jobs:

- name: Test the single bundles
run: |
bundles=(calendar-bundle core-bundle faq-bundle maker-bundle manager-bundle news-bundle)
bundles=(calendar-bundle core-bundle faq-bundle maker-bundle manager-bundle news-bundle newsletter-bundle)
for bundle in "${bundles[@]}"; do
cd $bundle
php -r '
Expand Down
10 changes: 5 additions & 5 deletions DEPRECATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ $hasFrontendUser = System::getContainer()->get('contao.security.token_checker')-
## kernel.packages

The `kernel.packages` parameter has been deprecated in Contao 4.5 and will be
removed in Contao 5.0. Use `PackageUtil::getVersion()` instead.
removed in Contao 5.0. Use the `Composer\InstalledVersions` class instead.

```php
$coreVersion = PackageUtil::getVersion('contao/core-bundle');
$coreVersion = InstalledVersions::getPrettyVersion('contao/core-bundle');
```

## TL_ASSETS_URL and TL_FILES_URL
Expand Down Expand Up @@ -150,11 +150,11 @@ deprecated in Contao 4.0 and will no longer work in Contao 5.0.
## VERSION and BUILD

The `VERSION` and `BUILD` constants have been deprecated in Contao 4.0 and will
be removed in Contao 5.0. Use the `kernel.packages` parameter instead.
be removed in Contao 5.0. Use the `ContaoCoreBundle::getVersion()` method
instead.

```php
$packages = System::getContainer()->getParameter('kernel.packages');
$coreVersion = $packages['contao/core-bundle'];
$coreVersion = ContaoCoreBundle::getVersion();
```

## member_grouped.html5
Expand Down
2 changes: 1 addition & 1 deletion calendar-bundle/src/Resources/contao/classes/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected function generateFiles($arrFeed)
{
foreach ($event['media:content'] as $enclosure)
{
$objItem->addEnclosure($enclosure, $strLink, 'media:content');
$objItem->addEnclosure($enclosure, $strLink, 'media:content', $arrFeed['imgSize']);
}
}

Expand Down
14 changes: 12 additions & 2 deletions calendar-bundle/src/Resources/contao/dca/tl_calendar_feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
// Palettes
'palettes' => array
(
'default' => '{title_legend},title,alias,language;{calendars_legend},calendars;{config_legend},format,source,maxItems,feedBase,description'
'default' => '{title_legend},title,alias,language;{calendars_legend},calendars;{config_legend},format,source,maxItems,feedBase,description;{image_legend:hide},imgSize'
),

// Fields
Expand Down Expand Up @@ -211,7 +211,17 @@
'inputType' => 'textarea',
'eval' => array('style'=>'height:60px', 'tl_class'=>'clr'),
'sql' => "text NULL"
)
),
'imgSize' => array
(
'label' => &$GLOBALS['TL_LANG']['MSC']['imgSize'],
'exclude' => true,
'inputType' => 'imageSize',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'helpwizard'=>true, 'tl_class'=>'w50'),
'options_callback' => array('contao.listener.image_size_options', '__invoke'),
'sql' => "varchar(255) NOT NULL default ''"
),
)
);

Expand Down
2 changes: 1 addition & 1 deletion calendar-bundle/src/Resources/contao/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Add palettes to tl_module
$GLOBALS['TL_DCA']['tl_module']['palettes']['calendar'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_noSpan,cal_startDay,cal_featured;{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_noSpan,cal_format,cal_featured,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']['eventreader'] = '{title_legend},name,headline,type;{config_legend},cal_calendar,cal_hideRunning,overviewPage;{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_noSpan,cal_format,cal_featured,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_noSpan,cal_format,cal_featured,cal_startDay,cal_showQuantity;{redirect_legend},jumpTo;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID';

Expand Down
3 changes: 3 additions & 0 deletions calendar-bundle/src/Resources/contao/languages/en/default.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<trans-unit id="MSC.eventPicker">
<source>Events</source>
</trans-unit>
<trans-unit id="MSC.eventOverview">
<source>Back to the event overview</source>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<trans-unit id="tl_calendar_feed.config_legend">
<source>Feed settings</source>
</trans-unit>
<trans-unit id="tl_calendar_feed.image_legend">
<source>Image settings</source>
</trans-unit>
<trans-unit id="tl_calendar_feed.source_teaser">
<source>Event teasers</source>
</trans-unit>
Expand Down
15 changes: 13 additions & 2 deletions calendar-bundle/src/Resources/contao/modules/ModuleEventReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,19 @@ protected function compile()
global $objPage;

$this->Template->event = '';
$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];

if ($this->overviewPage)
{
$this->Template->referer = PageModel::findById($this->overviewPage)->getFrontendUrl();
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['eventOverview'];
}
else
{
trigger_deprecation('contao/calendar-bundle', '4.13', 'If you do not select an overview page in the event reader module, the "go back" link will no longer be shown in Contao 5.0.');

$this->Template->referer = 'javascript:history.go(-1)';
$this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
}

// Get the current event
$objEvent = CalendarEventsModel::findPublishedByParentAndIdOrAlias(Input::get('events'), $this->cal_calendar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

<?= $this->event ?>

<!-- indexer::stop -->
<p class="back"><a href="<?= $this->referer ?>" title="<?= $this->back ?>"><?= $this->back ?></a></p>
<!-- indexer::continue -->
<?php if ($this->referer): ?>
<!-- indexer::stop -->
<p class="back"><a href="<?= $this->referer ?>" title="<?= $this->back ?>"><?= $this->back ?></a></p>
<!-- indexer::continue -->
<?php endif; ?>

<?php if ($this->allowComments): ?>
<div class="ce_comments block">
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 @@ -147,7 +147,7 @@ public function addCommentsToTemplate(FrontendTemplate $objTemplate, \stdClass $
$objTemplate->email = $GLOBALS['TL_LANG']['MSC']['com_email'];
$objTemplate->website = $GLOBALS['TL_LANG']['MSC']['com_website'];
$objTemplate->commentsTotal = $limit ? $gtotal : $total;
$objTemplate->requestToken = System::getContainer()->get('contao.csrf.token_manager')->getFrontendTokenValue();
$objTemplate->requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();

// Add a form to create new comments
$this->renderCommentForm($objTemplate, $objConfig, $strSource, $intParent, $varNotifies);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"ext-pcre": "*",
"ext-pdo": "*",
"ext-zlib": "*",
"composer-runtime-api": "^2.0",
"ausi/slug-generator": "^1.1",
"bacon/bacon-qr-code": "^2.0",
"composer/package-versions-deprecated": "^1.8",
"contao-components/ace": "^1.2",
"contao-components/chosen": "^1.2",
"contao-components/colorbox": "^1.6",
Expand Down Expand Up @@ -230,6 +230,7 @@
"Contao\\ManagerBundle\\Tests\\": "manager-bundle/tests/",
"Contao\\NewBundle\\": "core-bundle/tests/Fixtures/vendor/contao/new-bundle/src/",
"Contao\\NewsBundle\\Tests\\": "news-bundle/tests/",
"Contao\\NewsletterBundle\\Tests\\": "newsletter-bundle/tests/",
"Contao\\TestBundle\\": "core-bundle/tests/Fixtures/vendor/contao/test-bundle/"
}
},
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"ext-pcre": "*",
"ext-pdo": "*",
"ext-zlib": "*",
"composer-runtime-api": "^2.0",
"ausi/slug-generator": "^1.1",
"bacon/bacon-qr-code": "^2.0",
"composer/package-versions-deprecated": "^1.8",
"contao-components/ace": "^1.2",
"contao-components/chosen": "^1.2",
"contao-components/colorbox": "^1.6",
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/src/Command/VersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Contao\CoreBundle\Command;

use Contao\CoreBundle\Util\PackageUtil;
use Contao\CoreBundle\ContaoCoreBundle;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -36,7 +36,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(PackageUtil::getContaoVersion());
$output->writeln(ContaoCoreBundle::getVersion());

return 0;
}
Expand Down
16 changes: 16 additions & 0 deletions core-bundle/src/ContaoCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Contao\CoreBundle;

use Composer\InstalledVersions;
use Contao\CoreBundle\DependencyInjection\Compiler\AddAssetsPackagesPass;
use Contao\CoreBundle\DependencyInjection\Compiler\AddAvailableTransportsPass;
use Contao\CoreBundle\DependencyInjection\Compiler\AddCronJobsPass;
Expand Down Expand Up @@ -119,4 +120,19 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new AddNativeTransportFactoryPass());
$container->addCompilerPass(new IntlInstalledLocalesAndCountriesPass());
}

public static function getVersion(): string
{
try {
$version = (string) InstalledVersions::getPrettyVersion('contao/core-bundle');
} catch (\OutOfBoundsException $e) {
$version = '';
}

if ('' === $version) {
$version = (string) InstalledVersions::getPrettyVersion('contao/contao');
}

return $version;
}
}
4 changes: 2 additions & 2 deletions core-bundle/src/DataCollector/ContaoDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace Contao\CoreBundle\DataCollector;

use Contao\CoreBundle\ContaoCoreBundle;
use Contao\CoreBundle\Framework\FrameworkAwareInterface;
use Contao\CoreBundle\Framework\FrameworkAwareTrait;
use Contao\CoreBundle\Security\Authentication\Token\TokenChecker;
use Contao\CoreBundle\Util\PackageUtil;
use Contao\LayoutModel;
use Contao\Model\Registry;
use Contao\PageModel;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function __construct(TokenChecker $tokenChecker, bool $legacyRouting, str

public function collect(Request $request, Response $response, \Throwable $exception = null): void
{
$this->data = ['contao_version' => PackageUtil::getContaoVersion()];
$this->data = ['contao_version' => ContaoCoreBundle::getVersion()];

$this->addSummaryData();
$this->addLegacyRoutingData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

namespace Contao\CoreBundle\DependencyInjection\Compiler;

use Contao\CoreBundle\Util\PackageUtil;
use PackageVersions\Versions;
use Composer\InstalledVersions;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Container;
Expand Down Expand Up @@ -85,14 +84,10 @@ private function addComponents(ContainerBuilder $container): void
$packages = $container->getDefinition('assets.packages');
$context = new Reference('contao.assets.assets_context');

foreach (Versions::VERSIONS as $name => $version) {
if (!Path::isBasePath('contao-components', $name)) {
continue;
}

foreach (InstalledVersions::getInstalledPackagesByType('contao-component') as $name) {
$serviceId = 'assets._package_'.$name;
$basePath = Path::join('assets', Path::makeRelative($name, 'contao-components'));
$version = $this->createVersionStrategy($container, $version, $name);
$version = $this->createVersionStrategy($container, $name);

$container->setDefinition($serviceId, $this->createPackageDefinition($basePath, $version, $context));
$packages->addMethodCall('addPackage', [$name, new Reference($serviceId)]);
Expand All @@ -112,10 +107,10 @@ private function createPackageDefinition(string $basePath, Reference $version, R
return $package;
}

private function createVersionStrategy(ContainerBuilder $container, string $version, string $name): Reference
private function createVersionStrategy(ContainerBuilder $container, string $name): Reference
{
$def = new ChildDefinition('assets.static_version_strategy');
$def->replaceArgument(0, PackageUtil::parseVersion($version));
$def->replaceArgument(0, InstalledVersions::getPrettyVersion($name));
$def->replaceArgument(1, '%%s?v=%%s');

$container->setDefinition('assets._version_'.$name, $def);
Expand Down
14 changes: 10 additions & 4 deletions core-bundle/src/DependencyInjection/Compiler/AddPackagesPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,30 @@

namespace Contao\CoreBundle\DependencyInjection\Compiler;

use Contao\CoreBundle\Util\PackageUtil;
use PackageVersions\Versions;
use Composer\InstalledVersions;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Adds the composer packages and version numbers to the container.
*
* @internal
*
* @deprecated Deprecated since Contao 4.5, to be removed in Contao 5.0; use
* the Composer\InstalledVersions class instead
*/
class AddPackagesPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$packages = [];

foreach (Versions::VERSIONS as $name => $version) {
$packages[$name] = PackageUtil::parseVersion($version);
foreach (InstalledVersions::getAllRawData() as $installed) {
foreach ($installed['versions'] as $name => $version) {
if (isset($version['pretty_version'])) {
$packages[$name] = ltrim($version['pretty_version'], 'v');
}
}
}

$container->setParameter('kernel.packages', $packages);
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->scalarNode('editable_files')
->defaultValue('css,csv,html,ini,js,json,less,md,scss,svg,svgz,txt,xliff,xml,yml,yaml')
->defaultValue('css,csv,html,ini,js,json,less,md,scss,svg,svgz,ts,txt,xliff,xml,yml,yaml')
->end()
->scalarNode('url_suffix')
->setDeprecated('contao/core-bundle', '4.10', 'The URL suffix is configured per root page since Contao 4.10. Using this option requires legacy routing.')
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/Doctrine/Backup/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function dumpData(Connection $connection, Table $table): \Generator

$rows = $connection->executeQuery(sprintf('SELECT %s FROM `%s`', implode(', ', $values), $table->getName()));

foreach ($rows->fetchAllAssociative() as $row) {
foreach ($rows->iterateAssociative() as $row) {
$insertColumns = [];
$insertValues = [];

Expand Down

0 comments on commit 873e440

Please sign in to comment.