blob: 4733cbc6389d5b95f53b07be3e3eeedd89f78825 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2009 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:
* Eclipse Foundation- initial API and implementation
*******************************************************************************/
require_once(dirname(__FILE__) . "/../classes/common.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
$App = new App();
include($App->getProjectCommon());
/*
* This file generates XML content describing the hierarchy of projects.
* All projects are reported regardless of their state (i.e. archived projects
* are included).
*/
//require_once("../common/shared_functions.php");
//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', 1);
require_once("iplog_licenses.php");
require_once("iplog_contribution_questionnaires.php");
require_once("iplog_committers.php");
require_once("iplog_contributors.php");
//define("PROJECT_ID_PATTERN", "/^[a-zA-Z0-9]+(\.[a-zA-Z0-9]+){0,2}$/");
/*
* $projectids is an array containing the ids of the projects provided
* via the http request. We take the value provided in the "id" parameter
* and break the string into a collection of ids; each id is separated
* from the next by a comma. The first value is assumed to be the
* id of the project for which the log is generated.
*/
$ids = split(',', $_GET["id"]);
$allProjects = clean_project_ids($ids);
header("Content-type: text/xml");
header("Content-Disposition: inline; filename=project.iplog");
$filename = $_SERVER['DOCUMENT_ROOT'] . "/projects/xml/project_ip_data.php";
$last_modified = filemtime($filename);
$modified_date = date ("Y-m-d H:i:s", $last_modified);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<iplog:iplog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:iplog=\"http://www.eclipse.org/projects/xml/iplog\" xsi:schemaLocation=\"http://www.eclipse.org/projects/xml/iplog iplog.xsd\">\n";
dump_project_ids($allProjects);
dump_project_licenses($allProjects);
dump_project_cqs($allProjects);
dump_project_committers($allProjects);
dump_project_contributors($allProjects);
echo "</iplog:iplog>";
/*
* This function cleans up the given array of project ids to make
* sure that they at least look like proper values. That is, the
* array of ids provided is pruned to only include those that match
* the conventions established for project ids. No actual check is
* done by this function to see if the ids are real.
*/
function clean_project_ids(&$ids) {
$projectids = array();
foreach ($ids as $id) {
//$id = trim($id);
if (isValidProjectId($id)) {
$projectids[] = $id;
}
}
return $projectids;
}
//function isValidProjectId($id) {
// return preg_match(PROJECT_ID_PATTERN, $id) > 0;
//}
/*
* Echo the list of projects we've received. We query the database
* to find the names for the projects with the given ids. As a result
* of the query, the output contains only those projects that actually
* exist.
*
* This function assumes that the first id in the list is the "root"
* project and renders it specially. Specifically, the first id is
* rendered using the tag "iplog:root"; each subsequent project
* is rendered as "iplog:project" per the XSD.
*/
function dump_project_ids(&$projectids) {
global $App;
$query = "SELECT Name, ProjectId FROM Projects where ProjectId in ('" . implode( "','", $projectids ) ."')";
$result = $App->foundation_sql($query);
$tag = "project";
while( $row = mysql_fetch_assoc($result) ) {
$projectid = $row['ProjectId'];
$name = $row['Name'];
echo "<iplog:$tag id=\"$projectid\" name=\"$name\"/>";
$tag = "includes";
}
}
function log_message($message) {
//$message = htmlspecialchars($message);
//echo "<!-- log message=\"$message\" -->";
}
function log_query($sql) {
log_message("sql: $sql");
}
?>