Skip to content

Instantly share code, notes, and snippets.

@WaltRiceJr
Created March 27, 2016 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WaltRiceJr/3996e3e2d53509c1577f to your computer and use it in GitHub Desktop.
Save WaltRiceJr/3996e3e2d53509c1577f to your computer and use it in GitHub Desktop.
<h3><?php echo metadata('item', array('Dublin Core','Title')); ?></h3>
<div id="primary">
<!-- Items metadata -->
<div id="item-metadata">
<?php echo all_element_texts('item'); ?>
</div>
<?php if(metadata('item','Collection Name')): ?>
<div id="collection" class="element">
<h5><?php echo __('Collection'); ?></h5>
<div class="element-text"><?php echo link_to_collection_for_item(); ?></div>
</div>
<?php endif; ?>
<!-- The following prints a list of all tags associated with the item -->
<?php if (metadata('item','has tags')): ?>
<div id="item-tags" class="element">
<h5><?php echo __('Tags'); ?></h5>
<div class="element-text"><?php echo tag_string('item'); ?></div>
</div>
<?php endif;?>
<!-- The following prints a citation for this item. -->
<div id="item-citation" class="element">
<h5><?php echo __('Citation'); ?></h5>
<div class="element-text"><?php echo metadata('item','citation',array('no_escape'=>true)); ?></div>
</div>
<!-- <?php fire_plugin_hook('public_items_show', array('view' => $this, 'item' => $item)); ?> -->
</div> <!-- End of Primary. -->
<div id="secondary">
<!-- <h3><?php echo __('Files'); ?></h3> -->
<div id="item-images">
<?php
$index = 0;
foreach ($item->Files as $file)
{
if ($this->openLayersZoom()->isZoomed($file))
{
$index = $index + 1;
$vid = 'os' . $index;
list($width, $height, $type, $attr) = getimagesize(FILES_DIR . DIRECTORY_SEPARATOR . 'original' . DIRECTORY_SEPARATOR . $file->filename);
?>
<script type="text/javascript">
tileSize = 256;
var tileUrl<?php echo $index ?> = '<?php echo $this->openLayersZoom()->getTileUrl($file) ?>';
var origUrl<?php echo $index ?> = '<?php echo file_display_url($file, 'original') ?>';
var imageWidth<?php echo $index ?> = <?php echo $width ?>;
var imageHeight<?php echo $index ?> = <?php echo $height ?>;
var tierSizeInTiles<?php echo $index ?> = [];
while (imageWidth<?php echo $index ?> > tileSize || imageHeight<?php echo $index ?> > tileSize)
{
tierSizeInTiles<?php echo $index ?>.push([
Math.ceil(imageWidth<?php echo $index ?> / tileSize),
Math.ceil(imageHeight<?php echo $index ?> / tileSize)
]);
tileSize += tileSize;
}
tierSizeInTiles<?php echo $index ?>.push([1, 1]);
tierSizeInTiles<?php echo $index ?>.reverse();
var resolutions<?php echo $index ?> = [1];
var tileCountUpToTier<?php echo $index ?> = [0];
var i, ii;
for (i = 1, ii = tierSizeInTiles<?php echo $index ?>.length; i < ii; i++)
{
resolutions<?php echo $index ?>.push(1 << i);
tileCountUpToTier<?php echo $index ?>.push(tierSizeInTiles<?php echo $index ?>[i - 1][0] * tierSizeInTiles<?php echo $index ?>[i - 1][1] + tileCountUpToTier<?php echo $index ?>[i - 1]);
}
resolutions<?php echo $index ?>.reverse();
</script>
<?php
}
}
if ($index > 0)
{
?>
<div class="item-viewer">
<div id="<?php echo $vid ?>" style="height: 600px; width: 100%;"></div>
<script type="text/javascript">
os = OpenSeadragon({
id: "<?php echo $vid ?>",
prefixUrl: "<?php echo absolute_url('themes/mytheme/javascripts/openseadragon/images/'); ?>",
showNavigator: false,
animationTime: 0.5,
showRotationControl: true,
sequenceMode: true,
autoHideControls: false,
tileSources: [
<?php for ($i = 1; $i <= $index; $i++): ?>
{
height: imageHeight<?php echo $i ?>,
width: imageWidth<?php echo $i ?>,
tileSize: 256,
minLevel: 8,
getTileUrl: function( level, x, y ) {
var z = level - 8;
if (z < 0) return null;
// tile index should be equal to (y * width) + x + tiles from previous zoom levels
var tileIndex = (y * tierSizeInTiles<?php echo $i ?>[z][0]) + x + tileCountUpToTier<?php echo $i ?>[z];
var tileGroup = (tileIndex / 256) | 0;
var url = tileUrl<?php echo $i ?> + "/TileGroup" + tileGroup + "/" + z + "-" + x + "-" + y + ".jpg";
// console.log(url);
return url;
}
}
<?php if ($i < $index) echo ', ' ?>
<?php endfor; ?>
]
});
function showPage(i)
{
os.goToPage(i-1);
jQuery('.item-thumb').removeClass('current');
jQuery('#page' + i).addClass('current');
}
</script>
</div>
<?php
}
$index = 0;
echo '<div class="item-thumbs-wrapper">';
foreach ($item->Files as $file)
{
if ($this->openLayersZoom()->isZoomed($file))
{
$index++;
echo '<a href="javascript:showPage(' . $index . ');">';
echo file_markup($file, array('imageSize' => 'thumbnail', 'linkToFile' => false), array('class' => 'item-thumb' . ($index == 1 ? ' current' : ''),'id' => 'page' . $index));
echo '</a>';
}
}
echo '</div>';
echo '<div class="item-files-other">';
foreach ($item->Files as $file)
{
if (!$this->openLayersZoom()->isZoomed($file))
{
echo file_markup($file, array('imageSize' => 'fullsize'), array('class' => 'item-file'));
}
}
echo '</div>';
?>
<?php /* echo files_for_item(); */ ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment