summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-09 02:26:15 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-09 02:26:15 +0000
commit02d4ddb7bd85995d75b4bd63c685b42dfd950b66 (patch)
tree78b6e095c803aec1495c58e24a0b63ffa55310d9
parent0e3cb8a5e12fa86e24e59dd39f46f233ce820ffd (diff)
downloadbrdo-02d4ddb7bd85995d75b4bd63c685b42dfd950b66.tar.gz
brdo-02d4ddb7bd85995d75b4bd63c685b42dfd950b66.tar.bz2
- Patch #599640 by sun: move hard-coded comment query options to caller.
-rw-r--r--modules/comment/comment.module44
1 files changed, 13 insertions, 31 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index a5f3a2999..baf5b2e85 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -414,8 +414,8 @@ function comment_get_recent($number = 10) {
* "page=X" if the page number is greater than zero; empty string otherwise.
*/
function comment_new_page_count($num_comments, $new_replies, $node) {
- $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
- $mode = _comment_get_display_setting('mode', $node);
+ $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
+ $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
$pagenum = NULL;
$flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE;
if ($num_comments <= $comments_per_page) {
@@ -586,7 +586,9 @@ function comment_node_page_additions($node) {
// Unpublished comments are not included in $node->comment_count, so show
// comments unconditionally if the user is an administrator.
if ($node->comment_count || user_access('administer comments')) {
- if ($cids = comment_get_thread($node)) {
+ $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
+ $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
+ if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
$comments = comment_load_multiple($cids);
comment_prepare_thread($comments);
$build = comment_build_multiple($comments, $node);
@@ -615,10 +617,14 @@ function comment_node_page_additions($node) {
}
/**
- * Retrieve comment(s) for a thread.
+ * Retrieve comments for a thread.
*
* @param $node
* The node whose comment(s) needs rendering.
+ * @param $mode
+ * The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED.
+ * @param $comments_per_page
+ * The amount of comments to display per page.
*
* To display threaded comments in the correct order we keep a 'thread' field
* and order by that value. This field keeps this data in
@@ -674,10 +680,7 @@ function comment_node_page_additions($node) {
* spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need
* to consider the trailing "/" so we use a substring only.
*/
- function comment_get_thread($node) {
- $mode = _comment_get_display_setting('mode', $node);
- $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
-
+function comment_get_thread($node, $mode, $comments_per_page) {
$query = db_select('comment', 'c')->extend('PagerDefault');
$query->addField('c', 'cid');
$query
@@ -783,7 +786,7 @@ function comment_build($comment, $node, $build_mode = 'full') {
);
$prefix = '';
- $is_threaded = isset($comment->divs) && _comment_get_display_setting('mode', $node) == COMMENT_MODE_THREADED;
+ $is_threaded = isset($comment->divs) && variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED) == COMMENT_MODE_THREADED;
// Add 'new' anchor if needed.
if (!empty($comment->first_new)) {
@@ -2183,7 +2186,7 @@ function theme_comment_post_forbidden($variables) {
function template_preprocess_comment_wrapper(&$variables) {
// Provide contextual information.
$variables['node'] = $variables['content']['#node'];
- $variables['display_mode'] = _comment_get_display_setting('mode', $variables['node']);
+ $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED);
$variables['template_files'][] = 'comment-wrapper-' . $variables['node']->type;
}
@@ -2209,27 +2212,6 @@ function _comment_per_page() {
}
/**
- * Return a current comment display setting
- *
- * @param $setting
- * can be one of these: 'mode', 'sort', 'comments_per_page'
- * @param $node
- * The comment node in question.
- */
-function _comment_get_display_setting($setting, $node) {
- switch ($setting) {
- case 'mode':
- $value = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
- break;
-
- case 'comments_per_page':
- $value = variable_get('comment_default_per_page_' . $node->type, 50);
- }
-
- return $value;
-}
-
-/**
* Updates the comment statistics for a given node. This should be called any
* time a comment is added, deleted, or updated.
*