1 | <?php |
||
15 | abstract class AbstractFileService implements IFileSystem |
||
16 | { |
||
17 | /** @var array Collection of mime => extension */ |
||
18 | public static $mimes = array |
||
19 | ( |
||
20 | 'text/css' => 'css', |
||
21 | 'application/x-font-woff' => 'woff', |
||
22 | 'application/x-javascript' => 'js', |
||
23 | 'text/html;charset=utf-8' =>'htm', |
||
24 | 'text/x-component' => 'htc', |
||
25 | 'image/jpeg' => 'jpg', |
||
26 | 'image/pjpeg' => 'jpg', |
||
27 | 'image/png' => 'png', |
||
28 | 'image/x-png' => 'png', |
||
29 | 'image/jpg' => 'jpg', |
||
30 | 'image/gif' => 'gif', |
||
31 | 'text/plain' => 'txt', |
||
32 | 'application/pdf' => 'pdf', |
||
33 | 'application/zip' => 'zip', |
||
34 | 'application/rtf' => 'rtf', |
||
35 | 'application/msword' => 'doc', |
||
36 | 'application/msexcel' => 'xls', |
||
37 | 'application/vnd.ms-excel' => 'xls', |
||
38 | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', |
||
39 | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', |
||
40 | 'application/octet-stream' => 'sql', |
||
41 | 'audio/mpeg' => 'mp3', |
||
42 | 'text/x-c++' => 'php', |
||
43 | ); |
||
44 | |||
45 | /** |
||
46 | * File service initialization stage |
||
47 | */ |
||
48 | public function initialize() |
||
52 | |||
53 | /** |
||
54 | * Get file mime type in current file system |
||
55 | * @param $filePath string Path to file |
||
56 | * @return false|integer|string false if mime not found, otherwise file mime type |
||
57 | */ |
||
58 | public function mime($filePath) |
||
66 | |||
67 | /** |
||
68 | * Get relative path from $path |
||
69 | * @param string $fullPath Full file path |
||
70 | * @param string $fileName File name |
||
71 | * @param string $basePath Base path, must end WITHOUT '/', if not passed |
||
72 | * $fullPath one level top directory is used. |
||
73 | * @return string Relative path to file |
||
74 | */ |
||
75 | public function relativePath($fullPath, $fileName, $basePath = null) |
||
83 | |||
84 | /** |
||
85 | * Copy folder to selected location. |
||
86 | * Copy can be performed from file($filePath) to file($newPath), |
||
87 | * also copy can be performed from folder($filePath) to folder($newPath), |
||
88 | * currently copying from file($filePath) to folder($newPath) is not supported. |
||
89 | * |
||
90 | * @param string $filePath Source path or file path |
||
91 | * @param string $newPath New path or file path |
||
92 | * @return bool|null False if failed otherwise true if file/folder has been copied |
||
93 | */ |
||
94 | protected function copyFolder($filePath, $newPath) |
||
108 | |||
109 | /** |
||
110 | * Copy file to selected location. |
||
111 | * Copy can be performed from file($filePath) to file($newPath), |
||
112 | * also copy can be performed from folder($filePath) to folder($newPath), |
||
113 | * currently copying from file($filePath) to folder($newPath) is not supported. |
||
114 | * |
||
115 | * @param string $filePath Source path or file path |
||
116 | * @param string $newPath New path or file path |
||
117 | */ |
||
118 | protected function copyFile($filePath, $newPath) |
||
130 | |||
131 | /** |
||
132 | * Copy file/folder to selected location. |
||
133 | * Copy can be performed from file($filePath) to file($newPath), |
||
134 | * also copy can be performed from folder($filePath) to folder($newPath), |
||
135 | * currently copying from file($filePath) to folder($newPath) is not supported. |
||
136 | * |
||
137 | * @param string $filePath Source path or file path |
||
138 | * @param string $newPath New path or file path |
||
139 | * @return boolean False if failed otherwise true if file/folder has been copied |
||
140 | */ |
||
141 | public function copyPath($filePath, $newPath) |
||
162 | |||
163 | /** |
||
164 | * Create catalog in selected location |
||
165 | * @param string $path Path for new catalog |
||
166 | * @return boolean Result of catalog creating |
||
167 | */ |
||
168 | abstract public function mkDir($path); |
||
169 | } |
||
170 |
This function has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.