| <?php | |
| /******************************************************************************* | |
| * Copyright (c) 2011, 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"); | |
| function projectsAsArray($projects) { | |
| $all = array(); | |
| foreach($projects as $project) { | |
| $all[$project->getId()] = projectAsArray($project); | |
| } | |
| return $all; | |
| } | |
| function projectAsArray($project) { | |
| return array( | |
| 'id' => $project->getId(), | |
| 'name' => $project->getName(), | |
| 'shortname' => $project->getShortName(), | |
| 'projecturl' => normalizeHttpUrl($project->getProjectUrl()), | |
| 'description' => preg_replace('/\s+/', ' ', $project->getDescription()), | |
| 'scope' => preg_replace('/\s+/', ' ', $project->getScope()), | |
| 'licenses' => $project->getLicenses(), | |
| 'phase' => $project->getProjectPhase(), | |
| 'planurl' => normalizeHttpUrl($project->getPlanUrl()), | |
| 'bugzillaproduct' => $project->getBugzillaProduct(), | |
| 'proposalurl' => ($proposal = $project->getProposal()) ? $proposal->getProposalUrl() : null, | |
| 'wikiurl' => $project->getWikiUrl(), | |
| 'documentationurl' => normalizeHttpUrl($project->getDocumentationUrl()), | |
| 'downloadsurl' => normalizeHttpUrl($project->getDownloadsUrl()), | |
| 'gettingstartedurl' => normalizeHttpUrl($project->getGettingStartedUrl()), | |
| 'sourcerepositories' => sourceRepositoriesAsArray($project), | |
| 'mailinglists' => getMailingListsAsArray($project), | |
| 'forums' => getForumsAsArray($project), | |
| 'releases' => releasesAsArray($project), | |
| 'reviews' => reviewsAsArray($project), | |
| 'children' => projectsAsArray($project->getChildren()) | |
| ); | |
| } | |
| function getMailingListsAsArray(&$project) { | |
| $main = null; | |
| $lists = array(); | |
| foreach($project->getMailingLists() as $list) { | |
| if (!$list->getName()) continue; | |
| $item = array( | |
| 'email' => $list->getName(), | |
| 'description' => $list->getDescription(), | |
| 'type' => $list->getType() | |
| ); | |
| if (($list->getType() == 'main') && empty($main)) | |
| $main = $item; | |
| else | |
| $lists[] = $item; | |
| } | |
| if (empty($main) && count($lists)) { | |
| $main = $lists[0]; | |
| unset($lists[0]); | |
| } | |
| return array( | |
| 'devlist' => $main, | |
| 'other' => $lists | |
| ); | |
| } | |
| function getForumsAsArray(Project &$project) { | |
| $main = null; | |
| $forums = array(); | |
| foreach($project->getNewsgroups() as $group) { | |
| if (!$group->getName()) continue; | |
| $forums[] = array( | |
| 'name' => $group->getName(), | |
| 'description' => $group->getDescription(), | |
| 'type' => $group->getType(), | |
| 'url' => 'http://www.eclipse.org/forums/' . $group->getName() | |
| ); | |
| } | |
| return $forums; | |
| } | |
| function sourceRepositoriesAsArray($project) { | |
| $repositories = array(); | |
| foreach($project->getSourceRepositories() as $repository) { | |
| $repositories[] = $repository->getPath(); | |
| } | |
| return $repositories; | |
| } | |
| function releasesAsArray($project) { | |
| $releases = array(); | |
| foreach($project->getReleases() as $release) { | |
| $releases[] = releaseAsArray($release); | |
| } | |
| return $releases; | |
| } | |
| function releaseAsArray($release) { | |
| $values = array(); | |
| $values['name'] = $release->getName(); | |
| $values['date'] = date('Y-m-d', $release->getDate()); | |
| $values['noteworthy'] = normalizeHttpUrl($release->getNoteworthyUrl()); | |
| $values['planurl'] = normalizeHttpUrl($release->getPlan()); | |
| addPlanItems($values, $release->getPlan()); | |
| return $values; | |
| } | |
| function reviewsAsArray($project) { | |
| $reviews = array(); | |
| foreach($project->getReviews() as $review) { | |
| $reviews[] = reviewAsArray($review); | |
| } | |
| return $reviews; | |
| } | |
| /** | |
| * | |
| * @param Review $review | |
| * @return multitype:string | |
| */ | |
| function reviewAsArray($review) { | |
| $values = array(); | |
| $values['name'] = $review->getReviewName(); | |
| $values['date'] = date('Y-m-d', $review->getReviewDate()); | |
| $values['slides'] = normalizeHttpUrl($review->getSlidesUrl()); | |
| $values['iplog'] = normalizeHttpUrl($review->getIplogUrl()); | |
| $values['bug'] = $review->getBugNumber(); | |
| $values['creation'] = $review->isCreation(); | |
| $values['release'] = $review->isRelease(); | |
| $values['graduation'] = $review->isGraduation(); | |
| $values['restructure'] = $review->isRestructure(); | |
| $values['termination'] = $review->isTermination(); | |
| $values['successful'] = $review->isSuccessful(); | |
| $values['unsuccessful'] = $review->isUnsuccessful(); | |
| $values['withdrawn'] = $review->isWithdrawn(); | |
| return $values; | |
| } | |
| function addPlanItems(&$values, $planUrl) { | |
| if (!$planUrl) return; | |
| if (!preg_match('/\.xml$/', $planUrl)) return; | |
| require_once(dirname(__FILE__).'/project-plan-parser.inc'); | |
| $plan = ProjectPlanParser::getPlanFromFile(dirname(__FILE__) . '/../../' . $planUrl); | |
| if ($plan) $values['plan'] = $plan; | |
| } | |
| ?> |