TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:31 +02:00
commit 3e43c11539
407 changed files with 51272 additions and 0 deletions
@@ -0,0 +1,152 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Install\Configuration\Image;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Configuration\AbstractPreset;
/**
* Abstract class implements common image preset code
* @internal only to be used within EXT:install
*/
abstract class AbstractImagePreset extends AbstractPreset
{
/**
* @var array Default paths to search for executable, with trailing slash
*/
protected $defaultExecutableSearchPaths = [
'/usr/local/bin/',
'/opt/local/bin/',
'/usr/bin/',
'/usr/X11R6/bin/',
'/opt/bin/',
'C:/php/ImageMagick/',
'C:/php/GraphicsMagick/',
'C:/apache/ImageMagick/',
'C:/apache/GraphicsMagick/',
];
/**
* @var string Absolute path with found executable
*/
protected $foundPath = '';
/**
* Path where executable was found
*
* @return string Found path
*/
public function getFoundPath()
{
return $this->foundPath;
}
/**
* Check is preset is currently active on the system.
* Overwrites parent method to ignore processor_path setting
*
* @return bool TRUE if preset is active
*/
public function isActive()
{
$isActive = true;
foreach ($this->configurationValues as $configurationKey => $configurationValue) {
if ($configurationKey !== 'GFX/processor_path') {
$currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
if ($currentValue !== $configurationValue) {
$isActive = false;
break;
}
}
}
return $isActive;
}
/**
* Find out if GraphicsMagick is available
*
* @return bool TRUE if GraphicsMagick executable is found in path
*/
public function isAvailable()
{
$searchPaths = $this->getSearchPaths();
return $this->findExecutableInPath($searchPaths);
}
/**
* Get configuration values to activate prefix
*
* @return array Configuration values needed to activate prefix
*/
public function getConfigurationValues()
{
$this->findExecutableInPath($this->getSearchPaths());
$configurationValues = $this->configurationValues;
$configurationValues['GFX/processor_path'] = $this->getFoundPath();
return $configurationValues;
}
/**
* Find executable in path, wrapper for specific ImageMagick/GraphicsMagick find methods.
*
* @return mixed
*/
abstract protected function findExecutableInPath(array $searchPaths);
/**
* Get list of paths to search for image handling executables
*
* @return array List of paths to search for
*/
protected function getSearchPaths()
{
$searchPaths = $this->defaultExecutableSearchPaths;
// Add configured processor_path on top
$imPath = $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
$path = $this->cleanUpPath($imPath);
array_unshift($searchPaths, $path);
}
// Add additional search path from form if given
if (isset($this->postValues['additionalSearchPath'])
&& (string)$this->postValues['additionalSearchPath'] !== ''
&& !in_array($this->postValues['additionalSearchPath'], $searchPaths)
) {
$path = $this->cleanUpPath($this->postValues['additionalSearchPath']);
array_unshift($searchPaths, $path);
}
return $searchPaths;
}
/**
* Consolidate between Windows and Unix and add trailing slash im missing
*
* @param string $path Given path
* @return string Cleaned up path
*/
protected function cleanUpPath($path)
{
$path = GeneralUtility::fixWindowsFilePath((string)$path);
// Add trailing slash if missing
if (!preg_match('/[\\/]$/', $path)) {
$path .= '/';
}
return $path;
}
}
@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Install\Configuration\Image;
use TYPO3\CMS\Install\Configuration\AbstractCustomPreset;
use TYPO3\CMS\Install\Configuration\CustomPresetInterface;
/**
* Custom preset is a fallback if no other preset fits
* @internal only to be used within EXT:install
*/
class CustomPreset extends AbstractCustomPreset implements CustomPresetInterface
{
/**
* @var array Configuration values handled by this preset
*/
protected $configurationValues = [
'GFX/processor_enabled' => false,
'GFX/processor_path' => '',
'GFX/processor' => '',
'GFX/processor_effects' => false,
'GFX/processor_colorspace' => '',
];
protected $readonlyConfigurationValues = [
'GFX/processor_path' => true,
];
}
@@ -0,0 +1,93 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Install\Configuration\Image;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\CommandUtility;
/**
* Preset for GraphicsMagick
* @internal only to be used within EXT:install
*/
class GraphicsMagickPreset extends AbstractImagePreset
{
/**
* @var string Name of preset
*/
protected $name = 'GraphicsMagick';
/**
* @var int Priority of preset
*/
protected $priority = 80;
/**
* @var array Configuration values handled by this preset
*/
protected $configurationValues = [
'GFX/processor_enabled' => true,
// processor_path is determined and set by path lookup methods
'GFX/processor_path' => '',
'GFX/processor' => 'GraphicsMagick',
'GFX/processor_effects' => false,
];
/**
* Find executable in path, wrapper for specific ImageMagick/GraphicsMagick find methods.
*
* @return mixed
*/
protected function findExecutableInPath(array $searchPaths)
{
return $this->findGraphicsMagickInPaths($searchPaths);
}
/**
* Search for GraphicsMagick executables in given paths.
*
* @param array $searchPaths List of paths to search for
* @return bool TRUE if graphics magick was found in path
*/
protected function findGraphicsMagickInPaths(array $searchPaths)
{
$result = false;
foreach ($searchPaths as $path) {
if (Environment::isWindows()) {
$executable = 'gm.exe';
} else {
$executable = 'gm';
}
$binaryPath = $path . $executable;
if (!file_exists($binaryPath) || !is_executable($binaryPath)) {
continue;
}
$command = escapeshellarg($binaryPath) . ' -version';
$executingResult = [];
@CommandUtility::exec($command, $executingResult);
// First line of exec command should contain string GraphicsMagick
$firstResultLine = array_shift($executingResult);
if (is_string($firstResultLine) && str_contains($firstResultLine, 'GraphicsMagick')) {
$this->foundPath = $path;
$result = true;
break;
}
}
return $result;
}
}
@@ -0,0 +1,55 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Install\Configuration\Image;
use TYPO3\CMS\Install\Configuration\AbstractFeature;
use TYPO3\CMS\Install\Configuration\FeatureInterface;
/**
* Image feature detects imagemagick / graphicsmagick versions
* @internal only to be used within EXT:install
*/
class ImageFeature extends AbstractFeature implements FeatureInterface
{
/**
* @var string Name of feature
*/
protected $name = 'Image';
/**
* @var array List of preset classes
*/
protected $presetRegistry = [
GraphicsMagickPreset::class,
ImageMagick6Preset::class,
CustomPreset::class,
];
/**
* Image feature can be fed with an additional path to search for executables,
* this getter returns the given input string (for Fluid)
*
* @return string
*/
public function getAdditionalSearchPath()
{
$additionalPath = '';
if (isset($this->postValues['additionalSearchPath']) && $this->postValues['additionalSearchPath'] !== '') {
$additionalPath = $this->postValues['additionalSearchPath'];
}
return $additionalPath;
}
}
@@ -0,0 +1,102 @@
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Install\Configuration\Image;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\CommandUtility;
/**
* Preset for ImageMagick version 6 or higher
* @internal only to be used within EXT:install
*/
class ImageMagick6Preset extends AbstractImagePreset
{
/**
* @var string Name of preset
*/
protected $name = 'ImageMagick6';
/**
* @var int Priority of preset
*/
protected $priority = 70;
/**
* @var array Configuration values handled by this preset
*/
protected $configurationValues = [
'GFX/processor_enabled' => true,
// processor_path is determined and set by path lookup methods
'GFX/processor_path' => '',
'GFX/processor' => 'ImageMagick',
'GFX/processor_effects' => true,
];
/**
* Find executable in path, wrapper for specific ImageMagick/GraphicsMagick find methods.
*
* @return mixed
*/
protected function findExecutableInPath(array $searchPaths)
{
return $this->findImageMagick6InPaths($searchPaths);
}
/**
* Search for GraphicsMagick executables in given paths.
*
* @param array $searchPaths List of paths to search for
* @return bool TRUE if graphics magick was found in path
*/
protected function findImageMagick6InPaths(array $searchPaths)
{
$result = false;
foreach ($searchPaths as $path) {
if (Environment::isWindows()) {
$executable = 'identify.exe';
if (!@is_file($path . $executable)) {
$executable = 'magick.exe';
}
} else {
$executable = 'identify';
}
$binaryPath = $path . $executable;
if (!file_exists($binaryPath) || !is_executable($binaryPath)) {
continue;
}
$command = escapeshellarg($binaryPath) . ' -version';
$executingResult = [];
CommandUtility::exec($command, $executingResult);
// First line of exec command should contain string GraphicsMagick
$firstResultLine = array_shift($executingResult);
// Example: "Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org"
if (is_string($firstResultLine) && str_contains($firstResultLine, 'ImageMagick')) {
[, $version] = explode('ImageMagick', $firstResultLine);
// Example: "6.6.0-4"
[$version] = explode(' ', trim($version));
if (version_compare($version, '6.0.0') >= 0) {
$this->foundPath = $path;
$result = true;
break;
}
}
}
return $result;
}
}