‪TYPO3CMS  9.5
AbstractImagePreset.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
24 {
29  '/usr/local/bin/',
30  '/opt/local/bin/',
31  '/usr/bin/',
32  '/usr/X11R6/bin/',
33  '/opt/bin/',
34  'C:/php/ImageMagick/',
35  'C:/php/GraphicsMagick/',
36  'C:/apache/ImageMagick/',
37  'C:/apache/GraphicsMagick/',
38  ];
39 
43  protected ‪$foundPath = '';
44 
50  public function ‪getFoundPath()
51  {
52  return ‪$this->foundPath;
53  }
54 
61  public function ‪isActive()
62  {
63  $isActive = true;
64  foreach ($this->configurationValues as $configurationKey => $configurationValue) {
65  if ($configurationKey !== 'GFX/processor_path'
66  && $configurationKey !== 'GFX/processor_path_lzw'
67  ) {
68  $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
69  if ($currentValue !== $configurationValue) {
70  $isActive = false;
71  break;
72  }
73  }
74  }
75  return $isActive;
76  }
77 
83  public function ‪isAvailable()
84  {
85  $searchPaths = $this->‪getSearchPaths();
86  return $this->‪findExecutableInPath($searchPaths);
87  }
88 
94  public function ‪getConfigurationValues()
95  {
98  ‪$configurationValues['GFX/processor_path'] = $this->‪getFoundPath();
99  ‪$configurationValues['GFX/processor_path_lzw'] = $this->‪getFoundPath();
101  }
102 
109  abstract protected function ‪findExecutableInPath(array $searchPaths);
110 
116  protected function ‪getSearchPaths()
117  {
119 
120  // Add configured processor_path on top
121  $imPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
122  if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
123  $path = $this->‪cleanUpPath($imPath);
124  array_unshift($searchPaths, $path);
125  }
126 
127  // Add configured processor_path_lzw on top
128  $imLzwSearchPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'];
129  if ((string)$imLzwSearchPath !== '' && !in_array($imLzwSearchPath, $searchPaths)) {
130  $path = $this->‪cleanUpPath($imLzwSearchPath);
131  array_unshift($searchPaths, $path);
132  }
133 
134  // Add additional search path from form if given
135  if (isset($this->postValues['additionalSearchPath'])
136  && (string)$this->postValues['additionalSearchPath'] !== ''
137  && !in_array($this->postValues['additionalSearchPath'], $searchPaths)
138  ) {
139  $path = $this->‪cleanUpPath($this->postValues['additionalSearchPath']);
140  array_unshift($searchPaths, $path);
141  }
142 
143  return $searchPaths;
144  }
145 
152  protected function ‪cleanUpPath($path)
153  {
154  $path = \TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($path);
155  // Add trailing slash if missing
156  if (!preg_match('/[\\/]$/', $path)) {
157  $path .= '/';
158  }
159  return $path;
160  }
161 }
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:24
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getConfigurationValues
‪array getConfigurationValues()
Definition: AbstractImagePreset.php:92
‪TYPO3\CMS\Install\Configuration\AbstractPreset
Definition: AbstractPreset.php:26
‪TYPO3\CMS\Install\Configuration\AbstractPreset\$configurationValues
‪array $configurationValues
Definition: AbstractPreset.php:41
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\isActive
‪bool isActive()
Definition: AbstractImagePreset.php:59
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\cleanUpPath
‪string cleanUpPath($path)
Definition: AbstractImagePreset.php:150
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getFoundPath
‪string getFoundPath()
Definition: AbstractImagePreset.php:48
‪TYPO3\CMS\Install\Configuration
Definition: AbstractCustomPreset.php:2
‪TYPO3\CMS\Install\Configuration\Image
Definition: AbstractImagePreset.php:2
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$defaultExecutableSearchPaths
‪array $defaultExecutableSearchPaths
Definition: AbstractImagePreset.php:27
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$foundPath
‪string $foundPath
Definition: AbstractImagePreset.php:41
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\isAvailable
‪bool isAvailable()
Definition: AbstractImagePreset.php:81
‪$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:114