diff --git a/Makefile b/Makefile index c74191f..d74da9a 100755 --- a/Makefile +++ b/Makefile @@ -9,19 +9,19 @@ export CXXFLAGS export CXXFLAGSMAIN -all: cmslu +all: winix -cmslu: FORCE +winix: FORCE @cd core ; $(MAKE) -e @cd content ; $(MAKE) -e @cd confparser ; $(MAKE) -e @cd templates ; $(MAKE) -e @cd templatesnotify ; $(MAKE) -e @cd ../ezc/src ; $(MAKE) -e - $(CXX) -shared -o cmslu.so $(CXXFLAGS) core/*.o content/*.o templates/*.o templatesnotify/*.o confparser/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz + $(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o content/*.o templates/*.o templatesnotify/*.o confparser/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz @cd main ; $(MAKE) -e - # use the full path with cmslu.so - $(CXX) -o cmslu $(CXXFLAGSMAIN) main/*.o /home/tomek/roboczy/cmslu/cmslu.so + # use the full path with winix.so + $(CXX) -o winix $(CXXFLAGSMAIN) main/*.o /home/tomek/roboczy/winix/winix.so clean: @@ -32,8 +32,8 @@ clean: @cd templatesnotify ; $(MAKE) -e clean @cd ../ezc/src ; $(MAKE) -e clean @cd main ; $(MAKE) -e clean - rm -f cmslu.so - rm -f cmslu + rm -f winix.so + rm -f winix FORCE: @@ -50,7 +50,7 @@ depend: #install: all # mkdir -p bin -# rm -f bin/cmslu.so -# rm -f bin/cmslu -# cp cmslu.so bin/ -# cp cmslu bin/ +# rm -f bin/winix.so +# rm -f bin/winix +# cp winix.so bin/ +# cp winix bin/ diff --git a/confparser/confparser.cpp b/confparser/confparser.cpp index c5def8b..44758f5 100755 --- a/confparser/confparser.cpp +++ b/confparser/confparser.cpp @@ -19,13 +19,15 @@ ConfParser::ConfParser() ConfParser::Status ConfParser::Parse(const char * file_name) { + line = 1; + table.clear(); + + file.clear(); file.open( file_name ); if( !file ) return cant_open_file; - line = 1; - table.clear(); ReadChar(); status = ParseFile(); @@ -50,7 +52,8 @@ ConfParser::Status ConfParser::ParseFile() if( !ReadValue() ) return syntax_error; - table.insert( std::make_pair(variable, value) ); + //table.insert( std::make_pair(variable, value) ); + table[variable] = value; } if( lastc == commentary ) @@ -81,7 +84,8 @@ return false; bool ConfParser::IsValueSimpleChar(int c) { - if( c==-1 || c=='\n' || IsWhite(c) || c==commentary ) + //if( c==-1 || c=='\n' || IsWhite(c) || c==commentary ) + if( c==-1 || c=='\n' || c==commentary ) return false; return true; @@ -159,6 +163,7 @@ bool ConfParser::ReadValueSimple() ReadChar(); } + Trim(value); SkipWhite(); return true; @@ -202,7 +207,34 @@ void ConfParser::SkipLine() - +void ConfParser::Trim(std::string & s) +{ +std::string::size_type i; + + if( s.empty() ) + return; + + // looking for white characters at the end + for(i=s.size()-1 ; i>0 && IsWhite(s[i]) ; --i); + + if( i==0 && IsWhite(s[i]) ) + { + // the whole string has white characters + s.clear(); + return; + } + + // deleting white characters at the end + if( i != s.size() - 1 ) + s.erase(i+1, std::string::npos); + + // looking for white characters at the beginning + for(i=0 ; idone = Done::reloaded_templates; request.session->done_status = Error::ok; diff --git a/content/upload.cpp b/content/upload.cpp index 2724326..138b145 100755 --- a/content/upload.cpp +++ b/content/upload.cpp @@ -7,8 +7,8 @@ * */ -#include -#include +#include +#include #include #include "content.h" #include "../core/request.h" diff --git a/core/Makefile.dep b/core/Makefile.dep index 82f51e7..193331a 100755 --- a/core/Makefile.dep +++ b/core/Makefile.dep @@ -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 diff --git a/core/Makefile.o.dep b/core/Makefile.o.dep index 7727852..669d5c4 100755 --- a/core/Makefile.o.dep +++ b/core/Makefile.o.dep @@ -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 diff --git a/core/config.cpp b/core/config.cpp index e176d18..bd8ade3 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -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); } diff --git a/core/data.h b/core/data.h index 62bc0dd..3f4857f 100755 --- a/core/data.h +++ b/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 // ----------------------------------------------------------------- diff --git a/core/locale.cpp b/core/locale.cpp new file mode 100755 index 0000000..d6a3c6a --- /dev/null +++ b/core/locale.cpp @@ -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(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(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(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(); +} diff --git a/core/locale.h b/core/locale.h new file mode 100755 index 0000000..55cf488 --- /dev/null +++ b/core/locale.h @@ -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 +#include + + + +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 loc_tab; + ConfParser loc_parser; + std::string file_name; + std::string empty; + Lang default_lang; + Lang current_lang; +}; + + +#endif diff --git a/core/misc.cpp b/core/misc.cpp index 9da7709..9bce012 100755 --- a/core/misc.cpp +++ b/core/misc.cpp @@ -7,6 +7,8 @@ * */ +#include +#include #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()); +} diff --git a/core/misc.h b/core/misc.h index a020d0f..6686201 100755 --- a/core/misc.h +++ b/core/misc.h @@ -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 diff --git a/core/notify.cpp b/core/notify.cpp index 84c1fa6..2f5b28f 100755 --- a/core/notify.cpp +++ b/core/notify.cpp @@ -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); } } diff --git a/core/notify.h b/core/notify.h index fbed0d3..33dae41 100755 --- a/core/notify.h +++ b/core/notify.h @@ -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 notify_pool; static Notify * obj; std::string command; - std::string templates_dir; TemplatesNotify templates_notify; }; diff --git a/core/requestcontroller.cpp b/core/requestcontroller.cpp index 3f24c5d..ee41224 100755 --- a/core/requestcontroller.cpp +++ b/core/requestcontroller.cpp @@ -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(); // diff --git a/core/requestcontroller.h b/core/requestcontroller.h index 4c36435..2caf7a7 100755 --- a/core/requestcontroller.h +++ b/core/requestcontroller.h @@ -28,6 +28,8 @@ class RequestController { Content content; + + SessionManager session_manager; bool BaseUrlRedirect(); diff --git a/html/dir_last_info.html b/html/dir_last_info.html index 4ea17d2..5456e5b 100755 --- a/html/dir_last_info.html +++ b/html/dir_last_info.html @@ -1 +1 @@ -

Dodane przez: [dir_last_user], [dir_last_date_creation][if-no dir_last_dates_equal], ostatnio modyfikowany: [dir_last_date_modification][end]

+

{added_by}: [dir_last_user], [dir_last_date_creation][if-no dir_last_dates_equal], {last_modified}: [dir_last_date_modification][end]

diff --git a/html/err_404.html b/html/err_404.html index c0943ac..8f60406 100755 --- a/html/err_404.html +++ b/html/err_404.html @@ -1,3 +1,3 @@ -

Błąd 404

+

{error_404}

-

Przykro nam ale podanej strony nie ma w naszym serwisie.

+

{error_404_msg}

diff --git a/html/err_abuse.html b/html/err_abuse.html index a8e70d1..27f8657 100755 --- a/html/err_abuse.html +++ b/html/err_abuse.html @@ -1,8 +1,8 @@ [if-any done_is_error] [if-any done_status_incorrect_rebus] -

Proszę rozwiązać rebus!

+

{solve_rebus}

[else] [if-any done_status_spam] -

Jesteś podejrzany jako spamer,
nie możesz nic wysłać do czasu zalogowania się!

+

{suspected_spammer}

[end] [end] diff --git a/html/err_item_required.html b/html/err_item_required.html deleted file mode 100755 index 42416e2..0000000 --- a/html/err_item_required.html +++ /dev/null @@ -1,3 +0,0 @@ -

Item required

- -

This function can only be used with an item

diff --git a/html/err_others.html b/html/err_others.html index fc6899e..5208a3c 100755 --- a/html/err_others.html +++ b/html/err_others.html @@ -1,5 +1,5 @@ [if-one doc_is_error done_is_error] -

Przepraszamy ale wystąpiły problemy z wykonaniem tej operacji.

-

Kod błędu: [if-one doc_is_error]doc:[doc_status][end], [if-one done_is_error]done:[done_status][end]

+

{was_errors}

+

{error_code}: [if-one doc_is_error]doc:[doc_status][end], [if-one done_is_error]done:[done_status][end]

[end] diff --git a/html/err_per_denied.html b/html/err_per_denied.html index b5aca88..d03e0a1 100755 --- a/html/err_per_denied.html +++ b/html/err_per_denied.html @@ -1,3 +1,5 @@ -

Brak dostępu

+

{access_denied}

+ +

{access_denied_msg}

+ -

Przykro nam ale nie masz dostępu do tej części serwisu.

diff --git a/html/fun_cat.html b/html/fun_cat.html index d9ef4bd..781373b 100755 --- a/html/fun_cat.html +++ b/html/fun_cat.html @@ -1,8 +1,17 @@
[is mount_page_is "subject"] + [is mount_page_is "info"] -

[else]

[end][item_subject]

+

+ [else] +

[end] + + [item_subject] +

+ + [end] + [is mount_page_is "info"] [item_info] [end] @@ -12,7 +21,7 @@ [item_print_content] [else] [if-one item_static_auth_is_other] - Ściągnij plik: [item_subject] + {download}: [item_subject] [item_print_content] [else] [if-one item_static_auth_is_none] diff --git a/html/fun_createthread.html b/html/fun_createthread.html index 05c2734..71f4f7d 100755 --- a/html/fun_createthread.html +++ b/html/fun_createthread.html @@ -1,23 +1,25 @@ -

Załóż wątek

+

{create_thread_header}

