Showing with 3,389 additions and 2,223 deletions.
  1. +6 −1 CHANGELOG.md
  2. +7 −1 composer.json
  3. +2 −2 src/ContaoCoreBundle.php
  4. +23 −3 src/Controller/BackendController.php
  5. +0 −29 src/DataContainer/DcaFilterInterface.php
  6. +6 −5 src/DependencyInjection/Compiler/{PickerMenuProviderPass.php → PickerProviderPass.php}
  7. +3 −3 src/DependencyInjection/ContaoCoreExtension.php
  8. +16 −6 src/EventListener/CommandSchedulerListener.php
  9. +14 −23 src/EventListener/MergeHttpHeadersListener.php
  10. +2 −2 src/EventListener/PrettyErrorScreenListener.php
  11. +0 −169 src/Menu/AbstractMenuProvider.php
  12. +0 −79 src/Menu/ArticlePickerProvider.php
  13. +0 −136 src/Menu/FilePickerProvider.php
  14. +0 −79 src/Menu/PagePickerProvider.php
  15. +0 −130 src/Menu/PickerMenuBuilder.php
  16. +0 −58 src/Menu/PickerMenuBuilderInterface.php
  17. +0 −76 src/Menu/PickerMenuProviderInterface.php
  18. +153 −0 src/Picker/AbstractPickerProvider.php
  19. +81 −0 src/Picker/ArticlePickerProvider.php
  20. +48 −0 src/Picker/DcaPickerProviderInterface.php
  21. +191 −0 src/Picker/FilePickerProvider.php
  22. +105 −0 src/Picker/PagePickerProvider.php
  23. +116 −0 src/Picker/Picker.php
  24. +143 −0 src/Picker/PickerBuilder.php
  25. +58 −0 src/Picker/PickerBuilderInterface.php
  26. +185 −0 src/Picker/PickerConfig.php
  27. +49 −0 src/Picker/PickerInterface.php
  28. +73 −0 src/Picker/PickerProviderInterface.php
  29. +1 −0 src/Resources/config/listener.yml
  30. +38 −38 src/Resources/config/services.yml
  31. +0 −4 src/Resources/contao/classes/Ajax.php
  32. +25 −25 src/Resources/contao/classes/Backend.php
  33. +60 −99 src/Resources/contao/classes/DataContainer.php
  34. +14 −13 src/Resources/contao/config/agents.php
  35. +1 −1 src/Resources/contao/config/constants.php
  36. +16 −7 src/Resources/contao/controllers/BackendMain.php
  37. +1 −1 src/Resources/contao/dca/tl_article.php
  38. +4 −4 src/Resources/contao/dca/tl_content.php
  39. +2 −2 src/Resources/contao/dca/tl_form_field.php
  40. +1 −1 src/Resources/contao/dca/tl_image_size_item.php
  41. +1 −1 src/Resources/contao/dca/tl_layout.php
  42. +1 −1 src/Resources/contao/dca/tl_member.php
  43. +1 −1 src/Resources/contao/dca/tl_member_group.php
  44. +1 −1 src/Resources/contao/dca/tl_page.php
  45. +1 −1 src/Resources/contao/dca/tl_style.php
  46. +1 −1 src/Resources/contao/dca/tl_user.php
  47. +1 −1 src/Resources/contao/dca/tl_user_group.php
  48. +53 −63 src/Resources/contao/drivers/DC_Folder.php
  49. +46 −21 src/Resources/contao/drivers/DC_Table.php
  50. +1 −1 src/Resources/contao/forms/Form.php
  51. +3 −0 src/Resources/contao/languages/fr/default.xlf
  52. +2 −0 src/Resources/contao/languages/fr/tl_content.xlf
  53. +1 −0 src/Resources/contao/languages/fr/tl_form_field.xlf
  54. +4 −1 src/Resources/contao/languages/fr/tl_layout.xlf
  55. +1 −0 src/Resources/contao/languages/fr/tl_settings.xlf
  56. +1 −0 src/Resources/contao/languages/nl/tl_settings.xlf
  57. +1 −0 src/Resources/contao/languages/ru/tl_settings.xlf
  58. +1 −0 src/Resources/contao/languages/sr/tl_settings.xlf
  59. +2 −1 src/Resources/contao/library/Contao/Database.php
  60. +0 −1 src/Resources/contao/templates/backend/be_alerts.html5
  61. +0 −1 src/Resources/contao/templates/backend/be_confirm.html5
  62. +0 −1 src/Resources/contao/templates/backend/be_conflict.html5
  63. +0 −1 src/Resources/contao/templates/backend/be_diff.html5
  64. +0 −1 src/Resources/contao/templates/backend/be_help.html5
  65. +0 −1 src/Resources/contao/templates/backend/be_login.html5
  66. +1 −2 src/Resources/contao/templates/backend/be_main.html5
  67. +0 −1 src/Resources/contao/templates/backend/be_password.html5
  68. +0 −1 src/Resources/contao/templates/backend/be_picker.html5
  69. +0 −1 src/Resources/contao/templates/backend/be_popup.html5
  70. +0 −1 src/Resources/contao/templates/backend/be_switch.html5
  71. +2 −1 src/Resources/contao/templates/backend/be_tinyFlash.html5
  72. +2 −1 src/Resources/contao/templates/backend/be_tinyMCE.html5
  73. +2 −1 src/Resources/contao/templates/backend/be_tinyNews.html5
  74. +1 −9 src/Resources/contao/templates/forms/form_wrapper.html5
  75. +11 −0 src/Resources/contao/templates/js/js_autofocus.html5
  76. +0 −8 src/Resources/contao/templates/member/member_default.html5
  77. +0 −8 src/Resources/contao/templates/member/member_grouped.html5
  78. +0 −8 src/Resources/contao/templates/modules/mod_changePassword.html5
  79. +1 −9 src/Resources/contao/templates/modules/mod_login.html5
  80. +0 −8 src/Resources/contao/templates/modules/mod_password.html5
  81. +1 −1 src/Resources/contao/themes/flexible/basic.css
  82. +1 −1 src/Resources/contao/themes/flexible/main.css
  83. +3 −4 src/Resources/contao/themes/flexible/src/basic.css
  84. +22 −16 src/Resources/contao/themes/flexible/src/main.css
  85. +39 −50 src/Resources/contao/widgets/FileTree.php
  86. +42 −65 src/Resources/contao/widgets/PageTree.php
  87. +8 −13 src/Resources/public/core.js
  88. +2 −3 src/Resources/public/core.min.js
  89. BIN src/Resources/public/favicon.ico
  90. +2 −2 tests/Contao/EnvironmentTest.php
  91. +79 −10 tests/Controller/BackendControllerTest.php
  92. +3 −1 tests/Cors/WebsiteRootsConfigProviderTest.php
  93. +0 −77 tests/DependencyInjection/Compiler/PickerMenuProviderPassTest.php
  94. +90 −82 tests/DependencyInjection/ContaoCoreExtensionTest.php
  95. +79 −4 tests/EventListener/CommandSchedulerListenerTest.php
  96. +5 −8 tests/EventListener/MergeHttpHeadersListenerTest.php
  97. +0 −156 tests/Menu/AbstractMenuProviderTest.php
  98. +0 −124 tests/Menu/ArticlePickerProviderTest.php
  99. +0 −184 tests/Menu/FilePickerProviderTest.php
  100. +0 −124 tests/Menu/PagePickerProviderTest.php
  101. +0 −142 tests/Menu/PickerMenuBuilderTest.php
  102. +263 −0 tests/Picker/ArticlePickerProviderTest.php
  103. +362 −0 tests/Picker/FilePickerProviderTest.php
  104. +285 −0 tests/Picker/PagePickerProviderTest.php
  105. +194 −0 tests/Picker/PickerBuilderTest.php
  106. +160 −0 tests/Picker/PickerConfigTest.php
  107. +162 −0 tests/Picker/PickerTest.php
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Contao core bundle change log

