Showing with 4,258 additions and 1,889 deletions.
  1. +4 −2 .gitignore
  2. +111 −4 CHANGELOG.md
  3. +17 −0 DEPRECATED.md
  4. +35 −0 appveyor.yml
  5. +2 −3 composer.json
  6. +11 −86 src/Command/SymlinksCommand.php
  7. +1 −1 src/Config/Loader/XliffFileLoader.php
  8. +0 −4 src/ContaoFramework.php
  9. +2 −2 src/EventListener/ExceptionConverterListener.php
  10. +53 −25 src/EventListener/PrettyErrorScreenListener.php
  11. +1 −0 src/EventListener/StoreRefererListener.php
  12. +6 −0 src/HttpKernel/Bundle/ContaoModuleBundle.php
  13. +2 −2 src/Resources/config/listener.yml
  14. +113 −8 src/Resources/contao/classes/Backend.php
  15. +2 −2 src/Resources/contao/classes/DataContainer.php
  16. +7 −0 src/Resources/contao/classes/Versions.php
  17. +2 −0 src/Resources/contao/config/autoload.php
  18. +0 −1 src/Resources/contao/config/config.php
  19. +2 −0 src/Resources/contao/config/ide_compat.php
  20. +14 −1 src/Resources/contao/controllers/BackendHelp.php
  21. +10 −1 src/Resources/contao/controllers/FrontendIndex.php
  22. +2 −2 src/Resources/contao/dca/tl_article.php
  23. +6 −35 src/Resources/contao/dca/tl_content.php
  24. +1 −1 src/Resources/contao/dca/tl_form_field.php
  25. +1 −1 src/Resources/contao/dca/tl_image_size_item.php
  26. +2 −2 src/Resources/contao/dca/tl_member.php
  27. +2 −2 src/Resources/contao/dca/tl_member_group.php
  28. +1 −1 src/Resources/contao/dca/tl_module.php
  29. +1 −1 src/Resources/contao/dca/tl_page.php
  30. +1 −1 src/Resources/contao/dca/tl_style.php
  31. +2 −2 src/Resources/contao/dca/tl_templates.php
  32. +2 −2 src/Resources/contao/dca/tl_user.php
  33. +2 −2 src/Resources/contao/dca/tl_user_group.php
  34. +37 −9 src/Resources/contao/drivers/DC_Folder.php
  35. +21 −0 src/Resources/contao/drivers/DC_Table.php
  36. +12 −2 src/Resources/contao/helper/functions.php
  37. +1 −1 src/Resources/contao/languages/en/default.xlf
  38. +2 −20 src/Resources/contao/languages/en/exception.xlf
  39. +4 −4 src/Resources/contao/languages/en/explain.xlf
  40. +3 −3 src/Resources/contao/languages/en/tl_style.xlf
  41. +6 −1 src/Resources/contao/library/Contao/Automator.php
  42. +9 −1 src/Resources/contao/library/Contao/Combiner.php
  43. +53 −37 src/Resources/contao/library/Contao/Controller.php
  44. +521 −0 src/Resources/contao/library/Contao/Database/Installer.php
  45. +1,032 −0 src/Resources/contao/library/Contao/Database/Updater.php
  46. +48 −33 src/Resources/contao/library/Contao/Date.php
  47. +7 −1 src/Resources/contao/library/Contao/DcaExtractor.php
  48. +3 −3 src/Resources/contao/library/Contao/Environment.php
  49. +1 −1 src/Resources/contao/library/Contao/Feed.php
  50. +95 −40 src/Resources/contao/library/Contao/File.php
  51. +2 −0 src/Resources/contao/library/Contao/Folder.php
  52. +54 −20 src/Resources/contao/library/Contao/Image.php
  53. +9 −0 src/Resources/contao/library/Contao/InsertTags.php
  54. +9 −7 src/Resources/contao/library/Contao/Model.php
  55. +12 −12 src/Resources/contao/library/Contao/Model/Registry.php
  56. +2 −0 src/Resources/contao/library/Contao/System.php
  57. +1 −1 src/Resources/contao/library/Contao/Validator.php
  58. +1 −1 src/Resources/contao/library/Contao/ZipWriter.php
  59. +49 −49 src/Resources/contao/models/ArticleModel.php
  60. +205 −167 src/Resources/contao/models/ContentModel.php
  61. +32 −32 src/Resources/contao/models/FilesModel.php
  62. +75 −75 src/Resources/contao/models/FormFieldModel.php
  63. +41 −41 src/Resources/contao/models/FormModel.php
  64. +29 −29 src/Resources/contao/models/ImageSizeItemModel.php
  65. +25 −25 src/Resources/contao/models/ImageSizeModel.php
  66. +87 −87 src/Resources/contao/models/LayoutModel.php
  67. +42 −37 src/Resources/contao/models/MemberGroupModel.php
  68. +77 −77 src/Resources/contao/models/MemberModel.php
  69. +237 −237 src/Resources/contao/models/ModuleModel.php
  70. +132 −101 src/Resources/contao/models/PageModel.php
  71. +20 −20 src/Resources/contao/models/SessionModel.php
  72. +123 −123 src/Resources/contao/models/StyleModel.php
  73. +24 −24 src/Resources/contao/models/StyleSheetModel.php
  74. +21 −21 src/Resources/contao/models/ThemeModel.php
  75. +59 −59 src/Resources/contao/models/UserGroupModel.php
  76. +96 −96 src/Resources/contao/models/UserModel.php
  77. +1 −1 src/Resources/contao/modules/ModuleLogin.php
  78. +42 −3 src/Resources/contao/pages/PageForward.php
  79. +28 −1 src/Resources/contao/pages/PageRedirect.php
  80. +49 −12 src/Resources/contao/pages/PageRoot.php
  81. +5 −1 src/Resources/contao/templates/backend/be_popup.html5
  82. +2 −0 src/Resources/contao/templates/jquery/j_accordion.html5
  83. +1 −1 src/Resources/contao/templates/mootools/moo_accordion.html5
  84. +6 −6 src/Resources/contao/widgets/FileSelector.php
  85. +5 −5 src/Resources/contao/widgets/FileTree.php
  86. +1 −1 src/Resources/contao/widgets/MetaWizard.php
  87. +1 −1 src/Resources/contao/widgets/PageTree.php
  88. +0 −10 src/Resources/views/Error/access_denied.html.twig
  89. +0 −10 src/Resources/views/Error/page_not_found.html.twig
  90. +75 −0 src/Util/SymlinkUtil.php
  91. +1 −1 tests/Command/AutomatorCommandTest.php
  92. +3 −3 tests/Command/InstallCommandTest.php
  93. +1 −66 tests/Command/SymlinksCommandTest.php
  94. +1 −1 tests/Command/VersionCommandTest.php
  95. +10 −0 tests/Contao/EnvironmentTest.php
  96. +177 −18 tests/Contao/ImageTest.php
  97. +9 −3 tests/DependencyInjection/Compiler/AddResourcesPathsPassTest.php
  98. +27 −50 tests/EventListener/PrettyErrorScreenListenerTest.php
  99. +8 −2 tests/EventListener/StoreRefererListenerTest.php
  100. +1 −0 tests/Fixtures/app/logs/.gitignore
  101. +1 −0 tests/Fixtures/assets/.gitignore
  102. +1 −0 tests/Fixtures/system/themes/.gitignore
  103. +1 −1 tests/TestCase.php
  104. +63 −0 tests/Util/SymlinkUtilTest.php
  105. +1 −1 tests/bootstrap.php
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

