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 * 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 * @param array[num][assoc] $result
* @return json-string * @return json-string
*/ */
public static function arrayToSpsJson($result) { public static function arrayToSpsJson($result) {
$places = array(); $places = array();
foreach ($result as $row) { foreach ($result as $row) {
$place = array(self::$placeIdName => $row[\database\SpsSqlManager::$placeId], $place = array(self::$parentIdName => $row[\database\SpsSqlManager::$parentId], self::$refpointName => $row[\database\SpsSqlManager::$refpoint]);
self::$parentIdName => $row[\database\SpsSqlManager::$parentId], $places[$row[\database\SpsSqlManager::$placeId]] = $place;
self::$refpointName => $row[\database\SpsSqlManager::$refpoint]);
array_push($places, $place);
} }
return json_encode($places); return json_encode($places);
} }
@@ -84,68 +82,29 @@ class JsonManager implements SerialManager {
* @return json-string * @return json-string
*/ */
public static function arrayToPisJson($result) { public static function arrayToPisJson($result) {
$actPlace = 0;
$infos = array(); $infos = array();
$place = null;
foreach ($result as $row) { foreach ($result as $row) {
// fetch the place id of the row // fetch the place id of the row
$placeId = $row[\database\PisSqlManager::$placeId]; $placeId = $row[\database\PisSqlManager::$placeId];
$infos[$placeId][$row[\database\PisSqlManager::$infName]] = utf8_encode($row[\database\PisSqlManager::$infValue]);
// 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);
}
array_push($infos, $place);
return json_encode($infos); return json_encode($infos);
} }
/** /**
* Method convert an array to a response json for the pss service * 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 * @param array[num][assoc] $result
* @return Json-string * @return Json-string
*/ */
public static function arrayToPssJson($result) { public static function arrayToPssJson($result) {
$actPlace = 0;
$services = array(); $services = array();
$place = null;
foreach ($result as $row) { foreach ($result as $row) {
// fetch the place id of the row // fetch the place id of the row
$placeId = $row[\database\PssSqlManager::$placeId]; $placeId = $row[\database\PssSqlManager::$placeId];
$placeSrv = array(self::$placeSapName => $row[\database\PssSqlManager::$srvSap], self::$placeRequestName => $row[\database\PssSqlManager::$srvRequest]);
// if the id is new -> add new place item $services[$placeId][$row[\database\PssSqlManager::$srvName]] = $placeSrv;
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);
}
array_push($services, $place);
return json_encode($services); return json_encode($services);
} }