my $entries_per_page = 30;
my $debug = param('debug');
-print header;
+print header(
+ -charset => 'utf-8',
+);
sub dump_yaml {
my $name = shift;
return
$pager->previous_page ? li_a_href( $pager->previous_page, $prev ) : qq|<li class=skip>$prev</li>|
, ( map {
- if ( $_ == $pager->current_page ) {
+ if ( $_ eq $pager->current_page ) {
qq|<li class=current_page>$_</li>|;
} elsif ( $_ eq '' ) {
qq|<li class=skip>...</li>|;
# -linebreak => 0,
),
textfield( -name => 'search' ),
+ popup_menu( -name => 'attr_operator', -values => [ '', 'STRBW', 'STREQ' ],
+ -labels => {
+ '' => 'Bilo koja riječ',
+ 'STRBW' => 'Početak',
+ 'STREQ' => 'Točan oblik',
+ },
+ ),
submit,
- textfield( -name => 'entries_per_page', -default => $entries_per_page ),
- textfield( -name => 'current_page', -default => 1 ),
+ hidden( -name => 'entries_per_page', -default => $entries_per_page ),
+ hidden( -name => 'current_page', -default => 1 ),
+ checkbox( -name => 'debug', -default => 0 ), # FIXME hidden?
+ qq|<div id=inputs>|,
+ h2( 'Select input' ),
+ checkbox_group(
+ -name => 'only_input',
+ -values => [ map { $_->{name} } @{ $db->{input} } ],
+ -linebreak=> 'true',
+ ),
+ qq|</div>|,
+
;
+dump_yaml( 'inputs', $db->{input} );
+dump_yaml( 'input names', map { $_->{name} } @{ $db->{input} } );
+
print end_form;
if ( my $search = param('search') ) {
dump_yaml( 'pager', $pager );
- my $cond = Search::Estraier::Condition->new;
+ my $cond = Search::Estraier::Condition->new( debug => $debug );
$cond->set_phrase( $search );
$cond->set_skip( $pager->skipped );
$cond->set_max( $pager->entries_per_page );
+
+ if ( my $op = param('attr_operator') ) {
+ $cond->add_attr( param('attr') . " $op " . param('search') );
+ }
+
+ foreach my $i ( param('only_input') ) {
+ $cond->add_attr( '@uri STRBW file:///search/' . $database . '/' . $i );
+ }
+
+
my $nres = $node->search( $cond, 0 );
$pager->total_entries( $nres->hits );
-
dump_yaml( 'cond', $cond );
+ dump_yaml( 'nres', $nres );
if ( ! $nres ) {
my $no_results = "No results for search '%s'";
my $results = "%d results for search '%s' showing results %d - %d on page %d";
printf qq|<div class="message">$results</div>\n\n|, $nres->hits, $search, $pager->first, $pager->last, $pager->current_page;
- dump_yaml( 'pager html', show_pager( $pager ));
-
my $pager_html = join("\n", show_pager( $pager ));
print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html;