Changeset 107
- Timestamp:
- 03/05/07 07:01:39 (5 years ago)
- File:
-
- 1 edited
-
comment/recentcomments.module (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
comment/recentcomments.module
r106 r107 1 1 <?php 2 3 4 /** 5 * Implementation of hook_menu(). 6 */ 7 function recentcomments_menu($may_cache) { 8 $items = array(); 9 10 if ($may_cache) { 11 $items[] = array('path' => 'recentcomments', 'title' => t('Recent Comments'), 12 'callback' => 'recentcomments_page', 13 'access' => user_access('access comments'), 14 'type' => MENU_SUGGESTED_ITEM); 15 16 } 17 return $items; 18 } 19 20 function recentcomments_page() { 21 $result = pager_query(db_rewrite_sql('SELECT c.nid, c.subject, c.cid, c.timestamp, c.comment, n.title FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE n.status = 1 AND c.status = 0 ORDER BY c.timestamp DESC', 'c'), variable_get('default_morecomments', 10)); 22 $output = ''; 23 while ($comment = db_fetch_object($result)) { 24 $output .= theme('recentcomments', $comment, ''); 25 } 26 $output .= theme('pager', NULL, variable_get('default_morecomments', 10)); 27 return $output; //theme('page', $output); 28 } 2 29 3 30 /** … … 13 40 else if ($op == 'view' && user_access('access comments')) { 14 41 $block['subject'] = t('Recent Comments'); 15 $block['content'] = theme('recentcomment _block');42 $block['content'] = theme('recentcomments_block'); 16 43 return $block; 17 44 } … … 46 73 // From among the comments on the nodes selected in the first query, 47 74 // find the $number most recent comments. 48 $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('. implode(',', $nids) .') AND n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC', COMMENT_PUBLISHED, 0, $number);75 $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp, n.title FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('. implode(',', $nids) .') AND n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC', COMMENT_PUBLISHED, 0, $number); 49 76 while ($comment = db_fetch_object($result)) { 50 77 $comments[] = $comment; … … 62 89 */ 63 90 function theme_recentcomments_block() { 91 //$items = array(); 92 $return = ""; 93 foreach (recentcomments_get_recent() as $comment) { 94 $return .= '<div style=\'padding-top:0.5em;border-bottom:1px solid #D7D7D7;\'>'.l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .' in '.l($comment->title,"node/$comment->nid")." ".t('<em style=\'display:block;\'>@time ago</em>', array('@time' => format_interval(time() - $comment->timestamp))).'</div>'; 95 } 96 return $return.'<div class="more-link">'. l(t('more'), 'recentcomments', array('title' => t('Read the latest comments.'))) .'</div>'; 97 } 98 /*function theme_recentcomments_block() { 64 99 $items = array(); 65 100 foreach (recentcomments_get_recent() as $comment) { … … 67 102 } 68 103 if ($items) { 69 return theme('item_list', $items) ;104 return theme('item_list', $items).'<div class="more-link">'. l(t('more'), 'recentcomments', array('title' => t('Read the latest comments.'))) .'</div>'; 70 105 } 106 }*/ 107 108 109 function theme_recentcomments($comment, $links = 0) { 110 $output = "<div class=\"comment\">\n"; 111 $output .= '<div class="node"><h2 class="title">'. l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ." in ".l($comment->title,"node/$comment->nid")."</h2></div>\n"; 112 $output .= '<div class="moderation">'. $comment->moderation ."</div>\n"; 113 $output .= '<div class="credit">'. t('by !a on %b', array('!a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n"; 114 $output .= "<div class=\"body\">$comment->comment</div>\n"; 115 $output .= "<div class=\"links\">$links</div>\n"; 116 $output .= "</div>\n"; 117 return $output; 71 118 } 72 119 120 73 121 ?>
Note: See TracChangeset
for help on using the changeset viewer.
