/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to classes/export.php

  • Committer: Suren A. Chilingaryan
  • Date: 2011-03-15 02:47:05 UTC
  • mfrom: (210.1.3 adei)
  • Revision ID: csa@dside.dyndns.org-20110315024705-qljn30gwin8yrkne
Integration of work of students with fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
class EXPORT {
6
6
 var $req;
7
 
 
 
7
 var $dm;
 
8
 var $dmcb;             
 
9
 
8
10
 var $format;
9
11
 var $multimode;        // STREAM is used for joining groups
10
12
 
33
35
 const MASK_SOURCE = 2;
34
36
 const MASK_COMPLETE = 3;
35
37
   
36
 
 function __construct(DATARequest $props = NULL, STREAMObjectInterface $h = NULL, &$format = NULL) {
 
38
 function __construct(DATARequest $props = NULL, STREAMObjectInterface $h = NULL, &$format = NULL, DOWNLOADMANAGER $dm = NULL) {
 
39
    global $TMP_PATH;      
37
40
    if ($props) $this->req = $props;
38
41
    else $this->req = new DATARequest();
39
42
    
53
56
        );
54
57
    }
55
58
    
 
59
    if($dm){
 
60
      $this->dm = $dm;
 
61
      $this->dmcb = array($this->dm,"DlmanagerUpdate");
 
62
    }       
 
63
      
56
64
    $this->handler = new $handler["class"]($this->format);
57
65
    $this->export_data = ! $this->handler->data_not_needed;
58
66
 
72
80
                        if ($this->req->props['mask_mode']==EXPORT::MASK_STANDARD) $mask = $reader->CreateMask();
73
81
                        else $mask = NULL;
74
82
                        $list = $reader->CreateRequestSet($grp, $mask);
75
 
                        if ($list->GetSize() != 1) $this->multimode = true;
 
83
                        if ($list->GetSize() != 1) {
 
84
                          $this->multimode = true;
 
85
                          if($this->dm) $this->dm->UpdateFilesRemaining($this->req->GetProp('dl_id'), $list->GetSize());
 
86
                        }
76
87
                        unset($list);
77
88
 
78
89
                    }
88
99
        $this->resample = $this->req->props['resample'];
89
100
    } else {
90
101
        $this->resample = 0;
91
 
    }
92
 
 
93
 
    $this->output = $h;
 
102
    }      
 
103
 
 
104
    if($this->dm) $this->output = $this->dm->GetDmOutput($this->multimode, $this->handler->GetExtension(), $this->req);     
 
105
    else $this->output = $h;
 
106
    
94
107
 
95
108
    if (($this->format['filter'])||($this->multimode)) {
96
109
        $this->stream = new STREAM($this->format, $this->output, ($this->multimode?STREAM::MULTIMODE:0)|($this->handler->filewriter?STREAM::FILESTART:0));
177
190
            throw new ADEIException(translate("Unsupported mask mode (%u)", $this->req->props['mask_mode']));
178
191
    }
179
192
    
180
 
 
181
193
    $rdr = $this->CreateReader();
182
194
    if ($grp) $grp = $rdr->CreateGroup();
183
195
    else {
257
269
 function ExportVirtualGroup(READER $rdr, LOGGROUP $grp, MASK $mask = NULL) {
258
270
    $this->multigroup = true;
259
271
    $this->multirdr = true;
260
 
 
 
272
  
261
273
    if (!$mask) $mask = new MASK($minfo = array());
262
274
    
263
275
    $this->Start($rdr, $grp, $mask, NULL);
277
289
            $msk?$msk->name:""
278
290
        );
279
291
 
280
 
        $this->ExportGroup($req, $reader, $group, $ivl, $msk, $title);
 
292
        $this->ExportGroup($req, $reader, $group, $ivl, $msk, $title);  
 
293
        
281
294
    }
282
295
    $this->End();
 
296
    
 
297
    
283
298
 }
284
299
 
285
300
 
352
367
    }
353
368
 
354
369
    $this->handler->GroupStart($title, $subseconds);
355
 
    $rdr->Export($this->handler, $grp, $msk, $ivl, $this->resample);
 
370
    
 
371
    $rdr->Export($this->handler, $grp, $msk, $ivl, $this->resample, "", $this->dmcb);
356
372
    $this->handler->GroupEnd();    
357
373
 
358
374
    if (($this->stream)&&(!$this->handler->multigroup)) $this->stream->BlockEnd();    
359
375
 }
360
376
 
361
 
 function SendHeaders(READER $rdr = NULL, LOGGROUP $grp = NULL, MASK $msk = NULL, INTERVAL $ivl = NULL) {
 
377
 function SendHeaders(READER $rdr = NULL, LOGGROUP $grp = NULL, MASK $msk = NULL, INTERVAL $ivl = NULL) { 
362
378
    if ($this->stream) 
363
379
        $content_type = $this->stream->GetContentType();
364
380
    else
369
385
        if ($this->format["content_type"]) $content_type = $this->format["content_type"];
370
386
        else $content_type = "application/binary";
371
387
    }
372
 
 
 
388
    
373
389
    if ($this->stream)
374
390
        $extension = $this->stream->GetExtension();
375
391
    else
389
405
        if ($this->filename) $name = $this->filename;
390
406
        else $name = $this->GetName($rdr, $grp, $msk, $ivl);
391
407
        if ($extension) $name .= ".$extension";
 
408
    }    
 
409
   
 
410
    //    echo "$content_type , $name\n";
 
411
    //    exit;
 
412
    if($this->dm) {     
 
413
      $this->dm->SetContentType($content_type, $this->dm->GetDownload());
392
414
    }
393
 
    
394
 
//    echo "$content_type , $name\n";
395
 
//    exit;
396
 
 
397
 
    header("Cache-Control: no-cache, must-revalidate");
398
 
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
399
 
    header("Content-type: $content_type"); 
400
 
    header("Content-Disposition: attachment; filename=\"$name\"");
401
 
 }
 
415
    else {
 
416
      header("Cache-Control: no-cache, must-revalidate");
 
417
      header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 
418
      header("Content-type: $content_type");
 
419
      header("Content-Disposition: attachment; filename=\"$name\"");
 
420
    }   
 
421
  }
402
422
 
403
423
 function GetGroupName($sname, $dname, $gname, $mname, $iname = false) {
404
424
    if ($mname) $mname = "/$mname";