updated to the new Pikotools api (new Space struct)

This commit is contained in:
2021-04-09 17:50:58 +02:00
parent 00b980e74b
commit 35e10ed469
52 changed files with 795 additions and 736 deletions

View File

@@ -106,7 +106,7 @@ void TicketInfo::Clear()
cur_conf_wrap = &cur_conf_wrap_empty;
cur_conf = &cur_conf_empty;
cur_conf->Clear();
cur_conf->clear();
item_tab.clear();
ticket_tab.clear();
@@ -167,9 +167,9 @@ bool TicketInfo::ParseTicketConf(long mount_dir_id, const std::wstring & path)
conf_tab[mount_dir_id].file_name = path;
conf_parser.SetSpace(conf_tab[mount_dir_id].conf);
conf_tab[mount_dir_id].conf.Clear();
conf_tab[mount_dir_id].conf.clear();
return (conf_parser.ParseString(config_file.item_content.content_raw) == PT::SpaceParser::ok);
return (conf_parser.ParseSpace(config_file.item_content.content_raw) == PT::SpaceParser::ok);
}
@@ -264,15 +264,15 @@ void TicketInfo::FindCurrentConf()
void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
{
std::wstring * type = space.GetFirstValue(L"type");
std::wstring * type = space.get_wstr(L"type");
if( !type )
return;
if( *type == L"integer" )
{
std::wstring * min_str = space.GetFirstValue(L"min");
std::wstring * max_str = space.GetFirstValue(L"min");
std::wstring * min_str = space.get_wstr(L"min");
std::wstring * max_str = space.get_wstr(L"min");
if( min_str )
{
@@ -303,16 +303,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
else
if( *type == L"select" )
{
for(size_t a=0 ; a<space.spaces.size() ; ++a)
if( space.child_spaces )
{
PT::Space & sp = *space.spaces[a];
for(size_t a=0 ; a<space.child_spaces->size() ; ++a)
{
PT::Space & sp = *(*space.child_spaces)[a];
if( sp.name == L"option" && sp.Long(L"id") == par.intv )
return;
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == par.intv )
return;
}
}
par.intv = 0;
std::wstring * def = space.GetFirstValue(L"default");
std::wstring * def = space.get_wstr(L"default");
if( def )
par.intv = Tol(*def);
@@ -322,16 +325,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
PT::Space & TicketInfo::FindAddMetaByParam(PT::Space & meta, long param)
{
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
if( meta.child_spaces )
{
PT::Space & sp = *meta.spaces[i];
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
{
PT::Space & sp = *(*meta.child_spaces)[i];
if( sp.name == L"param" && sp.Long(L"id") == param )
return sp;
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == param )
return sp;
}
}
PT::Space & sp = meta.AddSpace(L"param");
sp.Add(L"id", param);
PT::Space & sp = meta.add_child_space(L"param");
sp.add(L"id", param);
return sp;
}
@@ -340,9 +346,9 @@ return sp;
bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta)
{
if( space.Text(L"type") == L"integer" ||
space.Text(L"type") == L"progress" ||
space.Text(L"type") == L"select" )
if( space.is_equal(L"type", L"integer") ||
space.is_equal(L"type", L"progress") ||
space.is_equal(L"type", L"select") )
{
par.intv = Tol(value);
par.decv.clear();
@@ -350,16 +356,16 @@ bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::Ticke
return true;
}
else
if( space.Text(L"type") == L"string" ||
space.Text(L"type") == L"multistring" )
if( space.is_equal(L"type", L"string") ||
space.is_equal(L"type", L"multistring") )
{
// !! dodac cos co sprawdzi czy string nie zawiera znakow konca linii
PT::Space & sp = FindAddMetaByParam(meta, param_id);
sp.Add(L"value", value);
sp.add(L"value", value);
return false;
}
if( space.Text(L"type") == L"images" ||
space.Text(L"type") == L"files" )
if( space.is_equal(L"type", L"images") ||
space.is_equal(L"type", L"files") )
{
if( !value.empty() )
{
@@ -404,16 +410,16 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
if( cur->request->status == WINIX_ERR_OK )
{
PT::Space & space = FindAddMetaByParam(meta, param_id);
PT::Space & file_space = space.AddSpace(L"file");
PT::Space & file_space = space.add_child_space(L"file");
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
file_space.Add(L"type", L"image");
file_space.add(L"type", L"image");
else
file_space.Add(L"type", L"file");
file_space.add(L"type", L"file");
file_space.Add(L"itemid", file.id);
file_space.add(L"itemid", file.id);
system->MakePath(file, file_path);
file_space.Add(L"path", file_path);
file_space.add(L"path", file_path);
}
else
{
@@ -425,11 +431,11 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
void TicketInfo::ReadTicketValue(PT::Space & space,
long param_id, const PostFile & value, PT::Space & meta)
{
std::wstring * type = space.GetFirstValue(L"type");
std::wstring * type = space.get_wstr(L"type");
if( type && (*type == L"images" || *type == L"files") )
{
std::wstring * upload_path = space.GetFirstValue(L"upload_dir");
std::wstring * upload_path = space.get_wstr(L"upload_dir");
if( upload_path && !upload_path->empty() )
{
@@ -479,14 +485,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
{
ticket_param.Clear();
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
if( cur_conf->child_spaces )
{
PT::Space & space = *cur_conf->spaces[i];
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
{
ReadTicketParam(space, ticket, param_id, value, meta);
return;
PT::Space & space = *(*cur_conf->child_spaces)[i];
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
{
ReadTicketParam(space, ticket, param_id, value, meta);
return;
}
}
}
@@ -497,14 +506,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
// always adds a new parameter
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
{
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
if( cur_conf->child_spaces )
{
PT::Space & space = *cur_conf->spaces[i];
if( space.name == L"param" && space.Long(L"id") == param_id )
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
{
ReadTicketValue(space, param_id, value, meta);
return;
PT::Space & space = *(*cur_conf->child_spaces)[i];
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
{
ReadTicketValue(space, param_id, value, meta);
return;
}
}
}
@@ -517,29 +529,32 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Spac
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta)
{
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
if( meta.child_spaces )
{
PT::Space & param = *meta.spaces[i];
if( param.name == L"param" )
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
{
for(size_t z=0 ; z<param.spaces.size() ; ++z)
PT::Space & param = *(*meta.child_spaces)[i];
if( param.name && *param.name == L"param" && param.child_spaces )
{
PT::Space & file = *param.spaces[z];
if( file.name == L"file" )
for(size_t z=0 ; z<param.child_spaces->size() ; ++z)
{
if( file.Long(L"itemid") == file_id )
PT::Space & file = *(*param.child_spaces)[z];
if( file.name && *file.name == L"file" )
{
param.RemoveSpace(z);
if( file.to_long(L"itemid") == file_id )
{
param.remove_child_space(z);
// !! IMPROVE ME
// temporarily we delete the file here
// but it should be really deleted when the user will press
// the submit button
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
// !! IMPROVE ME
// temporarily we delete the file here
// but it should be really deleted when the user will press
// the submit button
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
return true;
return true;
}
}
}
}
@@ -616,9 +631,8 @@ void TicketInfo::RemoveTicket(long file_id)
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
{
PT::Space & ticket_meta = item.item_content.meta.FindAddSpace(L"ticket");
PT::Space & ticket_meta = item.item_content.meta.find_add_child_space(L"ticket");
ticket_meta = ticket_space;
ticket_meta.name = L"ticket";
}