From 332902c2a6e9080a4d9ad6744cb34b7045399a51 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 23 Apr 2009 10:59:00 +0000 Subject: [PATCH] r1792@llin: dpavlin | 2009-04-23 11:24:02 +0200 added search by attributes git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1142 07558da8-63fa-0310-ba24-9fe276d99e06 --- vhost/ecas/config.yml | 13 ++++++------- vhost/style.css | 1 + vhost/webpac2.cgi | 29 +++++++++++++++++++++-------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/vhost/ecas/config.yml b/vhost/ecas/config.yml index 4b07549..216db23 100644 --- a/vhost/ecas/config.yml +++ b/vhost/ecas/config.yml @@ -1,7 +1,6 @@ -vhost: - name: 'Katalog elektronièkih èasopisa' - description: 'dostupnih u zbirkama nabavljenim za potrebe visoko¹kolskih i znanstvenih ustanova Republike Hrvatske' +# Encoding of this file must be UTF-8! +vhost: databases: 'Zbirke' no_results: 'nema rezultata' @@ -11,8 +10,8 @@ vhost: # - naslov: 'Naslov' # # operators: -# - STRINC: 'Bilo koja rijeè' -# - STRBW: 'Poèetak naslova' +# - STRINC: 'Bilo koja riječ' +# - STRBW: 'Početak naslova' # - STREQ: 'Cijeli naslov' # @@ -40,8 +39,8 @@ kinosearch: databases: ecas: - name: 'Katalog elektronièkih èasopisa' - description: 'dostupnih u zbirkama nabavljenim za potrebe visoko¹kolskih i znanstvenih ustanova Republike Hrvatske' + name: 'Katalog elektroničkih časopisa' + description: 'dostupnih u zbirkama nabavljenim za potrebe visokoÅ¡kolskih i znanstvenih ustanova Republike Hrvatske' input: - name: 'ovid' module: 'WebPAC::Input::Ovid' diff --git a/vhost/style.css b/vhost/style.css index 28ca7c6..14bcdb0 100644 --- a/vhost/style.css +++ b/vhost/style.css @@ -19,6 +19,7 @@ form { } form label, +form select, form input { float: left; } diff --git a/vhost/webpac2.cgi b/vhost/webpac2.cgi index d9d3adc..4079f3c 100755 --- a/vhost/webpac2.cgi +++ b/vhost/webpac2.cgi @@ -15,7 +15,9 @@ my $range_around = 5; my $entries_per_page = 30; my $debug = param('debug'); -print header; +print header( + -charset => 'utf-8', +); sub dump_yaml { my $name = shift; @@ -59,7 +61,7 @@ sub show_pager { return $pager->previous_page ? li_a_href( $pager->previous_page, $prev ) : qq|| , ( map { - if ( $_ == $pager->current_page ) { + if ( $_ eq $pager->current_page ) { qq|
  • $_
  • |; } elsif ( $_ eq '' ) { qq||; @@ -110,9 +112,17 @@ print # -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? ; print end_form; @@ -133,15 +143,20 @@ 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') ); + } + 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'"; @@ -151,8 +166,6 @@ if ( my $search = param('search') ) { my $results = "%d results for search '%s' showing results %d - %d on page %d"; printf qq|
    $results
    \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|\n\n| if $pager_html; -- 2.20.1