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:
2010-01-28 15:39:01 +00:00
parent 5dac8af300
commit 09d427b4ba
65 changed files with 1949 additions and 848 deletions

View File

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

View File

@@ -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<size_t>(lang) >= patterns.size() )
{
// ops, something wrong
return;
}
Ezc::Generator generator(notify_str, patterns[lang][pat_email_notify], functions);
generator.Generate();
}
TemplatesNotify::TemplatesNotify()
{
ClearPatterns();
}

View File

@@ -13,8 +13,9 @@
#include <iomanip>
#include <set>
#include <string>
#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<std::vector<Ezc::Pattern> > 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;
};