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

Commit d9060d1

Browse files
committed
ENH: refs #0460. Improve the item view page
*Add history view *Add License view (stub currently) *Add description view *Remove "in the same folder" section *Add "in folders" section if more than one parent folder *Add smart breadcrumb navigation and remove the Back button
1 parent 7fef18b commit d9060d1

File tree

7 files changed

+349
-279
lines changed

7 files changed

+349
-279
lines changed

core/controllers/FolderController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,14 @@ public function viewAction()
136136
{
137137
$user = $this->Folder->getUser($parent);
138138
$header = " <li class = 'pathUser'><img alt = '' src = '".$this->view->coreWebroot."/public/images/icons/unknownUser-small.png' /><span><a href = '".$this->view->webroot."/user/".$user->getKey()."'>".$this->Component->Utility->sliceName($user->getFullName(), 25)."</a></span></li>".$header;
139-
140139
}
141140
else
142141
{
143142
$header = " <li class = 'pathFolder'><img alt = '' src = '".$this->view->coreWebroot."/public/images/FileTree/directory.png' /><span><a href = '".$this->view->webroot."/folder/".$parent->getKey()."'>".$this->Component->Utility->sliceName($parent->getName(), 15)."</a></span></li>".$header;
144143
}
145144
$parent = $parent->getParent();
146145
}
147-
$header = "<ul class = 'pathBrowser'>".$header;
146+
$header = "<ul class='pathBrowser'>".$header;
148147
$header .= "</ul>";
149148
}
150149

@@ -169,6 +168,7 @@ public function viewAction()
169168

170169
$this->view->title .= ' - '.$folder->getName();
171170
$this->view->metaDescription = substr($folder->getDescription(), 0, 160);
171+
$folder->setDescription(htmlentities($folder->getDescription()));
172172
$this->view->json['folder'] = $folder;
173173
}// end View Action
174174

core/controllers/ItemController.php

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function editmetadataAction()
9595
*/
9696
function viewAction()
9797
{
98-
$this->view->header = $this->t("Item");
98+
9999
$this->view->Date = $this->Component->Date;
100100
$this->view->Utility = $this->Component->Utility;
101101
$itemId = $this->_getParam("itemId");
@@ -108,9 +108,9 @@ function viewAction()
108108
{
109109
throw new Zend_Exception("This item doesn't exist.");
110110
}
111-
if(!$this->Item->policyCheck($itemDao, $this->userSession->Dao))
111+
if(!$this->Item->policyCheck($itemDao, $this->userSession->Dao, MIDAS_POLICY_READ))
112112
{
113-
throw new Zend_Exception("Problem policies.");
113+
throw new Zend_Exception('Invalid policy: no read permission');
114114
}
115115

116116
$this->view->isAdmin = $this->Item->policyCheck($itemDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
@@ -186,7 +186,6 @@ function viewAction()
186186
// Display the good link if the item is pointing to a website
187187
$this->view->itemIsLink = false;
188188

189-
190189
if(isset($itemRevision) && $itemRevision !== false)
191190
{
192191
$bitstreams = $itemRevision->getBitstreams();
@@ -199,7 +198,12 @@ function viewAction()
199198
}
200199
}
201200
$itemDao->creation = $this->Component->Date->formatDate(strtotime($itemRevision->getDate()));
202-
$this->view->metadatavalues = $this->ItemRevision->getMetadata($itemRevision);
201+
}
202+
203+
// Add the metadata for each revision
204+
foreach($itemDao->getRevisions() as $revision)
205+
{
206+
$revision->metadatavalues = $this->ItemRevision->getMetadata($revision);
203207
}
204208

205209
$this->Component->Sortdao->field = 'revision';
@@ -213,9 +217,7 @@ function viewAction()
213217
$this->view->title .= ' - '.$itemDao->getName();
214218
$this->view->metaDescription = substr($itemDao->getDescription(), 0, 160);
215219

