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;

  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);
	}
	
	my $greeting = $ARGS{greeting};
	$greeting =~ s/</&lt;/sgi;
	$greeting =~ s/>/&gt;/sgi;
	$document->name( $greeting );
	$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;
  my $image = $document->get_image('picture');
  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>