@@ -95,7 +95,7 @@ function editmetadataAction()
95
95
*/
96
96
function viewAction ()
97
97
{
98
- $ this -> view -> header = $ this -> t ( " Item " );
98
+
99
99
$ this ->view ->Date = $ this ->Component ->Date ;
100
100
$ this ->view ->Utility = $ this ->Component ->Utility ;
101
101
$ itemId = $ this ->_getParam ("itemId " );
@@ -108,9 +108,9 @@ function viewAction()
108
108
{
109
109
throw new Zend_Exception ("This item doesn't exist. " );
110
110
}
111
- if (!$ this ->Item ->policyCheck ($ itemDao , $ this ->userSession ->Dao ))
111
+ if (!$ this ->Item ->policyCheck ($ itemDao , $ this ->userSession ->Dao , MIDAS_POLICY_READ ))
112
112
{
113
- throw new Zend_Exception (" Problem policies. " );
113
+ throw new Zend_Exception (' Invalid policy: no read permission ' );
114
114
}
115
115
116
116
$ this ->view ->isAdmin = $ this ->Item ->policyCheck ($ itemDao , $ this ->userSession ->Dao , MIDAS_POLICY_ADMIN );
@@ -186,7 +186,6 @@ function viewAction()
186
186
// Display the good link if the item is pointing to a website
187
187
$ this ->view ->itemIsLink = false ;
188
188
189
-
190
189
if (isset ($ itemRevision ) && $ itemRevision !== false )
191
190
{
192
191
$ bitstreams = $ itemRevision ->getBitstreams ();
@@ -199,7 +198,12 @@ function viewAction()
199
198
}
200
199
}
201
200
$ 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 );
203
207
}
204
208
205
209
$ this ->Component ->Sortdao ->field = 'revision ' ;
@@ -213,9 +217,7 @@ function viewAction()
213
217
$ this ->view ->title .= ' - ' .$ itemDao ->getName ();
214
218
$ this ->view ->metaDescription = substr ($ itemDao ->getDescription (), 0 , 160 );
215
219
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 ));
219
221
if (isset ($ tmp ['visualize ' ]) && $ tmp ['visualize ' ] == true )
220
222
{
221
223
$ this ->view ->preview = true ;
@@ -225,55 +227,72 @@ function viewAction()
225
227
$ this ->view ->preview = false ;
226
228
}
227
229
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 )
232
233
{
233
- $ this ->view ->backUploaded = true ;
234
- $ items = $ this ->Item ->load ($ this ->userSession ->uploaded );
234
+ $ currentFolder = $ parents [0 ];
235
235
}
236
- else
236
+ elseif ( isset ( $ this -> userSession -> recentFolders ))
237
237
{
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 )
244
239
{
245
- foreach ($ parents as $ p )
240
+ foreach ($ parents as $ parent )
246
241
{
247
- if (in_array ( $ p ->getKey (), $ this -> userSession -> recentFolders ) )
242
+ if ($ parent ->getKey () == $ recent )
248
243
{
249
- $ currentFolder = $ p ;
244
+ $ currentFolder = $ parent ;
250
245
break ;
251
246
}
252
247
}
253
-
254
248
}
255
- if (isset ( $ currentFolder) )
249
+ if ($ currentFolder === false && count ( $ parents ) > 0 )
256
250
{
257
- $ items = $ this ->Folder ->getItemsFiltered ($ currentFolder , $ this ->userSession ->Dao , MIDAS_POLICY_READ );
258
- $ this ->view ->currentFolder = $ currentFolder ;
251
+ $ currentFolder = $ parents [0 ];
259
252
}
260
253
}
254
+ else if (count ($ parents ) > 0 )
255
+ {
256
+ $ currentFolder = $ parents [0 ];
257
+ }
258
+ $ this ->view ->currentFolder = $ currentFolder ;
259
+ $ parent = $ currentFolder ;
261
260
262
- foreach ($ items as $ key => $ item )
261
+ $ header = '' ;
262
+ while ($ parent !== false )
263
263
{
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 )
266
265
{
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 ;
268
273
}
269
274
else
270
275
{
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 ;
272
277
}
278
+ $ parent = $ parent ->getParent ();
273
279
}
280
+ $ header = "<ul class='pathBrowser'> " .$ header ;
281
+ $ header .= "</ul> " ;
282
+ $ this ->view ->header = $ header ;
274
283
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 ;
276
294
295
+ $ itemDao ->setDescription (htmlentities ($ itemDao ->getDescription ()));
277
296
$ this ->view ->json ['item ' ] = $ itemDao ->toArray ();
278
297
$ this ->view ->json ['item ' ]['message ' ]['delete ' ] = $ this ->t ('Delete ' );
279
298
$ 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. ' );
0 commit comments