Line # Revision Author
1 3 ahitrov@rambler.ru %# vim:syn=mason
2 <& "/contenido/components/header.msn" &>
3 <& "/contenido/components/naviline.msn", sect_id => $owner->id &>
4
5 % if ($error) {
6 <div align="center" style="font-size:110%; color:red;">
7 <% $error %>
8 </div>
9 <br><br>
10 % }
11
12 % if (!ref($document)) {
13 % if ($id) {
14 <div align="center" style="font-size:110%; color:red;">
15 �������� � ��������������� <% $id %> �� ������
16 </div>
17 <br><br>
18 % } elsif ($class) {
19 <!-- ���� � ������� ������ ��������� ��� �������� -->
20 <table width="50%" border="0"><tr><td>
21 <fieldset>
22 <legend>�������� ��� ��������� ��� ��������</legend>
23 <& "/contenido/components/new_objects_form.msn", proto => 'documents', sect_id => $owner->id &>
24 </fieldset>
25 </td></tr></table>
26 % } else {
27 <div align="center" style="font-size:110%; color:red;">
28 �� ������ ����� ���������!!! (����������� id � class ������������)
29 </div>
30 <br><br>
31 % }
32
33 % } else {
34
35 <& "/contenido/components/obj_list_js.msn", object => $document &>
36 <& "/contenido/components/object_form.msn",
37 object => $document,
38 proto => 'documents',
39 sect_id => $owner->id,
40 clone => $clone,
41 filter_params => \%filter_params,
42 &>
43 % if (ref($document) && ($document->id))
44 % {
45
46 <!-- ����� � �������� � �������� -->
47
48 <br>
49
50 <table width="100%" cellspacing="5" cellpadding="0" border="0">
51 <tr>
52 <td width=50% valign=top>\
53 <& "/contenido/components/document_sections.msn", document => $document &>\
54 <& "/contenido/components/user_sections.msn", luser => $document &>\
55 % if ( $m->comp_exists ("/contenido/components/pbase_rubrics.msn") ) {
56 <& "/contenido/components/pbase_rubrics.msn", document => $document &>\
57 % }
58 </td>
59 <td width=50% valign=top>\
60 % if ( $m->comp_exists ("/contenido/components/pbase_links.msn") ) {
61 <& "/contenido/components/pbase_links.msn", document => $document &>\
62 % }
63 <iframe id="links" src="document_links.html?id=<% $document->id() %>&class=<% $document->class() %>" width="100%" height="700" frameborder="0"></iframe>
64
65 </td>
66 </tr>
67 </table>
68
69 <!-- / ����� � �������� � �������� -->
70
71 % }
72 % }
73
74 </body>
75 </html>
76 <%ARGS>
77 $p => 1
78 $class => undef
79 $sect_id => undef
80 $s_alias => undef
81 $id => undef
82 $delete => undef
83 $save => undef
84 $clone => undef
85 $activate => undef
86 $deactivate => undef
87 </%ARGS>
88 <%INIT>
89
90 &abort404 unless $class;
91 my $error='';
92 ### !!! ��� ���������� ���������� � ARGS �� ���� ������ � ������ ���������� � ��������� ����
93
94 my $filter = $m->comp('/contenido/components/context.msn', name => 'filter');
95
96 my $document;
97 my $new;
98
99 if ($id && ($id !~ /\D/) && ($id > 0)) {
100 $document = $keeper->get_document_by_id($id, class=>$class);
101 if ( $clone && exists $document->{'attributes'}->{'dtime'} ) {
102 $document->dtime(undef);
103 }
104 } elsif ( ($class) && (length($class)>0) && (! ref($document)) ) {
105 $document = new $class ($keeper);
106 $new = 1;
107 my @properties = $document->structure();
108 foreach my $prop ( @properties ) {
109 my $attr = $prop->{attr};
110 ### !!! ���� �� ����������� ����������, �� ����� ����������������
111 if ( exists $ARGS{$attr} && ! grep { $prop->{attr} eq $_ } qw( class sect_id id delete save clone s_alias activate deactivate p s use_section alpha alpha_search search_by search ) ) {
112 $document->$attr($ARGS{$attr});
113 }
114 }
115 }
116 &abort404 unless ref $document;
117
118 my @props = $document->structure();
119 my %filter_params;
120 if ($ARGS{use_section} && !grep { $_->{attr} eq 'use_section' } @props ) {
121 $filter_params{use_section} = $ARGS{use_section};
122 $filter_params{class} = $document->class;
123 }
124 $filter_params{alpha} = $ARGS{alpha} if $ARGS{alpha} && !grep { $_->{attr} eq 'alpha' } @props;
125 $filter_params{alpha_search} = $ARGS{alpha_search} if $ARGS{alpha_search} && !grep { $_->{attr} eq 'alpha_search' } @props;
126 $filter_params{search_by} = $ARGS{search_by} if $ARGS{search_by} && !grep { $_->{attr} eq 'search_by' } @props;
127 $filter_params{search} = $ARGS{search} if $ARGS{search} && !grep { $_->{attr} eq 'search' } @props;
128 $filter_params{s} = $ARGS{s} if $ARGS{s} && !grep { $_->{attr} eq 's' } @props;
129 $filter_params{p} = $p if $p > 1;
130 my $return_params = join ('&', map { $_.'='.$filter_params{$_} } grep { $_ ne 's' } keys %filter_params );
131
132
133 if ($s_alias) {
134 $sect_id = $project->s_alias->{$s_alias};
135 }
136
137 if ( (! $sect_id) && (ref($document)) && ($document->id) ) {
138 $sect_id = $document->section();
139 }
140 my $owner = $keeper->get_section_by_id ($sect_id || $Contenido::Section::ROOT || 1);
141
142 if (! ref($owner)) {
143 $owner = $keeper->get_section_by_id ($Contenido::Section::ROOT || 1);
144 }
145 if (! ref($owner)) {
146 warn "Contenido Die: �� ���� ����� �������� ������\n";
147 return undef;
148 }
149
150 if (ref($document) && $document->id() && $document->section()) {
151 my $document_access = $user->section_accesses($user, $owner);
152 if ($document_access != 2) {
153 $m->clear_buffer;
154 $m->abort(403);
155 }
156 }
157
158 # ��������...
159 if (defined($id) && ($id > 0) && ($delete == 1)) {
160 $document->delete( attachments => 1 );
161
162 $m->redirect("sections.html?id=".($filter_params{s} || $owner->id).($return_params ? '&'.$return_params : ''));
163 }
164
165 # ���������...
166 if (defined($id) && ($id > 0) && ($activate == 1)) {
167 $document->status(1);
168 $document->store;
169
170 $m->redirect("sections.html?id=".($filter_params{s} || $owner->id).($return_params ? '&'.$return_params : ''));
171 }
172
173 # �����������...
174 if (defined($id) && ($id > 0) && ($deactivate == 1)) {
175 $document->status(0);
176 $document->store;
177
178 $m->redirect("sections.html?id=".($filter_params{s} || $owner->id).($return_params ? '&'.$return_params : ''));
179 }
180
181 # ���������� ������������� ��������� ��� �������� ������...
182 # ������, ���� ����� �� �������������� �����...
183 elsif ( $save == 1 )
184 {
185 my $clonesource;
186 if ( $clone ) {
187 $clonesource = $keeper->get_document_by_id ($clone,
188 class => $document->class,
189 );
190 }
191 if ($m->comp('/contenido/components/set_properties.msn', object => $document, SETS => \%ARGS) != 1)
192 {
193 # ������, ���� �� ����������...
194 warn "Contenido Warning: �� ���� ���������� �������� �����!\n";
195 }
196 if ( $clone ) {
197 $m->comp('/contenido/components/clone_attachments.msn', object => $document, source => $clonesource );
198 $document->sections( $clonesource->sections );
199 } elsif ( $new ) {
200 $document->sections( $owner->id, $filter > 0 ? ($filter) : ());
201 }
202
203
204 unless ($document->store()) {
205 # ������, ���� �� ����������...
206 $error="������ ���������� ($keeper->{last_error})";
207 } else {
208
209 if ($ARGS{_save_and_leave}) {
210 $m->redirect("sections.html?id=".($filter_params{s} || $owner->id).($return_params ? '&'.$return_params : ''));
211 } elsif ($ARGS{_save_and_again}) {
212 $m->redirect("document.html?class=".$document->class()."&sect_id=".($filter_params{s} || $owner->id).($return_params ? '&'.$return_params : ''));
213 }
214
215
216 $m->redirect("document.html?id=".$document->id()."&class=".$document->class().(exists $filter_params{s} ? '&s='.$filter_params{s} : '').($return_params ? '&'.$return_params : ''));
217 }
218 }
219
220 </%INIT>