blob: 8723798d6eb30849472b3b0c4543fbf291bc62b2 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2011 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__) . "/projects.json.inc");
//mustBeEclipseFoundationCaller();
//header("Content-type: application/json");
$projects_array = projectsAsArray(getTopLevelProjects());
$count = $_GET['count'];
if (isset($count)){
$projects_array = array_slice($projects_array, 0, $count);
}
if (isset($_GET['columns'])) {
$columns = preg_split('/,/', $_GET['columns']);
} else {
$columns = array('id', 'name', 'provisioned');
}
function dumpProjectsAsCsv($projects, $columns, $out) {
foreach($projects as $project) {
$row = array();
foreach($columns as $column) {
$row[] = $project[$column];
}
fputcsv($out, $row);
dumpProjectsAsCsv($project['children'], $columns, $out);
}
}
$fp = fopen('php://output', 'w');
dumpProjectsAsCsv($projects_array, $columns, $fp);
fclose($fp);
?>