Skip to content

Commit 30bd749

Browse files
committed
Doc
1 parent 96a1137 commit 30bd749

File tree

8 files changed

+58
-13
lines changed

8 files changed

+58
-13
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# IIIF Manifest Reader for PHP
22

3-
Read IIIF Presentation API resources into PHP objects that offer some convenient data extraction methods.
3+
Read [IIIF](https://iiif.io/) Presentation API resources into PHP objects that offer some convenient data extraction methods.
44

55
Requires at least PHP 5.6.
66

7-
IIIF Presentation API support is primarily implemented for version 2.1, with some rudimentary support for Presentation API 3.0 and Metadata API 1.0.
7+
IIIF Presentation API support is primarily implemented for version [2.1](https://iiif.io/api/presentation/2.1/), with some rudimentary support for [Presentation API 3.0](https://iiif.io/api/presentation/3.0/) and [Metadata API 1.0](https://iiif.io/api/metadata/1.0/).
88

99
## Where to start
1010

Diff for: composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"type" : "library",
55
"keywords" : [
66
"iiif",
7-
"presentation-api"
7+
"iiif-presentation"
88
],
99
"require" : {
10+
"php" : ">=5.6",
1011
"flow/jsonpath" : ">=0.4.0"
1112
},
1213
"require-dev" : {

Diff for: src/Iiif/Context/IRI.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class IRI {
8686
*/
8787
protected $fragment;
8888

89+
/**
90+
* @param string|IRI $iri A string representation to read into an IRI object or an IRI object to copy
91+
*/
8992
public function __construct($iri = null) {
9093
if (is_string($iri) && self::isIri($iri)) {
9194
$this->iri = $iri;
@@ -139,7 +142,7 @@ public static function isCompactIri($iri, JsonLdContext $context) {
139142
}
140143

141144
/**
142-
* Checks if a string has the form of a IRI by matching the regex in https://tools.ietf.org/html/rfc3986#appendix-B
145+
* Checks if a string has the form of an IRI by matching the regex in https://tools.ietf.org/html/rfc3986#appendix-B
143146
* @param string $iri
144147
* @return boolean
145148
* @link https://tools.ietf.org/html/rfc3986#appendix-B

Diff for: src/Iiif/Context/JsonLdContext.php

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
class JsonLdContext {
3232

33+
// FIXME Context may have more than one IRI or none.
3334
protected $contextIri = "";
3435

3536
protected $baseIri = "";

Diff for: src/Iiif/Context/JsonLdProcessor.php

+22-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424

2525
/**
2626
* Implementation of the context processing algorithm of the JSON-LD API version 1.1.
27-
* Expansion, Compaction and Flattening algorithms are not implemented.
28-
*
29-
*
30-
* @author lutzhelm
31-
*
27+
* Expansion, Compaction and Flattening algorithms are not (yet) implemented.
28+
*
29+
* @author Lutz Helm <[email protected]>
3230
*/
3331
class JsonLdProcessor {
3432

@@ -102,6 +100,15 @@ private function loadUnknownContext($context) {
102100
return IiifHelper::getRemoteContent($context);
103101
}
104102

103+
/**
104+
*
105+
* @param string|array $localContext
106+
* @param JsonLdContext $activeContext
107+
* @param array $remoteContexts
108+
* @throws \Exception
109+
* @return \Ubl\Iiif\Context\JsonLdContext
110+
* @link https://w3c.github.io/json-ld-api/#context-processing-algorithm
111+
*/
105112
public function processContext($localContext, JsonLdContext $activeContext, $remoteContexts = array()) {
106113
// Numbering as in draft https://w3c.github.io/json-ld-api/#algorithm on 2019-01-10
107114
// 1)
@@ -243,6 +250,15 @@ public function processContext($localContext, JsonLdContext $activeContext, $rem
243250
return $result;
244251
}
245252

253+
/**
254+
*
255+
* @param JsonLdContext $activeContext
256+
* @param array $localContext
257+
* @param string $term
258+
* @param array $defined
259+
* @throws \Exception
260+
* @link https://w3c.github.io/json-ld-api/#create-term-definition
261+
*/
246262
protected function createTermDefinition(JsonLdContext $activeContext, $localContext, $term, &$defined) {
247263
// Numbering as in draft https://w3c.github.io/json-ld-api/#algorithm-0 on 2019-01-10
248264
// 1)
@@ -526,6 +542,7 @@ protected function createTermDefinition(JsonLdContext $activeContext, $localCont
526542
* @param array $localContext
527543
* @param array $defined
528544
* @return mixed
545+
* @link https://w3c.github.io/json-ld-api/#iri-expansion
529546
*/
530547
public function expandIRI(JsonLdContext $activeContext, $value, $documentRelative = false, $vocab = false, $localContext = null, $defined = null) {
531548
// Numbering as in draft https://w3c.github.io/json-ld-api/#algorithm-1 on 2019-01-10

Diff for: src/Iiif/Presentation/Common/Model/AbstractIiifEntity.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ abstract class AbstractIiifEntity {
6161
*/
6262
protected $otherData;
6363

64+
/**
65+
*
66+
* @param string|array $resource IRI, text content or array representation of IIIF document
67+
* @return \Ubl\Iiif\Presentation\Common\Model\AbstractIiifEntity|NULL
68+
*/
6469
public static function loadIiifResource($resource) {
6570
if (is_string($resource) && IRI::isAbsoluteIri($resource)) {
6671
$resource = IiifHelper::getRemoteContent($resource);
@@ -90,6 +95,10 @@ public function getOriginalJsonArray() {
9095
return $this->originalJsonArray;
9196
}
9297

98+
99+
/**
100+
* @return string[] A map to get the right property name for a given IRI or JSON-LD keyword.
101+
*/
93102
protected function getPropertyMap() {
94103
return [
95104
"@id" => "id",
@@ -107,7 +116,7 @@ protected function getStringResources() {
107116
}
108117

109118
/**
110-
* Names of properties that resolve to AbstractIiifEntity but have not @type given.
119+
* Names of properties that can be instantiated as AbstractIiifEntity but have not @type given.
111120
* Applies to "service" property.
112121
* Method has to be overridden by affected classes.
113122
*
@@ -239,6 +248,7 @@ protected function loadProperty($term, $value, JsonLdContext $context, &$allReso
239248
$property = substr($property, 1);
240249
}
241250
if (!property_exists($this, $property)) {
251+
// Check if the property can be resolved to an IRI or a JSON-LD keyword
242252
$iriOrKeyword = null;
243253
if ($context->getTermDefinition($property) != null) {
244254
$iriOrKeyword = $context->getTermDefinition($property)->getIriMapping();
@@ -247,6 +257,7 @@ protected function loadProperty($term, $value, JsonLdContext $context, &$allReso
247257
} elseif (Keywords::isKeyword($property) || IRI::isAbsoluteIri($property)) {
248258
$iriOrKeyword = $property;
249259
}
260+
// Check if there is a property for the IRI / keyword in the resource class
250261
$propertyMap = $this->getPropertyMap();
251262
if (array_key_exists($iriOrKeyword, $propertyMap)) {
252263
$property = $propertyMap[$iriOrKeyword];

Diff for: src/Iiif/Presentation/Common/Model/Resources/IiifResourceInterface.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,21 @@ public function getRequiredStatement();
9696
public function getRequiredStatementForDisplay($language = null, $joinChars = "; ", $options = IiifResourceInterface::SANITIZE_XML_ENCODE_NONHTML);
9797

9898
public function getSeeAlso();
99-
99+
/**
100+
* Looks a matching format in all entries of seeAlso and returns their URLs
101+
* @param string $format requested format
102+
* @return string[] Array of URLs / @id s of all matching entries
103+
*/
100104
public function getSeeAlsoUrlsForFormat($format);
101-
105+
106+
/**
107+
*
108+
* @param string $profile Requested profile
109+
* @param boolean $startsWith If true, a seeAlso entry matches if it's profile
110+
* starts with $profile. For example, "http://example.org/service/version1" will
111+
* then match "http://example.org/service/".
112+
* @return Array of URLs / @id s of all matching entries
113+
*/
102114
public function getSeeAlsoUrlsForProfile($profile, $startsWith = false);
103115

104116
/**

Diff for: src/Iiif/Tools/IiifHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class IiifHelper {
2828
*
2929
* @param string|array $resource IIIF resource. Can be an IRI, the JSON document as string
3030
* or a dictionary in form of a PHP associative array
31-
* @return NULL|\Ubl\Iiif\Presentation\Common\Model\AbstractIiifEntity An instance of the IIIF
31+
* @return NULL|\Ubl\Iiif\Presentation\Common\Model\AbstractIiifEntity An instance of the IIIF resource
3232
*/
3333
public static function loadIiifResource($resource) {
3434
return AbstractIiifEntity::loadIiifResource($resource);

0 commit comments

Comments
 (0)