[include "err_abuse.html"] +
-Wypełnij wszystkie pozycje formularza - -

Tytuł:

- - -[include "fun_emacs_post.html"] - -[if-no user_logged] -

Nick:

- - -

Rebus: Ile to jest [rebus_question]?

- -[end] - + {form_thread_legend} + +

{title}:

+ + + [include "fun_emacs_post.html"] + + [if-no user_logged] +

{nick}:

+ + +

{rebus_how_is_it} [rebus_question]?

+ + [end] + +
diff --git a/html/fun_createticket.html b/html/fun_createticket.html index 3dd9588..42c8df2 100755 --- a/html/fun_createticket.html +++ b/html/fun_createticket.html @@ -1,17 +1,20 @@ -[if-one ticket_is]

Edytuj zgłoszenie

[else]

Nowe zgłoszenie

[end] +[if-one ticket_is]

{edit_ticket_header}

[else]

{create_ticket_header}

[end] [include "err_abuse.html"] + + +
[if-one ticket_is] -Formularz edycji zgłoszenia. + {form_edit_ticket_legend} [else] -Formularz nowego zgłoszenia. + {form_create_ticket_legend} [end] -

Tytuł:

+

{title}:

@@ -19,7 +22,7 @@ [if-one ticket_type_tab_defined] [if-one ticket_type_tab] - + - + - + - + - + - + - + - + - + - + - + @@ -156,12 +159,14 @@ [if-no user_logged] -

Nick:

- - -

Rebus: Ile to jest [rebus_question]?

- +

{nick}:

+ + +

{rebus_how_is_it} [rebus_question]?

+ [end] - + + + diff --git a/html/fun_default.html b/html/fun_default.html index 0d42423..073c18e 100755 --- a/html/fun_default.html +++ b/html/fun_default.html @@ -1,25 +1,29 @@ -

Domyślna pozycja w katalogu

+

{default_header}

+ [if-any done_defaulted_dir done_is_error] -

Przykro nam ale wystąpiły błędy podczas zmiany domyślnej pozycji.
- -[if-any done_status_incorrect_dir] -

Podano nie istniejący katalog.

-[else] -[if-any done_status_no_item] -

Podano nie istniejąca pozycję.

-[else] -Kod błędu: [done_status]

-[end] -[end] +

{default_was_error}
+ + [if-any done_status_incorrect_dir] +

{default_error_no_dir}

+ [else] + [if-any done_status_no_item] +

default_error_no_file

+ [else] + {error_code}: [done_status]

+ [end] + [end] [end]
-Wypełnij wszystkie pozycje formularza -Url:
- - + {form_default_legend} + {url}:
+ +
+ + + diff --git a/html/fun_emacs.html b/html/fun_emacs.html index f0039bf..6c544da 100755 --- a/html/fun_emacs.html +++ b/html/fun_emacs.html @@ -1,25 +1,26 @@ -[if-one item_is]

Edytuj

[else]

Dodaj

[end] +[if-one item_is]

{edit}

[else]

{add}

[end] [include "err_abuse.html"] +
- Formularz edycji. + {form_emacs_legend} [if-one mount_type_is_cms] -

Tytuł:

- - -

Url:

- +

{title}:

+ + +

{url}:

+ [end] [if-one mount_type_is_thread] [is mount_thread_is "subject"] -

Tytuł:

+

{title}:

-

Url:

+

{url}:

[end] [end] @@ -27,13 +28,15 @@ [include "fun_emacs_post.html"] [if-no user_logged] -

Nick:

- - -

Rebus: Ile to jest [rebus_question]?

- +

{nick}:

+ + +

{rebus_how_is_it} [rebus_question]?

+ [end] - +
+ + diff --git a/html/fun_emacs_post.html b/html/fun_emacs_post.html index aac329c..d2c43e0 100755 --- a/html/fun_emacs_post.html +++ b/html/fun_emacs_post.html @@ -1,17 +1,20 @@ -[if-one mount_type_is_cms]

Zawartość:

[end] -[if-one mount_type_is_thread]

Post:

[end] -[if-one mount_type_is_ticket]

Opis:

[end] +[if-one mount_type_is_cms]

{form_emacs_content_cms}

[end] +[if-one mount_type_is_thread]

{form_emacs_content_thread}

[end] +[if-one mount_type_is_ticket]

{form_emacs_content_ticket}

[end] -

Rodzaj wiadomości:

+

{form_emacs_content_type}

+ + + diff --git a/html/fun_last.html b/html/fun_last.html index 7ac06e3..cf9dab2 100755 --- a/html/fun_last.html +++ b/html/fun_last.html @@ -1,14 +1,14 @@ -

Ostatnio logowani użytkownicy

+

{last_header}

[if-one last_tab] - -
Rodzaj zgłoszenia:{form_ticket_type}:
Rodzaj zgłoszenia:{form_ticket_type}:
Status:{form_ticket_status}:
Status:{form_ticket_status}:
Priorytet:{form_ticket_priority}:
Priorytet:{form_ticket_priority}:
Kategoria:{form_ticket_category}:
Kategoria:{form_ticket_category}:
Oczekiwany w:{form_ticket_expected}:
Oczekiwany w:{form_ticket_expected}:
Postęp prac (0-100):{form_ticket_progress}:
- -[for last_tab] - -[end] -
LoginAdres IPCzas zalogowaniaCzas wylogowania
[last_tab_name][last_tab_ip][last_tab_start][last_tab_end]
- + + + [for last_tab] + + [end] +
{last_table_login}{last_table_ip}{last_table_login_date}{last_table_logout_date}
[last_tab_name][last_tab_ip][last_tab_start][last_tab_end]
[else] -

Nie ma dostępnych żadnych informacji.

+

{last_none}

[end] + + diff --git a/html/fun_ls.html b/html/fun_ls.html index 7e29d3b..a7f9a48 100755 --- a/html/fun_ls.html +++ b/html/fun_ls.html @@ -1,34 +1,22 @@ -[if-one dir_can_write dir_can_remove] - -[end] - - [if-no item_is] - -[if-one dir_childs_tab] - - - + [if-one dir_childs_tab] + + [end] [end] -[end] [if-one item_tab] - - - + [end] diff --git a/html/fun_mkdir.html b/html/fun_mkdir.html index 6f225ef..b2f25ff 100755 --- a/html/fun_mkdir.html +++ b/html/fun_mkdir.html @@ -1,18 +1,21 @@ -

Stwórz katalog

+

{mkdir_header}

[if-any done_added_dir done_is_error] -

Przykro nam ale wystąpiły błędy podczas tworzenia tego katalogu.
-Kod błędu: [done_status]

+

{mkdir_was_error}
+ {error_code}: [done_status]

[end]
-Wypełnij wszystkie pozycje formularza -Tytuł:
- -Url:
- - + {mkdir_form_legend} + {title}
+ + {url}
+ +
+ + + diff --git a/html/fun_priv.html b/html/fun_priv.html index ba027b4..ae20e31 100755 --- a/html/fun_priv.html +++ b/html/fun_priv.html @@ -1,32 +1,40 @@ -

Zmień uprawnienia dostępu

+

{priv_header}

+ [if-any done_privileged_item done_is_error] -

Przykro nam ale wystąpiły błędy podczas zmiany uprawnień.
-Kod błędu: [done_status]

+

{priv_was_error}
+ {error_code}: [done_status]

[end] +
-Uprawnienia - - - - - - - - -
Użytkownik: - -
Grupa: - -
Uprawnienia:
- - + {priv_form_legend} + + + + + + + +
{user}: + +
{group}: + +
permissions:
+ +
+ + + diff --git a/html/fun_reload.html b/html/fun_reload.html index 1e5ea94..0e8a3b4 100755 --- a/html/fun_reload.html +++ b/html/fun_reload.html @@ -1,24 +1,21 @@ -

Reload

+

{reload_header}

+ [if-any done_reloaded_templates] + [if-any done_is_error] +

{reload_was_error}
+ {error_code}: [done_status]

+ [end] -[if-any done_is_error] -

Przykro nam ale wystąpiły błędy podczas ponownego wczytywania.
-Kod błędu: [done_status]

-[end] - -[if-no done_is_error] - -[if-any done_reloaded_templates] -

Szablony zostały pomyślnie wczytane.

-[end] - + [if-no done_is_error] + [if-any done_reloaded_templates] +

{templates_reloaded_successfully}

+ [end] + [end] [end] -[end] +

{reload_select}:

+{reload_templates} -

Wybierz pozycję:

-templates - diff --git a/html/fun_rm.html b/html/fun_rm.html index 69847cb..7a3977b 100755 --- a/html/fun_rm.html +++ b/html/fun_rm.html @@ -1,26 +1,30 @@ [if-one item_is] -

Czy napewno chcesz usunąć podaną pozycję?

-

-URL: [doc_base_url][dir][item_url]
-Krótki URL: [doc_base_url]/node/[item_id]
-Tytuł: [item_subject] -

- - +

{rm_file_header}

+ +

+ {url}: [doc_base_url][dir][item_url]
+ {title}: [item_subject] +

+ + [else] -

Czy napewno chcesz usunąć podany katalog?

-

-URL: [doc_base_url][dir] -

+

{rm_dir_header}

+ +

+ {url}: [doc_base_url][dir] +

+ + - [end] + + diff --git a/html/fun_run.html b/html/fun_run.html index 3dff9f4..f6f8ee3 100755 --- a/html/fun_run.html +++ b/html/fun_run.html @@ -1,13 +1,25 @@
-[is mount_page_is "subject"] -[is mount_page_is "info"]

[else]

[end][item_subject]

-[end] -[is mount_page_is "info"] -[item_info] -[end] -[item_run] + [is mount_page_is "subject"] + [is mount_page_is "info"] +

+ [else] +

+ [end] + + [item_subject] +

