Permalink
Browse files

adds support for “documents” display (web-only)

  • Loading branch information...
Erin Bell Erin Bell
Erin Bell authored and Erin Bell committed Sep 18, 2017
1 parent 57607c3 commit 560a75c90e478823c85c86f242cd14fad514cbd2
Showing with 113 additions and 1 deletion.
  1. +47 −0 curatescape/css/screen.css
  2. +64 −0 curatescape/custom.php
  3. +2 −1 curatescape/items/show-template-default.php
View
@@ -763,6 +763,53 @@ video,audio{
.now-playing .media-icon{color: #222;}
/*! DOCUMENTS TABLE */
#item-documents table{
width: 100%;
}
#item-documents table th{
color: #fff;
text-transform: uppercase;
padding-top: 0;
}
#item-documents table td{
background: #fff;
}
#item-documents table td.title,#item-documents table td.info{
border-right: 1px solid #ccc;
}
#item-documents table td.title{
padding-left: 1em;
}
#item-documents table td.info{
text-transform: uppercase;
min-width: 7em;
}
#item-documents table td.download{
padding-right: 1em;
}
#item-documents table .button{
margin-bottom: 0;
width: 100%;
color: #fff;
background: #222;
border-color: #ccc;
}
#item-documents table .button:hover{
color: #ccc;
}
@media all and (max-width:550px){
#item-documents table th {
display: none;
}
#item-documents table td,table tr{
display: block;
}
#item-documents table tr + tr{
margin-bottom: 1em;
}
}
/*! MEDIA TYPE AND SEARCH HEADINGS */
section.media h3,section.map h2, #search.browse h3.result-type-header, body#home h3.result-type-header{
font-size: 160%;
View
@@ -1423,6 +1423,38 @@ function mh_video_files($item='item',$html=null) {
</script>
<?php endif;
}
/*
** loop through and display DOCUMENT files other than the supported audio, video, and image types
*/
function mh_document_files($item='item',$html=null){
$blacklist=array('image/jpeg','image/jpg','image/png','image/jpeg','image/gif','video/mp4','video/mpeg','video/quicktime','audio/mpeg');
foreach (loop('files', $item->Files) as $file){
$documentMime = metadata($file,'MIME Type');
if ( !in_array($documentMime,$blacklist) ){
$title = metadata($file,array('Dublin Core','Title')) ? metadata($file,array('Dublin Core','Title')) : $file->original_filename;
$extension=pathinfo($file->getWebPath('original'), PATHINFO_EXTENSION);
$size=formatSizeUnits($file->size);
$download=$file->getWebPath('original');
$html .= '<tr>';
$html .= '<td class="title"><a href="/files/show/'.$file->id.'">'.$title.'</a></td>';
$html .= '<td class="info"><span>'.$extension.'</span> / '.$size.'</td>';
$html .= '<td class="download"><a class="button" target="_blank" title="Download" href="'.$download.'"><i class="fa fa-download" aria-hidden="true"></i> <span>Download</span></a></td>';
$html .= '</tr>';
}
}
if($html){
echo '<h3>'.__('Documents').'</h3>';
echo '<figure id="item-documents">';
echo '<table><tbody><tr><th>Name</th><th>Info</th><th>Actions</th></tr>'.$html.'</tbody></table>';
echo '</figure>';
}
}
/*
** display single file in FILE TEMPLATE
*/
@@ -2379,5 +2411,37 @@ function adjustBrightness($hex, $steps) {
return $return;
}
/*
** https://stackoverflow.com/questions/5501427/php-filesize-mb-kb-conversion
*/
function formatSizeUnits($bytes)
{
if ($bytes >= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
}
elseif ($bytes >= 1024)
{
$bytes = number_format($bytes / 1024, 2) . ' kB';
}
elseif ($bytes > 1)
{
$bytes = $bytes . ' bytes';
}
elseif ($bytes == 1)
{
$bytes = $bytes . ' byte';
}
else
{
$bytes = '0 bytes';
}
return $bytes;
}
?>
@@ -35,7 +35,8 @@
<h2 hidden class="hidden">Media</h2>
<?php mh_video_files($item);?>
<?php mh_item_images($item);?>
<?php mh_audio_files($item);?>
<?php mh_audio_files($item);?>
<?php mh_document_files($item);?>
</section>
<?php if(mh_get_item_json($item)): ?>
<section class="map">

0 comments on commit 560a75c

Please sign in to comment.