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_DEFAULT_EMPTY_PREFIX) {
60 $args['user'] = ''; // "Blogs/day" pages
62 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
65 $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
67 $sp = HTML::Raw('· ');
68 $prefix = $base = $parent . $this->_blogPrefix('wikiblog');
70 $prefix .= (SUBPAGE_SEPARATOR . $args['month']);
71 $pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix.SUBPAGE_SEPARATOR, true, 'posix'));
72 $html = HTML(); $i = 0;
73 while (($page = $pages->next()) and $i < $args['count']) {
74 $rev = $page->getCurrentRevision(false);
75 if ($rev->get('pagetype') != 'wikiblog') continue;
77 $blog = $this->_blog($rev);
78 //$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
79 $html->pushContent($rev->getTransformedContent('wikiblog'));
81 if ($args['user'] == $user->UserName() or $args['user'] == '')
82 $html->pushContent(Button(array('action'=>'WikiBlog',
84 _("New entry"), $base));
86 return HTML(HTML::h3(_("No Blog Entries")), $html);
87 if (!$args['noheader'])
88 return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
95 // $Log: not supported by cvs2svn $
96 // Revision 1.4 2005/11/21 20:56:23 rurban
97 // no duplicate headline and no direct page link anymore
99 // Revision 1.3 2005/11/21 20:47:21 rurban
102 // Revision 1.2 2005/10/29 09:06:37 rurban
103 // move common blog methods to WikiBlog
105 // Revision 1.1 2005/10/29 09:03:17 rurban
106 // Include the latest blog entries for the current users blog if signed,
107 // or the ADMIN_USER's Blog if not.
108 // UnfoldSubpages for blogs.
109 // Rui called this plugin "JournalLast", but this was written completely
110 // independently, without having seen the src (yet).
117 // c-hanging-comment-ender-p: nil
118 // indent-tabs-mode: nil