package promosuite::Article;
use strict;
use vars qw(@ISA);
use Contenido::Document;
use Time::ParseDate;
use Contenido::Globals;
@ISA = ('Contenido::Document');
sub extra_properties
{
return (
{ 'attr' => 'status', 'type' => 'status', 'rusname' => 'Статус новости',
'cases' => [
[0, 'Новость не активна'],
[1, 'Обычная новость'],
[2, 'Новость в блоке'],
[3, 'Новость импортирована'],
],
},
{ 'attr' => 'abstr', 'type' => 'text', 'rusname' => 'Аннотация', 'rows' => 10 },
{ 'attr' => 'body', 'type' => 'wysiwyg', 'rusname' => 'Текст статьи', 'rows' => 40 },
{ 'attr' => 'body_html', 'type' => 'text', 'rusname' => 'HTML-код статьи', 'rows' => 40, rem => 'Будет использован ВМЕСТО текста статьи' },
{ 'attr' => 'author', 'type' => 'string', 'rusname' => 'Автор статьи' },
{ 'attr' => 'source', 'type' => 'string', 'rusname' => 'Источник' },
{ 'attr' => 'source_id', 'type' => 'pickup', 'rusname' => 'Источник из базы',
lookup_opts => { class => 'promosuite::Source', search_by => 'name' },
},
{ 'attr' => 'url', 'type' => 'string', 'rusname' => 'URL оригинала' },
{ 'attr' => 'icon', 'type' => 'image', 'rusname' => 'Иконка для выноски', preview => ['100x100', '50x50'] },
{ 'attr' => 'file', 'type' => 'multimedia_new', 'rusname' => 'Файл с текстом статьи', softrename => 1 },
{ 'attr' => 'picture', 'type' => 'image', 'rusname' => 'Иллюстрация к статье', preview => '100x100' },
{ 'attr' => 'pictures', 'type' => 'images', 'rusname' => 'Список иллюстраций', preview => '240x240' },
)
}
sub class_name
{
return 'Текст или статья';
}
sub class_description
{
return 'Текст или статья';
}
sub class_table
{
return 'promosuite::SQL::DocumentTable';
}
sub export_to_search
{
my $self=shift;
my $keeper = $self->{keeper};
my $xml;
my %path;
foreach ('style', 'auto', 'home', 'money') {
$path{ $project->s_alias->{$_} } = $_;
}
my @sections = $self->sections;
my $main_sect = $keeper->get_section_by_id($sections[0]);
unless($main_sect) {
warn "wrong section stucture for mediapps::Article $self->{id}\n";
return undef;
}
my $app = $main_sect->pid();
$xml = "<document href=\"http://www.rambler.ru/".$path{ $app }."/?id=".$self->id()."\" atime=\"".time."\" mtime=\"".parsedate($self->mtime(), UK=>1)."\" status=\"".($self->status() ? "add" : "del")."\">\n";
#$xml .= "<rubric id=\"".$self->section()."\" name=\"".$keeper->get_section_by_id($self->section())->name()."\"/>\n";
$xml .= "<description><![CDATA[".$self->name()."]]></description>\n";
$xml .= "<html><![CDATA[".$self->body()."]]></html>\n</document>\n";
return $xml;
}
sub contenido_status_style
{
my $self = shift;
if ( $self->status == 3 ) {
return 'color:green;';
}
if ( $self->status == 2 ) {
return 'color:red;';
}
}
1;