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 ($debug) echo "<i>$pagename, ",strftime("%Y-%m-%d %h:%m:%s", $date),", $author</i><br>\n";
66 if ($userid and (!preg_match("/".$userid."/", $author))) continue;
67 if ($since and $date < $since) continue;
68 if ($until and $date > $until) continue;
69 if (!$comments and preg_match("/\/Comment/", $pagename)) continue;
70 $monthnum = strftime("%Y%m", $date);
71 if (!isset($pages[$monthnum]))
72 $pages[$monthnum] = array('author' => array(),
73 'month' => strftime("%B, %Y", $date));
74 if (!isset($pages[$monthnum]['author'][$author]))
75 $pages[$monthnum]['author'][$author] = array('count' => 0,
77 $pages[$monthnum]['author'][$author]['count']++;
78 $pages[$monthnum]['author'][$author]['pages'][] = $pagename;
81 $html = HTML::table(HTML::col(array('span' => 2,'align'=> 'left')));
82 $nbsp = HTML::raw(' ');
84 foreach ($pages as $monthname => $parr) {
85 $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2),
86 HTML::strong($parr['month']))));
87 uasort($parr['author'], 'cmp_by_count');
88 foreach ($parr['author'] as $user => $authorarr) {
89 $count = $authorarr['count'];
90 $id = preg_replace("/ /","_",'pages-'.$monthname.'-'.$user);
92 (HTML::tr(HTML::td($nbsp,$nbsp,
93 HTML::img(array('id' => "$id-img",
94 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"),
95 'onClick'=> "showHideFolder('$id')")),$nbsp,
101 foreach ($authorarr['pages'] as $p)
102 $pagelist->pushContent(WikiLink($p),', ');
104 $pagelist = join(', ',$authorarr['pages']);
107 (HTML::tr(array('id' => $id.'-body',
108 'style'=>'display:none; background-color: #eee;'),
109 HTML::td(array('colspan' => 2,
110 'style' => 'font-size:smaller'),
123 // c-hanging-comment-ender-p: nil
124 // indent-tabs-mode: nil