Alexander Nicolaysen Sørnes : Search for partial app names
Chris Morgan
cmorgan at winehq.org
Tue Jun 17 18:28:21 CDT 2008
Module: appdb
Branch: master
Commit: 88c098c83fbe306e9c08f107229a80506dff0036
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=88c098c83fbe306e9c08f107229a80506dff0036
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Wed Jun 18 00:14:27 2008 +0200
Search for partial app names
---
include/application_queue.php | 5 ++++-
include/util.php | 32 ++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/include/application_queue.php b/include/application_queue.php
index 0c7f2f3..d20dca8 100644
--- a/include/application_queue.php
+++ b/include/application_queue.php
@@ -276,8 +276,11 @@ class application_queue
function displayDuplicates()
{
- echo "<b>Like matches</b>\n";
+ echo "<b>Like matches</b><br />\n";
$this->displayDuplicateTable(searchForApplication($this->oApp->sName));
+ echo "<br />\n";
+ echo "<b>Partial matches</b><br />\n";
+ $this->displayDuplicateTable(searchForApplicationPartial($this->oApp->sName));
}
function displayDuplicateTable($hResult)
diff --git a/include/util.php b/include/util.php
index 57576ae..4009d1c 100644
--- a/include/util.php
+++ b/include/util.php
@@ -412,6 +412,34 @@ function cleanupSearchWords($search_words)
return $search_words;
}
+/* A common error for users is to submit a new app entry for a new app version,
+ such as C&C Red Alert 2 Yuri's Revenge when we already have C&C Red Alert 2.
+ Search for the first word in the search query */
+function searchForApplicationPartial($sSearchWords)
+{
+ $sSearchWords = cleanupSearchWords($sSearchWords);
+ $aWords = explode(' ', $sSearchWords);
+ $sSearchString = '';
+
+ for($i = 0; $i < sizeof($aWords); $i++)
+ {
+ if($i)
+ $sSearchString .= '%';
+ $sSearchString .= $aWords[$i];
+ if(strlen($aWords[$i]) > 4)
+ {
+ if($i < (sizeof($aWords) - 1))
+ $sSearchString .= ' ';
+ break;
+ }
+ }
+
+ $hResult = query_parameters("SELECT * FROM appFamily WHERE state = 'accepted' AND
+ appName LIKE '?%'", $sSearchString);
+
+ return $hResult;
+}
+
/* search the database and return a hResult from the query_appdb() */
function searchForApplication($search_words)
{
@@ -524,6 +552,10 @@ function perform_search_and_output_results($search_words)
echo "<center><b>Like matches</b></center>";
$hResult = searchForApplication($search_words);
outputSearchTableForhResult($search_words, $hResult);
+
+ echo "<center><b>Partial matches</b></center>";
+ $hResult = searchForApplicationPartial($search_words);
+ outputSearchTableForhResult($search_words, $hResult);
}
function display_page_range($iCurrentPage=1, $iPageRange=1, $iTotalPages=1, $sLinkurl=NULL)
More information about the wine-cvs
mailing list