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

Manual VuDL update, part 2 #100

Merged
merged 3 commits into from Feb 28, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions module/VuDL/src/VuDL/Connection/Fedora.php
Expand Up @@ -381,6 +381,63 @@ public function getQueryURL()
: null;
}

/**
* Get collapsable XML for an id
*
* @param object $record Record data
*
* @return html string
*/
public function getTechInfo($record = null, $renderer = null)
{
if ($record == null) {
return false;
}
$ret = array();
// OCR
if (isset($record['ocr-dirty'])) {
$record['ocr-dirty'] = $this->getDatastreamContent($record['id'], 'OCR-DIRTY');
}
// Technical Information
if (isset($record['master-md'])) {
$record['techinfo'] = $this->getDatastreamContent($record['id'], 'MASTER-MD');
$ret += $this->getSizeAndTypeInfo($record['techinfo']);
}
if ($renderer != null) {
$ret['div'] = $renderer
->render('vudl/techinfo.phtml', array('record'=>$record));
}
return $ret;
}

/**
* Get size/type information out of the technical metadata.
*
* @param string $techInfo Technical metadata
*
* @return array
*/
protected function getSizeAndTypeInfo($techInfo)
{
$data = $type = array();
preg_match('/<size[^>]*>([^<]*)/', $techInfo, $data);
preg_match('/mimetype="([^"]*)/', $techInfo, $type);
$size_index = 0;
if (count($data) > 1) {
$bytes = intval($data[1]);
$sizes = array('bytes','KB','MB');
while ($size_index < count($sizes)-1 && $bytes > 1024) {
$bytes /= 1024;
$size_index++;
}
return array(
'size' => round($bytes, 1) . ' ' . $sizes[$size_index],
'type' => $type[1]
);
}
return array();
}

/**
* Consolidation of Zend Client calls
*
Expand Down