blob: 1f64e115be7814180da2b772d30177d34e4b6e6e [file] [log] [blame]
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/projects/project.class.php");
class ProjectInfo {
var $project;
var $dom;
/**
* Create a new ProjectInfo object.
* The ProjectInfo object aggregates data from a number of sources
* into one convenient object.
*
* @param string $projectkey Key into the Eclipse Foundation's internal database
* of projects. These keys are assigned by the EMO.
*/
function ProjectInfo( $projectkey ) {
$this->project = new Project();
$this->project->selectList( $projectkey );
$url = $this->project->getUrlIndex();
if( substr($url,-1,1) != "/" )
$url .= "/";
$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/project-info.xml";
if( !file_exists($localfile) ) {
#
# Special cases for looking in older viewcvs directories
#
if( $projectkey == "tools.cdt" ) {
$localfile = "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/cdt-home/project-info/project-info.xml?cvsroot=Tools_Project";
$this->dom = implode("", file($localfile));
$this->dom = preg_replace( "/\<\!--.*?--\>/s", "", $this->dom );
}
#
# End special cases
#
else {
$this->dom = "";
}
} else {
/*NEEDS DOM $this->dom = domxml_open_file($localfile); */
/*NO DOM*/
$this->dom = implode("", file($localfile));
$this->dom = preg_replace( "/\<\!--.*?--\>/s", "", $this->dom );
/*NO DOM*/
}
}
/**
* The full name of the project.
* Source: Foundation database.
*/
function get_name() {
return $this->project->getName();
}
/**
* HTML fragment the the project name and a link to
* to the project's home page.
* Source: Foundation database.
*/
function linked_name() {
$url = $this->project->getUrlIndex();
$projectName = $this->project->getName();
if( $url != "" ) {
return "<a href=\"$url\">" . $projectName . "</a>";
} else {
return $projectName;
}
}
/**
* URL to the project's current Project IP Log.
* An absolute URL of the eclipse.org page (e.g., "/webtools/jst/index.php"),
* or NULL if there is no current Project IP Log.
* Source: project-info.xml
*/
function ip_log_url() {
$url = _getXpathValues($this->dom, "//project/ip-log/@url");
$url = _un_encode_url($url);
return $url;
}
function bugs_url() {
$url = _getXpathValues($this->dom, "//project/bugzilla/@url");
if( isset($url) ) {
$url = _un_encode_url($url);
return $url;
}
$product = _getXpathValues($this->dom, "//project/bugzilla/product/@name");
if( isset($product) )
return "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&product=" . $product . "&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED";
return NULL;
}
function committers_url() {
$url = _getXpathValues($this->dom, "//project/committers/@url");
$url = _un_encode_url($url);
return $url;
}
function contributors_url() {
$url = _getXpathValues($this->dom, "//project/contributors/@url");
$url = _un_encode_url($url);
return $url;
}
function cvs_url() {
$repository = _getXpathValues($this->dom, "//project/cvs/@repository");
if( !isset($repository) )
return NULL;
if( substr($repository,-1,1) != "/" )
$repository .= "/";
$viewrepository = "";
if( $repository == "/cvsroot/eclipse/") $viewrepository = "";
if( $repository == "/cvsroot/tools/") $viewrepository = "?cvsroot=Tools_Project";
if( $repository == "/cvsroot/webtools/") $viewrepository = "?cvsroot=WebTools_Project";
if( $repository == "/cvsroot/birt/") $viewrepository = "?cvsroot=BIRT_Project";
if( $repository == "/cvsroot/technology/") $viewrepository = "?cvsroot=Technology_Project";
if( $repository == "/cvsroot/tptp/") $viewrepository = "?cvsroot=TPTP_Project";
if( $repository == "/cvsroot/dsdp/") $viewrepository = "?cvsroot=DSDP_Project";
if( $repository == "/cvsroot/datatools/") $viewrepository = "?cvsroot=Datatools_Project";
$path = _getXpathValues($this->dom, "//project/cvs/@path");
if( isset($path) )
return "http://dev.eclipse.org/viewcvs/index.cgi/" . $path . "/" . $viewrepository;
else
return "http://dev.eclipse.org/viewcvs/index.cgi/" . $viewrepository;
}
function description_url() {
$url = _getXpathValues($this->dom, "//project/description/@url");
$url = _un_encode_url($url);
return $url;
}
function description_paragraph() {
$result = $this->_get_paragraph( "//project/description/@paragraph-url" );
if( isset($result) ) {
return $result;
} else {
return $this->linekd_name();
}
}
function summary_paragraph() {
$result = $this->_get_paragraph( "//project/summary/@paragraph-url" );
if( isset($result) ) {
return $result;
} else {
return "<em>No Status Information</em>";
}
}
function downloads_url() {
return $this->project->getUrlDownload();
}
function getting_started_url() {
$url = _getXpathValues($this->dom, "//project/getting-started/@url");
$url = _un_encode_url($url);
return $url;
}
function leaders_url() {
$url = _getXpathValues($this->dom, "//project/leaders/@url");
$url = _un_encode_url($url);
return $url;
}
function mailing_lists_url() {
$url = _getXpathValues($this->dom, "//project/mailing-lists/@url");
if( isset($url) ) {
$url = _un_encode_url($url);
return $url;
}
$name = _getXpathValues($this->dom, "//project/mailing-lists/list/@name");
if( isset($name) ) {
return "http://dev.eclipse.org/mhonarc/lists/" . $name . "/maillist.html";
}
return NULL;
}
function project_plan_url() {
$url = _getXpathValues($this->dom, "//project/project-plan/@url");
$url = _un_encode_url($url);
return $url;
}
function generate_common_nav( $thenav ) {
global $Nav;
$Nav->setLinkList( array() );
$Nav->addCustomNav("About", "#", "", 1);
$Nav->addCustomNav("Description", $this->description_url(), "", 2);
$Nav->addCustomNav("Project Plan", $this->project_plan_url(), "", 2);
$Nav->addCustomNav("Leadership", $this->leaders_url(), "", 2);
$Nav->addCustomNav("Committers", $this->committers_url(), "", 2);
$Nav->addCustomNav("Contributors", $this->contributors_url(), "", 2);
$Nav->addCustomNav("IP Log", $this->ip_log_url(), "", 2);
$Nav->addCustomNav("Downloads", $this->downloads_url(), "", 1);
$Nav->addCustomNav("Getting Started", $this->getting_started_url(), "", 1);
$Nav->addCustomNav("Development", "#", "", 1);
$Nav->addCustomNav("Project Plan", $this->project_plan_url(), "", 2);
$Nav->addCustomNav("Mailing Lists", $this->mailing_lists_url(), "", 2);
$Nav->addCustomNav("CVS", $this->cvs_url(), "", 2);
$Nav->addCustomNav("Bugs", $this->bugs_url(), "", 2);
}
function _get_paragraph( $xpath ) {
#$xx .= "<p>(1) <code>$xpath</code></p>";
$url = _getXpathValues($this->dom, $xpath );
$url = _un_encode_url($url);
#$xx .= "<p>(2) <code>$url</code></p>";
if( isset($url) ) {
$localfile = $_SERVER['DOCUMENT_ROOT'] . $url;
#$xx .= "<p>(3) <code>$localfile</code></p>";
if (file_exists($localfile)) {
$result = "";
$file = fopen($localfile,"r");
while(!feof($file)){
$buffer = fgets($file);
$result .= $buffer;
}
fclose($file);
return $result;
} else {
#
# Special cases for looking in older viewcvs directories
#
if( preg_match("/cdt/", $url) ) {
$url = preg_replace( "/\/cdt\//", "", $url);
$localfile = "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/cdt-home/$url?cvsroot=Tools_Project";
#$xx .= "<p>(4) <code>$localfile</code></p>";
return implode("\n", file($localfile));
}
#
# End special cases
#
}
}
return NULL;
}
}
/*NEEDS DOM
function _getXpathValues(&$dom, $expr) {
$xpth = $dom->xpath_new_context();
$xnode = xpath_eval($xpth,$expr);
if (isset ($xnode->nodeset[0])) {
$firstnode = $xnode->nodeset[0];
$children = $firstnode->children();
$value = $children[0]->content;
return $value;
}
else return NULL;
*/
/*NO DOM*/
function _getXpathValues($dom, $expr) {
if( preg_match( "/^\/\/(.*?)\/(.*?)\/(.*?)\/\@(.*?)$/", $expr, $matches ) ) {
$r1 = "/\<" . $matches[1] . "(\>|\s[^\>]*?\>).*?\<" . $matches[2] . "(\>|\s[^\>]*?\>).*?\<" . $matches[3] . "\s[^\>]*?" . $matches[4] . "=\"(.*?)\"/si";
if( preg_match( $r1, $dom, $matches ) )
return $matches[3];
else
return NULL;
}
if( preg_match( "/^\/\/(.*?)\/(.*?)\/\@(.*?)$/", $expr, $matches ) ) {
$r1 = "/\<" . $matches[1] . "(\>|\s[^\>]*?\>).*?\<" . $matches[2] . "\s[^\>]*?" . $matches[3] . "=\"(.*?)\"/si";
if( preg_match( $r1, $dom, $matches ) )
return $matches[2];
else
return NULL;
}
return NULL;
/*NO DOM*/
}
function _un_encode_url( $url ) {
if( !isset($url) ) return $url;
$url = preg_replace( "/\&amp;/", "&", $url );
$url = preg_replace( "/\&quot;/", "\"", $url );
$url = preg_replace( "/\&lt/", "<", $url );
$url = preg_replace( "/\&gt;/", ">", $url );
return $url;
}
?>