Changeset 1434

Show
Ignore:
Timestamp:
12/09/07 00:50:18 (9 months ago)
Author:
timh
Message:

-fix for ticket #112
-adds a widget_css inline override that can improive how weblog widgets show content

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/blog/lib.php

    r1395 r1434  
    316316  $blog_posts= widget_get_data("blog_posts", $widget->ident); 
    317317 
     318  $style .= "<style type=\"text/css\">"; 
     319  $style .= str_replace('{{url}}', $CFG->wwwroot, file_get_contents($CFG->dirroot . "mod/blog/widget_css")); 
     320  $style .= "</style>"; 
     321   
    318322  $body= ""; 
    319  
     323  $body .=$style; 
     324   
     325   
     326   
    320327  if (empty ($blog_id)) { 
    321328    global $page_owner; 
     
    326333  } 
    327334 
     335  $body .='<div class="weblog-post">'; 
    328336  $where= run("users:access_level_sql_where", $_SESSION['userid']); 
    329337  $posts= get_records_sql("select * from " . $CFG->prefix . "weblog_posts where ($where) and weblog = $blog_id order by posted desc limit $blog_posts"); 
     
    331339  if (is_array($posts) && !empty ($posts)) { 
    332340    foreach ($posts as $post) { 
    333       $body .= run("weblogs:posts:view", $post); 
     341      //$body .= run("weblogs:posts:view", $post); 
     342           
     343                $postedby = __gettext("Posted by"); 
     344                $commentsStr = __gettext("Comments"); 
     345                $date = gmdate("H:i",$post->posted); 
     346                $username = user_info('username', $post->owner); 
     347                $anyComments = __gettext("comment(s)"); 
     348           
     349                $body .= '<h3><a href="' . $CFG->wwwroot . user_name($post->weblog) . '/weblog/' . $post->ident . '.html">' . $post->title . '</a></h3>'; 
     350                $body .= $postedby . ' ' . $username . ' (' . $date . ')<br><br>'; 
     351                $body .= $post->body . '<br>'; 
     352                 
     353                if (!isset($_SESSION['comment_cache'][$post->ident]) || (time() - $_SESSION['comment_cache'][$post->ident]->created > 120)) { 
     354                        $numcomments = count_records('weblog_comments','post_id',$post->ident); 
     355                        $_SESSION['comment_cache'][$post->ident]->created = time(); 
     356                        $_SESSION['comment_cache'][$post->ident]->data = $numcomments; 
     357                } 
     358                $numcomments = $_SESSION['comment_cache'][$post->ident]->data; 
     359                $comments = "<a href=\"".url.$username."/{$post->ident}.html\">$numcomments $anyComments</a>"; 
     360         
     361                $body .= $comments . '</div>'; 
    334362    } 
    335363  }