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

24
winixd/models/Makefile Normal file
View File

@@ -0,0 +1,24 @@
include Makefile.o.dep
current_path := $(shell pwd)
global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WORKING_DIR))
winix_include_paths = -I$(global_relative_working_dir)/winix/winixd -I$(global_relative_working_dir)/ezc/src -I$(global_relative_working_dir)/tito/src -I$(global_relative_working_dir)/morm/src -I$(global_relative_working_dir)/pikotools
all: $(o)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(winix_include_paths) $<
depend:
makedepend -Y. $(winix_include_paths) -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
clean:
rm -f *.o
include Makefile.dep

View File

@@ -0,0 +1,66 @@
# DO NOT DELETE
item.o: ../../../winix/winixd/models/item.h ../../../morm/src/model.h
item.o: ../../../pikotools/textstream/textstream.h
item.o: ../../../pikotools/space/space.h
item.o: ../../../pikotools/textstream/types.h ../../../pikotools/date/date.h
item.o: ../../../pikotools/convert/inttostr.h
item.o: ../../../pikotools/membuffer/membuffer.h
item.o: ../../../pikotools/textstream/types.h
item.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
item.o: ../../../morm/src/dbconnector.h ../../../pikotools/log/log.h
item.o: ../../../pikotools/log/filelog.h ../../../morm/src/queryresult.h
item.o: ../../../morm/src/flatconnector.h ../../../morm/src/dbexpression.h
item.o: ../../../morm/src/baseexpression.h ../../../morm/src/morm_types.h
item.o: ../../../morm/src/modelenv.h ../../../morm/src/modeldata.h
item.o: ../../../morm/src/cursorhelper.h ../../../morm/src/finderhelper.h
item.o: ../../../morm/src/fieldvaluehelper.h
item.o: ../../../morm/src/flatexpression.h
item.o: ../../../winix/winixd/models/itemcontent.h ../../../morm/src/finder.h
item.o: ../../../pikotools/utf8/utf8.h ../../../morm/src/cursor.h
itemcontent.o: ../../../winix/winixd/models/itemcontent.h
itemcontent.o: ../../../pikotools/space/space.h
itemcontent.o: ../../../pikotools/textstream/types.h
itemcontent.o: ../../../pikotools/date/date.h
itemcontent.o: ../../../pikotools/convert/inttostr.h
itemcontent.o: ../../../morm/src/model.h
itemcontent.o: ../../../pikotools/textstream/textstream.h
itemcontent.o: ../../../pikotools/membuffer/membuffer.h
itemcontent.o: ../../../pikotools/textstream/types.h
itemcontent.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
itemcontent.o: ../../../morm/src/dbconnector.h ../../../pikotools/log/log.h
itemcontent.o: ../../../pikotools/log/filelog.h
itemcontent.o: ../../../morm/src/queryresult.h
itemcontent.o: ../../../morm/src/flatconnector.h
itemcontent.o: ../../../morm/src/dbexpression.h
itemcontent.o: ../../../morm/src/baseexpression.h
itemcontent.o: ../../../morm/src/morm_types.h ../../../morm/src/modelenv.h
itemcontent.o: ../../../morm/src/modeldata.h ../../../morm/src/cursorhelper.h
itemcontent.o: ../../../morm/src/finderhelper.h
itemcontent.o: ../../../morm/src/fieldvaluehelper.h
itemcontent.o: ../../../morm/src/flatexpression.h
itemcontent.o: ../../../winix/winixd/core/crypt.h
itemcontent.o: ../../../winix/winixd/core/run.h
itemcontent.o: ../../../winix/winixd/core/winixbase.h
itemcontent.o: ../../../winix/winixd/core/config.h
itemcontent.o: ../../../pikotools/space/spaceparser.h
itemcontent.o: ../../../pikotools/space/space.h
itemcontent.o: ../../../winix/winixd/core/log.h
itemcontent.o: ../../../winix/winixd/core/logmanipulators.h
itemcontent.o: ../../../winix/winixd/core/log.h
itemcontent.o: ../../../winix/winixd/core/synchro.h
itemcontent.o: ../../../winix/winixd/core/filelog.h
itemcontent.o: ../../../winix/winixd/core/lock.h
itemcontent.o: ../../../winix/winixd/core/synchro.h
itemcontent.o: ../../../winix/winixd/core/config.h
itemcontent.o: ../../../winix/winixd/core/user.h
itemcontent.o: ../../../winix/winixd/core/misc.h
itemcontent.o: ../../../winix/winixd/core/requesttypes.h
itemcontent.o: ../../../pikotools/utf8/utf8.h
itemcontent.o: ../../../winix/winixd/core/winix_const.h
itemcontent.o: ../../../pikotools/convert/convert.h
itemcontent.o: ../../../pikotools/convert/inttostr.h
itemcontent.o: ../../../pikotools/convert/patternreplacer.h
itemcontent.o: ../../../pikotools/convert/strtoint.h
itemcontent.o: ../../../pikotools/convert/text.h
itemcontent.o: ../../../pikotools/convert/misc.h

