changed: rename cmslu to winix
changed: html templates are a part of winix now and the user can provide special html templates for its site added: locales added: html templates are using HtmlFilter now (locales) changed: now we have html templates for each language git-svn-id: svn://ttmath.org/publicrep/winix/trunk@560 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -5,12 +5,12 @@ compress.o: compress.h log.h
|
||||
config.o: config.h ../confparser/confparser.h log.h data.h dirs.h item.h
|
||||
config.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h
|
||||
config.o: functions.h function.h lastcontainer.h mounts.h mount.h error.h
|
||||
config.o: rebus.h plugin.h request.h requesttypes.h session.h done.h thread.h
|
||||
config.o: compress.h acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
||||
config.o: postmultiparser.h ticket.h pluginmsg.h misc.h
|
||||
config.o: rebus.h locale.h plugin.h request.h requesttypes.h session.h done.h
|
||||
config.o: thread.h compress.h acceptencodingparser.h acceptbaseparser.h
|
||||
config.o: htmlfilter.h postmultiparser.h ticket.h pluginmsg.h misc.h
|
||||
data.o: data.h dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
||||
data.o: log.h groups.h group.h functions.h function.h lastcontainer.h
|
||||
data.o: mounts.h mount.h error.h rebus.h
|
||||
data.o: mounts.h mount.h error.h rebus.h locale.h ../confparser/confparser.h
|
||||
db.o: db.h item.h user.h group.h thread.h error.h log.h dircontainer.h
|
||||
db.o: ugcontainer.h ticket.h misc.h
|
||||
db_itemcolumns.o: db.h item.h user.h group.h thread.h error.h log.h
|
||||
@@ -18,7 +18,8 @@ db_itemcolumns.o: dircontainer.h ugcontainer.h ticket.h
|
||||
dircontainer.o: dircontainer.h item.h log.h
|
||||
dirs.o: dirs.h item.h dircontainer.h error.h log.h db.h user.h group.h
|
||||
dirs.o: thread.h ugcontainer.h ticket.h data.h users.h groups.h functions.h
|
||||
dirs.o: function.h lastcontainer.h mounts.h mount.h rebus.h
|
||||
dirs.o: function.h lastcontainer.h mounts.h mount.h rebus.h locale.h
|
||||
dirs.o: ../confparser/confparser.h
|
||||
done.o: done.h
|
||||
error.o: error.h log.h
|
||||
function.o: function.h item.h
|
||||
@@ -26,45 +27,52 @@ functioncodeparser.o: functioncodeparser.h item.h function.h log.h
|
||||
functionparser.o: functionparser.h requesttypes.h log.h item.h error.h data.h
|
||||
functionparser.o: dirs.h dircontainer.h users.h user.h ugcontainer.h groups.h
|
||||
functionparser.o: group.h functions.h function.h lastcontainer.h mounts.h
|
||||
functionparser.o: mount.h rebus.h db.h thread.h ticket.h request.h session.h
|
||||
functionparser.o: done.h compress.h acceptencodingparser.h acceptbaseparser.h
|
||||
functionparser.o: htmlfilter.h postmultiparser.h
|
||||
functionparser.o: mount.h rebus.h locale.h ../confparser/confparser.h db.h
|
||||
functionparser.o: thread.h ticket.h request.h session.h done.h compress.h
|
||||
functionparser.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
||||
functionparser.o: postmultiparser.h
|
||||
functions.o: functions.h function.h item.h
|
||||
groups.o: groups.h group.h ugcontainer.h log.h db.h item.h user.h thread.h
|
||||
groups.o: error.h dircontainer.h ticket.h
|
||||
htmlfilter.o: htmlfilter.h
|
||||
httpsimpleparser.o: httpsimpleparser.h
|
||||
lastcontainer.o: lastcontainer.h log.h
|
||||
locale.o: locale.h ../confparser/confparser.h log.h
|
||||
log.o: log.h
|
||||
misc.o: misc.h item.h log.h data.h dirs.h dircontainer.h users.h user.h
|
||||
misc.o: ugcontainer.h groups.h group.h functions.h function.h lastcontainer.h
|
||||
misc.o: mounts.h mount.h error.h rebus.h
|
||||
misc.o: mounts.h mount.h error.h rebus.h locale.h ../confparser/confparser.h
|
||||
mount.o: mount.h
|
||||
mountparser.o: mountparser.h mount.h item.h error.h log.h data.h dirs.h
|
||||
mountparser.o: dircontainer.h users.h user.h ugcontainer.h groups.h group.h
|
||||
mountparser.o: functions.h function.h lastcontainer.h mounts.h rebus.h misc.h
|
||||
mountparser.o: functions.h function.h lastcontainer.h mounts.h rebus.h
|
||||
mountparser.o: locale.h ../confparser/confparser.h misc.h
|
||||
mounts.o: mounts.h mount.h error.h log.h data.h dirs.h item.h dircontainer.h
|
||||
mounts.o: users.h user.h ugcontainer.h groups.h group.h functions.h
|
||||
mounts.o: function.h lastcontainer.h rebus.h request.h requesttypes.h
|
||||
mounts.o: session.h done.h thread.h compress.h acceptencodingparser.h
|
||||
mounts.o: function.h lastcontainer.h rebus.h locale.h
|
||||
mounts.o: ../confparser/confparser.h request.h requesttypes.h session.h
|
||||
mounts.o: done.h thread.h compress.h acceptencodingparser.h
|
||||
mounts.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h
|
||||
mounts.o: mountparser.h db.h
|
||||
notify.o: log.h notify.h ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
notify.o: data.h dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
||||
notify.o: groups.h group.h functions.h function.h lastcontainer.h mounts.h
|
||||
notify.o: mount.h error.h rebus.h misc.h request.h requesttypes.h session.h
|
||||
notify.o: done.h thread.h compress.h acceptencodingparser.h
|
||||
notify.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h
|
||||
notify.o: ../core/locale.h ../confparser/confparser.h ../templates/misc.h
|
||||
notify.o: ../templates/localefilter.h data.h dirs.h item.h dircontainer.h
|
||||
notify.o: users.h user.h ugcontainer.h groups.h group.h functions.h
|
||||
notify.o: function.h lastcontainer.h mounts.h mount.h error.h rebus.h
|
||||
notify.o: locale.h misc.h request.h requesttypes.h session.h done.h thread.h
|
||||
notify.o: compress.h acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
||||
notify.o: postmultiparser.h ticket.h
|
||||
plugin.o: plugin.h request.h requesttypes.h session.h done.h item.h error.h
|
||||
plugin.o: log.h user.h rebus.h function.h thread.h compress.h
|
||||
plugin.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
||||
plugin.o: postmultiparser.h ticket.h data.h dirs.h dircontainer.h users.h
|
||||
plugin.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h mounts.h
|
||||
plugin.o: mount.h pluginmsg.h
|
||||
plugin.o: mount.h locale.h ../confparser/confparser.h pluginmsg.h
|
||||
postmultiparser.o: postmultiparser.h error.h log.h requesttypes.h data.h
|
||||
postmultiparser.o: dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
||||
postmultiparser.o: groups.h group.h functions.h function.h lastcontainer.h
|
||||
postmultiparser.o: mounts.h mount.h rebus.h
|
||||
postmultiparser.o: mounts.h mount.h rebus.h locale.h
|
||||
postmultiparser.o: ../confparser/confparser.h
|
||||
rebus.o: log.h rebus.h misc.h item.h
|
||||
request.o: request.h requesttypes.h session.h done.h item.h error.h log.h
|
||||
request.o: user.h rebus.h function.h thread.h compress.h
|
||||
@@ -72,34 +80,40 @@ request.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
|
||||
request.o: postmultiparser.h ticket.h getparser.h httpsimpleparser.h
|
||||
request.o: postparser.h cookieparser.h data.h dirs.h dircontainer.h users.h
|
||||
request.o: ugcontainer.h groups.h group.h functions.h lastcontainer.h
|
||||
request.o: mounts.h mount.h plugin.h pluginmsg.h misc.h db.h
|
||||
request.o: mounts.h mount.h locale.h ../confparser/confparser.h plugin.h
|
||||
request.o: pluginmsg.h misc.h db.h
|
||||
requestcontroller.o: requestcontroller.h ../content/content.h ../core/item.h
|
||||
requestcontroller.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
requestcontroller.o: ../core/thread.h ../core/ticket.h ../core/done.h
|
||||
requestcontroller.o: sessionmanager.h sessioncontainer.h session.h done.h
|
||||
requestcontroller.o: item.h error.h log.h user.h rebus.h functionparser.h
|
||||
requestcontroller.o: requesttypes.h data.h dirs.h dircontainer.h users.h
|
||||
requestcontroller.o: ugcontainer.h groups.h group.h functions.h function.h
|
||||
requestcontroller.o: lastcontainer.h mounts.h mount.h request.h thread.h
|
||||
requestcontroller.o: misc.h item.h ../core/thread.h ../core/ticket.h
|
||||
requestcontroller.o: ../core/done.h sessionmanager.h sessioncontainer.h
|
||||
requestcontroller.o: session.h done.h error.h log.h user.h rebus.h
|
||||
requestcontroller.o: functionparser.h requesttypes.h data.h dirs.h
|
||||
requestcontroller.o: dircontainer.h users.h ugcontainer.h groups.h group.h
|
||||
requestcontroller.o: functions.h function.h lastcontainer.h mounts.h mount.h
|
||||
requestcontroller.o: locale.h ../confparser/confparser.h request.h thread.h
|
||||
requestcontroller.o: compress.h acceptencodingparser.h acceptbaseparser.h
|
||||
requestcontroller.o: htmlfilter.h postmultiparser.h ticket.h postparser.h
|
||||
requestcontroller.o: httpsimpleparser.h cookieparser.h notify.h
|
||||
requestcontroller.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
requestcontroller.o: ../core/locale.h ../templates/misc.h
|
||||
requestcontroller.o: ../templates/localefilter.h
|
||||
session.o: session.h done.h item.h error.h log.h user.h rebus.h
|
||||
sessioncontainer.o: sessioncontainer.h session.h done.h item.h error.h log.h
|
||||
sessioncontainer.o: user.h rebus.h data.h dirs.h dircontainer.h users.h
|
||||
sessioncontainer.o: ugcontainer.h groups.h group.h functions.h function.h
|
||||
sessioncontainer.o: lastcontainer.h mounts.h mount.h
|
||||
sessioncontainer.o: lastcontainer.h mounts.h mount.h locale.h
|
||||
sessioncontainer.o: ../confparser/confparser.h
|
||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h done.h item.h
|
||||
sessionmanager.o: error.h log.h user.h rebus.h request.h requesttypes.h
|
||||
sessionmanager.o: function.h thread.h compress.h acceptencodingparser.h
|
||||
sessionmanager.o: acceptbaseparser.h htmlfilter.h postmultiparser.h ticket.h
|
||||
sessionmanager.o: data.h dirs.h dircontainer.h users.h ugcontainer.h groups.h
|
||||
sessionmanager.o: group.h functions.h lastcontainer.h mounts.h mount.h
|
||||
sessionmanager.o: sessionparser.h
|
||||
sessionmanager.o: locale.h ../confparser/confparser.h sessionparser.h
|
||||
sessionparser.o: sessionparser.h session.h done.h item.h error.h log.h user.h
|
||||
sessionparser.o: rebus.h sessioncontainer.h data.h dirs.h dircontainer.h
|
||||
sessionparser.o: users.h ugcontainer.h groups.h group.h functions.h
|
||||
sessionparser.o: function.h lastcontainer.h mounts.h mount.h
|
||||
sessionparser.o: function.h lastcontainer.h mounts.h mount.h locale.h
|
||||
sessionparser.o: ../confparser/confparser.h
|
||||
users.o: users.h user.h ugcontainer.h log.h db.h item.h group.h thread.h
|
||||
users.o: error.h dircontainer.h ticket.h
|
||||
|
@@ -1 +1 @@
|
||||
o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o error.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o
|
||||
o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o error.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
Config::Config()
|
||||
{
|
||||
default_str.clear();
|
||||
@@ -108,7 +109,8 @@ void Config::AssignValues()
|
||||
data.post_file_max = Int("post_file_max", 8388608); // 8 MB
|
||||
data.static_auth_dir = Text("static_auth_dir");
|
||||
|
||||
data.templates = Text("templates");
|
||||
data.templates_dir = Text("templates_dir");
|
||||
data.templates_dir_default = Text("templates_dir_default");
|
||||
data.http_session_id_name = Text("http_session_id_name");
|
||||
data.db_database = Text("db_database");
|
||||
data.db_user = Text("db_user");
|
||||
@@ -132,7 +134,7 @@ void Config::AssignValues()
|
||||
|
||||
data.session_max_idle = Int("session_max_idle", 10800); // 3h
|
||||
data.session_remember_max_idle = Int("session_remember_max_idle", 16070400); // 3 months
|
||||
data.session_file = Text("session_file");
|
||||
data.session_file = Text("session_file");
|
||||
|
||||
data.compression = Bool("compression", true);
|
||||
|
||||
@@ -140,6 +142,15 @@ void Config::AssignValues()
|
||||
data.plugin_file.push_back(p);
|
||||
|
||||
data.html_filter = Bool("html_filter", true);
|
||||
|
||||
data.locale_str = Text("locale", "en");
|
||||
data.locale_dir = Text("locale_dir");
|
||||
data.locale_dir_default = Text("locale_dir_default");
|
||||
|
||||
Locale::Lang lang = Locale::StrToLang(data.locale_str);
|
||||
|
||||
if( lang != Locale::lang_unknown )
|
||||
data.locale.SetLang(lang);
|
||||
}
|
||||
|
||||
|
||||
|
19
core/data.h
19
core/data.h
@@ -22,6 +22,7 @@
|
||||
#include "lastcontainer.h"
|
||||
#include "mounts.h"
|
||||
#include "rebus.h"
|
||||
#include "locale.h"
|
||||
|
||||
|
||||
class Data
|
||||
@@ -58,7 +59,8 @@ public:
|
||||
// fast cgi: group of the socket
|
||||
std::string fcgi_socket_group;
|
||||
|
||||
std::string templates;
|
||||
std::string templates_dir;
|
||||
std::string templates_dir_default; // templates from winix
|
||||
|
||||
std::string db_database;
|
||||
std::string db_user;
|
||||
@@ -109,6 +111,17 @@ public:
|
||||
// directory for static files (for fastcgi authorizer mode)
|
||||
std::string static_auth_dir;
|
||||
|
||||
// default locale: en pl
|
||||
std::string locale_str;
|
||||
|
||||
// directory with locale files
|
||||
std::string locale_dir;
|
||||
|
||||
// directory with default locale files (those from winix)
|
||||
std::string locale_dir_default;
|
||||
|
||||
|
||||
|
||||
// below variables are based on the other config variables
|
||||
|
||||
// base_url_prefix + base_server
|
||||
@@ -120,6 +133,10 @@ public:
|
||||
// base_url_static_auth_prefix + base_server
|
||||
std::string base_url_static_auth;
|
||||
|
||||
|
||||
Locale locale;
|
||||
|
||||
|
||||
// end config members
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
|
190
core/locale.cpp
Executable file
190
core/locale.cpp
Executable file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "locale.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
Locale::Locale()
|
||||
{
|
||||
loc_tab.resize(lang_unknown);
|
||||
default_lang = lang_en;
|
||||
current_lang = lang_en;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::AddLocale(Lang lang)
|
||||
{
|
||||
ConfParser::Table::iterator i = loc_parser.table.begin();
|
||||
|
||||
for( ; i != loc_parser.table.end() ; ++i)
|
||||
loc_tab[lang][i->first] = i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file)
|
||||
{
|
||||
if( static_cast<size_t>(lang) >= loc_tab.size() )
|
||||
{
|
||||
// ops, something wrong
|
||||
return;
|
||||
}
|
||||
|
||||
loc_tab[lang].clear();
|
||||
bool read = false;
|
||||
|
||||
if( dir_def )
|
||||
{
|
||||
file_name = dir_def;
|
||||
file_name += '/';
|
||||
file_name += file;
|
||||
|
||||
if( loc_parser.Parse(file_name.c_str()) == ConfParser::ok )
|
||||
{
|
||||
read = true;
|
||||
AddLocale(lang);
|
||||
log << log3 << "Locale: read locale from: " << file_name << logend;
|
||||
}
|
||||
}
|
||||
|
||||
if( dir )
|
||||
{
|
||||
file_name = dir;
|
||||
file_name += '/';
|
||||
file_name += file;
|
||||
|
||||
if( loc_parser.Parse(file_name.c_str()) == ConfParser::ok )
|
||||
{
|
||||
read = true;
|
||||
AddLocale(lang);
|
||||
log << log3 << "Locale: read locale from: " << file_name << logend;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( !read )
|
||||
log << log1 << "Locale: cant open file for locale: " << file << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::Read(const char * dir, const char * dir_def)
|
||||
{
|
||||
ReadFile(dir, dir_def, lang_pl, "pl");
|
||||
ReadFile(dir, dir_def, lang_en, "en");
|
||||
}
|
||||
|
||||
|
||||
void Locale::Read(const std::string & dir, const std::string & dir_def)
|
||||
{
|
||||
if( dir_def.empty() )
|
||||
Read(dir.c_str());
|
||||
else
|
||||
Read(dir.c_str(), dir_def.c_str());
|
||||
}
|
||||
|
||||
|
||||
void Locale::SetLang(Lang lang)
|
||||
{
|
||||
current_lang = lang;
|
||||
}
|
||||
|
||||
|
||||
Locale::Lang Locale::GetLang()
|
||||
{
|
||||
return current_lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Locale::SetLangDef(Lang lang)
|
||||
{
|
||||
default_lang = lang_en;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::string & Locale::Get(const std::string & key) const
|
||||
{
|
||||
if( static_cast<size_t>(current_lang) >= loc_tab.size() )
|
||||
{
|
||||
// ops, something wrong
|
||||
return empty;
|
||||
}
|
||||
|
||||
// looking in the current_lang
|
||||
ConfParser::Table::const_iterator i = loc_tab[current_lang].find(key);
|
||||
|
||||
if( i != loc_tab[current_lang].end() )
|
||||
return i->second;
|
||||
|
||||
if( current_lang == default_lang )
|
||||
return empty;
|
||||
|
||||
|
||||
if( static_cast<size_t>(default_lang) >= loc_tab.size() )
|
||||
{
|
||||
// ops, something wrong
|
||||
return empty;
|
||||
}
|
||||
|
||||
// looking in a default language
|
||||
i = loc_tab[default_lang].find(key);
|
||||
|
||||
if( i != loc_tab[default_lang].end() )
|
||||
return i->second;
|
||||
|
||||
// there is no such a key
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
Locale::Lang Locale::StrToLang(const std::string & str)
|
||||
{
|
||||
if( str == "en" )
|
||||
return lang_en;
|
||||
else
|
||||
if( str == "pl" )
|
||||
return lang_pl;
|
||||
|
||||
return lang_unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * Locale::LangToStr(Lang lang)
|
||||
{
|
||||
static char buffer[30];
|
||||
|
||||
switch(lang)
|
||||
{
|
||||
case lang_en:
|
||||
sprintf(buffer, "en");
|
||||
break;
|
||||
|
||||
case lang_pl:
|
||||
sprintf(buffer, "pl");
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf(buffer, "unknown");
|
||||
}
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t Locale::Size()
|
||||
{
|
||||
return loc_tab.size();
|
||||
}
|
66
core/locale.h
Executable file
66
core/locale.h
Executable file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfilecmslucorelocale
|
||||
#define headerfilecmslucorelocale
|
||||
|
||||
#include "../confparser/confparser.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class Locale
|
||||
{
|
||||
public:
|
||||
|
||||
enum Lang
|
||||
{
|
||||
lang_en = 0,
|
||||
lang_pl,
|
||||
|
||||
lang_unknown // should be last
|
||||
};
|
||||
|
||||
Locale();
|
||||
|
||||
void Read(const char * dir, const char * dir_def = 0);
|
||||
void Read(const std::string & dir, const std::string & dir_def);
|
||||
const std::string & Get(const std::string & key) const;
|
||||
|
||||
// default is english
|
||||
void SetLang(Lang lang);
|
||||
Lang GetLang();
|
||||
|
||||
// which language is used instead if there is no a key in an other language
|
||||
// default: lang_en
|
||||
void SetLangDef(Lang lang);
|
||||
|
||||
|
||||
static Lang StrToLang(const std::string & str);
|
||||
static const char * LangToStr(Lang lang);
|
||||
|
||||
size_t Size();
|
||||
|
||||
private:
|
||||
|
||||
void AddLocale(Lang lang);
|
||||
void ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file);
|
||||
|
||||
|
||||
std::vector<ConfParser::Table> loc_tab;
|
||||
ConfParser loc_parser;
|
||||
std::string file_name;
|
||||
std::string empty;
|
||||
Lang default_lang;
|
||||
Lang current_lang;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "data.h"
|
||||
@@ -538,3 +540,17 @@ bool ValidateEmail(const std::string & email)
|
||||
|
||||
return correct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsFile(const char * file)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
return (stat(file, &sb) == 0);
|
||||
}
|
||||
|
||||
bool IsFile(const std::string & file)
|
||||
{
|
||||
return IsFile(file.c_str());
|
||||
}
|
||||
|
@@ -61,4 +61,8 @@ bool EqualNoCase(const char * short_str, const char * long_str);
|
||||
|
||||
bool ValidateEmail(const std::string & email);
|
||||
|
||||
bool IsFile(const char * file);
|
||||
bool IsFile(const std::string & file);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -28,15 +28,15 @@ Notify * Notify::obj;
|
||||
|
||||
|
||||
/*
|
||||
methods for second thread
|
||||
methods for the second thread
|
||||
|
||||
second thread can reference to 'this' by using 'obj' pointer
|
||||
the thread can reference to 'this' by using 'obj' pointer
|
||||
*/
|
||||
|
||||
void * Notify::ThreadRoutine(void * arg)
|
||||
{
|
||||
obj = (Notify*)arg;
|
||||
obj->templates_notify.Read(obj->templates_dir);
|
||||
|
||||
|
||||
|
||||
while( true )
|
||||
@@ -70,7 +70,10 @@ void Notify::SendEmail(NotifyMsg & n)
|
||||
{
|
||||
TemplatesNotifyFunctions::notify_msg = &n;
|
||||
|
||||
obj->templates_notify.Generate();
|
||||
obj->Lock(); // templates can be reloaded from the first thread
|
||||
obj->templates_notify.Generate(n.lang);
|
||||
obj->Unlock();
|
||||
|
||||
SendEmail(n.email, obj->templates_notify.notify_str.str());
|
||||
}
|
||||
|
||||
@@ -91,7 +94,6 @@ void Notify::SendEmail(const std::string & email, const std::string & message)
|
||||
|
||||
if( !sendmail )
|
||||
{
|
||||
|
||||
nlog << "Notify: can't run sendmail" << logend;
|
||||
return;
|
||||
}
|
||||
@@ -133,11 +135,20 @@ Notify::~Notify()
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Notify::Init(const std::string & tdir)
|
||||
void Notify::ReadTemplates()
|
||||
{
|
||||
templates_dir = tdir;
|
||||
|
||||
Lock();
|
||||
templates_notify.Read();
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Notify::Init()
|
||||
{
|
||||
templates_notify.CreateFunctions();
|
||||
|
||||
|
||||
int t = pthread_create(&thread, 0, ThreadRoutine, (void*)this);
|
||||
|
||||
if( t != 0 )
|
||||
@@ -229,6 +240,7 @@ Users::Iterator i;
|
||||
if( sending )
|
||||
{
|
||||
n.email = i->email;
|
||||
n.lang = data.locale.GetLang(); // !! bedzie osobno dla kazdego uzytkownika
|
||||
notify_pool.insert(notify_pool.end(), n);
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,9 @@ public:
|
||||
Notify();
|
||||
~Notify();
|
||||
|
||||
bool Init(const std::string & tdir);
|
||||
void ReadTemplates();
|
||||
|
||||
bool Init();
|
||||
|
||||
/*
|
||||
this method addes an item to our special pool
|
||||
@@ -64,7 +66,6 @@ private:
|
||||
std::list<NotifyMsg> notify_pool;
|
||||
static Notify * obj;
|
||||
std::string command;
|
||||
std::string templates_dir;
|
||||
TemplatesNotify templates_notify;
|
||||
|
||||
};
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2009, Tomasz Sowa
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -108,7 +108,7 @@ bool RequestController::Init()
|
||||
data.groups.ReadGroups();
|
||||
data.functions.ReadFunctions();
|
||||
data.mounts.ReadMounts();
|
||||
|
||||
data.locale.Read(data.locale_dir, data.locale_dir_default); // call it before content.Init()
|
||||
data.rebus.Init();
|
||||
//
|
||||
|
||||
|
@@ -28,6 +28,8 @@
|
||||
class RequestController
|
||||
{
|
||||
Content content;
|
||||
|
||||
|
||||
SessionManager session_manager;
|
||||
|
||||
bool BaseUrlRedirect();
|
||||
|
Reference in New Issue
Block a user