changed: rename cmslu to winix

changed: html templates are a part of winix now
         and the user can provide special html templates for its site
added:   locales
added:   html templates are using HtmlFilter now (locales)
changed: now we have html templates for each language



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@560 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2010-01-28 15:39:01 +00:00
parent 5dac8af300
commit 09d427b4ba
65 changed files with 1949 additions and 848 deletions

View File

@ -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/

View File

@ -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 ; i<s.size() && IsWhite(s[i]) ; ++i);
// deleting white characters at the beginning
if( i != 0 )
s.erase(0, i);
}

View File

@ -66,7 +66,7 @@ private:
bool IsWhite(int c);
void SkipWhite();
void SkipLine();
void Trim(std::string & s);
};

View File

@ -1,7 +1,9 @@
# DO NOT DELETE
cat.o: content.h ../core/item.h ../templates/templates.h
cat.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
cat.o: ../templates/patterncacher.h ../templates/misc.h
cat.o: ../templates/localefilter.h ../core/locale.h
cat.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
cat.o: ../core/done.h ../core/request.h ../core/requesttypes.h
cat.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
cat.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -9,7 +11,9 @@ cat.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
cat.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
cat.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
content.o: content.h ../core/item.h ../templates/templates.h
content.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
content.o: ../templates/patterncacher.h ../templates/misc.h
content.o: ../templates/localefilter.h ../core/locale.h
content.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
content.o: ../core/done.h ../core/request.h ../core/requesttypes.h
content.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
content.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -20,38 +24,42 @@ content.o: ../core/db.h ../core/group.h ../core/dircontainer.h
content.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h
content.o: ../core/users.h ../core/groups.h ../core/functions.h
content.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
content.o: ../core/misc.h ../core/plugin.h ../core/request.h ../core/data.h
content.o: ../core/pluginmsg.h
content.o: ../core/locale.h ../core/misc.h ../core/plugin.h ../core/request.h
content.o: ../core/data.h ../core/pluginmsg.h
createthread.o: content.h ../core/item.h ../templates/templates.h
createthread.o: ../templates/patterncacher.h ../core/thread.h
createthread.o: ../core/ticket.h ../core/done.h ../core/request.h
createthread.o: ../core/requesttypes.h ../core/session.h ../core/done.h
createthread.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
createthread.o: ../core/rebus.h ../core/function.h ../core/thread.h
createthread.o: ../core/compress.h ../core/acceptencodingparser.h
createthread.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
createthread.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
createthread.o: ../core/db.h ../core/group.h ../core/dircontainer.h
createthread.o: ../core/ugcontainer.h ../core/mount.h ../core/data.h
createthread.o: ../core/dirs.h ../core/users.h ../core/groups.h
createthread.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
createthread.o: ../core/mount.h
createthread.o: ../templates/patterncacher.h ../templates/misc.h
createthread.o: ../templates/localefilter.h ../core/locale.h
createthread.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
createthread.o: ../core/done.h ../core/request.h ../core/requesttypes.h
createthread.o: ../core/session.h ../core/done.h ../core/item.h
createthread.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h
createthread.o: ../core/function.h ../core/thread.h ../core/compress.h
createthread.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
createthread.o: ../core/htmlfilter.h ../core/postmultiparser.h
createthread.o: ../core/ticket.h ../core/error.h ../core/db.h ../core/group.h
createthread.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/mount.h
createthread.o: ../core/data.h ../core/dirs.h ../core/users.h
createthread.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
createthread.o: ../core/mounts.h ../core/mount.h ../core/locale.h
createticket.o: content.h ../core/item.h ../templates/templates.h
createticket.o: ../templates/patterncacher.h ../core/thread.h
createticket.o: ../core/ticket.h ../core/done.h ../core/request.h
createticket.o: ../core/requesttypes.h ../core/session.h ../core/done.h
createticket.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
createticket.o: ../core/rebus.h ../core/function.h ../core/thread.h
createticket.o: ../core/compress.h ../core/acceptencodingparser.h
createticket.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
createticket.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
createticket.o: ../core/db.h ../core/group.h ../core/dircontainer.h
createticket.o: ../core/ugcontainer.h ../core/mount.h ../core/data.h
createticket.o: ../core/dirs.h ../core/users.h ../core/groups.h
createticket.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
createticket.o: ../core/mount.h
createticket.o: ../templates/patterncacher.h ../templates/misc.h
createticket.o: ../templates/localefilter.h ../core/locale.h
createticket.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
createticket.o: ../core/done.h ../core/request.h ../core/requesttypes.h
createticket.o: ../core/session.h ../core/done.h ../core/item.h
createticket.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h
createticket.o: ../core/function.h ../core/thread.h ../core/compress.h
createticket.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
createticket.o: ../core/htmlfilter.h ../core/postmultiparser.h
createticket.o: ../core/ticket.h ../core/error.h ../core/db.h ../core/group.h
createticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/mount.h
createticket.o: ../core/data.h ../core/dirs.h ../core/users.h
createticket.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
createticket.o: ../core/mounts.h ../core/mount.h ../core/locale.h
default.o: content.h ../core/item.h ../templates/templates.h
default.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
default.o: ../templates/patterncacher.h ../templates/misc.h
default.o: ../templates/localefilter.h ../core/locale.h
default.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
default.o: ../core/done.h ../core/request.h ../core/requesttypes.h
default.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
default.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -62,8 +70,11 @@ default.o: ../core/db.h ../core/group.h ../core/dircontainer.h
default.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h
default.o: ../core/users.h ../core/groups.h ../core/functions.h
default.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
default.o: ../core/locale.h
editticket.o: content.h ../core/item.h ../templates/templates.h
editticket.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
editticket.o: ../templates/patterncacher.h ../templates/misc.h
editticket.o: ../templates/localefilter.h ../core/locale.h
editticket.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
editticket.o: ../core/done.h ../core/request.h ../core/requesttypes.h
editticket.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
editticket.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -74,9 +85,11 @@ editticket.o: ../core/error.h ../core/db.h ../core/group.h
editticket.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/mount.h
editticket.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
editticket.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
editticket.o: ../core/mount.h
editticket.o: ../core/mount.h ../core/locale.h
emacs.o: content.h ../core/item.h ../templates/templates.h
emacs.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
emacs.o: ../templates/patterncacher.h ../templates/misc.h
emacs.o: ../templates/localefilter.h ../core/locale.h
emacs.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
emacs.o: ../core/done.h ../core/request.h ../core/requesttypes.h
emacs.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
emacs.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -86,13 +99,18 @@ emacs.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
emacs.o: ../core/db.h ../core/group.h ../core/dircontainer.h
emacs.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
emacs.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
emacs.o: ../core/mounts.h ../core/mount.h ../core/notify.h
emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h ../core/misc.h
emacs.o: ../core/mounts.h ../core/mount.h ../core/locale.h ../core/notify.h
emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h
emacs.o: ../templates/misc.h ../core/misc.h
last.o: content.h ../core/item.h ../templates/templates.h
last.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
last.o: ../templates/patterncacher.h ../templates/misc.h
last.o: ../templates/localefilter.h ../core/locale.h
last.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
last.o: ../core/done.h
login.o: content.h ../core/item.h ../templates/templates.h
login.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
login.o: ../templates/patterncacher.h ../templates/misc.h
login.o: ../templates/localefilter.h ../core/locale.h
login.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
login.o: ../core/done.h ../core/request.h ../core/requesttypes.h
login.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
login.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -102,9 +120,11 @@ login.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
login.o: ../core/db.h ../core/group.h ../core/dircontainer.h
login.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
login.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
login.o: ../core/mounts.h ../core/mount.h
login.o: ../core/mounts.h ../core/mount.h ../core/locale.h
logout.o: content.h ../core/item.h ../templates/templates.h
logout.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
logout.o: ../templates/patterncacher.h ../templates/misc.h
logout.o: ../templates/localefilter.h ../core/locale.h
logout.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
logout.o: ../core/done.h ../core/request.h ../core/requesttypes.h
logout.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
logout.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -114,18 +134,22 @@ logout.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h
logout.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h
logout.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h
logout.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
logout.o: ../core/mount.h
logout.o: ../core/mount.h ../core/locale.h
ls.o: content.h ../core/item.h ../templates/templates.h
ls.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
ls.o: ../core/done.h ../core/request.h ../core/requesttypes.h
ls.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
ls.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
ls.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
ls.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
ls.o: ../core/postmultiparser.h ../core/ticket.h ../core/db.h ../core/group.h
ls.o: ../core/dircontainer.h ../core/ugcontainer.h
ls.o: ../templates/patterncacher.h ../templates/misc.h
ls.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
ls.o: ../core/thread.h ../core/ticket.h ../core/done.h ../core/request.h
ls.o: ../core/requesttypes.h ../core/session.h ../core/done.h ../core/item.h
ls.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h
ls.o: ../core/function.h ../core/thread.h ../core/compress.h
ls.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
ls.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h
ls.o: ../core/db.h ../core/group.h ../core/dircontainer.h
ls.o: ../core/ugcontainer.h
misc_item.o: content.h ../core/item.h ../templates/templates.h
misc_item.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
misc_item.o: ../templates/patterncacher.h ../templates/misc.h
misc_item.o: ../templates/localefilter.h ../core/locale.h
misc_item.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
misc_item.o: ../core/done.h ../core/request.h ../core/requesttypes.h
misc_item.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
misc_item.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -135,7 +159,9 @@ misc_item.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h
misc_item.o: ../core/misc.h ../core/db.h ../core/group.h
misc_item.o: ../core/dircontainer.h ../core/ugcontainer.h
misc_specialfile.o: content.h ../core/item.h ../templates/templates.h
misc_specialfile.o: ../templates/patterncacher.h ../core/thread.h
misc_specialfile.o: ../templates/patterncacher.h ../templates/misc.h
misc_specialfile.o: ../templates/localefilter.h ../core/locale.h
misc_specialfile.o: ../confparser/confparser.h ../core/thread.h
misc_specialfile.o: ../core/ticket.h ../core/done.h ../core/request.h
misc_specialfile.o: ../core/requesttypes.h ../core/session.h ../core/done.h
misc_specialfile.o: ../core/item.h ../core/error.h ../core/log.h
@ -147,9 +173,11 @@ misc_specialfile.o: ../core/ticket.h ../core/data.h ../core/dirs.h
misc_specialfile.o: ../core/dircontainer.h ../core/users.h
misc_specialfile.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h
misc_specialfile.o: ../core/functions.h ../core/lastcontainer.h
misc_specialfile.o: ../core/mounts.h ../core/mount.h
misc_specialfile.o: ../core/mounts.h ../core/mount.h ../core/locale.h
mkdir.o: content.h ../core/item.h ../templates/templates.h
mkdir.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
mkdir.o: ../templates/patterncacher.h ../templates/misc.h
mkdir.o: ../templates/localefilter.h ../core/locale.h
mkdir.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
mkdir.o: ../core/done.h ../core/request.h ../core/requesttypes.h
mkdir.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
mkdir.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -159,10 +187,13 @@ mkdir.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
mkdir.o: ../core/db.h ../core/group.h ../core/dircontainer.h
mkdir.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
mkdir.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
mkdir.o: ../core/mounts.h ../core/mount.h ../core/notify.h
mkdir.o: ../core/mounts.h ../core/mount.h ../core/locale.h ../core/notify.h
mkdir.o: ../templatesnotify/templatesnotify.h ../core/mount.h
mkdir.o: ../templates/misc.h
node.o: content.h ../core/item.h ../templates/templates.h
node.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
node.o: ../templates/patterncacher.h ../templates/misc.h
node.o: ../templates/localefilter.h ../core/locale.h
node.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
node.o: ../core/done.h ../core/request.h ../core/requesttypes.h
node.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
node.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -170,7 +201,9 @@ node.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
node.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
node.o: ../core/postmultiparser.h ../core/ticket.h
priv.o: content.h ../core/item.h ../templates/templates.h
priv.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
priv.o: ../templates/patterncacher.h ../templates/misc.h
priv.o: ../templates/localefilter.h ../core/locale.h
priv.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
priv.o: ../core/done.h ../core/request.h ../core/requesttypes.h
priv.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
priv.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -180,29 +213,36 @@ priv.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
priv.o: ../core/db.h ../core/group.h ../core/dircontainer.h
priv.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
priv.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
priv.o: ../core/mounts.h ../core/mount.h
priv.o: ../core/mounts.h ../core/mount.h ../core/locale.h
reload.o: content.h ../core/item.h ../templates/templates.h
reload.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
reload.o: ../templates/patterncacher.h ../templates/misc.h
reload.o: ../templates/localefilter.h ../core/locale.h
reload.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
reload.o: ../core/done.h ../core/request.h ../core/requesttypes.h
reload.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
reload.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
reload.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
reload.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
reload.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
reload.o: ../core/notify.h ../templatesnotify/templatesnotify.h
reload.o: ../core/mount.h ../templates/misc.h
rm.o: content.h ../core/item.h ../templates/templates.h
rm.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
rm.o: ../core/done.h ../core/request.h ../core/requesttypes.h
rm.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
rm.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
rm.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
rm.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
rm.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h ../core/db.h
rm.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
rm.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
rm.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
rm.o: ../core/mount.h
rm.o: ../templates/patterncacher.h ../templates/misc.h
rm.o: ../templates/localefilter.h ../core/locale.h ../confparser/confparser.h
rm.o: ../core/thread.h ../core/ticket.h ../core/done.h ../core/request.h
rm.o: ../core/requesttypes.h ../core/session.h ../core/done.h ../core/item.h
rm.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h
rm.o: ../core/function.h ../core/thread.h ../core/compress.h
rm.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
rm.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h
rm.o: ../core/error.h ../core/db.h ../core/group.h ../core/dircontainer.h
rm.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h ../core/users.h
rm.o: ../core/groups.h ../core/functions.h ../core/lastcontainer.h
rm.o: ../core/mounts.h ../core/mount.h ../core/locale.h
run.o: content.h ../core/item.h ../templates/templates.h
run.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
run.o: ../templates/patterncacher.h ../templates/misc.h
run.o: ../templates/localefilter.h ../core/locale.h
run.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
run.o: ../core/done.h ../core/request.h ../core/requesttypes.h
run.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
run.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -210,7 +250,9 @@ run.o: ../core/thread.h ../core/compress.h ../core/acceptencodingparser.h
run.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
run.o: ../core/postmultiparser.h ../core/ticket.h ../core/error.h
thread.o: content.h ../core/item.h ../templates/templates.h
thread.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
thread.o: ../templates/patterncacher.h ../templates/misc.h
thread.o: ../templates/localefilter.h ../core/locale.h
thread.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
thread.o: ../core/done.h ../core/request.h ../core/requesttypes.h
thread.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
thread.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -220,9 +262,11 @@ thread.o: ../core/postmultiparser.h ../core/ticket.h ../core/db.h
thread.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
thread.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
thread.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
thread.o: ../core/mount.h ../core/mount.h
thread.o: ../core/mount.h ../core/locale.h ../core/mount.h
ticket.o: content.h ../core/item.h ../templates/templates.h
ticket.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
ticket.o: ../templates/patterncacher.h ../templates/misc.h
ticket.o: ../templates/localefilter.h ../core/locale.h
ticket.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
ticket.o: ../core/done.h ../core/request.h ../core/requesttypes.h
ticket.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
ticket.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -232,9 +276,11 @@ ticket.o: ../core/postmultiparser.h ../core/ticket.h ../core/db.h
ticket.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
ticket.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
ticket.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
ticket.o: ../core/mount.h ../core/mount.h
ticket.o: ../core/mount.h ../core/locale.h ../core/mount.h
upload.o: content.h ../core/item.h ../templates/templates.h
upload.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
upload.o: ../templates/patterncacher.h ../templates/misc.h
upload.o: ../templates/localefilter.h ../core/locale.h
upload.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
upload.o: ../core/done.h ../core/request.h ../core/requesttypes.h
upload.o: ../core/session.h ../core/done.h ../core/item.h ../core/error.h
upload.o: ../core/log.h ../core/user.h ../core/rebus.h ../core/function.h
@ -244,7 +290,9 @@ upload.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h
upload.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h
upload.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h
upload.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
upload.o: ../core/mount.h
upload.o: ../core/mount.h ../core/locale.h
who.o: content.h ../core/item.h ../templates/templates.h
who.o: ../templates/patterncacher.h ../core/thread.h ../core/ticket.h
who.o: ../templates/patterncacher.h ../templates/misc.h
who.o: ../templates/localefilter.h ../core/locale.h
who.o: ../confparser/confparser.h ../core/thread.h ../core/ticket.h
who.o: ../core/done.h

