added: item content type: raw
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@549 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -32,7 +32,7 @@ void done_status(Info & i)
|
||||
|
||||
void done_status_no_item(Info & i)
|
||||
{
|
||||
i.result = request.session->done_status == Error::db_no_item;
|
||||
i.result = request.session->done_status == Error::no_item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,36 +63,79 @@ void item_content_noescape(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void item_print_content(Info & i)
|
||||
void item_content_type_is(Info & i)
|
||||
{
|
||||
if( request.item.content_type == 0 ) // simple txt
|
||||
switch(request.item.content_type)
|
||||
{
|
||||
HtmlEscape(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 1 ) // formatted txt
|
||||
{
|
||||
HtmlEscapeFormTxt(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 2 ) // html
|
||||
{
|
||||
if( request.CanUseHtml(request.item.user_id) )
|
||||
i.out << request.item.content;
|
||||
else
|
||||
HtmlEscape(i.out, request.item.content);
|
||||
}
|
||||
else
|
||||
if( request.item.content_type == 3 ) // bbcode
|
||||
{
|
||||
if( request.CanUseBBCode(request.item.user_id) )
|
||||
HtmlEscape(i.out, request.item.content); // tutaj bedzie parsowanie bbcodu i tworzenie odpowiadajacego mu html-a
|
||||
else
|
||||
i.out << request.item.content;
|
||||
case Item::ct_text:
|
||||
i.out_string = "text";
|
||||
break;
|
||||
|
||||
case Item::ct_formatted_text:
|
||||
i.out_string = "formatted text";
|
||||
break;
|
||||
|
||||
case Item::ct_html:
|
||||
i.out_string = "html";
|
||||
break;
|
||||
|
||||
case Item::ct_bbcode:
|
||||
i.out_string = "bbcode";
|
||||
break;
|
||||
|
||||
case Item::ct_raw:
|
||||
i.out_string = "raw";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_print_content(std::ostringstream & out, const std::string & content, Item::ContentType content_type)
|
||||
{
|
||||
if( content_type == Item::ct_text )
|
||||
{
|
||||
HtmlEscape(out, content);
|
||||
}
|
||||
else
|
||||
if( content_type == Item::ct_formatted_text )
|
||||
{
|
||||
HtmlEscapeFormTxt(out, content);
|
||||
}
|
||||
else
|
||||
if( content_type == Item::ct_html )
|
||||
{
|
||||
if( request.CanUseHtml(request.item.user_id) )
|
||||
out << content;
|
||||
else
|
||||
HtmlEscape(out, content);
|
||||
}
|
||||
else
|
||||
if( content_type == Item::ct_bbcode )
|
||||
{
|
||||
if( request.CanUseBBCode(request.item.user_id) )
|
||||
out << content; // !! tutaj bedzie parsowanie bbcodu i tworzenie odpowiadajacego mu html-a
|
||||
else
|
||||
HtmlEscape(out, content);
|
||||
}
|
||||
else
|
||||
if( content_type == Item::ct_raw )
|
||||
{
|
||||
if( request.CanUseRaw(request.item.user_id) )
|
||||
out << content;
|
||||
else
|
||||
HtmlEscape(out, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void item_print_content(Info & i)
|
||||
{
|
||||
item_print_content(i.out, request.item.content, request.item.content_type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_privileges(Info & i)
|
||||
{
|
||||
i.out << std::setbase(8) << request.item.privileges << std::setbase(10);
|
||||
@@ -212,6 +255,7 @@ void item_dates_equal(Info & i)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_run(Info & i)
|
||||
{
|
||||
if( !request.is_item )
|
||||
@@ -227,8 +271,12 @@ void item_run(Info & i)
|
||||
}
|
||||
|
||||
Ezc::Pattern * p = pattern_cacher.GetPattern(request.item);
|
||||
Ezc::Generator gen(i.out, *p, functions);
|
||||
std::ostringstream item_run_content;
|
||||
|
||||
Ezc::Generator gen(item_run_content, *p, functions);
|
||||
gen.Generate();
|
||||
|
||||
item_print_content(i.out, item_run_content.str(), request.item.content_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,33 +402,10 @@ void item_tab_print_content(Info & i)
|
||||
if( item_index >= request.item_table.size() )
|
||||
return;
|
||||
|
||||
int type = request.item_table[item_index].content_type;
|
||||
std::string & content = request.item_table[item_index].content;
|
||||
Item::ContentType type = request.item_table[item_index].content_type;
|
||||
|
||||
if( type == 0 ) // simple txt
|
||||
{
|
||||
HtmlEscape(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 1 ) // formatted txt
|
||||
{
|
||||
HtmlEscapeFormTxt(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 2 ) // html
|
||||
{
|
||||
if( request.CanUseHtml(request.item_table[item_index].user_id) )
|
||||
i.out << request.item_table[item_index].content;
|
||||
else
|
||||
HtmlEscape(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
else
|
||||
if( type == 3 ) // bbcode
|
||||
{
|
||||
if( request.CanUseBBCode(request.item_table[item_index].user_id) )
|
||||
HtmlEscape(i.out, request.item_table[item_index].content); // tutaj bedzie parsowanie bbcodu i tworzenie odpowiadajacego mu html-a
|
||||
else
|
||||
i.out << request.item_table[item_index].content;
|
||||
}
|
||||
item_print_content(i.out, content, type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -146,18 +146,18 @@ Ezc::Pattern * p = 0;
|
||||
p = content_for_function();
|
||||
break;
|
||||
|
||||
case Error::item_required:
|
||||
case Error::no_item:
|
||||
p = &pat_err_item_required;
|
||||
break;
|
||||
|
||||
case Error::permision_denied:
|
||||
case Error::permission_denied:
|
||||
case Error::cant_change_user:
|
||||
case Error::cant_change_group:
|
||||
case Error::cant_change_privileges:
|
||||
p = &pat_err_per_denied;
|
||||
break;
|
||||
|
||||
case Error::db_no_item:
|
||||
//case Error::no_item:
|
||||
case Error::no_function:
|
||||
case Error::unknown_param:
|
||||
p = &pat_err_404;
|
||||
@@ -226,6 +226,7 @@ void Templates::CreateFunctions()
|
||||
functions.Insert("item_subject_noescape", item_subject_noescape);
|
||||
functions.Insert("item_content", item_content);
|
||||
functions.Insert("item_content_noescape", item_content_noescape);
|
||||
functions.Insert("item_content_type_is", item_content_type_is);
|
||||
functions.Insert("item_print_content", item_print_content);
|
||||
functions.Insert("item_privileges", item_privileges);
|
||||
functions.Insert("item_dir", item_dir);
|
||||
@@ -307,9 +308,12 @@ void Templates::CreateFunctions()
|
||||
/*
|
||||
user
|
||||
*/
|
||||
functions.Insert("user_name", user_name);
|
||||
functions.Insert("user_logged", user_logged);
|
||||
functions.Insert("user_super_user", user_super_user);
|
||||
functions.Insert("user_name", user_name);
|
||||
functions.Insert("user_logged", user_logged);
|
||||
functions.Insert("user_super_user", user_super_user);
|
||||
functions.Insert("user_can_use_html", user_can_use_html);
|
||||
functions.Insert("user_can_use_bbcode", user_can_use_bbcode);
|
||||
functions.Insert("user_can_use_raw", user_can_use_raw);
|
||||
|
||||
|
||||
/*
|
||||
@@ -487,13 +491,22 @@ void Templates::ReadTemplates()
|
||||
|
||||
void Templates::Generate()
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
|
||||
using namespace TemplatesFunctions;
|
||||
|
||||
Ezc::Generator generator(request.page, pat_index, functions);
|
||||
|
||||
generator.Generate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Templates::GenerateRunRaw()
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
|
||||
Ezc::Info info(request.page);
|
||||
info.iter = 0;
|
||||
info.result = false;
|
||||
|
||||
item_run(info);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace TemplatesFunctions
|
||||
void item_subject_noescape(Info & i);
|
||||
void item_content(Info & i);
|
||||
void item_content_noescape(Info & i);
|
||||
void item_content_type_is(Info & i);
|
||||
void item_print_content(std::ostringstream & out, const std::string & content, Item::ContentType content_type);
|
||||
void item_print_content(Info & i);
|
||||
void item_privileges(Info & i);
|
||||
void item_dir(Info & i);
|
||||
@@ -80,7 +82,6 @@ namespace TemplatesFunctions
|
||||
void item_run(Info & i);
|
||||
void item_guest_name(Info & i);
|
||||
|
||||
// !! wprowadzic item_old_is ?
|
||||
void item_old_id(Info & i);
|
||||
void item_old_subject(Info & i);
|
||||
void item_old_subject_noescape(Info & i);
|
||||
@@ -146,7 +147,9 @@ namespace TemplatesFunctions
|
||||
void user_name(Info & i);
|
||||
void user_logged(Info & i);
|
||||
void user_super_user(Info & i);
|
||||
|
||||
void user_can_use_html(Info & i);
|
||||
void user_can_use_bbcode(Info & i);
|
||||
void user_can_use_raw(Info & i);
|
||||
|
||||
/*
|
||||
privileges
|
||||
@@ -246,6 +249,7 @@ public:
|
||||
void ReadTemplates();
|
||||
void CreateFunctions();
|
||||
void Generate();
|
||||
void GenerateRunRaw();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -43,8 +43,31 @@ void user_super_user(Info & i)
|
||||
}
|
||||
|
||||
|
||||
void user_can_use_html(Info & i)
|
||||
{
|
||||
if( !request.session->puser )
|
||||
i.result = false;
|
||||
else
|
||||
i.result = request.CanUseHtml(request.session->puser->id);
|
||||
}
|
||||
|
||||
|
||||
void user_can_use_bbcode(Info & i)
|
||||
{
|
||||
if( !request.session->puser )
|
||||
i.result = false;
|
||||
else
|
||||
i.result = request.CanUseBBCode(request.session->puser->id);
|
||||
}
|
||||
|
||||
|
||||
void user_can_use_raw(Info & i)
|
||||
{
|
||||
if( !request.session->puser )
|
||||
i.result = false;
|
||||
else
|
||||
i.result = request.CanUseRaw(request.session->puser->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user