‪TYPO3CMS  9.5
AbstractDriver.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 
22 abstract class ‪AbstractDriver implements ‪DriverInterface
23 {
24  /*******************
25  * CAPABILITIES
26  *******************/
33  protected ‪$capabilities = 0;
34 
40  protected ‪$storageUid;
41 
49  protected ‪$supportedHashAlgorithms = [];
50 
56  protected ‪$configuration = [];
57 
63  public function ‪__construct(array ‪$configuration = [])
64  {
65  $this->configuration = ‪$configuration;
66  }
67 
75  protected function ‪isValidFilename($fileName)
76  {
77  if (strpos($fileName, '/') !== false) {
78  return false;
79  }
80  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
81  return false;
82  }
83  return true;
84  }
85 
91  public function ‪setStorageUid(‪$storageUid)
92  {
93  $this->storageUid = ‪$storageUid;
94  }
95 
102  public function ‪getCapabilities()
103  {
104  return ‪$this->capabilities;
105  }
106 
113  public function ‪hasCapability($capability)
114  {
115  return ($this->capabilities & $capability) == $capability;
116  }
117 
118  /*******************
119  * FILE FUNCTIONS
120  *******************/
121 
128  protected function ‪getTemporaryPathForFile($fileIdentifier)
129  {
130  return \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('fal-tempfile-', '.' . ‪PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
131  }
132 
141  public function ‪hashIdentifier($identifier)
142  {
143  $identifier = $this->‪canonicalizeAndCheckFileIdentifier($identifier);
144  return sha1($identifier);
145  }
146 
155  public function ‪sanitizeFileName($fileName, $charset = '')
156  {
157  return $fileName;
158  }
159 
169  public function ‪isCaseSensitiveFileSystem()
170  {
171  if (isset($this->configuration['caseSensitive'])) {
172  return (bool)$this->configuration['caseSensitive'];
173  }
174  return true;
175  }
176 
183  abstract protected function ‪canonicalizeAndCheckFilePath($filePath);
184 
192  abstract protected function ‪canonicalizeAndCheckFileIdentifier($fileIdentifier);
193 
200  abstract protected function ‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
201 }
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$capabilities
‪int $capabilities
Definition: AbstractDriver.php:32
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$configuration
‪array $configuration
Definition: AbstractDriver.php:52
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getCapabilities
‪int getCapabilities()
Definition: AbstractDriver.php:98
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:22
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hashIdentifier
‪string hashIdentifier($identifier)
Definition: AbstractDriver.php:137
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string array pathinfo($path, $options=null)
Definition: PathUtility.php:207
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getTemporaryPathForFile
‪string getTemporaryPathForFile($fileIdentifier)
Definition: AbstractDriver.php:124
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hasCapability
‪bool hasCapability($capability)
Definition: AbstractDriver.php:109
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\setStorageUid
‪setStorageUid($storageUid)
Definition: AbstractDriver.php:87
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$supportedHashAlgorithms
‪array $supportedHashAlgorithms
Definition: AbstractDriver.php:46
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isValidFilename
‪bool isValidFilename($fileName)
Definition: AbstractDriver.php:71
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFilePath
‪string canonicalizeAndCheckFilePath($filePath)
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFileIdentifier
‪string canonicalizeAndCheckFileIdentifier($fileIdentifier)
‪TYPO3\CMS\Core\Resource\Driver
Definition: AbstractDriver.php:2
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFolderIdentifier
‪string canonicalizeAndCheckFolderIdentifier($folderIdentifier)
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$storageUid
‪int $storageUid
Definition: AbstractDriver.php:38
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='')
Definition: AbstractDriver.php:151
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\__construct
‪__construct(array $configuration=[])
Definition: AbstractDriver.php:59
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver
Definition: AbstractDriver.php:23
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isCaseSensitiveFileSystem
‪bool isCaseSensitiveFileSystem()
Definition: AbstractDriver.php:165