From 629d616de5275164349608827ad83e8013b4b7ed Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 20 Jul 2013 20:01:22 -0400 Subject: [PATCH] post search: internationalize and use config values --- search.php | 31 +++++++++++++++++++++---------- templates/search_form.html | 8 ++++---- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/search.php b/search.php index d2dbdf24..30c05df1 100644 --- a/search.php +++ b/search.php @@ -1,11 +1,15 @@ $boards, 'board' => isset($_POST['board']) ? $_POST['board'] : false, 'search' => isset($_POST['search']) ? str_replace('"', '"', utf8tohtml($_POST['search'])) : false)); @@ -18,13 +22,13 @@ $query->bindValue(':time', time() - ($queries_per_minutes[1] * 60)); $query->execute() or error(db_error($query)); if($query->fetchColumn() > $queries_per_minutes[0]) - error('Wait a while before searching again, please.'); + error(_('Wait a while before searching again, please.')); $query = prepare("SELECT COUNT(*) FROM `search_queries` WHERE `time` > :time"); $query->bindValue(':time', time() - ($queries_per_minutes_all[1] * 60)); $query->execute() or error(db_error($query)); if($query->fetchColumn() > $queries_per_minutes_all[0]) - error('Wait a while before searching again, please.'); + error(_('Wait a while before searching again, please.')); $query = prepare("INSERT INTO `search_queries` VALUES (:ip, :time, :query)"); @@ -34,6 +38,11 @@ $query->execute() or error(db_error($query)); _syslog(LOG_NOTICE, 'Searched /' . $_POST['board'] . '/ for "' . $phrase . '"'); + + // Cleanup search queries table + $query = prepare("DELETE FROM `search_queries` WHERE `time` <= :time"); + $query->bindValue(':time', time() - ($queries_per_minutes_all[1] * 60)); + $query->execute() or error(db_error($query)); openBoard($_POST['board']); @@ -44,7 +53,7 @@ $name = $m[2]; $value = isset($m[4]) ? $m[4] : $m[3]; - if(!in_array($name, Array('id', 'thread', 'subject', 'name'))) { + if(!in_array($name, array('id', 'thread', 'subject', 'name'))) { // unknown filter return $m[0]; } @@ -116,7 +125,7 @@ if($query->rowCount() == $search_limit) { _syslog(LOG_WARNING, 'Query too broad.'); - $body .= '

(Query too broad.)

'; + $body .= '

('._('Query too broad.').')

'; echo Element('page.html', Array( 'config'=>$config, 'title'=>'Search', @@ -136,7 +145,9 @@ } if(!empty($temp)) - $_body .= '
' . $query->rowCount() . ' result' . ($query->rowCount() != 1 ? 's' : '') . ' in ' . sprintf($config['board_abbreviation'], $board['uri']) . ' - ' . $board['title'] . @@ -146,7 +157,7 @@ if(!empty($_body)) $body .= $_body; else - $body .= '

(No results.)

'; + $body .= '

('._('No results.').')

'; } echo Element('page.html', Array( diff --git a/templates/search_form.html b/templates/search_form.html index 16b5d4af..a391ac53 100644 --- a/templates/search_form.html +++ b/templates/search_form.html @@ -1,11 +1,11 @@
-

Search

+

{% trans %}Search{% endtrans %}

- +