88 lines
2.0 KiB
PHP
88 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace api;
|
|
|
|
include_once "../../global.inc.php";
|
|
include_once PATH_DATABASE . "/PisSqlManager.php";
|
|
include_once PATH_UTILITTY . "/ArrayManager.php";
|
|
require_once PATH_API . "/Api.php";
|
|
|
|
/**
|
|
* This class provides some spezial PisAPI methods
|
|
* @author stubbfel
|
|
* @since 20.06.2013
|
|
*/
|
|
class PisApi extends Api {
|
|
|
|
/**
|
|
* Route string for the pids paramter
|
|
* @var string
|
|
*/
|
|
public static $routeParameterPids = "/pid/:pid+";
|
|
|
|
/**
|
|
* Route string for the iNames paramter
|
|
* @var string
|
|
*/
|
|
public static $routeParameterINames = "/iname/:iname+";
|
|
|
|
/**
|
|
* Keyword for pidList arguments
|
|
* @var string
|
|
*/
|
|
public static $keyPidList = "pidList";
|
|
|
|
/**
|
|
* Keyword for iNameList arguments
|
|
* @var string
|
|
*/
|
|
public static $keyINameList = "iNameList";
|
|
|
|
/**
|
|
* max number of pid for each query
|
|
* @var int
|
|
*/
|
|
private static $maxPid = 50;
|
|
|
|
/**
|
|
* Constructor
|
|
* @param array[assoc] $headers - RequestHeader
|
|
*/
|
|
public function __construct($headers = array()) {
|
|
$this->sqlManager = new \database\PisSqlManager();
|
|
parent::__construct($headers);
|
|
}
|
|
|
|
/**
|
|
* Default-DeConstructor
|
|
*/
|
|
public function __destruct() {
|
|
parent::__destruct();
|
|
}
|
|
|
|
/**
|
|
* Method start a pis-query
|
|
* @param array $queryArgs
|
|
* @return query result as xml
|
|
*/
|
|
public function sendPisQuery($queryArgs) {
|
|
$pidList = \utiliy\ArrayManager::removeEmptyItmes($queryArgs[self::$keyPidList]);
|
|
|
|
if (array_key_exists(self::$keyINameList, $queryArgs)) {
|
|
$iNameList = \utiliy\ArrayManager::removeEmptyItmes($queryArgs[self::$keyINameList]);
|
|
} else {
|
|
$iNameList = array();
|
|
}
|
|
|
|
if (count($pidList) < self::$maxPid) {
|
|
$result = $this->sqlManager->sendPisQuery($pidList, $iNameList);
|
|
|
|
return $this->serialManager->arrayToPis($result);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|