r1792@llin: dpavlin | 2009-04-23 11:24:02 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 23 Apr 2009 10:59:00 +0000 (10:59 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 23 Apr 2009 10:59:00 +0000 (10:59 +0000)
 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
vhost/style.css
vhost/webpac2.cgi

index 4b07549..216db23 100644 (file)
@@ -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'
index 28ca7c6..14bcdb0 100644 (file)
@@ -19,6 +19,7 @@ form {
 }
 
 form label,
+form select,
 form input {
        float: left;
 }
index d9d3adc..4079f3c 100755 (executable)
@@ -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|<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>|;
@@ -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|<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;