]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/BlogJournal.php
Activated Id substitution for Subversion
[SourceForge/phpwiki.git] / lib / plugin / BlogJournal.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /*
4  * Copyright 2005 $ThePhpWikiProgrammingTeam
5  */
6
7 require_once('lib/plugin/WikiBlog.php');
8
9 /**
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.
15  *
16  * @author: Reini Urban
17  */
18 class WikiPlugin_BlogJournal
19 extends WikiPlugin_WikiBlog
20 {
21     function getName() {
22         return _("BlogJournal");
23     }
24
25     function getDescription() {
26         return _("Include latest blog entries for the current or ADMIN user");
27     }
28
29     function getVersion() {
30         return preg_replace("/[Revision: $]/", '',
31                             "\$Revision: 1.5 $");
32     }
33
34     function getDefaultArguments() {
35         return array('count'    => 7,
36                      'user'     => '',
37                      'order'    => 'reverse',        // latest first
38                      'month'    => false,
39                      'noheader' => 0
40                      );
41     }
42
43     function run($dbi, $argstr, &$request, $basepage) {
44         if (is_array($argstr)) { // can do with array also.
45             $args =& $argstr;
46             if (!isset($args['order'])) $args['order'] = 'reverse';
47         } else {
48             $args = $this->getArgs($argstr, $request);
49         }
50         $user = $request->getUser();
51         if (empty($args['user'])) {
52             if ($user->isAuthenticated()) {
53                 $args['user'] = $user->UserName();
54             } else {
55                 $args['user'] = '';
56             }
57         }
58         if (!$args['user'] or $args['user'] == ADMIN_USER) {
59             if (BLOG_DEFAULT_EMPTY_PREFIX) {
60                 $args['user'] = '';         // "Blogs/day" pages 
61             } else {
62                 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages 
63             }
64         }
65         $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
66
67         $sp = HTML::Raw('&middot; ');
68         $prefix = $base = $parent . $this->_blogPrefix('wikiblog');
69         if ($args['month'])
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;
76             $i++;
77             $blog = $this->_blog($rev);
78             //$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
79             $html->pushContent($rev->getTransformedContent('wikiblog'));
80         }
81         if ($args['user'] == $user->UserName() or $args['user'] == '')
82             $html->pushContent(Button(array('action'=>'WikiBlog',
83                                             'mode'=>'add'), 
84                                       _("New entry"), $base));
85         if (!$i)
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']))),
89                         $html);
90         else
91             return $html;
92     }
93 };
94
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
98 //
99 // Revision 1.3  2005/11/21 20:47:21  rurban
100 // fix count error
101 //
102 // Revision 1.2  2005/10/29 09:06:37  rurban
103 // move common blog methods to WikiBlog
104 //
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).
111 //
112
113 // Local Variables:
114 // mode: php
115 // tab-width: 8
116 // c-basic-offset: 4
117 // c-hanging-comment-ender-p: nil
118 // indent-tabs-mode: nil
119 // End:
120 ?>