216-
217-
218-
$tmp = Zend_Registry::get('notifier')->callback("CALLBACK_VISUALIZE_CAN_VISUALIZE", array('item' => $itemDao));
220+
$tmp = Zend_Registry::get('notifier')->callback('CALLBACK_VISUALIZE_CAN_VISUALIZE', array('item' => $itemDao));
219221
if(isset($tmp['visualize']) && $tmp['visualize'] == true)
220222
{
221223
$this->view->preview = true;
@@ -225,55 +227,72 @@ function viewAction()
225227
$this->view->preview = false;
226228
}
227229

228-
$items = array();
229-
$this->view->backUploaded = false;
230-
$this->view->currentFolder = false;
231-
if(isset($this->userSession->uploaded) && in_array($itemDao->getKey(), $this->userSession->uploaded))
230+
$currentFolder = false;
231+
$parents = $itemDao->getFolders();
232+
if(count($parents) == 1)
232233
{
233-
$this->view->backUploaded = true;
234-
$items = $this->Item->load($this->userSession->uploaded);
234+
$currentFolder = $parents[0];
235235
}
236-
else
236+
elseif(isset($this->userSession->recentFolders))
237237
{
238-
$parents = $itemDao->getFolders();
239-
if(count($parents) == 1)
240-
{
241-
$currentFolder = $parents[0];
242-
}
243-
elseif(isset($this->userSession->recentFolders))
238+
foreach($this->userSession->recentFolders as $recent)
244239
{
245-
foreach($parents as $p)
240+
foreach($parents as $parent)
246241
{
247-
if(in_array($p->getKey(), $this->userSession->recentFolders))
242+
if($parent->getKey() == $recent)
248243
{
249-
$currentFolder = $p;
244+
$currentFolder = $parent;
250245
break;
251246
}
252247
}
253-
254248
}
255-
if(isset($currentFolder))
249+
if($currentFolder === false && count($parents) > 0)
256250
{
257-
$items = $this->Folder->getItemsFiltered($currentFolder, $this->userSession->Dao, MIDAS_POLICY_READ);
258-
$this->view->currentFolder = $currentFolder;
251+
$currentFolder = $parents[0];
259252
}
260253
}
254+
else if(count($parents) > 0)
255+
{
256+
$currentFolder = $parents[0];
257+
}
258+
$this->view->currentFolder = $currentFolder;
259+
$parent = $currentFolder;
261260

262-
foreach($items as $key => $item)
261+
$header = '';
262+
while($parent !== false)
263263
{
264-
$tmp = Zend_Registry::get('notifier')->callback("CALLBACK_VISUALIZE_CAN_VISUALIZE", array('item' => $item));
265-
if(isset($tmp['visualize']) && $tmp['visualize'] == true)
264+
if(strpos($parent->getName(), 'community') !== false && $this->Folder->getCommunity($parent) !== false)
266265
{
267-
$items[$key]->preview = 'true';
266+
$community = $this->Folder->getCommunity($parent);
267+
$header = " <li class = 'pathCommunity'><img alt = '' src = '".$this->view->coreWebroot."/public/images/icons/community.png' /><span><a href = '".$this->view->webroot."/community/".$community->getKey()."#tabs-3'>".$this->Component->Utility->sliceName($community->getName(), 25)."</a></span></li>".$header;
268+
}
269+
elseif(strpos($parent->getName(), 'user') !== false && $this->Folder->getUser($parent) !== false)
270+
{
271+
$user = $this->Folder->getUser($parent);
272+
$header = " <li class = 'pathUser'><img alt = '' src = '".$this->view->coreWebroot."/public/images/icons/unknownUser-small.png' /><span><a href = '".$this->view->webroot."/user/".$user->getKey()."'>".$this->Component->Utility->sliceName($user->getFullName(), 25)."</a></span></li>".$header;
268273
}
269274
else
270275
{
271-
$items[$key]->preview = 'false';
276+
$header = " <li class = 'pathFolder'><img alt = '' src = '".$this->view->coreWebroot."/public/images/FileTree/directory.png' /><span><a href = '".$this->view->webroot."/folder/".$parent->getKey()."'>".$this->Component->Utility->sliceName($parent->getName(), 15)."</a></span></li>".$header;
272277
}
278+
$parent = $parent->getParent();
273279
}
280+
$header = "<ul class='pathBrowser'>".$header;
281+
$header .= "</ul>";
282+
$this->view->header = $header;
274283

