|
Revision 278, 1.7 kB
(checked in by kevin, 9 months ago)
|
Commits this simple template keyword
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function blog_without_init() { |
|---|
| 4 |
global $CFG; |
|---|
| 5 |
$CFG->templates->variables_substitute['blog_without'][]= "blog_without_keyword"; |
|---|
| 6 |
} |
|---|
| 7 |
|
|---|
| 8 |
function blog_without_keyword($vars) { |
|---|
| 9 |
global $CFG; |
|---|
| 10 |
|
|---|
| 11 |
$body= ""; |
|---|
| 12 |
|
|---|
| 13 |
if (!isset ($vars[1])) { |
|---|
| 14 |
$blog_posts= 2; |
|---|
| 15 |
} else { |
|---|
| 16 |
$blog_posts= $vars[1]; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
if (!isset ($vars[2])) { |
|---|
| 20 |
$blog_user = 'news'; |
|---|
| 21 |
} else { |
|---|
| 22 |
$blog_user = $vars[2]; |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
$blog_id = user_info_username('ident', $blog_user); |
|---|
| 26 |
|
|---|
| 27 |
if ($blog_id) { |
|---|
| 28 |
$blog_id = (int) $blog_id; |
|---|
| 29 |
} else { |
|---|
| 30 |
$blog_id = 0; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
$where= run("users:access_level_sql_where", $_SESSION['userid']); |
|---|
| 34 |
|
|---|
| 35 |
$posts= get_records_sql("select * from " . $CFG->prefix . "weblog_posts where ($where) AND weblog != $blog_id order by posted desc limit $blog_posts"); |
|---|
| 36 |
|
|---|
| 37 |
if (is_array($posts) && !empty ($posts)) { |
|---|
| 38 |
foreach ($posts as $post) { |
|---|
| 39 |
if ($vars[3] != "slim") { |
|---|
| 40 |
$body .= run("weblogs:posts:view", $post); |
|---|
| 41 |
} else { |
|---|
| 42 |
$body .= "<div class=\"frontpage-blog-contents\">"; |
|---|
| 43 |
$body .= "<h4>" . $post->title . "</h4>"; |
|---|
| 44 |
$body .= "<p class=\"frontpage-blog-date\">" . strftime("%B %d, %Y", $post->posted) . "</p>"; |
|---|
| 45 |
$body .= "<p class=\"frontpage-blog-body\">" . run("weblogs:text:process", $post->body) . "</p>"; |
|---|
| 46 |
$body .= "<p class=\"frontpage-blog-from\">" . __gettext("From:") . " <a href=\"{$CFG->wwwroot}" . user_info("username", $post->weblog) . "\">" . user_info("name", $post->weblog) . "</a> - "; |
|---|
| 47 |
$body .= "<a href=\"{$CFG->wwwroot}" . user_info("username", $post->weblog) . "/weblog/" . $post->ident . ".html\">" . __gettext("Read more") . "</a></p>"; |
|---|
| 48 |
$body .= "</div>"; |
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
return $body; |
|---|
| 54 |
} |
|---|
| 55 |
?> |
|---|