7 #include <boost/algorithm/string/replace.hpp>
8 #include <boost/filesystem/operations.hpp>
9 #include <boost/filesystem/exception.hpp>
10 #include <boost/filesystem/convenience.hpp>
13 #include <Wt/WContainerWidget>
14 #include <Wt/WEnvironment>
15 #include <Wt/WVBoxLayout>
16 #include <Wt/WHBoxLayout>
17 #include <Wt/WOverlayLoadingIndicator>
23 #include <gdcore/gdCore.h>
36 : gdApplication(env), m_pUser(0), m_pButtonsBar(0), m_pContent(0), m_pImages(0)
38 std::string sUid = gdWApp->getUserID();
40 wApp->log(
"notice") <<
"WsApplication::WsApplication - Start load user with uid : " << sUid;
41 std::string cip = environment().clientAddress();
42 wApp->log(
"notice") <<
"WsApplication::WsApplication - Start load user with client IP : " << cip <<
" env ip " << environment().clientAddress();
47 wApp->useStyleSheet(wApp->theme()->resourcesUrl() +
"wittyshare/Css/wittyshare.css");
48 if(boost::filesystem::exists(wApp->docRoot() +
"/wt/resources/js/functions.js"))
49 wApp->require(wApp->resourcesUrl() +
"js/functions.js");
52 if (enableLoginWindow) {
53 if ( cip.compare(0, 8,
"192.168.") == 0 || cip.compare(0, 9,
"127.0.0.1") == 0 ) {
54 m_logon =
new gdWLogon(sUid, sPwd, root());
67 m_pUser =
new WsUser(sUid, pPassword, environment().clientAddress());
69 wApp->log(
"ERROR") <<
"WsApplication::doEndDialogLogon - Cannot load user with uid : " << sUid;
72 m_logon->setError(
"Invalid username or password");
77 root()->addStyleClass(
"wsMainWin");
79 wApp->messageResourceBundle().use(wApp->docRoot() + wApp->resourcesUrl() +
"wittyshare/Transl/wittyshare");
81 wApp->messageResourceBundle().use(wApp->docRoot() + wApp->theme()->resourcesUrl() +
"wittyshare/Conf/wittyshare_config");
83 WApplication::instance()->setLoadingIndicator(
new WOverlayLoadingIndicator());
85 std::string oldInternalPath = wApp->internalPath();
86 boost::algorithm::replace_all(oldInternalPath,
"&",
"&");
88 std::string truePath(
WsModules().pathWithoutPrefix(oldInternalPath));
89 if ( oldInternalPath !=
"/" && oldInternalPath.size() > 0 ) {
109 oldInternalPath =
"";
113 if ( oldInternalPath.size() > 1 ) {
119 WVBoxLayout* vbox =
new WVBoxLayout();
120 vbox->setContentsMargins(0, 0, 0, 0);
123 if ( oldInternalPath.size() > 0 )
129 vbox->addWidget(pTB, 0);
143 m_pImages =
WsApp->WsModules().module(
"WsModImages2")->createContents();
144 WHBoxLayout* hbox =
new WHBoxLayout();
146 hbox->addWidget(pContent, 1);
147 vbox->addLayout(hbox, 1);
149 vbox->addWidget(pContent, 1);
153 root()->setLayout(vbox);
189 std::string sPage = sPageOrig;
190 boost::algorithm::replace_all(sPage,
"&",
"&");
192 std::string truePath(
WsModules().pathWithoutPrefix(sPage));
194 if ( !rootNode.get() ) {
198 NodePtr curNode = rootNode.get()->eatPath(truePath);
199 if ( !curNode.get() ) {
200 boost::filesystem::path p(truePath);
201 truePath = p.parent_path().string();
202 curNode = rootNode.get()->eatPath(truePath);
205 std::string sTemplate;
208 while (pNode.get()) {
209 sTemplate = pNode.get()->getProperties().get()->get(
"global",
"template",
"");
210 if ( sTemplate.size() > 0 )
break;
211 pNode = pNode.get()->getParent();
213 if ( sTemplate.size() < 1 ) sTemplate =
"root.tpl";
214 if ( sPage.compare(0, 5,
"/Edit" ) == 0 ) sTemplate =
"stdEditPage.tpl";
215 if ( sPage.compare(0, 8,
"/SiteMap" ) == 0 ) sTemplate =
"stdContact.tpl";
216 if ( sPage.compare(0, 5,
"/Logo" ) == 0 ) sTemplate =
"GhFullWidth.tpl";
217 if ( sPage.compare(0, 7,
"/Search" ) == 0 ) sTemplate =
"stdContact.tpl";
232 WVBoxLayout* vbox =
new WVBoxLayout();
233 vbox->setContentsMargins(0, 0, 0, 0);
234 vbox->addWidget(pTemplate, 1);
235 root()->setLayout(vbox);
237 root()->addWidget(pTemplate);
253 m_pContent->setMaximumSize(WLength::Auto, WLength(10000));
274 if (!enableAnalytics) return ;
277 std::string googleCmd =
"(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\
278 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\
279 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\
280 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\
281 ga('create', '" + UA +
"', '" + domain +
"');\
282 ga('send', 'pageview');";
283 doJavaScript(googleCmd);
WsModulesLoader & WsModules()
void doPathChanged(std::string newPath)
boost::shared_ptr< WsAbstractNode > NodePtr
int getPermissions(const std::string &p)
return the permissions on specific node
void hideImages(bool bHide=true)
std::string checkPath(const std::string &path)
void setPath(std::string newPath)
void setContent(WsContent *pContent)
const std::string getHomePage()
return the home page
Interface that provides differents methods for accessing the FsTree as well as other features...
void googleAnalyticsLogger(std::string newPath)
void setTemplate(const std::string &sPage)
int load()
Load infos of the user.
WsContentButtonsBar * m_pButtonsBar
std::string get(const std::string §ion, const std::string &id, const std::string &def)
void doEndDialogLogon(std::string sUid, std::string pPassword)
std::string get(const std::string §ion, const std::string &id, const std::string &def)
#define WsApp
Define a shortcut to the application instance.
static WsLayoutProperties * instance()
Get the singleton instance.
const std::string & homePage()
static WsGlobalProperties * instance()
WsContentButtonsBar * contentButtonsBar()
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
WsApplication(const Wt::WEnvironment &env)
void setContentButtonsBar(WsContentButtonsBar *pButtonsBar)