Skip to content

Commit

Permalink
fixup! [TASK] TYPO3 v11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fabarea committed Jul 13, 2022
1 parent 8c7194d commit ead025b
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 117 deletions.
1 change: 0 additions & 1 deletion Classes/FileUpload/UploadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Security\FileNameValidator;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/UploadFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UploadFileService
*/
public function getUploadedFileList($property = '')
{
$parameters = GeneralUtility::_GPmerged('tx_mediaupload_pi1');
$parameters = GeneralUtility::_GPmerged('tx_mediaupload_upload');
return empty($parameters['uploadedFiles'][$property]) ? '' : $parameters['uploadedFiles'][$property];
}

Expand Down
40 changes: 20 additions & 20 deletions Classes/ViewHelpers/Widget/ShowUploadedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ public function initializeArguments()
'',
);
}
public function render(): string
{
$uploadFileService = GeneralUtility::makeInstance(
UploadFileService::class,
);

return static::renderStatic(
[
'property' => $this->arguments['property'],
'uploadedFileList' => $uploadFileService->getUploadedFileList(
$this->arguments['property'],
),
'uploadedFiles' => $uploadFileService->getUploadedFiles(
$this->arguments['property'],
),
],
$this->buildRenderChildrenClosure(),
$this->renderingContext,
);
}
#public function render(): string
#{
# $uploadFileService = GeneralUtility::makeInstance(
# UploadFileService::class,
# );
#
# return static::renderStatic(
# [
# 'property' => $this->arguments['property'],
# 'uploadedFileList' => $uploadFileService->getUploadedFileList(
# $this->arguments['property'],
# ),
# 'uploadedFiles' => $uploadFileService->getUploadedFiles(
# $this->arguments['property'],
# ),
# ],
# $this->buildRenderChildrenClosure(),
# $this->renderingContext,
# );
#}

public static function renderStatic(
array $arguments,
Expand Down
73 changes: 44 additions & 29 deletions Classes/ViewHelpers/Widget/UploadViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* LICENSE.md file that was distributed with this source code.
*/

use Fab\Media\Utility\PermissionUtility;
use Fab\MediaUpload\Service\UploadFileService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
Expand Down Expand Up @@ -66,38 +64,55 @@ public function initializeArguments()
);
}

public function render(): string
{
$uploadFileService = GeneralUtility::makeInstance(
UploadFileService::class,
);

return static::renderStatic(
[
'allowedExtensions' => $this->arguments['allowedExtensions'],
'maximumSize' => $this->arguments['maximumSize'],
'maximumSizeLabel' => self::getMaximumSizeLabel(
(int) $this->arguments['maximumSize'],
),
'sizeUnit' => $this->arguments['sizeUnit'],
'storage' => $this->arguments['storage'],
'maximumItems' => $this->arguments['maximumItems'],
'property' => $this->arguments['property'],
'uploadedFileList' => $uploadFileService->getUploadedFileList(
$this->arguments['property'],
),
'widgetIdentifier' => uniqid(),
],
$this->buildRenderChildrenClosure(),
$this->renderingContext,
);
}
#public function render(): string
#{
# $uploadFileService = GeneralUtility::makeInstance(
# UploadFileService::class,
# );
# return static::renderStatic(
# [
# 'allowedExtensions' => $this->arguments['allowedExtensions'],
# 'maximumSize' => $this->arguments['maximumSize'],
# 'maximumSizeLabel' => 'qwer' . self::getMaximumSizeLabel(
# (int) $this->arguments['maximumSize'],
# ),
# 'sizeUnit' => $this->arguments['sizeUnit'],
# 'storage' => $this->arguments['storage'],
# 'maximumItems' => $this->arguments['maximumItems'],
# 'property' => $this->arguments['property'],
# 'uploadedFileList' => $uploadFileService->getUploadedFileList(
# $this->arguments['property'],
# ),
# 'widgetIdentifier' => uniqid(),
# ],
# $this->buildRenderChildrenClosure(),
# $this->renderingContext,
# );
#}

public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {

$uploadFileService = GeneralUtility::makeInstance(
UploadFileService::class,
);

$arguments['maximumSizeLabel'] = self::getMaximumSizeLabel(
(int)$arguments['maximumSize'],
);

if ($arguments['maximumSize'] === 0) {
$arguments['maximumSize'] = GeneralUtility::getMaxUploadFileSize() * 1024;
}

$arguments['uploadedFileList'] = $uploadFileService->getUploadedFileList(
$arguments['property'],
);

$arguments['widgetIdentifier'] = uniqid();
/** @var StandaloneView $view */
$view = GeneralUtility::makeInstance(StandaloneView::class);

Expand All @@ -124,7 +139,7 @@ public static function getMaximumSizeLabel(int $maximumSize = 0): int
*/
public static function getUploadedFileList($property = ''): string
{
$parameters = GeneralUtility::_GPmerged('tx_mediaupload_pi1');
$parameters = GeneralUtility::_GPmerged('tx_mediaupload_upload');
return empty($parameters['uploadedFiles'][$property])
? ''
: $parameters['uploadedFiles'][$property];
Expand Down
17 changes: 3 additions & 14 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ page_1386871773 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
vendorName = Fab
extensionName = MediaUpload
pluginName = Pi1
switchableControllerActions {
MediaUpload {
1 = upload
}
}
pluginName = Upload
}
}

