From 0ec934bf2040148593ae4e654f8775db0e764ca9 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 22 Dec 2015 18:27:04 +0100 Subject: [PATCH] Add media integration for editor --- com.woltlab.wcf/templates/dashboard.tpl | 31 ------------------- com.woltlab.wcf/templates/wysiwyg.tpl | 30 ++++++++++++++++++ .../redactor2/plugins/WoltLabMedia.js | 14 +++++++++ 3 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabMedia.js diff --git a/com.woltlab.wcf/templates/dashboard.tpl b/com.woltlab.wcf/templates/dashboard.tpl index eda866905a..a3b3daf148 100644 --- a/com.woltlab.wcf/templates/dashboard.tpl +++ b/com.woltlab.wcf/templates/dashboard.tpl @@ -29,37 +29,6 @@ {/if} -{*TODO: remove dummy media manager dialog demonstration code later on*} -

click

- - -{* /end *} - {include file='userNotice'}
diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 272816bb3c..976333e511 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -15,6 +15,30 @@ var callbackIdentifier = 'Redactor2_' + elementId; WCF.System.Dependency.Manager.setup(callbackIdentifier, function() { + // TODO: Should the media stuff be here? + {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')} + require(['Language', 'Permission'], function(Language, Permission) { + Language.addObject({ + 'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}', + + 'wcf.media.insert': '{lang}wcf.media.insert{/lang}', + 'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}', + 'wcf.media.insert.imageSize.small': '{lang __literal=true}wcf.media.insert.imageSize.small{/lang}', + 'wcf.media.insert.imageSize.medium': '{lang __literal=true}wcf.media.insert.imageSize.medium{/lang}', + 'wcf.media.insert.imageSize.large': '{lang __literal=true}wcf.media.insert.imageSize.large{/lang}', + 'wcf.media.insert.imageSize.original': '{lang __literal=true}wcf.media.insert.imageSize.original{/lang}', + 'wcf.media.manager': '{lang}wcf.media.manager{/lang}', + 'wcf.media.edit': '{lang}wcf.media.edit{/lang}', + 'wcf.media.imageDimensions.value': '{lang __literal=true}wcf.media.imageDimensions.value{/lang}', + 'wcf.media.button.insert': '{lang}wcf.media.button.insert{/lang}', + 'wcf.media.search.filetype': '{lang}wcf.media.search.filetype{/lang}', + 'wcf.media.search.noResults': '{lang}wcf.media.search.noResults{/lang}' + }); + + Permission.add('admin.content.cms.canManageMedia', {if $__wcf->session->getPermission('admin.content.cms.canManageMedia')}true{else}false{/if}); + }); + {/if} + var element = elById(elementId); var autosave = elData(element, 'autosave') || ''; if (autosave) { @@ -34,6 +58,11 @@ config.plugins.push('WoltLabMention'); } + // media + {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')} + config.plugins.push('WoltLabMedia'); + {/if} + $(element).redactor(config); }); @@ -44,6 +73,7 @@ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabButton.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabDropdown.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabEvent.js?v={@LAST_UPDATE_TIME}', + {if $__wcf->session->getPermission('admin.content.cms.canUseMedia')}'{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}',{/if} '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}', '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}' diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabMedia.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabMedia.js new file mode 100644 index 0000000000..6bf08d8529 --- /dev/null +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabMedia.js @@ -0,0 +1,14 @@ +$.Redactor.prototype.WoltLabMedia = function() { + "use strict"; + + return { + init: function() { + var button = this.button.add('woltlabMedia', 'Media'); + $(button).attr('id', 'mediaManagerButton'); + + require(['WoltLab/WCF/Media/Manager'], (function(MediaManager) { + new MediaManager(); + }).bind(this)); + }, + }; +}; -- 2.20.1