TYPO3 CMS  TYPO3_7-6
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 
23 {
28  '/usr/local/bin/',
29  '/opt/local/bin/',
30  '/usr/bin/',
31  '/usr/X11R6/bin/',
32  '/opt/bin/',
33  'C:/php/ImageMagick/',
34  'C:/php/GraphicsMagick/',
35  'C:/apache/ImageMagick/',
36  'C:/apache/GraphicsMagick/',
37  ];
38 
42  protected $foundPath = '';
43 
49  public function getFoundPath()
50  {
51  return $this->foundPath;
52  }
53 
60  public function isActive()
61  {
62  $isActive = true;
63  foreach ($this->configurationValues as $configurationKey => $configurationValue) {
64  if ($configurationKey !== 'GFX/im_path'
65  && $configurationKey !== 'GFX/im_path_lzw'
66  ) {
67  $currentValue = $this->configurationManager->getConfigurationValueByPath($configurationKey);
68  if ($currentValue !== $configurationValue) {
69  $isActive = false;
70  break;
71  }
72  }
73  }
74  return $isActive;
75  }
76 
82  public function isAvailable()
83  {
84  $searchPaths = $this->getSearchPaths();
85  return $this->findExecutableInPath($searchPaths);
86  }
87 
93  public function getConfigurationValues()
94  {
95  $this->findExecutableInPath($this->getSearchPaths());
97  $configurationValues['GFX/im_path'] = $this->getFoundPath();
98  $configurationValues['GFX/im_path_lzw'] = $this->getFoundPath();
99  return $configurationValues;
100  }
101 
108  abstract protected function findExecutableInPath(array $searchPaths);
109 
115  protected function getSearchPaths()
116  {
118 
119  // Add configured im_path on top
120  $imPath = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
121  if ((string)$imPath !== '' && !in_array($imPath, $searchPaths)) {
122  $path = $this->cleanUpPath($imPath);
123  array_unshift($searchPaths, $path);
124  }
125 
126  // Add configured im_path_lzw on top
127  $imLzwSearchPath = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'];
128  if ((string)$imLzwSearchPath !== '' && !in_array($imLzwSearchPath, $searchPaths)) {
129  $path = $this->cleanUpPath($imLzwSearchPath);
130  array_unshift($searchPaths, $path);
131  }
132 
133  // Add additional search path from form if given
134  if (isset($this->postValues['additionalSearchPath'])
135  && (string)$this->postValues['additionalSearchPath'] !== ''
136  && !in_array($this->postValues['additionalSearchPath'], $searchPaths)
137  ) {
138  $path = $this->cleanUpPath($this->postValues['additionalSearchPath']);
139  array_unshift($searchPaths, $path);
140  }
141 
142  return $searchPaths;
143  }
144 
151  protected function cleanUpPath($path)
152  {
154  // Add trailing slash if missing
155  if (!preg_match('/[\\/]$/', $path)) {
156  $path .= '/';
157  }
158  return $path;
159  }
160 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']