|
|
@@ -197,6 +197,7 @@ class Api_WfsDataServer extends Api_WfsServerBase {
|
|
|
|
|
|
|
|
|
header('Content-type: application/xml; charset=utf-8');
|
|
|
+ // echo "\$args['filterFields']: ";print_r($args['filterFields']);echo "\$searchParams['cols']: ";print_r($searchParams['cols']);die("");
|
|
|
$xmlWriter = new Core_XmlWriter();
|
|
|
$xmlWriter->openUri('php://output');
|
|
|
// $xmlWriter->openMemory();// DBG
|
|
|
@@ -318,4 +319,51 @@ class Api_WfsDataServer extends Api_WfsServerBase {
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
+ public function GetBlobAction() {
|
|
|
+ $namespace = V::get('namespace', '', $_GET);
|
|
|
+ if (!$namespace) throw new Exception("Missing namespace");
|
|
|
+ $primaryKey = V::get('primaryKey', 0, $_GET, 'int');
|
|
|
+ if ($primaryKey < 0) throw new Exception("Missing primaryKey");
|
|
|
+ $fieldName = V::get('fieldName', '', $_GET);
|
|
|
+ if (!$fieldName) throw new Exception("Missing fieldName");
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace($namespace);
|
|
|
+ $idDatabase = $acl->getDatabaseID();
|
|
|
+ $rootTableName = $acl->getRootTableName();
|
|
|
+ $sqlFieldName = $acl->getSqlFieldName($fieldName);
|
|
|
+ $sqlPkField = $acl->getSqlPrimaryKeyField();
|
|
|
+
|
|
|
+ $item = $acl->getItem($primaryKey);
|
|
|
+ if (!$item) throw new Exception("Record not exists '{$primaryKey}'");
|
|
|
+ if (!$acl->canReadObjectField($fieldName, $item)) throw new Exception("Access Denied for field '{$fieldName}'");
|
|
|
+
|
|
|
+
|
|
|
+ $pdo = DB::getPDO($idDatabase);
|
|
|
+ switch ($pdo->getType()) {
|
|
|
+ case 'mysql': {
|
|
|
+ $sql = "
|
|
|
+ select {$sqlFieldName}
|
|
|
+ from {$rootTableName}
|
|
|
+ where `{$sqlPkField}` = :pk
|
|
|
+ limit 1
|
|
|
+ ";
|
|
|
+ $sth = $pdo->prepare($sql);
|
|
|
+ $sth->bindValue(':pk', $primaryKey, PDO::PARAM_STR);
|
|
|
+ $sth->execute();
|
|
|
+ $sth->bindColumn(1, $content, PDO::PARAM_LOB);
|
|
|
+ $sth->fetch();
|
|
|
+ } break;
|
|
|
+ default: throw new Exception("Not implemented database type '" . $pdo->getType() . "' in GetBlob");
|
|
|
+ }
|
|
|
+ if (empty($content)) throw new Exception("Brak danych");
|
|
|
+ $finfo = finfo_open(FILEINFO_MIME);
|
|
|
+ $mime = finfo_buffer($finfo, $content);
|
|
|
+ // $mime = "application/octet-stream";
|
|
|
+ header("Content-type: {$mime}");
|
|
|
+ // header("Content-Disposition: attachment; filename=\"{$fileName}\";" );
|
|
|
+ // header("Content-Transfer-Encoding: binary");
|
|
|
+ // header("Content-Length: ".strlen($content));
|
|
|
+ print $content;
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
}
|