@@ -108,7 +108,8 @@ public function indexAction()
108
108
109
109
if (empty ($ folders ) && empty ($ revisions ))
110
110
{
111
- throw new Zend_Exception ('There is nothing to download ' );
111
+ // download an empty zip with the name of item (if it exists), then exit
112
+ $ this ->_downloadEmptyItem ($ item );
112
113
}
113
114
if (empty ($ folders ) && count ($ revisions ) == 1 )
114
115
{
@@ -122,7 +123,8 @@ public function indexAction()
122
123
123
124
if (count ($ bitstreams ) == 0 )
124
125
{
125
- throw new Zend_Exception ('Empty item ' );
126
+ // download an empty zip with the name of item (if it exists), then exit
127
+ $ this ->_downloadEmptyItem ($ item );
126
128
}
127
129
elseif (count ($ bitstreams ) == 1 )
128
130
{
@@ -202,6 +204,37 @@ public function indexAction()
202
204
}
203
205
}//end index
204
206
207
+ /**
208
+ * will download a zip file with the same name as the item name,
209
+ * if the item exists, then will exit.
210
+ * @param type $item
211
+ */
212
+ private function _downloadEmptyItem ($ item )
213
+ {
214
+ while (ob_get_level () > 0 )
215
+ {
216
+ ob_end_clean ();
217
+ }
218
+ ob_start ();
219
+ Zend_Loader::loadClass ('ZipStream ' , BASE_PATH .'/library/ZipStream/ ' );
220
+ $ this ->_helper ->viewRenderer ->setNoRender ();
221
+ if (isset ($ item ))
222
+ {
223
+ $ name = $ item ->getName ();
224
+ }
225
+ else
226
+ {
227
+ $ name = "No_item_selected " ;
228
+ }
229
+ $ name = substr ($ name , 0 , 50 );
230
+ $ zip = new ZipStream ($ name .'.zip ' );
231
+ $ zip ->finish ();
232
+ exit ();
233
+ }
234
+
235
+
236
+
237
+
205
238
/** create zip recursive*/
206
239
private function _createZipRecursive ($ zip , $ path , $ folders , $ revisions )
207
240
{
0 commit comments