blob: 96244615bffaae6e0bf14e05c2593945ab2b9259 [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($_SERVER['DOCUMENT_ROOT'] . "/projects/common/project-info.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){
if(eregi("eclipse.org", $_SERVER['SERVER_NAME']))
{
$url = $_SERVER['DOCUMENT_ROOT'] . "/projects/web-api/projects-info-inner.php";
ob_start();
$_REQUEST['fetch'] = $fetch;
$_REQUEST['archived'] = $includearchived;
include_once( $url );
$contents = ob_get_contents();
ob_end_clean();
} else {
$url = "http://www.eclipse.org/projects/web-api/projects-info.php?fetch=" . urlencode($fetch) . "&archived=$includearchived";
$lines = file( $url );
if( $lines == false ) return;
$contents = implode( "", $lines );
}
$contents = preg_replace( "/\<\!--.*?--\>/s", "", $contents );
$XMLWrapper = new XMLWrapper($contents);
$projects = $XMLWrapper->getElement(array("projects", "project"));
$num_projects = count($projects);
for($p = 0; $p < $num_projects; $p++)
{
$project_key = $projects[$p];
if($fetch == 0)
{
$proj = new ProjectInfo($project_key, 0);
$this->_projects[] = $proj;
}
else
{
$this->_projects[] = New ProjectInfo($project_key, $fetch);
}
}
}
/**
* 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;
}
}
?>