forked from kitodo/kitodo-presentation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Support for musical sources, multi-level metadata and exper…
…imental annotations (kitodo#1281) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Christopher <[email protected]> Co-authored-by: Frank Schirlitz <[email protected]> Co-authored-by: haogatyp <[email protected]> Co-authored-by: Matthias Richter <[email protected]> Co-authored-by: Hizkiel Alemayehu <[email protected]> Co-authored-by: Daniel Röwenstrunk <[email protected]> Co-authored-by: Hizkiel Alemayehu <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Beatrycze Volk <[email protected]> Co-authored-by: frank-ulrich-weber <[email protected]>
- Loading branch information
1 parent
729110e
commit d7d6ce6
Showing
66 changed files
with
82,206 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.bak | ||
/.buildpath | ||
/.cache | ||
/.idea/ | ||
|
@@ -16,3 +17,4 @@ | |
/public/ | ||
/var/ | ||
/vendor/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Kitodo\Dlf\Common; | ||
|
||
/** | ||
* (c) Kitodo. Key to digital objects e.V. <[email protected]> | ||
* | ||
* This file is part of the Kitodo and TYPO3 projects. | ||
* | ||
* @license GNU General Public License version 3 or later. | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
class AnnotationRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $apiUrl = ''; | ||
|
||
/** | ||
* @param string $apiUrl The url of the annotation server api. | ||
*/ | ||
public function __construct($apiUrl) | ||
{ | ||
$this->apiUrl = trim($apiUrl, "/ "); | ||
} | ||
|
||
|
||
/** | ||
* Requests the annotation server | ||
* | ||
* @param string $url The annotation request url. | ||
* @return array | ||
*/ | ||
protected function requestAnnotions($url) : array | ||
{ | ||
$jsonld = Helper::getUrl($url); | ||
|
||
if ($jsonld) { | ||
$annotationData = json_decode($jsonld, true); | ||
|
||
if ($annotationData) { | ||
return $annotationData; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
|
||
/** | ||
* Returns all annotations of a document. | ||
* | ||
* @param string $id Document id (purl) | ||
* @return array | ||
*/ | ||
public function getAll($id) | ||
{ | ||
$annotations = []; | ||
|
||
$annotationData = $this->requestAnnotions($this->apiUrl . '?target=' . urlencode($id . '/*')); | ||
|
||
if (array_key_exists('first', $annotationData)) { | ||
$annotationPageData = $annotationData['first']; | ||
$annotations = array_merge($annotations, $annotationPageData["items"]); | ||
|
||
while (array_key_exists('next', $annotationPageData)) { | ||
$annotationPageData = $this->requestAnnotions($annotationPageData['next']); | ||
if (array_key_exists('items', $annotationPageData)) { | ||
$annotations = array_merge($annotations, $annotationPageData["items"]); | ||
} | ||
} | ||
} | ||
|
||
return $annotations; | ||
} | ||
} |
Oops, something went wrong.