blob: e8aaf1a9aa12077af26570617a8795cf93f9b20f [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2010 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
*******************************************************************************/
/*
* This script assumes that it is being included by another script. We
* assume that the $App variable has already been defined.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/Project.class.php");
$smallIconDir = "http://dev.eclipse.org/small_icons";
$projects = get_project_hierarchy();
//$yui_source = '/eclipse.org-common/yui/2.6.0/build';
$yui_source = 'http://yui.yahooapis.com/2.8.0r4/build';
$App->AddExtraHtmlHeader("<script src=\"$yui_source/yahoo/yahoo.js\"></script>");
$App->AddExtraHtmlHeader("<script src=\"$yui_source/event/event.js\"></script>");
$App->AddExtraHtmlHeader("<script src=\"$yui_source/connection/connection.js\"></script>");
$App->AddExtraHtmlHeader("<link type=\"text/css\" rel=\"stylesheet\" href=\"$yui_source/treeview/assets/skins/sam/treeview.css\">");
$App->AddExtraHtmlHeader("<script src=\"$yui_source/yahoo-dom-event/yahoo-dom-event.js\"></script>");
$App->AddExtraHtmlHeader("<script src=\"$yui_source/treeview/treeview-min.js\"></script>");
$App->AddExtraHtmlHeader("<link type=\"text/css\" rel=\"stylesheet\" href=\"/projects/web-parts/projects.css\">");
?>
<h3>Eclipse Projects</h3>
<div class="yui-skin-sam">
<div id="projects">
<div id="projects-tree">Loading...</div>
<div id="project-summary"></div>
<div style="clear:both;"></div>
</div>
</div>
<script language="javascript">
function treeInit() {
var div = document.getElementById("projects-tree");
var tree = new YAHOO.widget.TreeView("projects-tree", [
<?
function render_hierarchy($projects, $expand=true) {
global $smallIconDir;
$separator = '';
foreach($projects as $project) {
if ($project->isComponent()) continue;
$id = $project->getId();
if ($id == 'galileo') continue;
echo "$separator{\n";
$separator = ",";
$name = htmlentities($project->getName());
$projectUrl = $project->getProjectUrl();
$wikiUrl = $project->getWikiUrl();
$name = $project->getName();
// if ($projectUrl) {
// //$name = "<a href=\"$projectUrl\">$name</a>";
// }
// $icons = '';
//
// if ($project->isInIncubationPhase())
// $icons .= "<a href=\"http://wiki.eclipse.org/Development_Resources/HOWTO/Incubation_Phase\"><img title=\"This project is in the Incubation phase\" src=\"/projects/images/egg.gif\"></a>";
//
// $icons .= "<a href=\"/projects/project_summary.php?projectid=$id\"><img title=\"Project Summary\" src=\"$smallIconDir/apps/help-browser.png\"></a>";
//
// if ($wikiUrl)
// $icons .= "<a href=\"$wikiUrl\"><img title=\"Project Wiki Page\" src=\"/home/categories/images/wiki.gif\"></a>";
//
$label = addslashes("$name");
echo "\ttype: \"text\",\n";
echo "\tdata: \"$id\",";
echo "\tlabel: \"$label\",\n";
echo "\tpropagateHighlightUp: true,\n";
echo "\texpanded: " . ($expand ? 'true' : 'false');
if ($project->hasChildren()) {
echo ",\n";
echo "\tchildren: [\n";
render_hierarchy($project->getChildren(), false);
echo "]";
}
echo "}";
}
}
render_hierarchy($projects, false);
?>
]);
tree.subscribe("focusChanged",select);
function select(info) {
if(info.newNode!=null) {
var id = info.newNode.data;
loadSummary(id);
}
}
function loadSummary(id) {
var summaryDiv = document.getElementById("project-summary");
var url = '/projects/web-parts/project_summary.php?id=' + id;
var successFunction = function(req){
summaryDiv.innerHTML = req.responseText;
};
var transaction = YAHOO.util.Connect.asyncRequest('GET',url,{success:successFunction},null);
}
tree.render();
loadSummary(null);
}
YAHOO.util.Event.onDOMReady(treeInit);
</script>