# Tests
/tests/Fixtures/app/cache/contao/
/tests/Fixtures/assets/
/tests/Fixtures/assets/*
!/tests/Fixtures/assets/.gitignore
/tests/Fixtures/system/cache/
/tests/Fixtures/system/config/
/tests/Fixtures/system/logs/
/tests/Fixtures/system/themes/
/tests/Fixtures/system/themes/*
!/tests/Fixtures/system/themes/.gitignore
/tests/Fixtures/system/tmp/
/tests/Fixtures/web/

Expand Down
115 changes: 111 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,112 @@
Contao change log
=================
Contao core bundle change log
=============================

Version 4.0.3 (2015-09-10)
--------------------------

### Fixed
Strip the `web/` prefix in the `Image::get()` method (see #337).

### Fixed
Update the symlinks after a file or folder has been renamed (see #332).

### Fixed
Correctly trigger the command scheduler in the front end (see #340).

### Fixed
Handle legacy page types not returning a response object (see #331).

### Fixed
Correctly add the bundle style sheets in debug mode (see #328).

### Fixed
Register the related models in the registry (see #333).

### Fixed
Make sure that `TABLE_OPTIONS` is not an array (see #324).

### Fixed
Throw an exception if a module folder does not exist (see #326).

### Fixed
Add the missing `getResponse()` method to the respective page types.

### Fixed
Correctly validate paths in the template editor (see #325).

### Fixed
Correctly handle dimensionless SVG images (see #7882).

### Fixed
Enable the `strictMath` option of the LESS parser (see #7985).

### Fixed
Consider the pagination menu when inserting at the top (see #7895).

### Fixed
Store the correct edit URL in the back end personal data module (see #7987).

### Fixed
Adjust the breadcrumb trail when creating new folders (see #7980).

### Fixed
Convert the HTML content to XHTML when generating Atom feeds (see #7996).

### Fixed
Correctly link the items in the files breadcrumb menu (see #7965).

### Fixed
Handle explicit collations matching the default collation (see #7979).

### Fixed
Fix the duplicate content check in the front end controller (see #7661).

### Fixed
Correctly parse dates in MooTools (see #7983).

### Fixed
Correctly escape in the `findMultipleFilesByFolder()` method (see #7966).

### Fixed
Override the tabindex handling of the accordion to ensure that the togglers are
always focusable via keyboard (see #7963).

### Fixed
Check the script when storing the front end referer (see #7908).

### Fixed
Fix the back end pagination menu (see #7956).

### Fixed
Handle option callbacks in the back end help (see #7951).

### Fixed
Fixed the external links in the text field help wizard (see #7954) and the
keyboard shortcuts link on the back end start page (see #7935).

### Fixed
Fixed the CSS group field explanations (see #7949).

### Fixed
Use ./ instead of an empty href (see #7967).

### Fixed
Correctly detect Microsoft Edge (see #7970).

### Fixed
Respect the "order" parameter in the `findMultipleByIds()` method (see #7940).

### Fixed
Always trigger the "parseDate" hook (see #4260).

### Fixed
Allow to instantiate the `InsertTags` class (see #7946).

### Fixed
Do not parse the image `src` attribute to determine the state of an element,
because the image path might have been replaced with a `data:` string (e.g. by
the Apache module "mod_pagespeed").


Version 4.0.2 (2015-08-04)
--------------------------
Expand All @@ -18,7 +125,7 @@ Support overwriting the CSS ID in an alias element (see #305).
Add a `StringUtil` class to restore PHP 7 compatibility (see #309).

### Fixed
Correctly handle files in the `/web` directory in the Combiner (see #300).
Correctly handle files in the `/web` directory in the Combiner (see #300).

### Fixed
Fix the argument order of the `ondelete_callback` (see #301).
Expand All @@ -30,7 +137,7 @@ Correctly apply the class `active` in the pagination template (see #315).
Fix the `Validator::isEmail()` method (see #313).

### Fixed
Strip tags before auto-generating aliases (see contao/core#7857).
Strip tags before auto-generating aliases (see contao/core#7857).

### Fixed
Correctly encode the URLs in the popup file manager (see contao/core#7929).
Expand Down
17 changes: 17 additions & 0 deletions DEPRECATED.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Deprecated features
===================

### Page handler without getResponse()

Using a custom page handler without a `getResponse()` method has been
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.

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


### member_grouped.html5

Accessing the field groups via one of the following properties in the
Expand Down
35 changes: 35 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
build: false
shallow_clone: true
platform: x86
clone_folder: c:\projects\contao

install:
- cinst -y OpenSSL.Light
- SET PATH=C:\Program Files\OpenSSL;%PATH%
- cinst -y php
- cd c:\tools\php
- copy php.ini-production php.ini
- echo date.timezone="UTC" >> php.ini
- echo extension_dir=ext >> php.ini
- echo extension=php_bz2.dll >> php.ini
- echo extension=php_curl.dll >> php.ini
- echo extension=php_fileinfo.dll >> php.ini
- echo extension=php_exif.dll >> php.ini
- echo extension=php_gd2.dll >> php.ini
- echo extension=php_intl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo extension=php_mysqli.dll >> php.ini
- echo extension=php_openssl.dll >> php.ini
- echo extension=php_pdo_mysql.dll >> php.ini
- echo extension=php_soap.dll >> php.ini
- echo extension=php_sockets.dll >> php.ini
- echo extension=php_xmlrpc.dll >> php.ini
- echo extension=php_xsl.dll >> php.ini
- SET PATH=c:\tools\php;%PATH%
- cd c:\projects\contao
- php -r "readfile('http://getcomposer.org/installer');" | php
- php composer.phar install --prefer-source --no-interaction

test_script:
- cd c:\projects\contao
- vendor\bin\phpunit.bat
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/swiftmailer-bundle": "~2.3",
"symfony/yaml": "~2.7",
"sensio/framework-extra-bundle": "^3.0.2",
"twig/twig": "~1.18",
"twig/twig": "~1.20",
"doctrine/doctrine-bundle": "~1.4",
"leafo/scssphp": "~0.1",
"matthiasmullie/minify": "~1.3",
Expand Down Expand Up @@ -49,8 +49,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "4.1.x-dev",
"dev-hotfix/4.0.2": "4.0.x-dev"
"dev-develop": "4.1.x-dev"
}
}
}
97 changes: 11 additions & 86 deletions src/Command/SymlinksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
namespace Contao\CoreBundle\Command;

use Contao\CoreBundle\Analyzer\HtaccessAnalyzer;
use Contao\CoreBundle\Util\SymlinkUtil;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
Expand Down Expand Up @@ -119,9 +119,9 @@ private function symlinkThemes()
$themes = $this->getContainer()->get('contao.resource_finder')->findIn('themes')->depth(0)->directories();

foreach ($themes as $theme) {
$path = str_replace($this->rootDir . DIRECTORY_SEPARATOR, '', $theme->getPathname());
$path = str_replace(strtr($this->rootDir, '\\', '/') . '/', '', strtr($theme->getPathname(), '\\', '/'));

if (0 === strpos(strtr($path, '\\', '/'), 'system/modules/')) {
if (0 === strpos($path, 'system/modules/')) {
continue;
}

Expand Down Expand Up @@ -155,92 +155,17 @@ private function createSymlinksFromFinder(Finder $finder, $prepend)
*/
private function symlink($source, $target)
{
$this->validateSymlink($source, $target);

$fs = new Filesystem();

try {
$fs->symlink(
rtrim($fs->makePathRelative($source, dirname($target)), '/'),
$this->rootDir . '/' . $target
);
} catch (IOException $e) {
$fs->symlink($this->rootDir . '/' . $source, $this->rootDir . '/' . $target);
}

$this->fixSymlinkPermissions($target);
SymlinkUtil::symlink($source, $target, $this->rootDir);

$this->output->writeln(
sprintf('Added <comment>%s</comment> as symlink to <comment>%s</comment>.', $target, $source)
sprintf(
'Added <comment>%s</comment> as symlink to <comment>%s</comment>.',
strtr($target, '\\', '/'),
strtr($source, '\\', '/')
)
);
}

