some methods from templates/item.cpp moved to ItemContent
This commit is contained in:
parent
801fc062ef
commit
ade96bf6d3
|
@ -87,8 +87,8 @@
|
|||
<tr>
|
||||
<td>d</td>
|
||||
<td>[child_dirs.content.privileges_octal]</td>
|
||||
<td>[child_dirs.content.user_name]</td>
|
||||
<td>[child_dirs.content.group_name]</td>
|
||||
<td>[if child_dirs.content.has_user][child_dirs.content.user.login][end]</td>
|
||||
<td>[if child_dirs.content.has_group][child_dirs.content.group.name][end]</td>
|
||||
<td>
|
||||
[if child_dirs.is_parent_for_current_dir]
|
||||
<a href="[doc_base_url][dir_parent_without_slash][if winix_function_param_is "dirls"]/ls/l/dirls[end]">../</a>
|
||||
|
@ -101,10 +101,10 @@
|
|||
|
||||
[for items]
|
||||
<tr>
|
||||
<td>[if items.type_is_symlink]l[else][if items.has_static_file]s[else]-[end][end]</td>
|
||||
<td>[if items.type_is_symlink]l[else][if items.content.has_static_file]s[else]-[end][end]</td>
|
||||
<td>[items.content.privileges_octal]</td>
|
||||
<td>[items.content.user_name]</td>
|
||||
<td>[items.content.group_name]</td>
|
||||
<td>[if items.content.has_user][items.content.user.login][end]</td>
|
||||
<td>[if items.content.has_group][items.content.group.name][end]</td>
|
||||
<td><a href="[doc_base_url][dir][items.url]">[items.url]</a>[if items.type_is_symlink] -> [items.content.link_to][end]</td>
|
||||
</tr>
|
||||
[end]
|
||||
|
|
|
@ -39,6 +39,42 @@ namespace Winix
|
|||
{
|
||||
|
||||
|
||||
Group::Group()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void Group::fields()
|
||||
{
|
||||
field(L"id", id, morm::FT::no_insertable | morm::FT::no_updatable | morm::FT::primary_key);
|
||||
field(L"name", name);
|
||||
}
|
||||
|
||||
|
||||
void Group::table()
|
||||
{
|
||||
table_name(L"core", L"group");
|
||||
}
|
||||
|
||||
|
||||
void Group::after_insert()
|
||||
{
|
||||
get_last_sequence_for_primary_key(L"core.group_id_seq", id);
|
||||
}
|
||||
|
||||
|
||||
void Group::Clear()
|
||||
{
|
||||
id = -1;
|
||||
name.clear();
|
||||
//members.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool Group::do_migration(int & current_table_version)
|
||||
{
|
||||
bool ok = true;
|
||||
|
|
|
@ -53,36 +53,13 @@ public:
|
|||
std::wstring name; // group name
|
||||
//std::vector<long> members; // users id
|
||||
|
||||
Group()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
Group();
|
||||
|
||||
void fields();
|
||||
void table();
|
||||
void after_insert();
|
||||
|
||||
void fields()
|
||||
{
|
||||
field(L"id", id, morm::FT::no_insertable | morm::FT::no_updatable | morm::FT::primary_key);
|
||||
field(L"name", name);
|
||||
}
|
||||
|
||||
void table()
|
||||
{
|
||||
table_name(L"core", L"group");
|
||||
}
|
||||
|
||||
void after_insert()
|
||||
{
|
||||
get_last_sequence_for_primary_key(L"core.group_id_seq", id);
|
||||
}
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
name.clear();
|
||||
//members.clear();
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
||||
bool do_migration(int & current_table_version);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "core/request.h"
|
||||
#include "core/users.h"
|
||||
#include "core/groups.h"
|
||||
#include "templates/miscspace.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
@ -88,6 +89,8 @@ void ItemContent::fields()
|
|||
field(L"print_content", &ItemContent::print_content);
|
||||
field(L"has_static_file", &ItemContent::has_static_file);
|
||||
field(L"privileges_octal", &ItemContent::privileges_octal);
|
||||
field(L"has_user", &ItemContent::has_user);
|
||||
field(L"has_group", &ItemContent::has_group);
|
||||
field(L"user", &ItemContent::user);
|
||||
field(L"group", &ItemContent::group);
|
||||
field(L"type_is", &ItemContent::type_is);
|
||||
|
@ -101,6 +104,19 @@ void ItemContent::fields()
|
|||
field(L"has_thumb", &ItemContent::has_thumb);
|
||||
field(L"display_user_name", &ItemContent::display_user_name);
|
||||
|
||||
field(L"meta_to_str", &ItemContent::meta_to_str);
|
||||
field(L"meta_prop", &ItemContent::meta_prop);
|
||||
field(L"meta_prop_no_escape", &ItemContent::meta_prop_no_escape);
|
||||
field(L"meta_prop_tab", &ItemContent::meta_prop_tab);
|
||||
field(L"meta_prop_tab_value", &ItemContent::meta_prop_tab_value);
|
||||
field(L"meta_prop_tab_has_next",&ItemContent::meta_prop_tab_has_next);
|
||||
|
||||
field(L"admin_meta_to_str", &ItemContent::admin_meta_to_str);
|
||||
field(L"admin_meta_prop", &ItemContent::admin_meta_prop);
|
||||
field(L"admin_meta_prop_no_escape", &ItemContent::admin_meta_prop_no_escape);
|
||||
field(L"admin_meta_prop_tab", &ItemContent::admin_meta_prop_tab);
|
||||
field(L"admin_meta_prop_tab_value", &ItemContent::admin_meta_prop_tab_value);
|
||||
field(L"admin_meta_prop_tab_has_next", &ItemContent::admin_meta_prop_tab_has_next);
|
||||
|
||||
|
||||
// IMPROVEME prepare a setter functions which tests whether content_raw_type_helper and content_parsed_type_helper are correct values
|
||||
|
@ -433,6 +449,17 @@ void ItemContent::privileges_octal(EzcEnv & env)
|
|||
}
|
||||
|
||||
|
||||
bool ItemContent::has_user() const
|
||||
{
|
||||
return user_id != -1;
|
||||
}
|
||||
|
||||
|
||||
bool ItemContent::has_group() const
|
||||
{
|
||||
return group_id != -1;
|
||||
}
|
||||
|
||||
void ItemContent::user(morm::ModelWrapper ** model_wrapper)
|
||||
{
|
||||
Users * users = get_users();
|
||||
|
@ -576,5 +603,75 @@ void ItemContent::display_user_name(EzcEnv & env)
|
|||
}
|
||||
|
||||
|
||||
void ItemContent::meta_to_str(EzcEnv & env)
|
||||
{
|
||||
meta.serialize_to_space_stream(env.out, true);
|
||||
}
|
||||
|
||||
void ItemContent::meta_prop(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_value(env, meta);
|
||||
}
|
||||
|
||||
void ItemContent::meta_prop_no_escape(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_value(env, meta, false);
|
||||
}
|
||||
|
||||
|
||||
void ItemContent::meta_prop_tab(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_list_tab(env, meta);
|
||||
}
|
||||
|
||||
void ItemContent::meta_prop_tab_value(EzcEnv & env)
|
||||
{
|
||||
// FIXME there is no "item_meta_tab" now
|
||||
TemplatesFunctions::space_list_tab_value(env, meta, L"item_meta_tab");
|
||||
}
|
||||
|
||||
void ItemContent::meta_prop_tab_has_next(EzcEnv & env)
|
||||
{
|
||||
// FIXME there is no "item_meta_tab" now
|
||||
TemplatesFunctions::space_list_tab_has_next(env, meta, L"item_meta_tab");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ItemContent::admin_meta_to_str(EzcEnv & env)
|
||||
{
|
||||
meta_admin.serialize_to_space_stream(env.out, true);
|
||||
}
|
||||
|
||||
void ItemContent::admin_meta_prop(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_value(env, meta_admin);
|
||||
}
|
||||
|
||||
void ItemContent::admin_meta_prop_no_escape(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_value(env, meta_admin, false);
|
||||
}
|
||||
|
||||
|
||||
void ItemContent::admin_meta_prop_tab(EzcEnv & env)
|
||||
{
|
||||
TemplatesFunctions::space_list_tab(env, meta_admin);
|
||||
}
|
||||
|
||||
void ItemContent::admin_meta_prop_tab_value(EzcEnv & env)
|
||||
{
|
||||
// FIXME there is no "item_admin_meta_tab" now
|
||||
TemplatesFunctions::space_list_tab_value(env, meta_admin, L"item_admin_meta_tab");
|
||||
}
|
||||
|
||||
void ItemContent::admin_meta_prop_tab_has_next(EzcEnv & env)
|
||||
{
|
||||
// FIXME there is no "item_admin_meta_tab" now
|
||||
TemplatesFunctions::space_list_tab_has_next(env, meta_admin, L"item_admin_meta_tab");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
|
|
@ -270,6 +270,8 @@ public:
|
|||
|
||||
bool is_sticky_bit_set() const;
|
||||
|
||||
bool has_user() const;
|
||||
bool has_group() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -292,7 +294,18 @@ protected:
|
|||
void file_type_is_sound(EzcEnv & env);
|
||||
void has_thumb(EzcEnv & env);
|
||||
void display_user_name(EzcEnv & env);
|
||||
|
||||
void meta_to_str(EzcEnv & env);
|
||||
void meta_prop(EzcEnv & env);
|
||||
void meta_prop_no_escape(EzcEnv & env);
|
||||
void meta_prop_tab(EzcEnv & env);
|
||||
void meta_prop_tab_value(EzcEnv & env);
|
||||
void meta_prop_tab_has_next(EzcEnv & env);
|
||||
void admin_meta_to_str(EzcEnv & env);
|
||||
void admin_meta_prop(EzcEnv & env);
|
||||
void admin_meta_prop_no_escape(EzcEnv & env);
|
||||
void admin_meta_prop_tab(EzcEnv & env);
|
||||
void admin_meta_prop_tab_value(EzcEnv & env);
|
||||
void admin_meta_prop_tab_has_next(EzcEnv & env);
|
||||
|
||||
MORM_MEMBER_FIELD(ItemContent)
|
||||
|
||||
|
|
|
@ -375,75 +375,75 @@ void item_sort(Info & i)
|
|||
|
||||
|
||||
|
||||
void item_meta_str(Info & i)
|
||||
{
|
||||
cur->request->last_item->item_content.meta.serialize_to_space_stream(i.out, true);
|
||||
}
|
||||
|
||||
|
||||
void item_meta(Info & i)
|
||||
{
|
||||
space_value(i, cur->request->last_item->item_content.meta);
|
||||
}
|
||||
|
||||
|
||||
void item_meta_noescape(Info & i)
|
||||
{
|
||||
space_value(i, cur->request->last_item->item_content.meta, false);
|
||||
}
|
||||
//void item_meta_str(Info & i)
|
||||
//{
|
||||
// cur->request->last_item->item_content.meta.serialize_to_space_stream(i.out, true);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_meta(Info & i)
|
||||
//{
|
||||
// space_value(i, cur->request->last_item->item_content.meta);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_meta_noescape(Info & i)
|
||||
//{
|
||||
// space_value(i, cur->request->last_item->item_content.meta, false);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
void item_meta_tab(Info & i)
|
||||
{
|
||||
space_list_tab(i, cur->request->last_item->item_content.meta);
|
||||
}
|
||||
|
||||
|
||||
void item_meta_tab_value(Info & i)
|
||||
{
|
||||
space_list_tab_value(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_meta_tab_has_next(Info & i)
|
||||
{
|
||||
space_list_tab_has_next(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
|
||||
}
|
||||
//void item_meta_tab(Info & i)
|
||||
//{
|
||||
// space_list_tab(i, cur->request->last_item->item_content.meta);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_meta_tab_value(Info & i)
|
||||
//{
|
||||
// space_list_tab_value(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//void item_meta_tab_has_next(Info & i)
|
||||
//{
|
||||
// space_list_tab_has_next(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
void item_admin_meta_str(Info & i)
|
||||
{
|
||||
cur->request->last_item->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||
}
|
||||
|
||||
|
||||
void item_admin_meta(Info & i)
|
||||
{
|
||||
space_value(i, cur->request->last_item->item_content.meta_admin);
|
||||
}
|
||||
|
||||
|
||||
void item_admin_meta_tab(Info & i)
|
||||
{
|
||||
space_list_tab(i, cur->request->last_item->item_content.meta_admin);
|
||||
}
|
||||
|
||||
|
||||
void item_admin_meta_tab_value(Info & i)
|
||||
{
|
||||
space_list_tab_value(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
|
||||
}
|
||||
|
||||
|
||||
void item_admin_meta_tab_has_next(Info & i)
|
||||
{
|
||||
space_list_tab_has_next(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
|
||||
}
|
||||
|
||||
//void item_admin_meta_str(Info & i)
|
||||
//{
|
||||
// cur->request->last_item->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_admin_meta(Info & i)
|
||||
//{
|
||||
// space_value(i, cur->request->last_item->item_content.meta_admin);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_admin_meta_tab(Info & i)
|
||||
//{
|
||||
// space_list_tab(i, cur->request->last_item->item_content.meta_admin);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_admin_meta_tab_value(Info & i)
|
||||
//{
|
||||
// space_list_tab_value(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void item_admin_meta_tab_has_next(Info & i)
|
||||
//{
|
||||
// space_list_tab_has_next(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
|
||||
//}
|
||||
//
|
||||
|
||||
void item_can_content_be_html_filtered(Info & i)
|
||||
{
|
||||
|
|
|
@ -161,6 +161,25 @@ void print_user_name(Info & i, User * puser, const std::wstring & guest_name)
|
|||
}
|
||||
|
||||
|
||||
bool should_escape(Info & env)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for(size_t i=0 ; i < env.params.size() ; ++i)
|
||||
{
|
||||
// CHECKME what about env.params[i].is_function ?
|
||||
|
||||
if( env.params[i].str == L"noescape" || env.params[i].str == L"raw" )
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ void print_date_nice(Info & i, const pt::Date & date);
|
|||
void print_user_name(Info & i, User * puser, const std::wstring & guest_name);
|
||||
|
||||
|
||||
bool should_escape(Info & env);
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
|
|
@ -475,17 +475,17 @@ void Templates::CreateFunctions()
|
|||
ezc_functions.Insert("item_is_link_redirect", item_is_link_redirect);
|
||||
ezc_functions.Insert("item_file_size", item_file_size);
|
||||
ezc_functions.Insert("item_sort", item_sort);
|
||||
ezc_functions.Insert("item_meta_str", item_meta_str);
|
||||
ezc_functions.Insert("item_meta", item_meta);
|
||||
ezc_functions.Insert("item_meta_noescape", item_meta_noescape);
|
||||
ezc_functions.Insert("item_meta_tab", item_meta_tab);
|
||||
ezc_functions.Insert("item_meta_tab_value", item_meta_tab_value);
|
||||
ezc_functions.Insert("item_meta_tab_has_next", item_meta_tab_has_next);
|
||||
ezc_functions.Insert("item_admin_meta_str", item_admin_meta_str);
|
||||
ezc_functions.Insert("item_admin_meta", item_admin_meta);
|
||||
ezc_functions.Insert("item_admin_meta_tab", item_admin_meta_tab);
|
||||
ezc_functions.Insert("item_admin_meta_tab_value", item_admin_meta_tab_value);
|
||||
ezc_functions.Insert("item_admin_meta_tab_has_next", item_admin_meta_tab_has_next);
|
||||
// ezc_functions.Insert("item_meta_str", item_meta_str);
|
||||
// ezc_functions.Insert("item_meta", item_meta);
|
||||
// ezc_functions.Insert("item_meta_noescape", item_meta_noescape);
|
||||
// ezc_functions.Insert("item_meta_tab", item_meta_tab);
|
||||
// ezc_functions.Insert("item_meta_tab_value", item_meta_tab_value);
|
||||
// ezc_functions.Insert("item_meta_tab_has_next", item_meta_tab_has_next);
|
||||
// ezc_functions.Insert("item_admin_meta_str", item_admin_meta_str);
|
||||
// ezc_functions.Insert("item_admin_meta", item_admin_meta);
|
||||
// ezc_functions.Insert("item_admin_meta_tab", item_admin_meta_tab);
|
||||
// ezc_functions.Insert("item_admin_meta_tab_value", item_admin_meta_tab_value);
|
||||
// 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);
|
||||
|
||||
/*
|
||||
|
|
|
@ -365,17 +365,17 @@ namespace TemplatesFunctions
|
|||
void item_is_link_redirect(Info & i);
|
||||
void item_file_size(Info & i);
|
||||
void item_sort(Info & i);
|
||||
void item_meta_str(Info & i);
|
||||
void item_meta(Info & i);
|
||||
void item_meta_noescape(Info & i);
|
||||
void item_meta_tab(Info & i);
|
||||
void item_meta_tab_value(Info & i);
|
||||
void item_meta_tab_has_next(Info & i);
|
||||
void item_admin_meta_str(Info & i);
|
||||
void item_admin_meta(Info & i);
|
||||
void item_admin_meta_tab(Info & i);
|
||||
void item_admin_meta_tab_value(Info & i);
|
||||
void item_admin_meta_tab_has_next(Info & i);
|
||||
//void item_meta_str(Info & i);
|
||||
//void item_meta(Info & i);
|
||||
//void item_meta_noescape(Info & i);
|
||||
// void item_meta_tab(Info & i);
|
||||
// void item_meta_tab_value(Info & i);
|
||||
// void item_meta_tab_has_next(Info & i);
|
||||
// void item_admin_meta_str(Info & i);
|
||||
// void item_admin_meta(Info & i);
|
||||
// void item_admin_meta_tab(Info & i);
|
||||
// void item_admin_meta_tab_value(Info & i);
|
||||
// void item_admin_meta_tab_has_next(Info & i);
|
||||
void item_can_content_be_html_filtered(Info & i);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue