| <?php |
| /******************************************************************************* |
| * Copyright (c) 2011, 2012 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/SimultaneousReleaseInfo.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() { |
| $keys = array('top', 'id', 'phase', 'git', 'cvs', 'svn', 'liveliness', 'committers', 'organizations'); |
| return array_merge($keys, getSimultaneousReleaseNames()); |
| } |
| |
| 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() { |
| $projects = array(); |
| |
| foreach(getActiveProjects() as $project) { |
| $info = array( |
| 'id' => $project->getId(), |
| 'name' => $project->getName(), |
| 'top' => $project->getTopLevelProject()->getId(), |
| 'topName' => $project->getTopLevelProject()->getName(), |
| 'phase' => $project->isInIncubationPhase() ? 'incubating' : 'regular', |
| 'git' => in_array('git', $project->getSourceRepositoryTypes()), |
| 'svn' => in_array('svn', $project->getSourceRepositoryTypes()), |
| 'cvs' => in_array('cvs', $project->getSourceRepositoryTypes()), |
| 'liveliness' => $project->getLiveliness(), |
| 'committers' => $project->getActiveCommittersCount(), |
| 'organizations' => $project->getActiveOrganizationsCount() |
| ); |
| |
| foreach(getSimultaneousReleaseNames() as $name) { |
| $info[$name] = in_array($name, $project->getSimultaneousReleaseNames()) ? 1 : 0; |
| } |
| |
| if (!filter($info)) $projects[] = $info; |
| } |
| |
| 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 dumpStatus($projects) { |
| global $images; |
| |
| echo "<table>"; |
| |
| echo "<tr style=\"height: 5em;vertical-align:bottom\">"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('top') . "\">Top Level</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('id') . "\">Name</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('phase') . "\">Phase</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('git') . "\">Git</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('svn') . "\">SVN</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('cvs') . "\">CVS</a></div></th>"; |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('liveliness') . "\">Liveliness</a></div></th>"; |
| echo "<th><div style=\"width:3em;line-height:90%;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('committers') . "\">Active<br/>Committers</a></div></th>"; |
| echo "<th><div style=\"width:3em;line-height:90%;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?" . getHttpParameters('organizations') . "\">Active<br/>Organizations</a></div></th>"; |
| |
| $simultaneousReleaseNames = array_reverse(getSimultaneousReleaseNames()); |
| foreach($simultaneousReleaseNames as $name) { |
| $link = getHttpParameters($name); |
| $name = ucfirst($name); |
| echo "<th><div style=\"width:2em;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-90deg);\"><a href=\"?$link\">$name</a></div></th>"; |
| } |
| |
| echo "</tr>"; |
| |
| usort($projects, 'sort_projects'); |
| |
| $colour = true; |
| foreach($projects as $project) { |
| $top = $project['top']; |
| $topName = $project['topName']; |
| $name = $project['name']; |
| $id = $project['id']; |
| $phase = $project['phase'] == 'incubating' ? "<img src=\"$images->incubation_conforming_small\"/>" : ' '; |
| $git = $project['git'] ? "<img src=\"$images->check\"/>" : ' '; |
| $svn = $project['svn'] ? "<img src=\"$images->check\"/>" : ' '; |
| $cvs = $project['cvs'] ? "<img src=\"$images->check\"/>" : ' '; |
| $liveliness = getLivelinessIcon($project['liveliness']); |
| $committers = $project['committers']; |
| $organizations = $project['organizations']; |
| |
| $style = $colour ? ' style="background-color:#E2E2E2"' : ''; |
| $colour = !$colour; |
| |
| echo "<tr$style>"; |
| echo "<td>$topName</td>"; |
| echo "<td><a href=\"/projects/project.php?id=$id\">$name</a></td>"; |
| echo "<td>$phase</td>"; |
| echo "<td>$git</td>"; |
| echo "<td>$svn</td>"; |
| echo "<td>$cvs</td>"; |
| echo "<td><img src=\"$liveliness\"/></td>"; |
| echo "<td>$committers</td>"; |
| echo "<td>$organizations</td>"; |
| |
| foreach($simultaneousReleaseNames as $name) { |
| $in = $project[$name] ? "<img src=\"$images->check\"/>" : ' '; |
| echo "<td>$in</td>"; |
| } |
| |
| echo "</tr>"; |
| |
| } |
| echo "</table>"; |
| } |
| |
| 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_ACTIVE: return $images->active_small; |
| case PROJECT_LIVELINESS_STALE: return $images->stale_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 = $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->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->dead_small; ?>')">No activity for more than six 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('Nova', $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html); |
| ?> |