+ + [end] + + [is mount_page_is "info"] + [item_info] + [end] + + [item_run]
[include "item_options.html"] + + diff --git a/html/fun_thread.html b/html/fun_thread.html index c854f3e..5e9bed5 100755 --- a/html/fun_thread.html +++ b/html/fun_thread.html @@ -1,38 +1,47 @@ [if-one thread_can_create] - -[is mount_page_is "subject"][dir_last_subject][end] -[is mount_page_is "info"][dir_last_info][end] - - - -[if-one thread_tab] - - -[for thread_tab] -[end] -
Tytuł wątkuAutorRep.Ostatni post
[thread_tab_subject][thread_tab_author][thread_tab_answers][thread_tab_last_item_date_modification] ([thread_tab_last_item_user])
-[end] + [is mount_page_is "subject"][dir_last_subject][end] + [is mount_page_is "info"][dir_last_info][end] + + + + [if-one thread_tab] + + + [for thread_tab] + + + + + + [end] +
{thread_table_title}{thread_table_author}{thread_table_replies}{thread_table_last_post}
[thread_tab_subject][thread_tab_author][thread_tab_answers][thread_tab_last_item_date_modification] ([thread_tab_last_item_user])
+ [end] [end] + [if-one thread_is] - -[is mount_page_is "subject"][dir_last_subject][end] -[is mount_page_is "info"][dir_last_info][end] - -[if-one dir_can_use_emacs] - + [is mount_page_is "subject"][dir_last_subject][end] + [is mount_page_is "info"][dir_last_info][end] + + [if-one dir_can_use_emacs] + + [end] + + [for item_tab] +
+ [is mount_thread_is "subject"][item_tab_subject][end] + [is mount_thread_is "info"][item_tab_info][end] + [item_tab_print_content] +
+ [end] [end] -[for item_tab] -
-[is mount_thread_is "subject"][item_tab_subject][end] -[is mount_thread_is "info"][item_tab_info][end] -[item_tab_print_content] -
-[end] -[end] + + diff --git a/html/fun_ticket.html b/html/fun_ticket.html index 5c6d07b..856a41d 100755 --- a/html/fun_ticket.html +++ b/html/fun_ticket.html @@ -4,7 +4,7 @@ [if-one ticket_can_create] [end] @@ -12,11 +12,11 @@ [if-one ticket_tab] - - [if-any ticket_type_tab][end] - [if-any ticket_status_tab][end] - [if-any ticket_priority_tab][end] - [if-any ticket_expected_tab][end] + + [if-any ticket_type_tab][end] + [if-any ticket_status_tab][end] + [if-any ticket_priority_tab][end] + [if-any ticket_expected_tab][end] [for ticket_tab] @@ -33,21 +33,21 @@ [if-one ticket_is]
ZgłoszenieRodzajStatusPriorytetOczeki-
wany w
{ticket_table_name}{ticket_table_type}{ticket_table_status}{ticket_table_priority}{ticket_table_expected}
- [if-any ticket_type_tab][end] - [if-any ticket_status_tab][end] - [if-any ticket_priority_tab][end] - [if-any ticket_category_tab][end] - [if-any ticket_expected_tab][end] - + [if-any ticket_type_tab][end] + [if-any ticket_status_tab][end] + [if-any ticket_priority_tab][end] + [if-any ticket_category_tab][end] + [if-any ticket_expected_tab][end] +
Rodzaj zgłoszenia:[ticket_type]
Status:[ticket_status]
Piorytet:[ticket_priority]
Kategoria:[ticket_category]
Oczekiwany w:[ticket_expected]
Postęp prac:[ticket_progress]%
{ticket_info_type}:[ticket_type]
{ticket_info_status}:[ticket_status]
{ticket_info_priority}:[ticket_priority]
{ticket_info_category}:[ticket_category]
{ticket_info_expected}:[ticket_expected]
{ticket_info_progress}:[ticket_progress]%
[item_print_content]
[if-one dir_can_use_emacs] [end] @@ -59,3 +59,5 @@ [end] [end] + + diff --git a/html/fun_upload.html b/html/fun_upload.html index 1b553da..dd75c1e 100755 --- a/html/fun_upload.html +++ b/html/fun_upload.html @@ -1,43 +1,46 @@ -[if-one item_is]

Edytuj pozycję

[else]

Dodaj pozycję

[end] +[if-one item_is]

{edit}

[else]

{add}

[end] [include "err_abuse.html"]
-Edycja pozycji. - - - - -[if-one mount_type_is_cms] -

Tytuł:

- + {upload_form_legend} -

Url:

- -[end] - -[if-one mount_type_is_thread] - [is mount_thread_is "subject"] -

Tytuł:

+ + + + [if-one mount_type_is_cms] +

{title}:

-

Url:

+

{url}:

[end] -[end] - -

Post:

- - -[if-no user_logged] -

Nick:

- -

Rebus: Ile to jest [rebus_question]?

- -[end] + [if-one mount_type_is_thread] + [is mount_thread_is "subject"] +

{title}:

+ + +

{url}:

+ + [end] + [end] - + +

{upload_content}:

+ + + [if-no user_logged] +

{nick}:

+ + +

{rebus_how_is_it} [rebus_question]?

+ + [end] + + +
+ diff --git a/html/fun_who.html b/html/fun_who.html index fd98e25..06f20a7 100755 --- a/html/fun_who.html +++ b/html/fun_who.html @@ -1,15 +1,15 @@ +

{who_header}

-

Lista sesji

[if-any who_tab] - - -[for who_tab] - -[end] -
L.p.UżytkownikStartOstatnio aktywny
[who_tab_lp][who_tab_user][who_tab_time][who_tab_last_time]
+ + + [for who_tab] + + [end] +
{who_table_index}{user}{who_table_start}{who_table_last_active}
[who_tab_lp][who_tab_user][who_tab_time][who_tab_last_time]
[else] -

Nie ma żadnych dostępnych sesji.

+

{who_none}

[end] diff --git a/html/index.html b/html/index.html index 63f1121..cfac1d9 100755 --- a/html/index.html +++ b/html/index.html @@ -1,114 +1,72 @@ - + -Slimaczek.pl[doc_title] - - - - - + [doc_title] + + + + +
+ +
-

Quake 3

- - - -

Counter Strike

- - -

Forum

- - -[if-one is_group_tv] - -

Radio

- - -

Telewizja

- - -[end] -
+ +
- -[if-one done_loggedout] - -[end] - [content]
+ + + +
diff --git a/html/item_info.html b/html/item_info.html index 7b4381a..bc8b53a 100755 --- a/html/item_info.html +++ b/html/item_info.html @@ -1 +1 @@ -

Dodane przez: [item_user], [item_date_creation][if-no item_dates_equal], ostatnio modyfikowany: [item_date_modification][end]

+

{added_by}: [item_user], [item_date_creation][if-no item_dates_equal], {last_modified}: [item_date_modification][end]

diff --git a/html/item_modify_info.html b/html/item_modify_info.html index 7c0d9a9..e69de29 100755 --- a/html/item_modify_info.html +++ b/html/item_modify_info.html @@ -1,42 +0,0 @@ -[if-one done_added_dir] -[if-no done_is_error] -

Katalog został dodany:
-URL: [doc_base_url][item_old_dir][item_old_url]
-Krótki URL: [doc_base_url]/node/[item_old_id]

-[end] -[end] - -[if-one done_deleted_dir] -[if-no done_is_error] -

Katalog został usunięty:
-URL: [doc_base_url][dir_old] -

-[end] -[end] - -[if-one done_added_item] -[if-no done_is_error] -

Pozycja została dodana:
-URL: [doc_base_url][item_old_dir][item_old_url]
-Krótki URL: [doc_base_url]/node/[item_old_id]

-[end] -[end] - -[if-one done_edited_item] -[if-no done_is_error] -

Pozycja została zmodyfikowana:
-URL: [doc_base_url][item_old_dir][item_old_url]
-Krótki URL: [doc_base_url]/node/[item_old_id]

-[end] -[end] - -[if-one done_deleted_item] -[if-one done_is_error] -

Nie udało się skasować poniższej pozycji, możliwe że link jest nie prawidłowy:
-[else] -

Skasowano następującą pozycję:
-Tytuł: [item_old_subject]
-URL: [doc_base_url][item_old_dir][item_old_url]
-Krótki URL: [doc_base_url]/node/[item_old_id]

-[end] -[end] diff --git a/html/item_options.html b/html/item_options.html index 1c685e1..83a775e 100755 --- a/html/item_options.html +++ b/html/item_options.html @@ -1,12 +1,12 @@ [if-one dir_can_write item_can_write]
-

Dostępne opcje administracyjne:

+

{admin_options}:

[end] diff --git a/html/item_tab_info.html b/html/item_tab_info.html index 074ff75..3201b72 100755 --- a/html/item_tab_info.html +++ b/html/item_tab_info.html @@ -1 +1 @@ -

Dodane przez: [item_tab_user], [item_tab_date_creation][if-no item_tab_dates_equal], ostatnio modyfikowany: [item_tab_date_modification][end]

+

{added_by}: [item_tab_user], [item_tab_date_creation][if-no item_tab_dates_equal], {last_modified}: [item_tab_date_modification][end]

