Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ query-filters:
- note

paths-ignore:
- Resources/Public/JavaScript/Gridstack
- Resources/Public/JavaScript/jPlayer
- Resources/Public/JavaScript/jQuery
- Resources/Public/JavaScript/jQueryUI
- Resources/Public/JavaScript/OpenLayers
- Resources/Public/JavaScript/Toastify
- Resources/Public/JavaScript/Verovio
- Resources/Public/JavaScript/WildWebMidi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.bak
/.buildpath
/.cache
/.idea/
Expand All @@ -16,3 +17,4 @@
/public/
/var/
/vendor/
.DS_Store
2 changes: 1 addition & 1 deletion Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if ($document === null) {
$io->error('ERROR: Document with UID "' . $input->getOption('doc') . '" could not be found on PID ' . $this->storagePid . ' .');
exit(1);
return BaseCommand::FAILURE;
} else {
$doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $this->storagePid], true);
}
Expand Down
78 changes: 78 additions & 0 deletions Classes/Common/AnnotationRequest.php
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;
}
}
Loading