| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- Lib::loadClass('FeatureAttrSelected');
- Lib::loadClass('FeatureAttrContextSelected');
- class Api_Process_P5_GetSelectedFeatures { // TODO: extends Api_ProcessBase
- static function run($args, $responseForm) {
- DBG::log($args, 'array', "Run WPS Process 'p5:getSelectedFeatures'");
- $typeName = (!empty($args['typeName'][0])) ? $args['typeName'][0] : '';
- if (!$typeName) throw new Api_OwsException("Missing value for 'typeName'", 501, null, 'MissingParameterValue', 'request');
- $listPrimaryKeys = (!empty($args['primaryKey'])) ? $args['primaryKey'] : [];
- if (empty($listPrimaryKeys)) throw new Api_OwsException("Missing value for 'primaryKey'", 501, null, 'MissingParameterValue', 'request');
- $context = (!empty($args['context'])) ? $args['context'][0] : '';
- if (!empty($context)) {
- $idContext = (is_numeric($context)) ? $context : FeatureAttrContextSelected::getIdContext($context);
- DBG::log($args, 'array', "Run WPS Process 'p5:getSelectedFeatures' with context '{$context}' (ID: {$idContext})");
- $listSelectedState = FeatureAttrContextSelected::getSelectState($idContext, $typeName, $listPrimaryKeys);
- $totalSelected = FeatureAttrContextSelected::getTotalSelected($idContext, $typeName);
- } else {
- $listSelectedState = FeatureAttrSelected::getSelectState($typeName, $listPrimaryKeys);
- $totalSelected = FeatureAttrSelected::getTotalSelected($typeName);
- }
- $idAcl = DB::getPDO()->fetchValue("
- select t.idZasob
- from `CRM_#CACHE_ACL_OBJECT` t
- where t.namespace = :namespace
- and t.idZasob IS NOT NULL
- ", [
- ':namespace' => Api_WfsNs::toNamespace($typeName),
- ]);
- header('Content-Type: application/json');
- echo json_encode([
- 'type' => "success",
- 'msg' => "done",
- 'body' => [
- 'selected' => $listSelectedState,
- 'totalSelected' => $totalSelected,
- 'tools' => $idAcl ? Route_UrlAction::getSelectedFeatureTools($idAcl, User::getLogin()) : [],
- ]
- ]);
- exit;
- }
- }
|