+{if !$wysiwygEnableUpload|isset}{assign var=wysiwygEnableUpload value=false}{/if}
<link rel="stylesheet" type="text/css" href="{@$__wcf->getPath()}js/3rdParty/redactor/redactor.css" />
<script data-relocate="true">
var __REDACTOR_ICON_PATH = '{@$__wcf->getPath()}icon/';
var $editorName = '{if $wysiwygSelector|isset}{$wysiwygSelector|encodeJS}{else}text{/if}';
var $callbackIdentifier = 'Redactor_' + $editorName;
+ {if $wysiwygEnableUpload}
+ WCF.Language.addObject({
+ 'wcf.attachment.upload.error.invalidExtension': '{lang}wcf.attachment.upload.error.invalidExtension{/lang}',
+ 'wcf.attachment.upload.error.tooLarge': '{lang}wcf.attachment.upload.error.tooLarge{/lang}',
+ 'wcf.attachment.upload.error.reachedLimit': '{lang}wcf.attachment.upload.error.reachedLimit{/lang}',
+ 'wcf.attachment.upload.error.reachedRemainingLimit': '{lang}wcf.attachment.upload.error.reachedRemainingLimit{/lang}',
+ 'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}',
+ 'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}',
+ 'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}',
+ 'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}',
+ 'wcf.attachment.upload.limits': '{'wcf.attachment.upload.limits'|language|encodeJS}'
+ });
+ {/if}
+
WCF.System.Dependency.Manager.setup($callbackIdentifier, function() {
var $textarea = $('#' + $editorName);
var $buttons = [ ];
}
};
+ {if $wysiwygEnableUpload}
+ $config.plugins.push('wupload');
+ $config.wattachment = {
+ maxCount: {@$attachmentHandler->getMaxCount()},
+ objectType: '{@$attachmentObjectType}',
+ objectID: '{@$attachmentObjectID}',
+ parentObjectID: '{@$attachmentParentObjectID}',
+ tmpHash: '{$tmpHash|encodeJS}'
+ };
+ {/if}
+
{event name='javascriptInit'}
$textarea.redactor($config);
});
head.load([
+ '{@$__wcf->getPath()}js/WCF.Attachment{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}',
'{@$__wcf->getPath()}js/3rdParty/redactor/redactor.js',
'{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wbbcode.js',
'{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wbutton.js',
'{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wfontfamily.js',
'{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wfontsize.js',
'{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wmonkeypatch.js',
- '{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wutil.js'
+ '{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wutil.js',
+ '{@$__wcf->getPath()}js/3rdParty/redactor/plugins/wupload.js'
{event name='javascriptFiles'}
], function() {
WCF.System.Dependency.Manager.invoke($callbackIdentifier);
$buttons.push('table');
{/if}
+{if $wysiwygEnableUpload}
+ $buttons.push('upload');
+{/if}
+
{if MODULE_SMILEY && (!$permissionCanUseSmilies|isset || $__wcf->getSession()->getPermission($permissionCanUseSmilies)) && $defaultSmilies|isset && $defaultSmilies|count}
$buttons.push('smiley');
{/if}
--- /dev/null
+if (!RedactorPlugins) var RedactorPlugins = {};
+
+/**
+ * Provides file uploads for Redactor.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2014 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ */
+RedactorPlugins.wupload = {
+ /**
+ * attachments container object
+ * @var jQuery
+ */
+ _attachmentsContainer: null,
+
+ /**
+ * Initializes the RedactorPlugins.wupload plugin.
+ */
+ init: function() {
+ var self = this;
+ this.buttonReplace('upload', 'upload', 'Upload', function() { self._attachmentsContainer.toggle(); });
+ this.buttonAwesome('upload', 'fa-upload');
+
+ this._initAttachments();
+ },
+
+ /**
+ * Initializes the attachments user interface.
+ */
+ _initAttachments: function() {
+ this._attachmentsContainer = $('<div class="redactorAttachmentContainer" />').hide().appendTo(this.$box);
+ $('<ul class="formAttachmentList clearfix" />').hide().appendTo(this._attachmentsContainer);
+ $('<dl class="wide"><dt></dt><dd><div data-max-size="{@$attachmentHandler->getMaxSize()}"></div><small>' + WCF.String.unescapeHTML(WCF.Language.get('wcf.attachment.upload.limits')) + '</small></dd></dl>').appendTo(this._attachmentsContainer);
+
+ var $options = this.getOption('wattachment');
+ new WCF.Attachment.Upload(this._attachmentsContainer.find('> dl > dd > div'), this._attachmentsContainer.children('ul'), $options.objectType, $options.objectID, $options.tmpHash, $options.parentObjectID, $options.maxCount, this.$source.wcfIdentify());
+ new WCF.Action.Delete('wcf\\data\\attachment\\AttachmentAction', '.formAttachmentList > li');
+ }
+};
},
lastPostTime: this._container.data('lastPostTime'),
pageNo: this._container.data('pageNo'),
- removeQuoteIDs: (this._quoteManager === null ? [ ] : this._quoteManager.getQuotesMarkedForRemoval())
+ removeQuoteIDs: (this._quoteManager === null ? [ ] : this._quoteManager.getQuotesMarkedForRemoval()),
+ tmpHash: this._container.data('tmpHash') || ''
};
if (this._container.data('anchor')) {
$parameters.anchor = this._container.data('anchor');
--- /dev/null
+<?php
+namespace wcf\data;
+
+/**
+ * Default interface for actions implementing quick reply with attachment support.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2014 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data
+ * @category Community Framework
+ */
+interface IAttachmentMessageQuickReplyAction extends IExtendedMessageQuickReplyAction {
+ /**
+ * Returns an attachment handler object.
+ *
+ * @param \wcf\data\DatabaseObject $container
+ */
+ public function getAttachmentHandler(DatabaseObject $container);
+}
use wcf\util\ArrayUtil;
use wcf\util\ClassUtil;
use wcf\util\MessageUtil;
+use wcf\util\StringUtil;
+use wcf\data\IAttachmentMessageQuickReplyAction;
/**
* Manages quick replies and stored messages.
// check for message quote ids
$parameters['removeQuoteIDs'] = (isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs'])) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array();
+ // check for tmp hash (attachments)
+ $parameters['tmpHash'] = (isset($parameters['tmpHash'])) ? StringUtil::trim($parameters['tmpHash']) : '';
+
EventHandler::getInstance()->fireAction($this, 'validateParameters');
}
$parameters['data'] = array_merge($this->additionalFields, $parameters['data']);
+ // attachment support
+ if (MODULE_ATTACHMENT && $object instanceof IAttachmentMessageQuickReplyAction) {
+ $parameters['attachmentHandler'] = $object->getAttachmentHandler($this->container);
+ }
+
// clean up
$this->additionalFields = array();
}
}
+.redactorAttachmentContainer {
+ background-color: rgba(255, 255, 255, 1);
+ border: 1px solid rgba(238, 238, 238, 1);
+ border-top-width: 0;
+ padding: 7px 14px 7px;
+}
+
.redactor_dropdown_box_wsmiley > ul > li:not(:last-child) {
margin-right: 3px !important;
}