blob: 657190fe94f90410b4ad43bd9a836a32f48a4e65 [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();
if( $parentId == "" ) {
$ProjectList->selectProjectList("", "", "1", "", "", "");
} else {
$ProjectList->selectProjectList("", "", "", $parentId, "", "");
}
for($i = 0; $i < $ProjectList->getCount(); $i++) {
$Project = $ProjectList->getItemAt($i);
$projectName = $Project->getName();
$url = $Project->getUrlIndex();
if( substr($url,-1,1) != "/" )
$url .= "/";
$url .= $filename;
#
# First look in the project's home directory
#
$localfile = str_replace("http://www.eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $url);
$localfile = str_replace("http://eclipse.org/", $_SERVER['DOCUMENT_ROOT'] . "/", $localfile);
#
# Second (temporarily while project Phoenix is not deployed) look on the
# project's home directory on the main web server
#
if( !file_exists($localfile) ) {
$localfile = str_replace("http://www.eclipse.org/", "/home/data/httpd/www.eclipse.org/html/", $url);
$localfile = str_replace("http://eclipse.org/", "/home/data/httpd/www.eclipse.org/html/", $localfile);
}
#
# 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);
}
#
# 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 {
$file = fopen($localfile,"r");
$listhtml .= "<li>";
while(!feof($file)){
$buffer = fgets($file);
$listhtml .= $buffer;
}
fclose($file);
$listhtml .= "</li>
";
}
}
return $listhtml;
}
?>