Changeset 107


Ignore:
Timestamp:
03/05/07 07:01:39 (5 years ago)
Author:
nigel
Message:
  • Created a neater block
  • Put post name title
File:
1 edited

Legend:

Unmodified
Added
Removed
  • comment/recentcomments.module

    r106 r107  
    11<?php 
     2 
     3 
     4/** 
     5 * Implementation of hook_menu(). 
     6 */ 
     7function 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 
     20function 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} 
    229 
    330/** 
     
    1340  else if ($op == 'view' && user_access('access comments')) { 
    1441    $block['subject'] = t('Recent Comments'); 
    15     $block['content'] = theme('recentcomment_block'); 
     42    $block['content'] = theme('recentcomments_block'); 
    1643    return $block; 
    1744  } 
     
    4673    // From among the comments on the nodes selected in the first query, 
    4774    // 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); 
    4976    while ($comment = db_fetch_object($result)) { 
    5077      $comments[] = $comment; 
     
    6289 */ 
    6390function 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() { 
    6499  $items = array(); 
    65100  foreach (recentcomments_get_recent() as $comment) { 
     
    67102  } 
    68103  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>'; 
    70105  } 
     106}*/ 
     107 
     108 
     109function 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; 
    71118} 
    72119 
     120 
    73121?> 
Note: See TracChangeset for help on using the changeset viewer.