Revision 118

Date:
2011/08/22 12:04:27
Author:
ahitrov
Revision Log:
"Uncountable documents" option in Section.pm
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/core/comps/contenido/sections.html

     
    69 69 % } else {
    70 70 в разделе\
    71 71 % }
    72 % if ($total > 0) {
    72 % if (!$owner->no_count && $total > 0) {
    73 73 (всего: <% $total %>, показано с <% $first + 1 %> по <% ($first + $n > $total) ? $total : $first + $n %>)
    74 % } elsif ( $owner->no_count ) {
    75 (<span style="color:yellow">без пересчета</span>, показано с <% $first + 1 %> по <% $first + scalar @documents %>)
    74 76 % }
    75 77 </legend>
    76 78
    77 % if ($total or defined($alpha) or defined($search) ) {
    79 % if ($total || scalar @documents || defined($alpha) || defined($search) ) {
    78 80 % if ($section_access == 2) {
    79 81 <& "/contenido/components/new_objects_form.msn", proto => 'documents',
    80 82 sect_id => $owner->id,
     
    121 123 % }
    122 124
    123 125 <div style="height:5px"><spacer type="block" height="5"></div>
    126 % if ( $owner->no_count ) {
    127 <& /inc/pages_nocount.msn, p=>$p, n=>$n, found=> scalar @documents, href=>'sections.html', params=>\%ARGS, size => 15 &>
    128 % } else {
    124 129 <& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
    130 % }
    125 131 </div>
    126 132
    127 133 <& /contenido/components/section_browse.msn, documents => \@documents, columns => \@columns, section => $owner, filter => \%filter_params, %ARGS &>
    128 134
    129 135 <div style="font-size:12px; font-family:Arial;">
    136 % if ( $owner->no_count ) {
    137 <& /inc/pages_nocount.msn, p=>$p, n=>$n, found=> scalar @documents, href=>'sections.html', params=>\%ARGS, size => 15 &>
    138 % } else {
    130 139 <& /inc/pages_.msn, p=>$p, n=>$n, total=>$total, href=>'sections.html', params=>\%ARGS, &>
    140 % }
    131 141 <div style="height:5px"><spacer type="block" height="5"></div>
    132 142 </div>
    133 143
     
    326 336 }
    327 337 }
    328 338
    329 $total = $keeper->get_documents(%filter, count=>1);
    339 $total = $keeper->get_documents(%filter, count=>1) unless $owner->no_count;
    330 340
    331 341 my $n = 40;
    332 342 my $first = $n * ($p - 1);
    333 ($first,$p)=(0,0) if ($first>$total);
    343 ($first,$p)=(0,0) if (!$owner->no_count && $first>$total);
    334 344
    335 345 if ($class && !$use_section) {
    336 346 @documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first);
  • utf8/core/comps/inc/pages_nocount.msn

     
    1 % if ( @string ) {
    2 % $m->out( join($delimiter, @string) );
    3 % }
    4 <%args>
    5
    6 $n => 10
    7 $p => 1
    8 $href => ''
    9 $found => undef
    10 $size => 8
    11 $params => {}
    12 $pname => 'p'
    13 $delimiter => ' | '
    14
    15 </%args>
    16 <%init>
    17
    18 $p = 1 if $p > 10000;
    19
    20 my @string;
    21 my @params;
    22 while ( my ($key, $value) = each %$params ) {
    23 next if $key eq $pname;
    24 if ( ref $value eq 'ARRAY' ) {
    25 push @params, ( map { "$key=$_" } @$value );
    26 } else {
    27 push @params, "$key=$value";
    28 }
    29 }
    30
    31 my $delim = int( $size / 2 );
    32 my ($begin, $end);
    33 if ( $found < $n ) {
    34 $end = $p;
    35 $begin = $p >= $size ? $p - $size + 1 : 1;
    36 } elsif ( $p < $delim ) {
    37 $begin = 1;
    38 $end = $begin + $size - 1;
    39 } else {
    40 $begin = $p > $delim ? $p - $delim : 1;
    41 $end = $begin + $size - 1;
    42 }
    43 if ( $p > 1 ) {
    44 push @string, '<a href="'.$href.'?p='.($p - 1).(@params ? '&'.join('&', @params) : '' ).'">&larr; предыдущая</a>';
    45 if ( $begin > 1 ) {
    46 $string[-1] .= ' [<a href="'.$href.'?p=1'.(@params ? '&'.join('&', @params) : '' ).'">в начало</a>]';
    47 }
    48 }
    49 for ( $begin..$end ) {
    50 my $num = $_;
    51 if ( $num == $p ) {
    52 push @string, '<b>'.$num.'</b>';
    53 } else {
    54 push @string, '<a href="'.$href.'?p='.$num.( @params ? '&'.join('&', @params) : '' ).'">'.$num.'</a>';
    55 }
    56 }
    57 if ( defined $found && $found >= $n ) {
    58 push @string, '<a href="'.$href.'?p='.($p + 1).( @params ? '&'.join('&', @params) : '' ).'">следующая &rarr;</a>';
    59 }
    60
    61 </%init>
  • utf8/core/lib/Contenido/Section.pm

     
    108 108 'rusname' => 'Сортировка документов',
    109 109 },
    110 110 {
    111 'attr' => 'no_count',
    112 'type' => 'checkbox',
    113 'rusname' => 'Не пересчитывать документы в разделе админки',
    114 },
    115 {
    111 116 'attr' => 'filters',
    112 117 'type' => 'struct',
    113 118 'rusname' => 'Дополнительные фильтры выборки',