removed: ezn patterns for rawcontent and ajaxcontent:

index_rawcontent.html, index_ajaxcontent.html
         now we have out_streams in Request and some special
         keyword in ezc templates for sending content to the 
         specified streams
changed: the way how winix answers to the client's browsers:
         info from Request class:
	                                   winix answer send to the client's browser
	                                                       |
	                                                       |
	                                          depending on send_bin_stream
	                               -------------------------------------------------
	                               |                                               |
	                          text answer                                     binary answer
	                               |                                               |
	                   depending on return_json                          sending out_bin_stream
	             ------------------------------------
	             |                                  |
	       normal request                     ajax request
	             |                                  |
	   sending out_streams[0]           depending on return_info_only
	                              ------------------------------------------------------
	                              |                                                    |
	                 generating JSON object from:                   generating JSON object only from info
	                 out_streams and info, e.g.:                    e.g.:
	                 {                                              { info object serialized here }
	                  "stream_1": "some html content",
	                  "stream_2": "some other html content",
	                  "info": { info object serialized here }
	                 }
	                 note that out_streams[0] is not sent
	                 in JSON answers
	
	




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@937 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2013-11-14 20:59:23 +00:00
parent d801f53154
commit 3af3ac3f6f
15 changed files with 303 additions and 115 deletions

View File

@@ -29,6 +29,12 @@ Upload::Upload()
}
void Upload::Init()
{
json_serializer.TreatAsTable(L"infospace");
json_serializer.TreatAsNumeric(L"size");
}
bool Upload::HasAccess(const Item & item)
{
@@ -188,7 +194,7 @@ void Upload::UploadMulti()
}
if( is_jquery_upload )
CreateJSON();
CreateAnswer();
else
system->RedirectToLastDir();
}
@@ -224,7 +230,7 @@ void Upload::UploadSingle()
post_file.tmp_filename.clear();
if( is_jquery_upload )
CreateJSON();
CreateAnswer();
else
if( cur->request->status == WINIX_ERR_OK )
system->RedirectTo(cur->request->item, L"/cat");
@@ -255,17 +261,38 @@ void Upload::MakePost()
void Upload::CreateJSON()
void Upload::CreateAnswer()
{
size_t loc = TemplatesFunctions::locale.GetCurLang();
Ezc::Pattern * pat = TemplatesFunctions::patterns.Get(template_index, loc);
Request & req = *cur->request;
req.info.name = L"infospace"; // 'infospace' will be serialized to an array
if( pat )
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
{
templates->Generate(*pat);
cur->request->page_generated = true;
cur->request->use_html_filter = false;
PT::Space & file = req.info.AddSpace(L"");
file.Add(L"name", req.item_tab[i].url);
file.Add(L"size", req.item_tab[i].file_size);
std::wstring & link = file.Add(L"url", L"");
system->CreateItemLink(req.item_tab[i], link);
std::wstring & del_url = file.Add(L"delete_url", link);
del_url += L"/rm/jquery_upload";
file.Add(L"delete_type", L"POST");
if( req.item_tab[i].file_type == WINIX_ITEM_FILETYPE_IMAGE )
{
std::wstring & thumb = file.Add(L"thumbnail_url", link);
if( req.item_tab[i].has_thumb )
thumb += L"/-/thumb";
}
}
cur->request->return_json = true;
cur->request->return_info_only = true;
cur->request->info_serializer = &json_serializer;
}
@@ -280,7 +307,7 @@ void Upload::MakeGet()
db->GetItems(cur->request->item_tab, query);
CreateJSON();
CreateAnswer();
}
}