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