Changeset 407

Show
Ignore:
Timestamp:
06/21/06 00:12:20 (2 years ago)
Author:
sven
Message:

polished activity page a bit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_activity/index.php

    r374 r407  
    3636$body .= "<h2>" . gettext("Activity on your weblog posts") . "</h2>"; 
    3737 
    38 if ($activities = get_records_sql('SELECT u.username,wc.*,wp.ident AS weblogpost,wp.title AS weblogtitle, wp.weblog AS weblog 
    39                                    FROM '.$CFG->prefix.'weblog_comments wc LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id 
    40                                    LEFT JOIN '.$CFG->prefix.'users u on u.ident = wp.weblog  
    41                                    WHERE wc.posted >= ? AND wp.owner = ?  
    42                                    ORDER BY wc.posted DESC',array($starttime,$page_owner))) { 
     38// TODO: the foreach loops are identical and could possibly do with being functionised - Sven 
     39 
     40if ($activities = get_records_sql('SELECT wc.*, u.username,u.name as weblogname, wp.ident AS weblogpost,wp.title AS weblogtitle, wp.weblog AS weblog 
     41                                    FROM '.$CFG->prefix.'weblog_comments wc 
     42                                    LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id 
     43                                    LEFT JOIN '.$CFG->prefix.'users u ON u.ident = wp.weblog  
     44                                    WHERE wc.posted >= ? AND wp.owner = ?  
     45                                    ORDER BY wc.posted DESC',array($starttime,$page_owner))) { 
     46     
    4347    foreach($activities as $activity) { 
    4448        $commentbody = stripslashes($activity->body); 
    4549        $commentbody .= "<br /><br /><a href=\"" . url . $activity->username . "/weblog/" . $activity->weblogpost . ".html\">" . gettext("Read more") . "</a>"; 
    46         $commentposter = sprintf(gettext("<b>%s</b> commented on weblog post '%s' in %s:"),stripslashes($activity->postedname), stripslashes($activity->weblogtitle), stripslashes($activity->weblogname)); 
     50        $activity->postedname = stripslashes($activity->postedname); 
     51        $activity->weblogname = stripslashes($activity->weblogname); 
     52        if ($activity->weblog == $USER->ident) { 
     53            $activity->weblogname = gettext("your blog"); 
     54        } 
     55        if ($activity->owner == $USER->ident) { 
     56            $commentposter = sprintf(gettext("<b>You</b> commented on weblog post '%s' in %s:"), stripslashes($activity->weblogtitle), $activity->weblogname); 
     57        } else { 
     58            $commentposter = sprintf(gettext("<b>%s</b> commented on weblog post '%s' in %s:"), $activity->postedname, stripslashes($activity->weblogtitle), $activity->weblogname); 
     59        } 
    4760        $body .= templates_draw(array( 
    48                                       'context' => 'databox1', 
    49                                       'name' => $commentposter, 
    50                                       'column1' => $commentbody 
     61                                        'context' => 'databox1', 
     62                                        'name' => $commentposter, 
     63                                        'column1' => $commentbody 
    5164                                      ) 
    5265                                ); 
     
    5871$body .= "<h2>" . gettext("Activity on weblog posts you have marked as interesting") . "</h2>"; 
    5972 
    60     if ($activities = get_records_sql('SELECT wc.*, u.username, u.name as weblogname, wp.weblog, wp.ident AS weblogpost, wp.title AS weblogtitle, wp.weblog AS weblog  
    61                                         FROM '.$CFG->prefix.'weblog_comments wc  
    62                                         left join '.$CFG->prefix.'weblog_watchlist wl on wl.weblog_post = wc.post_id  
    63                                         left join '.$CFG->prefix.'weblog_posts wp on wp.ident = wc.post_id  
    64                                         left join '.$CFG->prefix.'users u on u.ident = wp.weblog  
    65                                         where wc.posted > ? and wl.owner = ? order by wc.posted desc',array($starttime, $page_owner))) { 
     73if ($activities = get_records_sql('SELECT wc.*, u.username, u.name as weblogname, wp.weblog, wp.ident AS weblogpost, wp.title AS weblogtitle, wp.weblog AS weblog  
     74                                    FROM '.$CFG->prefix.'weblog_comments wc  
     75                                    LEFT JOIN '.$CFG->prefix.'weblog_watchlist wl ON wl.weblog_post = wc.post_id  
     76                                    LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id  
     77                                    LEFT JOIN '.$CFG->prefix.'users u ON u.ident = wp.weblog  
     78                                    WHERE wc.posted > ? AND wl.owner = ? 
     79                                    ORDER BY wc.posted DESC',array($starttime, $page_owner))) { 
    6680    foreach($activities as $activity) { 
    6781        $commentbody = stripslashes($activity->body); 
    6882        $commentbody .= "<br /><br /><a href=\"" . url . $activity->username . "/weblog/" . $activity->weblogpost . ".html\">" . gettext("Read more") . "</a>"; 
    69         $commentposter = sprintf(gettext("<b>%s</b> posted on weblog post '%s'"),stripslashes($activity->postedname), stripslashes($activity->weblogtitle)); 
    70         $body .= templates_draw( array( 
    71                                              'context' => 'databox1', 
    72                                              'name' => $commentposter, 
    73                                              'column1' => $commentbody 
    74                                              ) 
    75                      ); 
     83        $activity->postedname = stripslashes($activity->postedname); 
     84        $activity->weblogname = stripslashes($activity->weblogname); 
     85        if ($activity->weblog == $USER->ident) { 
     86            $activity->weblogname = gettext("your blog"); 
     87        } 
     88        if ($activity->owner == $USER->ident) { 
     89            $commentposter = sprintf(gettext("<b>You</b> commented on weblog post '%s' in %s:"), stripslashes($activity->weblogtitle), $activity->weblogname); 
     90        } else { 
     91            $commentposter = sprintf(gettext("<b>%s</b> commented on weblog post '%s' in %s:"), $activity->postedname, stripslashes($activity->weblogtitle), $activity->weblogname); 
     92        } 
     93        $body .= templates_draw(array( 
     94                                        'context' => 'databox1', 
     95                                        'name' => $commentposter, 
     96                                        'column1' => $commentbody 
     97                                      ) 
     98                                ); 
    7699    } 
    77100} else { 
     
    85108                             ) 
    86109                       ); 
    87                         
     110 
    88111echo templates_page_draw( array( 
    89                                       $title, $body 
    90                                      
     112                                  $title, $body 
     113                                 
    91114         ); 
    92           
     115 
    93116?>