15 |
my $entries_per_page = 30; |
my $entries_per_page = 30; |
16 |
my $debug = param('debug'); |
my $debug = param('debug'); |
17 |
|
|
18 |
print header; |
print header( |
19 |
|
-charset => 'utf-8', |
20 |
|
); |
21 |
|
|
22 |
sub dump_yaml { |
sub dump_yaml { |
23 |
my $name = shift; |
my $name = shift; |
61 |
return |
return |
62 |
$pager->previous_page ? li_a_href( $pager->previous_page, $prev ) : qq|<li class=skip>$prev</li>| |
$pager->previous_page ? li_a_href( $pager->previous_page, $prev ) : qq|<li class=skip>$prev</li>| |
63 |
, ( map { |
, ( map { |
64 |
if ( $_ == $pager->current_page ) { |
if ( $_ eq $pager->current_page ) { |
65 |
qq|<li class=current_page>$_</li>|; |
qq|<li class=current_page>$_</li>|; |
66 |
} elsif ( $_ eq '' ) { |
} elsif ( $_ eq '' ) { |
67 |
qq|<li class=skip>...</li>|; |
qq|<li class=skip>...</li>|; |
112 |
# -linebreak => 0, |
# -linebreak => 0, |
113 |
), |
), |
114 |
textfield( -name => 'search' ), |
textfield( -name => 'search' ), |
115 |
|
popup_menu( -name => 'attr_operator', -values => [ '', 'STRBW', 'STREQ' ], |
116 |
|
-labels => { |
117 |
|
'' => 'Bilo koja riječ', |
118 |
|
'STRBW' => 'Početak', |
119 |
|
'STREQ' => 'Točan oblik', |
120 |
|
}, |
121 |
|
), |
122 |
submit, |
submit, |
123 |
textfield( -name => 'entries_per_page', -default => $entries_per_page ), |
hidden( -name => 'entries_per_page', -default => $entries_per_page ), |
124 |
textfield( -name => 'current_page', -default => 1 ), |
hidden( -name => 'current_page', -default => 1 ), |
125 |
|
checkbox( -name => 'debug', -default => 0 ), # FIXME hidden? |
126 |
; |
; |
127 |
|
|
128 |
print end_form; |
print end_form; |
143 |
|
|
144 |
dump_yaml( 'pager', $pager ); |
dump_yaml( 'pager', $pager ); |
145 |
|
|
146 |
my $cond = Search::Estraier::Condition->new; |
my $cond = Search::Estraier::Condition->new( debug => $debug ); |
147 |
$cond->set_phrase( $search ); |
$cond->set_phrase( $search ); |
148 |
$cond->set_skip( $pager->skipped ); |
$cond->set_skip( $pager->skipped ); |
149 |
$cond->set_max( $pager->entries_per_page ); |
$cond->set_max( $pager->entries_per_page ); |
150 |
|
|
151 |
|
if ( my $op = param('attr_operator') ) { |
152 |
|
$cond->add_attr( param('attr') . " $op " . param('search') ); |
153 |
|
} |
154 |
|
|
155 |
my $nres = $node->search( $cond, 0 ); |
my $nres = $node->search( $cond, 0 ); |
156 |
$pager->total_entries( $nres->hits ); |
$pager->total_entries( $nres->hits ); |
157 |
|
|
|
|
|
158 |
dump_yaml( 'cond', $cond ); |
dump_yaml( 'cond', $cond ); |
159 |
|
dump_yaml( 'nres', $nres ); |
160 |
|
|
161 |
if ( ! $nres ) { |
if ( ! $nres ) { |
162 |
my $no_results = "No results for search '%s'"; |
my $no_results = "No results for search '%s'"; |
166 |
my $results = "%d results for search '%s' showing results %d - %d on page %d"; |
my $results = "%d results for search '%s' showing results %d - %d on page %d"; |
167 |
printf qq|<div class="message">$results</div>\n\n|, $nres->hits, $search, $pager->first, $pager->last, $pager->current_page; |
printf qq|<div class="message">$results</div>\n\n|, $nres->hits, $search, $pager->first, $pager->last, $pager->current_page; |
168 |
|
|
|
dump_yaml( 'pager html', show_pager( $pager )); |
|
|
|
|
169 |
my $pager_html = join("\n", show_pager( $pager )); |
my $pager_html = join("\n", show_pager( $pager )); |
170 |
|
|
171 |
print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html; |
print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html; |