blob: a79ea59a3d519c1ad403780940119c7f0015fef7 [file] [log] [blame]
<?php
/***********************************************************************
* Copyright (c) Eclipse Foundation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
***********************************************************************/
require_once "../../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 ());
require_once '../classes/Project.class.php';
require_once '../classes/ProjectStatusReporter.class.inc';
require_once '../classes/debug.php';
require_once '../classes/database.inc';
require_once '../classes/common.php';
require_once './charts.inc';
$pageTitle = "Eclipse Project Status";
$pageKeywords = "";
$pageAuthor = "Wayne Beaton";
ob_start ();
if (!(($id = @$_GET['id']) && isValidProjectId($id))) {
header('Location: /projects');
exit;
}
$options = array();
$options['width'] = is_numeric(@$_GET['width']) ? @$_GET['width'] : 640;
$options['height'] = is_numeric(@$_GET['height']) ? @$_GET['height'] : 400;
$options['start'] = @$_GET['start'] ? date('Y-m-d', strtotime(@$_GET['start'])) : null;
$options['end'] = @$_GET['end'] ? date('Y-m-d', strtotime(@$_GET['end'])) : null;
// Add an entry to focus the report on every
// top-level project to the navigation bar.
$Nav->addNavSeparator("Report", "./report.php");
foreach(Project::getTopLevelProjects() as $project) {
$Nav->addCustomNav($project->getName(), "?id={$project->getId()}", "_self", 2);
}
/**
* Render an HTML report for a particular project.
*
* This uses an instance of the ProjectStatusReporter class to collect
* and render specific bits of information about the project.
*
* @see ProjectStatusReporter
*
* @param Project $project
*/
function renderProjectReport(Project $project, $options) {
if (! $project)
return;
$status = new ProjectStatusReporter ($project->getId());
echo "<h2><a href=\"?id={$project->getId()}\">{$project->getFormalName()}</a></h2>";
echo "<div style=\"margin-left:1em\">";
// Render alerts. Alerts are a warning about something that might
// be odd or wrong about a project. We render each line using a
// warning icon as the bullet.
if ($alerts = $status->alerts($project)) {
echo "<h3>Alerts</h3>";
echo "<ul style=\"list-style-type: none\">";
foreach($alerts as $message) {
echo "<li><span style=\"color: red;\">&#9888;</span> {$message}</li>";
}
echo "</ul>";
}
// Render project stats in a table. This is a little clunky in my
// attempt to make the specification of individual stats easily
// extended while making the rendering very consistent. Each of the
// "values" from the ProjectStatusReporter contains information about
// a particular bit of data from the project (including a label and
// corresponding value).
echo "<h3>Lifetime stats</h3>";
echo "<div class=\"container\">";
$status->values (function ($column) {
echo "<div class=\"row\">";
echo "<div class=\"col-md-6 title\">";
echo "<span class=\"title\">{$column->getTitle()}:</span>";
if ($description = $column->getDescription()) {
echo "<br/><span class=\"description\">{$description}</span>";
}
echo "</div>";
echo "<div class=\"col-md-6 value\">{$column->getValue()}</div>";
echo "</div>";
} );
echo "</div>";
// Render charts
// FIXME Experimental.
$status->charts(function($builder) use (&$options) {
$builder
->width ( $options['width'] )
->height ( $options['height'] )
->substitute (':start', $options['start'])
->substitute (':end', $options['end'])
->render();
});
echo "</div>";
}
?>
<style>
div.title {line-height:1;margin-bottom:10px}
span.title {width:25%;font-weight: bold}
span.description {font-size: 75%}
div.value {width:50%;margin-left: 2em}
</style>
<div id="maincontent">
<div id="midcolumn">
<h1><?=$pageTitle?></h1>
<p>This page shows some basic project status metrics.
Please report any discrepancies to <a href="mailto:emo@eclipse-foundation.org">emo@eclipse-foundation.org</a> </p>
<?php
$project = Project::getProject($id);
if ($project) {
renderProjectReport($project, $options);
} else {
print "<p>There is no project with that ID.</p>";
}
?>
</div>
</div>
<?php
$html = ob_get_contents ();
ob_end_clean ();
$App->generatePage ( null, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html );
?>