4 * Copyright (C) 2005 $ThePhpWikiProgrammingTeam
6 * This file is part of PhpWiki.
8 * PhpWiki is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * PhpWiki is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once('lib/plugin/WikiBlog.php');
26 * BlogJournal - Include the latest blog entries for the current users blog if signed,
27 * or the ADMIN_USER's Blog if not.
28 * UnfoldSubpages for blogs.
29 * Rui called this plugin "JournalLast", but this was written completely independent,
30 * without having seen the src.
32 * @author: Reini Urban
34 class WikiPlugin_BlogJournal
35 extends WikiPlugin_WikiBlog
38 return _("BlogJournal");
41 function getDescription() {
42 return _("Include latest blog entries for the current or ADMIN user");
45 function getDefaultArguments() {
46 return array('count' => 7,
48 'order' => 'reverse', // latest first
54 function run($dbi, $argstr, &$request, $basepage) {
55 if (is_array($argstr)) { // can do with array also.
57 if (!isset($args['order'])) $args['order'] = 'reverse';
59 $args = $this->getArgs($argstr, $request);
61 $user = $request->getUser();
62 if (empty($args['user'])) {
63 if ($user->isAuthenticated()) {
64 $args['user'] = $user->UserName();
69 if (!$args['user'] or $args['user'] == ADMIN_USER) {
70 if (BLOG_DEFAULT_EMPTY_PREFIX) {
71 $args['user'] = ''; // "Blogs/day" pages
73 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
76 $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
78 $sp = HTML::Raw('· ');
79 $prefix = $base = $parent . $this->_blogPrefix('wikiblog');
81 $prefix .= (SUBPAGE_SEPARATOR . $args['month']);
82 $pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix.SUBPAGE_SEPARATOR, true, 'posix'));
83 $html = HTML(); $i = 0;
84 while (($page = $pages->next()) and $i < $args['count']) {
85 $rev = $page->getCurrentRevision(false);
86 if ($rev->get('pagetype') != 'wikiblog') continue;
88 $blog = $this->_blog($rev);
89 //$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
90 $html->pushContent($rev->getTransformedContent('wikiblog'));
92 if ($args['user'] == $user->UserName() or $args['user'] == '')
93 $html->pushContent(Button(array('action'=>'WikiBlog',
95 _("New entry"), $base));
97 return HTML(HTML::h3(_("No Blog Entries")), $html);
98 if (!$args['noheader'])
99 return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
110 // c-hanging-comment-ender-p: nil
111 // indent-tabs-mode: nil