blob: 36e2c5d0a7038a0a4021ce3144a9cf42cf2997ca [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.class.php";
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/project-info.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/project.class.php");
/**
* Provides an easy way to enumerate all Eclipse Foundation Projects
*
* This Class gets the list of all projects on the Eclipse Foundation Database and creates a
* ProjectInfo object for each project. It ment as a way to enumerate all Eclipse Projects.
*
* @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0
* @example examples/all_projects.php A simple example of the usage of <b>projects-info.class.php</b>
* @link projects/common/doc/examples/all_projects.php Results of the example
* @author Eduardo A. Romero Gomez
*/
class ProjectsInfo{
var $_projects;
var $ind = 0;
/**
* Constructor, Creates the ProjectInfo object of each project
*
* Creates the ProjecInfo object for each project. If a Project doesn't have an URL index
* defined in the Foundation Database it won't be added to this list.
*
* @param integer $fetch Defines wether to get the project-info data from the temporary repository,
* from web or both. When set to 0 the data will be gathered from the project's web page. When set to 1
* it will be fetched from the local repository <b>only</b>. When set to 2 it will try from both, first from
* web, if there's no project-info.xml on the page it will fallback to the temporary repository. Web only is the
* default behavior. This is intended to be used only for a while, just until every project has its project-info.xml
* on web and updated.<br><br>
* @param boolean $includearchived If set to true the list will include Archived projects, defaults to false.<br>
* Projects under the Eclipse Technology Project have limited lifecycles. <br><br>
* Unlike the major top-level Projects, the Technology Projects are meant to be technology explorations or incubators.
* When these projects have explored, proved, or disproved their associated technologies, the project comes to its
* natural end. For some projects, this end is a paper publishing the research results; for others, this end is to
* be incorporated into the base technology of another top-level project, shuch projects are archived and described
*
* Unless specified the list <b>won't include Archived Projects</b>. <br>See http://www.eclipse.org/technology/archived.php
* for further reference.
* @return ProjectsInfo All the valid ProjectInfo's
*/
function ProjectsInfo($includearchived = false, $fetch = 0){
$this->_projects = array();
# Create DB Connection objects
$dbc = new DBConnection();
$dbh = $dbc->connect();
$sql = "SELECT
PRJ.project_id,
PRJ.name,
PRJ.url_index
FROM
projects AS PRJ
WHERE level >= 1";
if(!$includearchived)
{
$sql .= " AND is_active= '1'";
}
$result = MYSQL_QUERY($sql, $dbh);
while ($row = mysql_fetch_array ($result))
{
if($fetch == 0)
{
$proj = new ProjectInfo($row['project_id'], 0);
$this->_projects[] = $proj;
}
else
{
$this->_projects[] = New ProjectInfo($row['project_id'], $fetch);
}
}
# Destroy DB Objects
$dbc->disconnect();
$dbh = null;
$dbc = null;
$result = null;
$myrow = null;
}
/**
* The number of Projects found
*
* @access public
* @return integer The number of projects on this object.
*/
function hasProjects(){
return count($this->_projects);
}
/**
* Gets the <i>n</i>th Project on this object
*
* @access public
* @return ProjectInfo the Project
*/
function getProjectAt($index){
return $this->_projects[$index];
}
/**
* Get's the <i>n</i>th Project on this object
*
* @access public
* @return ProjectInfo the Project
*/
function getProject($index){
return $this->_projects[$index];
}
/**
* Get's the Next element of the list
*
* @access public
* @return ProjectInfo the next project
*/
function getNext()
{
if(isset($this->_projects[$this->ind]))
$project = $this->_projects[$this->ind];
else
$project = null;
$this->ind++;
return $project;
}
/**
* Get's the Previous element on the list
*
* @access public
* @return ProjectInfo the previous project
*/
function getPrevious()
{
$project = $this->_projects[$this->ind];
$this->ind--;
return $project;
}
}
?>