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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user