Revision 296 (by ahitrov, 2013/03/26 17:59:01) |
Promosite (anthill) project source
|
<doc id="<% $document->id %>">
% if ( ref $IMAGE && exists $IMAGE->{filename} ) {
% my $img_dir = $state->images_directory;
% $img_dir =~ s/\/$//;
<img src="<% $img_dir.$IMAGE->{filename} %>"/>
% }
<text><% $document->name %></text>
</doc>
<%args>
$store => undef
</%args>
<%init>
my $prj = $request->{project};
my $profile = $request->{project_profile};
my $root = $request->{project_section};
unless ( $store ) {
my %cookies = Apache::Cookie->fetch;
my $cookie = $cookies{card_id};
# Вытаскиваем SID из куки
$store = $cookie->value() if $cookie;
}
my $document;
my $IMAGE;
warn Dumper(\%ARGS);
if ( $store ) {
$document = $keeper->get_document_by_id ( $store,
class => 'promosuite::Postcard',
);
unless ( ref $document ) {
$document = promosuite::Postcard->new ($keeper);
$document->sections($root->id);
$document->status(1);
}
if ( $ARGS{picture} ) {
my @properties = $document->structure();
my ($prop) = grep { $_->{attr} eq 'picture' } @properties;
my $IMG = $document->get_image ('picture');
$IMAGE = $m->comp ('/subs/set_image.msn',
field => 'picture',
object => $document,
prop => $prop,
default => $IMG,
SETS => \%ARGS,
);
if (ref $IMAGE && exists($IMAGE->{filename})) {
local $Data::Dumper::Indent = 0;
$document->picture( Data::Dumper::Dumper($IMAGE) );
}
}
$document->store;
my $cookie = Apache::Cookie->new ($request->r(),
-name => 'card_id',
-expires=> '+7d',
-value => $document->id,
-path => '/',
);
$cookie->bake();
}
return unless ref $document && $document->id;
if ( $state->development ) {
$r->content_type('text/xml; charset=utf-8');
} else {
$r->content_type('text/xml; charset=utf-8');
}
$r->header_out ('X-Accel-Expires', 0);
</%init>