4 * Copyright (C) 2007 AVL
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
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * List all new pages per month per user.
31 class WikiPlugin_NewPagesPerUser
35 return _("NewPagesPerUser");
38 function getDescription () {
39 return _("List all new pages per month per user");
42 function getDefaultArguments() {
43 return array('userid' => '',
53 function run($dbi, $argstr, &$request, $basepage) {
55 $args = $this->getArgs($argstr, $request);
58 $since = strtotime($since);
60 $since = strtotime($month);
61 $since = mktime(0,0,0,date("m",$since),1,date("Y",$since));
62 $until = mktime(23,59,59,date("m",$since)+1,0,date("Y",$since));
66 $iter = $dbi->getAllPages(false,'-mtime');
69 while ($page = $iter->next()) {
70 $pagename = $page->getName();
71 if (!$page->exists()) continue;
72 $rev = $page->getRevision(1, false);
73 $date = $rev->get('mtime');
74 //$author = $rev->get('author_id');
75 $author = $page->getOwner();
76 if (defined('DEBUG') && DEBUG && $debug) {
77 echo "<i>$pagename, ",strftime("%Y-%m-%d %h:%m:%s", $date),", $author</i><br />\n";
79 if ($userid and (!preg_match("/".$userid."/", $author))) continue;
80 if ($since and $date < $since) continue;
81 if ($until and $date > $until) continue;
82 if (!$comments and preg_match("/\/Comment/", $pagename)) continue;
83 $monthnum = strftime("%Y%m", $date);
84 if (!isset($pages[$monthnum]))
85 $pages[$monthnum] = array('author' => array(),
86 'month' => strftime("%B, %Y", $date));
87 if (!isset($pages[$monthnum]['author'][$author]))
88 $pages[$monthnum]['author'][$author] = array('count' => 0,
90 $pages[$monthnum]['author'][$author]['count']++;
91 $pages[$monthnum]['author'][$author]['pages'][] = $pagename;
94 $html = HTML::table(HTML::col(array('span' => 2,'align'=> 'left')));
95 $nbsp = HTML::raw(' ');
97 foreach ($pages as $monthname => $parr) {
98 $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2),
99 HTML::strong($parr['month']))));
100 uasort($parr['author'], 'cmp_by_count');
101 foreach ($parr['author'] as $user => $authorarr) {
102 $count = $authorarr['count'];
103 $id = preg_replace("/ /","_",'pages-'.$monthname.'-'.$user);
105 (HTML::tr(HTML::td($nbsp,$nbsp,
106 HTML::img(array('id' => "$id-img",
107 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"),
108 'onclick'=> "showHideFolder('$id')",
109 'alt' => _("Click to hide/show"),
110 'title' => _("Click to hide/show"))),
117 foreach ($authorarr['pages'] as $p)
118 $pagelist->pushContent(WikiLink($p),', ');
120 $pagelist = join(', ',$authorarr['pages']);
123 (HTML::tr(array('id' => $id.'-body',
124 'style'=>'display:none; background-color: #eee;'),
125 HTML::td(array('colspan' => 2,
126 'style' => 'font-size:smaller'),
139 // c-hanging-comment-ender-p: nil
140 // indent-tabs-mode: nil