From: Matthias Schmidt Date: Thu, 1 Sep 2016 15:51:44 +0000 (+0200) Subject: Remove media add page and media edit form in ACP X-Git-Tag: 3.0.0_Beta_1~361 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9c07b2716c9e4105a5edf308b82778b34e9fd739;p=GitHub%2FWoltLab%2FWCF.git Remove media add page and media edit form in ACP Media add page has only been a minimal page anyway without any benefit over the direct upload button on the media list page and media editing is now always handled via the dialog editor directly. --- diff --git a/com.woltlab.wcf/acpMenu.xml b/com.woltlab.wcf/acpMenu.xml index fe7c1a9517..1dee560d6c 100644 --- a/com.woltlab.wcf/acpMenu.xml +++ b/com.woltlab.wcf/acpMenu.xml @@ -323,12 +323,6 @@ wcf.acp.menu.link.cms admin.content.cms.canManageMedia - - wcf\acp\form\MediaAddForm - wcf.acp.menu.link.cms.media.list - admin.content.cms.canManageMedia - fa-plus - diff --git a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl index b3f9ac4eb3..edc2ff04ee 100644 --- a/com.woltlab.wcf/templates/headIncludeJavaScript.tpl +++ b/com.woltlab.wcf/templates/headIncludeJavaScript.tpl @@ -67,8 +67,8 @@ requirejs.config({ 'wcf.global.form.error.empty': '{lang}wcf.global.form.error.empty{/lang}', 'wcf.global.form.error.greaterThan': '{lang __literal=true}wcf.global.form.error.greaterThan{/lang}', 'wcf.global.form.error.lessThan': '{lang __literal=true}wcf.global.form.error.lessThan{/lang}', - 'wcf.global.form.input.maxItems': '{lang}wcf.global.form.input.maxItems{/lang}', 'wcf.global.form.error.multilingual': '{lang}wcf.global.form.error.multilingual{/lang}', + 'wcf.global.form.input.maxItems': '{lang}wcf.global.form.input.maxItems{/lang}', 'wcf.global.language.noSelection': '{lang}wcf.global.language.noSelection{/lang}', 'wcf.global.loading': '{lang}wcf.global.loading{/lang}', 'wcf.global.noSelection': '{lang}wcf.global.noSelection{/lang}', diff --git a/com.woltlab.wcf/templates/mediaEditor.tpl b/com.woltlab.wcf/templates/mediaEditor.tpl index ef718a76d8..28b74c2c5b 100644 --- a/com.woltlab.wcf/templates/mediaEditor.tpl +++ b/com.woltlab.wcf/templates/mediaEditor.tpl @@ -10,19 +10,19 @@ {else} {@$media->getElementTag(48)} {/if} - +
{lang}wcf.media.filename{/lang}
{$media->filename}
- +
{lang}wcf.media.filesize{/lang}
{@$media->filesize|filesize}
- + {if $media->isImage}
{lang}wcf.media.imageDimensions{/lang}
{lang}wcf.media.imageDimensions.value{/lang}
{/if} - +
{lang}wcf.media.uploader{/lang}
{@$media->getUserProfile()->getAnchorTag()}
@@ -30,7 +30,7 @@

{lang}wcf.global.form.data{/lang}

- +
@@ -40,33 +40,33 @@
- + {include file='languageChooser' label='wcf.media.languageID'} - +
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true} - +
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true} - +
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true} - + {event name='dataFields'}
diff --git a/wcfsetup/install/files/acp/templates/header.tpl b/wcfsetup/install/files/acp/templates/header.tpl index 6321d46f81..7badf6ea27 100644 --- a/wcfsetup/install/files/acp/templates/header.tpl +++ b/wcfsetup/install/files/acp/templates/header.tpl @@ -83,6 +83,7 @@ 'wcf.global.form.error.empty': '{lang}wcf.global.form.error.empty{/lang}', 'wcf.global.form.error.greaterThan': '{lang __literal=true}wcf.global.form.error.greaterThan{/lang}', 'wcf.global.form.error.lessThan': '{lang __literal=true}wcf.global.form.error.lessThan{/lang}', + 'wcf.global.form.error.multilingual': '{lang}wcf.global.form.error.multilingual{/lang}', 'wcf.global.loading': '{lang}wcf.global.loading{/lang}', 'wcf.global.noSelection': '{lang}wcf.global.noSelection{/lang}', 'wcf.page.jumpTo': '{lang}wcf.page.jumpTo{/lang}', diff --git a/wcfsetup/install/files/acp/templates/mediaAdd.tpl b/wcfsetup/install/files/acp/templates/mediaAdd.tpl deleted file mode 100644 index 1279f72ef2..0000000000 --- a/wcfsetup/install/files/acp/templates/mediaAdd.tpl +++ /dev/null @@ -1,181 +0,0 @@ -{include file='header' pageTitle='wcf.acp.media.'|concat:$action} - -{if $action == 'add'} - -{/if} - -
-
-

