Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
ENH: fixed bug #162
Browse files Browse the repository at this point in the history
Added image viewer and fixed pdf download
  • Loading branch information
Charles Ma committed Aug 10, 2011
1 parent eb11429 commit fc58fc9
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 59 deletions.
16 changes: 9 additions & 7 deletions core/views/download/onebitstream.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ $modified = gmdate('D, d M Y H:i:s').' GMT';
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Last-Modified: $modified");

// if pdf set the content-type acordingly
if(!isset($contentType)&&pathinfo($this->name, PATHINFO_EXTENSION) == "pdf")
{
$contentType = 'application/pdf';
$enableContentDisposition = false;
}

if(!isset($contentType))
{
$contentType = 'application/octet-stream';
Expand All @@ -36,13 +43,8 @@ if(!isset($contentType)&&strlen($this->name)>4 && substr($this->name,strlen($thi
$contentType = 'application/isp';
}

// if pdf set the content-type acordingly
if(!isset($contentType)&&pathinfo($this->name, PATHINFO_EXTENSION) == "pdf")
{
$contentType = 'application/pdf';
$enableContentDisposition = false;
}



$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent))
{
Expand Down
5 changes: 3 additions & 2 deletions modules/visualize/controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Visualize_ImageController extends Visualize_AppController
public function indexAction()
{
$this->disableLayout();
$this->disableView();
$itemid = $this->_getParam('itemId');
$item = $this->Item->load($itemid);

Expand All @@ -33,8 +32,10 @@ public function indexAction()
throw new Zend_Exception('Error');
}
$this->bistream = $bitstreams[0];

$this->view->imageUrl = $this->view->webroot."/download?items=".$item->getKey();


echo "<img src='".$this->view->webroot."/download?items=".$item->getKey()."'/>";
}
} // end class
?>
2 changes: 1 addition & 1 deletion modules/visualize/controllers/PdfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function indexAction()
}
$this->bistream = $bitstreams[0];
echo "<html>";
echo "<object height='600' width='800' type='application/pdf' data='".$this->view->webroot."/download?items=".$item->getKey()."'> <param name='src' value='".$this->view->webroot."/download?items=".$item->getKey()."'/></object>";
echo "<object height='750' width='750' type='application/pdf' data='".$this->view->webroot."/download?items=".$item->getKey()."'> <param name='src' value='".$this->view->webroot."/download?items=".$item->getKey()."'/></object>";

echo "</html>";
}
Expand Down
7 changes: 7 additions & 0 deletions modules/visualize/public/js/image/image.index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(document).ready(function(){
$("#viewer").iviewer(
{
src: $('div#urlImage').html(),
update_on_resize: false
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions modules/visualize/public/js/jquery/iviewer/jquery.iviewer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.iviewer_common {
position:absolute;
bottom:10px;
border: 1px solid #000;
height: 28px;
z-index: 5000;
}

.iviewer_cursor {
cursor: -moz-grab;
}

.iviewer_drag_cursor {
cursor: -moz-grabbing;
}

.iviewer_button {
width: 28px;
cursor: pointer;
background-position: center center;
background-repeat: no-repeat;
}

.iviewer_zoom_in {
left: 20px;
background: url(img/iviewer.zoom_in.gif);
}

.iviewer_zoom_out {
left: 55px;
background: url(img/iviewer.zoom_out.gif);
}

.iviewer_zoom_zero {
left: 90px;
background: url(img/iviewer.zoom_zero.gif);
}

.iviewer_zoom_fit {
left: 125px;
background: url(img/iviewer.zoom_fit.gif);
}

.iviewer_zoom_status {
left: 160px;
font: 1em/28px Sans;
color: #000;
background-color: #fff;
text-align: center;
width: 60px;
}
28 changes: 28 additions & 0 deletions modules/visualize/public/js/jquery/iviewer/jquery.iviewer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
*
* Version: 3.0.2
*
* Requires: 1.2.2+
*/
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
40 changes: 40 additions & 0 deletions modules/visualize/views/image/index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
?>
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/js/jquery/iviewer/jquery.iviewer.css" />

<?php
echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/layout/jquery.js"></script>';
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/image/image.index.js');
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jquery/iviewer/jquery.iviewer.min.js');
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jquery/iviewer/jquery.mousewheel.min.js');
?>
<style>
.viewer
{
width: 750px;
height: 650px;
border: 1px solid black;
position: relative;
}

.wrapper
{
overflow: hidden;
}
</style>

<div class="wrapper">
<div id="viewer" class="viewer"></div>
</div>
<div id='urlImage' style="display:none;"><?php echo $this->imageUrl?></div>
<?php echo $this->headScript() ?>
49 changes: 0 additions & 49 deletions modules/visualize/views/pdf/index.phtml

This file was deleted.

0 comments on commit fc58fc9

Please sign in to comment.