Changeset 1051

Show
Ignore:
Timestamp:
03/29/07 16:36:15 (2 years ago)
Author:
ben
Message:

New blog executive summary class.

Files:

Legend:

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

    r1044 r1051  
    8080            $CFG->templates->variables_substitute['blog'][] = "blog_keyword"; 
    8181            $CFG->templates->variables_substitute['blogsummary'][] = "blog_summary_keyword"; 
     82            $CFG->templates->variables_substitute['blogexecutivesummary'][] = "blog_executive_summary_keyword"; 
    8283             // Delete users 
    8384            listen_for_event("user","delete","blog_user_delete"); 
     
    237238            return $body; 
    238239        } 
    239          
     240 
     241        function blog_executive_summary_keyword($vars) { 
     242            global $CFG; 
     243            $body = ""; 
     244             
     245            if (!isset($vars[1])) { 
     246                $blog_posts = 2; 
     247            } else { 
     248                $blog_posts = $vars[1]; 
     249            } 
     250 
     251            $where = run("users:access_level_sql_where",$_SESSION['userid']); 
     252                         
     253            if (!isset($vars[2]) || $vars[2] == "all") { 
     254                $posts = get_records_sql("select * from ".$CFG->prefix."weblog_posts where ($where) order by posted desc limit $blog_posts"); 
     255            } else { 
     256                $blog_id = (int) user_info_username('ident',$vars[2]); 
     257                $posts = get_records_sql("select * from ".$CFG->prefix."weblog_posts where ($where) and weblog = $blog_id order by posted desc limit $blog_posts"); 
     258            } 
     259             
     260            if (is_array($posts) && !empty($posts)) { 
     261                foreach($posts as $post) { 
     262                    $body .= "<div class=\"frontpage-blog-executive-summary\">"; 
     263                    $body .= "<div class=\"frontpage-blog-executive-icon\"><img src=\"". user_icon_html($post->weblog,100,true) ."\" align=\"left\" class=\"usericon\" /></div>"; 
     264                    $body .= "<h4>" . $post->title . "</h4>"; 
     265                    $body .= "<p class=\"frontpage-blog-date\">" . strftime("%B %d, %Y",$post->posted) . "</p>"; 
     266                    $postbodyarray = explode(" ", preg_replace( "|\w{3,10}://[\w\.\-_]+(:\d+)?[^\s\"\'<>\(\)\{\}]*|", "", strip_tags($post->body)), 30); 
     267                    $body .= "<p class=\"frontpage-blog-content\">" . implode(" ", array_slice($postbodyarray,0,sizeof($postbodyarray) - 1)) . " ...</p>"; 
     268                    $body .= "<p class=\"frontpage-blog-from\">" . __gettext("From:") . " <a href=\"{$CFG->wwwroot}" . user_info("username",$post->weblog) . "\">" . user_info("name",$post->weblog) . "</a> - "; 
     269                    $body .= "<a href=\"{$CFG->wwwroot}" . user_info("username",$post->weblog) . "/weblog/" . $post->ident . ".html\">" . __gettext("Read more") . "</a></p>"; 
     270                    $body .= "</div>"; 
     271                } 
     272            } 
     273             
     274            return $body; 
     275        } 
     276 
     277                 
    240278    function blog_page_owner() { 
    241279