finish #64
This commit is contained in:
@@ -23,9 +23,11 @@ abstract class Api extends \Slim\Slim {
|
||||
/**
|
||||
* Default-Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct() {
|
||||
$this->connect();
|
||||
parent::__construct();
|
||||
|
||||
// set content type td xml
|
||||
$this->contentType("Content-type: application/xml;charset=utf-8");
|
||||
}
|
||||
|
||||
@@ -33,6 +35,8 @@ abstract class Api extends \Slim\Slim {
|
||||
* Default-DeConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
|
||||
// destroy the sqlManager
|
||||
$this->sqlManager->closeConnection();
|
||||
unset($this->sqlManager);
|
||||
$this->sqlManager = null;
|
||||
|
||||
@@ -9,7 +9,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php";
|
||||
require_once PATH_API . "/Api.php";
|
||||
|
||||
/**
|
||||
* This class provides some spezial SpsAPI methods
|
||||
* This class provides some spezial PisAPI methods
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php";
|
||||
require_once PATH_API . "/Api.php";
|
||||
|
||||
/**
|
||||
* This class provides some spezial SpsAPI methods
|
||||
* This class provides some spezial PssAPI methods
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
*/
|
||||
@@ -52,7 +52,6 @@ class PssApi extends Api {
|
||||
|
||||
if (count($pidList) < $this->maxPid) {
|
||||
$result = $this->sqlManager->sendPssQuery($pidList);
|
||||
|
||||
return \utiliy\XmlManager::arrayToPssXml($result);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -21,7 +21,7 @@ class SpsApi extends Api {
|
||||
public static $routeParameterAlias = "/alias/:alias";
|
||||
|
||||
/**
|
||||
* Route string for the alias paramter
|
||||
* Route string for the domain paramter
|
||||
* @var string
|
||||
*/
|
||||
public static $routeParameterDomain = "/domain/:domain";
|
||||
@@ -116,7 +116,6 @@ class SpsApi extends Api {
|
||||
public function __construct() {
|
||||
$this->sqlManager = new \database\SpsSqlManager();
|
||||
parent::__construct();
|
||||
$this->contentType("Content-type: application/xml;charset=utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,6 +141,8 @@ class SpsApi extends Api {
|
||||
* @return querry result as xml
|
||||
*/
|
||||
public function sendSpsCoordinateQuery($queryArgs) {
|
||||
|
||||
// check arguments of the query
|
||||
if (!array_key_exists(SpsApi::$keyLong, $queryArgs) || !array_key_exists(SpsApi::$keyLat, $queryArgs)) {
|
||||
return null;
|
||||
}
|
||||
@@ -152,7 +153,10 @@ class SpsApi extends Api {
|
||||
return null;
|
||||
}
|
||||
|
||||
// build a request polygon
|
||||
$queryArgs[SpsApi::$keyPoly] = $this->createPolygon($latitude, $longitude, $this->range);
|
||||
|
||||
// send querry
|
||||
$result = $this->sqlManager->sendSpsCoordinateQuery($queryArgs);
|
||||
return \utiliy\XmlManager::arrayToSpsXml($result);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace config;
|
||||
|
||||
/**
|
||||
* This clas is an container for the DBConf
|
||||
*
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
*/
|
||||
class DBConfig {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ include_once PATH_UTILITTY . "/StringManager.php";
|
||||
require_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
* Description of ZisSqlManager
|
||||
* Description of PisSqlManager
|
||||
*
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
@@ -58,7 +58,7 @@ class PisSqlManager extends SQLManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default-DEConstructor
|
||||
* Default-DeConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
|
||||
@@ -7,7 +7,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php";
|
||||
require_once PATH_DATABASE . "/SqlManager.php";
|
||||
|
||||
/**
|
||||
* Description of ZisSqlManager
|
||||
* Description of PssSqlManager
|
||||
*
|
||||
* @author stubbfel
|
||||
* @since 20.06.2013
|
||||
@@ -64,7 +64,7 @@ class PssSqlManager extends SQLManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default-DEConstructor
|
||||
* Default-DeConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
parent::__destruct();
|
||||
|
||||
@@ -209,7 +209,8 @@ class SpsSqlManager extends SQLManager {
|
||||
* @return boolean
|
||||
*/
|
||||
private function validPolyString($poly) {
|
||||
if (\utiliy\StringManager::validSQLString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr) && \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) {
|
||||
if (\utiliy\StringManager::validSQLString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr)
|
||||
&& \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -74,15 +74,15 @@ abstract class SqlManager {
|
||||
* Default-DEConstructor
|
||||
*/
|
||||
public function __destruct() {
|
||||
|
||||
// close connection
|
||||
$this->closeConnection();
|
||||
|
||||
// delete connection parameter
|
||||
unset($this->serverAddress);
|
||||
unset($this->dbName);
|
||||
unset($this->userName);
|
||||
unset($this->userPW);
|
||||
$this->serverAddress = null;
|
||||
$this->dbName = null;
|
||||
$this->userName = null;
|
||||
$this->userPW = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,17 +116,24 @@ abstract class SqlManager {
|
||||
* @return result[num][assoc]
|
||||
*/
|
||||
protected function query($query) {
|
||||
|
||||
// send error
|
||||
$mysqlResult = mysql_query($query, $this->link);
|
||||
if (!$mysqlResult) {
|
||||
exit("Query error: " . mysql_error());
|
||||
}
|
||||
|
||||
// fetch result
|
||||
$rowNums = mysql_num_rows($mysqlResult);
|
||||
$result = array();
|
||||
for ($i = 0; $i < $rowNums; $i++) {
|
||||
$row = mysql_fetch_assoc($mysqlResult);
|
||||
$result[$i] = $row;
|
||||
}
|
||||
|
||||
// call gc
|
||||
mysql_free_result($mysqlResult);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ require_once PATH_API . "/PisApi.php";
|
||||
// instance a new api
|
||||
$app = new \api\PisApi();
|
||||
|
||||
// HTTP-Get-Method
|
||||
$app->get(\api\PisApi::$routeParameterPids, function ($pid) use ($app) {
|
||||
echo $app->sendPisQuery($pid);
|
||||
});
|
||||
|
||||
@@ -6,9 +6,11 @@ require_once PATH_API . "/PssApi.php";
|
||||
// instance a new api
|
||||
$app = new \api\PssApi();
|
||||
|
||||
// HTTP-Get-Method
|
||||
$app->get(\api\PssApi::$routeParameterPids, function ($pid) use ($app) {
|
||||
echo $app->sendPssQuery($pid);
|
||||
});
|
||||
|
||||
$app->run();
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,8 +6,7 @@ require_once PATH_API . "/SpsApi.php";
|
||||
// instance a new api
|
||||
$app = new \api\SpsApi();
|
||||
|
||||
// declare the get-methods
|
||||
// declare the get-methods
|
||||
// HTTP-Get-Methods
|
||||
$app->get(\api\SpsApi::$routeParameterAlias, function ($alias) use ($app) {
|
||||
$args = array();
|
||||
$args[\api\SpsApi::$keyAlias] = $alias;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace utiliy;
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
@@ -10,9 +11,9 @@ include_once PATH_UTILITTY . "/StringManager.php";
|
||||
* @since 26.06.2013
|
||||
*/
|
||||
class ArrayManager {
|
||||
|
||||
|
||||
/**
|
||||
* Method remove all empty itmes
|
||||
* Method remove all empty itmes of an array
|
||||
* @param array $queryArgs
|
||||
* @return array
|
||||
*/
|
||||
@@ -24,9 +25,9 @@ class ArrayManager {
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method convert a pidList to a where-string
|
||||
* Method convert an array to a where-string like $fieldname = $array[i] $operator
|
||||
* @param array $pidList
|
||||
* @return string
|
||||
*/
|
||||
@@ -38,9 +39,9 @@ class ArrayManager {
|
||||
$result = substr($arrayStr, 0, strlen($arrayStr) - strlen($operator));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check if all items of the pidlist are only digits
|
||||
|
||||
/**
|
||||
* Method check if all items of the array are only digits and < PHP_INT_MAX
|
||||
* @param array $poly
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -53,6 +54,7 @@ class ArrayManager {
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace utiliy;
|
||||
|
||||
include_once "../../global.inc.php";
|
||||
@@ -9,36 +10,34 @@ include_once "../../global.inc.php";
|
||||
* @since 25.06.2013
|
||||
*/
|
||||
class StringManager {
|
||||
|
||||
|
||||
/**
|
||||
* A Constant vor an emptystring like \"\"
|
||||
* A Constant vor an emptystring like ""
|
||||
* @var string
|
||||
*/
|
||||
public static $emptyString = "";
|
||||
|
||||
|
||||
/**
|
||||
* Method check if a certain string start with a certain sustring
|
||||
* Method check if a certain string start with a certain substring
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @return boolean
|
||||
*/
|
||||
public static function startsWith($haystack, $needle) {
|
||||
public static function startsWith($haystack, $needle) {
|
||||
return !strncmp($haystack, $needle, strlen($needle));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method check if a certain string end with a certain sustring
|
||||
* Method check if a certain string end with a certain substring
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @return boolean
|
||||
*/
|
||||
public static function endsWith($haystack, $needle) {
|
||||
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
|
||||
@@ -49,6 +48,7 @@ class StringManager {
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -36,34 +36,34 @@ class XmlManager {
|
||||
private static $placeServiceElementName = "placeService";
|
||||
|
||||
/**
|
||||
* Name for the placesap element
|
||||
* Name for the ssap element
|
||||
* @var string
|
||||
*/
|
||||
private static $placeSapElementName = "sap";
|
||||
|
||||
/**
|
||||
* Name for the placerequest element
|
||||
* Name for the request element
|
||||
* @var string
|
||||
*/
|
||||
private static $placeRequestElementName = "request";
|
||||
|
||||
/**
|
||||
* Name for the placeInfoName attribute
|
||||
* Name for the placeInfoName attribute
|
||||
* @var string
|
||||
*/
|
||||
private static $placeInfoName = "placeInformationName";
|
||||
private static $placeInfoAttrName = "placeInformationName";
|
||||
|
||||
/**
|
||||
* Name for the placeServiceName attribute
|
||||
* @var string
|
||||
*/
|
||||
private static $placeServiceName = "placeServiceName";
|
||||
private static $placeServiceAttrName = "placeServiceName";
|
||||
|
||||
/**
|
||||
* Name for the placeid attribute
|
||||
* @var string
|
||||
*/
|
||||
private static $placeIdAttrName = "id";
|
||||
private static $placeIdAttrName = "id";
|
||||
|
||||
/**
|
||||
* Name for the parent attribute
|
||||
@@ -73,6 +73,8 @@ class XmlManager {
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the sps service
|
||||
* <place id ="4711" parentID=%0815"/>
|
||||
*
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
@@ -88,7 +90,11 @@ class XmlManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the pis service
|
||||
* Method convert an array to a response xml for the pis service like
|
||||
* <place id ="4711">
|
||||
* <placeInformation placeInformationName = "key">Value</placeinformation>
|
||||
* </place>
|
||||
*
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
@@ -110,13 +116,20 @@ class XmlManager {
|
||||
|
||||
// add placeinformation elment
|
||||
$placeInfo = $place->addChild(XmlManager::$placeInfoElementName, utf8_encode($row[\database\PisSqlManager::$infValue]));
|
||||
$placeInfo->addAttribute(XmlManager::$placeInfoName, $row[\database\PisSqlManager::$infName]);
|
||||
$placeInfo->addAttribute(XmlManager::$placeInfoAttrName, $row[\database\PisSqlManager::$infName]);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method convert an array to a response xml for the pss service
|
||||
* <place id ="4711">
|
||||
* <placeService placeServiceName = "key">
|
||||
* <sap>sapValue</sap>
|
||||
* <request>reqVaule</request>
|
||||
* </placeService>
|
||||
* </place>
|
||||
*
|
||||
* @param array[num][assoc] $result
|
||||
* @return xml-string
|
||||
*/
|
||||
@@ -138,7 +151,7 @@ class XmlManager {
|
||||
|
||||
// add placeservice elment
|
||||
$placeSrv = $place->addChild(XmlManager::$placeServiceElementName);
|
||||
$placeSrv->addAttribute(XmlManager::$placeServiceName, $row[\database\PssSqlManager::$srvName]);
|
||||
$placeSrv->addAttribute(XmlManager::$placeServiceAttrName, $row[\database\PssSqlManager::$srvName]);
|
||||
$placeSrv->addChild(XmlManager::$placeSapElementName, $row[\database\PssSqlManager::$srvSap]);
|
||||
$placeSrv->addChild(XmlManager::$placeRequestElementName, $row[\database\PssSqlManager::$srvRequest]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user