renamed: WinixModel -> WinixModelDeprecated (this class will be removed)
added: WinixModel (models/winixmodel.h|cpp) - a class inheriting from morm::WinixModel, we have methods such as: get_config(), get_logger(), get_request()
and this class will be a base class for our models
added: WinixModelConnector (models/winixmodelconnector.h|cpp) - a class inheriting from morm::WinixModelConnector
this connector we are using instead of morm::ModelConnector - there are pointers to winix objects there (config, request, log)
added to Request: Ezc::Models models
removed from TemplatesFunctions: Ezc::Models ezc_models;
changed: ImgCrop winix functions is using its own item_tab vector now (not finished yet)
added: Item::is(), Item::link(), ItemContent::print_content()
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
#include "models/item.h"
|
||||
#include "core/misc.h"
|
||||
#include "finder.h"
|
||||
#include "core/request.h"
|
||||
#include "templates/templates.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -65,7 +67,9 @@ void Item::fields()
|
||||
field(L"sort_index", sort_index);
|
||||
field(L"content_id", L"content", item_content, morm::FT::foreign_key);
|
||||
|
||||
//field(L"my_test_function", my_test_function);
|
||||
field(L"is", &Item::is);
|
||||
field(L"link", &Item::link);
|
||||
|
||||
|
||||
// may we should add a method setTypeFromInt(int t)?
|
||||
type = static_cast<Type>(type_helper);
|
||||
@@ -232,6 +236,73 @@ void Item::propagate_connector()
|
||||
}
|
||||
|
||||
|
||||
// IMPROVEME move me to a better place
|
||||
void Item::print_dir(Ezc::FunInfo<HtmlTextStream> & env)
|
||||
{
|
||||
Request * req = get_request();
|
||||
|
||||
if( req )
|
||||
{
|
||||
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
||||
env.out << req->dir_tab[a]->url << '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// IMPROVEME move me to a better place
|
||||
void Item::print_dir_without_slash(Ezc::FunInfo<HtmlTextStream> & env)
|
||||
{
|
||||
Request * req = get_request();
|
||||
|
||||
if( req )
|
||||
{
|
||||
for(size_t a=0 ; a < req->dir_tab.size() ; ++a)
|
||||
{
|
||||
env.out << req->dir_tab[a]->url;
|
||||
|
||||
if( a < req->dir_tab.size()-1 )
|
||||
env.out << '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Item::is(Ezc::FunInfo<HtmlTextStream> & env)
|
||||
{
|
||||
Request * req = get_request();
|
||||
|
||||
if( req )
|
||||
{
|
||||
env.res = req->is_item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Item::link(Ezc::FunInfo<HtmlTextStream> & env)
|
||||
{
|
||||
Config * config = get_config();
|
||||
Request * req = get_request();
|
||||
|
||||
if( config && req )
|
||||
{
|
||||
TemplatesFunctions::doc_proto(env);
|
||||
|
||||
if( !req->subdomain.empty() )
|
||||
env.out << req->subdomain << '.';
|
||||
|
||||
env.out << config->base_url;
|
||||
|
||||
// FIXME this prints cur->request->dir_tab but we should print the directory in which actually there is the item
|
||||
print_dir(env);
|
||||
env.out << url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -366,5 +437,6 @@ bool Item::do_migration_to_4()
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
Reference in New Issue
Block a user