blob: 498b58db6e8a88aa1eb0cc7d9915f44236e2fb18 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 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:
* Wayne Beaton - initial API and implementation
*******************************************************************************/
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/common.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/debug.php");
trace_file_info(__FILE__);
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();
// TODO Refactor this code
// This is repeated in downloads.php; if it's use twice, it needs a single home.
if ($App->devmode) {
$base = $_SERVER['DOCUMENT_ROOT'] . '/projects/tests/data/ip-scans';
} else {
$base = '/home/data/httpd/writable/projects/ip-scans';
mustBeCommitter();
include($App->getProjectCommon());
}
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/util/summary.php");
function getProjectPairings($base) {
global $projectNamePattern;
$pairings = array();
if (!$dh = opendir($base)) return $scans;
while (($file = readdir($dh)) !== false) {
if (!preg_match("/^$projectNamePattern.xml$/", $file)) continue;
retrievePairings($pairings, "$base/$file");
}
closedir($dh);
return $pairings;
}
function retrievePairings(&$pairings, $file) {
$scan = simplexml_load_file($file);
foreach ($scan->project as $project) {
retrieveProjectPairings($pairings, $project);
}
}
function retrieveProjectPairings(&$pairings, $project) {
$source = $project['id'];
foreach($project->includes as $target) {
$target = (string)$target['id'];
$pairings[$target][] = $source;
}
}
function cmp_count($a, $b) {
if (count($a) == count($b)) return 0;
return (count($a) > count($b)) ? -1 : 1;
}
$pairings = getProjectPairings($base);
uasort($pairings, 'cmp_count');
ob_start();
$pageKeywords = "";
$pageTitle = "Project Use Frequency";
$pageAuthor = "Wayne Beaton";
?>
<div id="midcolumn">
<h1><?= $pageTitle ?></h1>
<div class="homeitem">
<p>This page shows the frequency with which bits of projects are distributed
by other projects. Project A is considered to be used/distributed by project B
if project B includes at least one bundle from project A in its download directory.
Note that that this does not reflect actual use; that would require scanning
bundle manifests (which we don't do just yet).</p>
<?php
echo "<ul>";
foreach($pairings as $target => $sources) {
$count = count($sources);
$entries = array();
foreach($sources as $id) {
$entries[] = "<a href=\"downloads.php?id=$id\">$id</a>";
}
$list = join(', ', $entries);
echo "<li>$target ($count)";
echo "<ul><li>$list</li></ul>";
echo "</li>";
}
echo "</ul>";
?>
</div>
</div>
<?php
$html = ob_get_contents();
ob_end_clean();
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
echo get_trace_html();
?>