275-
$this->view->sameLocation = $items;
284+
$folders = array();
285+
$parents = $itemDao->getFolders();
286+
foreach($parents as $parent)
287+
{
288+
if($this->Folder->policyCheck($parent, $this->userSession->Dao, MIDAS_POLICY_READ))
289+
{
290+
$folders[] = $parent;
291+
}
292+
}
293+
$this->view->folders = $folders;
276294

295+
$itemDao->setDescription(htmlentities($itemDao->getDescription()));
277296
$this->view->json['item'] = $itemDao->toArray();
278297
$this->view->json['item']['message']['delete'] = $this->t('Delete');
279298
$this->view->json['item']['message']['sharedItem'] = $this->t('This item is currrently shared by other folders and/or communities. Deletion will make it disappear in all these folders and/or communitites. ');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ div.viewInfo{
1111
}
1212

1313
div.viewHeader{
14-
padding: 0px 0px 4px 25px!important;
14+
padding: 0px 0px 4px 15px!important;
1515
}
1616

1717
div.genericBigButton{

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

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
div#revisionContent{
2-
display:none;
3-
}
41
div.viewAction{
52
display:block!important;
63
}
@@ -15,7 +12,6 @@ table#browseTable{
1512

1613
table#metadataTable {
1714
display: table!important;
18-
width: 580px;
1915
table-layout: fixed;
2016
}
2117

@@ -43,7 +39,7 @@ div.genericInfo .genericSubtitle {
4339
}
4440

4541
.itemStats {
46-
float: right;
42+
float: right;
4743
font-size: 10px;
4844
color: #777777;
4945
margin-right: 10px;
@@ -83,4 +79,61 @@ img.closeVisuButton{
8379

8480
div.manageMetadata{
8581
float:right;
86-
}
82+
}
83+
84+
#revisionList h3 a {
85+
text-decoration: none;
86+
}
87+
88+
#revisionList a img {
89+
float: left;
90+
margin-right: 2px;
91+
}
92+
93+
#parentList a img {
94+
position: relative;
95+
top: 3px;
96+
}
97+
98+
#licenseDiv {
99+
100+
}
101+
102+
div.itemViewMainSection {
103+
border-top: 1px solid #D7D7D7;
104+
margin-bottom: 14px;
105+
}
106+
107+
div.itemViewMainSection h4 {
108+
color: #999;
109+
font-size: 11px;
110+
text-shadow: white 0px 1px 1px;
111+
text-transform: uppercase;
112+
margin-top: 0.67em;
113+
margin-bottom: 0.67em;
114+
}
115+
116+
table.bitstreamList, table.metadataList {
117+
width: 100%;
118+
border-spacing: 0px;
119+
border-collapse: collapse;
120+
}
121+
122+
table.bitstreamList th, table.metadataList th {
123+
border: 1px solid gray;
124+
background-color: #D0D0F6;
125+
}
126+
127+
table.bitstreamList td, table.metadataList td {
128+
border: 1px solid #B5B5B5;
129+
}
130+
131+
div.viewHeader{
132+
padding: 0px 0px 4px 15px!important;
133+
}
134+
135+
div.revisionEntry {
136+
padding-left: 13px !important;
137+
padding-right: 13px !important;
138+
border-top: 1px solid #A7A7A7 !important;
139+
}
71 Bytes
Loading

0 commit comments

Comments
 (0)