Expand All @@ -70,14 +65,8 @@ page_1386871774 {
10 = USER_INT
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run

vendorName = Fab
extensionName = MediaUpload
pluginName = Pi1
switchableControllerActions {
MediaUpload {
1 = delete
}
}
pluginName = Delete
}
}
}
2 changes: 1 addition & 1 deletion Resources/Private/Assets/JavaScript/MediaUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
})
.on('submit', {_settings: settings}, function(event) {
var params = {};
var parameterPrefix = 'tx_mediaupload_pi1';
var parameterPrefix = 'tx_mediaupload_upload';
params[parameterPrefix + '[storageIdentifier]'] = event.data._settings.storage;
params['type'] = '1386871773';
$(this).fineUploader('setParams', params);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div>

<input id="uploaded-files-{property}" type="hidden"
name="tx_mediaupload_pi1[uploadedFiles][{property}]" value="{uploadedFileList}" />
name="tx_mediaupload_upload[uploadedFiles][{property}]" value="{uploadedFileList}" />

<f:if condition="{uploadedFiles}">
<ul class="qq-upload-list-selector qq-upload-list">
Expand All @@ -21,4 +21,4 @@

</div>

{namespace m=TYPO3\CMS\Media\ViewHelpers}
{namespace m=TYPO3\CMS\Media\ViewHelpers}
49 changes: 25 additions & 24 deletions Resources/Private/Templates/ViewHelpers/Widget/Upload/Index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<div>

<input id="uploaded-files-{property}" type="hidden"
name="tx_mediaupload_pi1[uploadedFiles][{property}]" value="{uploadedFileList}"/>
name="tx_mediaupload_upload[uploadedFiles][{property}]" value="{uploadedFileList}"/>

<div id="jquery-wrapped-fine-uploader-{widgetIdentifier}"></div>

<script type="text/template" id="media-upload-template-{uniqueId}">
<div class="qq-uploader-selector qq-uploader">
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span>{f:translate(key: 'fineUploader.dropFilesHere')}</span>
<span>{f:translate(extensionName: 'media_upload', key: 'fineUploader.dropFilesHere')}</span>
</div>
<div class="qq-upload-button-selector qq-upload-button">
<div>{f:translate(key: 'fineUploader.uploadFile')}</div>
<div>{f:translate(extensionName: 'media_upload', key: 'fineUploader.uploadFile')}</div>
</div>
(max {maximumSizeLabel} {f:translate(key: sizeUnit)})
(max {maximumSizeLabel} {f:translate(extensionName: 'media_upload', key: sizeUnit)})
<span class="qq-drop-processing-selector qq-drop-processing">
<span>{f:translate(key: 'fineUploader.processingDropFiles')}</span>
<span>{f:translate(extensionName: 'media_upload', key: 'fineUploader.processingDropFiles')}</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul id="qq-upload-list-{uniqueId}" class="qq-upload-list-selector qq-upload-list">
Expand All @@ -29,13 +29,13 @@
<span class="qq-upload-file-selector qq-upload-file"></span>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
<a class="qq-upload-cancel-selector btn btn-small btn-warning" href="#">{f:translate(key: 'fineUploader.cancel')}</a>
<a class="qq-upload-retry-selector btn btn-small btn-info" href="#">{f:translate(key: 'fineUploader.retry')}</a>
<a class="qq-upload-delete-selector btn btn-small btn-warning" href="#">{f:translate(key: 'fineUploader.delete')}</a>
<a class="qq-upload-pause-selector btn btn-small btn-info" href="#">{f:translate(key: 'fineUploader.pause')}</a>
<a class="qq-upload-continue-selector btn btn-small btn-info" href="#">{f:translate(key: 'fineUploader.continue')}</a>
<a class="qq-upload-cancel-selector btn btn-small btn-warning" href="#">{f:translate(extensionName: 'media_upload', key: 'fineUploader.cancel')}</a>
<a class="qq-upload-retry-selector btn btn-small btn-info" href="#">{f:translate(extensionName: 'media_upload', key: 'fineUploader.retry')}</a>
<a class="qq-upload-delete-selector btn btn-small btn-warning" href="#">{f:translate(extensionName: 'media_upload', key: 'fineUploader.delete')}</a>
<a class="qq-upload-pause-selector btn btn-small btn-info" href="#">{f:translate(extensionName: 'media_upload', key: 'fineUploader.pause')}</a>
<a class="qq-upload-continue-selector btn btn-small btn-info" href="#">{f:translate(extensionName: 'media_upload', key: 'fineUploader.continue')}</a>
<span class="qq-upload-status-text-selector qq-upload-status-text"></span>
<a class="view-btn btn btn-small btn-info hide" target="_blank">{f:translate(key: 'fineUploader.view')}</a>
<a class="view-btn btn btn-small btn-info hide" target="_blank">{f:translate(extensionName: 'media_upload', key: 'fineUploader.view')}</a>
</li>
</ul>
</div>
Expand All @@ -52,19 +52,20 @@
var property= '{property}';
var allowedExtensions= ['<f:format.raw>{allowedExtensions}</f:format.raw>'];

var typeError = "{f:translate(key: 'fineUploader.message.errorType')}";
var sizeError = "{f:translate(key: 'fineUploader.message.sizeError')}";
var minSizeError = "{f:translate(key: 'fineUploader.message.minSizeError')}";
var emptyError = "{f:translate(key: 'fineUploader.message.emptyError')}";
var noFilesError = "{f:translate(key: 'fineUploader.message.noFilesError')}";
var tooManyItemsError = "{f:translate(key: 'fineUploader.message.tooManyItemsError')}";
var maxHeightImageError = "{f:translate(key: 'fineUploader.message.maxHeightImageError')}";
var maxWidthImageError = "{f:translate(key: 'fineUploader.message.maxWidthImageError')}";
var minHeightImageError = "{f:translate(key: 'fineUploader.message.minHeightImageError')}";
var minWidthImageError = "{f:translate(key: 'fineUploader.message.minWidthImageError')}";
var retryFailTooManyItems = "{f:translate(key: 'fineUploader.message.retryFailTooManyItems')}";
var onLeave = "{f:translate(key: 'fineUploader.message.onLeave')}";
var unsupportedBrowserIos8Safari = "{f:translate(key: 'fineUploader.message.unsupportedBrowserIos8Safari')}";
console.log(maximumSize)
var typeError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.errorType')}";
var sizeError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.sizeError')}";
var minSizeError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.minSizeError')}";
var emptyError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.emptyError')}";
var noFilesError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.noFilesError')}";
var tooManyItemsError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.tooManyItemsError')}";
var maxHeightImageError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.maxHeightImageError')}";
var maxWidthImageError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.maxWidthImageError')}";
var minHeightImageError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.minHeightImageError')}";
var minWidthImageError = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.minWidthImageError')}";
var retryFailTooManyItems = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.retryFailTooManyItems')}";
var onLeave = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.onLeave')}";
var unsupportedBrowserIos8Safari = "{f:translate(extensionName: 'media_upload', key: 'fineUploader.message.unsupportedBrowserIos8Safari')}";

</script>

Expand Down
28 changes: 14 additions & 14 deletions Resources/Public/Build/media_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Repository: git://github.com/FineUploader/fine-uploader.git
*
* Licensed only under the MIT license (http://fineuploader.com/licensing).
*/
*/


(function(global) {
Expand Down Expand Up @@ -10732,9 +10732,9 @@ qq.extend(qq.Scaler.prototype, {

qq.ExifRestorer = (function()
{

var ExifRestorer = {};

ExifRestorer.KEY_STR = "ABCDEFGHIJKLMNOP" +
"QRSTUVWXYZabcdef" +
"ghijklmnopqrstuv" +
Expand Down Expand Up @@ -10775,23 +10775,23 @@ qq.ExifRestorer = (function()

return output;
};

ExifRestorer.restore = function(origFileBase64, resizedFileBase64)
{
var expectedBase64Header = "data:image/jpeg;base64,";

if (!origFileBase64.match(expectedBase64Header))
{
return resizedFileBase64;
}
}

var rawImage = this.decode64(origFileBase64.replace(expectedBase64Header, ""));
var segments = this.slice2Segments(rawImage);

var image = this.exifManipulation(resizedFileBase64, segments);

return expectedBase64Header + this.encode64(image);

};


Expand Down Expand Up @@ -10835,7 +10835,7 @@ qq.ExifRestorer = (function()
};



ExifRestorer.slice2Segments = function(rawImageArray)
{
var head = 0,
Expand Down Expand Up @@ -10863,8 +10863,8 @@ qq.ExifRestorer = (function()
};


ExifRestorer.decode64 = function(input)

ExifRestorer.decode64 = function(input)
{
var output = "",
chr1, chr2, chr3 = "",
Expand Down Expand Up @@ -10907,7 +10907,7 @@ qq.ExifRestorer = (function()
return buf;
};


return ExifRestorer;
})();

Expand Down Expand Up @@ -11791,7 +11791,7 @@ else {
})
.on('submit', {_settings: settings}, function(event) {
var params = {};
var parameterPrefix = 'tx_mediaupload_pi1';
var parameterPrefix = 'tx_mediaupload_upload';
params[parameterPrefix + '[storageIdentifier]'] = event.data._settings.storage;
params['type'] = '1386871773';
$(this).fineUploader('setParams', params);
Expand Down
4 changes: 2 additions & 2 deletions Resources/Public/Build/media_upload.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit ead025b

Please sign in to comment.