Item class has been moved to a new directory 'models', a new class has been added: ItemContent
and same fields from Item were moved to ItemContent Item - id - parent_id - type (file, dir, symlink) - url - subject - template (html template) - sort_index - content_id ItemContent - id - ref -> references (renamed) - user_id - modification_user_id - group_id - privileges - date_creation - date_modification - guest_name - link_to - link_redirect - file_path - file_fs - file_type - file_size - has_thumb -> file_has_thumb (renamed) - hash -> file_hash (renamed) - hash_type -> file_hash_type (renamed) - content -> content_raw (renamed) - content_type -> content_raw_type (renamed) - content_parsed - content_parsed_type - meta - ameta -> meta_admin (renamed) - modify_index (removed) WIP: #4
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* Copyright (c) 2008-2021, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -154,25 +154,32 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
if( UploadSaveStaticFile(item, tmp_filename) )
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
//cur->request->status = db->EditFileById(item, item.id);
|
||||
if( item.update(false, true) )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
if( item.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->DelItem(item);
|
||||
item.remove();
|
||||
//db->DelItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +215,7 @@ void Upload::UploadMulti()
|
||||
cur->request->item.Clear(); // clearing and setting date
|
||||
cur->request->item.parent_id = cur->request->dir_tab.back()->id;
|
||||
cur->request->item.type = Item::file;
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
functions->SetUser(cur->request->item);
|
||||
|
||||
PostFileTab::iterator i = cur->request->post_file_tab.begin();
|
||||
@@ -219,8 +226,8 @@ void Upload::UploadMulti()
|
||||
|
||||
cur->request->item.subject = file_name;
|
||||
cur->request->item.url = file_name;
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = i->second.file_size;
|
||||
cur->request->item.item_content.file_type = SelectFileType(file_name);
|
||||
cur->request->item.item_content.file_size = i->second.file_size;
|
||||
|
||||
functions->PrepareUrl(cur->request->item);
|
||||
UploadFile(cur->request->item, i->second.tmp_filename);
|
||||
@@ -243,13 +250,13 @@ void Upload::UploadSingle()
|
||||
|
||||
functions->ReadItem(cur->request->item, Item::file); // ReadItem() changes the url if it is empty
|
||||
functions->SetUser(cur->request->item);
|
||||
cur->request->item.privileges = system->NewFilePrivileges();
|
||||
cur->request->item.item_content.privileges = system->NewFilePrivileges();
|
||||
|
||||
PostFile & post_file = cur->request->post_file_tab.begin()->second;
|
||||
|
||||
const wchar_t * file_name = post_file.filename.c_str();
|
||||
cur->request->item.file_type = SelectFileType(file_name);
|
||||
cur->request->item.file_size = post_file.file_size;
|
||||
cur->request->item.item_content.file_type = SelectFileType(file_name);
|
||||
cur->request->item.item_content.file_size = post_file.file_size;
|
||||
|
||||
if( !has_subject )
|
||||
cur->request->item.subject = file_name;
|
||||
@@ -305,7 +312,7 @@ void Upload::CreateAnswer()
|
||||
PT::Space & file = files.AddSpace(L"");
|
||||
|
||||
file.Add(L"name", req.item_tab[i].url);
|
||||
file.Add(L"size", req.item_tab[i].file_size);
|
||||
file.Add(L"size", req.item_tab[i].item_content.file_size);
|
||||
|
||||
std::wstring & link = file.Add(L"url", L"");
|
||||
system->CreateItemLink(req.item_tab[i], link);
|
||||
@@ -315,11 +322,11 @@ void Upload::CreateAnswer()
|
||||
|
||||
file.Add(L"deleteType", L"POST");
|
||||
|
||||
if( req.item_tab[i].file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
if( req.item_tab[i].item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
std::wstring & thumb = file.Add(L"thumbnailUrl", link);
|
||||
|
||||
if( req.item_tab[i].has_thumb )
|
||||
if( req.item_tab[i].item_content.file_has_thumb )
|
||||
thumb += L"/-/thumb";
|
||||
}
|
||||
|
||||
@@ -342,12 +349,22 @@ void Upload::MakeGet()
|
||||
{
|
||||
if( cur->request->IsParam(L"jquery_upload") )
|
||||
{
|
||||
query.Clear();
|
||||
query.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
query.WhereType(Item::file);
|
||||
query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
// query.Clear();
|
||||
// query.WhereParentId(cur->request->dir_tab.back()->id);
|
||||
// query.WhereType(Item::file);
|
||||
// query.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
|
||||
db->GetItems(cur->request->item_tab, query);
|
||||
morm::Finder<Item> finder(model_connector);
|
||||
|
||||
finder.
|
||||
select().
|
||||
where().
|
||||
eq(L"parent_id", cur->request->dir_tab.back()->id).
|
||||
eq(L"type", static_cast<int>(Item::file)).
|
||||
neq(L"content.file_type", WINIX_ITEM_FILETYPE_NONE).
|
||||
get_vector(cur->request->item_tab);
|
||||
|
||||
//db->GetItems(cur->request->item_tab, query);
|
||||
|
||||
CreateAnswer();
|
||||
}
|
||||
|
Reference in New Issue
Block a user