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

Commit 58a7328

Browse files
author
Charles Marion
committed
ENH: Module Visualize: Add paths in configuration & improve design
fixed bug #140
1 parent cb29547 commit 58a7328

File tree

16 files changed

+225
-130
lines changed

16 files changed

+225
-130
lines changed

core/AppController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ public function preDispatch()
149149
$this->view->userDao = $user->Dao;
150150
$cookieData = $this->getRequest()->getCookie('recentItems'.$this->userSession->Dao->user_id);
151151
$this->view->recentItems = array();
152-
if(isset($cookieData))
153-
{
152+
if(isset($cookieData) && file_exists(BASE_PATH.'/core/configs/database.local.ini')) //check if midas installed
153+
{
154154
$this->view->recentItems = unserialize($cookieData);
155155
$check = $this->_getParam('checkRecentItem');
156156
// check if recent items exit (every 5 minutes)

core/public/css/item/item.view.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ iframe#fullscreenVisualizeIframe{
4242

4343
div#fullscreenPanel{
4444
float:right;
45+
width:380px;
46+
-webkit-box-shadow: #CCC 0px 0px 3px;
47+
-moz-box-shadow: 0px 0px 6px #CCC;
48+
background-color: white;
49+
border: 1px solid #D7D7D7;
50+
-moz-border-radius: 6px;
51+
-webkit-border-radius: 6px;
52+
-khtml-border-radius: 6px;
53+
border-radius: 6px;
54+
padding: 0px 0px 7px;
55+
}
56+
57+
div#fullscreenPanel h1{
58+
font-size: 14px;
4559
}
4660

4761
div#fullscreenPanel ul{

core/public/js/upload/upload.simpleupload.js

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,10 @@
3434
});
3535

3636

37-
// if($.browser.msie&&$.browser.version<9)
38-
if($.browser.msie)
39-
{
40-
$('#swfuploadContent').show();
41-
$('#jqueryFileUploadContent').hide();
42-
initSwfupload();
43-
}
44-
else
45-
{
46-
$('#swfuploadContent').hide();
47-
$('#jqueryFileUploadContent').show();
48-
initJqueryFileupload();
49-
}
37+
38+
$('#swfuploadContent').hide();
39+
$('#jqueryFileUploadContent').show();
40+
initJqueryFileupload();
5041

5142
function sendParentToJavaSession()
5243
{
@@ -78,62 +69,6 @@
7869
}
7970

8071

81-
function initSwfupload()
82-
{
83-
var settings = {
84-
flash_url : json.global.coreWebroot+"/public/js/swfupload/swfupload_fp10/swfupload.swf",
85-
flash9_url :json.global.coreWebroot+"/public/js/swfupload/swfupload_fp9/swfupload_fp9.swf",
86-
upload_url:json.global.webroot+"/upload/saveuploaded",
87-
post_params: {"sid" : $('.sessionId').val(),"parent": $('#destinationId').val(),'license': $('select[name=licenseSelect]').val()},
88-
file_size_limit : $('.maxSizeFile').val()+" MB",
89-
file_types : "*.*",
90-
file_types_description : "All Files",
91-
file_upload_limit : 100,
92-
file_queue_limit : 0,
93-
custom_settings : {
94-
progressTarget : "fsUploadProgress",
95-
cancelButtonId : "btnCancel"
96-
},
97-
debug: false,
98-
99-
// Button settings
100-
button_image_url: json.global.coreWebroot+"/public/js/swfupload/images/Button_65x29.png",
101-
button_width: "65",
102-
button_height: "20",
103-
button_placeholder_id: "spanButtonPlaceHolder",
104-
button_text: '<span class="theFont">'+$('.buttonBrowse').val()+'</span>',
105-
button_text_style: ".theFont { font-size: 12; }",
106-
button_text_left_padding: 5,
107-
button_text_top_padding: 0,
108-
109-
// The event handler functions are defined in handlers.js
110-
swfupload_preload_handler : preLoad,
111-
swfupload_load_failed_handler : loadFailed,
112-
file_queued_handler : fileQueued,
113-
file_queue_error_handler : fileQueueError,
114-
file_dialog_complete_handler : fileDialogComplete,
115-
upload_start_handler : uploadPreStart,
116-
upload_progress_handler : uploadProgress,
117-
upload_error_handler : uploadError,
118-
upload_success_handler : uploadSuccess,
119-
upload_complete_handler : uploadComplete,
120-
queue_complete_handler : queueComplete // Queue plugin event
121-
};
122-
$('#swfuploadContent').show();
123-
swfu = new SWFUpload(settings);
124-
125-
$('#startUploadLink').click(function()
126-
{
127-
if($('#destinationId').val()==undefined||$('#destinationId').val().length==0)
128-
{
129-
createNotive("Please select where you want to upload your files.", 4000);
130-
return false;
131-
}
132-
swfu.startUpload();
133-
});
134-
}
135-
136-
13772
function initJqueryFileupload()
13873
{
13974
updateUploadedCount();

core/views/item/view.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PURPOSE. See the above copyright notices for more information.
1818
$this->headScript()->appendFile($this->coreWebroot . '/public/js/item/item.view.js');
1919
if($this->preview) // module visualize
2020
{
21+
$this->headScript()->appendFile($this->coreWebroot.'/public/js/common/common.browser.js');
2122
$this->headScript()->appendFile($this->webroot . '/modules/visualize/public/js/main.js');
2223
}
2324
?>

core/views/upload/simpleupload.phtml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,6 @@ PURPOSE. See the above copyright notices for more information.
1414
<link href="<?php echo $this->coreWebroot?>/public/css/jquery/jquery.fileupload-ui.css?<?php echo time()?>" rel="stylesheet" type="text/css" />
1515
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
1616

17-
<?php
18-
if (Zend_Registry::get("configGlobal")->smartoptimizer == 1)
19-
{
20-
echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/swfupload/js/swfupload.js,swfupload.queue.js,fileprogress.js,handlers.js"></script>';
21-
}
22-
else
23-
{
24-
?>
25-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/swfupload/js/swfupload.js"></script>
26-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/swfupload/js/swfupload.queue.js"></script>
27-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/swfupload/js/fileprogress.js"></script>
28-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/swfupload/js/handlers.js"></script>
29-
<?php
30-
}
31-
?>
32-
33-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload.js"></script>
34-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload-ui.js"></script>
35-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload-uix.js"></script>
36-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.form.js"></script>
37-
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/upload/upload.simpleupload.js?<?php echo time()?>"></script>
38-
3917
<div class="tabs" id='uploadTabs'>
4018
<ul>
4119
<li><a href="#uploadTabs-1">Simple</a></li>
@@ -45,13 +23,6 @@ PURPOSE. See the above copyright notices for more information.
4523
<div id="uploadTabs-1">
4624
<b><?php echo $this->t('Step 1: Select files to upload')?></b>
4725
<br/>
48-
<div id="swfuploadContent">
49-
<span id="spanButtonPlaceHolder"></span>
50-
<div>
51-
<div class="fieldset flash" id="fsUploadProgress">
52-
</div>
53-
</div>
54-
</div>
5526
<div id="jqueryFileUploadContent">
5627
<div id="file_upload">
5728
<form action="<?php echo $this->webroot?>/upload/saveuploaded" method="POST" enctype="multipart/form-data">
@@ -156,4 +127,21 @@ PURPOSE. See the above copyright notices for more information.
156127
<input type="hidden" class="uploadedLinks" value="0"/>
157128

158129

130+
<?php
131+
if (Zend_Registry::get("configGlobal")->smartoptimizer == 1)
132+
{
133+
echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/jquery/jquery.fileupload.js,jquery.fileupload-ui.js,jquery.fileupload-uix.js,jquery.form.js"></script>';
134+
}
135+
else
136+
{
137+
?>
138+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload.js"></script>
139+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload-ui.js"></script>
140+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.fileupload-uix.js"></script>
141+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/jquery/jquery.form.js"></script>
142+
<?php
143+
}
144+
?>
145+
<script type="text/javascript" src="<?php echo $this->coreWebroot?>/public/js/upload/upload.simpleupload.js"></script>
146+
159147

modules/visualize/configs/module.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ fullname= Visualization
66
; description
77
description= "Preview online various types of document (Beta version)"
88

9-
useparaview = "false"
9+
useparaview = "false"
10+
userwebgl = "true"
11+
customtmp = ''
12+
paraviewworkdir = ''

modules/visualize/controllers/ConfigController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function indexAction()
2727

2828
$module = 'visualize';
2929

30-
if(file_exists(BASE_PATH."/core/configs/api.local.ini"))
30+
if(file_exists(BASE_PATH."/core/configs/".$module.".local.ini"))
3131
{
3232
$applicationConfig = parse_ini_file(BASE_PATH."/core/configs/".$module.".local.ini", true);
3333
}
@@ -39,6 +39,9 @@ function indexAction()
3939

4040
$formArray = $this->getFormAsArray($configForm);
4141
$formArray['useparaview']->setValue($applicationConfig['global']['useparaview']);
42+
$formArray['userwebgl']->setValue($applicationConfig['global']['userwebgl']);
43+
$formArray['customtmp']->setValue($applicationConfig['global']['customtmp']);
44+
$formArray['paraviewworkdir']->setValue($applicationConfig['global']['paraviewworkdir']);
4245

4346
$this->view->configForm = $formArray;
4447

@@ -58,6 +61,9 @@ function indexAction()
5861
rename(BASE_PATH."/core/configs/".$module.".local.ini",BASE_PATH."/core/configs/".$module.".local.ini.old");
5962
}
6063
$applicationConfig['global']['useparaview'] = $this->_getParam('useparaview');
64+
$applicationConfig['global']['customtmp'] = $this->_getParam('customtmp');
65+
$applicationConfig['global']['userwebgl'] = $this->_getParam('userwebgl');
66+
$applicationConfig['global']['paraviewworkdir'] = $this->_getParam('paraviewworkdir');
6167
$this->Component->Utility->createInitFile(BASE_PATH."/core/configs/".$module.".local.ini", $applicationConfig);
6268
echo JsonComponent::encode(array(true, 'Changed saved'));
6369
}

