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:
2021-02-24 01:19:47 +01:00
parent 3d7ece15f8
commit 32e93a04c5
118 changed files with 5795 additions and 4514 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2011-2016, Tomasz Sowa
* Copyright (c) 2011-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,11 +34,12 @@
#include "templates/templates.h"
#include "core/plugin.h"
#include "core/item.h"
#include "core/log.h"
#include "core/misc.h"
#include "cache.h"
#include "templates/miscspace.h"
#include "models/item.h"
namespace Winix
{
@@ -61,11 +62,12 @@ extern int mount_par_menu_skip;
extern Cache cache;
static Ezc::Stack * stack = &empty_stack;
static DbItemQuery iq;
//static DbItemQuery iq;
static std::vector<Item> item_tab;
static MenuItem menu_item;
struct StackItem : public Ezc::FunData
{
CacheItem * citem;
@@ -99,36 +101,53 @@ return WINIX_PL_MENU_PARAM_NONE;
}
void read_from_db(long dir_id, int param, bool with_meta)
{
iq.SetAll(false, false);
iq.sel_subject = true;
iq.sel_url = true;
iq.sel_sort_index = true;
iq.sort_date_asc = false; // !! FIXED ME we need an option for this
iq.sel_type = true;
iq.sel_file = true;
iq.sel_meta = with_meta;
iq.WhereParentId(dir_id);
// iq.SetAll(false, false);
// iq.sel_subject = true;
// iq.sel_url = true;
// iq.sel_sort_index = true;
// iq.sort_date_asc = false; // !! FIXED ME we need an option for this
// iq.sel_type = true;
// iq.sel_file = true;
// iq.sel_meta = with_meta;
// iq.WhereParentId(dir_id);
// CHECKME is it correct to get the connector from last item?
morm::ModelConnector * model_connector = cur->request->last_item->get_connector();
morm::Finder<Item> finder(model_connector);
finder.
select().
where().
eq(L"parent_id", dir_id);
if( param == WINIX_PL_MENU_PARAM_IMAGES )
{
iq.WhereType(Item::file);
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
// iq.WhereType(Item::file);
// iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
finder.
eq(L"type", static_cast<int>(Item::file)).
eq(L"content.file_type", WINIX_ITEM_FILETYPE_IMAGE);
}
else
if( param == WINIX_PL_MENU_PARAM_DIRS )
{
iq.WhereType(Item::dir);
//iq.WhereType(Item::dir);
finder.eq(L"type", static_cast<int>(Item::dir));
}
else
if( param == WINIX_PL_MENU_PARAM_FILES )
{
iq.WhereType(Item::file);
//iq.WhereType(Item::file);
finder.eq(L"type", static_cast<int>(Item::file));
}
db->GetItems(item_tab, iq);
finder.get_vector(item_tab);
//db->GetItems(item_tab, iq);
log << log4 << "Menu: loaded directories/files from the database for parent_id: "
<< dir_id << logend;
}
@@ -190,9 +209,9 @@ void copy_items(CacheItem & citem)
menu_item.id = item_tab[i].id;
menu_item.subject = item_tab[i].subject;
menu_item.url = item_tab[i].url;
menu_item.meta = item_tab[i].meta;
menu_item.meta = item_tab[i].item_content.meta;
menu_item.type = item_tab[i].type;
menu_item.file_type = item_tab[i].file_type;
menu_item.file_type = item_tab[i].item_content.file_type;
citem.menu_items.push_back(menu_item);
}