Draft implementation for comments
authorAlexander Ebert <ebert@woltlab.com>
Wed, 1 Mar 2017 15:15:51 +0000 (16:15 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 2 Mar 2017 11:03:38 +0000 (12:03 +0100)
See #2222

com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/commentListAddComment.tpl [new file with mode: 0644]
com.woltlab.wcf/templates/userProfileCommentList.tpl
wcfsetup/install/files/js/WCF.Comment.js
wcfsetup/install/files/lib/data/comment/Comment.class.php
wcfsetup/setup/db/install.sql

index dc6d9dc70ccb3e31c6f4494dbc5ef17a7dd7a599..45d5888da3e05bf620e98d09c0cf3462d87022f3 100644 (file)
                        <name>com.woltlab.wcf.user.signature</name>
                        <definitionname>com.woltlab.wcf.message</definitionname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.comment</name>
+                       <definitionname>com.woltlab.wcf.message</definitionname>
+               </type>
                
                <type>
                        <name>com.woltlab.wcf.bbcode.smiley</name>
diff --git a/com.woltlab.wcf/templates/commentListAddComment.tpl b/com.woltlab.wcf/templates/commentListAddComment.tpl
new file mode 100644 (file)
index 0000000..fb8d280
--- /dev/null
@@ -0,0 +1,17 @@
+<li class="box48 jsCommentAdd jsOnly">
+       {@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(48)}
+       <div class="commentListAddComment">
+               <textarea id="text" name="text" class="wysiwygTextarea"
+                         data-disable-attachments="true"
+                         data-support-mention="true"
+               ></textarea>
+               {include file='wysiwyg' userProfileCommentList=$commentListContainerID}
+               
+               <div class="formSubmit">
+                       <button class="buttonPrimary" data-type="save" accesskey="s">{lang}wcf.global.button.submit{/lang}</button>
+                       
+                       {include file='messageFormPreviewButton' previewMessageObjectType='com.woltlab.wcf.comment' previewMessageObjectID=0}
+               </div>
+       </div>
+</li>
+
index 7e3c3c574c75cdf3f9e5b84b349dd8d1702e0eef..3c89728b992935f64b308adb8698ce736514337e 100644 (file)
@@ -2,6 +2,7 @@
 
 {if $commentCanAdd}
        <ul id="userProfileCommentList" class="commentList containerList" data-can-add="true" data-object-id="{@$userID}" data-object-type-id="{@$commentObjectTypeID}" data-comments="{@$commentList->countObjects()}" data-last-comment-time="{@$lastCommentTime}">
+               {include file='commentListAddComment' commentListContainerID='userProfileCommentList'}
                {include file='commentList'}
        </ul>
 {else}
index 634bf95dbb632ef718961232d3807be5a12112b4..5ca29ca3f4d0412ebffb7d4f5368e52a3e45f1ee 100644 (file)
@@ -332,13 +332,8 @@ WCF.Comment.Handler = Class.extend({
         * Initializes the UI components to add a comment.
         */
        _initAddComment: function() {
-               // create UI
-               this._commentAdd = $('<li class="box48 jsCommentAdd">' + this._userAvatar + '<div /></li>').prependTo(this._container);
-               var $inputContainer = this._commentAdd.children('div');
-               var $input = $('<textarea placeholder="' + WCF.Language.get('wcf.comment.add') + '" maxlength="65535" class="long" />').appendTo($inputContainer).flexible();
-               $('<button class="small">' + WCF.Language.get('wcf.global.button.submit') + '</button>').click($.proxy(this._save, this)).appendTo($inputContainer);
-               
-               $input.keyup($.proxy(this._keyUp, this));
+               var button = elBySel('.jsCommentAdd .formSubmit button[data-type="save"]', this._commentAdd[0]);
+               if (button) button.addEventListener(WCF_CLICK_EVENT, this._save.bind(this));
        },
        
        /**
index 5223e47ae1a0b5a633374b85f25a7bdf91afcc95..ab8b9163c67068086107fcfd64e0a9a35e5e6404 100644 (file)
@@ -24,6 +24,7 @@ use wcf\util\StringUtil;
  * @property-read      string          $message                comment message
  * @property-read      integer         $responses              number of responses on the comment
  * @property-read      string          $responseIDs            serialized array with the ids of the five latest comment responses
+ * @property-read       integer         $enableHtml             is 1 if HTML will rendered in the comment, otherwise 0
  */
 class Comment extends DatabaseObject implements IMessage {
        use TUserContent;
index 4f1ad9df3ca58813b4e38dbb14901112ff21a345..958f3950e1be5d929b2fb481b1a217314f09ae72 100644 (file)
@@ -378,6 +378,7 @@ CREATE TABLE wcf1_comment (
        message TEXT NOT NULL,
        responses MEDIUMINT(7) NOT NULL DEFAULT '0',
        responseIDs VARCHAR(255) NOT NULL DEFAULT '',
+       enableHtml TINYINT(1) NOT NULL DEFAULT 0,
        
        KEY (objectTypeID, objectID, time),
        KEY lastCommentTime (userID, time)