blob: 528dd7253dd6aeba373054810258c4fbc3d6bbca [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2008-2011 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:
* Bjorn Freeman-Benson (Eclipse Foundation) - initial API and implementation
* Gabe O'Brien (Eclipse Foundation) - various fixes
* Wayne Beaton (Eclipse Foundation) - Bug 360086
*******************************************************************************/
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");
require_once(dirname(__FILE__) . "/classes/Project.class.php");
require_once(dirname(__FILE__) . "/classes/debug.php");
require_once(dirname(__FILE__) . "/classes/common.php");
trace_file_info(__FILE__);
// ----------------------------------------------------------------------------
// PHOENIX STUFF
$App = new App();
$Nav = new Nav();
$Menu = new Menu();
include($App->getProjectCommon());
$pageTitle = "Project Plan";
$pageAuthor = "Wayne Beaton";
include( '_commonLeftNav.php' );
/**
* Handle input parameters.
*/
$parameters = trace("Parsing parameters");
if (isset($_REQUEST['projectid'])) {
$projectid = $_REQUEST['projectid'];
if (isValidProjectId($projectid)) {
$parameters->trace("Project is is $projectid");
} else {
$projectid = htmlspecialchars($projectid);
$parameters->trace("The specified project id ($projectid) is invalid.");
}
} else $projectid = null;
if (isset($_REQUEST['date'])) {
$value = $_REQUEST['date'];
$releaseDate = strtotime($value);
if ($releaseDate) {
$parameters->trace("Target release date is " . date('Y-m-d', $releaseDate));
} else {
$value = htmlentities($value);
$parameters->trace("The specified date ($value) is invalid.");
}
} else $releaseDate = null;
if (isset($_REQUEST['name'])) {
$releaseName = $_REQUEST['name'];
$parameters->trace("Target release name is $releaseName.");
} else $releaseName = null;
if (isset($_REQUEST['planurl'])) {
$value = $_REQUEST['planurl'];
$url = normalizeFilePathUrl($url);
if ($url) {
$parameters->trace("Plan URL is $url");
} else {
$value = htmlentities($value);
$parameters->trace("The specified url ($value) is invalid.");
}
} else $url = null;
$raw = isset($_REQUEST['raw']);
/*
* Must have a ?projectid=xxx or ?planurl=http://www.eclipse.org/xxx
*/
if ($projectid) {
$project = getProject($projectid);
if ($project) {
$url = normalizeFilePathUrl($project->getPlanUrl());
$release = null;
if ($releaseDate) {
$release = $project->getReleaseOnDate($releaseDate);
if (!$release) $parameters->trace('Release on ' . date('Y-m-d', $releaseDate) . ' not found!');
} else if ($releaseName) {
$release = $project->getReleaseNamed($releaseName);
if (!$release) $parameters->trace("Release named $releaseName not found!");
}
if ($release) $url = normalizeFilePathUrl($release->getPlan());
} else {
$parameters->trace("Project $projectid not found!");
}
}
// TODO What if the $url is null?
$App->AddExtraHtmlHeader("
<style>
h2 {border-bottom: 2px solid gray;}
h3 {border-bottom: 1px dotted gray;}
</style>");
ob_start();
?>
<?php renderProjectPlan($project, $url, $releaseDate, $raw);
function renderProjectPlan($project, $url, $releaseDate, $raw) {
if ($raw) renderRawProjectPlan($url);
else renderHtmlProjectPlan($project, $url, $releaseDate);
}
function renderRawProjectPlan($url) {
$contents = @file_get_contents( $url );
echo "<div id=\"maincontent\">";
echo "<div id=\"midcolumn\">";
echo "<div style=\"margin-left: 10px; margin-top: 10px\">";
echo "<b>Location:</b> $url<br>";
echo "<b>Meta-data Tag:</b> projectplanurl<br>";
echo "<b>Raw:</b>";
echo "<pre>";
echo htmlspecialchars($contents);
echo "</pre>";
echo "</div>";
echo "</div>";
echo "</div>";
}
function renderHtmlProjectPlan($project, $url, $releaseDate) {
$xml = new DomDocument();
$xml->load($url);
if( $xml === false ) {
echo "<div id=\"maincontent\">";
echo "<div id=\"midcolumn\">";
$contents = @file_get_contents( $url );
if( !$contents ) {
show_error_page( 'The specified URL (' . htmlspecialchars($url) . ') points to an empty file.', $projectid );
} else {
if( preg_match( "/&(?<!amp;)/", $contents ) ) {
show_error_page( 'the file appears to have at least one naked &amp;s in bugzilla urls: &amp;s must be escaped as &amp;amp; to be valid XML.', $projectid );
} else {
show_error_page( 'the file is not a valid project plan XML file. See <a href="http://wiki.eclipse.org/Development_Resources/Project_Plan">the documentation</a> for details.', $projectid );
}
}
echo "</div>";
echo "</div>";
return;
}
// If we don't have a reference to the project, obtain it from the plan.
if (!$project) {
$releases = $xml->getElementsByTagName( "release" );
$projectid = $releases->item(0)->getAttribute( "projectid" );
$project = get_project($projectid);
}
$pageTitle = "Project Plan for " . $project->getName();
$projectName = $project->getName();
// ----------------------------------------------------------------------------
// OUTPUT
$old_error_handler = set_error_handler("globalDisplayErrorHandler");
/* create the processor and import the stylesheet */
$xsl = new DomDocument();
$xsl->load("project-plan-render.xsl");
$proc = new XsltProcessor();
$xsl = $proc->importStylesheet($xsl);
$proc->setParameter(null, "projectName", $projectName);
$proc->setParameter(null, "projectId", $projectid);
/* transform and output the xml document */
$echo = $proc->transformToXML($xml);
if($echo === false){
show_error_page( 'the project XML file loaded but was not able to be transformed by our XSL. Please confirm that your XML is valid.', $projectid );
} else{
echo $echo;
}
restore_error_handler();
}
?>
<div style="float: right; text-align: right"><a href="?projectid=<?= $projectid ?>&raw=1">view raw xml of project plan</a><br>
<a href="/projects/dev_process/project-status-infrastructure.php">from project meta-data key "projectplanurl"</a></div>
<?php
$html = ob_get_contents();
ob_end_clean();
# Generate the web page
$pageKeywords = '';
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
echo get_trace_html();
function show_error_page( $errormsg, $projectid ) {
global $App;
$leaders = array();
$result = $App->foundation_sql("
SELECT DISTINCT(People.PersonID), FName, LName
FROM PeopleProjects, Projects, People
WHERE PeopleProjects.Relation in ('PL','PD')
AND InactiveDate is NULL
AND People.PersonID = PeopleProjects.PersonID
AND Projects.ProjectID = PeopleProjects.ProjectID
AND Projects.ProjectID = '$projectid'
ORDER BY LName");
while( $row = mysql_fetch_assoc($result) ) {
$leaders[] = $row['FName'] . ' ' . $row['LName'];
}
if( count($leaders) == 0 ) {
$leaderstr = "project leader(s)";
} else {
if( count($leaders) == 1 ) {
$leaderstr = "project leader (" . $leaders[0] . ")";
} else {
$t1 = array_pop( $leaders );
$leaderstr = "project leaders (" . implode( ", ", $leaders ) . " and " . $t1 . ")";
}
}
?>
<div style="margin-top: 60px; margin-left: 50px; width: 400px">
<center>
<img src="/projects/images/no-plan.jpg">
<p style="margin-top: 40px;">Unable to display the <?= $projectid ?> project plan because <?= $errormsg ?></p>
<?php if(count($leaders) != 0 ){ ?>
<p style="margin-bottom: 60px;">The project team and <?= $leaderstr ?> are responsible for the project plan. You can contact them via the <a href="http://www.eclipse.org/mail/">project's developer mailing list</a>.</p>
<?php } ?>
</center>
</div>
<?php
}
// Global Errror Handler Function
// This replicates the look/functionality of userErrorHandler from harness.php
// but doesn't implement the test-specific checks for global flags.
// NOTE: This is not setup by default. If you need to enable this,
// do something like: $old_error_handler = set_error_handler("globalDisplayErrorHandler");
// external_entry() sets this up if the context calls for it.
function globalDisplayErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
// TODO Refactor. This function is repeated in several files.
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
switch($errno) {
case E_NOTICE: // discard NOTICEs
case E_STRICT: // discard RUNTIME notices for deprecated usages
return;
default:
echo "<p><table cellpadding=10 width=400 bgcolor=#ffcccc><tr><td><font size=+2>Trouble: </font>";
echo "PHP $errortype[$errno]:<br>$errmsg<br>$filename ($linenum)";
$mysql_error_func = 'mysql_error_check';
if(function_exists($mysql_error_func)) {
$mysql_error_func();
}
echo "</table></p>\n";
}
}
?>