4 * Copyright 2004 $ThePhpWikiProgrammingTeam
7 //require_once('lib/PageList.php');
8 require_once('lib/plugin/WikiBlog.php');
11 * BlogArchives - List monthly links for the current users blog if signed,
12 * or the ADMIN_USER's Blog if not.
13 * On month=... list the blog titles per month.
16 * support PageList (paging, limit, info filters: title, num, month, year, ...)
17 * leave off time subpage? Blogs just per day with one summary title only?
18 * @author: Reini Urban
20 class WikiPlugin_BlogArchives
21 extends WikiPlugin_WikiBlog
27 function getDescription() {
28 return _("List blog months links for the current or ADMIN user");
31 function getVersion() {
32 return preg_replace("/[Revision: $]/", '',
36 function getDefaultArguments() {
39 //PageList::supportedArgs(),
41 'order' => 'reverse', // latest first
42 'info' => 'month,numpages', // ignored
48 function run($dbi, $argstr, &$request, $basepage) {
49 if (is_array($argstr)) { // can do with array also.
51 if (!isset($args['order'])) $args['order'] = 'reverse';
53 $args = $this->getArgs($argstr, $request);
55 if (empty($args['user'])) {
56 $user = $request->getUser();
57 if ($user->isAuthenticated()) {
58 $args['user'] = $user->UserName();
63 if (!$args['user'] or $args['user'] == ADMIN_USER) {
64 if (BLOG_DEFAULT_EMPTY_PREFIX)
65 $args['user'] = ''; // "Blogs/day" pages
67 $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
69 $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
71 //$info = explode(',', $args['info']);
72 //$pagelist = new PageList($args['info'], $args['exclude'], $args);
73 //if (!is_array('pagename'), explode(',', $info))
74 // unset($pagelist->_columns['pagename']);
76 $sp = HTML::Raw('· ');
77 if (!empty($args['month'])) {
78 $prefix = $parent . $this->_blogPrefix('wikiblog') . SUBPAGE_SEPARATOR . $args['month'];
79 $pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix, true, 'posix'));
81 while ($page = $pages->next()) {
82 $rev = $page->getCurrentRevision(false);
83 if ($rev->get('pagetype') != 'wikiblog') continue;
84 $blog = $this->_blog($rev);
85 $html->pushContent(HTML::li(WikiLink($page, 'known', $rev->get('summary'))));
87 if (!$args['noheader'])
88 return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
94 $blogs = $this->findBlogs ($dbi, $args['user'], 'wikiblog');
96 if (!$basepage) $basepage = _("BlogArchives");
98 usort($blogs, array("WikiPlugin_WikiBlog", "cmp"));
99 if ($args['order'] == 'reverse')
100 $blogs = array_reverse($blogs);
101 // collapse pagenames by month
103 foreach ($blogs as $rev) {
104 $blog = $this->_blog($rev);
105 $mon = $blog['month'];
106 if (empty($months[$mon]))
108 array('title' => $this->_monthTitle($mon),
111 'link' => WikiURL($basepage,
112 $this->_nonDefaultArgs(array('month' => $mon))));
114 $months[$mon]['num']++;
116 foreach ($months as $m) {
117 $html->pushContent(HTML::li(HTML::a(array('href'=>$m['link'],
118 'class' => 'named-wiki'),
119 $m['title'] . " (".$m['num'].")")));
121 if (!$args['noheader'])
122 return HTML(HTML::h3(_("Blog Archives:")), $html);
129 // box is used to display a fixed-width, narrow version with common header
130 function box($args=false, $request=false, $basepage=false) {
131 if (!$request) $request =& $GLOBALS['request'];
132 if (!$args or empty($args['limit'])) $args['limit'] = 10;
133 $args['noheader'] = 1;
134 return $this->makeBox(_("Archives"), $this->run($request->_dbi, $args, $request, $basepage));
138 // $Log: not supported by cvs2svn $
139 // Revision 1.5 2005/10/29 09:06:37 rurban
140 // move common blog methods to WikiBlog
142 // Revision 1.4 2004/12/16 18:29:00 rurban
143 // allow empty Blog prefix
145 // Revision 1.3 2004/12/15 17:45:08 rurban
148 // Revision 1.2 2004/12/14 21:35:15 rurban
149 // support new BLOG_EMPTY_DEFAULT_PREFIX
151 // Revision 1.1 2004/12/13 13:22:57 rurban
152 // new BlogArchives plugin for the new blog theme. enable default box method
153 // for all plugins. Minor search improvement.
160 // c-hanging-comment-ender-p: nil
161 // indent-tabs-mode: nil