/**
* Validates a symlink.
*
* @param string $source The symlink name
* @param string $target The symlink target
*
* @throws \InvalidArgumentException If the source or target is invalid
* @throws \LogicException If the symlink cannot be created
*/
private function validateSymlink($source, $target)
{
if ('' === $source) {
throw new \InvalidArgumentException('The symlink source must not be empty.');
}

if ('' === $target) {
throw new \InvalidArgumentException('The symlink target must not be empty.');
}

if (false !== strpos($target, '../')) {
throw new \InvalidArgumentException('The symlink target must not be relative.');
}

$fs = new Filesystem();

if ($fs->exists($this->rootDir . '/' . $target) && !is_link($this->rootDir . '/' . $target)) {
throw new \LogicException('The symlink target "' . $target . '" exists and is not a symlink.');
}
}

/**
* Fixes the symlink permissions.
*
* @param string $target The symlink target
*/
private function fixSymlinkPermissions($target)
{
$stat = lstat($this->rootDir . '/' . $target);

// Try to fix the UID
if ($stat['uid'] !== getmyuid()) {
$this->changeOwnership($target, 'lchown', getmyuid());
}

// Try to fix the GID
if ($stat['gid'] !== getmygid()) {
$this->changeOwnership($target, 'lchgrp', getmygid());
}
}