View File

@@ -0,0 +1 @@
o = item.o itemcontent.o

231
winixd/models/item.cpp Normal file
View File

@@ -0,0 +1,231 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2010-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "models/item.h"
#include "finder.h"
namespace Winix
{
Item::Item()
{
Clear();
}
void Item::map_fields()
{
int type_helper = static_cast<int>(type);
field(L"id", id, false, false, true);
field(L"parent_id", parent_id);
field(L"type", type_helper);
field(L"url", url);
field(L"subject", subject);
field(L"template", html_template);
field(L"sort_index", sort_index);
//field(L"content_id", content_id);
field(L"content_id", item_content, true, true, true);
// may we should add a method setTypeFromInt(int t)?
type = static_cast<Type>(type_helper);
}
void Item::table_name(PT::TextStream & stream)
{
stream << "core.item";
}
void Item::before_insert()
{
// IMPROVEME if prepare_status is false then update the 'url' with the 'id'
// add a method: update_url()
url_was_prepared_correctly = prepare_url();
}
void Item::after_insert()
{
get_last_sequence(L"core.item_id_seq", id);
if( !url_was_prepared_correctly )
{
// update_url();
// what about an error from update_url()?
}
}
bool Item::update(morm::ModelData * model_data, bool url_was_changed, bool update_whole_tree)
{
bool prepare_url_status = true;
if( url_was_changed )
{
prepare_url_status = prepare_url();
}
bool update_status = morm::Model::update(model_data, update_whole_tree);
if( update_status )
{
if( !prepare_url_status )
{
// IMPROVEME add update_url() method
// set 'url' to the same value as 'id'
//update_status = update_url();
}
}
return update_status;
}
bool Item::update(morm::ModelData & model_data, bool url_was_changed, bool update_whole_tree)
{
return update(&model_data, url_was_changed, update_whole_tree);
}
bool Item::update(bool url_was_changed, bool update_whole_tree)
{
return update(nullptr, url_was_changed, update_whole_tree);
}
void Item::Clear()
{
id = -1;
parent_id = -1;
type = none;
url.clear();
subject.clear();
html_template.clear();
sort_index = 0;
content_id = -1;
item_content.Clear();
// used only when inserting, not saved to the database
url_was_prepared_correctly = true;
}
long Item::calc_items_by_url(long parent_id, const std::wstring & url)
{
morm::Finder<CalcItemsHelper> finder(model_connector);
CalcItemsHelper helper = finder.
prepare_to_select().
raw("select count(id) as size from core.item").
where().
eq(L"parent_id", parent_id).
eq(L"url", url).
get();
return helper.size;
}
bool Item::prepare_url()
{
std::wstring temp_url;
bool is_that_url;
int index = 1;
const int max_index = 99;
wchar_t appendix[20];
size_t appendix_len = sizeof(appendix) / sizeof(wchar_t);
appendix[0] = 0;
// only root dir may not have the url
if( parent_id != -1 && url.empty() )
url = L"empty"; // IMPROVEME move me to locales
do
{
temp_url = url;
temp_url += appendix;
long size = calc_items_by_url(parent_id, temp_url);
if( size > 0 )
{
swprintf(appendix, appendix_len, L"_(%d)", ++index);
is_that_url = true;
}
else
{
url = temp_url;
is_that_url = false;
}
}
while( is_that_url && index <= max_index );
return !is_that_url;
}
void Item::do_migration(morm::ModelConnector * model_connector)
{
return;
///////
morm::Finder<Item> finder(model_connector);
std::list<Item> list = finder.select().where().eq(L"type", static_cast<int>(Item::dir)).eq(L"content_id", -1).get_list();
for(Item & item : list)
{
item.item_content.set_save_mode(morm::Model::DO_INSERT_ON_SAVE);
item.save();
}
}
} // namespace Winix

