PageRenderTime 423ms CodeModel.GetById 181ms app.highlight 3ms RepoModel.GetById 137ms app.codeStats 1ms

/indra/newview/llviewerhelputil.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 67 lines | 26 code | 7 blank | 34 comment | 0 complexity | 54c1b373955840856da3ba36fca1cf44 MD5 | raw file
 1/** 
 2 * @file llviewerhelp.cpp
 3 * @brief Utility functions for the Help system
 4 * @author Soft Linden
 5 *
 6 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
 7 * Second Life Viewer Source Code
 8 * Copyright (C) 2010, Linden Research, Inc.
 9 * 
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation;
13 * version 2.1 of the License only.
14 * 
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Lesser General Public License for more details.
19 * 
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 * 
24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
25 * $/LicenseInfo$
26 */
27
28#include "llviewerprecompiledheaders.h"
29#include "llviewerhelputil.h"
30
31#include "llagent.h"
32#include "llsd.h"
33#include "llstring.h"
34#include "lluri.h"
35#include "llweb.h"
36#include "llviewercontrol.h"
37
38//////////////////////////////////////////////
39// Build a help URL from a topic and formatter
40
41//static
42std::string LLViewerHelpUtil::helpURLEncode( const std::string &component )
43{
44	// Every character rfc3986 allows as unreserved in 2.3, minus the tilde
45	// which we may grant special meaning. Yay.
46	const char* allowed =   
47	"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
48	"abcdefghijklmnopqrstuvwxyz"
49	"0123456789"
50	"-._";
51	std::string escaped = LLURI::escape(component, allowed);
52	
53	return escaped;
54}
55
56//static
57std::string LLViewerHelpUtil::buildHelpURL( const std::string &topic)
58{
59	LLSD substitution;
60	substitution["TOPIC"] = helpURLEncode(topic);
61	substitution["DEBUG_MODE"] = gAgent.isGodlike() ? "/debug" : "";
62	
63	// get the help URL and expand all of the substitutions
64	// (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
65	std::string helpURL = gSavedSettings.getString("HelpURLFormat");
66	return LLWeb::expandURLSubstitutions(helpURL, substitution);
67}