/**
* Changes the ownership of a symlink.
*
* @param string $target The symlink
* @param string $function The function name
* @param int $id The user or group ID
*/
private function changeOwnership($target, $function, $id)
{
if (!function_exists($function)) {
return;
}

$function($this->rootDir . '/' . $target, $id);
}

/**
* Returns a finder instance to find files in the given path.
*
Expand All @@ -263,9 +188,9 @@ private function getFilterClosure()
return function (SplFileInfo $file) {
static $paths;

$dir = str_replace($this->rootDir . DIRECTORY_SEPARATOR, '', $file->getPath());
$dir = str_replace(strtr($this->rootDir, '\\', '/') . '/', '', strtr($file->getPath(), '\\', '/'));
$paths[] = $dir;
$chunks = explode(DIRECTORY_SEPARATOR, $dir);
$chunks = explode('/', $dir);
$test = $chunks[0];

for ($i = 1, $c = count($chunks); $i < $c; ++$i) {
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Loader/XliffFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private function convertXlfToPhp($name, $language)
{
$xml = $this->getDomDocumentFromFile($name);

$return = "\n// " . str_replace($this->rootDir . DIRECTORY_SEPARATOR, '', $name) . "\n";
$return = "\n// " . str_replace(strtr($this->rootDir, '\\', '/') . '/', '', strtr($name, '\\', '/')) . "\n";
$units = $xml->getElementsByTagName('trans-unit');

/** @var \DOMElement[] $units */
Expand Down
4 changes: 0 additions & 4 deletions src/ContaoFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ private function initializeFramework()
error_reporting($this->errorLevel);

$this->includeHelpers();

// TODO: use Monolog to log errors
$this->iniSet('error_log', $this->rootDir . '/system/logs/error.log');

$this->includeBasicClasses();

// Set the container
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/ExceptionConverterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;

Expand Down Expand Up @@ -66,7 +66,7 @@ public function onKernelException(GetResponseForExceptionEvent $event)
* @param \Exception $exception The exception object
* @param string $target The target exception
*
* @return HttpExceptionInterface|null The HTTP exception or null
* @return HttpException|null The HTTP exception or null
*/
private function convertToHttpException(\Exception $exception, $target)
{
Expand Down
Loading