Created
November 16, 2012 13:04
-
-
Save jsicot/4087208 to your computer and use it in GitHub Desktop.
Omeka OaiPmhRepository - Relation : add square_thumbnail for item
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
From 2b5c55774c7f0f1107bbbb814cd7070c4f797da7 Mon Sep 17 00:00:00 2001 | |
From: jsicot <[email protected]> | |
Date: Fri, 16 Nov 2012 14:01:30 +0100 | |
Subject: [PATCH] OaiPmhRepository - Relation : add square_thumbnail for item | |
--- | |
metadata/OaiDc.php | 27 +++++++++++++++++++++++---- | |
1 file changed, 23 insertions(+), 4 deletions(-) | |
diff --git a/metadata/OaiDc.php b/metadata/OaiDc.php | |
index 9da3600..4844f81 100755 | |
--- a/metadata/OaiDc.php | |
+++ b/metadata/OaiDc.php | |
@@ -37,8 +37,11 @@ class OaiPmhRepository_Metadata_OaiDc extends OaiPmhRepository_Metadata_Abstract | |
* and further children for each of the Dublin Core fields present in the | |
* item. | |
*/ | |
- public function appendMetadata($metadataElement) | |
+ public function appendMetadata() | |
{ | |
+ $metadataElement = $this->document->createElement('metadata'); | |
+ $this->parentElement->appendChild($metadataElement); | |
+ | |
$oai_dc = $this->document->createElementNS( | |
self::METADATA_NAMESPACE, 'oai_dc:dc'); | |
$metadataElement->appendChild($oai_dc); | |
@@ -72,9 +75,25 @@ class OaiPmhRepository_Metadata_OaiDc extends OaiPmhRepository_Metadata_Abstract | |
{ | |
$this->appendNewElement($oai_dc, | |
'dc:'.$elementName, $elementText->text); | |
- } | |
- // Append the browse URI to all results | |
- if($elementName == 'identifier') | |
+ } | |
+ // Relation : add square_thumbnail for item | |
+ if($elementName == 'relation') | |
+ { | |
+ $files = $this->item->getFiles(); | |
+ foreach($files as $file) { | |
+ $re1='.*?'; # Non-greedy match on filler | |
+ $re2='(titre)'; # Word 1 | |
+ $re3='(\\d+)'; # Integer Number 1 | |
+ $file= $file->archive_filename; | |
+ if ($c=preg_match_all ("/".$re1.$re2.$re3."/is", $file, $matches)){ | |
+ $img = WEB_SQUARE_THUMBNAILS. DIRECTORY_SEPARATOR . $file . ''; | |
+ $this->appendNewElement($oai_dc,'dc:relation', 'vignette : '. $img); | |
+ } | |
+ else { } | |
+ } | |
+ } | |
+ // Append the browse URI to all results | |
+ if($elementName == 'identifier') | |
{ | |
$this->appendNewElement($oai_dc, | |
'dc:identifier', abs_item_uri($this->item)); | |
-- | |
1.8.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment