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

Commit 1c2dfc3

Browse files
author
Charles Marion
committed
ENH: Improved paraview web visualization
Added online visualization: pdf, txt, audio, video, image
1 parent 3d0ad25 commit 1c2dfc3

File tree

26 files changed

+591
-116
lines changed

26 files changed

+591
-116
lines changed

core/AppController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,15 @@ public function preDispatch()
100100
}
101101
}
102102

103+
$controllerName = $fc->getRequest()->getControllerName();
104+
$actionName = $fc->getRequest()->getActionName();
103105
if($fc->getRequest()->getControllerName() == 'browse' || $fc->getRequest()->getControllerName() == 'download')
104106
{
105-
session_write_close();
107+
$element = $this->_getParam('type');
108+
if($actionName != 'getelementinfo' || !isset($element) || $element != 'folder')
109+
{
110+
session_write_close();
111+
}
106112
}
107113
$this->userSession = $user;
108114
$this->view->recentItems = array();

core/controllers/BrowseController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class BrowseController extends AppController
2323
function init()
2424
{
2525
$this->view->activemenu = 'browse'; // set the active menu
26-
session_write_close();
2726
} // end init()
2827

2928
/** Index Action*/
@@ -294,6 +293,15 @@ public function getelementinfoAction()
294293
$folder = $this->Folder->load($id);
295294
$jsonContent = array_merge($jsonContent, $folder->toArray());
296295
$jsonContent['creation'] = $this->Component->Date->formatDate(strtotime($jsonContent['date']));
296+
if(!isset($this->userSession->Dao->recentFolders))
297+
{
298+
$this->userSession->Dao->recentFolders = array();
299+
}
300+
array_push($this->userSession->Dao->recentFolders, $folder->getKey());
301+
if(count($this->userSession->Dao->recentFolders) > 5)
302+
{
303+
array_shift($this->userSession->Dao->recentFolders);
304+
}
297305
break;
298306
case 'item':
299307
$item = $this->Item->load($id);

core/controllers/FolderController.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,21 @@ public function viewAction()
126126
}
127127
$parent = $parent->getParent();
128128
}
129-
$header = "<ul class = 'pathBrowser'>
130-
<li class = 'pathData'><a href = '".$this->view->webroot."/browse'>".$this->t('Data')."</a></li>".$header;
129+
$header = "<ul class = 'pathBrowser'>"
130+
.$header;
131131
$header .= "</ul>";
132132
}
133133

134+
if(!isset($this->userSession->Dao->recentFolders))
135+
{
136+
$this->userSession->Dao->recentFolders = array();
137+
}
138+
array_push($this->userSession->Dao->recentFolders, $folder->getKey());
139+
if(count($this->userSession->Dao->recentFolders) > 5)
140+
{
141+
array_shift($this->userSession->Dao->recentFolders);
142+
}
143+
134144
$this->Folder->incrementViewCount($folder);
135145
$this->view->mainFolder = $folder;
136146
$this->view->folders = $folders;
@@ -176,7 +186,7 @@ public function deleteAction()
176186
{
177187
throw new Zend_Exception("User Folder. You cannot delete it.");
178188
}
179-
$this->Folder->delete($folder);
189+
$this->Folder->delete($folder, true);
180190
$folderInfo = $folder->toArray();
181191
echo JsonComponent::encode(array(true, $this->t('Changes saved'), $folderInfo));
182192
}// end deleteAction

core/controllers/ItemController.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/** Item Controller */
1414
class ItemController extends AppController
1515
{
16-
public $_models = array('Item', 'ItemRevision', 'Bitstream');
16+
public $_models = array('Item', 'ItemRevision', 'Bitstream', 'Folder');
1717
public $_daos = array();
1818
public $_components = array('Date', 'Utility', 'Sortdao');
1919
public $_forms = array('Item');
@@ -128,6 +128,43 @@ function viewAction()
128128
{
129129
$this->view->preview = false;
130130
}
131+
132+
$items = array();
133+
if(in_array($itemDao->getKey(), $this->userSession->uploaded))
134+
{
135+
$items = $this->Item->load($this->userSession->uploaded);
136+
}
137+
else
138+
{
139+
$parents = $itemDao->getFolders();
140+
if(isset($this->userSession->Dao->recentFolders))
141+
{
142+
foreach($parents as $p)
143+
{
144+
if(in_array($p->getKey(), $this->userSession->Dao->recentFolders))
145+
{
146+
$currentFolder = $p;
147+
break;
148+
}
149+
}
150+
}
151+
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
152+
}
153+
154+
foreach($items as $key => $item)
155+
{
156+
$tmp = Zend_Registry::get('notifier')->notify(MIDAS_NOTIFY_CAN_VISUALIZE, array('item' => $item));
157+
if(isset($tmp['visualize']) && $tmp['visualize'] == true)
158+
{
159+
$items[$key]->preview = 'true';
160+
}
161+
else
162+
{
163+
$items[$key]->preview = 'false';
164+
}
165+
}
166+
167+
$this->view->sameLocation = $items;
131168

132169
$this->view->json['item'] = $itemDao->toArray();
133170
$this->view->json['item']['message']['delete'] = $this->t('Delete');

core/controllers/UserController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function indexAction()
5656
$this->view->order = $order;
5757
$this->view->offset = $offset;
5858
$this->view->users = $users;
59+
$this->view->nUsers = $this->User->getCountAll();
5960
} //end index
6061

6162
/** Recover the password (ajax) */

core/layouts/layout.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ echo $this->doctype()
171171
echo '<span style="color:red;">More than 5 errors occured in the last 24 hours. <a href="'.$this->webroot.'/admin/#ui-tabs-2">Check the logs</a></span><br/><br/>';
172172
}
173173
?>
174-
<div class=SubWrapper">
174+
<div class="SubWrapper">
175175

176176
<div class="MainContent">
177177
<div class="SideBar">

core/models/pdo/FolderModel.php

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function getRoot($folder)
209209
} // end getRoot()
210210

211211
/** Get the folder tree */
212-
function getAllChildren($folder, $userDao)
212+
function getAllChildren($folder, $userDao, $admin = false)
213213
{
214214
$isAdmin = false;
215215
if($userDao == null)
@@ -228,6 +228,11 @@ function getAllChildren($folder, $userDao)
228228
$isAdmin = true;
229229
}
230230
}
231+
232+
if($admin)
233+
{
234+
$isAdmin = true;
235+
}
231236

232237
if(!$folder instanceof FolderDao)
233238
{
@@ -349,6 +354,7 @@ public function move($folder, $parent)
349354
}
350355

351356
$tmpParent = $parent->getParent();
357+
$currentParent = $folder->getParent();
352358
while($tmpParent != false)
353359
{
354360
if($tmpParent->getKey() == $folder->getKey())
@@ -366,23 +372,82 @@ public function move($folder, $parent)
366372
{
367373
throw new Zend_Exception("Error parameter.");
368374
}
369-
$leftIndice = $folder->getLeftIndice();
370-
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice - 2')),
371-
array('left_indice >= ?' => $leftIndice));
372-
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice - 2')),
373-
array('right_indice >= ?' => $leftIndice));
374-
$folder->setParentId($parent->getKey());
375-
$rightParent = $parent->getRightIndice();
376375

377-
$folder->setRightIndice($rightParent + 1);
378-
$folder->setLeftIndice($rightParent);
376+
$node_id = $folder->getKey();
377+
$node_pos_left = $folder->getLeftIndice();
378+
$node_pos_right = $folder->getRightIndice();
379+
$parent_id = $parent->getKey();
380+
381+
$parent_pos_right = $parent->getRightIndice();
382+
$node_size = $node_pos_right - $node_pos_left + 1;
383+
384+
// step 1: temporary "remove" moving node
385+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('0 - left_indice'), 'right_indice' => new Zend_Db_Expr('0 - right_indice')),
386+
'left_indice >= '.$node_pos_left.' AND right_indice <= '.$node_pos_right);
379387

380-
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('2 + right_indice')),
381-
array('right_indice >= ?' => $rightParent));
382-
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('2 + left_indice')),
383-
array('left_indice >= ?' => $rightParent));
388+
// step 2: decrease left and/or right position values of currently 'lower' items (and parents)
389+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice - '.$node_size)),
390+
array('left_indice > ?' => $node_pos_right));
391+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice - '.$node_size)),
392+
array('right_indice > ?' => $node_pos_right));
384393

394+
// step 3: increase left and/or right position values of future 'lower' items (and parents)
395+
$cond = ($parent_pos_right > $node_pos_right ? $parent_pos_right - $node_size : $parent_pos_right);
396+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice + '.$node_size)),
397+
array('left_indice >= ?' => $cond));
398+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice + '.$node_size)),
399+
array('right_indice >= ?' => $cond));
400+
401+
// step 4: move node (ant it's subnodes) and update it's parent item id
402+
$cond = ($parent_pos_right > $node_pos_right) ? $parent_pos_right - $node_pos_right - 1 : $parent_pos_right - $node_pos_right - 1 + $node_size;
403+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('0 - left_indice + '.$cond), 'right_indice' => new Zend_Db_Expr('0 - right_indice + '.$cond)),
404+
'left_indice <= '.(0 - $node_pos_left).' AND right_indice >= '.(0 - $node_pos_right));
405+
406+
$folder = $this->load($folder->getKey());
407+
$folder->setParentId($parent->getKey());
385408
parent::save($folder);
409+
/*
410+
411+
$allChildren = $this->getAllChildren($folder, null, true);
412+
413+
$leftIndice = $folder->getLeftIndice();
414+
$rightIndice = $folder->getRightIndice();
415+
$rightParentIndice = $currentParent->getRightIndice();
416+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice - '.$diff)),
417+
array('left_indice > ?' => $rightIndice));
418+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice - '.$diff)),
419+
array('right_indice > ?' => $rightIndice));
420+
421+
422+
$childrenIds = array();
423+
foreach($allChildren as $child)
424+
{
425+
$childrenIds[] = $child->getKey();
426+
}
427+
$childrenIds[] = $folder->getKey();
428+
$folder = $this->load($folder->getKey());
429+
$parent = $this->load($parent->getKey());
430+
431+
$diff = $folder->getLeftIndice() - $parent->getRightIndice();
432+
433+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr('left_indice - '.$diff)),
434+
array('folder_id IN (?)' => $childrenIds));
435+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr('right_indice - '.$diff)),
436+
array('folder_id IN (?)' => $childrenIds));
437+
438+
$this->getLogger()->info('2:'.$diff);
439+
$parent = $this->load($parent->getKey());
440+
$folder = $this->load($folder->getKey());
441+
$diff = $folder->getRightIndice() - $parent->getRightIndice() + 1;
442+
443+
$this->database->getDB()->update('folder', array('right_indice' => new Zend_Db_Expr($diff.' + right_indice')),
444+
array('right_indice >= ?' => $parent->getRightIndice()));
445+
$this->database->getDB()->update('folder', array('left_indice' => new Zend_Db_Expr($diff.' + left_indice')),
446+
array('left_indice >= ?' => $parent->getRightIndice()));
447+
$folder = $this->load($folder->getKey());
448+
$folder->setParentId($parent->getKey());
449+
$this->getLogger()->info('3:'.$diff);
450+
parent::save($folder);*/
386451
}//end move
387452

388453
/** Custom save function*/

core/public/css/folder/folder.view.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ div.viewAction{
99
div.viewInfo{
1010
display:inherit!important;
1111
}
12+
13+
div.viewHeader{
14+
padding: 0px 0px 4px 25px!important;
15+
}
16+
17+
div.genericBigButton{
18+
position: relative;
19+
top:-20px;
20+
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,22 @@ div.genericInfo .genericCompany {
3434
font-size: 10px;
3535
color: #777777;
3636
margin-right: 10px;
37+
}
38+
39+
iframe#fullscreenVisualizeIframe{
40+
border:0;
41+
}
42+
43+
div#fullscreenPanel{
44+
float:right;
45+
}
46+
47+
div#fullscreenPanel ul{
48+
list-style: none;
49+
margin: 0;
50+
padding: 0;
51+
}
52+
53+
img.closeVisuButton{
54+
float:right;
3755
}

core/public/js/browse/browse.uploaded.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
var html='';
2626
if(type=='item')
2727
{
28-
html+='<li><a href="'+json.global.webroot+'/item/'+element+'">'+json.browse.view+'</a></li>';
29-
html+='<li><a href="'+json.global.webroot+'/download?items='+element+'">'+json.browse.downloadLastest+'</a></li>';
28+
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/view.png"/> <a href="'+json.global.webroot+'/item/'+element+'">'+json.browse.view+'</a></li>';
29+
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/download.png"/> <a href="'+json.global.webroot+'/download?items='+element+'">'+json.browse.downloadLastest+'</a></li>';
3030
if(policy>=1)
3131
{
32-
html+='<li><a type="item" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
33-
html+='<li ><a class onclick="deleteItem('+element+');">'+json.browse['delete']+'</a></li>';
32+
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/share.png"/> <a type="item" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
33+
html+='<li ><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/close.png"/> <a class onclick="deleteItem('+element+');">'+json.browse['delete']+'</a></li>';
3434
}
3535
}
3636
$('div.viewAction ul').html(html);

0 commit comments

Comments
 (0)