| 12 |
/** |
/** |
| 13 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 14 |
*/ |
*/ |
| 15 |
function comment_page_menu($may_cache) { |
function comment_page_menu() { |
| 16 |
if ($may_cache) { |
$items['admin/content/comment_page'] = array( |
| 17 |
$items[] = array( |
'title' => 'Comment page', |
| 18 |
'path' => 'admin/content/comment_page', |
'description' => 'Adjust the settings for the comment page module.', |
| 19 |
'title' => t('Comment page'), |
'page callback' => 'drupal_get_form', |
| 20 |
'description' => t('Adjust the settings for the comment page module.'), |
'page arguments' => array('comment_page_settings'), |
| 21 |
'callback' => 'drupal_get_form', |
'access arguments' => array('admin comments'), |
| 22 |
'callback arguments' => array('comment_page_settings'), |
'type' => MENU_NORMAL_ITEM, |
| 23 |
'access' => user_access('administer comments'), |
); |
| 24 |
'type' => MENU_NORMAL_ITEM, |
|
| 25 |
); |
$items['comment/%comment_page'] = array( |
| 26 |
} |
'title' => 'Viewing a comment', |
| 27 |
else { |
'description' => 'View this comment.', |
| 28 |
if (arg(0) == 'comment' && intval(arg(1)) > 0) { |
'page callback' => 'comment_page_display', |
| 29 |
drupal_add_css(drupal_get_path('module', 'comment_page') .'/comment_page.css'); |
'page arguments' => array(1), |
| 30 |
|
'access arguments' => array('access comments'), |
| 31 |
|
'type' => MENU_CALLBACK, |
| 32 |
|
); |
| 33 |
|
|
| 34 |
$items[] = array( |
return $items; |
| 35 |
'path' => 'comment/'. arg(1), |
} |
| 36 |
'title' => t('Viewing a comment'), |
|
| 37 |
'description' => t('View this comment.'), |
/** |
| 38 |
'callback' => 'comment_page_display', |
* Implementation of hook_load() |
| 39 |
'callback arguments' => array(arg(1)), |
* |
| 40 |
'access' => user_access('access comments'), |
* This will be called based on the menu definition above to pass back a |
| 41 |
'type' => MENU_CALLBACK, |
* comment based on the %comment_page placeholder |
| 42 |
); |
*/ |
| 43 |
} |
function comment_page_load($cid) { |
| 44 |
|
if (!is_numeric($cid) || $cid < 1) { |
| 45 |
|
return FALSE; |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
return $items; |
return _comment_load($cid); |
| 49 |
} |
} |
| 50 |
|
|
| 51 |
/** |
/** |
| 52 |
* Implementation of hook_comment(). |
* Implementation of hook_comment(). |
| 53 |
*/ |
*/ |
| 54 |
function comment_page_comment($arg1, $op) { |
function comment_page_comment($arg1, $op) { |
| 55 |
switch($op) { |
switch ($op) { |
| 56 |
case 'insert': |
case 'insert': |
| 57 |
if (variable_get('default_comment_subject_on', TRUE)) { |
if (variable_get('default_comment_subject_on', TRUE)) { |
| 58 |
$comment = (object) $arg1; |
$comment = (object) $arg1; |
| 241 |
|
|
| 242 |
$result = db_query("SELECT cid, pid, uid, subject, thread, name, timestamp FROM " |
$result = db_query("SELECT cid, pid, uid, subject, thread, name, timestamp FROM " |
| 243 |
."{comments} WHERE nid = %d ORDER BY thread DESC", $comment->nid); |
."{comments} WHERE nid = %d ORDER BY thread DESC", $comment->nid); |
| 244 |
$node->replies = db_num_rows($result); |
$node->replies = db_result(db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d", $comment->nid)); |
| 245 |
|
|
| 246 |
$output = '<div class="comment-thread">'; |
$output = '<div class="comment-thread">'; |
| 247 |
|
|
| 255 |
} |
} |
| 256 |
} |
} |
| 257 |
$output .= '<span class="thread-title">'. l($node->title, $dst) .'</span> '; |
$output .= '<span class="thread-title">'. l($node->title, $dst) .'</span> '; |
| 258 |
|
|
| 259 |
// Add the name of the node author if enabled. |
// Add the name of the node author if enabled. |
| 260 |
if (variable_get('comment_page_thread_show_names', TRUE)) { |
if (variable_get('comment_page_thread_show_names', TRUE)) { |
| 261 |
if ($node->uid) { |
if ($node->uid) { |
| 267 |
$output .= '<span class="thread-author">' |
$output .= '<span class="thread-author">' |
| 268 |
. t('By: !name', array('!name' => $name)) .'</span> '; |
. t('By: !name', array('!name' => $name)) .'</span> '; |
| 269 |
} |
} |
| 270 |
|
|
| 271 |
// Add the reply count if enabled. |
// Add the reply count if enabled. |
| 272 |
if (variable_get('comment_page_thread_show_count', TRUE)) { |
if (variable_get('comment_page_thread_show_count', TRUE)) { |
| 273 |
$output .= '<span class="thread-count">' |
$output .= '<span class="thread-count">' |
| 274 |
. t('(%count <em>replies</em>)', array('%count' => $node->replies)) |
. t('(%count <em>replies</em>)', array('%count' => $node->replies)) |
| 275 |
.'</span> '; |
.'</span> '; |
| 276 |
} |
} |
| 277 |
|
|
| 278 |
// Add the date beneath the thread title. |
// Add the date beneath the thread title. |
| 279 |
if (variable_get('comment_page_thread_show_date', TRUE)) { |
if (variable_get('comment_page_thread_show_date', TRUE)) { |
| 280 |
$output .= '<span class="thread-date">'. format_date($node->created) |
$output .= '<span class="thread-date">'. format_date($node->created) |
| 310 |
} |
} |
| 311 |
|
|
| 312 |
$output .= '<li>'; |
$output .= '<li>'; |
| 313 |
|
|
| 314 |
// Add the comment's subject. |
// Add the comment's subject. |
| 315 |
$output .= '<span class="comment-title '. $class .'">'. $subject .'</span> '; |
$output .= '<span class="comment-title '. $class .'">'. $subject .'</span> '; |
| 316 |
|
|