summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Reddy <lynx@lindenlab.com>2009-10-20 14:07:50 +0000
committerMartin Reddy <lynx@lindenlab.com>2009-10-20 14:07:50 +0000
commiteb620735fc27d5f4fe21b52deceaec2818fea27d (patch)
tree07c068436dc31ce970517c4f49104be6a32ed95a
parent2180706f4cb5e8f5ba24b3973a25a50c6176be38 (diff)
DEV-41358: Added support for search categories.
You can now specify a search category for all web-based searches, e.g., "all" (default), "people", "places", "events", "groups", "wiki", "destinations", "classifieds". Specifying a category will add the relevant subdir to the search URL, as specified by the search team.
-rw-r--r--indra/newview/lleventnotifier.cpp2
-rw-r--r--indra/newview/llfloatersearch.cpp45
-rw-r--r--indra/newview/llfloatersearch.h8
-rw-r--r--indra/newview/llgroupactions.cpp2
-rw-r--r--indra/newview/llnavigationbar.cpp2
-rw-r--r--indra/newview/llworldmapview.cpp6
-rw-r--r--indra/newview/skins/default/xui/en/floater_search.xml2
7 files changed, 52 insertions, 15 deletions
diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp
index 68a4f31730..867fb0255a 100644
--- a/indra/newview/lleventnotifier.cpp
+++ b/indra/newview/lleventnotifier.cpp
@@ -198,7 +198,7 @@ bool LLEventNotification::handleResponse(const LLSD& notification, const LLSD& r
break;
}
case 1:
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "event").insert("id", S32(getEventID())));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "events").insert("id", S32(getEventID())));
break;
case 2:
break;
diff --git a/indra/newview/llfloatersearch.cpp b/indra/newview/llfloatersearch.cpp
index 904263e2c2..4c83530f43 100644
--- a/indra/newview/llfloatersearch.cpp
+++ b/indra/newview/llfloatersearch.cpp
@@ -40,6 +40,17 @@ LLFloaterSearch::LLFloaterSearch(const LLSD& key) :
LLFloater(key),
mBrowser(NULL)
{
+ // declare a map that transforms a category name into
+ // the URL suffix that is used to search that category
+ mCategoryPaths = LLSD::emptyMap();
+ mCategoryPaths["all"] = "search";
+ mCategoryPaths["people"] = "search/people";
+ mCategoryPaths["places"] = "search/places";
+ mCategoryPaths["events"] = "search/events";
+ mCategoryPaths["groups"] = "search/groups";
+ mCategoryPaths["wiki"] = "search/wiki";
+ mCategoryPaths["destinations"] = "destinations";
+ mCategoryPaths["classifieds"] = "classifieds";
}
BOOL LLFloaterSearch::postBuild()
@@ -79,13 +90,33 @@ void LLFloaterSearch::handleMediaEvent(LLPluginClassMedia *self, EMediaEvent eve
void LLFloaterSearch::search(const LLSD &key)
{
- if (mBrowser)
+ if (! mBrowser)
+ {
+ return;
+ }
+
+ // get the URL for the search page
+ std::string url = getString("search_url");
+ if (! LLStringUtil::endsWith(url, "/"))
{
- std::string query = getString("search_url");
- if (key.has("id"))
- {
- query += std::string("?q=") + key["id"].asString();
- }
- mBrowser->navigateTo(query);
+ url += "/";
}
+
+ // work out the subdir to use based on the requested category
+ std::string category = key.has("category") ? key["category"].asString() : "";
+ if (mCategoryPaths.has(category))
+ {
+ url += mCategoryPaths[category].asString();
+ }
+ else
+ {
+ url += mCategoryPaths["all"].asString();
+ }
+
+ // append the search query string
+ std::string search_text = key.has("id") ? key["id"].asString() : "";
+ url += std::string("?q=") + search_text;
+
+ // and load the URL in the web view
+ mBrowser->navigateTo(url);
}
diff --git a/indra/newview/llfloatersearch.h b/indra/newview/llfloatersearch.h
index 46af53b154..743107484f 100644
--- a/indra/newview/llfloatersearch.h
+++ b/indra/newview/llfloatersearch.h
@@ -56,9 +56,14 @@ public:
LLFloaterSearch(const LLSD& key);
/// show the search floater with a new search
+ /// see search() for details on the key parameter.
/*virtual*/ void onOpen(const LLSD& key);
- /// perform a search with the specific search term
+ /// perform a search with the specific search term.
+ /// The key should be a map that can contain the following keys:
+ /// - "id": specifies the text phrase to search for
+ /// - "category": one of "all" (default), "people", "places",
+ /// "events", "groups", "wiki", "destinations", "classifieds"
void search(const LLSD &key);
private:
@@ -68,6 +73,7 @@ private:
/*virtual*/ void handleMediaEvent(LLPluginClassMedia *self, EMediaEvent event);
LLMediaCtrl *mBrowser;
+ LLSD mCategoryPaths;
};
#endif // LL_LLFLOATERSEARCH_H
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index 220fb3c8a0..c46eedbef2 100644
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -112,7 +112,7 @@ LLGroupHandler gGroupHandler;
// static
void LLGroupActions::search()
{
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "group"));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "groups"));
}
// static
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index 19fee20740..b77415dfee 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -535,7 +535,7 @@ void LLNavigationBar::handleLoginComplete()
void LLNavigationBar::invokeSearch(std::string search_text)
{
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "all").insert("id", LLSD(search_text)));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "all").insert("id", LLSD(search_text)));
}
void LLNavigationBar::clearHistoryCache()
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 5446a08ebf..3aad5c7378 100644
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -1897,20 +1897,20 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask )
id.toString(uuid_str);
uuid_str = uuid_str.substr(28);
sscanf(uuid_str.c_str(), "%X", &event_id);
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "event").insert("id", event_id));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "events").insert("id", event_id));
break;
}
case MAP_ITEM_LAND_FOR_SALE:
case MAP_ITEM_LAND_FOR_SALE_ADULT:
{
LLFloaterReg::hideInstance("world_map");
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "land").insert("id", id));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "destinations").insert("id", id));
break;
}
case MAP_ITEM_CLASSIFIED:
{
LLFloaterReg::hideInstance("world_map");
- LLFloaterReg::showInstance("search", LLSD().insert("panel", "classified").insert("id", id));
+ LLFloaterReg::showInstance("search", LLSD().insert("category", "classifieds").insert("id", id));
break;
}
default:
diff --git a/indra/newview/skins/default/xui/en/floater_search.xml b/indra/newview/skins/default/xui/en/floater_search.xml
index 4ac0edca5a..296cde92e3 100644
--- a/indra/newview/skins/default/xui/en/floater_search.xml
+++ b/indra/newview/skins/default/xui/en/floater_search.xml
@@ -13,7 +13,7 @@
width="620">
<floater.string
name="search_url">
- http://eniac21.lindenlab.com:10001/viewer/search/
+ http://eniac21.lindenlab.com:10001/viewer
</floater.string>
<floater.string
name="loading_text">