Skip to content

Commit 4d76b75

Browse files
committed
Ver.26 FileMaker API for PHP compatible mode.
1 parent 1de5786 commit 4d76b75

8 files changed

Lines changed: 57 additions & 20 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# FMDataAPI Ver.25 [![Build Status](https://github.com/msyk/FMDataAPI/actions/workflows/php.yml/badge.svg)](https://github.com/msyk/FMDataAPI/actions/workflows/php.yml)
1+
# FMDataAPI Ver.26 [![Build Status](https://github.com/msyk/FMDataAPI/actions/workflows/php.yml/badge.svg)](https://github.com/msyk/FMDataAPI/actions/workflows/php.yml)
22

33
by Masayuki Nii (nii@msyk.net)
44

@@ -64,7 +64,7 @@ FMDataAPI has "composer.json," so you can add your composer.json file in your pr
6464
...
6565
"require": {
6666
...
67-
"inter-mediator/fmdataapi":"25"
67+
"inter-mediator/fmdataapi":"26"
6868
} ...
6969
```
7070

@@ -162,6 +162,8 @@ MIT License
162162
Bug fix for portal limit parameter. Thanks to tkuijer.
163163
- 2022-03-24: [Ver.25]
164164
Add methods(getFirstRecord, getLastRecord, getRecords) to the FileMakerRelation class.
165+
- 2022-03-26: [Ver.26]
166+
Add methods(setFieldHTMLEncoding, getFieldHTMLEncoding) to the FMDataAPI class. These is going to use for comatibility mode of FileMaker API for PHP.
165167

166168
## API Differences between ver.8 and 7.
167169
### FMDataAPI class

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inter-mediator/fmdataapi",
3-
"version": "25",
3+
"version": "26",
44
"time": "2022-03-24",
55
"repositories": [
66
{

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FMDataAPI.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @link https://github.com/msyk/FMDataAPI GitHub Repository
1414
* @property-read FileMakerLayout $<<layout_name>> Returns the FileMakerLayout object from the layout named with the property.
1515
* If the layout doesn't exist, no error arises here. Any errors might arise on methods of FileMakerLayout class.
16-
* @version 25
16+
* @version 26
1717
* @author Masayuki Nii <nii@msyk.net>
1818
* @copyright 2017-2022 Masayuki Nii (Claris FileMaker is registered trademarks of Claris International Inc. in the U.S. and other countries.)
1919
* @source 1 100000 The source code.
@@ -113,7 +113,8 @@ public function setDebug($value)
113113
* Set the cURL communication timeout in seconds
114114
* @param int $timeout
115115
*/
116-
public function setTimeout($timeout) {
116+
public function setTimeout($timeout)
117+
{
117118
$this->provider->timeout = $timeout;
118119
}
119120

@@ -144,6 +145,29 @@ public function setCertValidating($value)
144145
$this->provider->isCertVaridating = $value;
145146
}
146147

148+
/**
149+
* Set to true if the return value of the field() method uses htmlspecialchars function.
150+
* The default value is FALSE. The nostalgic FileMaker API for PHP was returning htmlspecialchars value of the field.
151+
* If we want to get the row field data, we had to call getFieldUnencoded method. If this property set to true,
152+
* FileMakerRelation class's field method (including describing field name directly) returns the value processed
153+
* with htmlspecialchars. This means kind of compatible mode of FileMaker API for PHP.
154+
* This feature works whole the FMDataAPI library.
155+
* @param bool $value Turn on to verify the certificate if the value is true.
156+
*/
157+
public function setFieldHTMLEncoding($value)
158+
{
159+
$this->provider->fieldHTMLEncoding = $value;
160+
}
161+
162+
/**
163+
* Detect the return value of the field() method uses htmlspecialchars function or not.
164+
* @return bool The result.
165+
*/
166+
public function getFieldHTMLEncoding($value)
167+
{
168+
return $this->provider->fieldHTMLEncoding;
169+
}
170+
147171
/**
148172
* Set session token
149173
* @param string $value The session token.

src/Supporting/CommunicationProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @package INTER-Mediator\FileMakerServer\RESTAPI
99
* @link https://github.com/msyk/FMDataAPI GitHub Repository
10-
* @version 25
10+
* @version 26
1111
* @author Masayuki Nii <nii@msyk.net>
1212
* @copyright 2017-2022 Masayuki Nii (Claris FileMaker is registered trademarks of Claris International Inc. in the U.S. and other countries.)
1313
*/
@@ -205,6 +205,11 @@ class CommunicationProvider
205205
* @ignore
206206
*/
207207
public $timeout;
208+
/**
209+
* @var
210+
* @ignore
211+
*/
212+
public $fieldHTMLEncoding = false;
208213

209214
/**
210215
* CommunicationProvider constructor.
@@ -542,7 +547,7 @@ private function getOAuthIdentifier($provider)
542547
{
543548
try {
544549
$this->callRestAPI([], [
545-
"trackingID" => rand(10000000,99999999),
550+
"trackingID" => rand(10000000, 99999999),
546551
"provider" => $provider,
547552
"address" => "127.0.0.1",
548553
"X-FMS-OAuth-AuthType" => 2

src/Supporting/FileMakerLayout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @package INTER-Mediator\FileMakerServer\RESTAPI
1212
* @link https://github.com/msyk/FMDataAPI GitHub Repository
13-
* @version 25
13+
* @version 26
1414
* @author Masayuki Nii <nii@msyk.net>
1515
* @copyright 2017-2022 Masayuki Nii (Claris FileMaker is registered trademarks of Claris International Inc. in the U.S. and other countries.)
1616
*/

src/Supporting/FileMakerRelation.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @property string $<<field_name>> The field value named as the property name.
1515
* @property FileMakerRelation $<<portal_name>> FileMakerRelation object associated with the property name.
1616
* The table occurrence name of the portal can be the 'portal_name,' and also the object name of the portal.
17-
* @version 25
17+
* @version 26
1818
* @author Masayuki Nii <nii@msyk.net>
1919
* @copyright 2017-2022 Masayuki Nii (Claris FileMaker is registered trademarks of Claris International Inc. in the U.S. and other countries.)
2020
*/
@@ -59,10 +59,12 @@ class FileMakerRelation implements Iterator
5959
/**
6060
* FileMakerRelation constructor.
6161
*
62-
* @param $data
62+
* @param array<object> $responseData
63+
* @param object $infoData
6364
* @param string $result
6465
* @param int $errorCode
65-
* @param null $portalName
66+
* @param string $portalName
67+
* @param CommunicationProvider $provider
6668
*
6769
* @ignore
6870
*/
@@ -354,6 +356,8 @@ public function getPortalNames()
354356
*
355357
* @return string|FileMakerRelation The field value as string, or the FileMakerRelation object of the portal.
356358
* @throws Exception The field specified in parameters doesn't exist.
359+
* @see FMDataAPI::setFieldHTMLEncoding() Compatible mode for FileMaker API for PHP.
360+
*
357361
*/
358362
public function field($name, $toName = null)
359363
{
@@ -411,7 +415,9 @@ public function field($name, $toName = null)
411415
if (is_null($value)) {
412416
throw new \Exception("Field {$fieldName} doesn't exist.");
413417
}
414-
418+
if ($this->restAPI && $this->restAPI->fieldHTMLEncoding && !is_object($value)) {
419+
$value = htmlspecialchars($value);
420+
}
415421
return $value;
416422
}
417423

test/.phpunit.result.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":1,"defects":[],"times":{"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_initializeObjects":0.005,"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_Query":0.013,"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_ErrorQuery":0.002}}
1+
{"version":1,"defects":[],"times":{"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_initializeObjects":0.005,"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_Query":0.019,"INTERMediator\\FileMakerServer\\RESTAPI\\FMDataAPIUnitTest::test_ErrorQuery":0.001}}

0 commit comments

Comments
 (0)