View File

@ -10,12 +10,16 @@
#include "content.h"
#include "../core/request.h"
#include "../core/error.h"
#include "../core/notify.h"
void Content::FunReloadTemplates()
{
log << log1 << "Content: reloading html templates" << logend;
templates.ReadTemplates();
notify.ReadTemplates(); // make sure that ReadTemplates() is using some kind of locking
request.session->done = Done::reloaded_templates;
request.session->done_status = Error::ok;

View File

@ -7,8 +7,8 @@
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdio>
#include "content.h"
#include "../core/request.h"

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -22,6 +22,7 @@
#include "lastcontainer.h"
#include "mounts.h"
#include "rebus.h"
#include "locale.h"
class Data
@ -58,7 +59,8 @@ public:
// fast cgi: group of the socket
std::string fcgi_socket_group;
std::string templates;
std::string templates_dir;
std::string templates_dir_default; // templates from winix
std::string db_database;
std::string db_user;
@ -109,6 +111,17 @@ public:
// directory for static files (for fastcgi authorizer mode)
std::string static_auth_dir;
// default locale: en pl
std::string locale_str;
// directory with locale files
std::string locale_dir;
// directory with default locale files (those from winix)
std::string locale_dir_default;
// below variables are based on the other config variables
// base_url_prefix + base_server
@ -120,6 +133,10 @@ public:
// base_url_static_auth_prefix + base_server
std::string base_url_static_auth;
Locale locale;
// end config members
// -----------------------------------------------------------------

190
core/locale.cpp Executable file
View File

@ -0,0 +1,190 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* All rights reserved.
*
*/
#include "locale.h"
#include "log.h"
Locale::Locale()
{
loc_tab.resize(lang_unknown);
default_lang = lang_en;
current_lang = lang_en;
}
void Locale::AddLocale(Lang lang)
{
ConfParser::Table::iterator i = loc_parser.table.begin();
for( ; i != loc_parser.table.end() ; ++i)
loc_tab[lang][i->first] = i->second;
}
void Locale::ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file)
{
if( static_cast<size_t>(lang) >= loc_tab.size() )
{
// ops, something wrong
return;
}
loc_tab[lang].clear();
bool read = false;
if( dir_def )
{
file_name = dir_def;
file_name += '/';
file_name += file;
if( loc_parser.Parse(file_name.c_str()) == ConfParser::ok )
{
read = true;
AddLocale(lang);
log << log3 << "Locale: read locale from: " << file_name << logend;
}
}
if( dir )
{
file_name = dir;
file_name += '/';
file_name += file;
if( loc_parser.Parse(file_name.c_str()) == ConfParser::ok )
{
read = true;
AddLocale(lang);
log << log3 << "Locale: read locale from: " << file_name << logend;
}
}
if( !read )
log << log1 << "Locale: cant open file for locale: " << file << logend;
}
void Locale::Read(const char * dir, const char * dir_def)
{
ReadFile(dir, dir_def, lang_pl, "pl");
ReadFile(dir, dir_def, lang_en, "en");
}
void Locale::Read(const std::string & dir, const std::string & dir_def)
{
if( dir_def.empty() )
Read(dir.c_str());
else
Read(dir.c_str(), dir_def.c_str());
}
void Locale::SetLang(Lang lang)
{
current_lang = lang;
}
Locale::Lang Locale::GetLang()
{
return current_lang;
}
void Locale::SetLangDef(Lang lang)
{
default_lang = lang_en;
}
const std::string & Locale::Get(const std::string & key) const
{
if( static_cast<size_t>(current_lang) >= loc_tab.size() )
{
// ops, something wrong
return empty;
}
// looking in the current_lang
ConfParser::Table::const_iterator i = loc_tab[current_lang].find(key);
if( i != loc_tab[current_lang].end() )
return i->second;
if( current_lang == default_lang )
return empty;
if( static_cast<size_t>(default_lang) >= loc_tab.size() )
{
// ops, something wrong
return empty;
}
// looking in a default language
i = loc_tab[default_lang].find(key);
if( i != loc_tab[default_lang].end() )
return i->second;
// there is no such a key
return empty;
}
Locale::Lang Locale::StrToLang(const std::string & str)
{
if( str == "en" )
return lang_en;
else
if( str == "pl" )
return lang_pl;
return lang_unknown;
}
const char * Locale::LangToStr(Lang lang)
{
static char buffer[30];
switch(lang)
{
case lang_en:
sprintf(buffer, "en");
break;
case lang_pl:
sprintf(buffer, "pl");
break;
default:
sprintf(buffer, "unknown");
}
return buffer;
}
size_t Locale::Size()
{
return loc_tab.size();
}

