Index: openacs-4/packages/search/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.tcl,v diff -u -r1.38 -r1.39 --- openacs-4/packages/search/www/search.tcl 27 Oct 2014 16:41:55 -0000 1.38 +++ openacs-4/packages/search/www/search.tcl 27 Apr 2015 15:28:20 -0000 1.39 @@ -75,7 +75,6 @@ #set q [string tolower $q] set urlencoded_query [ad_urlencode $q] -if { $offset < 0 } { set offset 0 } set params [list $q $offset $limit $user_id $df] if {$search_package_id eq "" && [parameter::get -package_id $package_id -parameter SubsiteSearchP -default 1] && [subsite::main_site_id] != [ad_conn subsite_id]} { @@ -128,10 +127,17 @@ } set elapsed [format "%.02f" [expr {double(abs($tend - $t0)) / 1000.0}]] +# +# $count is the number of results to be displayed, while +# $result(count) is the total number of results (without taking +# permissions into account) +# +set count [llength $result(ids)] if { $offset >= $result(count) } { set offset [expr {($result(count) / $limit) * $limit}] } set low [expr {$offset + 1}] set high [expr {$offset + $limit}] if { $high > $result(count) } { set high $result(count) } + if { $info(automatic_and_queries_p) && "and" in $q } { set and_queries_notice_p 1 } else { @@ -142,22 +148,15 @@ append url_advanced_search "advanced-search?q=$urlencoded_query" if { $num > 0 } { append url_advanced_search "&num=$num" } - set query $q set nquery [llength [split $q]] set stopwords $result(stopwords) set nstopwords [llength $result(stopwords)] -set count $result(count) template::multirow create searchresult title_summary txt_summary url_one object_id -for { set __i 0 } { $__i < $high - $low + 1 } { incr __i } { +foreach object_id $result(ids) { if {[catch { - set object_id [lindex $result(ids) $__i] - if {$object_id eq ""} { - ns_log warning "Search object_id is empty, this should never happen query was '${q}'" - continue - } set object_type [acs_object_type $object_id] if {[callback::impl_exists -impl $object_type -callback search::datasource]} { array set datasource [lindex [callback -impl $object_type search::datasource -object_id $object_id] 0]