| <?php |
| /******************************************************************************* |
| * Copyright (c) 2012 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Wayne Beaton (Eclipse Foundation)- initial API and implementation |
| *******************************************************************************/ |
| require_once(dirname(__FILE__) . "/../../eclipse.org-common/system/app.class.php"); |
| $App = new App(); |
| |
| require_once(dirname(__FILE__) . "/../classes/common.php"); |
| require_once(dirname(__FILE__) . "/../classes/debug.php"); |
| require_once(dirname(__FILE__) . "/../classes/Project.class.php"); |
| |
| //mustBeEclipseFoundationCaller(); |
| header("Content-type: application/json"); |
| |
| $projects = array(); |
| foreach(getActiveProjects() as $project) { |
| /* @var Project $project */ |
| $id = $project->getId(); |
| if ($repositories = getRepositoriesForProject($project)) |
| $projects[$id] = array( |
| 'id' => $id, |
| 'name' => $project->getName(), |
| 'description' => $project->getDescription(), |
| 'repositories' => $repositories |
| ); |
| if ($logo = $project->getLogoUrl()) |
| $projects[$id]['logo'] = normalizeHttpUrl($logo); |
| } |
| |
| echo json_encode($projects); |
| |
| /** |
| * |
| * @param Project $project |
| */ |
| function getRepositoriesForProject($project) { |
| $repositories = array(); |
| foreach($project->getSourceRepositories() as $repository) { |
| /* @var SourceRepository $repository */ |
| if ($repository->isReal()) { |
| $repositories[] = $repository->getUrl(); |
| } |
| } |
| return $repositories; |
| } |
| ?> |