12 #include <boost/filesystem/operations.hpp>
28 : WContainerWidget(parent)
30 addStyleClass(
"WsBanners");
35 WContainerWidget::load();
36 if ( Wt::asString(
option(
"useInternalPath")) ==
"true" ) {
45 std::string sPathWithoutPrefix =
WsApp->WsModules().pathWithoutPrefix(newPath);
47 boost::filesystem::path root = pUser->
getRootPath();
48 std::string sCurrent = root.string() + sPathWithoutPrefix;
50 std::string imgPath = Wt::asString(
option(
"imagesPath")).toUTF8();
51 boost::algorithm::replace_all(imgPath,
"&",
"&");
52 if ( imgPath.size() > 0 ) {
55 std::string s = root.string() + imgPath;
56 boost::replace_all(s, wApp->docRoot(),
"");
63 boost::replace_all(sCurrent,
"//",
"/");
64 boost::filesystem::path current(sCurrent);
66 if ( !boost::filesystem::is_directory(current) )
67 current = current.parent_path();
69 sCurrent = current.string() +
"/ws.res/images/WsBanners";
70 boost::replace_all(sCurrent,
"//",
"/");
71 boost::filesystem::path banners(sCurrent);
73 if ( boost::filesystem::is_directory(banners) ) {
74 boost::filesystem::directory_iterator end_itr;
75 for (boost::filesystem::directory_iterator itr_dir(banners); itr_dir != end_itr; ++itr_dir) {
76 if ( ( itr_dir->path().extension() ==
".jpeg"
77 || itr_dir->path().extension() ==
".jpg"
78 || itr_dir->path().extension() ==
".png"
80 string str_bann = banners.string();
81 boost::replace_all(str_bann,
"//",
"/");
82 boost::replace_all(str_bann,
WsApp->docRoot(),
"");
85 pImg->setOption(
"imagesPath", str_bann);
93 if (current == root)
break;
96 std::string noRoot = current.string();
97 boost::replace_all(noRoot, root.string(),
"");
98 NodePtr currentNode = startNode.get()->eatPath(noRoot);
100 if ( currentNode.get()->getProperties().get()->get(
"global",
"banners_up",
"true") ==
"false" )
break;
101 current = current.parent_path();
103 wApp->log(
"notice") <<
"WsBanners::doPathChanged() NO Image(s) found";
boost::shared_ptr< WsAbstractNode > NodePtr
void build()
Build the vector.
virtual void load()
Load the widget (traditional wt virtual function).
const std::vector< WsOption > & options() const
Get all options.
Interface that provides differents methods for accessing the FsTree as well as other features...
WsBanners(Wt::WContainerWidget *parent=0)
void setOption(const std::string &attribute, boost::any value)
Set an options if previously set, update the value.
const boost::any & option(const std::string &attribute) const
Get an options value.
const std::string getRootPath()
return the root path of the filesystem tree, example : /var/www/demo_site
#define WsApp
Define a shortcut to the application instance.
void setOptions(const std::vector< WsOption > &vOptions)
Set all options.
A class that render a menu.
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
void doPathChanged(std::string newPath)
a wittyShare class that render images randomly