- added to FunctionBase: bool register_default_models (default true)

if true then winix will add default models for ezc templates such as "request", "item", etc.
- some methods from templates/item.cpp moved to Item
This commit is contained in:
2021-06-20 18:04:50 +02:00
parent e7c7324058
commit 79eda7abb0
21 changed files with 271 additions and 83 deletions

View File

@@ -38,6 +38,7 @@
#include "core/request.h"
#include "templates/templates.h"
#include "core/session.h"
#include "core/log.h"
@@ -85,7 +86,10 @@ void Item::fields()
field(L"can_be_removed", &Item::can_be_removed);
field(L"has_read_access", &Item::has_read_access);
field(L"has_write_access", &Item::has_write_access);
field(L"has_read_write_access", &Item::has_read_write_access);
field(L"has_read_exec_access", &Item::has_read_exec_access);
field(L"execute", &Item::execute);
// may we should add a method setTypeFromInt(int t)?
@@ -374,17 +378,27 @@ bool Item::can_be_removed() const
}
bool Item::has_read_access()
bool Item::has_read_access() const
{
return item_content.has_read_access();
}
bool Item::has_write_access()
bool Item::has_write_access() const
{
return item_content.has_write_access();
}
bool Item::has_read_write_access() const
{
return item_content.has_read_write_access();
}
bool Item::has_read_exec_access() const
{
return item_content.has_read_exec_access();
}
bool Item::type_is_symlink() const
{
@@ -603,10 +617,43 @@ void Item::url_is(EzcEnv & env)
}
//bool Item::has_read_accessxx() const
//{
//
//}
void Item::execute(EzcEnv & env)
{
if( has_read_access() )
{
PatternCacher * pattern_cacher = get_pattern_cacher();
Request * request = get_request();
Config * config = get_config();
if( pattern_cacher && request && config )
{
HtmlTextStream item_run_content;
TemplatesFunctions::EzcGen ezc_generator;
Ezc::Pattern * p = pattern_cacher->GetPattern(*this);
TemplatesFunctions::InitGenerator(ezc_generator, request->models);
ezc_generator.SetPattern(*p);
if( config->allow_ezc_frames_in_executable_items )
ezc_generator.Generate(item_run_content, request->out_streams);
else
ezc_generator.Generate(item_run_content);
ItemContent::print_content(env.out, item_run_content.Str(), item_content.content_raw_type, config->html_filter);
}
}
else
{
Log * log = get_logger();
if( log )
{
(*log) << "Item::execute: permission denied, no read_exec access to item id: " << id << ", url: " << url << ", subject" << subject;
}
}
}