111 'Composer mode is active. You are not allowed to upload any extension file.',
127 'Composer mode is active. You are not allowed to upload any extension file.',
131 $file = $_FILES[
'tx_extensionmanager_tools_extensionmanagerextensionmanager'];
132 $fileName = pathinfo($file[
'name'][
'extensionFile'], PATHINFO_BASENAME);
136 if (!empty($file[
'tmp_name'][
'extensionFile'])) {
137 $tempFile = GeneralUtility::upload_to_tempfile($file[
'tmp_name'][
'extensionFile']);
140 'Creating temporary file failed. Check your upload_max_filesize and post_max_size limits.',
145 $isAutomaticInstallationEnabled = (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(
'extensionmanager',
'automaticInstallation');
146 if (!$isAutomaticInstallationEnabled) {
148 $this->
translate(
'extensionList.uploadFlashMessage.message', [$extensionData[
'extKey']]),
149 $this->
translate(
'extensionList.uploadFlashMessage.title'),
155 $this->
translate(
'extensionList.installedFlashMessage.message', [$extensionData[
'extKey']]),
160 $this->
redirect(
'unresolvedDependencies',
'List',
null, [
'extensionKey' => $extensionData[
'extKey']]);
171 $this->
redirect(
'index',
'List',
null, [
172 self::TRIGGER_RefreshModuleMenu =>
true,
173 self::TRIGGER_RefreshTopbar =>
true
185 $extension = pathinfo($fileName, PATHINFO_EXTENSION);
186 if (empty($fileName)) {
189 if ($extension !==
't3x' && $extension !==
'zip') {
190 throw new ExtensionManagerException(
'Wrong file format "' . $extension .
'" given. Allowed formats are t3x and zip.', 1342858853);
206 $fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);
207 if ($fileExtension ===
't3x') {
213 return $extensionData;
222 $this->managementService->reloadPackageInformation($extensionKey);
223 $extension = $this->managementService->getExtension($extensionKey);
224 return is_array($this->managementService->installExtension($extension));
238 $fileContent = file_get_contents($file);
240 throw new ExtensionManagerException(
'File had no or wrong content.', 1342859339);
242 $extensionData = $this->terUtility->decodeExchangeData($fileContent);
243 if (empty($extensionData[
'extKey'])) {
244 throw new ExtensionManagerException(
'Decoding the file went wrong. No extension key found', 1342864309);
246 $isExtensionAvailable = $this->managementService->isAvailable($extensionData[
'extKey']);
247 if (!$overwrite && $isExtensionAvailable) {
248 throw new ExtensionManagerException($this->
translate(
'extensionList.overwritingDisabled'), 1342864310);
250 if ($isExtensionAvailable) {
253 $this->removeFromOriginalPath =
true;
254 $extension = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionData[
'extKey'], $extensionData[
'EM_CONF'][
'version']);
255 $this->fileHandlingUtility->unpackExtensionFromExtensionDataArray($extensionData, $extension);
257 if (empty($extension)
258 && empty($extensionData[
'EM_CONF'][
'constraints'])
259 && !isset($extensionData[
'FILES'][
'ext_emconf.php'])
260 && !isset($extensionData[
'FILES'][
'/ext_emconf.php'])
262 throw new DependencyConfigurationNotFoundException(
'Extension cannot be installed automatically because no dependencies could be found! Please check dependencies manually (on typo3.org) before installing the extension.', 1439587168);
265 return $extensionData;
284 $isExtensionAvailable = $this->managementService->isAvailable($extensionKey);
285 if (!$overwrite && $isExtensionAvailable) {
286 throw new ExtensionManagerException(
'Extension is already available and overwriting is disabled.', 1342864311);
288 if ($isExtensionAvailable) {
291 $this->removeFromOriginalPath =
true;
292 $this->fileHandlingUtility->unzipExtensionFromFile($file, $extensionKey);
294 return [
'extKey' => $extensionKey];
305 return preg_replace(
'/_(\\d+)(\\.|\\-)(\\d+)(\\.|\\-)(\\d+).*/i',
'', strtolower(substr($fileName, 0, -4)));
316 $this->extensionBackupPath =
Environment::getVarPath() .
'/transient/' . $extensionKey . substr(sha1($extensionKey . microtime()), 0, 7) .
'/';
317 GeneralUtility::mkdir($this->extensionBackupPath);
318 GeneralUtility::copyDirectory(
319 $this->fileHandlingUtility->getExtensionDir($extensionKey),
320 $this->extensionBackupPath
333 if ($this->removeFromOriginalPath && is_dir($extDirPath)) {
334 GeneralUtility::rmdir($extDirPath,
true);
336 if (!empty($this->extensionBackupPath)) {
337 GeneralUtility::mkdir($extDirPath);
338 GeneralUtility::copyDirectory($this->extensionBackupPath, $extDirPath);
347 if (!empty($this->extensionBackupPath)) {
348 GeneralUtility::rmdir($this->extensionBackupPath,
true);
349 $this->extensionBackupPath =
'';