Line # Revision Author
1 296 ahitrov <doc id="<% $document->id %>">
2 % if ( ref $IMAGE && exists $IMAGE->{filename} ) {
3 % my $img_dir = $state->images_directory;
4 % $img_dir =~ s/\/$//;
5 <img src="<% $img_dir.$IMAGE->{filename} %>"/>
6 % }
7 <text><% $document->name %></text>
8 </doc>
9 <%args>
10
11 $store => undef
12
13 </%args>
14 <%init>
15
16 my $prj = $request->{project};
17 my $profile = $request->{project_profile};
18 my $root = $request->{project_section};
19
20 unless ( $store ) {
21 my %cookies = Apache::Cookie->fetch;
22 my $cookie = $cookies{card_id};
23
24 # Вытаскиваем SID из куки
25 $store = $cookie->value() if $cookie;
26 }
27 my $document;
28 my $IMAGE;
29 warn Dumper(\%ARGS);
30
31 if ( $store ) {
32 $document = $keeper->get_document_by_id ( $store,
33 class => 'promosuite::Postcard',
34 );
35 unless ( ref $document ) {
36 $document = promosuite::Postcard->new ($keeper);
37 $document->sections($root->id);
38 $document->status(1);
39 }
40
41 if ( $ARGS{picture} ) {
42 my @properties = $document->structure();
43 my ($prop) = grep { $_->{attr} eq 'picture' } @properties;
44 my $IMG = $document->get_image ('picture');
45 $IMAGE = $m->comp ('/subs/set_image.msn',
46 field => 'picture',
47 object => $document,
48 prop => $prop,
49 default => $IMG,
50 SETS => \%ARGS,
51 );
52 if (ref $IMAGE && exists($IMAGE->{filename})) {
53 local $Data::Dumper::Indent = 0;
54 $document->picture( Data::Dumper::Dumper($IMAGE) );
55 }
56 }
57 $document->store;
58 my $cookie = Apache::Cookie->new ($request->r(),
59 -name => 'card_id',
60 -expires=> '+7d',
61 -value => $document->id,
62 -path => '/',
63 );
64 $cookie->bake();
65 }
66 return unless ref $document && $document->id;
67 if ( $state->development ) {
68 $r->content_type('text/xml; charset=utf-8');
69 } else {
70 $r->content_type('text/xml; charset=utf-8');
71 }
72 $r->header_out ('X-Accel-Expires', 0);
73
74 </%init>