1 |
234 |
ahitrov |
<& "/contenido/components/header.msn" &> |
2 |
|
|
<& "/contenido/components/naviline.msn" &> |
3 |
|
|
|
4 |
236 |
ahitrov |
<script type="text/javascript"> |
5 |
|
|
<!-- |
6 |
|
|
function set_create_button( oSelect, sBtnID ) { |
7 |
|
|
if ( oSelect.value == '' ) { |
8 |
|
|
$('#'+sBtnID).attr('disabled','disabled'); |
9 |
|
|
} else { |
10 |
|
|
$('#'+sBtnID).removeAttr('disabled'); |
11 |
|
|
} |
12 |
|
|
} |
13 |
|
|
//--> |
14 |
|
|
</script> |
15 |
234 |
ahitrov |
|
16 |
236 |
ahitrov |
<table width="100%" cellspacing="0" cellpadding="0" border="0"> |
17 |
|
|
<tr valign="top"> |
18 |
|
|
<td width="35%"> |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
</td> |
23 |
|
|
<td width="2%"> </td> |
24 |
|
|
<td width="65%"> |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
<fieldset> |
28 |
|
|
<legend>Документы\ |
29 |
|
|
% if ($class) { |
30 |
|
|
класса <% $class %>\ |
31 |
|
|
% if ($use_section) { |
32 |
|
|
c учетом текущей секции\ |
33 |
|
|
% } |
34 |
|
|
% } else { |
35 |
|
|
в разделе\ |
36 |
|
|
% } |
37 |
|
|
% if ( $total > 0 ) { |
38 |
|
|
(всего: <% $total %>, показано с <% $first + 1 %> по <% ($first + $n > $total) ? $total : $first + $n %>) |
39 |
|
|
% } |
40 |
|
|
</legend> |
41 |
|
|
|
42 |
|
|
% if ($total || scalar @documents || defined($alpha) || defined($search) ) { |
43 |
|
|
% |
44 |
|
|
|
45 |
|
|
<& "/contenido/components/new_objects_form.msn", proto => 'documents', |
46 |
|
|
sect_id => ref $owner ? $owner->id : undef, |
47 |
|
|
default => 'blogs::Blog' &> |
48 |
|
|
|
49 |
|
|
<div style="font-size:12px; font-family:Arial;"> |
50 |
|
|
<table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0 0; border:1px solid gray;"> |
51 |
|
|
<tr bgcolor="#e0e0e0"><th colspan="4">Поиск по букве: [<a href="?id=<% $id %>" style="font-weight:normal;">сброс фильтра</a>]</th></tr> |
52 |
|
|
<tr><td style="font-size:12px; font-family:Arial; padding:2px 4px;"> |
53 |
|
|
<& /inc/alpha.msn, alpha=>$alpha, params=>\%ARGS, &> |
54 |
|
|
</td></tr></table> |
55 |
|
|
|
56 |
|
|
% ## Форма поиска. Работает при включенном фильтре класса |
57 |
|
|
% ## и описанной для класса функции search_fields |
58 |
|
|
% ######################################################## |
59 |
|
|
% if ( $filter{class} ) { |
60 |
|
|
% my $document = $filter{class}->new ($keeper); |
61 |
|
|
% my @fields = $document->search_fields; |
62 |
|
|
% if ( @fields ) { |
63 |
|
|
% my @props = $document->required_properties; |
64 |
|
|
<form action="sections.html"> |
65 |
|
|
<table border="0" cellspacing="0" cellpadding="2" width="100%" style="margin:4px 0; border:1px solid gray;"> |
66 |
|
|
<tr bgcolor="#e0e0e0"><th colspan="4">Поиск по полю: [<a href="?id=<% $id %>" style="font-weight:normal;">сброс фильтра</a>]</th></tr><tr> |
67 |
|
|
<td width="1%" nowrap style="padding:2px 0 2px 4px;"><select name="search_by"> |
68 |
|
|
% foreach my $field ( @fields ) { |
69 |
|
|
% my ($prop) = grep { $_->{'attr'} eq $field } @props; |
70 |
|
|
% my $selected = $field eq $search_by ? ' selected' : ''; |
71 |
|
|
<option value="<% $field %>"<% $selected %>><% ref $prop ? $prop->{'shortname'} || $prop->{'rusname'} : $field %> |
72 |
|
|
% } |
73 |
|
|
</td><td width="0">:</td> |
74 |
|
|
<td width="98%"><input type="text" name="search" value="<% $search %>" style="width:100%"></td> |
75 |
|
|
<td width="1%" style="padding:2px 4px 2px 0;"><input type="submit" value=" » " style="border:1px solid gray;"></td> |
76 |
|
|
</tr></table> |
77 |
|
|
% if ( $id ) { |
78 |
|
|
<input type="hidden" name="id" value="<% $id %>"> |
79 |
|
|
% } |
80 |
|
|
% if ( $class ) { |
81 |
|
|
<input type="hidden" name="class" value="<% $class %>"> |
82 |
|
|
% } |
83 |
|
|
% if ( $use_section ) { |
84 |
|
|
<input type="hidden" name="use_section" value="<% $use_section %>"> |
85 |
|
|
% } |
86 |
|
|
</form> |
87 |
|
|
% } |
88 |
|
|
% } |
89 |
|
|
|
90 |
|
|
<div style="height:5px"><spacer type="block" height="5"></div> |
91 |
|
|
<& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &> |
92 |
|
|
</div> |
93 |
|
|
|
94 |
|
|
<& /contenido/blogs/components/blogs_browse.msn, documents => \@documents, columns => \@columns, section => $owner, filter => \%filter_params, %ARGS &> |
95 |
|
|
|
96 |
|
|
<div style="font-size:12px; font-family:Arial;"> |
97 |
|
|
<& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &> |
98 |
|
|
<div style="height:5px"><spacer type="block" height="5"></div> |
99 |
|
|
</div> |
100 |
|
|
|
101 |
|
|
|
102 |
|
|
% } else { |
103 |
|
|
<h4 align="center"><i>---- Нет документов -----</i></h4> |
104 |
|
|
% } |
105 |
|
|
% |
106 |
|
|
|
107 |
|
|
<& "/contenido/components/new_objects_form.msn", proto => 'documents', |
108 |
|
|
sect_id => ref $owner ? $owner->id : undef, |
109 |
|
|
default => 'blogs::Blog' &> |
110 |
|
|
|
111 |
|
|
</fieldset> |
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
</td> |
116 |
|
|
</tr> |
117 |
|
|
</table> |
118 |
|
|
|
119 |
|
|
|
120 |
234 |
ahitrov |
</body> |
121 |
|
|
</html> |
122 |
236 |
ahitrov |
<%args> |
123 |
|
|
|
124 |
|
|
$id => undef |
125 |
|
|
$p => 1 |
126 |
|
|
$class => 'blogs::Blog' |
127 |
|
|
$use_section => undef |
128 |
|
|
$alpha => undef |
129 |
|
|
$alpha_search => undef |
130 |
|
|
$search_by => undef |
131 |
|
|
$search => undef |
132 |
|
|
$update => undef |
133 |
|
|
$delete => undef |
134 |
|
|
|
135 |
|
|
</%args> |
136 |
|
|
<%init> |
137 |
|
|
|
138 |
|
|
$id = 0 if $id =~ /\D/; |
139 |
|
|
my $owner; |
140 |
|
|
|
141 |
|
|
if ( ref $project->s_alias && exists $project->s_alias->{blogs} ) { |
142 |
|
|
$owner = $keeper->get_section_by_id( $project->s_alias->{blogs} ); |
143 |
|
|
} else { |
144 |
|
|
$owner = $keeper->get_section_by_id( $Contenido::Section::ROOT ); |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
my %filter_params; |
148 |
|
|
$filter_params{class} = $class if $class; |
149 |
|
|
$filter_params{alpha} = $alpha if $alpha; |
150 |
|
|
$filter_params{alpha_search} = $alpha_search if $alpha_search; |
151 |
|
|
$filter_params{search_by} = $search_by if $search_by; |
152 |
|
|
$filter_params{search} = $search if $search; |
153 |
|
|
$filter_params{p} = $p if $p && $p > 1; |
154 |
|
|
|
155 |
|
|
# Фильтры работают в любом случае... |
156 |
|
|
my $filter = $m->comp('/contenido/components/context.msn', name => 'filter'); |
157 |
|
|
my $profile = $m->comp('/contenido/components/context.msn', name => 'profile'); |
158 |
|
|
|
159 |
|
|
my (@documents, $total); |
160 |
|
|
|
161 |
|
|
|
162 |
|
|
my %filter=(); |
163 |
|
|
my $nothing_found = 0; |
164 |
|
|
my %order = (order => ['date','direct']); |
165 |
|
|
if (defined $alpha and $alpha ne '') { |
166 |
|
|
$filter{ilike}=1; |
167 |
|
|
$filter{ $alpha_search || 'name' }="$alpha%"; |
168 |
|
|
$order{order}=['name','reverse']; |
169 |
|
|
delete $order{order_by}; |
170 |
|
|
} |
171 |
|
|
$filter{class} = $class; |
172 |
|
|
|
173 |
|
|
if ( $search_by && defined $search ) { |
174 |
|
|
my $doc_class = $class; |
175 |
|
|
if ( $doc_class ) { |
176 |
|
|
my @props = $doc_class->new( $keeper )->structure(); |
177 |
|
|
my ($prop) = grep { $_->{attr} eq $search_by } @props if @props; |
178 |
|
|
if ( ref $prop && ($prop->{type} eq 'integer' || $prop->{type} eq 'checkbox' || |
179 |
|
|
(($prop->{type} eq 'pickup' || $prop->{type} eq 'lookup') && $search =~ /^\d+$/) || |
180 |
|
|
(exists $prop->{db_type} && $prop->{db_type} =~ /integer\[\]/) )) { |
181 |
|
|
$filter{$search_by} = int($search); |
182 |
|
|
} elsif ( ref $prop && ($prop->{type} eq 'pickup' || $prop->{type} eq 'lookup') && $search =~ /\D/ ) { |
183 |
|
|
my $lookup_opts = $prop->{lookup_opts}; |
184 |
|
|
if ( ref $lookup_opts && exists $lookup_opts->{class} ) { |
185 |
|
|
my $search_field = exists $lookup_opts->{search_by} ? $lookup_opts->{search_by} : 'name'; |
186 |
|
|
my @ids = $keeper->get_documents ( |
187 |
|
|
ids => 1, |
188 |
|
|
class => $lookup_opts->{class}, |
189 |
|
|
ilike => 1, |
190 |
|
|
$search_field => '%'.$search.'%', |
191 |
|
|
); |
192 |
|
|
if ( @ids ) { |
193 |
|
|
$filter{$search_by} = \@ids; |
194 |
|
|
} else { |
195 |
|
|
$nothing_found = 1; |
196 |
|
|
} |
197 |
|
|
} |
198 |
|
|
} else { |
199 |
|
|
$filter{$search_by}='%'.$search.'%'; |
200 |
|
|
$filter{ilike} = 1; |
201 |
|
|
} |
202 |
|
|
} else { |
203 |
|
|
$filter{$search_by}='%'.$search.'%'; |
204 |
|
|
$filter{ilike} = 1; |
205 |
|
|
} |
206 |
|
|
} |
207 |
|
|
$total = $keeper->get_documents(%filter, count=>1); |
208 |
|
|
|
209 |
|
|
my $n = 40; |
210 |
|
|
my $first = $n * ($p - 1); |
211 |
|
|
($first,$p)=(0,0) if $first > $total; |
212 |
|
|
|
213 |
|
|
unless ( $nothing_found ) { |
214 |
|
|
@documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first); |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
# набор колонок таблицы документов... |
218 |
|
|
my @columns = (); |
219 |
|
|
|
220 |
|
|
# пытаемся найти колонки, которые документ сам пожелал показать (required_properties -> column)... |
221 |
|
|
if ($filter{class} or @documents and $documents[0]) { |
222 |
|
|
push @columns, |
223 |
|
|
sort {$a->{column} <=> $b->{column}} |
224 |
|
|
grep {$_->{column}} ($filter{class} ? $filter{class}->new($keeper)->structure : $documents[0]->structure); |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
# стандартная жопка таблицы... |
228 |
|
|
@columns = (@columns, |
229 |
|
|
{attr => '_act_', rusname => 'Действия'}, |
230 |
|
|
); |
231 |
|
|
|
232 |
|
|
</%init> |