Line # | Revision | Author | |
---|---|---|---|
1 | 8 | ahitrov@rambler.ru | <form action="<% $INVITE->{$proto}->[1] %>" method="GET" name="formnew"> |
2 | <div align="right"> | ||
3 | 450 | ahitrov | <table width="100%" border="0" cellpadding="3" cellspacing="0" class="tform"> |
4 | <tr><td><% $INVITE->{$proto}->[0] %></td> | ||
5 | <td width="100%"> | ||
6 | 17 | ahitrov@rambler.ru | <& "/contenido/components/select.msn", name=>'class', values=>$classes, check=>$default, style=>'width:100%;', onChange => "set_create_button(this, 'create_$btn_id')" &> |
7 | 450 | ahitrov | </td> |
8 | 451 | ahitrov | <td><input id="create_<% $btn_id %>" type="submit" value="Создать"<% $default || scalar @class == 1 ? '' : ' disabled="disabled"' %>></td> |
9 | 450 | ahitrov | <td><input type="hidden" name="sect_id" value="<% $sect_id %>"></td> |
10 | </tr></table> | ||
11 | 8 | ahitrov@rambler.ru | </div></form> |
12 | <%ONCE> | ||
13 | use locale; | ||
14 | </%ONCE> | ||
15 | <%ARGS> | ||
16 | |||
17 | 450 | ahitrov | $default => undef |
18 | $proto => 'documents' | ||
19 | $sect_id => 1 | ||
20 | $section => undef | ||
21 | 8 | ahitrov@rambler.ru | |
22 | </%ARGS> | ||
23 | <%INIT> | ||
24 | 450 | ahitrov | |
25 | my $INVITE = { | ||
26 | 8 | ahitrov@rambler.ru | 'documents' => ['Новый документ','document.html'], |
27 | 'sections' => ['Новая секция','section.html'], | ||
28 | 'links' => ['Новая связь','link.html'], | ||
29 | 'users' => ['Новый пользователь','users.html'], | ||
30 | }; | ||
31 | 450 | ahitrov | my $btn_id = int(rand(10000)); |
32 | |||
33 | my @class; | ||
34 | if ( $proto eq 'documents' ) { | ||
35 | @class = @{ $user->get_available_classes }; | ||
36 | if ( ref $section ) { | ||
37 | if ( $section->default_table_class ) { | ||
38 | @class = grep { $_->new( $keeper )->class_table eq $section->default_table_class } @class; | ||
39 | } elsif ( $section->default_document_class ) { | ||
40 | @class = grep { $_ eq $section->default_document_class } @class; | ||
41 | ($default) = grep { $_ eq $section->default_document_class } @class unless $default; | ||
42 | } | ||
43 | } | ||
44 | } else { | ||
45 | @class = @{ $state->{'available_'.$proto} }; | ||
46 | } | ||
47 | |||
48 | my $classes = scalar @class > 1 ? [ '' => '--- Выберите тип ---' ] : []; | ||
49 | |||
50 | foreach my $class ( sort { $a->class_name cmp $b->class_name } @class ) { | ||
51 | my $object = $class->new($keeper); | ||
52 | push @$classes, $class, "".$object->class_name()." ($class)"; | ||
53 | } | ||
54 | |||
55 | 8 | ahitrov@rambler.ru | </%INIT> |