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

Commit fc58fc9

Browse files
author
Charles Ma
committed
ENH: fixed bug #162
Added image viewer and fixed pdf download
1 parent eb11429 commit fc58fc9

File tree

13 files changed

+150
-59
lines changed

13 files changed

+150
-59
lines changed

core/views/download/onebitstream.phtml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ $modified = gmdate('D, d M Y H:i:s').' GMT';
2525
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
2626
header("Last-Modified: $modified");
2727

28+
// if pdf set the content-type acordingly
29+
if(!isset($contentType)&&pathinfo($this->name, PATHINFO_EXTENSION) == "pdf")
30+
{
31+
$contentType = 'application/pdf';
32+
$enableContentDisposition = false;
33+
}
34+
2835
if(!isset($contentType))
2936
{
3037
$contentType = 'application/octet-stream';
@@ -36,13 +43,8 @@ if(!isset($contentType)&&strlen($this->name)>4 && substr($this->name,strlen($thi
3643
$contentType = 'application/isp';
3744
}
3845

39-
// if pdf set the content-type acordingly
40-
if(!isset($contentType)&&pathinfo($this->name, PATHINFO_EXTENSION) == "pdf")
41-
{
42-
$contentType = 'application/pdf';
43-
$enableContentDisposition = false;
44-
}
45-
46+
47+
4648
$agent = env('HTTP_USER_AGENT');
4749
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent))
4850
{

modules/visualize/controllers/ImageController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Visualize_ImageController extends Visualize_AppController
1717
public function indexAction()
1818
{
1919
$this->disableLayout();
20-
$this->disableView();
2120
$itemid = $this->_getParam('itemId');
2221
$item = $this->Item->load($itemid);
2322

@@ -33,8 +32,10 @@ public function indexAction()
3332
throw new Zend_Exception('Error');
3433
}
3534
$this->bistream = $bitstreams[0];
35+
36+
$this->view->imageUrl = $this->view->webroot."/download?items=".$item->getKey();
37+
3638

37-
echo "<img src='".$this->view->webroot."/download?items=".$item->getKey()."'/>";
3839
}
3940
} // end class
4041
?>

modules/visualize/controllers/PdfController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function indexAction()
3434
}
3535
$this->bistream = $bitstreams[0];
3636
echo "<html>";
37-
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>";
37+
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>";
3838

3939
echo "</html>";
4040
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$(document).ready(function(){
2+
$("#viewer").iviewer(
3+
{
4+
src: $('div#urlImage').html(),
5+
update_on_resize: false
6+
});
7+
});
Loading
Loading
Loading
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.iviewer_common {
2+
position:absolute;
3+
bottom:10px;
4+
border: 1px solid #000;
5+
height: 28px;
6+
z-index: 5000;
7+
}
8+
9+
.iviewer_cursor {
10+
cursor: -moz-grab;
11+
}
12+
13+
.iviewer_drag_cursor {
14+
cursor: -moz-grabbing;
15+
}
16+
17+
.iviewer_button {
18+
width: 28px;
19+
cursor: pointer;
20+
background-position: center center;
21+
background-repeat: no-repeat;
22+
}
23+
24+
.iviewer_zoom_in {
25+
left: 20px;
26+
background: url(img/iviewer.zoom_in.gif);
27+
}
28+
29+
.iviewer_zoom_out {
30+
left: 55px;
31+
background: url(img/iviewer.zoom_out.gif);
32+
}
33+
34+
.iviewer_zoom_zero {
35+
left: 90px;
36+
background: url(img/iviewer.zoom_zero.gif);
37+
}
38+
39+
.iviewer_zoom_fit {
40+
left: 125px;
41+
background: url(img/iviewer.zoom_fit.gif);
42+
}
43+
44+
.iviewer_zoom_status {
45+
left: 160px;
46+
font: 1em/28px Sans;
47+
color: #000;
48+
background-color: #fff;
49+
text-align: center;
50+
width: 60px;
51+
}

modules/visualize/public/js/jquery/iviewer/jquery.iviewer.min.js

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
2+
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
3+
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
4+
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
5+
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
6+
*
7+
* Version: 3.0.2
8+
*
9+
* Requires: 1.2.2+
10+
*/
11+
(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);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
?>
13+
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/js/jquery/iviewer/jquery.iviewer.css" />
14+
15+
<?php
16+
echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/layout/jquery.js"></script>';
17+
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/image/image.index.js');
18+
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jquery/iviewer/jquery.iviewer.min.js');
19+
$this->headScript()->appendFile($this->moduleWebroot . '/public/js/jquery/iviewer/jquery.mousewheel.min.js');
20+
?>
21+
<style>
22+
.viewer
23+
{
24+
width: 750px;
25+
height: 650px;
26+
border: 1px solid black;
27+
position: relative;
28+
}
29+
30+
.wrapper
31+
{
32+
overflow: hidden;
33+
}
34+
</style>
35+
36+
<div class="wrapper">
37+
<div id="viewer" class="viewer"></div>
38+
</div>
39+
<div id='urlImage' style="display:none;"><?php echo $this->imageUrl?></div>
40+
<?php echo $this->headScript() ?>

modules/visualize/views/pdf/index.phtml

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)