11 #include <Wt/WRegExpValidator>
21 : gdToolbar(parent), m_pDialog(0), m_pLE_Name(0), m_pButOk(0), m_bDebug(true)
23 if ( WString::tr(
"byObjectStyleSheet").narrow() ==
"true" )
24 wApp->useStyleSheet(wApp->theme()->resourcesUrl() +
"wittyshare/Css/WsContentButtonBar.css");
25 addStyleClass(
"WsContentButtonsBar");
26 WsApp->setContentButtonsBar(
this);
28 gdToolbarItem* pTbItem = 0;
30 pTbItem = addToolbarItem(wApp->theme()->resourcesUrl() +
"gdwtcore/Icons/edit.png",
"",
"Edit current node !");
31 pTbItem->setUrl(
"/Edit");
33 pTbItem = addToolbarItem(wApp->theme()->resourcesUrl() +
"gdwtcore/Icons/folder_add.png",
"",
"Create a new folder");
35 pTbItem = addToolbarItem(wApp->theme()->resourcesUrl() +
"gdwtcore/Icons/file_add.png",
"",
"Create a new file");
37 pTbItem = addToolbarItem(wApp->theme()->resourcesUrl() +
"gdwtcore/Icons/folder_delete.png",
"",
"Delete current node");
39 pTbItem = addToolbarItem(wApp->theme()->resourcesUrl() +
"gdwtcore/Icons/file_upload.png",
"",
"Upload a file");
40 pTbItem->setUrl(
"/FileUpload");
43 for (
int iModule = 0; iModule <
WsApp->WsModules().modules().size(); ++iModule) {
44 WsModule* curModule =
WsApp->WsModules().modules()[iModule]->module;
60 std::string str = pTbItem->url() + wApp->internalPath();
65 if(!pNode.get())
return;
67 if(!pNode.get()->isDirectory()){
68 int ret =
WsApp->wsUser()->isLocked(wApp->internalPath(), id);
70 WMessageBox::show(
"Warning",
"The file is currently locked by \"" +
id +
"\". Please try again later.", Ok);
81 Wt::WRegExpValidator* validator =
new Wt::WRegExpValidator(
"[a-zA-Z0-9._& ]{2,48}");
88 WLabel* label =
new Wt::WLabel(
" : Name of the new Folder ",
m_pDialog->contents());
93 WPushButton* cancel =
new Wt::WPushButton(
"Cancel",
m_pDialog->footer());
94 cancel->clicked().connect(
m_pDialog, &Wt::WDialog::reject);
102 Wt::WRegExpValidator* validator =
new Wt::WRegExpValidator(
"[a-zA-Z0-9._& ]{2,48}");
109 WLabel* label =
new Wt::WLabel(
" : Name of the new File ",
m_pDialog->contents());
114 WPushButton* cancel =
new Wt::WPushButton(
"Cancel",
m_pDialog->footer());
115 cancel->clicked().connect(
m_pDialog, &Wt::WDialog::reject);
143 if (
m_pDialog->result() == Wt::WDialog::Accepted ) {
144 std::string newName =
m_pLE_Name->text().toUTF8();
145 boost::algorithm::replace_all(newName,
"&",
"&");
146 std::string currentPath =
WsApp->WsModules().pathWithoutPrefix(wApp->internalPath());
147 boost::algorithm::replace_all(currentPath,
"&",
"&");
149 if (currentPath ==
"/")
155 if(!pNode.get())
return;
157 if(!pNode.get()->isDirectory())
158 currentPath = path(currentPath).parent_path().string();
160 std::string path2Create = currentPath +
"/" + newName;
172 if (
m_pDialog->result() == Wt::WDialog::Accepted ) {
173 std::string newName =
m_pLE_Name->text().toUTF8();
174 boost::algorithm::replace_all(newName,
"&",
"&");
175 boost::filesystem::path pathName(newName);
176 if ( pathName.extension().string() ==
"" ) newName +=
".fhtml";
177 std::string currentPath =
WsApp->WsModules().pathWithoutPrefix(wApp->internalPath());
178 boost::algorithm::replace_all(currentPath,
"&",
"&");
182 if(!pNode.get())
return;
184 if(!pNode.get()->isDirectory())
185 currentPath = path(currentPath).parent_path().string();
187 std::string path2Create = currentPath +
"/" + newName;
188 boost::algorithm::replace_all(path2Create,
"//",
"/");
202 std::string newPath =
WsApp->WsModules().pathWithoutPrefix(wApp->internalPath());
203 boost::algorithm::replace_all(newPath,
"&",
"&");
204 WMessageBox* pBox =
new WMessageBox(
"Confirm",
"Delete : " + newPath, Wt::Information, Wt::Yes | Wt::No);
211 int res = pBox->buttonResult();
213 if ( res != Wt::Yes )
return;
216 std::string newPath =
WsApp->WsModules().pathWithoutPrefix(wApp->internalPath());
217 boost::algorithm::replace_all(newPath,
"&",
"&");
219 wApp->setInternalPath(path(newPath).parent_path().
string(),
true);
226 std::string fullPath = sDocumentRoot + wApp->internalPath();
227 std::string currentPath = wApp->internalPath();
228 boost::algorithm::replace_all(fullPath,
"&",
"&");
232 if(!pNode.get())
return;
234 if(!pNode.get()->isDirectory())
235 currentPath = path(currentPath).parent_path().string();
244 if (sub == wApp->internalPath()) {
245 sub =
WsApp->WsModules().pathWithoutPrefix(sub);
247 boost::algorithm::replace_all(url, sub,
"");
249 std::string newPath = sub + url;
250 wApp->setInternalPath(newPath, refresh);
boost::shared_ptr< WsAbstractNode > NodePtr
WsContentButtonsBar(Wt::WContainerWidget *parent=0)
void doFileUpload(gdToolbarItem *pTbItem, Wt::WMouseEvent ev)
void doMBoxRespons(Wt::WMessageBox *pBox)
void doFileEnterPressed()
void doDeleteNode(gdToolbarItem *pTbItem, Wt::WMouseEvent ev)
Interface that provides differents methods for accessing the FsTree as well as other features...
Wt::WLineEdit * m_pLE_Name
void doFileNew(gdToolbarItem *pTbItem, Wt::WMouseEvent ev)
void doMenuEditPage(gdToolbarItem *pTbItem, Wt::WMouseEvent ev)
void doFolderNew(gdToolbarItem *pTbItem, Wt::WMouseEvent ev)
Wt::WPushButton * m_pButOk
virtual Wt::WWidget * createContentsMenuBar(Wt::WContainerWidget *parent=0) const =0
Create the functionalities.
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
int createNode(const string &path, NodeType type)
create a directory or File. If the node is a WsDirNode than it will be only accessible to the Admin a...
#define WsApp
Define a shortcut to the application instance.
void setNewInternalPath(std::string sub, std::string url, bool refresh=false)
void doFolderEnterPressed()
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
void doFolderNameChanged()
int deleteNode(const string &path)
delete a node. The user must be an Admin on editor to remove the node In case of a WsDirNode...