Merge branch 'hotfix/#105'

This commit is contained in:
stubbfel
2013-07-11 12:53:49 +02:00

View File

@@ -62,17 +62,15 @@ class JsonManager implements SerialManager {
/**
* Method convert an array to a response json for the sps service
* @example [{"id":"121799787","parentId":null}]
* @example {"127003463":{"name":"Informations-, Kommunikations- und Medienzentrum","typ":"library"},"129258513":{"name":"Wohnheim Papitzer Stra\u00dfe 4\/5","typ":"guest_house"}}
* @param array[num][assoc] $result
* @return json-string
*/
public static function arrayToSpsJson($result) {
$places = array();
foreach ($result as $row) {
$place = array(self::$placeIdName => $row[\database\SpsSqlManager::$placeId],
self::$parentIdName => $row[\database\SpsSqlManager::$parentId],
self::$refpointName => $row[\database\SpsSqlManager::$refpoint]);
array_push($places, $place);
$place = array(self::$parentIdName => $row[\database\SpsSqlManager::$parentId], self::$refpointName => $row[\database\SpsSqlManager::$refpoint]);
$places[$row[\database\SpsSqlManager::$placeId]] = $place;
}
return json_encode($places);
}
@@ -84,68 +82,29 @@ class JsonManager implements SerialManager {
* @return json-string
*/
public static function arrayToPisJson($result) {
$actPlace = 0;
$infos = array();
$place = null;
$infos = array();
foreach ($result as $row) {
// fetch the place id of the row
$placeId = $row[\database\PisSqlManager::$placeId];
// if the id is new -> add new place item
if ($actPlace != $placeId) {
if ($place) {
array_push($infos, $place);
}
$actPlace = $placeId;
$place = array(self::$placeIdName => $placeId);
}
// add placeinformation item
$placeInfo = array(self::$placeInfoName => $row[\database\PisSqlManager::$infName], self::$placeInfoValueName => utf8_encode($row[\database\PisSqlManager::$infValue]));
array_push($place, $placeInfo);
$placeId = $row[\database\PisSqlManager::$placeId];
$infos[$placeId][$row[\database\PisSqlManager::$infName]] = utf8_encode($row[\database\PisSqlManager::$infValue]);
}
array_push($infos, $place);
return json_encode($infos);
}
/**
* Method convert an array to a response json for the pss service
*
* @example {"1":{"website":{"sap":"http:\/\/www.","request":"tu-cottbus.de\/btu\/"}},"2":{"website":{"sap":"http:\/\/www.","request":"hs-lausitz.de\/start.html"}}}
* @param array[num][assoc] $result
* @return Json-string
*/
public static function arrayToPssJson($result) {
$actPlace = 0;
$services = array();
$place = null;
foreach ($result as $row) {
// fetch the place id of the row
$placeId = $row[\database\PssSqlManager::$placeId];
// if the id is new -> add new place item
if ($actPlace != $placeId) {
if ($place) {
array_push($services, $place);
}
$actPlace = $placeId;
$place = array(self::$placeIdName => $placeId);
}
// add placeservice items
$placeSrv = array(self::$placeServiceName => $row[\database\PisSqlManager::$srvName],
self::$placeSapName => $row[\database\PisSqlManager::$srvSap],
self::$placeRequestName => $row[\database\PisSqlManager::$srvRequest]);
array_push($place, $placeSrv);
$placeSrv = array(self::$placeSapName => $row[\database\PssSqlManager::$srvSap], self::$placeRequestName => $row[\database\PssSqlManager::$srvRequest]);
$services[$placeId][$row[\database\PssSqlManager::$srvName]] = $placeSrv;
}
array_push($services, $place);
return json_encode($services);
}