4 * Copyright (C) 2004 $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 * BlogArchives - List monthly links for the current users blog if signed,
27 * or the ADMIN_USER's Blog if not.
28 * On month=... list the blog titles per month.
31 * support PageList (paging, limit, info filters: title, num, month, year, ...)
32 * leave off time subpage? Blogs just per day with one summary title only?
33 * @author: Reini Urban
35 class WikiPlugin_BlogArchives
36 extends WikiPlugin_WikiBlog
43 function getDescription()
45 return _("List blog months links for the current or ADMIN user");
48 function getDefaultArguments()
52 //PageList::supportedArgs(),
54 'order' => 'reverse', // latest first
55 'info' => 'month,numpages', // ignored
61 function run($dbi, $argstr, &$request, $basepage)
63 if (is_array($argstr)) { // can do with array also.
65 if (!isset($args['order'])) $args['order'] = 'reverse';
67 $args = $this->getArgs($argstr, $request);
69 if (empty($args['user'])) {
70 $user = $request->getUser();
71 if ($user->isAuthenticated()) {
72 $args['user'] = $user->UserName();
77 if (!$args['user'] or $args['user'] == ADMIN_USER) {
78 if (BLOG_DEFAULT_EMPTY_PREFIX)
79 $args['user'] = ''; // "Blogs/day" pages
81 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
83 $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
85 //$info = explode(',', $args['info']);
86 //$pagelist = new PageList($args['info'], $args['exclude'], $args);
87 //if (!is_array('pagename'), explode(',', $info))
88 // unset($pagelist->_columns['pagename']);
90 $sp = HTML::Raw('· ');
91 if (!empty($args['month'])) {
92 $prefix = $parent . $this->_blogPrefix('wikiblog') . SUBPAGE_SEPARATOR . $args['month'];
93 $pages = $dbi->titleSearch(new TextSearchQuery("^" . $prefix, true, 'posix'));
95 while ($page = $pages->next()) {
96 $rev = $page->getCurrentRevision(false);
97 if ($rev->get('pagetype') != 'wikiblog') continue;
98 $blog = $this->_blog($rev);
99 $html->pushContent(HTML::li(WikiLink($page, 'known', $rev->get('summary'))));
101 if (!$args['noheader'])
102 return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
108 $blogs = $this->findBlogs($dbi, $args['user'], 'wikiblog');
110 if (!$basepage) $basepage = _("BlogArchives");
112 usort($blogs, array("WikiPlugin_WikiBlog", "cmp"));
113 if ($args['order'] == 'reverse')
114 $blogs = array_reverse($blogs);
115 // collapse pagenames by month
117 foreach ($blogs as $rev) {
118 $blog = $this->_blog($rev);
119 $mon = $blog['month'];
120 if (empty($months[$mon]))
122 array('title' => $this->_monthTitle($mon),
125 'link' => WikiURL($basepage,
126 $this->_nonDefaultArgs(array('month' => $mon))));
128 $months[$mon]['num']++;
130 foreach ($months as $m) {
131 $html->pushContent(HTML::li(HTML::a(array('href' => $m['link'],
132 'class' => 'named-wiki'),
133 $m['title'] . " (" . $m['num'] . ")")));
135 if (!$args['noheader'])
136 return HTML(HTML::h3(_("Blog Archives:")), $html);
143 // box is used to display a fixed-width, narrow version with common header
144 function box($args = false, $request = false, $basepage = false)
146 if (!$request) $request =& $GLOBALS['request'];
147 if (!$args or empty($args['limit'])) $args['limit'] = 10;
148 $args['noheader'] = 1;
149 return $this->makeBox(_("Archives"), $this->run($request->_dbi, $args, $request, $basepage));
157 // c-hanging-comment-ender-p: nil
158 // indent-tabs-mode: nil