-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetplatforminfo.php
More file actions
47 lines (42 loc) · 1.85 KB
/
Copy pathgetplatforminfo.php
File metadata and controls
47 lines (42 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once 'config/app.config.php';
require_once 'src/RepositoryReader.php';
require_once 'src/ScmTree.php';
require_once 'src/ErrorCodes.php';
require_once 'config/zend.config.php';
require_once 'src/models/Deployment.php';
$deploymentModel = new Deployment();
if(!isset($_GET['url'])) {
send_response('', NO_URL_ERROR, 'No platfrom URL specified');
}
$svnreader = new RepositoryReader;
$svntree = $svnreader->readRepoStructure();
$scmtree = new ScmTree($svntree);
$scmtree->setReadOnly(!isset($_GET['readonly']) || $_GET['readonly'] == 'true');
$rules = $deploymentModel->getDeploymentRulesByProjectUrl(SvnWrapper::singleton()->getURL());
$scmtree->setDeploymentRules($rules);
$pattern = $deploymentModel->getPatternByPlatformUrl($_GET['url']);
$versions = Version::categorizeVersions($scmtree->getVersionsForPattern($pattern), $pattern);
function convertVersions($node, $scmtree, $pattern) {
$convertedNode = array();
foreach($node as $key => $leaf) {
if(is_array($leaf)) {
$convertedNode[] = array('label' => $key, 'children' => convertVersions($leaf, $scmtree, $pattern));
} else {
$convertedNode[] = array('label' => $leaf, 'children' => array());
if($link = $scmtree->getDeploymentLink($leaf)) {
$convertedNode[count($convertedNode) - 1]['link'] = $link;
}
if($scmtree->isLatestForPattern($leaf, $pattern)) {
$convertedNode[count($convertedNode) - 1]['latest'] = true;
}
}
}
return $convertedNode;
}
$versions = convertVersions($versions, $scmtree, $pattern);
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
send_response(array('pattern' => $pattern, 'versions' => $versions));
?>