‪TYPO3CMS  ‪main
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  $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();
100  }
101 
107  abstract protected function ‪findExecutableInPath(array $searchPaths);
108 
114  protected function ‪getSearchPaths()
115  {
117 
118  // Add configured processor_path on top
119  $imPath = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_path'];
120  if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
121  $path = $this->‪cleanUpPath($imPath);
122  array_unshift($searchPaths, $path);
123  }
124 
125  // Add additional search path from form if given
126  if (isset($this->postValues['additionalSearchPath'])
127  && (string)$this->postValues['additionalSearchPath'] !== ''
128  && !in_array($this->postValues['additionalSearchPath'], $searchPaths)
129  ) {
130  $path = $this->‪cleanUpPath($this->postValues['additionalSearchPath']);
131  array_unshift($searchPaths, $path);
132  }
133 
134  return $searchPaths;
135  }
136 
143  protected function ‪cleanUpPath($path)
144  {
145  $path = GeneralUtility::fixWindowsFilePath((string)$path);
146  // Add trailing slash if missing
147  if (!preg_match('/[\\/]$/', $path)) {
148  $path .= '/';
149  }
150  return $path;
151  }
152 }
‪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:92
‪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:141
‪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:81
‪$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:112
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52