3 * Copyright 2016, Franck Villaume - TrivialDev
4 * http://fusionforge.org
6 * This file is a part of FusionForge.
8 * FusionForge 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 * FusionForge 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 FusionForge. If not, see <http://www.gnu.org/licenses/>.
22 require_once 'Widget.class.php';
25 * Widget_ProjectScmStats
28 class Widget_ProjectScmStats extends Widget {
30 var $content = array();
32 function __construct() {
33 parent::__construct('projectscmstats');
34 $request =& HTTPRequest::instance();
35 $pm = ProjectManager::instance();
36 $project = $pm->getProject($request->get('group_id'));
37 if ($project && $this->canBeUsedByProject($project) && forge_check_perm('scm', $project->getID(), 'read')) {
38 $this->content['title'] = _('Repository History');
43 return $this->content['title'];
46 function getContent() {
47 $html_projectscmstats = '';
48 $request = HTTPRequest::instance();
49 $pm = ProjectManager::instance();
50 $project = $pm->getProject($request->get('group_id'));
51 $project_plugins = $project->getPlugins();
52 foreach ($project_plugins as $value) {
53 $plugin_object = plugin_get_object($value);
54 if (is_object($plugin_object) && $plugin_object->provide('scm')) {
55 $html_projectscmstats .= $plugin_object->getStatsBlock($project);
58 return $html_projectscmstats;
61 function getDescription() {
62 return _('Display Repository Statistics history. Number of adds & updates per user since the init of the repository');
65 function canBeUsedByProject(&$project) {
66 return $project->usesSCM();
69 function getCategory() {
73 function isAvailable() {
74 return isset($this->content['title']);