12 #include <boost/algorithm/string/replace.hpp>
13 #include <boost/filesystem.hpp>
18 #include <gdcore/gdCore.h>
29 void* hndl = dlopen(
"libwt.so", RTLD_NOW | RTLD_GLOBAL);
31 fprintf(stderr,
"cannot load libwt.so shared library! %s\n", dlerror());
42 : WContainerWidget(parent), m_nStartImage(0), m_nMaxImages(3), m_pTimerThumb(0), m_pTimerImage(0), m_nCurrentImage(0), m_pImages2(0), m_pImages2Text(0), m_cwThumb(0)
44 addStyleClass(
"WsImagesGallery");
53 WContainerWidget::load();
55 std::string sWithoutPrefix =
WsApp->WsModules().pathWithoutPrefix(
WsApp->internalPath());
57 if ( !startNode )
return;
58 NodePtr curNode = startNode.get()->eatPath(sWithoutPrefix);
59 std::string title = curNode.get()->getDisplayName(
true);
60 WText* pTitle =
new WText(title);
61 pTitle->addStyleClass(
"WsTitle");
63 int nMaxImages = asNumber(
option(
"maxImages"));
84 std::string imgPath = asString(
option(
"imagesPath")).toUTF8();
85 boost::algorithm::replace_all(imgPath,
"&",
"&");
86 if ( imgPath.size() < 1 )
return;
88 std::string sWithoutPrefix =
WsApp->WsModules().pathWithoutPrefix(
WsApp->internalPath());
89 boost::filesystem::directory_iterator end_itr;
91 for (boost::filesystem::directory_iterator itr_dir(pUser->
getRootPath() + imgPath); itr_dir != end_itr; ++itr_dir) {
92 if ( ! ( itr_dir->path().extension() ==
".jpeg"
93 || itr_dir->path().extension() ==
".jpg"
94 || itr_dir->path().extension() ==
".png"
96 if ( gdcore_isPathHidden(itr_dir->path()) )
continue;
97 if ( gdcore_isPathSymLink(itr_dir->path()) )
continue;
98 if ( boost::filesystem::is_directory(itr_dir->status()) )
continue;
99 m_vImages.push_back(itr_dir->path().string());
101 }
catch (boost::filesystem::filesystem_error& e) {
102 wApp->log(
"ERROR") <<
"WsImagesGallery::buildVector() bad image path =" << imgPath <<
" error = " << e.what();
109 for (
int curImg = 0; curImg <
m_vImages.size(); ++curImg) {
110 std::string urlSized =
m_vImages[curImg];
111 std::string sResize = asString(
option(
"resize")).toUTF8();
112 if ( sResize.size() < 1 ) sResize =
"100*75";
115 int status = gdImage_resizeImage(
m_vImages[curImg], rBlob, sResize);
118 wApp->log(
"notice") <<
"WsImagesGallery::buildThumbnails() : cannot resize to Blob = " << urlSized <<
" status = " << status <<
" url source " <<
m_vImages[curImg];
142 WContainerWidget* cw =
new WContainerWidget();
143 cw->addStyleClass(
"WsPlayer");
144 WPushButton* button =
new WPushButton(
"", cw);
145 button->setIcon(WLink(WLink::Url, wApp->theme()->resourcesUrl() +
"wittyshare/Icons/previous.png"));
147 button =
new WPushButton(
"", cw);
148 button->setIcon(WLink(WLink::Url, wApp->theme()->resourcesUrl() +
"wittyshare/Icons/play.png"));
150 button =
new WPushButton(
"", cw);
151 button->setIcon(WLink(WLink::Url, wApp->theme()->resourcesUrl() +
"wittyshare/Icons/next.png"));
160 bool bNewThumb =
false;
164 m_cwThumb->addStyleClass(
"WsThumbnails");
172 WApplication::instance()->log(
"notice") <<
"WsImagesGallery::renderThumb : OH OH anormal break !!!!";
175 WImage* pImage =
new WImage();
176 pImage->addStyleClass(
"thumbnails");
178 pImage->addStyleClass(
"WsSelected");
180 pImage->addStyleClass(
"WsClickable");
181 std::string imglnk =
"data:image/jpeg;base64," +
m_vThumbnails[countDir].base64();
182 pImage->setImageLink(imglnk);
195 boost::algorithm::replace_first(imgPath, wApp->docRoot(),
"");
248 std::string state = pButton->icon().url();
249 if ( state == wApp->theme()->resourcesUrl() +
"wittyshare/Icons/play.png") {
250 pButton->setIcon(WLink(WLink::Url, wApp->theme()->resourcesUrl() +
"wittyshare/Icons/pause.png"));
253 pButton->setIcon(WLink(WLink::Url, wApp->theme()->resourcesUrl() +
"wittyshare/Icons/play.png"));
307 return "WsModImagesGallery wittyShare module";
boost::shared_ptr< WsAbstractNode > NodePtr
void WsModImagesGalleryInit(void)
void build()
Build the vector.
WsEditorWidget * createEditor(Wt::WContainerWidget *parent=0) const
Create the contents for an editor (create a view of options).
std::vector< Magick::Blob > m_vThumbnails
void doThumbClicked(int nImageId)
void setMaxImages(int nMaxImages)
Set the number of images in the menu. If the number of images is more than this value a timer rotate ...
const std::vector< WsOption > & options() const
Get all options.
Interface that provides differents methods for accessing the FsTree as well as other features...
void doPlay(Wt::WPushButton *pButton)
void doPrevious(Wt::WPushButton *pButton)
void setOption(const std::string &attribute, boost::any value)
Set an options if previously set, update the value.
WsImagesGallery(Wt::WContainerWidget *parent=0)
CTor.
const boost::any & option(const std::string &attribute) const
Get an options value.
Wt::WText * m_pImages2Text
std::string description() const
Return the description of the module.
std::vector< std::string > m_vImages
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.
WContainerWidget * m_cwThumb
void setOptions(const std::vector< WsOption > &vOptions)
Set all options.
const std::string & text()
Return the text of the current image.
NodePtr getAccessRoot()
return the root node of the access tree starting from the root
Wt::WWidget * createAdmin(Wt::WContainerWidget *parent=0) const
Create the contents for an administrator.
WsModImagesGallery()
CTor.
Wt::WTimer * m_pTimerThumb
Wt::WWidget * createContentsMenuBar(Wt::WContainerWidget *parent=0) const
Create the functionalities.
Wt::WTimer * m_pTimerImage
Wt::WWidget * createContents(Wt::WContainerWidget *parent=0) const
Create the contents.
void doNext(Wt::WPushButton *pButton)