Næste version

[insert_php]

echo ““;

/***************************************

FETCHING DATA

*****************************************/

// get feed
// sprogparametre: 1 = danish | 2 = english

// aktivt feed
$feed = file_get_contents(‘https://api.AutoPilot.dk/api/GetFutureReleaseNotes/1’);

// decode feed
$object = json_decode($feed);

$filter = [‘version’=> [], ‘program’ => [], ‘type’ => []];

$uri = $_SERVER[REQUEST_URI];

// decode again for some reason.
$changelog = json_decode($object, true);
$changelist = [];

//Group by RelVersion and releasenoteId
foreach($changelog as $key => $value) {

//Only last part of RelVersion is needed
$version = end(explode( ‘.’, $value[‘RelVersion’]));
$line = $value[‘ReleaseNoteId’];

if(!in_array($value[‘MTabrivation’], $filter[‘program’])){
$filter[‘program’][] = $value[‘MTabrivation’];
}

if(!in_array($version, $filter[‘version’])){
$filter[‘version’][] = $version;
}

if(!in_array($value[‘RTTrelaseTypeTranslation’], $filter[‘type’])){
$filter[‘type’][] = $value[‘RTTrelaseTypeTranslation’];
}

//If there’s no entry for relVersion, we create it
if(!array_key_exists($version, $changelist)){
$changelist[$version]= [];

}

/***************************************

FILTERING DATA

*****************************************/

$show = true;
$oldTerm = ”;

//fetch only entries that has search term
if(isset($_POST[‘search’]) && $_POST[‘search’] != ” ){
$oldTerm = $_POST[‘search’];
$needle =trim(strtolower($_POST[‘search’]));

$result = strpos($value[‘RTdescription’], $needle);
if($result == null){
$show = false;
}

}

//only show the entries with the right version, type, or program
if(isset($_POST[‘version’]) && $_POST[‘version’] != 0 && $_POST[‘version’] != $version){
$show = false;

}

if(isset($_POST[‘type’]) && $_POST[‘type’] != ‘0’ && $_POST[‘type’] != $value[‘RTTrelaseTypeTranslation’]){
$show = false;

}

if(isset($_POST[‘program’]) && $_POST[‘program’] != ‘0’ && $_POST[‘program’] != $value[‘MTabrivation’]){
$show = false;
}

if($show){
//If a line hasn’t been seen before, it’s created
if(!array_key_exists($line, $changelist[$version])){
$changelist[$version][$line] = array(
‘description’=>$value[‘RTdescription’],
‘programs’ => [$value[‘MTabrivation’]],
‘type’ => $value[‘RTTrelaseTypeTranslation’]
);
}
else{
if(!in_array($value[‘MTabrivation’], $changelist[$version][$line][‘programs’])){
$changelist[$version][$line][‘programs’][] = $value[‘MTabrivation’]; //For some reason we have the same program multiple times.
}
}
}

}

/***************************************

SHOWING SEARCH-FORM

*****************************************/

echo “

“;
echo “

“;

echo “

“;
echo “

“;

echo “


“;
echo “

“;

echo “


“;
echo “

“;
echo “

“;
echo “


“;
echo “ “;
echo “ “;
echo “

“;
echo “

“;

/***************************************

SHOWING DATA

*****************************************/

//Show data
foreach($changelist AS $version=> $lines){
if(count($lines) > 0){
echo “

Version “.$version.”

“;
echo “

“;
echo “

“;
//Show each line in a version.

foreach($lines AS $subVersion => $line){
$programs = implode(‘, ‘, $line[‘programs’]);
echo “

“;
}

echo “

“;
echo “

Note Program Type
“.strip_tags($line[“description”], ““).” “.$programs.” “.$line[‘type’].”

“;
}
}

echo “

“;
echo ““;
echo ““;

echo ““;
echo ““;
[/insert_php]