added: two options to the config:

ezc_error_prefix (string)
        ezc_error_postfix (string)
        // prefix and postfix used when there is an error in Ezc patterns
        // default:
        // prefix:  "<!-- "
        // postfix: " -->"
added:  Ezc::Blocks to templates
added:  although patterns have pointers to functions and blocks cached
        the Ezc::Generator should use SetFunctions() and SetBlocks() method
        in order to correctly recognize variables (aliases)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@978 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2014-10-19 21:20:09 +00:00
parent 5266a7e4e5
commit fb18b2238e
27 changed files with 1105 additions and 949 deletions

View File

@@ -58,6 +58,7 @@ PatternCacher pattern_cacher; // patterns for user items (files with an exec
Locale locale;
EzcFun ezc_functions;
Ezc::Blocks ezc_blocks;
LocaleFilter locale_filter;
HTMLFilter html_filter;
@@ -157,16 +158,7 @@ Ezc::Pattern * p = 0;
if( p )
{
content_gen.TrimWhite(gen_trim_white);
content_gen.SkipNewLine(gen_skip_new_line);
content_gen.RecognizeSpecialChars(gen_use_special_chars);
content_gen.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
/*
* !! IMPROVE ME
* add blocks and variables
*/
//content_gen.AddFunctions();
InitGenerator(content_gen);
content_gen.SetPattern(*p);
content_gen.Generate(i.out);
}
@@ -852,11 +844,15 @@ using namespace TemplatesFunctions;
patterns.Clear();
index_patterns.Clear();
change_patterns.Clear();
ezc_blocks.Clear();
//a pattern cacher chyba tez powinien byc wyczyszczony (tylko tam jest jakies zabezpieczenie)
//bo moze miec skeszowane bloki....
pat_index = patterns.Add(config->templates_index);
pat_index_fullscreen = patterns.Add(L"index_fullscreen.html");
pat_err_404 = patterns.Add(L"err_404.html");
pat_err_per_denied = patterns.Add(L"err_per_denied.html");
pat_index_fullscreen = patterns.Add(L"index_fullscreen.html"); // !! IMPROVE ME name to the config
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
ReadTemplatesForFunctions();
ReadIndexTemplates();
@@ -864,6 +860,11 @@ using namespace TemplatesFunctions;
plugin.Call((Session*)0, WINIX_ADD_TEMPLATE);
patterns.RebuildCache();
ezc_blocks.CacheBlocks(ezc_blocks);
ezc_blocks.CacheFunctions(ezc_functions);
pattern_cacher.RebuildCache();
SetHtmlFilter();
log << log3 << "Templates: there are " << patterns.Size() << " patterns"
@@ -881,8 +882,10 @@ void Templates::Init()
using namespace TemplatesFunctions;
patterns.SetDirectories(config->templates_dir, config->templates_dir_default);
patterns.SetEzcCommentary(config->ezc_error_prefix, config->ezc_error_postfix);
pattern_cacher.SetWhenDelete(config->pattern_cacher_when_delete, config->pattern_cacher_how_many_delete);
pattern_cacher.SetEzcCommentary(config->ezc_error_prefix, config->ezc_error_postfix);
CreateFunctions(); // create functions first (functions will be cached by patterns)
ReadTemplates();
}
@@ -974,15 +977,8 @@ using namespace TemplatesFunctions;
if( index )
{
generator.TrimWhite(gen_trim_white);
generator.SkipNewLine(gen_skip_new_line);
generator.RecognizeSpecialChars(gen_use_special_chars);
generator.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
InitGenerator(generator);
generator.SetPattern(*index);
/*
* !! IMPROVE ME
* add blocks and variables
*/
generator.Generate(cur->request->out_streams);
}
else
@@ -1018,15 +1014,8 @@ void Templates::Generate(Ezc::Pattern & pattern)
{
using namespace TemplatesFunctions;
generator.TrimWhite(gen_trim_white);
generator.SkipNewLine(gen_skip_new_line);
generator.RecognizeSpecialChars(gen_use_special_chars);
generator.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
InitGenerator(generator);
generator.SetPattern(pattern);
/*
* !! IMPROVE ME
* add blocks and variables
*/
generator.Generate(cur->request->out_streams);
}
@@ -1074,11 +1063,13 @@ Templates::Templates()
using namespace TemplatesFunctions;
patterns.SetEzcFunctions(&ezc_functions);
patterns.SetEzcBlocks(&ezc_blocks);
patterns.SetLocale(&locale);
patterns.SetLocaleFilter(&locale_filter);
index_patterns.SetPatterns(&patterns);
change_patterns.SetPatterns(&patterns);
pattern_cacher.SetEzcFunctions(&ezc_functions);
pattern_cacher.SetEzcBlocks(&ezc_blocks);
}