@@ -44,6 +44,7 @@ public function indexAction()
4444 $ folderIds = $ this ->_getParam ('folders ' );
4545 $ bitsreamid = $ this ->_getParam ('bitstream ' );
4646 $ sessionUser = $ this ->userSession ->Dao ;
47+ $ testingMode = Zend_Registry::get ('configGlobal ' )->environment == 'testing ' ;
4748 if ($ sessionUser != null )
4849 {
4950 // Make sure this is a copy and not a reference
@@ -148,7 +149,7 @@ public function indexAction()
148149 $ revision = $ revisions [0 ];
149150 $ bitstreams = $ revision ->getBitstreams ();
150151
151- if ($ this -> _getParam ( ' testingmode ' ) == ' 1 ' )
152+ if ($ testingMode )
152153 {
153154 $ bitstreams = array ($ bitstreams [0 ]);
154155 }
@@ -167,10 +168,7 @@ public function indexAction()
167168 return ;
168169 }
169170 $ this ->disableView ();
170- if ($ this ->_getParam ('testingmode ' ) == '1 ' )
171- {
172- $ this ->Component ->DownloadBitstream ->testingmode = true ;
173- }
171+ $ this ->Component ->DownloadBitstream ->testingmode = $ testingMode ;
174172 $ this ->Component ->DownloadBitstream ->download ($ bitstreams [0 ], $ offset , true );
175173 }
176174 else
@@ -348,6 +346,57 @@ public function checksizeAction()
348346 }
349347 }
350348
349+ /**
350+ * This action exposes downloading a single item and should be called as
351+ * download/item/<item_id>/...
352+ * Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
353+ * if the content-disposition header is ignored by the user agent.
354+ */
355+ public function itemAction ()
356+ {
357+ $ pathParams = UtilityComponent::extractPathParams ();
358+ if (empty ($ pathParams ))
359+ {
360+ throw new Zend_Exception ('Must specify item id as a path parameter ' );
361+ }
362+
363+ $ this ->_forward ('index ' , null , null , array ('items ' => $ pathParams [0 ]));
364+ }
365+
366+ /**
367+ * This action exposes downloading a single folder and should be called as
368+ * download/folder/<folder_id>/...
369+ * Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
370+ * if the content-disposition header is ignored by the user agent.
371+ */
372+ public function folderAction ()
373+ {
374+ $ pathParams = UtilityComponent::extractPathParams ();
375+ if (empty ($ pathParams ))
376+ {
377+ throw new Zend_Exception ('Must specify folder id as a path parameter ' );
378+ }
379+
380+ $ this ->_forward ('index ' , null , null , array ('folders ' => $ pathParams [0 ]));
381+ }
382+
383+ /**
384+ * This action exposes downloading a single bitstream and should be called as
385+ * download/bitstream/<bitstream_id>/...
386+ * Any extra parameters are ignored and can be used to force clients like wget to download to the correct filename
387+ * if the content-disposition header is ignored by the user agent.
388+ */
389+ public function bitstreamAction ()
390+ {
391+ $ pathParams = UtilityComponent::extractPathParams ();
392+ if (empty ($ pathParams ))
393+ {
394+ throw new Zend_Exception ('Must specify bitstream id as a path parameter ' );
395+ }
396+
397+ $ this ->_forward ('index ' , null , null , array ('bitstream ' => $ pathParams [0 ]));
398+ }
399+
351400 /**
352401 * Render the view for the large data downloader applet
353402 * @param itemIds Comma separated list of items to download
@@ -477,7 +526,7 @@ private function _downloadEmptyItem($item)
477526 }
478527 ob_start ();
479528 Zend_Loader::loadClass ('ZipStream ' , BASE_PATH .'/library/ZipStream/ ' );
480- $ this ->_helper -> viewRenderer -> setNoRender ();
529+ $ this ->disableView ();
481530 if (isset ($ item ) && $ item instanceof ItemDao)
482531 {
483532 $ name = $ item ->getName ();
0 commit comments