Add media integration for editor
authorMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2015 17:27:04 +0000 (18:27 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 22 Dec 2015 17:27:34 +0000 (18:27 +0100)
com.woltlab.wcf/templates/dashboard.tpl
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabMedia.js [new file with mode: 0644]

index eda866905ae424c2bbabf0705fe4206378b53548..a3b3daf148c7cee0c49027869a4c0404528b4825 100644 (file)
        </header>
 {/if}
 
-{*TODO: remove dummy media manager dialog demonstration code later on*}
-<p class="button" id="mediaManagerButton">click</p>
-
-<script data-relocate="true">
-       $(function() {
-               require(['WoltLab/WCF/Media/Manager', 'Language', 'Permission'], function(MediaManager, 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});
-                       
-                       new MediaManager();
-               });
-       });
-</script>
-{* /end *}
-
 {include file='userNotice'}
 
 <div class="contentNavigation">
index 272816bb3ce097fdb98fe32d523ac0479c75a542..976333e51199822c398ced459c7436109383af08 100644 (file)
        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) {
                        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 (file)
index 0000000..6bf08d8
--- /dev/null
@@ -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));
+               },
+       };
+};