'', 'order' => 'reverse', // latest first 'info' => 'month,numpages', // ignored 'month' => false, 'noheader' => 0 ); } // "2004-12" => "December 2004" function _monthTitle($month){ //list($year,$mon) = explode("-",$month); return strftime("%B %Y", strtotime($month."-01")); } // "User/Blog/2004-12-13/12:28:50+01:00" => array('month' => "2004-12", ...) function _blog($rev_or_page) { $pagename = $rev_or_page->getName(); if (preg_match("/^(.*\/Blog)\/(\d\d\d\d-\d\d)-(\d\d)\/(.*)/", $pagename, $m)) list(,$prefix,$month,$day,$time) = $m; return array('pagename' => $pagename, // page (list pages per month) or revision (list months)? //'title' => isa($rev_or_page,'WikiDB_PageRevision') ? $rev_or_page->get('summary') : '', //'monthtitle' => $this->_monthTitle($month), 'month' => $month, 'day' => $day, 'time' => $time, 'prefix' => $prefix); } function _nonDefaultArgs($args) { return array_diff_assoc($args, $this->getDefaultArguments()); } function run($dbi, $argstr, &$request, $basepage) { if (is_array($argstr)) // can do with array also. $args =& $argstr; else $args = $this->getArgs($argstr, $request); if (empty($args['user'])) { $user = $request->getUser(); if ($user->isAuthenticated()) { $args['user'] = $user->UserName(); } else { $args['user'] = ''; } } if (!$args['user'] or $args['user'] == ADMIN_USER) { if (BLOG_EMPTY_DEFAULT_PREFIX) $args['user'] = ''; // "Blogs/day" pages else $args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages } $parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR); //$info = explode(',', $args['info']); //$pagelist = new PageList($args['info'], $args['exclude'], $args); //if (!is_array('pagename'), explode(',', $info)) // unset($pagelist->_columns['pagename']); if (!empty($args['month'])) { $prefix = $parent . $this->_blogPrefix('wikiblog') . SUBPAGE_SEPARATOR . $args['month']; $pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix, true, 'posix')); $html = HTML::ul(); while ($page = $pages->next()) { $rev = $page->getCurrentRevision(false); if ($rev->get('pagetype') != 'wikiblog') continue; $blog = $this->_blog($rev); $html->pushContent(WikiLink($page, 'known', $rev->get('summary'))); } if (!$args['noheader']) return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))), $html); else return $html; } $blogs = $this->findBlogs ($dbi, $args['user'], 'wikiblog'); if ($blogs) { if (!$basepage) $basepage = _("BlogArchives"); $html = HTML::ul(); usort($blogs, array("WikiPlugin_WikiBlog", "cmp")); if ($args['order'] == 'reverse') $blogs = array_reverse($blogs); // collapse pagenames by month $months = array(); foreach ($blogs as $rev) { $blog = $this->_blog($rev); $mon = $blog['month']; if (empty($months[$mon])) $months[$mon] = array('title' => $this->_monthTitle($mon), 'num' => 1, 'month' => $mon, 'link' => WikiURL($basepage, $this->_nonDefaultArgs(array('month' => $mon)))); else $months[$mon]['num']++; } foreach ($months as $m) { $html->pushContent(HTML::a(array('href'=>$m['link'], 'class' => 'named-wiki'), $m['title'] . " (".$m['num'].")")); } if (!$args['noheader']) return HTML(HTML::h3(_("Blog Archives:")), $html); else return $html; } else return ''; } // box is used to display a fixed-width, narrow version with common header function box($args=false, $request=false, $basepage=false) { if (!$request) $request =& $GLOBALS['request']; if (!$args or empty($args['limit'])) $args['limit'] = 10; $args['noheader'] = 1; return $this->makeBox(_("Archives"), $this->run($request->_dbi, $args, $request, $basepage)); } }; // $Log: not supported by cvs2svn $ // Revision 1.1 2004/12/13 13:22:57 rurban // new BlogArchives plugin for the new blog theme. enable default box method // for all plugins. Minor search improvement. // // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>