1 # Copyright 2003-2008 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: capture_page.tag,v 1.12 2008-10-01 09:21:45 racke Exp $
10 UserTag capture_page Order page file
11 UserTag capture_page addAttr
12 UserTag capture_page Version $Revision: 1.12 $
13 UserTag capture_page Routine <<EOR
15 my ($page, $file, $opt) = @_;
17 # check if we are using a file
19 # check if we are allowed to write the file
20 unless (Vend::File::allowed_file($file, 1)) {
21 Vend::File::log_file_violation($file, 'capture_page');
26 my $stat = (stat($file))[9];
28 if ($stat > $opt->{expiry}) {
31 unless (utime ($now, $now, $file)) {
32 ::logError ("Error on touching file $file: $!\n");
41 Vend::Page::do_scan($opt->{scan});
44 $::Scratch->{mv_no_count} = 1;
47 my (@output, %outptr, %outfilter, %outextended, $multiout, $content, $retval);
49 @output = @Vend::Output;
50 %outptr = %Vend::OutPtr;
51 %outfilter = %Vend::OutFilter;
52 %outextended = %Vend::OutExtended;
53 $multiout = $Vend::MultiOutput;
56 @Vend::Output = %Vend::OutPtr = %Vend::OutFilter = %Vend::OutExtended = ();
57 $Vend::MultiOutput = 0;
59 Vend::Page::display_page($page, {return => 1});
61 for my $part (@Vend::Output) {
62 Vend::Interpolate::substitute_image($part);
66 # restore mapped output
67 @Vend::Output = @output;
68 %Vend::OutPtr = %outptr;
69 %Vend::OutFilter = %outfilter;
70 %Vend::OutExtended = %outextended;
71 $Vend::MultiOutput = $multiout;
73 if ($opt->{scratch}) {
74 $::Scratch->{$opt->{scratch}} = $content;
79 $retval = Vend::File::writefile (">$file", \$content,
80 {auto_create_dir => $opt->{auto_create_dir},
81 umask => $opt->{umask}});