Browse Source

Added some checks to the displayMetadata method so that it does not cause errors if the exif datastream is empty or missing.

pull/105/head
root 14 years ago
parent
commit
9ab9ba0751
  1. 53
      plugins/Exiftool.inc

53
plugins/Exiftool.inc

@ -32,32 +32,35 @@ class Exiftool {
function displayMetadata() { function displayMetadata() {
$output=''; $output='';
$exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF')); $exif = $this->item->get_datastream_dissemination('EXIF');
if ($exifDom != NULL) { if (trim($exif) != '') {
$description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#','Description'); $exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF'));
if ($description->length > 0) { if ($exifDom != NULL) {
$description=$description->item(0); $description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#','Description');
$output .= '<div class="fedora_technical_metadata"><ul>'; if ($description->length > 0) {
for ($i=0;$i<$description->childNodes->length;$i++){ $description=$description->item(0);
$name=$description->childNodes->item($i)->nodeName; $output .= '<div class="fedora_technical_metadata"><ul>';
$value=$description->childNodes->item($i)->nodeValue; for ($i=0;$i<$description->childNodes->length;$i++){
if ($name != '#text' && !preg_match('/^System\:.*$/',$name) && trim($value) != '') { $name=$description->childNodes->item($i)->nodeName;
list($type,$name) = preg_split('/\:/',$name); $value=$description->childNodes->item($i)->nodeValue;
$name = trim(preg_replace('/(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])/'," $1", $name)); if ($name != '#text' && !preg_match('/^System\:.*$/',$name) && trim($value) != '') {
$output .= '<li><b>'.$name. '</b>: '. $value .' </li>'; list($type,$name) = preg_split('/\:/',$name);
} $name = trim(preg_replace('/(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])/'," $1", $name));
} $output .= '<li><b>'.$name. '</b>: '. $value .' </li>';
$output.='</ul></div>'; }
}
$output.='</ul></div>';
$fieldset = array( $fieldset = array(
'#title' => t("!text", array('!text' => 'Technical Metadata')), '#title' => t("!text", array('!text' => 'Technical Metadata')),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
'#value' => $output '#value' => $output
); );
$output = theme('fieldset', $fieldset); $output = theme('fieldset', $fieldset);
} }
} }
}
return $output; return $output;
} }

Loading…
Cancel
Save