tazbug rev 59
bugs.cgi: fix search function
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Jan 07 20:33:09 2014 +0100 (2014-01-07) |
parents | f005632d7c8b |
children | 141a32000fcd |
files | web/bugs.cgi |
line diff
1.1 --- a/web/bugs.cgi Tue Jan 07 20:15:56 2014 +0100 1.2 +++ b/web/bugs.cgi Tue Jan 07 20:33:09 2014 +0100 1.3 @@ -750,6 +750,7 @@ 1.4 exit 0 1.5 fi ;; 1.6 *\ search\ *) 1.7 + found=0 1.8 header 1.9 html_header 1.10 user_box 1.11 @@ -761,24 +762,25 @@ 1.12 </form> 1.13 <div> 1.14 EOT 1.15 - 1.16 - #found=0 JS to notify or write results nb under the search box. 1.17 - for bug in $bugdir/* 1.18 + cd $bugdir 1.19 + for bug in * 1.20 do 1.21 result=$(fgrep -i "$(GET search)" $bug/*) 1.22 if [ "$result" ]; then 1.23 - #found=$(($found + 1)) 1.24 - id=${bug#bug/} 1.25 + found=$(($found + 1)) 1.26 + id=${bug} 1.27 echo "<p><strong>Bug $id</strong> <a href=\"?id=$id\">"$(gettext 'Show')"</a></p>" 1.28 echo '<pre>' 1.29 fgrep -i "$(GET search)" $bugdir/$id/* | \ 1.30 sed s"/$(GET search)/<span class='ok'>$(GET search)<\/span>/"g 1.31 echo '</pre>' 1.32 - else 1.33 - get_search=$(GET search) 1.34 - echo "<p>$(eval_gettext 'No result found for: $get_search')</p>" 1.35 fi 1.36 done 1.37 + if [ "$found" == "0" ]; then 1.38 + echo "<p>$(gettext 'No result found for') : $(GET search)</p>" 1.39 + else 1.40 + echo "<p> $found $(gettext 'results found')</p>" 1.41 + fi 1.42 echo '</div>' 1.43 html_footer ;; 1.44 *)