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 along
19 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * List all new pages per month per user.
31 class WikiPlugin_NewPagesPerUser
34 private function cmp_by_count($a, $b)
36 if ($a['count'] == $b['count']) return 0;
37 return $a['count'] < $b['count'] ? 1 : -1;
40 function getDescription()
42 return _("List all new pages per month per user.");
45 function getDefaultArguments()
47 return array('userid' => '',
57 function run($dbi, $argstr, &$request, $basepage)
60 $args = $this->getArgs($argstr, $request);
63 $since = strtotime($since);
65 $since = strtotime($month);
66 $since = mktime(0, 0, 0, date("m", $since), 1, date("Y", $since));
67 $until = mktime(23, 59, 59, date("m", $since) + 1, 0, date("Y", $since));
71 $iter = $dbi->getAllPages(false, '-mtime');
74 while ($page = $iter->next()) {
75 $pagename = $page->getName();
76 if (!$page->exists()) continue;
77 $rev = $page->getRevision(1, false);
78 $date = $rev->get('mtime');
79 //$author = $rev->get('author_id');
80 $author = $page->getOwner();
81 if (defined('DEBUG') && DEBUG && $debug) {
82 echo "<i>$pagename, ", strftime("%Y-%m-%d %h:%m:%s", $date), ", $author</i><br />\n";
84 if ($userid and (!preg_match("/" . $userid . "/", $author))) continue;
85 if ($since and $date < $since) continue;
86 if ($until and $date > $until) continue;
87 if (!$comments and preg_match("/\/Comment/", $pagename)) continue;
88 $monthnum = strftime("%Y%m", $date);
89 if (!isset($pages[$monthnum]))
90 $pages[$monthnum] = array('author' => array(),
91 'month' => strftime("%B, %Y", $date));
92 if (!isset($pages[$monthnum]['author'][$author]))
93 $pages[$monthnum]['author'][$author] = array('count' => 0,
95 $pages[$monthnum]['author'][$author]['count']++;
96 $pages[$monthnum]['author'][$author]['pages'][] = $pagename;
99 $html = HTML::table(HTML::col(array('span' => 2, 'align' => 'left')));
100 $nbsp = HTML::raw(' ');
102 foreach ($pages as $monthname => $parr) {
103 $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2),
104 HTML::strong($parr['month']))));
105 uasort($parr['author'], array($this, 'cmp_by_count'));
106 foreach ($parr['author'] as $user => $authorarr) {
107 $count = $authorarr['count'];
108 $id = preg_replace("/ /", "_", 'pages-' . $monthname . '-' . $user);
110 (HTML::tr(HTML::td($nbsp, $nbsp,
111 HTML::img(array('id' => "$id-img",
112 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"),
113 'onclick' => "showHideFolder('$id')",
114 'alt' => _("Click to hide/show"),
115 'title' => _("Click to hide/show"))),
122 foreach ($authorarr['pages'] as $p)
123 $pagelist->pushContent(WikiLink($p), ', ');
125 $pagelist = join(', ', $authorarr['pages']);
128 (HTML::tr(array('id' => $id . '-body',
129 'style' => 'display:none; background-color: #eee;'),
130 HTML::td(array('colspan' => 2,
131 'style' => 'font-size:smaller'),
144 // c-hanging-comment-ender-p: nil
145 // indent-tabs-mode: nil