8 * List all new pages per month per user.
15 class WikiPlugin_NewPagesPerUser
19 return _("NewPagesPerUser");
22 function getDescription () {
23 return _("List all new pages per month per user");
26 function getVersion() {
27 return preg_replace("/[Revision: $]/", '',
31 function getDefaultArguments() {
32 return array('userid' => '',
42 function run($dbi, $argstr, &$request, $basepage) {
44 $args = $this->getArgs($argstr, $request);
47 $since = strtotime($since);
49 $since = strtotime($month);
50 $since = mktime(0,0,0,date("m",$since),1,date("Y",$since));
51 $until = mktime(23,59,59,date("m",$since)+1,0,date("Y",$since));
55 $iter = $dbi->getAllPages(false,'-mtime');
58 while ($page = $iter->next()) {
59 $pagename = $page->getName();
60 if (!$page->exists()) continue;
61 $rev = $page->getRevision(1, false);
62 $date = $rev->get('mtime');
63 //$author = $rev->get('author_id');
64 $author = $page->getOwner();
65 if (defined('DEBUG') && DEBUG && $debug) {
66 echo "<i>$pagename, ",strftime("%Y-%m-%d %h:%m:%s", $date),", $author</i><br />\n";
68 if ($userid and (!preg_match("/".$userid."/", $author))) continue;
69 if ($since and $date < $since) continue;
70 if ($until and $date > $until) continue;
71 if (!$comments and preg_match("/\/Comment/", $pagename)) continue;
72 $monthnum = strftime("%Y%m", $date);
73 if (!isset($pages[$monthnum]))
74 $pages[$monthnum] = array('author' => array(),
75 'month' => strftime("%B, %Y", $date));
76 if (!isset($pages[$monthnum]['author'][$author]))
77 $pages[$monthnum]['author'][$author] = array('count' => 0,
79 $pages[$monthnum]['author'][$author]['count']++;
80 $pages[$monthnum]['author'][$author]['pages'][] = $pagename;
83 $html = HTML::table(HTML::col(array('span' => 2,'align'=> 'left')));
84 $nbsp = HTML::raw(' ');
86 foreach ($pages as $monthname => $parr) {
87 $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2),
88 HTML::strong($parr['month']))));
89 uasort($parr['author'], 'cmp_by_count');
90 foreach ($parr['author'] as $user => $authorarr) {
91 $count = $authorarr['count'];
92 $id = preg_replace("/ /","_",'pages-'.$monthname.'-'.$user);
94 (HTML::tr(HTML::td($nbsp,$nbsp,
95 HTML::img(array('id' => "$id-img",
96 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"),
97 'onclick'=> "showHideFolder('$id')",
98 'alt' => _("Click to hide/show"),
99 'title' => _("Click to hide/show"))),
106 foreach ($authorarr['pages'] as $p)
107 $pagelist->pushContent(WikiLink($p),', ');
109 $pagelist = join(', ',$authorarr['pages']);
112 (HTML::tr(array('id' => $id.'-body',
113 'style'=>'display:none; background-color: #eee;'),
114 HTML::td(array('colspan' => 2,
115 'style' => 'font-size:smaller'),
128 // c-hanging-comment-ender-p: nil
129 // indent-tabs-mode: nil