### 4.4.2 (2017-07-25)

* Adjust the command scheduler listener so it does not rely on request parameters (see #955).
* Rewrite the DCA picker (see #950).

### 4.4.1 (2017-07-12)

* Prevent arbitrary PHP file inclusions in the back end (see CVE-2017-10993).
* Correctly handle subpalettes in "edit multiple" mode (see #946).
* Correctly handle subpalettes in "edit multiple" mode (see #946).
* Correctly show the DCA picker in the site structure (see #906).
* Correctly update the style sheets if a format definition is enabled/disabled (see #893).
* Always show the "show from" and "show until" fields (see #908).
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/filesystem": "^3.3",
"symfony/finder": "^3.3",
"symfony/framework-bundle": "^3.3",
"symfony/http-foundation": "^3.3",
"symfony/http-foundation": "^3.3.5",
"symfony/security": "^3.3",
"symfony/yaml": "^3.3",
"sensio/framework-extra-bundle": "^3.0.2",
Expand Down Expand Up @@ -123,6 +123,12 @@
"config": {
"preferred-install": "dist"
},
"support": {
"docs": "https://docs.contao.org",
"forum": "https://community.contao.org",
"issues": "https://github.com/contao/core-bundle/issues",
"source": "https://github.com/contao/core-bundle"
},
"extra": {
"branch-alias": {
"dev-release/4.4.0": "4.4.x-dev"
Expand Down
4 changes: 2 additions & 2 deletions src/ContaoCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Contao\CoreBundle\DependencyInjection\Compiler\AddResourcesPathsPass;
use Contao\CoreBundle\DependencyInjection\Compiler\AddSessionBagsPass;
use Contao\CoreBundle\DependencyInjection\Compiler\DoctrineMigrationsPass;
use Contao\CoreBundle\DependencyInjection\Compiler\PickerMenuProviderPass;
use Contao\CoreBundle\DependencyInjection\Compiler\PickerProviderPass;
use Contao\CoreBundle\DependencyInjection\ContaoCoreExtension;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -63,6 +63,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new AddResourcesPathsPass());
$container->addCompilerPass(new AddImagineClassPass());
$container->addCompilerPass(new DoctrineMigrationsPass());
$container->addCompilerPass(new PickerMenuProviderPass());
$container->addCompilerPass(new PickerProviderPass());
}
}
26 changes: 23 additions & 3 deletions src/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
use Contao\BackendPopup;
use Contao\BackendPreview;
use Contao\BackendSwitch;
use Contao\CoreBundle\Picker\PickerConfig;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

/**
* Handles the Contao backend routes.
Expand Down Expand Up @@ -214,18 +216,36 @@ public function alertsAction()
}

/**
* Handles the picker redirect.
* Redirects the user to the Contao back end and includes the picker query parameter. It will determine
* the current provider URL based on the value (usually read dynamically via JavaScript).
*
* @param Request $request
*
* @throws BadRequestHttpException
*
* @return RedirectResponse
*
* @Route("/_contao/picker", name="contao_backend_picker")
*/
public function pickerAction(Request $request)
{
$pickerBuilder = $this->container->get('contao.menu.picker_menu_builder');
$extras = [];

if ($request->query->has('extras')) {
$extras = $request->query->get('extras');

if (!is_array($extras)) {
throw new BadRequestHttpException('Invalid picker extras');
}
}

$config = new PickerConfig($request->query->get('context'), $extras, $request->query->get('value'));
$picker = $this->container->get('contao.picker.builder')->create($config);

if (null === $picker) {
throw new BadRequestHttpException('Unsupported picker context');
}

return new RedirectResponse($pickerBuilder->getPickerUrl($request));
return new RedirectResponse($picker->getCurrentUrl());
}
}
29 changes: 0 additions & 29 deletions src/DataContainer/DcaFilterInterface.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Registers the picker menu providers.
* Registers the picker providers.
*
* @author Leo Feyer <https://github.com/leofeyer>
* @author Andreas Schempp <https://github.com/aschempp>
*/
class PickerMenuProviderPass implements CompilerPassInterface
class PickerProviderPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

Expand All @@ -28,12 +29,12 @@ class PickerMenuProviderPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container)
{
if (!$container->has('contao.menu.picker_menu_builder')) {
if (!$container->has('contao.picker.builder')) {
return;
}

$definition = $container->findDefinition('contao.menu.picker_menu_builder');
$references = $this->findAndSortTaggedServices('contao.picker_menu_provider', $container);
$definition = $container->findDefinition('contao.picker.builder');
$references = $this->findAndSortTaggedServices('contao.picker_provider', $container);

foreach ($references as $reference) {
$definition->addMethodCall('addProvider', [$reference]);
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/ContaoCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Contao\CoreBundle\DependencyInjection;

use Contao\CoreBundle\Menu\PickerMenuProviderInterface;
use Contao\CoreBundle\Picker\PickerProviderInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
Expand Down Expand Up @@ -90,8 +90,8 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
$this->overwriteImageTargetDir($mergedConfig, $container);

$container
->registerForAutoconfiguration(PickerMenuProviderInterface::class)
->addTag('contao.picker_menu_provider')
->registerForAutoconfiguration(PickerProviderInterface::class)
->addTag('contao.picker_provider')
;
}

Expand Down
22 changes: 16 additions & 6 deletions src/EventListener/CommandSchedulerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@ class CommandSchedulerListener
*/
private $connection;

/**
* @var string
*/
private $fragmentPath;

/**
* Constructor.
*
* @param ContaoFrameworkInterface $framework
* @param Connection $connection
* @param string $fragmentPath
*/
public function __construct(ContaoFrameworkInterface $framework, Connection $connection)
public function __construct(ContaoFrameworkInterface $framework, Connection $connection, $fragmentPath = '_fragment')
{
$this->framework = $framework;
$this->connection = $connection;
$this->fragmentPath = $fragmentPath;
}

/**
Expand Down Expand Up @@ -72,14 +79,17 @@ public function onKernelTerminate(PostResponseEvent $event)
*/
private function canRunController(Request $request)
{
$pathInfo = $request->getPathInfo();

// Skip the listener in the install tool and upon fragment URLs
if (preg_match('~(?:^|/)(?:contao/install$|'.preg_quote($this->fragmentPath, '~').'/)~', $pathInfo)) {
return false;
}

/** @var Config $config */
$config = $this->framework->getAdapter(Config::class);

return $config->isComplete()
&& !$config->get('disableCron')
&& in_array($request->attributes->get('_route'), ['contao_backend', 'contao_frontend'], true)
&& $this->canRunDbQuery()
;
return $config->isComplete() && !$config->get('disableCron') && $this->canRunDbQuery();
}

/**
Expand Down
37 changes: 14 additions & 23 deletions src/EventListener/MergeHttpHeadersListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class MergeHttpHeadersListener
private $framework;

/**
* @var array
* @var array|null
*/
private $headers = [];
private $headers;

/**
* @var array
Expand All @@ -46,30 +46,11 @@ class MergeHttpHeadersListener
* Constructor.
*
* @param ContaoFrameworkInterface $framework
* @param array|null $headers Meant for unit testing only!
*/
public function __construct(ContaoFrameworkInterface $framework)
public function __construct(ContaoFrameworkInterface $framework, array $headers = null)
{
$this->framework = $framework;
$this->setHeaders(headers_list());
}

/**
* Returns the headers.
*
* @return array
*/
public function getHeaders()
{
return $this->headers;
}

/**
* Sets the headers.
*
* @param array $headers
*/
public function setHeaders(array $headers)
{
$this->headers = $headers;
}

Expand Down Expand Up @@ -161,6 +142,16 @@ private function mergeHttpHeaders(Response $response)
return $response;
}

/**
* Returns the headers.
*
* @return array
*/
private function getHeaders()
{
return $this->headers ?: headers_list();
}

/**
* Returns the unique header key.
*
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/PrettyErrorScreenListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Contao\CoreBundle\Exception\NoActivePageFoundException;
use Contao\CoreBundle\Exception\NoLayoutSpecifiedException;
use Contao\CoreBundle\Exception\NoRootPageFoundException;
use Contao\CoreBundle\Exception\RedirectResponseException;
use Contao\CoreBundle\Exception\ResponseException;
use Contao\CoreBundle\Framework\ContaoFrameworkInterface;
use Contao\PageError404;
use Contao\StringUtil;
Expand Down Expand Up @@ -200,7 +200,7 @@ private function getResponseFromPageHandler($type)

try {
return $pageHandler->getResponse();
} catch (RedirectResponseException $e) {
} catch (ResponseException $e) {
return $e->getResponse();
} catch (\Exception $e) {
return null;
Expand Down
Loading