‪TYPO3CMS  10.4
AbstractImagePreset.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
27 {
32  '/usr/local/bin/',
33  '/opt/local/bin/',
34  '/usr/bin/',
35  '/usr/X11R6/bin/',
36  '/opt/bin/',
37  'C:/php/ImageMagick/',
38  'C:/php/GraphicsMagick/',
39  'C:/apache/ImageMagick/',
40  'C:/apache/GraphicsMagick/',
41  ];
42 
46  protected ‪$foundPath = '';
47 
53  public function ‪getFoundPath()
54  {
55  return ‪$this->foundPath;
56  }
57 
64  public function ‪isActive()
65  {
66  $isActive = true;
67  foreach ($this->configurationValues as $configurationKey => $configurationValue) {
68  if ($configurationKey !== 'GFX/processor_path'
69  && $configurationKey !== 'GFX/processor_path_lzw'
70  ) {
71  $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
72  if ($currentValue !== $configurationValue) {
73  $isActive = false;
74  break;
75  }
76  }
77  }
78  return $isActive;
79  }
80 
86  public function ‪isAvailable()
87  {
88  $searchPaths = $this->‪getSearchPaths();
89  return $this->‪findExecutableInPath($searchPaths);
90  }
91 
97  public function ‪getConfigurationValues()
98  {
101  ‪$configurationValues['GFX/processor_path'] = $this->‪getFoundPath();
102  ‪$configurationValues['GFX/processor_path_lzw'] = $this->‪getFoundPath();
104  }
105 
112  abstract protected function ‪findExecutableInPath(array $searchPaths);
113 
119  protected function ‪getSearchPaths()
120  {
122 
123  // Add configured processor_path on top
124  $imPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
125  if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
126  $path = $this->‪cleanUpPath($imPath);
127  array_unshift($searchPaths, $path);
128  }
129 
130  // Add configured processor_path_lzw on top
131  $imLzwSearchPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'];
132  if ((string)$imLzwSearchPath !== '' && !in_array($imLzwSearchPath, $searchPaths)) {
133  $path = $this->‪cleanUpPath($imLzwSearchPath);
134  array_unshift($searchPaths, $path);
135  }
136 
137  // Add additional search path from form if given
138  if (isset($this->postValues['additionalSearchPath'])
139  && (string)$this->postValues['additionalSearchPath'] !== ''
140  && !in_array($this->postValues['additionalSearchPath'], $searchPaths)
141  ) {
142  $path = $this->‪cleanUpPath($this->postValues['additionalSearchPath']);
143  array_unshift($searchPaths, $path);
144  }
145 
146  return $searchPaths;
147  }
148 
155  protected function ‪cleanUpPath($path)
156  {
157  $path = GeneralUtility::fixWindowsFilePath($path);
158  // Add trailing slash if missing
159  if (!preg_match('/[\\/]$/', $path)) {
160  $path .= '/';
161  }
162  return $path;
163  }
164 }
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:27
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getConfigurationValues
‪array getConfigurationValues()
Definition: AbstractImagePreset.php:95
‪TYPO3\CMS\Install\Configuration\AbstractPreset
Definition: AbstractPreset.php:27
‪TYPO3\CMS\Install\Configuration\AbstractPreset\$configurationValues
‪array $configurationValues
Definition: AbstractPreset.php:42
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\isActive
‪bool isActive()
Definition: AbstractImagePreset.php:62
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\cleanUpPath
‪string cleanUpPath($path)
Definition: AbstractImagePreset.php:153
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getFoundPath
‪string getFoundPath()
Definition: AbstractImagePreset.php:51
‪TYPO3\CMS\Install\Configuration
Definition: AbstractCustomPreset.php:16
‪TYPO3\CMS\Install\Configuration\Image
Definition: AbstractImagePreset.php:16
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$defaultExecutableSearchPaths
‪array $defaultExecutableSearchPaths
Definition: AbstractImagePreset.php:30
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$foundPath
‪string $foundPath
Definition: AbstractImagePreset.php:44
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\isAvailable
‪bool isAvailable()
Definition: AbstractImagePreset.php:84
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getSearchPaths
‪array getSearchPaths()
Definition: AbstractImagePreset.php:117
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46