{lang}wcf.acp.media.{$action}{/lang}

-
- - -
- -{if $action == 'edit'} - {include file='formError'} -{/if} - -{if $success|isset} -

{lang}wcf.global.success.{$action}{/lang}

-{/if} - -{if $action == 'add'} -
-

{lang}wcf.media.file{/lang}

- -
-
-
-
-
-
-
-
-{else} -
-
-

{lang}wcf.global.form.data{/lang}

- -
-
{lang}wcf.media.file{/lang}
-
- {if $media->isImage} - {@$media->getThumbnailTag('small')} - {else} - {$media->filename} - {/if} -
-
- -
-
-
- -
-
- - {include file='languageChooser' label='wcf.media.languageID'} - - -
{lang}wcf.global.title{/lang}
-
- - {if $errorField == 'title'} - - {if $errorType == 'title' || $errorType == 'multilingual'} - {lang}wcf.global.form.error.{@$errorType}{/lang} - {else} - {lang}wcf.media.title.error.{@$errorType}{/lang} - {/if} - - {/if} -
- - {include file='multipleLanguageInputJavascript' elementIdentifier='title' forceSelection=true} - - -
{lang}wcf.media.caption{/lang}
-
- - {if $errorField == 'caption'} - - {if $errorType == 'title' || $errorType == 'multilingual'} - {lang}wcf.global.form.error.{@$errorType}{/lang} - {else} - {lang}wcf.media.caption.error.{@$errorType}{/lang} - {/if} - - {/if} -
- - {include file='multipleLanguageInputJavascript' elementIdentifier='caption' forceSelection=true} - - -
{lang}wcf.media.altText{/lang}
-
- - {if $errorField == 'altText'} - - {if $errorType == 'title' || $errorType == 'multilingual'} - {lang}wcf.global.form.error.{@$errorType}{/lang} - {else} - {lang}wcf.media.altText.error.{@$errorType}{/lang} - {/if} - - {/if} -
- - {include file='multipleLanguageInputJavascript' elementIdentifier='altText' forceSelection=true} - - {event name='dataFields'} -
- - {include file='aclSimple'} - - {event name='sections'} - -
- - {@SECURITY_TOKEN_INPUT_TAG} -
-
-{/if} - -{if $action == 'edit'} - {* this code needs to be put after all multipleLanguageInputJavascript template have been included *} - -{/if} - -{include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/mediaEditor.tpl b/wcfsetup/install/files/acp/templates/mediaEditor.tpl index 69e982028f..28b74c2c5b 100644 --- a/wcfsetup/install/files/acp/templates/mediaEditor.tpl +++ b/wcfsetup/install/files/acp/templates/mediaEditor.tpl @@ -46,7 +46,7 @@
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true} @@ -54,7 +54,7 @@
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true} @@ -62,7 +62,7 @@
- +
{include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true} diff --git a/wcfsetup/install/files/acp/templates/mediaList.tpl b/wcfsetup/install/files/acp/templates/mediaList.tpl index fc8d748f9b..14589086e5 100644 --- a/wcfsetup/install/files/acp/templates/mediaList.tpl +++ b/wcfsetup/install/files/acp/templates/mediaList.tpl @@ -1,48 +1,18 @@ {include file='header' pageTitle='wcf.acp.media.list'} +{* hidden container element containg the element for the uploaded media file *} + +

{lang}wcf.acp.media.list{/lang}

