add pss #62
This commit is contained in:
58
geoapi/utility/ArrayManager.php
Normal file
58
geoapi/utility/ArrayManager.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace utiliy;
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
include_once PATH_UTILITTY . "/StringManager.php";
|
||||
|
||||
/**
|
||||
* The ArrayManager provides some array-methods
|
||||
* @author stubbfel
|
||||
* @since 26.06.2013
|
||||
*/
|
||||
class ArrayManager {
|
||||
|
||||
/**
|
||||
* Method remove all empty itmes
|
||||
* @param array $queryArgs
|
||||
* @return array
|
||||
*/
|
||||
public static function removeEmptyItmes($array) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (empty($value)) {
|
||||
unset($array[$key]);
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert a pidList to a where-string
|
||||
* @param array $pidList
|
||||
* @return string
|
||||
*/
|
||||
public static function toSqlWhereString($array, $operator = "", $fieldname = "") {
|
||||
$arrayStr = StringManager::$emptyString;
|
||||
foreach ($array as $value) {
|
||||
$arrayStr .= $fieldname . $value . $operator;
|
||||
}
|
||||
$result = substr($arrayStr, 0, strlen($arrayStr) - strlen($operator));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if all items of the pidlist are only digits
|
||||
* @param array $poly
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validIntList($list) {
|
||||
foreach ($list as $value) {
|
||||
|
||||
if (!ctype_digit($value) || PHP_INT_MAX < $value) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -37,6 +37,18 @@ class StringManager {
|
||||
public static function endsWith($haystack, $needle) {
|
||||
return (substr($haystack, -strlen($needle)) === $needle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method if the string is not a empty String (not only spaces and controlls)
|
||||
* @param string $string
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validSQLString($string) {
|
||||
if (!ctype_space($string) && !ctype_cntrl($string)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -15,50 +15,68 @@ class XmlManager {
|
||||
* a default xml document
|
||||
* @var xml-string
|
||||
*/
|
||||
public static $defaultXmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>";
|
||||
private static $defaultXmlDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>";
|
||||
|
||||
/**
|
||||
* Name for the place element
|
||||
* @var string
|
||||
*/
|
||||
public static $placeElementName = "place";
|
||||
private static $placeElementName = "place";
|
||||
|
||||
/**
|
||||
* Name for the placeinformation element
|
||||
* @var string
|
||||
*/
|
||||
public static $placeInfoElementName = "placeInformation";
|
||||
private static $placeInfoElementName = "placeInformation";
|
||||
|
||||
/**
|
||||
* Name for the placeserviceelement
|
||||
* @var string
|
||||
*/
|
||||
private static $placeServiceElementName = "placeService";
|
||||
|
||||
/**
|
||||
* Name for the placesap element
|
||||
* @var string
|
||||
*/
|
||||
private static $placeSapElementName = "sap";
|
||||
|
||||
/**
|
||||
* Name for the placerequest element
|
||||
* @var string
|
||||
*/
|
||||
private static $placeRequestElementName = "request";
|
||||
|
||||
/**
|
||||
* Name for the placeInfoName attribute
|
||||
* @var string
|
||||
*/
|
||||
public static $placeInfoName = "placeInformationName";
|
||||
private static $placeInfoName = "placeInformationName";
|
||||
|
||||
/**
|
||||
* Name for the place element
|
||||
* Name for the placeServiceName attribute
|
||||
* @var string
|
||||
*/
|
||||
public static $placeInfoValue = "placeInformationValue";
|
||||
private static $placeServiceName = "placeServiceName";
|
||||
|
||||
/**
|
||||
* Name for the placeid attribute
|
||||
* @var string
|
||||
*/
|
||||
public static $placeIdAttrName = "id";
|
||||
private static $placeIdAttrName = "id";
|
||||
|
||||
/**
|
||||
* Name for the parent attribute
|
||||
* @var string
|
||||
*/
|
||||
public static $parentIdAttrName = "parentId";
|
||||
private static $parentIdAttrName = "parentId";
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the sps service
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
public static function arrayToSpsXml($result = array()) {
|
||||
public static function arrayToSpsXml($result) {
|
||||
$xml = new \SimpleXMLElement(XmlManager::$defaultXmlDoc);
|
||||
|
||||
foreach ($result as $row) {
|
||||
@@ -70,26 +88,26 @@ class XmlManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the sps service
|
||||
* Method convert an array to a response xml for the pis service
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
public static function arrayToPisXml($result = array()) {
|
||||
public static function arrayToPisXml($result) {
|
||||
$xml = new \SimpleXMLElement(XmlManager::$defaultXmlDoc);
|
||||
$actPlace = 0;
|
||||
|
||||
|
||||
foreach ($result as $row) {
|
||||
|
||||
|
||||
// fetch the place id of the row
|
||||
$placeId = $row[\database\PisSqlManager::$placeId];
|
||||
|
||||
|
||||
// if the id is new -> add new place element
|
||||
if ($actPlace != $placeId) {
|
||||
$actPlace = $placeId;
|
||||
$place = $xml->addChild(XmlManager::$placeElementName);
|
||||
$place->addAttribute(XmlManager::$placeIdAttrName, $placeId);
|
||||
}
|
||||
|
||||
|
||||
// add placeinformation elment
|
||||
$placeInfo = $place->addChild(XmlManager::$placeInfoElementName, utf8_encode($row[\database\PisSqlManager::$infValue]));
|
||||
$placeInfo->addAttribute(XmlManager::$placeInfoName, $row[\database\PisSqlManager::$infName]);
|
||||
@@ -97,6 +115,36 @@ class XmlManager {
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the pss service
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
public static function arrayToPssXml($result) {
|
||||
$xml = new \SimpleXMLElement(XmlManager::$defaultXmlDoc);
|
||||
$actPlace = 0;
|
||||
|
||||
foreach ($result as $row) {
|
||||
|
||||
// fetch the place id of the row
|
||||
$placeId = $row[\database\PssSqlManager::$placeId];
|
||||
|
||||
// if the id is new -> add new place element
|
||||
if ($actPlace != $placeId) {
|
||||
$actPlace = $placeId;
|
||||
$place = $xml->addChild(XmlManager::$placeElementName);
|
||||
$place->addAttribute(XmlManager::$placeIdAttrName, $placeId);
|
||||
}
|
||||
|
||||
// add placeservice elment
|
||||
$placeSrv = $place->addChild(XmlManager::$placeServiceElementName);
|
||||
$placeSrv->addAttribute(XmlManager::$placeServiceName, $row[\database\PssSqlManager::$srvName]);
|
||||
$placeSrv->addChild(XmlManager::$placeSapElementName, $row[\database\PssSqlManager::$srvSap]);
|
||||
$placeSrv->addChild(XmlManager::$placeRequestElementName, $row[\database\PssSqlManager::$srvRequest]);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user