2 rcs_id('$Id: BlogJournal.php,v 1.2 2005-10-29 09:06:37 rurban Exp $');
4 * Copyright 2005 $ThePhpWikiProgrammingTeam
7 require_once('lib/plugin/WikiBlog.php');
10 * BlogJournal - Include the latest blog entries for the current users blog if signed,
11 * or the ADMIN_USER's Blog if not.
12 * UnfoldSubpages for blogs.
13 * Rui called this plugin "JournalLast", but this was written completely independent,
14 * without having seen the src.
16 * @author: Reini Urban
18 class WikiPlugin_BlogJournal
19 extends WikiPlugin_WikiBlog
22 return _("BlogJournal");
25 function getDescription() {
26 return _("Include latest blog entries for the current or ADMIN user");
29 function getVersion() {
30 return preg_replace("/[Revision: $]/", '',
34 function getDefaultArguments() {
35 return array('count' => 7,
37 'order' => 'reverse', // latest first
43 function run($dbi, $argstr, &$request, $basepage) {
44 if (is_array($argstr)) { // can do with array also.
46 if (!isset($args['order'])) $args['order'] = 'reverse';
48 $args = $this->getArgs($argstr, $request);
50 $user = $request->getUser();
51 if (empty($args['user'])) {
52 if ($user->isAuthenticated()) {
53 $args['user'] = $user->UserName();
58 if (!$args['user'] or $args['user'] == ADMIN_USER) {
59 if (BLOG_EMPTY_DEFAULT_PREFIX)
60 $args['user'] = ''; // "Blogs/day" pages
62 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
64 $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
66 $sp = HTML::Raw('· ');
67 $prefix = $parent . $this->_blogPrefix('wikiblog');
69 $prefix .= (SUBPAGE_SEPARATOR . $args['month']);
70 $pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix, true, 'posix'));
71 $html = HTML(); $i = 0;
72 while (($page = $pages->next()) and $i < $count) {
73 $rev = $page->getCurrentRevision(false);
74 if ($rev->get('pagetype') != 'wikiblog') continue;
76 $blog = $this->_blog($rev);
77 $html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
78 $html->pushContent($rev->getTransformedContent('wikiblog'));
80 if ($args['user'] == $user->UserName())
81 $html->pushContent(WikiLink(_("WikiBlog"), 'known', "New entry"));
83 return HTML(HTML::h3(_("No Blog Entries")), $html);
84 if (!$args['noheader'])
85 return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
92 // $Log: not supported by cvs2svn $
93 // Revision 1.1 2005/10/29 09:03:17 rurban
94 // Include the latest blog entries for the current users blog if signed,
95 // or the ADMIN_USER's Blog if not.
96 // UnfoldSubpages for blogs.
97 // Rui called this plugin "JournalLast", but this was written completely
98 // independently, without having seen the src (yet).
105 // c-hanging-comment-ender-p: nil
106 // indent-tabs-mode: nil