renamed: WinixModel -> WinixModelDeprecated (this class will be removed)

added: WinixModel (models/winixmodel.h|cpp) - a class inheriting from morm::WinixModel, we have methods such as: get_config(), get_logger(), get_request()
       and this class will be a base class for our models
added: WinixModelConnector (models/winixmodelconnector.h|cpp) - a class inheriting from morm::WinixModelConnector
       this connector we are using instead of morm::ModelConnector - there are pointers to winix objects there (config, request, log)
added to Request: Ezc::Models models
removed from TemplatesFunctions: Ezc::Models ezc_models;
changed: ImgCrop winix functions is using its own item_tab vector now (not finished yet)
added: Item::is(), Item::link(), ItemContent::print_content()
This commit is contained in:
2021-06-16 18:07:44 +02:00
parent 9688b1a26a
commit 6dddc5e948
63 changed files with 654 additions and 225 deletions

View File

@@ -52,6 +52,12 @@ void HtmlTextStream::Clear()
}
void HtmlTextStream::clear()
{
Clear();
}
/*
without escaping

View File

@@ -85,6 +85,7 @@ public:
* clearing the buffer and setting 'escape' flag to true
*/
void Clear();
void clear(); // utf8 methods call clear(), in the future Clear() will be renamed to clear()
/*

View File

@@ -74,10 +74,10 @@ void insert_page_run(Info & i)
info.run_content.Clear();
InitGenerator(info.ezc_gen);
InitGenerator(info.ezc_gen, cur->request->models);
info.ezc_gen.SetPattern(*pat);
info.ezc_gen.Generate(info.run_content);
item_print_content(i.out, info.run_content.Str(), info.item.item_content.content_raw_type);
ItemContent::print_content(i.out, info.run_content.Str(), info.item.item_content.content_raw_type, config->html_filter);
insert_page_cur -= 1;
}
@@ -119,7 +119,7 @@ void insert_page(Info & i)
insert_page_run(i);
else
if( system->HasReadAccess(info.item) )
item_print_content(i.out, info.item.item_content.content_raw, info.item.item_content.content_raw_type);
ItemContent::print_content(i.out, info.item.item_content.content_raw, info.item.item_content.content_raw_type, config->html_filter);
}
}

View File

@@ -46,7 +46,6 @@ namespace Winix
namespace TemplatesFunctions
{
static BBCODEParser bbcode_parser;
static HtmlTextStream item_run_content;
static EzcGen ezc_generator;
@@ -126,52 +125,11 @@ void item_content_type_is(Info & i)
}
void item_print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type)
{
if( config->html_filter && !ItemContent::CanContentBeHtmlFiltered(content_type) )
out << R("<nofilter>");
if( content_type == ItemContent::ct_text )
{
out << content;
}
else
if( content_type == ItemContent::ct_formatted_text )
{
HtmlEscapeFormTxt(out, content);
}
else
if( content_type == ItemContent::ct_bbcode )
{
static std::wstring out_temp;
out_temp.clear();
out_temp.reserve(content.size()*2);
bbcode_parser.Filter(content.c_str(), out_temp);
out << R(out_temp);
}
else
{
// ct_html, ct_other
out << R(content);
}
if( config->html_filter && !ItemContent::CanContentBeHtmlFiltered(content_type) )
out << R("</nofilter>");
}
void item_content_is_empty(Info & i)
{
i.res = cur->request->last_item->item_content.content_raw.empty();
}
void item_print_content(Info & i)
{
item_print_content(i.out, cur->request->last_item->item_content.content_raw, cur->request->last_item->item_content.content_raw_type);
}
void item_privileges(Info & i)
{
@@ -332,7 +290,7 @@ void item_run(Info & i)
Ezc::Pattern * p = pattern_cacher.GetPattern(*cur->request->last_item);
item_run_content.Clear();
InitGenerator(ezc_generator);
InitGenerator(ezc_generator, cur->request->models);
ezc_generator.SetPattern(*p);
if( config->allow_ezc_frames_in_executable_items )
@@ -340,7 +298,7 @@ void item_run(Info & i)
else
ezc_generator.Generate(item_run_content);
item_print_content(i.out, item_run_content.Str(), cur->request->last_item->item_content.content_raw_type);
ItemContent::print_content(i.out, item_run_content.Str(), cur->request->last_item->item_content.content_raw_type, config->html_filter);
}
else
{
@@ -490,7 +448,7 @@ void item_can_content_be_html_filtered(Info & i)
}
/*
static size_t item_index;
@@ -739,7 +697,7 @@ void item_tab_run(Info & i)
{
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item_tab[item_index]);
item_run_content.Clear();
InitGenerator(ezc_generator);
InitGenerator(ezc_generator, cur->request->models);
ezc_generator.SetPattern(*p);
if( config->allow_ezc_frames_in_executable_items )
@@ -884,7 +842,7 @@ void item_tab_meta_tab_has_next(Info & i)
if( item_index < cur->request->item_tab.size() )
space_list_tab_has_next(i, cur->request->item_tab[item_index].item_content.meta, L"item_tab_meta_tab");
}
*/

