Line # Revision Author
1 296 ahitrov package promosuite::Article;
2
3 use strict;
4 use vars qw(@ISA);
5
6 use Contenido::Document;
7 use Time::ParseDate;
8 use Contenido::Globals;
9
10 @ISA = ('Contenido::Document');
11
12 sub extra_properties
13 {
14
15 return (
16 { 'attr' => 'status', 'type' => 'status', 'rusname' => 'Статус новости',
17 'cases' => [
18 [0, 'Новость не активна'],
19 [1, 'Обычная новость'],
20 [2, 'Новость в блоке'],
21 [3, 'Новость импортирована'],
22 ],
23 },
24 { 'attr' => 'abstr', 'type' => 'text', 'rusname' => 'Аннотация', 'rows' => 10 },
25 { 'attr' => 'body', 'type' => 'wysiwyg', 'rusname' => 'Текст статьи', 'rows' => 40 },
26 { 'attr' => 'body_html', 'type' => 'text', 'rusname' => 'HTML-код статьи', 'rows' => 40, rem => 'Будет использован ВМЕСТО текста статьи' },
27 { 'attr' => 'author', 'type' => 'string', 'rusname' => 'Автор статьи' },
28 { 'attr' => 'source', 'type' => 'string', 'rusname' => 'Источник' },
29 { 'attr' => 'source_id', 'type' => 'pickup', 'rusname' => 'Источник из базы',
30 lookup_opts => { class => 'promosuite::Source', search_by => 'name' },
31 },
32 { 'attr' => 'url', 'type' => 'string', 'rusname' => 'URL оригинала' },
33 { 'attr' => 'icon', 'type' => 'image', 'rusname' => 'Иконка для выноски', preview => ['100x100', '50x50'] },
34 { 'attr' => 'file', 'type' => 'multimedia_new', 'rusname' => 'Файл с текстом статьи', softrename => 1 },
35 { 'attr' => 'picture', 'type' => 'image', 'rusname' => 'Иллюстрация к статье', preview => '100x100' },
36 { 'attr' => 'pictures', 'type' => 'images', 'rusname' => 'Список иллюстраций', preview => '240x240' },
37 )
38 }
39
40 sub class_name
41 {
42 return 'Текст или статья';
43 }
44
45 sub class_description
46 {
47 return 'Текст или статья';
48 }
49
50 sub class_table
51 {
52 return 'promosuite::SQL::DocumentTable';
53 }
54
55 sub export_to_search
56 {
57 my $self=shift;
58 my $keeper = $self->{keeper};
59 my $xml;
60 my %path;
61 foreach ('style', 'auto', 'home', 'money') {
62 $path{ $project->s_alias->{$_} } = $_;
63 }
64 my @sections = $self->sections;
65 my $main_sect = $keeper->get_section_by_id($sections[0]);
66 unless($main_sect) {
67 warn "wrong section stucture for mediapps::Article $self->{id}\n";
68 return undef;
69 }
70 my $app = $main_sect->pid();
71 $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";
72
73 #$xml .= "<rubric id=\"".$self->section()."\" name=\"".$keeper->get_section_by_id($self->section())->name()."\"/>\n";
74 $xml .= "<description><![CDATA[".$self->name()."]]></description>\n";
75 $xml .= "<html><![CDATA[".$self->body()."]]></html>\n</document>\n";
76 return $xml;
77 }
78
79 sub contenido_status_style
80 {
81 my $self = shift;
82 if ( $self->status == 3 ) {
83 return 'color:green;';
84 }
85 if ( $self->status == 2 ) {
86 return 'color:red;';
87 }
88 }
89
90 1;