diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llpaneldirfind.cpp | 169 |
1 files changed, 95 insertions, 74 deletions
diff --git a/linden/indra/newview/llpaneldirfind.cpp b/linden/indra/newview/llpaneldirfind.cpp index cb83ee1..ed22477 100644 --- a/linden/indra/newview/llpaneldirfind.cpp +++ b/linden/indra/newview/llpaneldirfind.cpp | |||
@@ -227,8 +227,20 @@ void LLPanelDirFindAll::search(const std::string& search_text) | |||
227 | 227 | ||
228 | if (!search_text.empty()) | 228 | if (!search_text.empty()) |
229 | { | 229 | { |
230 | // Check whether or not we're on the old or web search All -- MC | ||
231 | bool is_web = false; | ||
232 | LLPanel* tabs_panel = mFloaterDirectory->getChild<LLTabContainer>("Directory Tabs")->getCurrentPanel(); | ||
233 | if (tabs_panel) | ||
234 | { | ||
235 | is_web = tabs_panel->getName() == "find_all_panel"; | ||
236 | } | ||
237 | else | ||
238 | { | ||
239 | llwarns << "search panel not found! How can this be?!" << llendl; | ||
240 | } | ||
241 | |||
230 | std::string selected_collection = childGetValue( "Category" ).asString(); | 242 | std::string selected_collection = childGetValue( "Category" ).asString(); |
231 | std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult); | 243 | std::string url = buildSearchURL(search_text, selected_collection, inc_pg, inc_mature, inc_adult, is_web); |
232 | if (mWebBrowser) | 244 | if (mWebBrowser) |
233 | { | 245 | { |
234 | mWebBrowser->navigateTo(url); | 246 | mWebBrowser->navigateTo(url); |
@@ -250,26 +262,28 @@ void LLPanelDirFind::focus() | |||
250 | 262 | ||
251 | void LLPanelDirFind::navigateToDefaultPage() | 263 | void LLPanelDirFind::navigateToDefaultPage() |
252 | { | 264 | { |
253 | std::string start_url = gSavedSettings.getString("SearchURLDefault"); | 265 | std::string start_url; |
254 | // Note: beware porting stuff like below. We use the web panel in OpenSim as well as Second Life -- MC | 266 | // Note: we use the web panel in OpenSim as well as Second Life -- MC |
255 | /*if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { | 267 | if (gHippoGridManager->getConnectedGrid()->isSecondLife()) |
256 | start_url = getString("default_search_page"); | 268 | { |
257 | } else { | 269 | start_url = gSavedSettings.getString("SearchURLDefault"); |
258 | start_url = gHippoGridManager->getConnectedGrid()->getSearchUrl(); | ||
259 | start_url += "panel=" + getLabel() + "&"; | ||
260 | }*/ | ||
261 | 270 | ||
262 | BOOL inc_pg = childGetValue("incpg").asBoolean(); | 271 | BOOL inc_pg = childGetValue("incpg").asBoolean(); |
263 | BOOL inc_mature = childGetValue("incmature").asBoolean(); | 272 | BOOL inc_mature = childGetValue("incmature").asBoolean(); |
264 | BOOL inc_adult = childGetValue("incadult").asBoolean(); | 273 | BOOL inc_adult = childGetValue("incadult").asBoolean(); |
265 | if (!(inc_pg || inc_mature || inc_adult)) | 274 | if (!(inc_pg || inc_mature || inc_adult)) |
275 | { | ||
276 | // if nothing's checked, just go for pg; we don't notify in | ||
277 | // this case because it's a default page. | ||
278 | inc_pg = true; | ||
279 | } | ||
280 | |||
281 | start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, true); | ||
282 | } | ||
283 | else | ||
266 | { | 284 | { |
267 | // if nothing's checked, just go for pg; we don't notify in | 285 | start_url = gSavedSettings.getString("SearchURLDefaultOpenSim"); |
268 | // this case because it's a default page. | ||
269 | inc_pg = true; | ||
270 | } | 286 | } |
271 | |||
272 | start_url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); | ||
273 | 287 | ||
274 | llinfos << "default url: " << start_url << llendl; | 288 | llinfos << "default url: " << start_url << llendl; |
275 | 289 | ||
@@ -280,11 +294,11 @@ void LLPanelDirFind::navigateToDefaultPage() | |||
280 | } | 294 | } |
281 | // static | 295 | // static |
282 | std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, | 296 | std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const std::string& collection, |
283 | bool inc_pg, bool inc_mature, bool inc_adult) | 297 | bool inc_pg, bool inc_mature, bool inc_adult, bool is_web) |
284 | { | 298 | { |
285 | std::string url; | 299 | std::string url; |
286 | if (search_text.empty()) { | 300 | if (search_text.empty()) { |
287 | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY); | 301 | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_EMPTY, is_web); |
288 | } else { | 302 | } else { |
289 | // Replace spaces with "+" for use by Google search appliance | 303 | // Replace spaces with "+" for use by Google search appliance |
290 | // Yes, this actually works for double-spaces | 304 | // Yes, this actually works for double-spaces |
@@ -307,7 +321,7 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const | |||
307 | "-._~$+!*'()"; | 321 | "-._~$+!*'()"; |
308 | std::string query = LLURI::escape(search_text_with_plus, allowed); | 322 | std::string query = LLURI::escape(search_text_with_plus, allowed); |
309 | 323 | ||
310 | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY); | 324 | url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_QUERY, is_web); |
311 | std::string substring = "[QUERY]"; | 325 | std::string substring = "[QUERY]"; |
312 | std::string::size_type where = url.find(substring); | 326 | std::string::size_type where = url.find(substring); |
313 | if (where != std::string::npos) | 327 | if (where != std::string::npos) |
@@ -325,66 +339,73 @@ std::string LLPanelDirFind::buildSearchURL(const std::string& search_text, const | |||
325 | } | 339 | } |
326 | 340 | ||
327 | } | 341 | } |
328 | url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult); | 342 | url += getSearchURLSuffix(inc_pg, inc_mature, inc_adult, is_web); |
329 | llinfos << "search url " << url << llendl; | 343 | llinfos << "search url " << url << llendl; |
330 | return url; | 344 | return url; |
331 | } | 345 | } |
332 | // static | 346 | // static |
333 | std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult) | 347 | std::string LLPanelDirFind::getSearchURLSuffix(bool inc_pg, bool inc_mature, bool inc_adult, bool is_web) |
334 | { | 348 | { |
335 | std::string url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_TEMPLATE); | 349 | std::string url = gHippoGridManager->getConnectedGrid()->getSearchUrl(HippoGridInfo::SEARCH_ALL_TEMPLATE, is_web); |
336 | 350 | ||
337 | // if the mature checkbox is unchecked, modify query to remove | 351 | if (!url.empty()) |
338 | // terms with given phrase from the result set | ||
339 | // This builds a value from 1-7 by or-ing together the flags, and then converts | ||
340 | // it to a string. | ||
341 | std::string substring="[MATURITY]"; | ||
342 | S32 maturityFlag = | ||
343 | (inc_pg ? SEARCH_PG : SEARCH_NONE) | | ||
344 | (inc_mature ? SEARCH_MATURE : SEARCH_NONE) | | ||
345 | (inc_adult ? SEARCH_ADULT : SEARCH_NONE); | ||
346 | url.replace(url.find(substring), substring.length(), boost::lexical_cast<std::string>(maturityFlag)); | ||
347 | |||
348 | // Include region and x/y position, not for the GSA, but | ||
349 | // just to get logs on the web server for search_proxy.php | ||
350 | // showing where people were standing when they searched. | ||
351 | std::string region_name; | ||
352 | LLViewerRegion* region = gAgent.getRegion(); | ||
353 | if (region) | ||
354 | { | 352 | { |
355 | region_name = region->getName(); | 353 | // Note: opensim's template (SearchURLSuffixOpenSim) is currently empty -- MC |
354 | if (gHippoGridManager->getConnectedGrid()->isSecondLife()) | ||
355 | { | ||
356 | // if the mature checkbox is unchecked, modify query to remove | ||
357 | // terms with given phrase from the result set | ||
358 | // This builds a value from 1-7 by or-ing together the flags, and then converts | ||
359 | // it to a string. | ||
360 | std::string substring="[MATURITY]"; | ||
361 | S32 maturityFlag = | ||
362 | (inc_pg ? SEARCH_PG : SEARCH_NONE) | | ||
363 | (inc_mature ? SEARCH_MATURE : SEARCH_NONE) | | ||
364 | (inc_adult ? SEARCH_ADULT : SEARCH_NONE); | ||
365 | url.replace(url.find(substring), substring.length(), boost::lexical_cast<std::string>(maturityFlag)); | ||
366 | |||
367 | // Include region and x/y position, not for the GSA, but | ||
368 | // just to get logs on the web server for search_proxy.php | ||
369 | // showing where people were standing when they searched. | ||
370 | std::string region_name; | ||
371 | LLViewerRegion* region = gAgent.getRegion(); | ||
372 | if (region) | ||
373 | { | ||
374 | region_name = region->getName(); | ||
375 | } | ||
376 | // take care of spaces in names | ||
377 | region_name = LLURI::escape(region_name); | ||
378 | substring = "[REGION]"; | ||
379 | url.replace(url.find(substring), substring.length(), region_name); | ||
380 | |||
381 | LLVector3 pos_region = gAgent.getPositionAgent(); | ||
382 | |||
383 | std::string x = llformat("%.0f", pos_region.mV[VX]); | ||
384 | substring = "[X]"; | ||
385 | url.replace(url.find(substring), substring.length(), x); | ||
386 | std::string y = llformat("%.0f", pos_region.mV[VY]); | ||
387 | substring = "[Y]"; | ||
388 | url.replace(url.find(substring), substring.length(), y); | ||
389 | std::string z = llformat("%.0f", pos_region.mV[VZ]); | ||
390 | substring = "[Z]"; | ||
391 | url.replace(url.find(substring), substring.length(), z); | ||
392 | |||
393 | LLUUID session_id = gAgent.getSessionID(); | ||
394 | std::string session_string = session_id.getString(); | ||
395 | substring = "[SESSION]"; | ||
396 | url.replace(url.find(substring), substring.length(), session_string); | ||
397 | |||
398 | // set the currently selected language by asking the pref setting | ||
399 | std::string language_string = LLUI::getLanguage(); | ||
400 | std::string language_tag = "[LANG]"; | ||
401 | url.replace( url.find( language_tag ), language_tag.length(), language_string ); | ||
402 | |||
403 | // and set the flag for the teen grid | ||
404 | std::string teen_string = gAgent.isTeen() ? "y" : "n"; | ||
405 | std::string teen_tag = "[TEEN]"; | ||
406 | url.replace( url.find( teen_tag ), teen_tag.length(), teen_string ); | ||
407 | } | ||
356 | } | 408 | } |
357 | // take care of spaces in names | ||
358 | region_name = LLURI::escape(region_name); | ||
359 | substring = "[REGION]"; | ||
360 | url.replace(url.find(substring), substring.length(), region_name); | ||
361 | |||
362 | LLVector3 pos_region = gAgent.getPositionAgent(); | ||
363 | |||
364 | std::string x = llformat("%.0f", pos_region.mV[VX]); | ||
365 | substring = "[X]"; | ||
366 | url.replace(url.find(substring), substring.length(), x); | ||
367 | std::string y = llformat("%.0f", pos_region.mV[VY]); | ||
368 | substring = "[Y]"; | ||
369 | url.replace(url.find(substring), substring.length(), y); | ||
370 | std::string z = llformat("%.0f", pos_region.mV[VZ]); | ||
371 | substring = "[Z]"; | ||
372 | url.replace(url.find(substring), substring.length(), z); | ||
373 | |||
374 | LLUUID session_id = gAgent.getSessionID(); | ||
375 | std::string session_string = session_id.getString(); | ||
376 | substring = "[SESSION]"; | ||
377 | url.replace(url.find(substring), substring.length(), session_string); | ||
378 | |||
379 | // set the currently selected language by asking the pref setting | ||
380 | std::string language_string = LLUI::getLanguage(); | ||
381 | std::string language_tag = "[LANG]"; | ||
382 | url.replace( url.find( language_tag ), language_tag.length(), language_string ); | ||
383 | |||
384 | // and set the flag for the teen grid | ||
385 | std::string teen_string = gAgent.isTeen() ? "y" : "n"; | ||
386 | std::string teen_tag = "[TEEN]"; | ||
387 | url.replace( url.find( teen_tag ), teen_tag.length(), teen_string ); | ||
388 | 409 | ||
389 | return url; | 410 | return url; |
390 | } | 411 | } |