diff options
author | Martin Reddy <lynx@lindenlab.com> | 2009-10-20 14:07:50 +0000 |
---|---|---|
committer | Martin Reddy <lynx@lindenlab.com> | 2009-10-20 14:07:50 +0000 |
commit | eb620735fc27d5f4fe21b52deceaec2818fea27d (patch) | |
tree | 07c068436dc31ce970517c4f49104be6a32ed95a /indra/newview/llfloatersearch.cpp | |
parent | 2180706f4cb5e8f5ba24b3973a25a50c6176be38 (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.
Diffstat (limited to 'indra/newview/llfloatersearch.cpp')
-rw-r--r-- | indra/newview/llfloatersearch.cpp | 45 |
1 files changed, 38 insertions, 7 deletions
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); } |