From 285f77ca8d1ca2f2113410b070d00b90a0443359 Mon Sep 17 00:00:00 2001 From: Ingo Kruetzen Date: Wed, 2 Oct 2024 14:48:45 +0200 Subject: [PATCH 1/3] add overallcount for addresses --- plugin/AddressList.php | 51 +++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/plugin/AddressList.php b/plugin/AddressList.php index 0ec43242d..57c640970 100644 --- a/plugin/AddressList.php +++ b/plugin/AddressList.php @@ -126,6 +126,9 @@ class AddressList /** @var AddressListEnvironment */ private $_pEnvironment = null; + /** @var APIClientActionGeneric */ + private $_pApiClientAction = null; + /** @var DataListViewAddress */ private $_pDataViewAddress = null; @@ -147,6 +150,9 @@ public function __construct(DataViewAddress $pDataViewAddress = null, AddressLis { $this->_pEnvironment = $pEnvironment ?? new AddressListEnvironmentDefault(); $this->_pDataViewAddress = $pDataViewAddress ?? new DataListViewAddress(0, 'default'); + $pSDKWrapper = $this->_pEnvironment->getSDKWrapper(); + $this->_pApiClientAction = new APIClientActionGeneric + ($pSDKWrapper, onOfficeSDK::ACTION_ID_READ, 'address'); } /** @@ -159,7 +165,7 @@ public function __construct(DataViewAddress $pDataViewAddress = null, AddressLis public function loadAddressesById(array $addressIds, array $fields) { $this->_pEnvironment->getFieldnames()->loadLanguage(); - $pApiCall = new APIClientActionGeneric + $this->_pApiClientAction = new APIClientActionGeneric ($this->_pEnvironment->getSDKWrapper(), onOfficeSDK::ACTION_ID_READ, 'address'); $parameters = [ 'recordids' => $addressIds, @@ -167,20 +173,20 @@ public function loadAddressesById(array $addressIds, array $fields) 'outputlanguage' => Language::getDefault(), 'formatoutput' => true, ]; - $parametersRaw = [ - 'recordids' => $addressIds, - 'data' => $this->_addressParametersForImageAlt, - 'outputlanguage' => Language::getDefault(), - 'formatoutput' => false, - ]; - $pApiCall->setParameters($parameters); - $pApiCall->addRequestToQueue()->sendRequests(); - - $records = $pApiCall->getResultRecords(); + $parametersRaw = [ + 'recordids' => $addressIds, + 'data' => $this->_addressParametersForImageAlt, + 'outputlanguage' => Language::getDefault(), + 'formatoutput' => false, + ]; + $this->_pApiClientAction->setParameters($parameters); + $this->_pApiClientAction->addRequestToQueue()->sendRequests(); + + $records = $this->_pApiClientAction->getResultRecords(); $this->fillAddressesById($records); $this->_pDataViewAddress->setFields($fields); - $this->addRawRecordsByAPICall(clone $pApiCall, $parametersRaw); + $this->addRawRecordsByAPICall(clone $this->_pApiClientAction, $parametersRaw); } /** @@ -205,21 +211,21 @@ public function loadAddresses(int $inputPage = 1) $apiOnlyFields = $pModifier->getAllAPIFields(); $parameters = $pDataListViewToApi->buildParameters($apiOnlyFields, $this->_pDataViewAddress, $newPage, true); - $pApiCall = new APIClientActionGeneric + $this->_pApiClientAction = new APIClientActionGeneric ($this->_pEnvironment->getSDKWrapper(), onOfficeSDK::ACTION_ID_READ, 'address'); - $pApiCall->setParameters($parameters); - $pApiCall->addRequestToQueue(); + $this->_pApiClientAction->setParameters($parameters); + $this->_pApiClientAction->addRequestToQueue(); $addressParameterRaws = $pDataListViewToApi->buildParameters($this->_addressParametersForImageAlt, $this->_pDataViewAddress, $newPage); - $this->addRawRecordsByAPICall(clone $pApiCall, $addressParameterRaws); + $this->addRawRecordsByAPICall(clone $this->_pApiClientAction, $addressParameterRaws); $this->getCountEstateForAddress($this->getAddressIds()); - $this->_records = $pApiCall->getResultRecords(); + $this->_records = $this->_pApiClientAction->getResultRecords(); $this->fillAddressesById($this->_records); - $resultMeta = $pApiCall->getResultMeta(); + $resultMeta = $this->_pApiClientAction->getResultMeta(); $numpages = ceil($resultMeta['cntabsolute']/$this->_pDataViewAddress->getRecordsPerPage()); $multipage = $numpages > 1; @@ -339,6 +345,15 @@ public function getAddressById($id): array return $this->_addressesById[$id] ?? []; } + /** + * @return int + * @throws API\ApiClientException + */ + public function getAddressOverallCount() + { + return $this->_pApiClientAction->getResultMeta()['cntabsolute']; + } + /** * @param bool $raw * @return array From c0d086a29c7139cb5c910191dfcb06dc5fd200a3 Mon Sep 17 00:00:00 2001 From: Ingo Kruetzen Date: Mon, 7 Oct 2024 17:22:33 +0200 Subject: [PATCH 2/3] remove douplicate code --- SDK | 2 +- plugin/AddressList.php | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/SDK b/SDK index 102921b2e..b5513ee2c 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit 102921b2e3ce8c8ae330246ea53f7c0b099d1c9b +Subproject commit b5513ee2c1ca80e37c9a29cca0c7d4cbcf967fd9 diff --git a/plugin/AddressList.php b/plugin/AddressList.php index 57c640970..70788f0b1 100644 --- a/plugin/AddressList.php +++ b/plugin/AddressList.php @@ -165,8 +165,6 @@ public function __construct(DataViewAddress $pDataViewAddress = null, AddressLis public function loadAddressesById(array $addressIds, array $fields) { $this->_pEnvironment->getFieldnames()->loadLanguage(); - $this->_pApiClientAction = new APIClientActionGeneric - ($this->_pEnvironment->getSDKWrapper(), onOfficeSDK::ACTION_ID_READ, 'address'); $parameters = [ 'recordids' => $addressIds, 'data' => $fields, @@ -211,8 +209,6 @@ public function loadAddresses(int $inputPage = 1) $apiOnlyFields = $pModifier->getAllAPIFields(); $parameters = $pDataListViewToApi->buildParameters($apiOnlyFields, $this->_pDataViewAddress, $newPage, true); - $this->_pApiClientAction = new APIClientActionGeneric - ($this->_pEnvironment->getSDKWrapper(), onOfficeSDK::ACTION_ID_READ, 'address'); $this->_pApiClientAction->setParameters($parameters); $this->_pApiClientAction->addRequestToQueue(); From ab1fa7387ae347faa544f7b0865c3e11f0b65fa9 Mon Sep 17 00:00:00 2001 From: Ingo Kruetzen Date: Mon, 7 Oct 2024 17:57:48 +0200 Subject: [PATCH 3/3] revert SDK --- SDK | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK b/SDK index b5513ee2c..102921b2e 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit b5513ee2c1ca80e37c9a29cca0c7d4cbcf967fd9 +Subproject commit 102921b2e3ce8c8ae330246ea53f7c0b099d1c9b