Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide prohibited images in collections #66

Merged
merged 1 commit into from
Aug 8, 2017
Merged
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
11 changes: 11 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ public function removeAllUsage($dcx_id);
*/
public function getCollections();

/**
* Retrieve all docs of a collection.
*
* @param string $utag_id
* Id of a collection.
*
* @return array
* Documents of the given collection.
*/
public function getDocsOfCollection($utag_id);

/**
* Return filename and url of a thumbnail for the given (image) document.
*
Expand Down
21 changes: 12 additions & 9 deletions src/JsonClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,27 +841,30 @@ public function getCollections() {
}

/**
* Retrieve all docs of a collection.
*
* @param string $utag_id
* Id of a collection.
*
* @return array
* Documents of the given collection.
* {@inheritdoc}
*/
public function getDocsOfCollection($utag_id) {
$doctoutag_params = [
'q[utag_id]' => $utag_id,
's[properties]' => '*',
's[_referenced][dcx:document][s][_rights_effective]' => '*',
's[_referenced][dcx:document][s][files]' => '*',
's[_referenced][dcx:document][s][_referenced][dcx:rights][s][properties]' => '*',
];

$this->dcxApiClient->get('doctoutag', $doctoutag_params, $docs);

$documents = [];

foreach ($docs['entries'] as $doc) {
$documents[] = $doc['properties']['doc_id']['_id'];

$document = reset($this->extractData($doc, ['_referenced', 'dcx:document']));
$rights = $this->extractData($doc, ['_referenced', 'dcx:rights']);

$document['_referenced']['dcx:rights'] = $rights;

if ($this->computeStatus($document)) {
$documents[] = $doc['properties']['doc_id']['_id'];
}
}

return $documents;
Expand Down