plugin ticket: rewritten templates ezc functions
(now images/files are working fine) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@795 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -67,15 +67,19 @@ void TicketInfo::Clear()
|
||||
{
|
||||
ticket = &ticket_empty;
|
||||
item = &item_empty;
|
||||
ticket->Clear();
|
||||
item->Clear();
|
||||
// we use meta from item which should not be const
|
||||
|
||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||
cur_conf = &cur_conf_empty;
|
||||
cur_conf->Clear();
|
||||
|
||||
item_tab.clear();
|
||||
ticket_tab.clear();
|
||||
item_sort_tab.clear();
|
||||
|
||||
create_new_ticket = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +337,6 @@ return false;
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id,
|
||||
const PostFile & value,
|
||||
std::vector<long> & file_map,
|
||||
PT::Space & meta,
|
||||
Item & upload_dir)
|
||||
{
|
||||
@@ -349,20 +352,17 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
PT::Space & sp = meta.AddSpace(L"param");
|
||||
|
||||
sp.Add(L"id", param_id);
|
||||
PT::Space & space = FindAddMetaByParam(meta, param_id);
|
||||
PT::Space & file_space = space.AddSpace(L"file");
|
||||
|
||||
if( file.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
sp.Add(L"type", L"image");
|
||||
file_space.Add(L"type", L"image");
|
||||
else
|
||||
sp.Add(L"type", L"file");
|
||||
file_space.Add(L"type", L"file");
|
||||
|
||||
sp.Add(L"file_id", file.id);
|
||||
file_space.Add(L"itemid", file.id);
|
||||
system->MakePath(file, file_path);
|
||||
sp.Add(L"path", file_path);
|
||||
|
||||
file_map.push_back(file.id);
|
||||
file_space.Add(L"path", file_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -372,21 +372,24 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||
long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
if( space.Text(L"type") == L"images" ||
|
||||
space.Text(L"type") == L"files" )
|
||||
if( space.Text(L"type") == L"images" || space.Text(L"type") == L"files" )
|
||||
{
|
||||
std::wstring & upload_path = space.Text(L"upload_dir");
|
||||
Item * upload_dir = system->dirs.GetDir(upload_path);
|
||||
|
||||
if( upload_dir )
|
||||
if( !upload_path.empty() )
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, file_map, meta, *upload_dir);
|
||||
Item * upload_dir = system->dirs.GetDir(upload_path);
|
||||
|
||||
if( upload_dir )
|
||||
ReadTicketValue(space, param_id, value, meta, *upload_dir);
|
||||
else
|
||||
log << log1 << "Ticket: there is no an upload directory: " << upload_path << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Ticket: there is no an upload directory: " << upload_path << logend;
|
||||
log << log1 << "Ticket: you must set 'upload_dir' directory in the config" << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,15 +442,15 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
||||
|
||||
|
||||
// always adds a new parameter
|
||||
void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const PostFile & value, std::vector<long> & file_map, PT::Space & meta)
|
||||
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
|
||||
{
|
||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & space = *cur_conf->spaces[i];
|
||||
|
||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
||||
if( space.name == L"param" && space.Long(L"id") == param_id )
|
||||
{
|
||||
ReadTicketValue(space, param_id, value, file_map, meta);
|
||||
ReadTicketValue(space, param_id, value, meta);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -457,7 +460,7 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const PostFile
|
||||
|
||||
|
||||
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, std::vector<long> & file_map, PT::Space & meta)
|
||||
void TicketInfo::ReadTicketParams(Ticket & ticket, bool clear_ticket, PT::Space & meta)
|
||||
{
|
||||
PostTab::iterator i;
|
||||
PostFileTab::iterator i2;
|
||||
@@ -465,18 +468,16 @@ PostFileTab::iterator i2;
|
||||
if( clear_ticket )
|
||||
ticket.Clear();
|
||||
|
||||
PT::Space & ticket_meta = meta.FindAddSpace(L"ticket");
|
||||
|
||||
for(i=cur->request->post_tab.begin() ; i!=cur->request->post_tab.end() ; ++i)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i->first) )
|
||||
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, ticket_meta);
|
||||
ReadTicketParam(ticket, Tol(i->first.c_str() + config->ticket_form_prefix.size()), i->second, meta);
|
||||
}
|
||||
|
||||
for(i2=cur->request->post_file_tab.begin() ; i2!=cur->request->post_file_tab.end() ; ++i2)
|
||||
{
|
||||
if( IsSubString(config->ticket_form_prefix, i2->first) )
|
||||
ReadTicketParam(ticket, Tol(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, file_map, ticket_meta);
|
||||
ReadTicketParam(Tol(i2->first.c_str() + config->ticket_form_prefix.size()), i2->second, meta);
|
||||
}
|
||||
|
||||
ticket.SortParTab();
|
||||
@@ -505,5 +506,12 @@ void TicketInfo::RemoveTicket(long file_id)
|
||||
}
|
||||
|
||||
|
||||
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
|
||||
{
|
||||
PT::Space & ticket_meta = item.meta.FindAddSpace(L"ticket");
|
||||
ticket_meta = ticket_space;
|
||||
ticket_meta.name = L"ticket";
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user