diff --git a/html/notify_email.txt b/html/notify_email.txt index af6a371..455fd53 100755 --- a/html/notify_email.txt +++ b/html/notify_email.txt @@ -1,52 +1,46 @@ -Subject: [if-one notify_item_added]Nowości[else]Zmiany[end] -From: Ślimaczkowe powiadomienia +Subject: [if-one notify_item_added]{notify_new}[else]{notify_change}[end] +From: {notify_from} To: [notify_to] -Content-Type: text/plain; charset="ISO-8859-2" +Content-Type: {notify_content_type} -Witamy +{notify_header} -Chcielibyśmy powiadomić że właśnie[if-one notify_mount_type_is_thread] +{notify_msg1}[if-one notify_mount_type_is_thread] -[if-one notify_dir_added] ktoś rozpoczął nowy wątek: +[if-one notify_dir_added] {notify_msg2} [notify_doc_base_url][notify_item_dir] [else] -[if-one notify_item_added] ktoś odpowiedział w wątku: +[if-one notify_item_added] {notify_msg3} [notify_doc_base_url][notify_item_dir] [end] [end] -[if-one notify_item_edited] ktoś zmienił swoją odpowiedź w wątku: +[if-one notify_item_edited] {notify_msg4} [notify_doc_base_url][notify_item_dir] [end] -[if-one notify_item_deleted] czyjaś odpowiedź została skasowana z wątku: +[if-one notify_item_deleted] {notify_msg5} [notify_doc_base_url][notify_item_dir] [end] [else] [if-one notify_mount_type_is_cms] -[if-one notify_item_added] pojawiła się nowa pozycja do poczytania: +[if-one notify_item_added] {notify_msg6} [notify_item_link] [end] -[if-one notify_item_edited] zmieniono coś na: +[if-one notify_item_edited] {notify_msg7} [notify_item_link] [end] -[if-one notify_item_deleted] skasowano następującą pozycję: +[if-one notify_item_deleted] {notify_msg8} [notify_item_link] [end] [end] [end] -Życzymy miłego dnia i zapraszamy do lektury. +{notify_msg9} - - --- -http://www.slimaczek.pl -Ta wiadomość została wysłana automatycznie - prosimy na nią nie odpowiadać. -Jeśli nie chcesz dostawać więcej takich wiadomości możesz je wyłączyć -w swoim panelu użytkownika. +{notify_footer} diff --git a/locale/en b/locale/en new file mode 100755 index 0000000..79c68a6 --- /dev/null +++ b/locale/en @@ -0,0 +1,192 @@ +language = en +charset = iso-8859-1 + +logged_as = logged as +logout = logout + +form_login_legend = Loging + +remember_me = Remember me + +home_page = Home page + + +button_login = Login + + + +added_by = Added by +last_modified = Last modified + +error_404 = Error 404 +error_404_msg = We are sory but there is no such a page in our service. + + +solve_rebus = Solve the rebus please! +suspected_spammer = You are suspected to be a spammer,
you cannot send anything without logging first. + + +was_errors = We are sory but there were some problems with the operation. +error_code = Error code + +access_denied = Permission denied +access_denied_msg = We are sory but you don't have access to the page. + +download = download + + +create_thread_header = Create thread +form_thread_legend = Thread form +button_thread_submit = Create thread + +url = Url +short_url = Short url +title = Title +nick = Nick +change = Change +edit = Edit +add = Add +user = User +group = Group +permissions = Permissions +yes = Yes +no = No + +rebus_how_is_it = Rebus: How is it + +edit_ticket_header = Edit ticket +create_ticket_header = Create a new ticket + +form_edit_ticket_legend = Edit ticket form. +form_create_ticket_legend = Ticket form. + + +form_ticket_type = Ticket type +form_ticket_status = Status +form_ticket_priority = Priority +form_ticket_category = Category +form_ticket_expected = Expected in +form_ticket_progress = Progress (0-100) + +form_ticket_create_submit = Create a new ticket +form_ticket_edit_submit = Edit a ticket + +default_header = Default item in a directory +default_was_error = We are sory but there was an error during changing the default item. +default_error_no_dir = There is no such a directory. +default_error_no_file = There is no such a file. + +form_default_legend = Default item form + +form_emacs_legend = Edit form + +form_emacs_content_cms = Content +form_emacs_content_thread = Post +form_emacs_content_ticket = Info + +form_emacs_content_type = Message type + +form_emacs_content_type_text = text +form_emacs_content_type_formatted_text = formatted text +form_emacs_content_type_html = html +form_emacs_content_type_bbcode = bbcode +form_emacs_content_type_raw = raw + + +last_header = Last logged users +last_table_login = Login +last_table_ip = IP +last_table_login_date = Login time +last_table_logout_date = Logout time +last_none = There is no anything information. + +mkdir_header = Make directory +mkdir_was_error = We are sorry but there were errors during creating the directory +mkdir_form_legend = Make directory form + +priv_header = Permissions +priv_was_error = We are sorry but there were errors while changing permissions. +priv_form_legend = Permissions + +reload_header = Reload +reload_was_error = We are sorry but there were errors while reloading. +templates_reloaded_successfully = Templates reloaded successfully. +reload_select = What to reload: +reload_templates = templates + + +rm_file_header = Are you sure you want to delete the file? +rm_dir_header = Are you sure you want to delete the directory? + +thread_create_new = Create a new thread +thread_table_title = Thread title +thread_table_author = Author +thread_table_replies = Rep. +thread_table_last_post = Last post +thread_reply_in_this_thread = Reply in this thread + +ticket_create_new = Create a new ticket +ticket_table_name = Ticket +ticket_table_type = Type +ticket_table_status = Status +ticket_table_priority = Priority +ticket_table_expected = Expected in + +ticket_info_type = Type +ticket_info_status = Status +ticket_info_priority = Priority +ticket_info_category = Category +ticket_info_expected = Expected in +ticket_info_progress = Progress +ticket_reply_in_this_thread = Replay in this thread + +upload_form_legend = Upload form +upload_content = File description + +who_header = Sessions +who_table_index = Ind. +who_table_start = Start +who_table_last_active = Last active +who_none = There is no any sessions. + +admin_options = Available administrative options. +admin_mkdir = Add directory +admin_emacs_add = Add file +admin_emacs_edit = Edit file +admin_rm = Remove file + + + + + +# notifications +notify_new = News +notify_change = Changes +notify_from = ttmath.org notifications +notify_content_type = text/plain; charset="ISO-8859-1" +notify_header = Welcome +notify_msg1 = We would like to inform you that +notify_msg2 = someone started a new thread: +notify_msg3 = someone replayed in a thread: +notify_msg4 = someone has changed its post: +notify_msg5 = a post has been deleted from a thread: +notify_msg6 = a new page has been added: +notify_msg7 = a page has been modified: +notify_msg8 = a page has been deleted: +notify_msg9 = We invite you to read.\nHave a good day. Bye. +notify_footer = \n\n-- \nhttp://www.ttmath.org\nThis message has been sent automatically - do not answer please.\nIf you do not want to receive such messages you can switch them off\nin your user control panel. + + + + + + + + + + + + + + + diff --git a/locale/pl b/locale/pl new file mode 100755 index 0000000..f03065c --- /dev/null +++ b/locale/pl @@ -0,0 +1,181 @@ +language = pl +charset = iso-8859-2 + +logged_as = zalogowany jako + +logout = wyloguj + +form_login_legend = Logowanie + +remember_me = Zapamiętaj mnie + +home_page = Strona główna + + +button_login = Loguj + + + +added_by = Dodane przez +last_modified = ostatnio modyfikowany + +error_404 = Błąd 404 +error_404_msg = Przykro nam ale podanej strony nie ma w naszym serwisie. + + +solve_rebus = Proszę rozwiązać rebus! +suspected_spammer = Jesteś podejrzany jako spamer,
nie możesz nic wysłać do czasu zalogowania się! + +was_errors = Przepraszamy ale wystąpiły problemy z wykonaniem tej operacji. +error_code = Kod błędu + +access_denied = Brak dostępu +access_denied_msg = Przykro nam ale nie masz dostępu do tej części serwisu. + +download = Ściągnij plik + + +create_thread_header = Załóż wątek +form_thread_legend = Wypełnij wszystkie pozycje formularza +button_thread_submit = Załóż wątek + +url = Url +short_url = Krótki url +title = Tytuł +nick = Nick +change = Zmień +edit = Edytuj +add = Dodaj +user = Użytkownik +group = Grupa +permissions = Uprawnienia +yes = Tak +no = Nie + +rebus_how_is_it = Rebus: Ile to jest + +edit_ticket_header = Edytuj zgłoszenie +create_ticket_header = Nowe zgłoszenie + +form_edit_ticket_legend = Formularz edycji zgłoszenia. +form_create_ticket_legend = Formularz nowego zgłoszenia. + + +form_ticket_type = Rodzaj zgłoszenia +form_ticket_status = Status +form_ticket_priority = Priorytet +form_ticket_category = Kategoria +form_ticket_expected = Oczekiwany w +form_ticket_progress = Postęp prac (0-100) + +form_ticket_create_submit = Załóż zgłoszenie +form_ticket_edit_submit = Edytuj zgłoszenie + +default_header = Domyślna pozycja w katalogu +default_was_error = Przykro nam ale wystąpiły błędy podczas zmiany domyślnej pozycji. +default_error_no_dir = Podano nie istniejący katalog. +default_error_no_file = Podano nie istniejący post. + +form_default_legend = Formularz zmiany pozycji domyślnej + +form_emacs_legend = Formularz edycji. + +form_emacs_content_cms = Zawartość: +form_emacs_content_thread = Post: +form_emacs_content_ticket = Opis: + +form_emacs_content_type = Rodzaj wiadomości: + +form_emacs_content_type_text = text +form_emacs_content_type_formatted_text = sformatowany text +form_emacs_content_type_html = html +form_emacs_content_type_bbcode = bbcode +form_emacs_content_type_raw = surowa postać + + +last_header = Ostatnio logowani użytkownicy +last_table_login = Login +last_table_ip = Adres IP +last_table_login_date = Czas zalogowania +last_table_logout_date = Czas wylogowania +last_none = Nie ma dostępnych żadnych informacji. + +mkdir_header = Stwórz katalog +mkdir_was_error = Przykro nam ale wystąpiły błędy podczas tworzenia tego katalogu. +mkdir_form_legend = Wypełnij wszystkie pozycje formularza + +priv_header = Zmień uprawnienia dostępu +priv_was_error = Przykro nam ale wystąpiły błędy podczas zmiany uprawnień. +priv_form_legend = Uprawnienia + +reload_header = Przeładuj +reload_was_error = Przykro nam ale wystąpiły błędy podczas ponownego wczytywania. +templates_reloaded_successfully = Szablony zostały pomyślnie wczytane. +reload_select = Wybierz pozycję +reload_templates = templates + + +rm_file_header = Czy napewno chcesz usunąć podaną pozycję? +rm_dir_header = Czy napewno chcesz usunąć podany katalog? + +thread_create_new = Załóż nowy wątek +thread_table_title = Tytuł wątku +thread_table_author = Autor +thread_table_replies = Odp. +thread_table_last_post = Ostatni post +thread_reply_in_this_thread = Odpowiedz w tym wątku + +ticket_create_new = Załóż nowe zgłoszenie +ticket_table_name = Zgłoszenie +ticket_table_type = Rodzaj +ticket_table_status = Status +ticket_table_priority = Priorytet +ticket_table_expected = Oczeki-
wany w + +ticket_info_type = Rodzaj zgłoszenia +ticket_info_status = Status +ticket_info_priority = Piorytet +ticket_info_category = Kategoria +ticket_info_expected = Oczekiwany w +ticket_info_progress = Postęp prac +ticket_reply_in_this_thread = Odpowiedz w tym wątku + +upload_form_legend = Formularz do wysłania pliku +upload_content = Opis pliku + +who_header = Lista sesji +who_table_index = L.p. +who_table_start = Start +who_table_last_active = Ostatnio aktywny +who_none = Nie ma żadnych dostępnych sesji. + +admin_options = Dostępne opcje administracyjne +admin_mkdir = Dodaj katalog +admin_emacs_add = Dodaj pozycję +admin_emacs_edit = Edytuj pozycję +admin_rm = Usuń pozycję + + + + +# notifications +notify_new = Coœ nowego +notify_change = Zmiany +notify_from = Ślimaczkowe powiadomienia +notify_content_type = text/plain; charset="ISO-8859-2" +notify_header = Witamy +notify_msg1 = Chcielibyśmy powiadomić że właśnie +notify_msg2 = ktoś rozpoczął nowy wątek: +notify_msg3 = ktoś odpowiedział w wątku: +notify_msg4 = ktoś zmienił swoją odpowiedź w wątku: +notify_msg5 = czyjaś odpowiedź została skasowana z wątku: +notify_msg6 = pojawiła się nowa pozycja do poczytania: +notify_msg7 = zmieniono coś na: +notify_msg8 = skasowano następującą pozycję: +notify_msg9 = Życzymy miłego dnia i zapraszamy do lektury. +notify_footer = \n\n-- \nhttp://www.slimaczek.pl\nTa wiadomość została wysłana automatycznie - prosimy na nią nie odpowiadać.\nJeśli nie chcesz dostawać więcej takich wiadomości możesz je wyłączyć\nw swoim panelu użytkownika. + + + + + diff --git a/main/Makefile.dep b/main/Makefile.dep index 02fb16d..2457540 100755 --- a/main/Makefile.dep +++ b/main/Makefile.dep @@ -2,18 +2,20 @@ main.o: ../core/requestcontroller.h ../content/content.h ../core/item.h main.o: ../templates/templates.h ../templates/patterncacher.h -main.o: ../core/thread.h ../core/ticket.h ../core/done.h -main.o: ../core/sessionmanager.h ../core/sessioncontainer.h ../core/session.h -main.o: ../core/done.h ../core/item.h ../core/error.h ../core/log.h -main.o: ../core/user.h ../core/rebus.h ../core/functionparser.h +main.o: ../templates/misc.h ../templates/localefilter.h ../core/locale.h +main.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h +main.o: ../core/done.h ../core/sessionmanager.h ../core/sessioncontainer.h +main.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h +main.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/functionparser.h main.o: ../core/requesttypes.h ../core/data.h ../core/dirs.h main.o: ../core/dircontainer.h ../core/users.h ../core/ugcontainer.h main.o: ../core/groups.h ../core/group.h ../core/functions.h main.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -main.o: ../core/mount.h ../core/log.h ../core/request.h ../core/thread.h -main.o: ../core/compress.h ../core/acceptencodingparser.h +main.o: ../core/mount.h ../core/locale.h ../core/log.h ../core/request.h +main.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h main.o: ../core/acceptbaseparser.h ../core/htmlfilter.h main.o: ../core/postmultiparser.h ../core/ticket.h ../core/db.h -main.o: ../core/config.h ../confparser/confparser.h ../core/notify.h -main.o: ../templatesnotify/templatesnotify.h ../core/mount.h ../core/plugin.h -main.o: ../core/request.h ../core/data.h ../core/pluginmsg.h +main.o: ../core/config.h ../core/notify.h +main.o: ../templatesnotify/templatesnotify.h ../core/mount.h +main.o: ../templates/misc.h ../core/plugin.h ../core/request.h ../core/data.h +main.o: ../core/pluginmsg.h diff --git a/main/main.cpp b/main/main.cpp index 552d3c7..8d15480 100755 --- a/main/main.cpp +++ b/main/main.cpp @@ -35,6 +35,7 @@ Notify notify; Plugin plugin; + void signal_term(int) { req_controller.SaveSessions(); @@ -62,7 +63,6 @@ void print_syntax() - int main(int argv, char ** argc) { std::srand(std::time(0)); @@ -74,8 +74,6 @@ int main(int argv, char ** argc) } data.config_file = argc[1]; - - if( !config.ReadConfig(true) ) /* errors to stdout */ return 2; @@ -107,9 +105,12 @@ int main(int argv, char ** argc) if( !req_controller.Init() ) return 1; - if( !notify.Init(data.templates) ) + // !! teraz mamy dwa katalogi z templetami + if( !notify.Init() ) return 2; + notify.ReadTemplates(); + signal(SIGTERM, signal_term); signal(SIGINT, signal_term); signal(SIGHUP, signal_hup); diff --git a/templates/Makefile.dep b/templates/Makefile.dep index febabe0..fb44e2e 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -1,6 +1,7 @@ # DO NOT DELETE -dir.o: templates.h patterncacher.h ../core/item.h ../core/request.h +dir.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +dir.o: ../core/locale.h ../confparser/confparser.h ../core/request.h dir.o: ../core/requesttypes.h ../core/session.h ../core/done.h ../core/item.h dir.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h dir.o: ../core/function.h ../core/thread.h ../core/compress.h @@ -9,63 +10,80 @@ dir.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h dir.o: ../core/data.h ../core/dirs.h ../core/dircontainer.h ../core/users.h dir.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h dir.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -dir.o: ../core/mount.h ../core/db.h ../core/log.h ../core/misc.h -doc.o: templates.h patterncacher.h ../core/item.h ../core/data.h +dir.o: ../core/mount.h ../core/locale.h ../core/db.h ../core/log.h +dir.o: ../core/misc.h +doc.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +doc.o: ../core/locale.h ../confparser/confparser.h ../core/data.h doc.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h doc.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h doc.o: ../core/group.h ../core/functions.h ../core/function.h doc.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -doc.o: ../core/error.h ../core/rebus.h ../core/request.h +doc.o: ../core/error.h ../core/rebus.h ../core/locale.h ../core/request.h doc.o: ../core/requesttypes.h ../core/session.h ../core/done.h doc.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h doc.o: ../core/acceptbaseparser.h ../core/htmlfilter.h doc.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -done.o: templates.h patterncacher.h ../core/item.h ../core/request.h +done.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +done.o: ../core/locale.h ../confparser/confparser.h ../core/request.h done.o: ../core/requesttypes.h ../core/session.h ../core/done.h done.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h done.o: ../core/rebus.h ../core/function.h ../core/thread.h done.o: ../core/compress.h ../core/acceptencodingparser.h done.o: ../core/acceptbaseparser.h ../core/htmlfilter.h done.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -item.o: templates.h patterncacher.h ../core/item.h ../core/data.h +item.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +item.o: ../core/locale.h ../confparser/confparser.h ../core/data.h item.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h item.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h item.o: ../core/group.h ../core/functions.h ../core/function.h item.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -item.o: ../core/error.h ../core/rebus.h ../core/request.h +item.o: ../core/error.h ../core/rebus.h ../core/locale.h ../core/request.h item.o: ../core/requesttypes.h ../core/session.h ../core/done.h item.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h item.o: ../core/acceptbaseparser.h ../core/htmlfilter.h item.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -last.o: templates.h patterncacher.h ../core/item.h ../core/lastcontainer.h +last.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +last.o: ../core/locale.h ../confparser/confparser.h ../core/lastcontainer.h last.o: ../core/data.h ../core/dirs.h ../core/item.h ../core/dircontainer.h last.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h last.o: ../core/groups.h ../core/group.h ../core/functions.h last.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -last.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/request.h -last.o: ../core/requesttypes.h ../core/session.h ../core/done.h -last.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -last.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -last.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -mount.o: templates.h patterncacher.h ../core/item.h ../core/data.h +last.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/locale.h +last.o: ../core/request.h ../core/requesttypes.h ../core/session.h +last.o: ../core/done.h ../core/thread.h ../core/compress.h +last.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +last.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h +last.o: ../core/misc.h +localefilter.o: localefilter.h ../core/locale.h ../confparser/confparser.h +localefilter.o: ../core/misc.h ../core/item.h +misc.o: ../core/data.h ../core/dirs.h ../core/item.h ../core/dircontainer.h +misc.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h +misc.o: ../core/groups.h ../core/group.h ../core/functions.h +misc.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h +misc.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/locale.h +misc.o: ../core/misc.h misc.h localefilter.h ../core/locale.h +misc.o: ../confparser/confparser.h +mount.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +mount.o: ../core/locale.h ../confparser/confparser.h ../core/data.h mount.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h mount.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h mount.o: ../core/group.h ../core/functions.h ../core/function.h mount.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -mount.o: ../core/error.h ../core/rebus.h +mount.o: ../core/error.h ../core/rebus.h ../core/locale.h patterncacher.o: patterncacher.h ../core/item.h ../core/data.h ../core/dirs.h patterncacher.o: ../core/item.h ../core/dircontainer.h ../core/users.h patterncacher.o: ../core/user.h ../core/ugcontainer.h ../core/log.h patterncacher.o: ../core/groups.h ../core/group.h ../core/functions.h patterncacher.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h patterncacher.o: ../core/mount.h ../core/error.h ../core/rebus.h -patterncacher.o: ../core/log.h -priv.o: templates.h patterncacher.h ../core/item.h ../core/data.h +patterncacher.o: ../core/locale.h ../core/log.h +priv.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +priv.o: ../core/locale.h ../confparser/confparser.h ../core/data.h priv.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h priv.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h priv.o: ../core/group.h ../core/functions.h ../core/function.h priv.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -priv.o: ../core/error.h ../core/rebus.h ../core/request.h +priv.o: ../core/error.h ../core/rebus.h ../core/locale.h ../core/request.h priv.o: ../core/requesttypes.h ../core/session.h ../core/done.h priv.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h priv.o: ../core/acceptbaseparser.h ../core/htmlfilter.h @@ -79,60 +97,71 @@ rebus.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h rebus.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h rebus.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h rebus.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h -rebus.o: ../core/mount.h templates.h patterncacher.h ../core/item.h -sys.o: templates.h patterncacher.h ../core/item.h ../core/data.h +rebus.o: ../core/mount.h ../core/locale.h templates.h patterncacher.h +rebus.o: ../core/item.h misc.h localefilter.h ../core/locale.h +rebus.o: ../confparser/confparser.h +sys.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +sys.o: ../core/locale.h ../confparser/confparser.h ../core/data.h sys.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h sys.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h sys.o: ../core/group.h ../core/functions.h ../core/function.h sys.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -sys.o: ../core/error.h ../core/rebus.h ../core/request.h +sys.o: ../core/error.h ../core/rebus.h ../core/locale.h ../core/request.h sys.o: ../core/requesttypes.h ../core/session.h ../core/done.h sys.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h sys.o: ../core/acceptbaseparser.h ../core/htmlfilter.h sys.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -templates.o: templates.h patterncacher.h ../core/item.h ../core/data.h +templates.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +templates.o: ../core/locale.h ../confparser/confparser.h ../core/data.h templates.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h templates.o: ../core/users.h ../core/user.h ../core/ugcontainer.h templates.o: ../core/log.h ../core/groups.h ../core/group.h templates.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h templates.o: ../core/mounts.h ../core/mount.h ../core/error.h ../core/rebus.h -templates.o: ../core/request.h ../core/requesttypes.h ../core/session.h -templates.o: ../core/done.h ../core/thread.h ../core/compress.h -templates.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h -templates.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h -templates.o: ../core/misc.h ../core/plugin.h ../core/request.h ../core/data.h +templates.o: ../core/locale.h ../core/request.h ../core/requesttypes.h +templates.o: ../core/session.h ../core/done.h ../core/thread.h +templates.o: ../core/compress.h ../core/acceptencodingparser.h +templates.o: ../core/acceptbaseparser.h ../core/htmlfilter.h +templates.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h +templates.o: ../core/plugin.h ../core/request.h ../core/data.h templates.o: ../core/pluginmsg.h -thread.o: templates.h patterncacher.h ../core/item.h ../core/data.h +thread.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +thread.o: ../core/locale.h ../confparser/confparser.h ../core/data.h thread.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h thread.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h thread.o: ../core/groups.h ../core/group.h ../core/functions.h thread.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -thread.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/request.h -thread.o: ../core/requesttypes.h ../core/session.h ../core/done.h -thread.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -thread.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -thread.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -ticket.o: templates.h patterncacher.h ../core/item.h ../core/data.h +thread.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/locale.h +thread.o: ../core/request.h ../core/requesttypes.h ../core/session.h +thread.o: ../core/done.h ../core/thread.h ../core/compress.h +thread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +thread.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h +thread.o: ../core/misc.h +ticket.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +ticket.o: ../core/locale.h ../confparser/confparser.h ../core/data.h ticket.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ticket.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h ticket.o: ../core/groups.h ../core/group.h ../core/functions.h ticket.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h -ticket.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/request.h -ticket.o: ../core/requesttypes.h ../core/session.h ../core/done.h -ticket.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h -ticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h -ticket.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -user.o: templates.h patterncacher.h ../core/item.h ../core/data.h +ticket.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/locale.h +ticket.o: ../core/request.h ../core/requesttypes.h ../core/session.h +ticket.o: ../core/done.h ../core/thread.h ../core/compress.h +ticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h +ticket.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h +ticket.o: ../core/misc.h +user.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +user.o: ../core/locale.h ../confparser/confparser.h ../core/data.h user.o: ../core/dirs.h ../core/item.h ../core/dircontainer.h ../core/users.h user.o: ../core/user.h ../core/ugcontainer.h ../core/log.h ../core/groups.h user.o: ../core/group.h ../core/functions.h ../core/function.h user.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h -user.o: ../core/error.h ../core/rebus.h ../core/request.h +user.o: ../core/error.h ../core/rebus.h ../core/locale.h ../core/request.h user.o: ../core/requesttypes.h ../core/session.h ../core/done.h user.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h user.o: ../core/acceptbaseparser.h ../core/htmlfilter.h user.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h -who.o: templates.h patterncacher.h ../core/item.h ../core/sessioncontainer.h +who.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h +who.o: ../core/locale.h ../confparser/confparser.h ../core/sessioncontainer.h who.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h who.o: ../core/log.h ../core/user.h ../core/rebus.h who.o: ../core/requestcontroller.h ../content/content.h @@ -142,7 +171,7 @@ who.o: ../core/functionparser.h ../core/requesttypes.h ../core/data.h who.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h who.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h who.o: ../core/functions.h ../core/function.h ../core/lastcontainer.h -who.o: ../core/mounts.h ../core/mount.h ../core/request.h ../core/thread.h -who.o: ../core/compress.h ../core/acceptencodingparser.h +who.o: ../core/mounts.h ../core/mount.h ../core/locale.h ../core/request.h +who.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h who.o: ../core/acceptbaseparser.h ../core/htmlfilter.h who.o: ../core/postmultiparser.h ../core/ticket.h ../core/misc.h diff --git a/templates/Makefile.o.dep b/templates/Makefile.o.dep index 96cdb13..148b339 100755 --- a/templates/Makefile.o.dep +++ b/templates/Makefile.o.dep @@ -1 +1 @@ -o = dir.o doc.o done.o item.o last.o mount.o patterncacher.o priv.o rebus.o sys.o templates.o thread.o ticket.o user.o who.o +o = dir.o doc.o done.o item.o last.o localefilter.o misc.o mount.o patterncacher.o priv.o rebus.o sys.o templates.o thread.o ticket.o user.o who.o diff --git a/templates/dir.cpp b/templates/dir.cpp index a9292ff..d8c4688 100755 --- a/templates/dir.cpp +++ b/templates/dir.cpp @@ -228,7 +228,10 @@ void dir_last_subject(Info & i) void dir_last_info(Info & i) { - Ezc::Generator gen(i.out, pat_dir_last_info, functions); + if( static_cast(data.locale.GetLang()) >= patterns.size() ) + return; + + Ezc::Generator gen(i.out, patterns[data.locale.GetLang()][pat_dir_last_info], functions); gen.Generate(); } diff --git a/templates/doc.cpp b/templates/doc.cpp index 0866e4c..7c6bbeb 100755 --- a/templates/doc.cpp +++ b/templates/doc.cpp @@ -21,13 +21,6 @@ namespace TemplatesFunctions -void doc_language(Info & i) -{ - // at the moment only Polish language - i.out << "pl"; -} - - void doc_title(Info & i) { @@ -49,11 +42,6 @@ void doc_title(Info & i) -void doc_charset(Info & i) -{ - i.out << "iso-8859-2"; -} - diff --git a/templates/item.cpp b/templates/item.cpp index 85bd5d0..0d1ac38 100755 --- a/templates/item.cpp +++ b/templates/item.cpp @@ -190,7 +190,10 @@ void item_can_write(Info & i) void item_info(Info & i) { - Ezc::Generator gen(i.out, pat_item_info, functions); + if( static_cast(data.locale.GetLang()) >= patterns.size() ) + return; + + Ezc::Generator gen(i.out, patterns[data.locale.GetLang()][pat_item_info], functions); gen.Generate(); } @@ -448,7 +451,10 @@ void item_tab_can_read(Info & i) void item_tab_info(Info & i) { - Ezc::Generator gen(i.out, pat_item_tab_info, functions); + if( static_cast(data.locale.GetLang()) >= patterns.size() ) + return; + + Ezc::Generator gen(i.out, patterns[data.locale.GetLang()][pat_item_tab_info], functions); gen.Generate(); } diff --git a/templates/localefilter.cpp b/templates/localefilter.cpp new file mode 100755 index 0000000..bd7e4f9 --- /dev/null +++ b/templates/localefilter.cpp @@ -0,0 +1,117 @@ +/* + * 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 "localefilter.h" +#include "../core/misc.h" + + + +LocaleFilter::LocaleFilter() +{ + open_mark = '{'; + closing_mark = '}'; +} + + + +void LocaleFilter::ReadKey() +{ + key.clear(); + + for( ; *pchar && *pchar != closing_mark ; ++pchar) + key += *pchar; + + // skipping last closing mark (if exists) + if( *pchar == closing_mark ) + ++pchar; + + TrimWhite(key); +} + + +std::string & LocaleFilter::FilterValue(const std::string & in) +{ + value.clear(); + const char * p = in.c_str(); + + while( *p ) + { + if( *p == '\\' && (*(p+1) == 'n') ) + { + value += '\n'; + p += 2; + } + else + if( *p == '\\' && (*(p+1) == '\\') ) + { + value += '\\'; + p += 2; + } + else + { + value += *p; + p += 1; + } + } + +return value; +} + + + +void LocaleFilter::Parse(std::string & str) +{ + res.clear(); + pchar = str.c_str(); + + while( *pchar ) + { + if( *pchar == open_mark ) + { + ++pchar; + ReadKey(); + res += FilterValue(plocale->Get(key)); + } + else + if( *pchar == '\\' && (*(pchar+1) == open_mark || *(pchar+1) == closing_mark || *(pchar+1) == '\\') ) + { + res += *(pchar+1); + pchar += 2; + } + else + { + res += *pchar; + pchar += 1; + } + } + + str = res; +} + + + + +void LocaleFilter::FilterText(Ezc::Pattern::Item & item) +{ + if( !item.text.empty() ) + Parse(item.text); + + std::vector::iterator i = item.item_table.begin(); + + for( ; i != item.item_table.end() ; ++i ) + FilterText(**i); +} + + + +void LocaleFilter::Filter(Ezc::Pattern & pattern, const Locale & locale) +{ + plocale = &locale; + FilterText( pattern.item_root ); +} diff --git a/templates/localefilter.h b/templates/localefilter.h new file mode 100755 index 0000000..d6420dc --- /dev/null +++ b/templates/localefilter.h @@ -0,0 +1,46 @@ +/* + * 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 headerfilecmslutemplateslocalefilter +#define headerfilecmslutemplateslocalefilter + + +#include "../core/locale.h" +#include "ezc.h" + + + +class LocaleFilter +{ +public: + + LocaleFilter(); + void Filter(Ezc::Pattern & pattern, const Locale & locale); + +private: + void ReadKey(); + std::string & FilterValue(const std::string & in); + void FilterText(Ezc::Pattern::Item & item); + void Parse(std::string & str); + + char open_mark; // default '{' + char closing_mark; // default '}' + + const Locale * plocale; + std::string res; + std::string key; + std::string value; + const char * pchar; + +}; + + + + +#endif diff --git a/templates/misc.cpp b/templates/misc.cpp new file mode 100755 index 0000000..a517009 --- /dev/null +++ b/templates/misc.cpp @@ -0,0 +1,88 @@ +/* + * 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 "../core/data.h" +#include "../core/misc.h" +#include "misc.h" + + +namespace TemplatesMisc +{ + +// those functions from here are used in the second thread too + + +void Read(Patterns & patterns, size_t pat, LocaleFilter & locale_filter, const std::string & dir, const char * file, bool delete_white) +{ + size_t i; + size_t len = patterns.size(); + Locale::Lang old_lang = data.locale.GetLang(); + + + for(i=0 ; i(i); + data.locale.SetLang(new_lang); + + locale_filter.Filter(patterns[i][pat], data.locale); + + log << "Read pattern: " << dir << "/" << file << " for lang: " << data.locale.LangToStr(new_lang) << logend; + } + } + + data.locale.SetLang(old_lang); +} + + + +void Read(Patterns & patterns, size_t pat, LocaleFilter & locale_filter, const char * file, bool delete_white) +{ + std::string temp = data.templates_dir; + temp += '/'; + temp += file; + + + if( IsFile(temp) ) + { + Read(patterns, pat, locale_filter, data.templates_dir, file, delete_white); + } + else + { + Read(patterns, pat, locale_filter, data.templates_dir_default, file, delete_white); + } +} + + + +void ClearPatterns(Patterns & patterns, size_t len) +{ +size_t loc, pat; + + patterns.resize(Locale::lang_unknown); + + for(loc=0 ; loc < static_cast(Locale::lang_unknown) ; ++loc) + { + patterns[loc].resize(len); + + for(pat=0 ; pat +#include +#include "localefilter.h" +#include "ezc.h" + + + + +namespace TemplatesMisc +{ + +typedef std::vector > Patterns; + + + +// those functions from here are used in the second thread too + +void Read(Patterns & patterns, size_t pat, LocaleFilter & locale_filter, const std::string & dir, const char * file, bool delete_white = false); +void Read(Patterns & patterns, size_t pat, LocaleFilter & locale_filter, const char * file, bool delete_white = false); +void ClearPatterns(Patterns & patterns, size_t len); + + + +} // namespace TemplatesMisc + +#endif + diff --git a/templates/templates.cpp b/templates/templates.cpp index 7c2d43c..123c963 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -2,12 +2,13 @@ * 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. * */ #include "templates.h" +#include "localefilter.h" #include "../core/data.h" #include "../core/request.h" #include "../core/misc.h" @@ -16,37 +17,11 @@ namespace TemplatesFunctions { -Ezc::Pattern pat_index; -Ezc::Pattern pat_fun_cat; -Ezc::Pattern pat_fun_ls; -Ezc::Pattern pat_fun_emacs; -Ezc::Pattern pat_fun_mkdir; -Ezc::Pattern pat_fun_default; -Ezc::Pattern pat_fun_priv; -Ezc::Pattern pat_fun_rm; -Ezc::Pattern pat_fun_who; -Ezc::Pattern pat_fun_run; -Ezc::Pattern pat_fun_last; -Ezc::Pattern pat_fun_thread; -Ezc::Pattern pat_fun_reload; -Ezc::Pattern pat_fun_createthread; -Ezc::Pattern pat_fun_upload; -Ezc::Pattern pat_fun_ticket; -Ezc::Pattern pat_fun_createticket; -Ezc::Pattern pat_err_item_required; -Ezc::Pattern pat_err_404; -Ezc::Pattern pat_err_per_denied; -Ezc::Pattern pat_err_others; -Ezc::Pattern pat_item_info; -Ezc::Pattern pat_item_tab_info; -Ezc::Pattern pat_dir_last_info; - +TemplatesMisc::Patterns patterns; Ezc::Functions functions; - - -PatternCacher pattern_cacher; - +PatternCacher pattern_cacher; +LocaleFilter locale_filter; @@ -60,86 +35,44 @@ Ezc::Pattern * content_for_function() { Ezc::Pattern * p = 0; - if( !request.pfunction ) { log << log1 << "Templates: no function" << logend; return p; } + static PatName pat_name_tab[] = { + {FUN_CAT, pat_fun_cat}, + {FUN_LS, pat_fun_ls}, + {FUN_RM, pat_fun_rm}, + {FUN_EMACS, pat_fun_emacs}, + {FUN_MKDIR, pat_fun_mkdir}, + {FUN_DEFAULT, pat_fun_default}, + {FUN_PRIV, pat_fun_priv}, + {FUN_RUN, pat_fun_run}, + {FUN_WHO, pat_fun_who}, + {FUN_LAST, pat_fun_last}, + {FUN_THREAD, pat_fun_thread}, + {FUN_RELOAD, pat_fun_reload}, + {FUN_CREATETHREAD, pat_fun_createthread}, + {FUN_TICKET, pat_fun_ticket}, + {FUN_CREATETICKET, pat_fun_createticket}, + {FUN_EDITTICKET, pat_fun_createticket}, + {FUN_UPLOAD, pat_fun_upload} + }; - switch( request.pfunction->code ) + size_t i, len = sizeof(pat_name_tab)/sizeof(PatName); + + for(i=0 ; icode ) + { + // !! data.locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika + p = &patterns[data.locale.GetLang()][pat_name_tab[i].pat]; + break; + } } - return p; } @@ -149,6 +82,13 @@ void content(Info & i) { Ezc::Pattern * p = 0; + if( static_cast(data.locale.GetLang()) >= patterns.size() ) + { + log << log1 << "Templates: there is no such a language in patterns" << logend; + return; + } + + switch( request.status ) { case Error::ok: @@ -165,17 +105,20 @@ Ezc::Pattern * p = 0; case Error::cant_change_user: case Error::cant_change_group: case Error::cant_change_privileges: - p = &pat_err_per_denied; + // !! data.locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika + p = &patterns[data.locale.GetLang()][pat_err_per_denied]; break; case Error::no_item: case Error::no_function: case Error::unknown_param: - p = &pat_err_404; + // !! data.locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika + p = &patterns[data.locale.GetLang()][pat_err_404]; break; default: - p = &pat_err_others; + // !! data.locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika + p = &patterns[data.locale.GetLang()][pat_err_others]; break; } @@ -218,9 +161,7 @@ void Templates::CreateFunctions() /* doc */ - functions.Insert("doc_language", doc_language); functions.Insert("doc_title", doc_title); - functions.Insert("doc_charset", doc_charset); functions.Insert("doc_base_url", doc_base_url); functions.Insert("doc_base_url_static", doc_base_url_static); functions.Insert("doc_base_url_static_auth", doc_base_url_static_auth); @@ -482,90 +423,59 @@ void Templates::CreateFunctions() + void Templates::ReadTemplates() { - using namespace TemplatesFunctions; - - pat_index.Directory(data.templates); - pat_index.ParseFile("index.html"); - - pat_err_404.Directory(data.templates); - pat_err_404.ParseFile("err_404.html"); +using namespace TemplatesFunctions; +using namespace TemplatesMisc; - pat_err_per_denied.Directory(data.templates); - pat_err_per_denied.ParseFile("err_per_denied.html"); + ClearPatterns(); - pat_fun_cat.Directory(data.templates); - pat_fun_cat.ParseFile("fun_cat.html"); - - pat_fun_ls.Directory(data.templates); - pat_fun_ls.ParseFile("fun_ls.html"); - - pat_fun_rm.Directory(data.templates); - pat_fun_rm.ParseFile("fun_rm.html"); - - pat_err_item_required.Directory(data.templates); - pat_err_item_required.ParseFile("err_item_required.html"); - - pat_fun_emacs.Directory(data.templates); - pat_fun_emacs.ParseFile("fun_emacs.html"); - - pat_fun_mkdir.Directory(data.templates); - pat_fun_mkdir.ParseFile("fun_mkdir.html"); - - pat_fun_default.Directory(data.templates); - pat_fun_default.ParseFile("fun_default.html"); - - pat_fun_priv.Directory(data.templates); - pat_fun_priv.ParseFile("fun_priv.html"); - - pat_err_others.Directory(data.templates); - pat_err_others.ParseFile("err_others.html"); - - pat_fun_who.Directory(data.templates); - pat_fun_who.ParseFile("fun_who.html"); - - pat_fun_run.Directory(data.templates); - pat_fun_run.ParseFile("fun_run.html"); - - pat_fun_last.Directory(data.templates); - pat_fun_last.ParseFile("fun_last.html"); - - pat_item_info.Directory(data.templates); - pat_item_info.ParseFile("item_info.html"); - - pat_item_tab_info.Directory(data.templates); - pat_item_tab_info.ParseFile("item_tab_info.html"); - - pat_fun_thread.Directory(data.templates); - pat_fun_thread.ParseFile("fun_thread.html"); - - pat_fun_createthread.Directory(data.templates); - pat_fun_createthread.ParseFile("fun_createthread.html"); - - pat_dir_last_info.Directory(data.templates); - pat_dir_last_info.ParseFile("dir_last_info.html"); - - pat_fun_reload.Directory(data.templates); - pat_fun_reload.ParseFile("fun_reload.html"); - - pat_fun_upload.Directory(data.templates); - pat_fun_upload.ParseFile("fun_upload.html"); - - pat_fun_ticket.Directory(data.templates); - pat_fun_ticket.ParseFile("fun_ticket.html"); - - pat_fun_createticket.Directory(data.templates); - pat_fun_createticket.ParseFile("fun_createticket.html"); + Read(patterns, pat_index, locale_filter, "index.html"); + Read(patterns, pat_err_404, locale_filter, "err_404.html"); + Read(patterns, pat_err_per_denied, locale_filter, "err_per_denied.html"); + Read(patterns, pat_fun_cat, locale_filter, "fun_cat.html"); + Read(patterns, pat_fun_ls, locale_filter, "fun_ls.html"); + Read(patterns, pat_fun_rm, locale_filter, "fun_rm.html"); + Read(patterns, pat_fun_emacs, locale_filter, "fun_emacs.html"); + Read(patterns, pat_fun_mkdir, locale_filter, "fun_mkdir.html"); + Read(patterns, pat_fun_default, locale_filter, "fun_default.html"); + Read(patterns, pat_fun_priv, locale_filter, "fun_priv.html"); + Read(patterns, pat_err_others, locale_filter, "err_others.html"); + Read(patterns, pat_fun_who, locale_filter, "fun_who.html"); + Read(patterns, pat_fun_run, locale_filter, "fun_run.html"); + Read(patterns, pat_fun_last, locale_filter, "fun_last.html"); + Read(patterns, pat_item_info, locale_filter, "item_info.html"); + Read(patterns, pat_item_tab_info, locale_filter, "item_tab_info.html"); + Read(patterns, pat_fun_thread, locale_filter, "fun_thread.html"); + Read(patterns, pat_fun_createthread,locale_filter, "fun_createthread.html"); + Read(patterns, pat_dir_last_info, locale_filter, "dir_last_info.html"); + Read(patterns, pat_fun_reload, locale_filter, "fun_reload.html"); + Read(patterns, pat_fun_upload, locale_filter, "fun_upload.html"); + Read(patterns, pat_fun_ticket, locale_filter, "fun_ticket.html"); + Read(patterns, pat_fun_createticket,locale_filter, "fun_createticket.html"); } + +void Templates::ClearPatterns() +{ +using namespace TemplatesFunctions; + + TemplatesMisc::ClearPatterns(patterns, pat_last); +} + + void Templates::Generate() { using namespace TemplatesFunctions; - Ezc::Generator generator(request.page, pat_index, functions); + // !! locale beda w zaleznosci od uzytkownika + if( static_cast(data.locale.GetLang()) >= patterns.size() ) + return; + + Ezc::Generator generator(request.page, patterns[data.locale.GetLang()][pat_index], functions); generator.Generate(); } @@ -582,3 +492,10 @@ using namespace TemplatesFunctions; item_run(info); } + +Templates::Templates() +{ + ClearPatterns(); +} + + diff --git a/templates/templates.h b/templates/templates.h index 5e3e6f7..06567df 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -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. * */ @@ -12,9 +12,9 @@ #include #include - #include "ezc.h" #include "patterncacher.h" +#include "misc.h" @@ -22,11 +22,45 @@ namespace TemplatesFunctions { using Ezc::Info; + enum Pat { + pat_index = 0, // first should be zero + pat_fun_cat, + pat_fun_ls, + pat_fun_emacs, + pat_fun_mkdir, + pat_fun_default, + pat_fun_priv, + pat_fun_rm, + pat_fun_who, + pat_fun_run, + pat_fun_last, + pat_fun_thread, + pat_fun_reload, + pat_fun_createthread, + pat_fun_upload, + pat_fun_ticket, + pat_fun_createticket, + pat_err_404, + pat_err_per_denied, + pat_err_others, + pat_item_info, + pat_item_tab_info, + pat_dir_last_info, + + pat_last // should be last + }; + + struct PatName + { + int fun_code; + Pat pat; + }; + + + + extern TemplatesMisc::Patterns patterns; extern PatternCacher pattern_cacher; extern Ezc::Functions functions; - extern Ezc::Pattern pat_item_info; - extern Ezc::Pattern pat_item_tab_info; - extern Ezc::Pattern pat_dir_last_info; @@ -41,9 +75,7 @@ namespace TemplatesFunctions /* doc */ - void doc_language(Info & i); void doc_title(Info & i); - void doc_charset(Info & i); void doc_base_url(Info & i); void doc_base_url_static(Info & i); void doc_base_url_static_auth(Info & i); @@ -301,11 +333,18 @@ class Templates { public: + Templates(); + + void ClearPatterns(); void ReadTemplates(); void CreateFunctions(); void Generate(); void GenerateRunRaw(); +private: + + std::string temp; + }; diff --git a/templatesnotify/Makefile.dep b/templatesnotify/Makefile.dep index 1dc6a80..b4f468c 100755 --- a/templatesnotify/Makefile.dep +++ b/templatesnotify/Makefile.dep @@ -1,6 +1,16 @@ # DO NOT DELETE -notify.o: templatesnotify.h ../core/mount.h ../core/notify.h +notify.o: templatesnotify.h ../core/mount.h ../core/locale.h +notify.o: ../confparser/confparser.h ../templates/misc.h +notify.o: ../templates/localefilter.h ../core/notify.h notify.o: ../templatesnotify/templatesnotify.h -templatesnotify.o: templatesnotify.h ../core/mount.h ../core/misc.h -templatesnotify.o: ../core/item.h +templatesnotify.o: templatesnotify.h ../core/mount.h ../core/locale.h +templatesnotify.o: ../confparser/confparser.h ../templates/misc.h +templatesnotify.o: ../templates/localefilter.h ../core/misc.h ../core/item.h +templatesnotify.o: ../core/data.h ../core/dirs.h ../core/dircontainer.h +templatesnotify.o: ../core/users.h ../core/user.h ../core/ugcontainer.h +templatesnotify.o: ../core/log.h ../core/groups.h ../core/group.h +templatesnotify.o: ../core/functions.h ../core/function.h +templatesnotify.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h +templatesnotify.o: ../core/error.h ../core/rebus.h ../core/locale.h +templatesnotify.o: ../core/log.h diff --git a/templatesnotify/templatesnotify.cpp b/templatesnotify/templatesnotify.cpp index 05b3cdb..41278b6 100755 --- a/templatesnotify/templatesnotify.cpp +++ b/templatesnotify/templatesnotify.cpp @@ -9,27 +9,33 @@ #include "templatesnotify.h" #include "../core/misc.h" +#include "../core/locale.h" +#include "../core/data.h" +#include "../core/log.h" + namespace TemplatesNotifyFunctions { -Ezc::Pattern pat_notify_email; + +TemplatesMisc::Patterns patterns; Ezc::Functions functions; +LocaleFilter locale_filter; + // you can use this pointer in template functions (will be always valid) NotifyMsg * notify_msg; - - - } // namespace TemplatesNotifyFunctions + + void TemplatesNotify::CreateFunctions() { using namespace TemplatesNotifyFunctions; @@ -51,22 +57,34 @@ using namespace TemplatesNotifyFunctions; - -void TemplatesNotify::Read(const std::string & templates_dir) +void TemplatesNotify::ClearPatterns() { using namespace TemplatesNotifyFunctions; - pat_notify_email.delete_all_white = true; - pat_notify_email.Directory(templates_dir); - pat_notify_email.ParseFile("notify_email.txt"); - CreateFunctions(); + TemplatesMisc::ClearPatterns(patterns, pat_last); +} + + + +// templates are read in the main thread +// (before creating the second thread) +void TemplatesNotify::Read() +{ +using namespace TemplatesNotifyFunctions; +using namespace TemplatesMisc; + + ClearPatterns(); + + TemplatesMisc::Read(patterns, pat_email_notify, locale_filter, "notify_email.txt", true); + + notify_msg = 0; } -void TemplatesNotify::Generate() +void TemplatesNotify::Generate(Locale::Lang lang) { using namespace TemplatesNotifyFunctions; @@ -75,8 +93,37 @@ using namespace TemplatesNotifyFunctions; if( !notify_msg ) return; - Ezc::Generator generator(notify_str, pat_notify_email, functions); + if( static_cast(lang) >= patterns.size() ) + { + // ops, something wrong + return; + } + + Ezc::Generator generator(notify_str, patterns[lang][pat_email_notify], functions); generator.Generate(); } +TemplatesNotify::TemplatesNotify() +{ + ClearPatterns(); +} + + + + + + + + + + + + + + + + + + + diff --git a/templatesnotify/templatesnotify.h b/templatesnotify/templatesnotify.h index df72447..6b5e88c 100755 --- a/templatesnotify/templatesnotify.h +++ b/templatesnotify/templatesnotify.h @@ -13,8 +13,9 @@ #include #include #include - #include "../core/mount.h" +#include "../core/locale.h" +#include "../templates/misc.h" #include "ezc.h" @@ -23,6 +24,7 @@ struct NotifyMsg std::string email; int notify_code; Mount::Type current_mount_type; + Locale::Lang lang; std::string doc_base_url; std::string item_dir; std::string item_link; @@ -33,6 +35,15 @@ namespace TemplatesNotifyFunctions { using Ezc::Info; + enum Pat { + pat_email_notify = 0, // first should be zero + + pat_last // should be last + }; + + typedef std::vector > Patterns; + + extern TemplatesMisc::Patterns patterns; extern NotifyMsg * notify_msg; void notify_item_added(Info & i); @@ -55,15 +66,21 @@ class TemplatesNotify { public: - void Read(const std::string & templates_dir); - void Generate(); + TemplatesNotify(); + + void Read(); + void CreateFunctions(); + void Generate(Locale::Lang lang); std::ostringstream notify_str; private: - void CreateFunctions(); + void Read(TemplatesNotifyFunctions::Pat pat, const std::string & dir, const char * file); + void Read(TemplatesNotifyFunctions::Pat pat, const char * file); + void ClearPatterns(); + std::string temp; };