View File

@@ -48,7 +48,6 @@ namespace TemplatesFunctions
extern EzcFun ezc_functions;
extern Ezc::Blocks ezc_blocks;
extern Ezc::Vars ezc_vars;
extern Ezc::Models ezc_models;
void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in)
@@ -93,7 +92,7 @@ int was_enter = 0; // how many enteres there were before
void InitGenerator(EzcGen & gen)
void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models)
{
gen.TrimWhite(gen_trim_white);
gen.SkipNewLine(gen_skip_new_line);

View File

@@ -63,7 +63,7 @@ HtmlTextStream::RawText<RawType> R(const RawType & par)
}
void InitGenerator(EzcGen & gen);
void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models);
void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in);

View File

@@ -63,7 +63,6 @@ EzcFun ezc_functions;
Ezc::Blocks ezc_blocks;
Ezc::Objects<HtmlTextStream> ezc_objects;
Ezc::Vars ezc_vars;
Ezc::Models ezc_models;
LocaleFilter locale_filter;
HTMLFilter html_filter;
@@ -186,7 +185,7 @@ Ezc::Pattern * p = 0;
if( p )
{
InitGenerator(content_gen);
InitGenerator(content_gen, cur->request->models);
content_gen.SetPattern(*p);
content_gen.Generate(i.out, cur->request->out_streams);
}
@@ -438,7 +437,6 @@ void Templates::CreateFunctions()
ezc_functions.Insert("item_content", item_content);
ezc_functions.Insert("item_content_noescape", item_content_noescape);
ezc_functions.Insert("item_content_type_is", item_content_type_is);
ezc_functions.Insert("item_print_content", item_print_content);
ezc_functions.Insert("item_privileges", item_privileges);
ezc_functions.Insert("item_dir", item_dir);
ezc_functions.Insert("item_url", item_url);
@@ -486,6 +484,7 @@ void Templates::CreateFunctions()
ezc_functions.Insert("item_admin_meta_tab_has_next", item_admin_meta_tab_has_next);
ezc_functions.Insert("item_can_content_be_html_filtered", item_can_content_be_html_filtered);
/*
ezc_functions.Insert("item_tab", item_tab);
ezc_functions.Insert("item_tab_index", item_tab_index);
ezc_functions.Insert("item_tab_id", item_tab_id);
@@ -530,7 +529,7 @@ void Templates::CreateFunctions()
ezc_functions.Insert("item_tab_meta_tab", item_tab_meta_tab);
ezc_functions.Insert("item_tab_meta_tab_value", item_tab_meta_tab_value);
ezc_functions.Insert("item_tab_meta_tab_has_next", item_tab_meta_tab_has_next);
*/
/*
last
@@ -1024,8 +1023,6 @@ using namespace TemplatesFunctions;
log << log4 << "Templates: patterns cache size: " << pattern_cacher.Size() << logend;
pattern_cacher.DeleteOldPatterns();
ezc_models.Clear();
}
@@ -1128,7 +1125,7 @@ using namespace TemplatesFunctions;
if( index )
{
InitGenerator(generator);
InitGenerator(generator, cur->request->models);
generator.SetPattern(*index);
generator.Generate(cur->request->out_main_stream, cur->request->out_streams);
}
@@ -1147,7 +1144,7 @@ void Templates::Generate(Ezc::Pattern & pattern)
using namespace TemplatesFunctions;
ezc_vars.clear();
InitGenerator(generator);
InitGenerator(generator, cur->request->models);
generator.SetPattern(pattern);
generator.Generate(cur->request->out_main_stream, cur->request->out_streams);
}

View File

@@ -96,9 +96,6 @@ namespace TemplatesFunctions
extern bool gen_skip_new_line;
extern bool gen_use_special_chars;
extern Ezc::Models ezc_models;
/*
adduser
@@ -331,8 +328,6 @@ namespace TemplatesFunctions
void item_content_type_is(Item & item, Info & i);
void item_content_type_is(Info & i);
void item_content_is_empty(Info & i);
void item_print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type);
void item_print_content(Info & i);
void item_privileges(Info & i);
void item_dir(Info & i);
void item_url(Info & i);
@@ -379,6 +374,7 @@ namespace TemplatesFunctions
void item_admin_meta_tab_has_next(Info & i);
void item_can_content_be_html_filtered(Info & i);
/*
void item_tab(Info & i);
void item_tab_index(Info & i);
void item_tab_id(Info & i);
@@ -423,7 +419,7 @@ namespace TemplatesFunctions
void item_tab_meta_tab(Info & i);
void item_tab_meta_tab_value(Info & i);
void item_tab_meta_tab_has_next(Info & i);
*/
/*
last