blob: 5396b957938a9d60cb0866544b3f81b5e4717b64 [file] [log] [blame]
<?php
/**
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (http://www.eclipse.org/legal/epl-v10.html).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
*
*/
require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_projectinfo_ro.class.php");
class ProjectInfoData
{
private $rows; // raw query results for database, ProjectID, MainKey, SubKey, Value, ProjectInfoID
private $mainkeys; // [main key] -> # of rows
private $subkeys; // [main key] -> true if has subkeys, false otherwise
function ProjectInfoData( $projectid )
{
$dbc = new DBConnectionProjectInfo();
$dbh = $dbc->connect();
$result = mysql_query("
SELECT * FROM ProjectInfo, ProjectInfoValues
WHERE ProjectID = '$projectid'
AND ProjectInfo.ProjectInfoID = ProjectInfoValues.ProjectInfoID", $dbh);
$this->rows = array();
$this->mainkeys = array();
$this->subkeys = array();
while($row = mysql_fetch_assoc($result)) {
$this->rows[] = $row;
$mainkey = $row['MainKey'];
if( isset($this->mainkeys[$mainkey]))
$this->mainkeys[$mainkey]++;
else
$this->mainkeys[$mainkey] = 1;
if( !isset($this->subkeys[$mainkey]))
$this->subkeys[$mainkey] = false;
if( $row['SubKey'] != null )
$this->subkeys[$mainkey] = true;
}
}
function __get( $varname )
{
foreach( $this->rows as $row ) {
$mainkey = $row['MainKey'];
if( $mainkey == $varname ) {
if( $this->mainkeys[$mainkey] == 1 ) {
if( $this->subkeys[$mainkey] == false ) {
return $row['Value'];
} else {
$subrows = array();
foreach( $this->rows as $rr ) {
if( $row['ProjectInfoID'] == $rr['ProjectInfoID']) {
$subrows[] = $rr;
}
}
return new ProjectInfoValues( $this, $subrows );
}
} else {
if( $this->subkeys[$mainkey] == false ) {
$result = array();
foreach( $this->rows as $rr ) {
if( $rr['MainKey'] == $mainkey) {
$result[] = $rr['Value'];
}
}
return $result;
} else {
$result = array();
foreach( $this->rows as $rr ) {
if( $rr['MainKey'] == $mainkey) {
$subrows = array();
foreach( $this->rows as $rr ) {
if( $row['ProjectInfoID'] == $rr['ProjectInfoID']) {
$subrows[] = $rr;
}
}
$result[] = new ProjectInfoValues( $this, $subrows );
}
}
return $result;
}
}
}
}
return null;
}
}
class ProjectInfoValues {
private $rows;
function ProjectInfoValues( $projectinfo, $subrows ) {
$this->rows = $subrows;
}
function __get( $varname )
{
foreach( $this->rows as $row ) {
$subkey = $row['SubKey'];
if( $subkey == $varname ) {
return $row['Value'];
}
}
return null;
}
}
class ProjectInfo {
private $info;
function ProjectInfo($projectkey) {
$this->info = new ProjectInfoData($projectkey);
}
/**
* Generate the common left menu navigation menu
*/
function generate_common_nav( $thenav, $users = NULL, $integrators = NULL, $contributors = NULL ) {
global $Nav;
$Nav->setLinkList( array() );
$Nav->addNavSeparator( $this->info->projectshortname . "3", $this->info->projecturl );
$Nav->addCustomNav("About", $this->info->descriptionurl, "", 1);
if( $this->info->teamurl
|| (!$this->info->leadersurl
&& !$this->info->committersurl
&& !$this->info->contributorsurl) ) {
$Nav->addCustomNav("Team", htmlspecialchars($this->info->teamurl), "", 2);
} else { /* old-style */
$Nav->addCustomNav("Team", "#", "", 2);
$Nav->addCustomNav("Leaders", htmlspecialchars($this->info->leadersurl), "", 3);
$Nav->addCustomNav("Committers", htmlspecialchars($this->info->committersurl), "", 3);
$Nav->addCustomNav("Contributors", htmlspecialchars($this->info->contributorsurl), "", 3);
}
$Nav->addCustomNav("Plan", htmlspecialchars($this->info->projectplanurl), "", 2);
if( $this->info->legalurl != "" ) {
$Nav->addCustomNav("Legal", htmlspecialchars($this->info->legalurl), "", 2);
} else { /* old-style */
$Nav->addCustomNav("Legal", htmlspecialchars($this->info->iplogurl), "", 2);
}
$Nav->addCustomNav("Users", htmlspecialchars($this->info->gettingstartedurl), "", 1);
$Nav->addCustomNav("Getting Started", htmlspecialchars($this->info->gettingstartedurl), "", 2);
$Nav->addCustomNav("Downloads", htmlspecialchars($this->info->downloadsurl), "", 2);
$Nav->addCustomNav("Newsgroups", htmlspecialchars($this->newsgroup_url()), "", 2);
$Nav->addCustomNav("Bugs", htmlspecialchars($this->bugzilla_url()), "", 2);
if( !empty($users) ) {
$users($Nav);
}
$Nav->addCustomNav("Integrators", htmlspecialchars($this->info->integratorsurl), "", 1);
$Nav->addCustomNav("API Plan", htmlspecialchars($this->info->projectplanurl), "", 2);
if( !empty($integrators) ) {
$integrators($Nav);
}
$Nav->addCustomNav("Contributors", htmlspecialchars($this->info->contributingurl), "", 1);
$Nav->addCustomNav("Contributing", htmlspecialchars($this->info->contributingurl), "", 2);
$Nav->addCustomNav("Mailing Lists", htmlspecialchars($this->mailinglist_url()), "", 2);
if( !empty($contributors) ) {
$contributors($Nav);
}
}
function newsgroup_url() {
$x = $this->info->newsgroup;
if( !$x ) return "";
if( count($x) > 0 ) $x = $x[0];
return "http://dev.eclipse.org/newslists/news." . $x->name . "/maillist.html";
}
function mailinglist_url() {
$x = $this->info->mailinglist;
if( !$x ) return "";
if( count($x) > 0 ) $x = $x[0];
return "https://dev.eclipse.org/mailman/listinfo/" . $x->name;
}
function bugzilla_url() {
if( $this->info->bugzilla->productname )
return "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=" . $this->info->bugzilla->productname . "&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";
else
return "";
}
}
?>