‪TYPO3CMS  10.4
AbstractDriver.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 
24 abstract class ‪AbstractDriver implements ‪DriverInterface
25 {
26  /*******************
27  * CAPABILITIES
28  *******************/
35  protected ‪$capabilities = 0;
36 
42  protected ‪$storageUid;
43 
51  protected ‪$supportedHashAlgorithms = [];
52 
58  protected ‪$configuration = [];
59 
65  public function ‪__construct(array ‪$configuration = [])
66  {
67  $this->configuration = ‪$configuration;
68  }
69 
77  protected function ‪isValidFilename($fileName)
78  {
79  if (strpos($fileName, '/') !== false) {
80  return false;
81  }
82  if (!preg_match('/^[\\pL\\d[:blank:]._-]*$/u', $fileName)) {
83  return false;
84  }
85  return true;
86  }
87 
93  public function ‪setStorageUid(‪$storageUid)
94  {
95  $this->storageUid = ‪$storageUid;
96  }
97 
107  public function ‪getCapabilities()
108  {
109  return ‪$this->capabilities;
110  }
111 
118  public function ‪hasCapability($capability)
119  {
120  return ($this->capabilities & $capability) === $capability;
121  }
122 
123  /*******************
124  * FILE FUNCTIONS
125  *******************/
126 
133  protected function ‪getTemporaryPathForFile($fileIdentifier)
134  {
135  return GeneralUtility::tempnam('fal-tempfile-', '.' . ‪PathUtility::pathinfo($fileIdentifier, PATHINFO_EXTENSION));
136  }
137 
146  public function ‪hashIdentifier($identifier)
147  {
148  $identifier = $this->‪canonicalizeAndCheckFileIdentifier($identifier);
149  return sha1($identifier);
150  }
151 
160  public function ‪sanitizeFileName($fileName, $charset = '')
161  {
162  return $fileName;
163  }
164 
174  public function ‪isCaseSensitiveFileSystem()
175  {
176  if (isset($this->configuration['caseSensitive'])) {
177  return (bool)$this->configuration['caseSensitive'];
178  }
179  return true;
180  }
181 
188  abstract protected function ‪canonicalizeAndCheckFilePath($filePath);
189 
197  abstract protected function ‪canonicalizeAndCheckFileIdentifier($fileIdentifier);
198 
205  abstract protected function ‪canonicalizeAndCheckFolderIdentifier($folderIdentifier);
206 }
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$capabilities
‪int $capabilities
Definition: AbstractDriver.php:34
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$configuration
‪array $configuration
Definition: AbstractDriver.php:54
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getCapabilities
‪int getCapabilities()
Definition: AbstractDriver.php:103
‪TYPO3\CMS\Core\Resource\Driver\DriverInterface
Definition: DriverInterface.php:23
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hashIdentifier
‪string hashIdentifier($identifier)
Definition: AbstractDriver.php:142
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\getTemporaryPathForFile
‪string getTemporaryPathForFile($fileIdentifier)
Definition: AbstractDriver.php:129
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\hasCapability
‪bool hasCapability($capability)
Definition: AbstractDriver.php:114
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\setStorageUid
‪setStorageUid($storageUid)
Definition: AbstractDriver.php:89
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$supportedHashAlgorithms
‪array $supportedHashAlgorithms
Definition: AbstractDriver.php:48
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isValidFilename
‪bool isValidFilename($fileName)
Definition: AbstractDriver.php:73
‪TYPO3\CMS\Core\Utility\PathUtility\pathinfo
‪static string string[] pathinfo($path, $options=null)
Definition: PathUtility.php:208
‪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:16
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\canonicalizeAndCheckFolderIdentifier
‪string canonicalizeAndCheckFolderIdentifier($folderIdentifier)
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\$storageUid
‪int $storageUid
Definition: AbstractDriver.php:40
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\sanitizeFileName
‪string sanitizeFileName($fileName, $charset='')
Definition: AbstractDriver.php:156
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\__construct
‪__construct(array $configuration=[])
Definition: AbstractDriver.php:61
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver
Definition: AbstractDriver.php:25
‪TYPO3\CMS\Core\Resource\Driver\AbstractDriver\isCaseSensitiveFileSystem
‪bool isCaseSensitiveFileSystem()
Definition: AbstractDriver.php:170