2 namespace TYPO3\CMS\Extensionmanager\Utility;
73 $this->languageService->includeLLFile(
'EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
89 $files = array_diff_key($files, array_flip($directories));
104 $directories = array();
105 foreach ($files as $filePath => $file) {
106 preg_match(
'/(.*)\\//', $filePath, $matches);
107 if (!empty($matches[0])) {
108 $directories[] = $matches[0];
111 return array_unique($directories);
122 return $extensionData[
'FILES'];
135 foreach ($directories as $directory) {
150 }
catch (\RuntimeException $exception) {
152 sprintf($this->languageService->getLL(
'fileHandling.couldNotCreateDirectory'), $this->
getRelativePath($directory)),
167 foreach ($files as $file) {
184 if (is_dir($extDirPath)) {
203 $path = $paths[$pathType];
204 if (!$path || !is_dir($path) || !$extensionKey) {
206 sprintf($this->languageService->getLL(
'fileHandling.installPathWasNoDirectory'), $this->
getRelativePath($path)),
211 return $path . $extensionKey .
'/';
224 if (!is_dir($extDirPath)) {
226 sprintf($this->languageService->getLL(
'fileHandling.couldNotCreateDirectory'), $this->
getRelativePath($extDirPath)),
254 return is_dir($directory);
265 $requestedDirectories = array();
266 $requestUploadFolder = isset($extension[
'uploadfolder']) ? (bool)$extension[
'uploadfolder'] :
false;
267 if ($requestUploadFolder) {
271 $requestCreateDirectories = empty($extension[
'createDirs']) ?
false : (string)$extension[
'createDirs'];
272 if ($requestCreateDirectories) {
278 return $requestedDirectories;
289 return 'uploads/tx_' . str_replace(
'_',
'', $extension[
'key']) .
'/';
302 $extensionPathWithoutTrailingSlash = rtrim($extDirPath,
'/');
303 if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !==
'WIN') {
304 $result = unlink($extensionPathWithoutTrailingSlash);
308 if ($result ===
false) {
310 sprintf($this->languageService->getLL(
'fileHandling.couldNotRemoveDirectory'), $this->
getRelativePath($extDirPath)),
327 $emConfFileData = array();
328 if (file_exists($rootPath .
'ext_emconf.php')) {
329 $emConfFileData = $this->emConfUtility->includeEmConf(
331 'key' => $extensionData[
'extKey'],
336 $extensionData[
'EM_CONF'] = array_replace_recursive($emConfFileData, $extensionData[
'EM_CONF']);
337 $emConfContent = $this->emConfUtility->constructEmConf($extensionData, $extension);
350 foreach ($allowedPaths as $allowedPath) {
368 if (empty($absolutePath)) {
371 return $absolutePath;
393 $extension = $this->installUtility->enrichExtensionWithDetails($extension);
395 return $absolutePath;
406 $extensionData = $this->installUtility->enrichExtensionWithDetails($extension);
407 $version = $extensionData[
'version'];
425 if (empty($version)) {
429 if (!@is_dir(PATH_site .
'typo3temp/ExtensionManager/')) {
432 $fileName = $this->
getAbsolutePath(
'typo3temp/ExtensionManager/' . $extension .
'_' . $version .
'_' . date(
'YmdHi',
$GLOBALS[
'EXEC_TIME']) .
'.zip');
434 $zip = new \ZipArchive();
435 $zip->open($fileName, \ZipArchive::CREATE);
437 $excludePattern =
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXT'][
'excludeForPackaging'];
453 $files = array_filter($files);
455 foreach ($files as $file) {
456 $fullPath = $extensionPath . $file;
459 if (is_dir($fullPath)) {
460 $zip->addEmptyDir($file);
462 $zip->addFile($fullPath, $file);
482 $zip = zip_open($file);
483 if (is_resource($zip)) {
484 while (($zipEntry = zip_read($zip)) !==
false) {
485 if (strpos(zip_entry_name($zipEntry),
'/') !==
false) {
486 $last = strrpos(zip_entry_name($zipEntry),
'/');
487 $dir = substr(zip_entry_name($zipEntry), 0, $last);
488 $file = substr(zip_entry_name($zipEntry), strrpos(zip_entry_name($zipEntry),
'/') + 1);
489 if (!is_dir($extensionDir . $dir)) {
492 if (trim($file) !==
'') {
493 $return =
GeneralUtility::writeFile($extensionDir . $dir .
'/' . $file, zip_entry_read($zipEntry, zip_entry_filesize($zipEntry)));
494 if ($return ===
false) {
499 GeneralUtility::writeFile($extensionDir . zip_entry_name($zipEntry), zip_entry_read($zipEntry, zip_entry_filesize($zipEntry)));
516 if ($downloadName ===
'') {
517 $downloadName = basename($fileName,
'.zip');
519 header(
'Content-Type: application/zip');
520 header(
'Content-Length: ' . filesize($fileName));
521 header(
'Content-Disposition: attachment; filename="' . $downloadName .
'.zip"');
536 if ($downloadName ===
'') {
537 $downloadName = basename($fileName,
'.sql');
539 $downloadName = basename($downloadName,
'.sql');
541 header(
'Content-Type: text');
542 header(
'Content-Length: ' . filesize($fileName));
543 header(
'Content-Disposition: attachment; filename="' . $downloadName .
'.sql"');
554 $this->installUtility->reloadPackageInformation($extensionKey);