TYPO3  7.6
AbstractGraphicalTask.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Processing;
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 
17 
25 abstract class AbstractGraphicalTask extends AbstractTask
26 {
31 
38  public function getTargetFilename()
39  {
40  return $this->getSourceFile()->getNameWithoutExtension()
41  . '_' . $this->getConfigurationChecksum()
42  . '.' . $this->getTargetFileExtension();
43  }
44 
51  public function getTargetFileExtension()
52  {
53  if (!isset($this->targetFileExtension)) {
54  $this->targetFileExtension = $this->determineTargetFileExtension();
55  }
56 
58  }
59 
67  protected function determineTargetFileExtension()
68  {
69  if (!empty($this->configuration['fileExtension'])) {
70  $targetFileExtension = $this->configuration['fileExtension'];
71  } else {
72  // explanation for "thumbnails_png"
73  // Bit0: If set, thumbnails from non-jpegs will be 'png', otherwise 'gif' (0=gif/1=png).
74  // Bit1: Even JPG's will be converted to png or gif (2=gif/3=png)
75 
76  $targetFileExtensionConfiguration = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails_png'];
77  if ($this->getSourceFile()->getExtension() === 'jpg' || $this->getSourceFile()->getExtension() === 'jpeg') {
78  if ($targetFileExtensionConfiguration == 2) {
79  $targetFileExtension = 'gif';
80  } elseif ($targetFileExtensionConfiguration == 3) {
81  $targetFileExtension = 'png';
82  } else {
83  $targetFileExtension = 'jpg';
84  }
85  } else {
86  // check if a png or a gif should be created
87  if ($targetFileExtensionConfiguration == 1 || $this->getSourceFile()->getExtension() === 'png') {
88  $targetFileExtension = 'png';
89  } else {
90  // thumbnails_png is "0"
91  $targetFileExtension = 'gif';
92  }
93  }
94  }
95 
96  return $targetFileExtension;
97  }
98 }