Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit b21d53c

Browse files
author
Jose Antonio Guerra
committed
[FEATURE] create extension upload folder
Relates: #45704
1 parent 290fc5e commit b21d53c

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

Classes/Cli/Dispatcher.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ protected function extensionApi() {
186186
case 'updatelist':
187187
$extensionApiService->updateMirrors();
188188
break;
189+
case 'createuploadfolders' :
190+
$messages = $extensionApiService->createUploadFolders();
191+
if (sizeof($messages)) {
192+
foreach ($messages as $message) {
193+
$this->outputLine($message);
194+
}
195+
} else {
196+
$this->outputLine('no uploadFolder created');
197+
}
198+
break;
189199
case 'listinstalled':
190200
$extensions = $extensionApiService->getInstalledExtensions($_SERVER['argv'][2]);
191201
$out = array();

Classes/Command/ExtensionApiCommandController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,25 @@ public function updateListCommand() {
128128
$this->outputLine('Extension list has been updated.');
129129
}
130130

131+
/**
132+
* createUploadFoldersCommand
133+
*
134+
* @return void
135+
*/
136+
public function createUploadFoldersCommand() {
137+
/** @var $service Tx_Coreapi_Service_ExtensionApiService */
138+
$service = $this->objectManager->get('Tx_Coreapi_Service_ExtensionApiService');
139+
$messages = $service->createUploadFolders();
140+
141+
if (sizeof($messages)) {
142+
foreach ($messages as $message) {
143+
$this->outputLine($message);
144+
}
145+
} else {
146+
$this->outputLine('no uploadFolder created');
147+
}
148+
}
149+
131150
}
132151

133152
?>

Classes/Service/ExtensionApiService.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,45 @@ public function updateMirrors() {
9898
$emTask = t3lib_div::makeInstance('tx_em_Tasks_UpdateExtensionList');
9999
$emTask->execute();
100100
}
101+
102+
/**
103+
* createUploadFolders
104+
*
105+
* @return array
106+
*/
107+
public function createUploadFolders() {
108+
$extensions = $this->getInstalledExtensions();
109+
110+
// 6.0 creates also Dirs
111+
if (class_exists('\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility')) {
112+
$fileHandlingUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility');
113+
foreach ($extensions AS $key => $extension) {
114+
$extension['key'] = $key;
115+
$fileHandlingUtility->ensureConfiguredDirectoriesExist($extension);
116+
}
117+
return array('done with \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility->ensureConfiguredDirectoriesExist');
118+
}
119+
120+
// < 6.0 creates no Dirs
121+
$messages = array();
122+
123+
foreach ($extensions as $extKey => $extInfo) {
124+
$uploadFolder = PATH_site . tx_em_Tools::uploadFolder($extKey);
125+
if ($extInfo['uploadfolder'] && ! @is_dir($uploadFolder)) {
126+
t3lib_div::mkdir($uploadFolder);
127+
$messages[] = 'mkdir ' . $uploadFolder;
128+
$indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
129+
<HTML>
130+
<HEAD>
131+
<TITLE></TITLE>
132+
<META http-equiv=Refresh Content="0; Url=../../">
133+
</HEAD>
134+
</HTML>';
135+
t3lib_div::writeFile($uploadFolder . 'index.html', $indexContent);
136+
}
137+
}
138+
return $messages;
139+
}
101140
}
102141

103142
?>

0 commit comments

Comments
 (0)