‪TYPO3CMS  11.5
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 
20 
26 {
31  '/usr/local/bin/',
32  '/opt/local/bin/',
33  '/usr/bin/',
34  '/usr/X11R6/bin/',
35  '/opt/bin/',
36  'C:/php/ImageMagick/',
37  'C:/php/GraphicsMagick/',
38  'C:/apache/ImageMagick/',
39  'C:/apache/GraphicsMagick/',
40  ];
41 
45  protected ‪$foundPath = '';
46 
52  public function ‪getFoundPath()
53  {
54  return ‪$this->foundPath;
55  }
56 
63  public function ‪isActive()
64  {
65  $isActive = true;
66  foreach ($this->configurationValues as $configurationKey => $configurationValue) {
67  if ($configurationKey !== 'GFX/processor_path'
68  && $configurationKey !== 'GFX/processor_path_lzw'
69  ) {
70  $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
71  if ($currentValue !== $configurationValue) {
72  $isActive = false;
73  break;
74  }
75  }
76  }
77  return $isActive;
78  }
79 
85  public function ‪isAvailable()
86  {
87  $searchPaths = $this->‪getSearchPaths();
88  return $this->‪findExecutableInPath($searchPaths);
89  }
90 
96  public function ‪getConfigurationValues()
97  {
100  ‪$configurationValues['GFX/processor_path'] = $this->‪getFoundPath();
101  ‪$configurationValues['GFX/processor_path_lzw'] = $this->‪getFoundPath();
103  }
104 
111  abstract protected function ‪findExecutableInPath(array $searchPaths);
112 
118  protected function ‪getSearchPaths()
119  {
121 
122  // Add configured processor_path on top
123  $imPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
124  if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
125  $path = $this->‪cleanUpPath($imPath);
126  array_unshift($searchPaths, $path);
127  }
128 
129  // Add configured processor_path_lzw on top
130  $imLzwSearchPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path_lzw'];
131  if ((string)$imLzwSearchPath !== '' && !in_array($imLzwSearchPath, $searchPaths)) {
132  $path = $this->‪cleanUpPath($imLzwSearchPath);
133  array_unshift($searchPaths, $path);
134  }
135 
136  // Add additional search path from form if given
137  if (isset($this->postValues['additionalSearchPath'])
138  && (string)$this->postValues['additionalSearchPath'] !== ''
139  && !in_array($this->postValues['additionalSearchPath'], $searchPaths)
140  ) {
141  $path = $this->‪cleanUpPath($this->postValues['additionalSearchPath']);
142  array_unshift($searchPaths, $path);
143  }
144 
145  return $searchPaths;
146  }
147 
154  protected function ‪cleanUpPath($path)
155  {
156  $path = GeneralUtility::fixWindowsFilePath($path);
157  // Add trailing slash if missing
158  if (!preg_match('/[\\/]$/', $path)) {
159  $path .= '/';
160  }
161  return $path;
162  }
163 }
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset
Definition: AbstractImagePreset.php:26
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\findExecutableInPath
‪mixed findExecutableInPath(array $searchPaths)
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getConfigurationValues
‪array getConfigurationValues()
Definition: AbstractImagePreset.php:94
‪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:61
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\cleanUpPath
‪string cleanUpPath($path)
Definition: AbstractImagePreset.php:152
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getFoundPath
‪string getFoundPath()
Definition: AbstractImagePreset.php:50
‪TYPO3\CMS\Install\Configuration\Image
Definition: AbstractImagePreset.php:16
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$defaultExecutableSearchPaths
‪array $defaultExecutableSearchPaths
Definition: AbstractImagePreset.php:29
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\$foundPath
‪string $foundPath
Definition: AbstractImagePreset.php:43
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\isAvailable
‪bool isAvailable()
Definition: AbstractImagePreset.php:83
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Install\Configuration\Image\AbstractImagePreset\getSearchPaths
‪array getSearchPaths()
Definition: AbstractImagePreset.php:116
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50