180
winixd/models/item.h Normal file
View File

@@ -0,0 +1,180 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_models_item
#define headerfile_winix_models_item
#include <string>
#include "model.h"
#include "models/itemcontent.h"
namespace Winix
{
// IMPROVEME rename me and move to a better place
class CalcItemsHelper : public morm::Model
{
public:
long size;
void map_fields()
{
field(L"size", size);
}
};
class Item : public morm::Model
{
public:
enum Type
{
dir = 0,
file = 1,
symlink = 2,
none = 1000
};
/*
*
*/
long id;
/*
*
*/
long parent_id;
/*
* may change to int?
*/
Type type;
/*
*
*/
std::wstring url;
/*
*
*/
std::wstring subject;
/*
*
*/
std::wstring html_template;
/*
* sort index used when displaying a group of items
*/
int sort_index;
/*
* may not needed?
* the id is in the ItemContent object
*/
long content_id;
/*
*
*/
ItemContent item_content;
Item();
void map_fields();
void table_name(PT::TextStream & stream);
void before_insert();
void after_insert();
/*
* what about clear() from Model?
*/
void Clear();
bool prepare_url();
/*
* CHECKME
* make sure update(...) methods from Model are not available
*/
bool update(morm::ModelData * model_data, bool url_was_changed, bool update_whole_tree = true);
bool update(morm::ModelData & model_data, bool url_was_changed, bool update_whole_tree = true);
bool update(bool url_was_changed, bool update_whole_tree = true);
// IMPROVEME make the same for save() methods
/*
* IMPROVEME
* when removing we should check whether the item_content.references is zero and them remove it
* in other cases only decrement item_content.references
*
*/
/*
* temporary
*/
static void do_migration(morm::ModelConnector * model_connector);
protected:
bool url_was_prepared_correctly;
long calc_items_by_url(long parent_id, const std::wstring & url);
};
} // namespace Winix
#endif

View File

@@ -0,0 +1,176 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "models/itemcontent.h"
#include "core/crypt.h"
#include "core/misc.h"
namespace Winix
{
ItemContent::ItemContent()
{
Clear();
}
// IMPROVEME move me to morm
void ItemContent::field(const wchar_t * db_field_name, PT::Space & space)
{
}
void ItemContent::map_fields()
{
int content_raw_type_helper = static_cast<int>(content_raw_type);
int content_parsed_type_helper = static_cast<int>(content_parsed_type);
field(L"id", id, false, false, true);
field(L"references", references);
field(L"user_id", user_id);
field(L"group_id", group_id);
field(L"guest_name", guest_name);
field(L"modification_user_id", modification_user_id);
field(L"privileges", privileges);
field(L"date_creation", date_creation);
field(L"date_modification", date_modification);
field(L"link_to", link_to);
field(L"link_redirect", link_redirect);
field(L"file_path", file_path);
field(L"file_fs", file_fs);
field(L"file_type", file_type);
field(L"file_has_thumb", file_has_thumb);
field(L"file_hash", file_hash);
field(L"file_hash_type", file_hash_type);
field(L"file_size", file_size);
field(L"content_raw", content_raw);
field(L"content_raw_type", content_raw_type_helper);
field(L"content_parsed", content_parsed);
field(L"content_parsed_type", content_parsed_type_helper);
// field(L"meta", meta);
// field(L"meta_admin", meta_admin);
content_raw_type = static_cast<ContentType>(content_raw_type_helper);
content_parsed_type = static_cast<ContentType>(content_parsed_type_helper);
}
void ItemContent::table_name(PT::TextStream & stream)
{
stream << "core.content";
}
void ItemContent::after_insert()
{
get_last_sequence(L"core.content_id_seq", id);
}
// !! IMPROVEME
// now we have Request::start_time and Request::start_date
// we can somehow get the current time from the request
// may setting the date should be completetly removed from here?
void ItemContent::SetDateToNow()
{
date_creation = std::time(0);
date_modification = date_creation;
}
void ItemContent::SetDateModifyToNow()
{
date_modification = std::time(0);
}
void ItemContent::Clear()
{
id = -1;
references = 1;
user_id = -1;
group_id = -1;
guest_name.clear();
modification_user_id = -1;
privileges = 0;
link_to.clear();
link_redirect = false;
file_path.clear();
file_fs = -1;
file_type = WINIX_ITEM_FILETYPE_NONE;
file_has_thumb = false;
file_hash.clear();
file_hash_type = WINIX_CRYPT_HASH_NONE;
file_size = 0;
content_raw.clear();
content_raw_type = ct_formatted_text;
content_parsed.clear();
content_parsed_type = ct_formatted_text;
meta.Clear();
meta_admin.Clear();
SetDateToNow();
}
/*
* we're using the HtmlFilter only for those contents
*
*/
bool ItemContent::CanContentBeHtmlFiltered(ItemContent::ContentType ct)
{
return ct == ct_text || ct == ct_formatted_text || ct == ct_html || ct == ct_bbcode;
}
bool ItemContent::CanContentBeHtmlFiltered()
{
return CanContentBeHtmlFiltered(content_raw_type);
}
} // namespace Winix

