Skip to content

Commit

Permalink
OAI-PMH: add download link if downloading is permitted by author
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 1, 2023
1 parent d211dda commit f6b2611
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
7 changes: 6 additions & 1 deletion oai-pmh/oai.php
Expand Up @@ -317,7 +317,8 @@ function makeRecordFromTemplate($metadataPrefix,$template, $metadata){
),
'keywords' => explode("\n", $metadata->keywords),
'relation' => array(
'thumbnail' => $metadata->thumbnail
'thumbnail' => $metadata->thumbnail,
'download' => $metadata->download
),
'lifecycle' => array(
'author' => $metadata->author,
Expand All @@ -337,6 +338,10 @@ function makeRecordFromTemplate($metadataPrefix,$template, $metadata){
'levelId' => $metadata->levelId,
),
));
if ($record['metadata']['relation']['download'])
{
$record['metadata']['relation']['download_url'] = $metadata->downloadUrl;
}
}
else if($metadataPrefix == "oai_dc"){
$record = array('identifier' => ($xerte_toolkits_site->site_url . $template['template_id']),
Expand Down
26 changes: 26 additions & 0 deletions oai-pmh/oaiserver.php
Expand Up @@ -528,6 +528,32 @@ private function add_metadata($metadataPrefix,$cur_record, $record)
$langstring_node = $this->response->addChild($entry_node, 'langstring', $thumbnail_url);
$langstring_node->setAttribute("xml:lang", "x-none");

//RELATION - download package - normal export
if (isset($record['metadata']['relation']['download_url']) && $record['metadata']['relation']['download_url'] != "") {

$relation_node = $this->response->addChild($schema_node, 'relation');
$kind_node = $this->response->addChild($relation_node, 'kind');
$source_node = $this->response->addChild($kind_node, 'source');
$langstring_node = $this->response->addChild($source_node, 'langstring', "http://purl.edustandaard.nl/relation_kind_nllom_20131211");
$langstring_node->setAttribute("xml:lang", "x-none");

$value_node = $this->response->addChild($kind_node, 'value');
$langstring_node = $this->response->addChild($value_node, 'langstring', "hasformat");
$langstring_node->setAttribute("xml:lang", "x-none");

$resource_node = $this->response->addChild($relation_node, 'resource');
$description_node = $this->response->addChild($resource_node, 'description');
$langstring_node = $this->response->addChild($description_node, 'langstring', "application/zip");
$langstring_node->setAttribute("xml:lang", "x-none");
$catalogentry_node = $this->response->addChild($resource_node, 'catalogentry');
$this->response->addChild($catalogentry_node, 'catalog', 'URI');
$entry_node = $this->response->addChild($catalogentry_node, 'entry');
// Bleeh eascpe & in url
$download_url = str_replace("&", "&", $record['metadata']['relation']['download_url']);
$langstring_node = $this->response->addChild($entry_node, 'langstring', $download_url);
$langstring_node->setAttribute("xml:lang", "x-none");
}

// CLASSIFICATION - domain
$domain = $record['metadata']['classification']['domain'];
$domain_id = $record['metadata']['classification']['domain_id'];
Expand Down
6 changes: 5 additions & 1 deletion oai-pmh/xerteobjects.php
Expand Up @@ -20,7 +20,7 @@
*/

require_once(dirname(__FILE__) . "/Html2Text.php");

require_once(dirname(__FILE__) . "/../website_code/php/url_library.php");
function get_meta_data($template_id, $creator_user_name="", $template_type_name="", $template_owner="")
{
global $config;
Expand Down Expand Up @@ -201,6 +201,10 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
{
$xerteMetaObj->rights = $syndication['license'];
$xerteMetaObj->download = ($syndication['export'] == 'true' ? true : false);
if ($xerteMetaObj->download)
{
$xerteMetaObj->downloadUrl = $xerte_toolkits_site->site_url . url_return("export", $template_id);
}
$q = "select * from {$xerte_toolkits_site->database_table_prefix}oai_rights where label=?";
$params = array( $syndication['license']);
$rights = db_query_one($q, $params);
Expand Down

0 comments on commit f6b2611

Please sign in to comment.