12 #include <boost/algorithm/string/replace.hpp>
13 #include <boost/filesystem.hpp>
30 void* hndl = dlopen(
"libwt.so", RTLD_NOW | RTLD_GLOBAL);
32 fprintf(stderr,
"cannot load libwt.so shared library! %s\n", dlerror());
43 : WContainerWidget(parent), m_nStartImage(0), m_nMaxImages(3), m_pTimer(0)
45 addStyleClass(
"WsMenuImages");
54 int nMaxImages = asNumber(
option(
"maxImages"));
57 WContainerWidget::load();
74 std::string sWithoutPrefix =
WsApp->WsModules().pathWithoutPrefix(
WsApp->internalPath());
76 if ( !startNode.get() ) {
77 WApplication::instance()->log(
"ERROR") <<
"WsMenuImages::buildVector : startNode is NULL !";
80 NodePtr selNode = startNode.get()->eatPath(sWithoutPrefix);
81 if ( !selNode.get() ) {
82 WApplication::instance()->log(
"ERROR") <<
"WsMenuImages::buildVector : selNode is NULL !";
85 if ( selNode.get()->isRegularFile() ) {
86 selNode = selNode.get()->getParent();
87 if ( !selNode.get() ) {
88 WApplication::instance()->log(
"ERROR") <<
"WsMenuImages::buildVector : selected node parent is NULL !" << sWithoutPrefix;
92 std::vector<NodePtr> dirNode = startNode.get()->getDirectories();
93 for (std::vector<NodePtr>::iterator it = dirNode.begin(); it != dirNode.end(); ++it) {
97 std::string curDir = curNode.get()->getFullPath().string() + endPath;
98 if ( !boost::filesystem::exists(curDir) )
continue;
102 std::string curPathUrl = curNode.get()->getFullPath().string();
103 boost::algorithm::replace_first(curPathUrl, wApp->docRoot(),
"");
104 pImg->
setOption(
"imagesPath", std::string(curPathUrl + endPath));
106 if ( !pImg->
count() ) {
132 for (
int countDir =
m_nStartImage; countDir < maxImg; ++countDir) {
139 pImg->
setOption(
"useImageTitle", std::string(
"true"));
202 return "WsModMenuImages wittyShare module";
const std::string PathToImages
boost::shared_ptr< WsAbstractNode > NodePtr
void build()
Build the vector.
const std::vector< WsOption > & options() const
Get all options.
Interface that provides differents methods for accessing the FsTree as well as other features...
int count()
Return the number of images.
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.
#define WsApp
Define a shortcut to the application instance.
void setOptions(const std::vector< WsOption > &vOptions)
Set all options.
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
a wittyShare class that render images randomly