@@ -51,7 +21,7 @@
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js new file mode 100644 index 0000000000..379d0c8b9c --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js @@ -0,0 +1,75 @@ +/** + * Initializes modules required for media list view. + * + * @author Matthias Schmidt + * @copyright 2001-2016 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Controller/Media/List + */ +define(['EventHandler', 'WoltLabSuite/Core/Controller/Clipboard', 'WoltLabSuite/Core/Media/Editor', 'WoltLabSuite/Core/Media/Search', 'WoltLabSuite/Core/Media/List/Upload'], function(EventHandler, Clipboard, MediaEditor, MediaSearch, MediaListUpload) { + "use strict"; + + var _mediaEditor; + + /** + * @exports WoltLabSuite/Core/Controller/Media/List + */ + return { + init: function(options) { + options = options || {}; + new MediaListUpload('uploadButton', 'mediaFile'); + + Clipboard.setup({ + hasMarkedItems: options.hasMarkedItems || false, + pageClassName: 'wcf\\acp\\page\\MediaListPage' + }); + + EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this)); + + new MediaSearch('{$fileType}'); + + new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow'); + + _mediaEditor = new MediaEditor(); + + var editButtons = elByClass('jsMediaEditButton'); + for (var i = 0, length = editButtons.length; i < length; i++) { + editButtons[i].addEventListener(WCF_CLICK_EVENT, this._edit.bind(this)); + } + }, + + /** + * + * @param {object} actionData + */ + _clipboardAction: function(actionData) { + // only consider events if the action has been executed + if (actionData.responseData === null) { + return; + } + + if (actionData.data.actionName === 'com.woltlab.wcf.media.delete') { + var mediaIds = actionData.responseData.objectIDs; + + var mediaRows = elByClass('jsMediaRow'); + for (var i = 0; i < mediaRows.length; i++) { + var media = mediaRows[i]; + var mediaID = ~~elData(elByClass('jsClipboardItem', media)[0], 'object-id'); + + if (mediaIds.indexOf(mediaID) !== -1) { + elRemove(media); + i--; + } + } + + if (!mediaRows.length) { + window.location.reload(); + } + } + }, + + _edit: function(event) { + _mediaEditor.edit(elData(event.currentTarget, 'object-id')); + } + } +}); \ No newline at end of file diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js index 26dea2802d..5e17eaafe0 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Editor.js @@ -24,17 +24,15 @@ define( * @constructor */ function MediaEditor(callbackObject) { - if (typeof callbackObject !== 'object') { - throw new TypeError("Parameter 'callbackObject' has to be an object, " + typeof callbackObject + " given."); - } - if (typeof callbackObject._editorClose !== 'function') { + this._callbackObject = callbackObject || {}; + + if (this._callbackObject._editorClose && typeof this._callbackObject._editorClose !== 'function') { throw new TypeError("Callback object has no function '_editorClose'."); } - if (typeof callbackObject._editorSuccess !== 'function') { + if (this._callbackObject._editorSuccess && typeof this._callbackObject._editorSuccess !== 'function') { throw new TypeError("Callback object has no function '_editorSuccess'."); } - this._callbackObject = callbackObject; this._media = null; this._dialogs = new Dictionary(); @@ -62,7 +60,9 @@ define( _ajaxSuccess: function(data) { UiNotification.show(); - this._callbackObject._editorSuccess(this._media); + if (this._callbackObject._editorSuccess) { + this._callbackObject._editorSuccess(this._media); + } UiDialog.close('mediaEditor_' + this._media.mediaID); @@ -75,7 +75,9 @@ define( _close: function() { this._media = null; - this._callbackObject._editorClose(); + if (this._callbackObject._editorClose) { + this._callbackObject._editorClose(); + } }, /** @@ -138,7 +140,7 @@ define( var error = elCreate('small'); error.className = 'innerError'; error.textContent = Language.get('wcf.global.form.error.multilingual'); - thistitle.parentNode.parentNode.appendChild(error); + title.parentNode.parentNode.appendChild(error); } } @@ -218,9 +220,15 @@ define( /** * Edits the media with the given data. * - * @param {object} media data of the edited media + * @param {object|integer} media data of the edited media or media id for which the data will be loaded */ edit: function(media) { + if (typeof media !== 'object') { + media = { + mediaID: ~~media + }; + } + if (this._media !== null) { throw new Error("Cannot edit media with id '" + media.mediaID + "' while editing media with id '" + this._media.mediaID + "'"); } @@ -239,15 +247,30 @@ define( }, source: { after: (function(content, data) { + var didLoadMediaData = false; + if (data.returnValues.mediaData) { + this._media = data.returnValues.mediaData; + + didLoadMediaData = true; + } + // make sure that the language chooser is initialized first setTimeout(function() { LanguageChooser.setLanguageId('languageID', this._media.languageID || LANGUAGE_ID); + var title = elBySel('input[name=title]', content); + var altText = elBySel('input[name=altText]', content); + if (this._media.isMultilingual) { LanguageInput.setValues('altText_' + this._media.mediaID, Dictionary.fromObject(this._media.altText || { })); LanguageInput.setValues('caption_' + this._media.mediaID, Dictionary.fromObject(this._media.caption || { })); LanguageInput.setValues('title_' + this._media.mediaID, Dictionary.fromObject(this._media.title || { })); } + else { + title.value = this._media.title ? this._media.title[LANGUAGE_ID] : ''; + altText.value = this._media.altText ? this._media.altText[LANGUAGE_ID] : ''; + elBySel('textarea[name=caption]', content).value = this._media.caption ? this._media.caption[LANGUAGE_ID] : ''; + } var isMultilingual = elBySel('input[name=isMultilingual]', content); isMultilingual.addEventListener('change', this._updateLanguageFields.bind(this)); @@ -255,8 +278,8 @@ define( this._updateLanguageFields(null, isMultilingual); var keyPress = this._keyPress.bind(this); - elBySel('input[name=altText]', content).addEventListener('keypress', keyPress); - elBySel('input[name=title]', content).addEventListener('keypress', keyPress); + altText.addEventListener('keypress', keyPress); + title.addEventListener('keypress', keyPress); elBySel('button[data-type=submit]', content).addEventListener(WCF_CLICK_EVENT, this._saveData.bind(this)); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/List/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/List/Upload.js new file mode 100644 index 0000000000..e88e5142d5 --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/List/Upload.js @@ -0,0 +1,107 @@ +/** + * Uploads media files. + * + * @author Matthias Schmidt + * @copyright 2001-2016 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Media/List/Upload + */ +define( + [ + 'Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Dom/Util', 'Language', 'Ui/Confirmation', 'Ui/Notification', '../Upload' + ], + function( + Core, DomChangeListener, DomTraverse, DomUtil, Language, UiConfirmation, UiNotification, MediaUpload + ) +{ + "use strict"; + + /** + * @constructor + */ + function MediaListUpload(buttonContainerId, targetId, options) { + options = options || {}; + + // only one file may be uploaded file list upload for proper error display + options.multiple = false; + + MediaUpload.call(this, buttonContainerId, targetId, options); + } + Core.inherit(MediaListUpload, MediaUpload, { + /** + * Creates the upload button. + */ + _createButton: function() { + this._fileUpload = elCreate('input'); + elAttr(this._fileUpload, 'type', 'file'); + elAttr(this._fileUpload, 'name', this._options.name); + this._fileUpload.addEventListener('change', this._upload.bind(this)); + + this._button = elCreate('p'); + this._button.className = 'button uploadButton'; + + this._button.innerHTML = ' ' + Language.get('wcf.global.button.upload') + ''; + + DomUtil.prepend(this._fileUpload, this._button); + + this._insertButton(); + + DomChangeListener.trigger(); + }, + + /** + * @see WoltLabSuite/Core/Upload#_success + */ + _success: function(uploadId, data) { + var icon = DomTraverse.childByClass(this._button, 'icon'); + icon.classList.remove('fa-spinner'); + icon.classList.add('fa-upload'); + + var file = this._fileElements[uploadId][0]; + + var internalFileId = elData(file, 'internal-file-id'); + var media = data.returnValues.media[internalFileId]; + + if (media) { + UiNotification.show(Language.get('wcf.media.upload.success'), function() { + window.location.reload(); + }); + } + else { + var error = data.returnValues.errors[internalFileId]; + if (!error) { + error = { + errorType: 'uploadFailed', + filename: elData(file, 'filename') + }; + } + + UiConfirmation.show({ + confirm: function() { + // do nothing + }, + message: Language.get('wcf.media.upload.error.' + error.errorType, { + filename: error.filename + }) + }); + } + }, + + /** + * @see WoltLabSuite/Core/Upload#_success + */ + _upload: function(event, file, blob) { + var uploadId = MediaListUpload._super.prototype._upload.call(this, event, file, blob); + + var icon = DomTraverse.childByClass(this._button, 'icon'); + window.setTimeout(function() { + icon.classList.remove('fa-upload'); + icon.classList.add('fa-spinner'); + }, 500); + + return uploadId; + } + }); + + return MediaListUpload; +}); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js index 52b1fffe48..f629c11d1d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js @@ -70,8 +70,7 @@ define(['AjaxRequest', 'Core', 'Dom/ChangeListener', 'Language', 'Dom/Util', 'Do this._fileUpload.addEventListener('change', this._upload.bind(this)); this._button = elCreate('p'); - this._button.classList.add('button'); - this._button.classList.add('uploadButton'); + this._button.className = 'button uploadButton'; var span = elCreate('span'); span.textContent = Language.get('wcf.global.button.upload'); diff --git a/wcfsetup/install/files/lib/acp/form/MediaEditForm.class.php b/wcfsetup/install/files/lib/acp/form/MediaEditForm.class.php deleted file mode 100644 index 97f37545b8..0000000000 --- a/wcfsetup/install/files/lib/acp/form/MediaEditForm.class.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @package WoltLabSuite\Core\Acp\Form - * @since 3.0 - */ -class MediaEditForm extends AbstractForm { - /** - * acl values - * @var array - */ - public $aclValues = []; - - /** - * @inheritDoc - */ - public $activeMenuItem = 'wcf.acp.menu.link.cms.media.list'; - - /** - * is 1 if media data is multilingual - * @var integer - */ - public $isMultilingual = 0; - - /** - * id of the selected language - * @var integer - */ - public $languageID = 0; - - /** - * edited media - * @var ViewableMedia - */ - public $media = null; - - /** - * id of the edited media - * @var integer - */ - public $mediaID = 0; - - /** - * @inheritDoc - */ - public $neededPermissions = ['admin.content.cms.canManageMedia']; - - /** - * @inheritDoc - */ - public function assignVariables() { - parent::assignVariables(); - - I18nHandler::getInstance()->assignVariables(); - - WCF::getTPL()->assign([ - 'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues), - 'action' => 'edit', - 'isMultilingual' => $this->isMultilingual, - 'languages' => LanguageFactory::getInstance()->getLanguages(), - 'languageID' => $this->languageID, - 'media' => $this->media - ]); - } - - /** - * @inheritDoc - */ - public function readData() { - parent::readData(); - - if (empty($_POST)) { - $this->isMultilingual = $this->media->isMultilingual; - if (!$this->isMultilingual && !$this->media->languageID) { - $this->isMultilingual = 1; - } - - if ($this->media->languageID) { - $this->languageID = $this->media->languageID; - } - else { - $this->languageID = WCF::getUser()->languageID; - } - - $contentData = $this->media->getI18nData(); - if (!empty($contentData)) { - if (!empty($contentData['altText'])) I18nHandler::getInstance()->setValues('altText', $contentData['altText']); - if (!empty($contentData['caption'])) I18nHandler::getInstance()->setValues('caption', $contentData['caption']); - if (!empty($contentData['title'])) I18nHandler::getInstance()->setValues('title', $contentData['title']); - } - - $this->aclValues = SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.media', $this->media->mediaID); - } - - if (!$this->languageID) { - $this->languageID = WCF::getUser()->languageID; - } - } - - /** - * @inheritDoc - */ - public function readFormParameters() { - parent::readFormParameters(); - - if (isset($_POST['isMultilingual'])) $this->isMultilingual = intval($_POST['isMultilingual']); - if (!$this->isMultilingual) { - if (isset($_POST['languageID'])) $this->languageID = intval($_POST['languageID']); - } - I18nHandler::getInstance()->readValues(); - - if (isset($_POST['aclValues']) && is_array($_POST['aclValues'])) $this->aclValues = $_POST['aclValues']; - } - - /** - * @inheritDoc - */ - public function readParameters() { - parent::readParameters(); - - if (isset($_REQUEST['id'])) $this->mediaID = intval($_REQUEST['id']); - - $this->media = ViewableMedia::getMedia($this->mediaID); - if ($this->media === null) { - throw new IllegalLinkException(); - } - - I18nHandler::getInstance()->register('title'); - I18nHandler::getInstance()->register('caption'); - I18nHandler::getInstance()->register('altText'); - } - - /** - * @inheritDoc - */ - public function save() { - parent::save(); - - $this->objectAction = new MediaAction([$this->media->getDecoratedObject()], 'update', array_merge($this->additionalFields, [ - 'data' => [ - 'isMultilingual' => $this->isMultilingual, - 'languageID' => $this->languageID ?: null - ], - 'altText' => I18nHandler::getInstance()->getValues('altText'), - 'caption' => I18nHandler::getInstance()->getValues('caption'), - 'title' => I18nHandler::getInstance()->getValues('title') - ])); - $this->objectAction->executeAction(); - - // save acl - SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.media', $this->media->mediaID, $this->aclValues); - - $this->saved(); - - WCF::getTPL()->assign('success', true); - } - - /** - * @inheritDoc - * @throws UserInputException - */ - public function validate() { - parent::validate(); - - if (!$this->isMultilingual && !$this->languageID) { - throw new UserInputException('languageID'); - } - - if ($this->languageID && !LanguageFactory::getInstance()->getLanguage($this->languageID)) { - throw new UserInputException('languageID'); - } - - foreach (['title', 'caption', 'altText'] as $i18nData) { - if (!I18nHandler::getInstance()->validateValue($i18nData, $this->isMultilingual? true : false, true)) { - if ($this->isMultilingual) { - // in contrast to I18nHandler::validateValues(), we allow all fields to be empty - if (empty(ArrayUtil::trim(I18nHandler::getInstance()->getValues($i18nData)))) { - continue; - } - - throw new UserInputException($i18nData, 'multilingual'); - } - else { - throw new UserInputException($i18nData); - } - } - } - } -} diff --git a/wcfsetup/install/files/lib/acp/page/MediaAddPage.class.php b/wcfsetup/install/files/lib/acp/page/MediaAddPage.class.php deleted file mode 100644 index 11ecf00d1d..0000000000 --- a/wcfsetup/install/files/lib/acp/page/MediaAddPage.class.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @package WoltLabSuite\Core\Acp\Page - * @since 3.0 - */ -class MediaAddPage extends AbstractPage { - /** - * @inheritDoc - */ - public $activeMenuItem = 'wcf.acp.menu.link.cms.media.add'; - - /** - * @inheritDoc - */ - public $neededPermissions = ['admin.content.cms.canManageMedia']; - - /** - * @inheritDoc - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign('action', 'add'); - } -} diff --git a/wcfsetup/install/files/lib/data/media/MediaAction.class.php b/wcfsetup/install/files/lib/data/media/MediaAction.class.php index a3851e23d9..1682f5e28b 100644 --- a/wcfsetup/install/files/lib/data/media/MediaAction.class.php +++ b/wcfsetup/install/files/lib/data/media/MediaAction.class.php @@ -249,7 +249,10 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction, * @return string[] */ public function getEditorDialog() { - $media = new ViewableMedia($this->getSingleObject()->getDecoratedObject()); + $mediaList = new ViewableMediaList(); + $mediaList->setObjectIDs([$this->getSingleObject()->mediaID]); + $mediaList->readObjects(); + $media = $mediaList->search($this->getSingleObject()->mediaID); I18nHandler::getInstance()->register('title_' . $media->mediaID); I18nHandler::getInstance()->register('caption_' . $media->mediaID); @@ -257,6 +260,7 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction, I18nHandler::getInstance()->assignVariables(); return [ + 'mediaData' => $this->getI18nMediaData($mediaList)[$this->getSingleObject()->mediaID], 'template' => WCF::getTPL()->fetch('mediaEditor', 'wcf', [ '__aclSimplePrefix' => 'mediaEditor_' . $media->mediaID . '_', 'aclValues' => SimpleAclHandler::getInstance()->getValues('com.woltlab.wcf.media', $media->mediaID), diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 841486d11f..c265f1457e 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -714,7 +714,6 @@ - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 9f5ff1f033..6ca788dc92 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -712,7 +712,6 @@ Examples for medium ID detection: - @@ -2513,6 +2512,7 @@ Errors are: +