--- trunk/vhost/webpac2.cgi 2009/04/22 14:27:25 1141
+++ trunk/vhost/webpac2.cgi 2009/04/23 10:59:00 1142
@@ -15,7 +15,9 @@
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 @@
return
$pager->previous_page ? li_a_href( $pager->previous_page, $prev ) : qq|
$prev|
, ( map {
- if ( $_ == $pager->current_page ) {
+ if ( $_ eq $pager->current_page ) {
qq|$_|;
} elsif ( $_ eq '' ) {
qq|...|;
@@ -110,9 +112,17 @@
# -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 @@
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 @@
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;