66
core/locale.h Executable file
View File

@ -0,0 +1,66 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorelocale
#define headerfilecmslucorelocale
#include "../confparser/confparser.h"
#include <vector>
#include <string>
class Locale
{
public:
enum Lang
{
lang_en = 0,
lang_pl,
lang_unknown // should be last
};
Locale();
void Read(const char * dir, const char * dir_def = 0);
void Read(const std::string & dir, const std::string & dir_def);
const std::string & Get(const std::string & key) const;
// default is english
void SetLang(Lang lang);
Lang GetLang();
// which language is used instead if there is no a key in an other language
// default: lang_en
void SetLangDef(Lang lang);
static Lang StrToLang(const std::string & str);
static const char * LangToStr(Lang lang);
size_t Size();
private:
void AddLocale(Lang lang);
void ReadFile(const char * dir, const char * dir_def, Lang lang, const char * file);
std::vector<ConfParser::Table> loc_tab;
ConfParser loc_parser;
std::string file_name;
std::string empty;
Lang default_lang;
Lang current_lang;
};
#endif

View File

@ -7,6 +7,8 @@
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include "misc.h"
#include "log.h"
#include "data.h"
@ -538,3 +540,17 @@ bool ValidateEmail(const std::string & email)
return correct;
}
bool IsFile(const char * file)
{
struct stat sb;
return (stat(file, &sb) == 0);
}
bool IsFile(const std::string & file)
{
return IsFile(file.c_str());
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -30,7 +30,9 @@ public:
Notify();
~Notify();
bool Init(const std::string & tdir);
void ReadTemplates();
bool Init();
/*
this method addes an item to our special pool
@ -64,7 +66,6 @@ private:
std::list<NotifyMsg> notify_pool;
static Notify * obj;
std::string command;
std::string templates_dir;
TemplatesNotify templates_notify;
};

View File

@ -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();
//

View File

@ -28,6 +28,8 @@
class RequestController
{
Content content;
SessionManager session_manager;
bool BaseUrlRedirect();

View File

@ -1 +1 @@
<p class="iteminfo">Dodane przez: [dir_last_user], [dir_last_date_creation][if-no dir_last_dates_equal], ostatnio modyfikowany: [dir_last_date_modification][end]</p>
<p class="iteminfo">{added_by}: [dir_last_user], [dir_last_date_creation][if-no dir_last_dates_equal], {last_modified}: [dir_last_date_modification][end]</p>

View File

@ -1,3 +1,3 @@
<h1>Błąd 404</h1>
<h1>{error_404}</h1>
<p>Przykro nam ale podanej strony nie ma w naszym serwisie.</p>
<p>{error_404_msg}</p>

View File

@ -1,8 +1,8 @@
[if-any done_is_error]
[if-any done_status_incorrect_rebus]
<p class="error">Proszę rozwiązać rebus!</p>
<p class="error">{solve_rebus}</p>
[else]
[if-any done_status_spam]
<p class="error">Jesteś podejrzany jako spamer,<br> nie możesz nic wysłać do czasu zalogowania się!</p>
<p class="error">{suspected_spammer}</p>
[end]
[end]

View File

@ -1,3 +0,0 @@
<h1>Item required</h1>
<p>This function can only be used with an item</p>

View File

@ -1,5 +1,5 @@
[if-one doc_is_error done_is_error]
<h1>Przepraszamy ale wystąpiły problemy z wykonaniem tej operacji.</h1>
<p>Kod błędu: [if-one doc_is_error]doc:[doc_status][end], [if-one done_is_error]done:[done_status][end]</p>
<h1>{was_errors}</h1>
<p>{error_code}: [if-one doc_is_error]doc:[doc_status][end], [if-one done_is_error]done:[done_status][end]</p>
[end]

View File

@ -1,3 +1,5 @@
<h1>Brak dostępu</h1>
<h1>{access_denied}</h1>
<p>{access_denied_msg}</p>
<p>Przykro nam ale nie masz dostępu do tej części serwisu.</p>

View File

@ -1,8 +1,17 @@
<div>
[is mount_page_is "subject"]
[is mount_page_is "info"]
<h1 class="withinfo">[else]<h1>[end][item_subject]</h1>
<h1 class="withinfo">
[else]
<h1>
[end]