Changeset 887

Show
Ignore:
Timestamp:
12/12/06 07:24:58 (2 years ago)
Author:
fumiakiy
Message:

Added link to each backed up file in the table when backup operation is finished. BugId: 45769

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/lib/MT/App/CMS.pm

    r879 r887  
    1107911079        $fh = gensym(); 
    1108011080        open $fh, ">$filename"; 
    11081         push @files, { filename => $file . "-1.xml" }; 
     11081        push @files, {  
     11082            url => $app->uri . "?__mode=backup_download&name=$file-1.xml&magic_token=" . $app->current_magic, 
     11083            filename => $file . "-1.xml" 
     11084        }; 
    1108211085        $printer = sub { my ($data, $message) = @_; print $fh $data; $app->print($message); return length($data); }; 
    1108311086        $splitter = sub { 
     
    1108811091            $fh = gensym(); 
    1108911092            open $fh, ">$filename"; 
    11090             push @files, { filename => $file . "-$findex.xml" }; 
     11093            push @files, { 
     11094                url => $app->uri . "?__mode=backup_download&name=$file-$findex.xml&magic_token=" . $app->current_magic, 
     11095                filename => $file . "-$findex.xml" 
     11096            }; 
    1109111097            my $header .= "<movabletype xmlns='" . MT::BackupRestore::NS_MOVABLETYPE() . "'>\n"; 
    1109211098            $header = "<?xml version='1.0' encoding='$enc'?>\n$header" if $enc !~ m/utf-?8/i; 
     
    1111511121            print $fh "</manifest>\n"; 
    1111611122            close $fh; 
    11117             push @files, { filename => "$file.manifest" }; 
     11123            push @files, { 
     11124                url => $app->uri . "?__mode=backup_download&name=$file.manifest&magic_token=" . $app->current_magic, 
     11125                filename => "$file.manifest" 
     11126            }; 
    1111811127            if ('0' eq $archive) { 
    1111911128                $param->{files_loop} = \@files; 
     
    1117311182    my $filename = $app->param('filename'); 
    1117411183    my $temp_dir = $app->config('TempDir'); 
     11184    my $newfilename; 
     11185    if (defined($filename)) { 
     11186        my $sess = MT::Session->load( { kind => 'BU', name => $filename } ); 
     11187        if (!defined($sess) || !$sess) { 
     11188            return $app->errtrans("Specified file was not found."); 
     11189        } 
     11190        my @ts = gmtime($sess->start); 
     11191        my $ts = sprintf "%04d-%02d-%02d-%02d-%02d-%02d", 
     11192            $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]; 
     11193        $newfilename = "Movable_Type-$ts" . '-Backup'; 
     11194        $sess->remove; 
     11195    } else { 
     11196        $newfilename = $app->param('name'); 
     11197        $filename = $newfilename; 
     11198    } 
     11199 
    1117511200    require File::Spec; 
    1117611201    my $fname = File::Spec->catfile($temp_dir, $filename); 
    11177      
    11178     my $sess = MT::Session->load( { kind => 'BU', name => $filename } ); 
    11179     if (!defined($sess) || !$sess) { 
    11180         return $app->errtrans("Specified file was not found."); 
    11181     } 
    11182     my @ts = gmtime($sess->start); 
    11183     my $ts = sprintf "%04d-%02d-%02d-%02d-%02d-%02d", 
    11184         $ts[5]+1900, $ts[4]+1, @ts[3,2,1,0]; 
    11185     my $newfilename = "Movable_Type-$ts" . '-Backup'; 
    11186     $sess->remove; 
    11187  
    11188     $app->{no_print_body} = 1; 
     11202 
    1118911203    my $contenttype; 
    1119011204    if ($filename =~ m/^xml\..+$/i) { 
     
    1119911213        $newfilename .= '.zip'; 
    1120011214    } else { 
    11201         $app->send_http_header('application/octet-stream'); 
    11202     } 
    11203  
    11204     $app->set_header("Content-Disposition" => "attachment; filename=$newfilename"); 
    11205     $app->send_http_header($contenttype); 
     11215        $contenttype = 'application/octet-stream'; 
     11216    } 
    1120611217     
    11207     open my $fh, "<$fname"; 
    11208     my $data; 
    11209     while (read $fh, my($chunk), 8192) { 
    11210         $data .= $chunk; 
    11211     } 
    11212     close $fh; 
    11213     $app->print($data); 
    11214     unlink $fname; 
     11218    if (open(my $fh, "<$fname")) { 
     11219        $app->{no_print_body} = 1; 
     11220        $app->set_header("Content-Disposition" => "attachment; filename=$newfilename"); 
     11221        $app->send_http_header($contenttype); 
     11222        my $data; 
     11223        while (read $fh, my($chunk), 8192) { 
     11224            $data .= $chunk; 
     11225        } 
     11226        close $fh; 
     11227        $app->print($data); 
     11228        unlink $fname; 
     11229    } else { 
     11230        $app->errtrans('Specified file was not found.'); 
     11231    } 
    1121511232} 
    1121611233 
  • branches/wheeljack/tmpl/cms/backup_end.tmpl

    r877 r887  
    4747function submit_form() { 
    4848    window.clearTimeout(timer); 
     49    var p = getByID('download_message'); 
     50    if (p) 
     51        p.style.display = 'none'; 
    4952    var f = document['file_download']; 
    5053    if (f) { 
     
    5558timer = window.setTimeout("submit_form()", 3000); 
    5659</script> 
    57 <p><strong><MT_TRANS phrase="_BACKUP_DOWNLOAD_MESSAGE"></strong></p> 
     60<p id="download_message"><strong><MT_TRANS phrase="_BACKUP_DOWNLOAD_MESSAGE"></strong></p> 
    5861</TMPL_IF> 
    5962<TMPL_ELSE>