blob: f476d92001402dc5fcca2d3db138bc73d259bded [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2011, 2016 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wayne Beaton (Eclipse Foundation) - initial API and implementation
*******************************************************************************/
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php");
$App = new App();
$Nav = new Nav();
$Menu = new Menu();
include($App->getProjectCommon());
//include( '_commonLeftNav.php' );
$pageTitle = "Eclipse Project Status";
$pageAuthor = "Wayne Beaton";
$pageKeywords = "eclipse,scm,vcs,dvcs,git,cvs,svn";
require_once $_SERVER['DOCUMENT_ROOT'] . '/projects/classes/Project.class.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/projects/classes/images.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/projects/classes/common.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/projects/classes/debug.php';
//mustBeCommitter();
function isValidKey($key) {
return in_array($key, getValidSortKeys());
}
function getValidSortKeys() {
return array('top', 'id', 'phase', 'liveliness', 'committers', 'organizations',
'initialCommit', 'latestCommit', 'totalCommits');
}
function getSortKeys() {
global $_sortKeys;
if (!$_sortKeys) {
$keys = preg_split('/,/',isset($_GET['sort']) ? $_GET['sort'] : 'top,id');
$_sortKeys = array();
foreach($keys as $key) {
if (isValidKey($key) && !in_array($key, $_sortKeys))
$_sortKeys[] = $key;
}
}
return $_sortKeys;
}
function filter($info) {
foreach($_GET as $key=>$value) {
if (isset($info[$key])) {
if ($info[$key] != $value) return true;
}
}
return false;
}
function getProjectStatus() {
global $App;
$projects = array();
foreach(getActiveProjects() as $project) {
switch ($id = $project->getId()) {
case 'locationtech' :
case 'polarsys' :
break;
default:
$info = array(
'id' => $id,
'name' => $project->getName(),
'top' => $project->getTopLevelProject()->getId(),
'topName' => preg_replace('/ Root$/','', $project->getTopLevelProject()->getName()),
'phase' => $project->isInIncubationPhase() ? 'incubating' : 'regular',
'url' => $project->getUrl(),
'liveliness' => $project->getLiveliness(),
'committers' => $project->getActiveCommittersCount(),
'organizations' => $project->getActiveOrganizationsCount()
);
if (!filter($info)) $projects[$id] = $info;
}
}
$sql = "
select
project as id, date(initialCommit) as initialCommit,
date(latestCommit) as latestCommit,
format(totalCommits,0) as totalCommits
from ProjectStats";
$result = $App->dashboard_sql($sql);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
if (!isset($projects[$id])) continue;
$projects[$id]['initialCommit'] = $row['initialCommit'];
$projects[$id]['latestCommit'] = $row['latestCommit'];
$projects[$id]['totalCommits'] = $row['totalCommits'];
}
return $projects;
}
function getSortParameter($main) {
$parameters = array($main);
foreach(getSortKeys() as $key)
if (!in_array($key, $parameters))
$parameters[] = $key;
return implode(',', $parameters);
}
function getHttpParameters($sort=null, $top=null) {
$parameters = array();
foreach($_GET as $key=>$value) $parameters[$key] = $value;
if ($sort) $parameters['sort'] = getSortParameter($sort);
if ($top) $parameters['top'] = $top;
$out = ''; $separator = '';
foreach($parameters as $key => $value) {
$out = "$out$separator$key=$value";
$separator = '&';
}
return $out;
}
function getProjectUrl($id) {
}
$css = "<style>
table.status {padding:5px;}
table.status th div {
width:2em; line-height: 90%;
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-90deg);
}
table.status tr.odd {
background-color:#E2E2E2;
}
</style>";
$App->AddExtraHtmlHeader($css);
function dumpStatus($projects) {
global $images;
echo "<table class=\"status\" width=\"100%\">";
echo "<tr style=\"height: 5em;vertical-align:bottom\">";
echo "<th><div><a href=\"?" . getHttpParameters('top') . "\">Top&nbsp;Level</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('id') . "\">Name</a></div></th>";
echo "<th><div>Contribution Questionnaires</div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('phase') . "\">Phase</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('liveliness') . "\">Commit Activity</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('committers') . "\">Active Committers</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('organizations') . "\">Active Organizations</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('initialCommit') . "\">Initial Commit</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('latestCommit') . "\">Latest Commit</a></div></th>";
echo "<th><div><a href=\"?" . getHttpParameters('totalCommits') . "\">Total Commits</a></div></th>";
echo "</tr>";
usort($projects, 'sort_projects');
$odd = true;
foreach($projects as $project) {
$top = $project['top'];
$topName = $project['topName'];
$name = $project['name'];
$id = $project['id'];
$url = $project['url'];
$phase = $project['phase'] == 'incubating' ? "<img src=\"$images->incubation_conforming_small\"/>" : '&nbsp;';
$liveliness = getLivelinessIcon($project['liveliness']);
$committers = $project['committers'];
$organizations = $project['organizations'];
$initial = valueOrDashes($project['initialCommit']);
$latest = valueOrDashes($project['latestCommit']);
$totalCommits = valueOrDashes($project['totalCommits']);
$class = $odd ? 'odd' : 'even';
$odd = !$odd;
echo "<tr class=\"$class\">";
echo "<td>$topName</td>";
echo "<td><a href=\"$url\">$name</a></td>";
echo "<td><a target=\"ipzilla\" href=\"https://dev.eclipse.org/ipzilla/buglist.cgi?component=$id\"><img src=\"/projects/images/external.gif\"/></a></td>";
echo "<td>$phase</td>";
echo "<td><img src=\"$liveliness\"/></td>";
echo "<td>$committers</td>";
echo "<td>$organizations</td>";
echo "<td>$initial</td>";
echo "<td>$latest</td>";
echo "<td align=\"right\">$totalCommits</td>";
echo "</tr>";
}
echo "</table>";
}
function valueOrDashes($value) {
if (!$value) return '--';
return preg_replace('/\-/','&#8209;',$value);
}
function sort_projects($projectA, $projectB) {
foreach(getSortKeys() as $key) {
$a = $projectA[$key];
$b = $projectB[$key];
// Make sure that empty values end up on the bottom.
if (!$a && !$b) return 0;
if (!$a) return 1;
if (!$b) return -1;
if ($key == 'organizations' || $key == 'committers') {
if ($a == $b) continue;
return $a < $b ? 1 : -1;
}
$cmp = strcasecmp($a, $b);
if ($cmp !== 0) return $cmp;
}
return 0;
}
function getGitStatus($git) {
switch($git) {
case PROJECT_REPO_ALL_GIT: return 'All Git';
case PROJECT_REPO_SOME_GIT: return 'Some Git';
case PROJECT_REPO_NO_GIT: return 'No Git';
default: return 'No repositories';
}
}
function getLivelinessIcon($liveliness) {
global $images;
switch($liveliness) {
case PROJECT_LIVELINESS_NEVER_ACTIVE: return $images->tools_small;
case PROJECT_LIVELINESS_ACTIVE: return $images->active_small;
case PROJECT_LIVELINESS_STALE: return $images->stale_small;
case PROJECT_LIVELINESS_INACTIVE: return $images->inactive_small;
case PROJECT_LIVELINESS_DEAD: return $images->dead_small;
}
}
if (isset($_GET['json'])) {
header("Content-type: application/json");
echo json_encode(getProjectStatus());
exit;
}
ob_start();
?>
<div id="maincontent">
<div id="midcolumn">
<h1><?php echo $pageTitle; ?></h1>
<?php dumpStatus(getProjectStatus()); ?>
</div>
</div>
<div id="rightcolumn">
<div class="sideitem">
<h6>Filter by Top Level</h6>
<ul>
<?php
foreach(getTopLevelProjects() as $project) {
$id = $project->getId();
$name = preg_replace("/ Root$/", '', $project->getName());
$link = "?" . getHttpParameters(null, $id);
echo "<li><a href=\"$link\">$name</a></li>";
}
?>
</ul>
</div>
<div class="sideitem">
<h6>Legend</h6>
<ul>
<li style="list-style-image: url('<?php echo $images->tools_small; ?>')">No project activity (project may be new)</li>
<li style="list-style-image: url('<?php echo $images->active_small; ?>')">Activity in the last three months</li>
<li style="list-style-image: url('<?php echo $images->stale_small; ?>')">Activity in the last six months</li>
<li style="list-style-image: url('<?php echo $images->inactive_small; ?>')">No activity for more than six months</li>
<li style="list-style-image: url('<?php echo $images->dead_small; ?>')">No activity for more than twelve months</li>
</ul>
<p>Note that subprojects are included in the determination of liveliness. A project is as lively as the most lively of its subprojects.</p>
</div>
</div>
<?php
$html = ob_get_contents();
ob_end_clean();
$App->generatePage('solstice', $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
?>