blob: d8b080b842c7dd53b928d1a8c74ef97dc169ea0b [file] [log] [blame]
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/projects/projectList.class.php");
function project_list_as_html( $filename, $parentId ) {
$ProjectList = new ProjectList();
$listhtml = "";
if( $parentId == "" ) {
$ProjectList->selectProjectList("", "", "1", "", "", "PRJ.sort_order");
} else {
$ProjectList->selectProjectList("", "", "", $parentId, "", "");
}
for($i = 0; $i < $ProjectList->getCount(); $i++) {
$Project = $ProjectList->getItemAt($i);
$projectName = $Project->getName();
if( !$Project->getIsActive() ) {
continue;
}
if( $Project->getProjectID() == "foundation-internal" ) {
continue;
}
if( strpos( $projectName, "[archived]")
|| strpos( $projectName, "[closed]" ) ) {
continue;
}
$url = $Project->getUrlIndex();
if( substr($url,-1,1) != "/" )
$url .= "/";
#
# First look in the project's project-info directory
#
$localfile = str_replace("http://www.eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $url);
$localfile = str_replace("http://eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $localfile);
if( substr($localfile,-1,1) != "/" )
$localfile .= "/";
$localfile .= "project-info/" . $filename;
#$listhtml .= "<p>(1) <code>" . $localfile . "</code></p>\n";
#
# Second look in the project's home directory (the old location)
#
if( !file_exists($localfile) ) {
$localfile = str_replace("http://www.eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $url);
$localfile = str_replace("http://eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $localfile);
if( substr($localfile,-1,1) != "/" )
$localfile .= "/";
$localfile .= $filename;
#$listhtml .= "<p>(2) <code>" . $localfile . "</code></p>\n";
}
#
# Third if the project does not have the file, then use our temporary version
# eventually all the projects should have their own files and these
# temporary versions can be deleted
#
if( !file_exists($localfile) ) {
$localfile = str_replace("http://www.eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/projects/temporary/", $url);
$localfile = str_replace("http://eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/projects/temporary/", $localfile);
if( substr($localfile,-1,1) != "/" )
$localfile .= "/";
$localfile .= $filename;
#$listhtml .= "<p>(3) <code>" . $localfile . "</code></p>\n";
}
#
# Fourth if there just isn't a file anywhere, then show only the project name.
#
if (!file_exists($localfile)){
$url = $Project->getUrlIndex();
if( $url != "" ) {
$listhtml .= "<li><a href=\"$url\">" . $projectName . "</a></li>\n";
} else {
$listhtml .= "<li>" . $projectName . "</li>\n";
}
} else {
$listhtml .= "<li>";
$listhtml .= file_get_contents( $localfile );
$listhtml .= "</li>
";
}
}
return $listhtml;
}
?>