244
winixd/models/itemcontent.h Normal file
View File

@@ -0,0 +1,244 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2021, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef headerfile_winix_models_itemcontent
#define headerfile_winix_models_itemcontent
#include <string>
#include "space/space.h"
#include "date/date.h"
#include "model.h"
namespace Winix
{
#define WINIX_ITEM_FILETYPE_NONE 0
#define WINIX_ITEM_FILETYPE_IMAGE 1
#define WINIX_ITEM_FILETYPE_DOCUMENT 2
#define WINIX_ITEM_FILETYPE_VIDEO 3
#define WINIX_ITEM_FILETYPE_UNKNOWN 10
class ItemContent : public morm::Model
{
public:
/*
* may we should add ct_none? and this will be default (set in Clear method)
*/
enum ContentType
{
ct_text = 0,
ct_formatted_text,
ct_html,
ct_bbcode,
ct_other, // no auto-formatting is applied
};
/*
* record id
*/
long id;
/*
* how many Items references to this
*/
int references;
/*
* user owner
* -1 means the item was created by a not logged in user and in such a case a 'guest_name' field is set
*/
long user_id;
/*
* group owner
*/
long group_id;
/*
* a guest name in a case when the item was created by a not logged in user (user_id is -1)
*/
std::wstring guest_name;
/*
* who has modified the item last
* this field is not taken into account when checking permissions
*/
long modification_user_id;
/*
* privileges, e.g: 0755
* IMPROVEME need some info here
*/
int privileges;
/*
* when the object was created
*/
PT::Date date_creation;
/*
* when the object was last modified
*/
PT::Date date_modification;
/*
* name of a link in the case when type is a symlink or a directory
*/
std::wstring link_to;
/*
* whether or not winix should make a redirect to link_to link
* IMPROVE ME should it be 'bool'?
*/
int link_redirect;
/*
* static file (if exists)
* relative file path
*/
std::wstring file_path;
/*
* file system type where the file was saved
*/
int file_fs;
/*
* file type (none, image, doc, etc)
*/
int file_type;
/*
* whether or not we have a thumbnail
*/
bool file_has_thumb;
/*
* file hash (md4, md5, ...)
*/
std::wstring file_hash;
/*
* hash type WINIX_CRYPT_HASH_* (see crypt.h)
*/
int file_hash_type;
/*
* size of the file
*/
size_t file_size;
/*
* object content as provided by the user
*/
std::wstring content_raw;
/*
* raw content type
*/
ContentType content_raw_type;
/*
* parsed object content
* IMPROVEME not used in winix yet
*/
std::wstring content_parsed;
/*
* parsed content type
* IMPROVEME not used in winix yet
*/
ContentType content_parsed_type;
/*
* meta information
* additional information in the form af a Space struct
*/
PT::Space meta;
/*
* admin meta information
* additional information available to edit only by an admin
*/
PT::Space meta_admin;
ItemContent();
void map_fields();
void table_name(PT::TextStream & stream);
void after_insert();
void SetDateToNow();
void SetDateModifyToNow();
/*
* what about clear() from Model?
*/
void Clear();
static bool CanContentBeHtmlFiltered(ItemContent::ContentType ct);
bool CanContentBeHtmlFiltered();
// IMPROVEME move me to morm
using morm::Model::field;
void field(const wchar_t * db_field_name, PT::Space & space);
};
} // namespace Winix
#endif