From 9bcaad5946c7e1811c9ae4604ba5bd65e78b9ece Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 6 Jun 2006 20:46:08 +0000 Subject: [PATCH] Added optional second param to Items.search() to restrict search to a particular collectionID --- .../content/scholar/xpcom/data_access.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 55ed85429f..e2543f58eb 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -899,7 +899,7 @@ Scholar.Items = new function(){ * * TODO: more **/ - function search(text){ + function search(text, parentCollectionID){ if (!text){ text = ''; } @@ -910,9 +910,17 @@ Scholar.Items = new function(){ + "(SELECT creatorID FROM creators WHERE firstName LIKE ?1 " + "OR lastName LIKE ?1) UNION " + "SELECT itemID FROM itemKeywords WHERE keywordID IN " - + "(SELECT keywordID FROM keywords WHERE keyword LIKE ?)"; - - return Scholar.DB.columnQuery(sql, [{'string':'%' + text + '%'}]); + + "(SELECT keywordID FROM keywords WHERE keyword LIKE ?1)"; + + var sqlParams = [{'string':'%' + text + '%'}]; + + if (parentCollectionID){ + sql = "SELECT itemID FROM (" + sql + ") WHERE itemID IN " + + "(SELECT itemID FROM collectionItems WHERE collectionID=?2)"; + sqlParams.push({'int':parentCollectionID}); + } + + return Scholar.DB.columnQuery(sql, sqlParams); } @@ -1828,5 +1836,5 @@ Scholar.getItems = function(parent){ return toReturn; } - return Scholar.Items.get(children) + return Scholar.Items.get(children); }