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>

	$id	=> undef
	$new	=> undef

</%args>
<%init>

  &abort404	if $id && $id =~ /\D/;
  my $prj = $request->{project};
  my $profile = $request->{project_profile};
  my $root = $request->{project_section};

  if ( $new ) {
#	$r->header_out ('X-Accel-Expires', 0);
  }
  if ( !$new && !$id ) {
	my %cookies = Apache::Cookie->fetch;
	my $cookie = $cookies{card_id};

	# Вытаскиваем SID из куки
	$id = $cookie->value()             if $cookie;
  }
  my $document;
  if ( $id && !$new ) {
	$document = $keeper->get_document_by_id ( $id,
			class	=> 'promosuite::Postcard',
		);
  }
  unless ( ref $document ) {
#	$r->header_out ('X-Accel-Expires', 0);
	$document = promosuite::Postcard->new ($keeper);
	$document->sections($root->id);
	$document->status(1);
	$document->store;
	my $cookie = Apache::Cookie->new ($request->r(),
		-name   => 'card_id',
		-expires=> '+7d',
		-value  => $document->id,
		-path   => '/',
	);
	$cookie->bake();
  }
  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');
  }

</%init>