<parent>wcf.acp.menu.link.cms</parent>
<permissions>admin.content.cms.canManageMedia</permissions>
</acpmenuitem>
- <acpmenuitem name="wcf.acp.menu.link.cms.media.add">
- <controller>wcf\acp\form\MediaAddForm</controller>
- <parent>wcf.acp.menu.link.cms.media.list</parent>
- <permissions>admin.content.cms.canManageMedia</permissions>
- <icon>fa-plus</icon>
- </acpmenuitem>
<!-- /cms -->
<!-- article -->
'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}',
{else}
{@$media->getElementTag(48)}
{/if}
-
+
<dl class="plain dataList">
<dt>{lang}wcf.media.filename{/lang}</dt>
<dd id="mediaFilename">{$media->filename}</dd>
-
+
<dt>{lang}wcf.media.filesize{/lang}</dt>
<dd id="mediaFilesize">{@$media->filesize|filesize}</dd>
-
+
{if $media->isImage}
<dt>{lang}wcf.media.imageDimensions{/lang}</dt>
<dd id="mediaImageDimensions">{lang}wcf.media.imageDimensions.value{/lang}</dd>
{/if}
-
+
<dt>{lang}wcf.media.uploader{/lang}</dt>
<dd id="mediaUploader">{@$media->getUserProfile()->getAnchorTag()}</dd>
</dl>
<section class="section">
<h2 class="sectionTitle">{lang}wcf.global.form.data{/lang}</h2>
-
+
<dl>
<dt></dt>
<dd>
</label>
</dd>
</dl>
-
+
{include file='languageChooser' label='wcf.media.languageID'}
-
+
<dl>
<dt><label for="title_{@$media->mediaID}">{lang}wcf.global.title{/lang}</label></dt>
<dd>
- <input type="text" id="title_{@$media->mediaID}" name="title" class="long" value="TODO">
+ <input type="text" id="title_{@$media->mediaID}" name="title" class="long">
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
-
+
<dl>
<dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
<dd>
- <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3">TODO</textarea>
+ <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
-
+
<dl>
<dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
<dd>
- <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long" value="TODO">
+ <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
-
+
{event name='dataFields'}
</section>
'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}',
+++ /dev/null
-{include file='header' pageTitle='wcf.acp.media.'|concat:$action}
-
-{if $action == 'add'}
- <script data-relocate="true">
- require(['EventHandler', 'WoltLabSuite/Core/Media/Upload'], function(EventHandler, MediaUpload) {
- new MediaUpload('uploadButton', 'mediaFile');
-
- // redirect the user to the edit form after uploading the file
- EventHandler.add('com.woltlab.wcf.media.upload', 'success', function(data) {
- for (var index in data.media) {
- window.location = '{link controller='MediaEdit' id=2147483648 encode=false}{/link}'.replace(2147483648, data.media[index].mediaID);
- }
- });
- });
- </script>
-{/if}
-
-<header class="contentHeader">
- <div class="contentHeaderTitle">
- <h1 id="mediaActionTitle" class="contentTitle">{lang}wcf.acp.media.{$action}{/lang}</h1>
- </div>
-
- <nav class="contentHeaderNavigation">
- <ul>
- <li><a href="{link controller='MediaList'}{/link}" class="button"><span class="icon icon16 fa-list"></span> <span>{lang}wcf.acp.menu.link.media.list{/lang}</span></a></li>
-
- {event name='contentHeaderNavigation'}
- </ul>
- </nav>
-</header>
-
-{if $action == 'edit'}
- {include file='formError'}
-{/if}
-
-{if $success|isset}
- <p class="success">{lang}wcf.global.success.{$action}{/lang}</p>
-{/if}
-
-{if $action == 'add'}
- <section class="section">
- <h2 class="sectionTitle">{lang}wcf.media.file{/lang}</h2>
-
- <dl>
- <dt></dt>
- <dd>
- <div id="mediaFile"></div>
- <div id="uploadButton"></div>
- </dd>
- </dl>
- </section>
-{else}
- <form method="post" action="{link controller='MediaEdit' object=$media}{/link}">
- <section class="section">
- <h2 class="sectionTitle">{lang}wcf.global.form.data{/lang}</h2>
-
- <dl>
- <dt>{lang}wcf.media.file{/lang}</dt>
- <dd>
- {if $media->isImage}
- {@$media->getThumbnailTag('small')}
- {else}
- {$media->filename}
- {/if}
- </dd>
- </dl>
-
- <dl>
- <dt></dt>
- <dd>
- <label>
- <input type="checkbox" id="isMultilingual" name="isMultilingual" value="1"{if $isMultilingual} checked{/if}>
- <span>{lang}wcf.media.isMultilingual{/lang}</span>
- </label>
- </dd>
- </dl>
-
- {include file='languageChooser' label='wcf.media.languageID'}
-
- <dl{if $errorField == 'title'} class="formError"{/if}>
- <dt>{lang}wcf.global.title{/lang}</dt>
- <dd>
- <input type="text" id="title" name="title" value="{$i18nPlainValues['title']}" class="long">
- {if $errorField == 'title'}
- <small class="innerError">
- {if $errorType == 'title' || $errorType == 'multilingual'}
- {lang}wcf.global.form.error.{@$errorType}{/lang}
- {else}
- {lang}wcf.media.title.error.{@$errorType}{/lang}
- {/if}
- </small>
- {/if}
- </dd>
- </dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='title' forceSelection=true}
-
- <dl{if $errorField == 'caption'} class="formError"{/if}>
- <dt>{lang}wcf.media.caption{/lang}</dt>
- <dd>
- <textarea id="caption" name="caption" cols="40" rows="3">{$i18nPlainValues['caption']}</textarea>
- {if $errorField == 'caption'}
- <small class="innerError">
- {if $errorType == 'title' || $errorType == 'multilingual'}
- {lang}wcf.global.form.error.{@$errorType}{/lang}
- {else}
- {lang}wcf.media.caption.error.{@$errorType}{/lang}
- {/if}
- </small>
- {/if}
- </dd>
- </dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='caption' forceSelection=true}
-
- <dl{if $errorField == 'altText'} class="formError"{/if}>
- <dt>{lang}wcf.media.altText{/lang}</dt>
- <dd>
- <input type="text" id="altText" name="altText" value="{$i18nPlainValues['altText']}" class="long">
- {if $errorField == 'altText'}
- <small class="innerError">
- {if $errorType == 'title' || $errorType == 'multilingual'}
- {lang}wcf.global.form.error.{@$errorType}{/lang}
- {else}
- {lang}wcf.media.altText.error.{@$errorType}{/lang}
- {/if}
- </small>
- {/if}
- </dd>
- </dl>
- {include file='multipleLanguageInputJavascript' elementIdentifier='altText' forceSelection=true}
-
- {event name='dataFields'}
- </section>
-
- {include file='aclSimple'}
-
- {event name='sections'}
-
- <div class="formSubmit">
- <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
- {@SECURITY_TOKEN_INPUT_TAG}
- </div>
- </form>
-{/if}
-
-{if $action == 'edit'}
- {* this code needs to be put after all multipleLanguageInputJavascript template have been included *}
- <script data-relocate="true">
- require(['WoltLabSuite/Core/Language/Input'], function(LanguageInput) {
- function updateLanguageFields() {
- var languageIdContainer = elById('languageIDContainer').parentNode;
-
- if (elById('isMultilingual').checked) {
- LanguageInput.enable('title');
- LanguageInput.enable('caption');
- LanguageInput.enable('altText');
-
- elHide(languageIdContainer);
- }
- else {
- LanguageInput.disable('title');
- LanguageInput.disable('caption');
- LanguageInput.disable('altText');
-
- elShow(languageIdContainer);
- }
- };
-
- elById('isMultilingual').addEventListener('change', updateLanguageFields);
-
- updateLanguageFields();
-
- {if !$isMultilingual}
- elById('title').value = '{$i18nPlainValues['title']|encodeJS}';
- elById('caption').value = '{$i18nPlainValues['caption']|encodeJS}';
- elById('altText').value = '{$i18nPlainValues['altText']|encodeJS}';
- {/if}
- });
- </script>
-{/if}
-
-{include file='footer'}
<dl>
<dt><label for="title_{@$media->mediaID}">{lang}wcf.global.title{/lang}</label></dt>
<dd>
- <input type="text" id="title_{@$media->mediaID}" name="title" class="long" value="TODO">
+ <input type="text" id="title_{@$media->mediaID}" name="title" class="long">
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
<dl>
<dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
<dd>
- <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3">TODO</textarea>
+ <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
<dl>
<dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
<dd>
- <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long" value="TODO">
+ <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
</dd>
</dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
{include file='header' pageTitle='wcf.acp.media.list'}
<script data-relocate="true">
- document.addEventListener('DOMContentLoaded', function() {
- require(['EventHandler', 'Language', 'Ui/SimpleDropdown', 'WoltLabSuite/Core/Controller/Clipboard', 'WoltLabSuite/Core/Media/Search'], function (EventHandler, Language, UiSimpleDropdown, Clipboard, MediaSearch) {
- Language.add('wcf.media.search.filetype', '{lang}wcf.media.search.filetype{/lang}');
-
- Clipboard.setup({
- hasMarkedItems: {if $hasMarkedItems}true{else}false{/if},
- pageClassName: 'wcf\\acp\\page\\MediaListPage'
- });
-
- EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', 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();
- }
- }
- });
-
- new MediaSearch('{$fileType}');
-
- new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow');
+ {include file='mediaJavaScript'}
+
+ require(['WoltLabSuite/Core/Controller/Media/List'], function (ControllerMediaList) {
+ ControllerMediaList.init({
+ hasMarkedItems: {if $hasMarkedItems}true{else}false{/if}
});
});
</script>
+{* hidden container element containg the element for the uploaded media file *}
+<p id="mediaFile" style="display: none;"></p>
+
<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.media.list{/lang}</h1>
<nav class="contentHeaderNavigation">
<ul>
- <li><a href="{link controller='MediaAdd'}{/link}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.acp.media.add{/lang}</span></a></li>
+ <li><div id="uploadButton"></div></li>
{event name='contentHeaderNavigation'}
</ul>
<tr class="jsMediaRow jsClipboardObject">
<td class="columnMark"><input type="checkbox" class="jsClipboardItem" data-object-id="{@$media->mediaID}"></td>
<td class="columnIcon">
- <a href="{link controller='MediaEdit' object=$media}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon24 fa-pencil"></span></a>
+ <span class="icon icon24 fa-pencil jsMediaEditButton jsTooltip pointer" title="{lang}wcf.global.button.edit{/lang}" data-object-id="{@$media->mediaID}"></span>
<span class="icon icon24 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$media->mediaID}" data-confirm-message-html="{lang title=$media->filename __encode=true}wcf.media.delete.confirmMessage{/lang}"></span>
{event name='rowButtons'}
{@$media->getElementTag(48)}
<div>
- <p><a href="{link controller='MediaEdit' object=$media}{/link}">{$media->filename|tableWordwrap}</a></p>
+ <p>{$media->filename|tableWordwrap}</p>
<p><small>{if $media->userID}{if $__wcf->session->getPermission('admin.user.canEditUser')}<a href="{link controller='UserEdit' id=$media->userID}{/link}">{$media->username}</a>{else}{$media->username}{/if}{else}{lang}wcf.user.guest{/lang}{/if}</small></p>
</div>
</div>
--- /dev/null
+/**
+ * Initializes modules required for media list view.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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
* @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();
_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);
_close: function() {
this._media = null;
- this._callbackObject._editorClose();
+ if (this._callbackObject._editorClose) {
+ this._callbackObject._editorClose();
+ }
},
/**
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);
}
}
/**
* 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 + "'");
}
},
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));
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));
--- /dev/null
+/**
+ * Uploads media files.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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 = '<span class="icon icon16 fa-upload"></span> <span>' + Language.get('wcf.global.button.upload') + '</span>';
+
+ 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;
+});
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');
+++ /dev/null
-<?php
-namespace wcf\acp\form;
-use wcf\data\media\MediaAction;
-use wcf\data\media\ViewableMedia;
-use wcf\form\AbstractForm;
-use wcf\system\acl\simple\SimpleAclHandler;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\exception\UserInputException;
-use wcf\system\language\I18nHandler;
-use wcf\system\language\LanguageFactory;
-use wcf\system\WCF;
-use wcf\util\ArrayUtil;
-
-/**
- * Shows the form to edit a media file.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2016 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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);
- }
- }
- }
- }
-}
+++ /dev/null
-<?php
-namespace wcf\acp\page;
-use wcf\page\AbstractPage;
-use wcf\system\WCF;
-
-/**
- * Shows the page to upload a media file.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2016 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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');
- }
-}
* @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);
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),
<item name="wcf.acp.menu.link.cms.box.list"><![CDATA[Boxen]]></item>
<item name="wcf.acp.menu.link.cms.box.add"><![CDATA[Box hinzufügen]]></item>
<item name="wcf.acp.menu.link.cms.media.list"><![CDATA[Medien]]></item>
- <item name="wcf.acp.menu.link.cms.media.add"><![CDATA[Medium hinzufügen]]></item>
<item name="wcf.acp.menu.link.article"><![CDATA[Artikel]]></item>
<item name="wcf.acp.menu.link.article.list"><![CDATA[Artikel]]></item>
<item name="wcf.acp.menu.link.article.add"><![CDATA[Artikel hinzufügen]]></item>
<item name="wcf.acp.menu.link.cms.box.list"><![CDATA[Boxes]]></item>
<item name="wcf.acp.menu.link.cms.box.add"><![CDATA[Add Box]]></item>
<item name="wcf.acp.menu.link.cms.media.list"><![CDATA[Media]]></item>
- <item name="wcf.acp.menu.link.cms.media.add"><![CDATA[Add Medium]]></item>
<item name="wcf.acp.menu.link.article"><![CDATA[Articles]]></item>
<item name="wcf.acp.menu.link.article.list"><![CDATA[Articles]]></item>
<item name="wcf.acp.menu.link.article.add"><![CDATA[Add Article]]></item>
<item name="wcf.media.search.filetype.other"><![CDATA[Other]]></item>
<item name="wcf.media.search.filetype.text"><![CDATA[Texts]]></item>
<item name="wcf.media.search.placeholder"><![CDATA[Search Files]]></item>
+ <item name="wcf.media.upload.success"><![CDATA[The file has been successfully uploaded.]]></item>
<item name="wcf.media.uploader"><![CDATA[Uploaded By]]></item>
</category>