modules/visualize/controllers/MediaController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function indexAction()
3333
}
3434
$this->bistream = $bitstreams[0];
3535

36-
$ext = substr(strrchr($bitstreams[0]->getName(), '.'), 1);
36+
$ext = strtolower(substr(strrchr($bitstreams[0]->getName(), '.'), 1));
3737
if(in_array($ext, array('avi', 'mp4', 'm4v')))
3838
{
3939
$this->view->json['type'] = 'm4v';

modules/visualize/controllers/ParaviewController.php

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,66 @@ public function indexAction()
2424
{
2525
throw new Zend_Exception("This item doesn't exist or you don't have the permissions.");
2626
}
27+
28+
$modulesConfig=Zend_Registry::get('configsModules');
29+
$paraviewworkdir = $modulesConfig['visualize']->paraviewworkdir;
30+
$customtmp = $modulesConfig['visualize']->customtmp;
31+
$useparaview = $modulesConfig['visualize']->useparaview;
32+
$userwebgl = $modulesConfig['visualize']->userwebgl;
33+
if(!isset($useparaview) || !$useparaview)
34+
{
35+
throw new Zend_Exception('Please unable paraviewweb');
36+
}
2737

28-
if(!file_exists(BASE_PATH.'/tmp/visualize'))
38+
if(!isset($paraviewworkdir) || empty($paraviewworkdir))
2939
{
30-
mkdir(BASE_PATH.'/tmp/visualize');
40+
throw new Zend_Exception('Please set the paraview work directory');
41+
}
42+
43+
if(isset($customtmp) && !empty($customtmp))
44+
{
45+
$tmp_dir = $customtmp;
46+
if(!file_exists($tmp_dir) || !is_writable($tmp_dir))
47+
{
48+
throw new Zend_Exception('Unable to access temp dir');
49+
}
50+
}
51+
else
52+
{
53+
if(!file_exists(BASE_PATH.'/tmp/visualize'))
54+
{
55+
mkdir(BASE_PATH.'/tmp/visualize');
56+
}
57+
$tmp_dir = BASE_PATH.'/tmp/visualize';
58+
}
59+
60+
$dir = opendir($tmp_dir);
61+
while($entry = readdir($dir))
62+
{
63+
if(is_dir($tmp_dir.'/'.$entry) && filemtime($tmp_dir.'/'.$entry) < strtotime('-1 hours') && !in_array($entry, array('.','..')))
64+
{
65+
if(strpos($entry, 'Paraview') !== false)
66+
{
67+
$this->rrmdir($tmp_dir.'/'.$entry);
68+
}
69+
}
3170
}
32-
3371
do
3472
{
3573
$tmpFolderName = 'ParaviewWeb_'.mt_rand(0, 9999999);
36-
$path = BASE_PATH.'/tmp/visualize/'.$tmpFolderName;
74+
$path = $tmp_dir.'/'.$tmpFolderName;
3775
}
38-
while (!mkdir($path, '700'));
76+
while (!mkdir($path));
3977

4078
$revision = $this->Item->getLastRevision($item);
4179
$bitstreams = $revision->getBitstreams();
4280
foreach($bitstreams as $bitstream)
4381
{
4482
copy($bitstream->getFullPath(), $path.'/'.$bitstream->getName());
45-
$ext = substr(strrchr($bitstream->getName(), '.'), 1);
83+
$ext = strtolower(substr(strrchr($bitstream->getName(), '.'), 1));
4684
if($ext != 'pvsm')
4785
{
48-
$filePath = "/workspace/PW-work/midas/".$tmpFolderName.'/'.$bitstream->getName();
86+
$filePath = $paraviewworkdir."/".$tmpFolderName.'/'.$bitstream->getName();
4987
$mainBitstream = $bitstream;
5088
}
5189
}
@@ -54,12 +92,12 @@ public function indexAction()
5492

5593
foreach($bitstreams as $bitstream)
5694
{
57-
$ext = substr(strrchr($bitstream->getName(), '.'), 1);
95+
$ext = strtolower(substr(strrchr($bitstream->getName(), '.'), 1));
5896
if($ext == 'pvsm')
5997
{
6098
$file_contents = file_get_contents($path.'/'.$bitstream->getName());
6199
$file_contents = preg_replace('/\"([a-zA-Z0-9_.\/\\\:]{1,1000})'. str_replace('.', '\.', $mainBitstream->getName())."/", '"'.$filePath, $file_contents);
62-
$filePath = "/workspace/PW-work/midas/".$tmpFolderName.'/'.$bitstream->getName();
100+
$filePath = $paraviewworkdir."/".$tmpFolderName.'/'.$bitstream->getName();
63101
$inF = fopen($path.'/'.$bitstream->getName(),"w");
64102
fwrite($inF, $file_contents);
65103
fclose($inF);
@@ -69,18 +107,44 @@ public function indexAction()
69107
}
70108

71109

72-
if($item->getSizebytes()> 1*1024*1024)
110+
if(!$userwebgl || $item->getSizebytes()> 1*1024*1024)
73111
{
74112
$this->view->renderer = 'js';
75113
}
76114
else
77115
{
78116
$this->view->renderer = 'webgl';
79117
}
80-
81118
$this->view->json['visualize']['url'] = $filePath;
82119
$this->view->json['visualize']['width'] = $this->_getParam('width');
83-
$this->view->json['visualize']['height'] = $this->_getParam('height');
120+
$this->view->json['visualize']['height'] = $this->_getParam('height');
121+
$this->view->usewebgl = $userwebgl;
84122
}
123+
124+
/** recursively delete a folder*/
125+
private function rrmdir($dir)
126+
{
127+
if(is_dir($dir))
128+
{
129+
$objects = scandir($dir);
130+
}
131+
132+
foreach($objects as $object)
133+
{
134+
if($object != "." && $object != "..")
135+
{
136+
if(filetype($dir."/".$object) == "dir")
137+
{
138+
$this->rrmdir($dir."/".$object);
139+
}
140+
else
141+
{
142+
unlink($dir."/".$object);
143+
}
144+
}
145+
}
146+
reset($objects);
147+
rmdir($dir);
148+
}
85149
} // end class
86150
?>

0 commit comments

Comments
 (0)