Increased displayed comments from 10/3 to 30/5
authorAlexander Ebert <ebert@woltlab.com>
Sun, 1 Feb 2015 14:51:39 +0000 (15:51 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 1 Feb 2015 14:51:39 +0000 (15:51 +0100)
com.woltlab.wcf/package.xml
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/acp/rebuild_comments_com.woltlab.wcf_2.1.php [new file with mode: 0644]
wcfsetup/install/files/lib/data/comment/CommentAction.class.php
wcfsetup/install/files/lib/data/comment/CommentEditor.class.php
wcfsetup/install/files/lib/data/comment/StructuredCommentList.class.php
wcfsetup/install/files/lib/system/comment/manager/AbstractCommentManager.class.php

index f7ef2b9720e347aaff2b82718147740d7f04eac0..94b3e47602cd372fec257f15f4f3d7e2a76f2006 100644 (file)
@@ -86,6 +86,7 @@
                <instruction type="userProfileMenu">userProfileMenu.xml</instruction>
                
                <instruction type="script" run="standalone">acp/update_mqc_com.woltlab.wcf_2.1.php</instruction>
+               <instruction type="script" run="standalone">acp/rebuild_comments_com.woltlab.wcf_2.1.php</instruction>
        </instructions>
        
        <instructions type="update" fromversion="2.1.0 Beta 3">
@@ -97,5 +98,7 @@
                
                <instruction type="option">option.xml</instruction>
                <instruction type="userMenu">userMenu.xml</instruction>
+               
+               <instruction type="script" run="standalone">acp/rebuild_comments_com.woltlab.wcf_2.1.php</instruction>
        </instructions>
 </package>
index fc56a362a8923daea2172121d70462d10884207c..307a5ec498eede4f5b4d61ac361ef5d01d2592fc 100644 (file)
@@ -62,7 +62,6 @@ $(function() {
                var $config = {
                        autosave: false,
                        buttons: $buttons,
-                       buttonSource: true,
                        convertImageLinks: false,
                        convertUrlLinks: false,
                        convertVideoLinks: false,
@@ -73,6 +72,7 @@ $(function() {
                        plugins: [ 'wutil', 'wmonkeypatch', 'table', 'wbutton', 'wbbcode', 'wfontcolor', 'wfontfamily', 'wfontsize', 'wupload' ],
                        removeEmpty: false,
                        replaceDivs: false,
+                       source: true,
                        tabifier: false,
                        toolbarFixed: false,
                        woltlab: {
diff --git a/wcfsetup/install/files/acp/rebuild_comments_com.woltlab.wcf_2.1.php b/wcfsetup/install/files/acp/rebuild_comments_com.woltlab.wcf_2.1.php
new file mode 100644 (file)
index 0000000..cbd78c3
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+use wcf\system\WCF;
+use wcf\system\package\SplitNodeException;
+
+/**
+ * @author     Alexander Ebert
+ * @copyright  2001-2015 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+$rebuildData = WCF::getSession()->getVar('__wcfUpdateRebuildComments');
+if ($rebuildData === null) {
+       $sql = "SELECT  COUNT(*) AS count
+               FROM    wcf".WCF_N."_comment
+               WHERE   responses > ?";
+       $statement = WCF::getDB()->prepareStatement($sql);
+       $statement->execute(array(3));
+       $row = $statement->fetchSingleRow();
+       
+       $rebuildData = array(
+               'i' => 0,
+               'max' => 0
+       );
+       
+       if ($row['count']) {
+               $rebuildData['max'] = ceil($row['count'] / 50);
+       }
+}
+
+if ($rebuildData['max']) {
+       $offset = $rebuildData['i'] * 50;
+       
+       // get comments
+       $sql = "SELECT          commentID
+               FROM            wcf".WCF_N."_comment
+               WHERE           responses > ?
+               ORDER BY        commentID";
+       $statement = WCF::getDB()->prepareStatement($sql, 50, $offset);
+       $statement->execute(array(3));
+       
+       $commentData = array();
+       while ($row = $statement->fetchArray()) {
+               $commentData[$row['commentID']] = array();
+       }
+       
+       if (empty($commentData)) {
+               WCF::getSession()->unregister('__wcfUpdateRebuildComments');
+       }
+       else {
+               // get responses per comment
+               $sql = "SELECT          responseID
+                       FROM            wcf".WCF_N."_comment_response
+                       WHERE           commentID = ?
+                       ORDER BY        time";
+               $statement = WCF::getDB()->prepareStatement($sql, 5);
+               
+               foreach ($commentData as $commentID => &$responseIDs) {
+                       $statement->execute(array($commentID));
+                       while ($row = $statement->fetchArray()) {
+                               $responseIDs[] = $row['responseID'];
+                       }
+                       
+                       $responseIDs = serialize($responseIDs);
+               }
+               
+               // set responseIDs per comment
+               $sql = "UPDATE  wcf".WCF_N."_comment
+                       SET     responseIDs = ?
+                       WHERE   commentID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               WCF::getDB()->beginTransaction();
+               foreach ($commentData as $commentID => $responseIDs) {
+                       $statement->execute(array(
+                               $responseIDs,
+                               $commentID
+                       ));
+               }
+               WCF::getDB()->commitTransaction();
+               
+               $rebuildData['i']++;
+               WCF::getSession()->register('__wcfUpdateRebuildComments', $rebuildData);
+               
+               // call this script again
+               throw new SplitNodeException();
+       }
+}
+
index 93e496b4ff601b17dd41bae5597f6339ac3ac62b..58f6b011a750b092c80c7b9c21fc6b7066351622 100644 (file)
@@ -333,7 +333,7 @@ class CommentAction extends AbstractDatabaseObjectAction {
                
                // update response data
                $responseIDs = $this->comment->getResponseIDs();
-               if (count($responseIDs) < 3) {
+               if (count($responseIDs) < 5) {
                        $responseIDs[] = $this->createdResponse->responseID;
                }
                $responses = $this->comment->responses + 1;
index e95d67830d222d71220ea6bb4c729aa4d809c36e..c4c6a57493f100f8a23d0fcce365e8c53e9bc529 100644 (file)
@@ -7,7 +7,7 @@ use wcf\system\WCF;
  * Provides functions to edit comments.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage data.comment
@@ -27,7 +27,7 @@ class CommentEditor extends DatabaseObjectEditor {
                        FROM            wcf".WCF_N."_comment_response
                        WHERE           commentID = ?
                        ORDER BY        time ASC";
-               $statement = WCF::getDB()->prepareStatement($sql, 3);
+               $statement = WCF::getDB()->prepareStatement($sql, 5);
                $statement->execute(array($this->commentID));
                $responseIDs = array();
                while ($row = $statement->fetchArray()) {
index 1e3c07a477857ff66f7a855139ed98edbb657fec..f8d8b9d3b64eceb2f93922485ee926997e69baae 100644 (file)
@@ -50,7 +50,7 @@ class StructuredCommentList extends CommentList {
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlLimit
         */
-       public $sqlLimit = 10;
+       public $sqlLimit = 30;
        
        /**
         * @see \wcf\data\DatabaseObjectList::$sqlOrderBy
index 73c3cfd53173a51e1a41f5f66f65379048db0496..1291841070f9099c1009dac9d933b696c89872e5 100644 (file)
@@ -9,7 +9,7 @@ use wcf\system\WCF;
  * Default implementation for comment managers.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
+ * @copyright  2001-2015 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system.comment.manager
@@ -20,7 +20,7 @@ abstract class AbstractCommentManager extends SingletonFactory implements IComme
         * display comments per page
         * @var integer
         */
-       public $commentsPerPage = 10;
+       public $commentsPerPage = 30;
        
        /**
         * permission name for comment/response creation