diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index 29aa9f1..3a191d7 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -328,6 +328,9 @@ bool App::Init() model_connector.set_flat_connector(json_connector); model_connector.set_db_connector(postgresql_connector); model_connector.set_logger(log); + model_connector.set_winix_config(&config); + model_connector.set_winix_request(&req); + model_connector.set_winix_logger(&log); if( !TryToMakeDatabaseMigration() ) return false; diff --git a/winixd/core/app.h b/winixd/core/app.h index b154f66..d5da989 100644 --- a/winixd/core/app.h +++ b/winixd/core/app.h @@ -54,18 +54,16 @@ #include "cookieparser.h" #include "postmultiparser.h" #include "acceptencodingparser.h" - #include "winixrequest.h" #include "log/log.h" #include "filelog.h" +#include "models/winixmodelconnector.h" namespace Winix { - - class App { public: @@ -166,13 +164,13 @@ private: std::string http_header_8bit; std::wstring empty_response; - morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector + WinixModelConnector model_connector; // main thread model connector, each thread has its own connector morm::JSONConnector json_connector; morm::PostgreSQLConnector postgresql_connector; // objects for main thread WinixBase winix_base; - WinixModel winix_model; + WinixModelDeprecated winix_model; WinixSystem winix_system; WinixRequest winix_request; // /////////////////////// @@ -184,10 +182,10 @@ private: // log_buffer for the main thread pt::WTextStream log_buffer; - // logger only for App object + // logger only for the main thread Log log; - // file logger, one object for every Log objects + // file logger, one object for all Log objects FileLog file_log; bool InitFCGI(char * sock, char * sock_user, char * sock_group); diff --git a/winixd/core/basethread.h b/winixd/core/basethread.h index 144e7a0..c7b20ba 100644 --- a/winixd/core/basethread.h +++ b/winixd/core/basethread.h @@ -37,7 +37,7 @@ #include #include "synchro.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" @@ -47,7 +47,7 @@ namespace Winix -class BaseThread : public WinixModel +class BaseThread : public WinixModelDeprecated { public: diff --git a/winixd/core/dirs.cpp b/winixd/core/dirs.cpp index a97e5ae..8ae26d6 100644 --- a/winixd/core/dirs.cpp +++ b/winixd/core/dirs.cpp @@ -61,9 +61,9 @@ void Dirs::SetNotify(Notify * pnotify) } -void Dirs::set_dependency(WinixModel * winix_model) +void Dirs::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); dir_tab.set_dependency(winix_model); } diff --git a/winixd/core/dirs.h b/winixd/core/dirs.h index 4c4a514..9ab6ded 100644 --- a/winixd/core/dirs.h +++ b/winixd/core/dirs.h @@ -42,8 +42,8 @@ #include "dircontainer.h" #include "db/db.h" #include "request.h" -#include "winixmodel.h" #include "models/item.h" +#include "winixmodeldeprecated.h" @@ -57,7 +57,7 @@ class Notify; // (we will support '..' in the future) -class Dirs : public WinixModel +class Dirs : public WinixModelDeprecated { public: @@ -68,7 +68,7 @@ public: void SetDb(Db * pdb); void SetNotify(Notify * pnotify); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); // these methods return false if there is no such a dir bool IsDir(long dir_id); diff --git a/winixd/core/groups.cpp b/winixd/core/groups.cpp index 240da15..0e0a6d2 100644 --- a/winixd/core/groups.cpp +++ b/winixd/core/groups.cpp @@ -46,9 +46,9 @@ Groups::Groups() } -void Groups::set_dependency(WinixModel * winix_model) +void Groups::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); table.set_dependency(winix_model); } diff --git a/winixd/core/groups.h b/winixd/core/groups.h index 5062319..a7f53ea 100644 --- a/winixd/core/groups.h +++ b/winixd/core/groups.h @@ -40,7 +40,7 @@ #include "models/group.h" #include "ugcontainer.h" #include "db/db.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" @@ -49,7 +49,7 @@ namespace Winix -class Groups : public WinixModel +class Groups : public WinixModelDeprecated { typedef UGContainer Table; @@ -57,7 +57,7 @@ Table table; public: - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); typedef Table::Iterator Iterator; typedef Table::SizeType SizeType; diff --git a/winixd/core/httpsimpleparser.h b/winixd/core/httpsimpleparser.h index b6d832d..e0cdc1f 100644 --- a/winixd/core/httpsimpleparser.h +++ b/winixd/core/httpsimpleparser.h @@ -36,7 +36,8 @@ #define headerfile_winix_core_httpsimpleparser #include -#include "winixmodel.h" + +#include "winixmodeldeprecated.h" namespace Winix @@ -44,7 +45,7 @@ namespace Winix -class HttpSimpleParser : public WinixModel +class HttpSimpleParser : public WinixModelDeprecated { protected: diff --git a/winixd/core/ipbancontainer.h b/winixd/core/ipbancontainer.h index 7cba8e7..03398d5 100644 --- a/winixd/core/ipbancontainer.h +++ b/winixd/core/ipbancontainer.h @@ -37,7 +37,7 @@ #include #include "ipban.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" @@ -46,7 +46,7 @@ namespace Winix -class IPBanContainer : public WinixModel +class IPBanContainer : public WinixModelDeprecated { public: diff --git a/winixd/core/mountparser.h b/winixd/core/mountparser.h index 3620931..04d7996 100644 --- a/winixd/core/mountparser.h +++ b/winixd/core/mountparser.h @@ -42,8 +42,8 @@ #include #include "mount.h" #include "dirs.h" -#include "winixmodel.h" #include "models/item.h" +#include "winixmodeldeprecated.h" @@ -52,7 +52,7 @@ namespace Winix -class MountParser : public WinixModel +class MountParser : public WinixModelDeprecated { public: diff --git a/winixd/core/mounts.h b/winixd/core/mounts.h index c496f39..077c79a 100644 --- a/winixd/core/mounts.h +++ b/winixd/core/mounts.h @@ -46,7 +46,7 @@ #include "db/db.h" #include "request.h" #include "mountparser.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" namespace Winix @@ -55,7 +55,7 @@ namespace Winix -class Mounts : public WinixModel +class Mounts : public WinixModelDeprecated { public: diff --git a/winixd/core/plugin.cpp b/winixd/core/plugin.cpp index e8fa5a2..114060b 100644 --- a/winixd/core/plugin.cpp +++ b/winixd/core/plugin.cpp @@ -66,7 +66,7 @@ void PluginInfo::set_dependency_for(WinixBase & winix_base) set_dependency_for(&winix_base); } -void PluginInfo::set_dependency_for(WinixModel * winix_model) +void PluginInfo::set_dependency_for(WinixModelDeprecated * winix_model) { plugin->SetDependencyFor(winix_model); @@ -74,7 +74,7 @@ void PluginInfo::set_dependency_for(WinixModel * winix_model) // CHECKME what about model_connector here? } -void PluginInfo::set_dependency_for(WinixModel & winix_model) +void PluginInfo::set_dependency_for(WinixModelDeprecated & winix_model) { set_dependency_for(&winix_model); } @@ -232,7 +232,7 @@ void Plugin::SetDependencyFor(WinixBase * winix_base) } -void Plugin::SetDependencyFor(WinixModel * winix_model) +void Plugin::SetDependencyFor(WinixModelDeprecated * winix_model) { winix_model->set_dependency(winix_request); } diff --git a/winixd/core/plugin.h b/winixd/core/plugin.h index f9fded3..1a1fdef 100644 --- a/winixd/core/plugin.h +++ b/winixd/core/plugin.h @@ -54,7 +54,7 @@ class Functions; class Templates; class SessionManager; -class WinixModel; +class WinixModelDeprecated; class WinixRequest; @@ -81,7 +81,7 @@ struct Session; // move me to a different file -// may it should be based on WinixModel? +// may it should be based on WinixModelDeprecated? struct PluginInfo { // these variables are used for some purposes @@ -134,8 +134,8 @@ struct PluginInfo void set_dependency_for(WinixBase * winix_base); void set_dependency_for(WinixBase & winix_base); - void set_dependency_for(WinixModel * winix_model); - void set_dependency_for(WinixModel & winix_model); + void set_dependency_for(WinixModelDeprecated * winix_model); + void set_dependency_for(WinixModelDeprecated & winix_model); void Clear() { @@ -291,7 +291,7 @@ private: bool SetDependency(PluginInfo & info); void SetDependencyFor(WinixBase * winix_base); - void SetDependencyFor(WinixModel * winix_model); + void SetDependencyFor(WinixModelDeprecated * winix_model); void Lock(); void Unlock(); diff --git a/winixd/core/request.cpp b/winixd/core/request.cpp index 8f8729a..f795952 100644 --- a/winixd/core/request.cpp +++ b/winixd/core/request.cpp @@ -143,6 +143,7 @@ void Request::Clear() return_info_only = false; info.clear(); return_json = false; + models.Clear(); out_bin_stream.clear(); send_bin_stream = false; diff --git a/winixd/core/request.h b/winixd/core/request.h index cc745f4..7106180 100644 --- a/winixd/core/request.h +++ b/winixd/core/request.h @@ -48,6 +48,7 @@ #include "space/space.h" #include "textstream/textstream.h" #include "outstreams.h" +#include "models.h" namespace Winix @@ -309,7 +310,8 @@ struct Request // additional info added when sending the JSON answer pt::Space info; - + // models to return or to render through ezc library + Ezc::Models models; // if set to true then the standard template system will not be used diff --git a/winixd/core/sessioncontainer.h b/winixd/core/sessioncontainer.h index f2e96e8..9b724f1 100644 --- a/winixd/core/sessioncontainer.h +++ b/winixd/core/sessioncontainer.h @@ -42,7 +42,7 @@ #include "session.h" #include "cur.h" #include "config.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" @@ -52,7 +52,7 @@ namespace Winix -class SessionContainer : public WinixModel +class SessionContainer : public WinixModelDeprecated { public: diff --git a/winixd/core/sessionmanager.cpp b/winixd/core/sessionmanager.cpp index c41dc61..aebc969 100644 --- a/winixd/core/sessionmanager.cpp +++ b/winixd/core/sessionmanager.cpp @@ -89,9 +89,9 @@ void SessionManager::SetLastContainer(LastContainer * plast_container) } -void SessionManager::set_dependency(WinixModel * winix_model) +void SessionManager::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); session_tab.set_dependency(winix_model); session_id_manager.set_dependency(winix_model); } diff --git a/winixd/core/sessionmanager.h b/winixd/core/sessionmanager.h index 393d521..564d2cf 100644 --- a/winixd/core/sessionmanager.h +++ b/winixd/core/sessionmanager.h @@ -65,7 +65,7 @@ public: void SetSystem(System * psystem); void SetLastContainer(LastContainer * plast_container); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); // can return a null pointer Session * FindSession(long id); diff --git a/winixd/core/system.cpp b/winixd/core/system.cpp index 5a2a88e..b993d88 100644 --- a/winixd/core/system.cpp +++ b/winixd/core/system.cpp @@ -81,9 +81,9 @@ void System::SetSessionManager(SessionManager * sm) } -void System::set_dependency(WinixModel * winix_model) +void System::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); dirs.set_dependency(this); mounts.set_dependency(this); diff --git a/winixd/core/system.h b/winixd/core/system.h index 86a1c81..81dcb36 100644 --- a/winixd/core/system.h +++ b/winixd/core/system.h @@ -64,7 +64,7 @@ class SessionManager; // file system -class System : WinixModel +class System : WinixModelDeprecated { public: @@ -109,7 +109,7 @@ public: TimeZones time_zones; - using WinixModel::get_model_connector; + using WinixModelDeprecated::get_model_connector; void SetCur(Cur * pcur); //void SetConfig(Config * pconfig); @@ -118,7 +118,7 @@ public: void SetFunctions(Functions * pfunctions); void SetSessionManager(SessionManager * sm); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); void Init(); diff --git a/winixd/core/textstream.h b/winixd/core/textstream.h index 24ed8ed..67cf4cb 100644 --- a/winixd/core/textstream.h +++ b/winixd/core/textstream.h @@ -74,12 +74,20 @@ public: typedef typename StringType::value_type CharType; typedef typename StringType::value_type char_type; + typedef typename StringType::iterator iterator; + typedef typename StringType::const_iterator const_iterator; void Clear(); + void clear(); // utf8 methods call clear(), in the future Clear() will be renamed to clear() bool Empty() const; size_t Size() const; void Reserve(size_t len); + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; + const StringType & Str() const; const CharType * CStr() const; @@ -149,6 +157,12 @@ void TextStream::Clear() buffer.clear(); } +template +void TextStream::clear() +{ + Clear(); +} + template bool TextStream::Empty() const { @@ -168,6 +182,33 @@ void TextStream::Reserve(size_t len) } +template +TextStream::iterator TextStream::begin() +{ + return buffer.begin(); +} + +template +TextStream::iterator TextStream::end() +{ + return buffer.end(); +} + +template +TextStream::const_iterator TextStream::begin() const +{ + return buffer.begin(); +} + +template +TextStream::const_iterator TextStream::end() const +{ + return buffer.end(); +} + + + + template const StringType & TextStream::Str() const { diff --git a/winixd/core/threadmanager.cpp b/winixd/core/threadmanager.cpp index bf7fbb4..c00b9a8 100644 --- a/winixd/core/threadmanager.cpp +++ b/winixd/core/threadmanager.cpp @@ -95,6 +95,10 @@ void ThreadManager::Add(BaseThread * pbase, const wchar_t * thread_name) data.postgresql_connector.wait_for_connection(); data.model_connector.set_db_connector(data.postgresql_connector); data.model_connector.set_flat_connector(data.json_connector); + data.model_connector.set_winix_config(config); + data.model_connector.set_winix_logger(item.object->get_logger()); + data.model_connector.set_logger(item.object->get_logger()); + //data.model_connector.set_winix_request(); item.object->set_model_connector(&data.model_connector); diff --git a/winixd/core/threadmanager.h b/winixd/core/threadmanager.h index 3718a0d..03811af 100644 --- a/winixd/core/threadmanager.h +++ b/winixd/core/threadmanager.h @@ -40,15 +40,14 @@ #include "basethread.h" #include "synchro.h" #include "textstream/textstream.h" +#include "models/winixmodelconnector.h" namespace Winix { - - -class ThreadManager : public WinixModel +class ThreadManager : public WinixModelDeprecated { public: @@ -76,7 +75,7 @@ private: struct ThreadItemData { - morm::ModelConnector model_connector; + WinixModelConnector model_connector; morm::JSONConnector json_connector; morm::PostgreSQLConnector postgresql_connector; diff --git a/winixd/core/users.cpp b/winixd/core/users.cpp index 19e4679..724b25b 100644 --- a/winixd/core/users.cpp +++ b/winixd/core/users.cpp @@ -50,9 +50,9 @@ Users::Users() } -void Users::set_dependency(WinixModel * winix_model) +void Users::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); table.set_dependency(winix_model); last.set_dependency(winix_model); } diff --git a/winixd/core/users.h b/winixd/core/users.h index 3accab0..25aee56 100644 --- a/winixd/core/users.h +++ b/winixd/core/users.h @@ -41,7 +41,7 @@ #include "lastcontainer.h" #include "cur.h" #include "db/db.h" -#include "winixmodel.h" +#include "winixmodeldeprecated.h" @@ -53,13 +53,13 @@ namespace Winix class SessionManager; -class Users : public WinixModel +class Users : public WinixModelDeprecated { typedef UGContainer Table; public: - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); typedef Table::Iterator Iterator; diff --git a/winixd/core/winixmodel.cpp b/winixd/core/winixmodeldeprecated.cpp similarity index 78% rename from winixd/core/winixmodel.cpp rename to winixd/core/winixmodeldeprecated.cpp index e9b0313..7b172a9 100644 --- a/winixd/core/winixmodel.cpp +++ b/winixd/core/winixmodeldeprecated.cpp @@ -32,7 +32,7 @@ * */ -#include "winixmodel.h" +#include "winixmodeldeprecated.h" namespace Winix @@ -40,44 +40,44 @@ namespace Winix -WinixModel::WinixModel() +WinixModelDeprecated::WinixModelDeprecated() { plugin = nullptr; model_connector = nullptr; } -WinixModel::~WinixModel() +WinixModelDeprecated::~WinixModelDeprecated() { } -void WinixModel::set_plugin(Plugin * plugin) +void WinixModelDeprecated::set_plugin(Plugin * plugin) { this->plugin = plugin; } -void WinixModel::set_model_connector(morm::ModelConnector * model_connector) +void WinixModelDeprecated::set_model_connector(morm::ModelConnector * model_connector) { this->model_connector = model_connector; } -morm::ModelConnector * WinixModel::get_model_connector() +morm::ModelConnector * WinixModelDeprecated::get_model_connector() { return model_connector; } -void WinixModel::set_dependency(WinixBase * winix_base) +void WinixModelDeprecated::set_dependency(WinixBase * winix_base) { WinixBase::set_dependency(winix_base); } -void WinixModel::set_dependency(WinixModel * winix_model) +void WinixModelDeprecated::set_dependency(WinixModelDeprecated * winix_model) { WinixBase::set_dependency(winix_model); model_connector = winix_model->model_connector; @@ -85,7 +85,7 @@ void WinixModel::set_dependency(WinixModel * winix_model) } -Plugin * WinixModel::get_plugin() +Plugin * WinixModelDeprecated::get_plugin() { return plugin; } diff --git a/winixd/core/winixmodel.h b/winixd/core/winixmodeldeprecated.h similarity index 92% rename from winixd/core/winixmodel.h rename to winixd/core/winixmodeldeprecated.h index 25d4439..97e265f 100644 --- a/winixd/core/winixmodel.h +++ b/winixd/core/winixmodeldeprecated.h @@ -44,12 +44,12 @@ namespace Winix { // may rename it to WinixConnector or WinixStorage? -class WinixModel : public WinixBase +class WinixModelDeprecated : public WinixBase { public: - WinixModel(); - virtual ~WinixModel(); + WinixModelDeprecated(); + virtual ~WinixModelDeprecated(); void set_model_connector(morm::ModelConnector * model_connector); morm::ModelConnector * get_model_connector(); @@ -57,7 +57,7 @@ public: void set_plugin(Plugin * plugin); void set_dependency(WinixBase * winix_base); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); // temporarily for templates, will be removed diff --git a/winixd/core/winixrequest.cpp b/winixd/core/winixrequest.cpp index 0dc594d..992374f 100644 --- a/winixd/core/winixrequest.cpp +++ b/winixd/core/winixrequest.cpp @@ -79,9 +79,9 @@ void WinixRequest::set_dependency(WinixBase * winix_base) } -void WinixRequest::set_dependency(WinixModel * winix_model) +void WinixRequest::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); } diff --git a/winixd/core/winixrequest.h b/winixd/core/winixrequest.h index 5dba20c..24d4efe 100644 --- a/winixd/core/winixrequest.h +++ b/winixd/core/winixrequest.h @@ -59,7 +59,7 @@ public: void set_dependency(WinixBase * winix_base); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); void set_dependency(WinixSystem * winix_system); void set_dependency(WinixRequest * winix_request); diff --git a/winixd/core/winixsystem.cpp b/winixd/core/winixsystem.cpp index 6813ee8..cda75ed 100644 --- a/winixd/core/winixsystem.cpp +++ b/winixd/core/winixsystem.cpp @@ -62,15 +62,15 @@ void WinixSystem::set_dependency(WinixBase * winix_base) } -void WinixSystem::set_dependency(WinixModel * winix_model) +void WinixSystem::set_dependency(WinixModelDeprecated * winix_model) { - WinixModel::set_dependency(winix_model); + WinixModelDeprecated::set_dependency(winix_model); } void WinixSystem::set_dependency(WinixSystem * winix_system) { - WinixModel::set_dependency(winix_system); + WinixModelDeprecated::set_dependency(winix_system); system = winix_system->system; } diff --git a/winixd/core/winixsystem.h b/winixd/core/winixsystem.h index f9eab1e..01ce81c 100644 --- a/winixd/core/winixsystem.h +++ b/winixd/core/winixsystem.h @@ -35,8 +35,8 @@ #ifndef headerfile_winix_core_winixsystem #define headerfile_winix_core_winixsystem -#include "core/winixmodel.h" #include "core/system.h" +#include "winixmodeldeprecated.h" @@ -44,7 +44,7 @@ namespace Winix { -class WinixSystem : public WinixModel +class WinixSystem : public WinixModelDeprecated { public: @@ -54,7 +54,7 @@ public: void set_system(System * system); void set_dependency(WinixBase * winix_base); - void set_dependency(WinixModel * winix_model); + void set_dependency(WinixModelDeprecated * winix_model); void set_dependency(WinixSystem * winix_system); diff --git a/winixd/functions/cat.cpp b/winixd/functions/cat.cpp index 6d22c3e..2d7252b 100644 --- a/winixd/functions/cat.cpp +++ b/winixd/functions/cat.cpp @@ -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 @@ -67,23 +67,7 @@ void Cat::MakeGet() } cur->request->send_as_attachment = cur->request->IsParam(L"attachment"); - - - // temporary for tests - //////////////////////////////////////////////////////////// - foo1.subject = L"subject

from

foo1"; - foo2.subject = L"subject from foo2"; - - foo1.item_content.content_raw = L"raw content from foo1"; - foo2.item_content.content_raw = L"raw content from foo2"; - - foo1.set_connector(model_connector); - foo2.set_connector(model_connector); - - return_model(L"foo1", foo1); - return_model(L"foo2", foo2); - //////////////////////////////////////////////////////////// - + cur->request->models.Add(L"item", cur->request->item); } diff --git a/winixd/functions/cat.h b/winixd/functions/cat.h index 8194f0e..8815046 100644 --- a/winixd/functions/cat.h +++ b/winixd/functions/cat.h @@ -54,10 +54,6 @@ public: void MakeGet(); -private: - - Item foo1; - Item foo2; }; diff --git a/winixd/functions/functionbase.cpp b/winixd/functions/functionbase.cpp index f1514a9..2bca752 100644 --- a/winixd/functions/functionbase.cpp +++ b/winixd/functions/functionbase.cpp @@ -149,18 +149,6 @@ void FunctionBase::MakeDelete() -void FunctionBase::return_model(const wchar_t * name, morm::Model & model) -{ - TemplatesFunctions::ezc_models.Add(name, model); -} - -void FunctionBase::return_model(const wchar_t * name, morm::Model * model) -{ - TemplatesFunctions::ezc_models.Add(name, model); -} - - - } // namespace Winix diff --git a/winixd/functions/functionbase.h b/winixd/functions/functionbase.h index 447c2d0..ae57663 100644 --- a/winixd/functions/functionbase.h +++ b/winixd/functions/functionbase.h @@ -102,9 +102,6 @@ public: //void SetSessionManager(SessionManager * pmanager); - virtual void return_model(const wchar_t * name, morm::Model & model); - virtual void return_model(const wchar_t * name, morm::Model * model); - protected: //Config * config; diff --git a/winixd/functions/functionparser.h b/winixd/functions/functionparser.h index 5e4762b..28abbda 100644 --- a/winixd/functions/functionparser.h +++ b/winixd/functions/functionparser.h @@ -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 @@ -36,10 +36,11 @@ #define headerfile_winix_functions_functionparser #include + +#include "core/winixmodeldeprecated.h" #include "db/db.h" #include "core/cur.h" #include "core/system.h" -#include "core/winixmodel.h" namespace Winix @@ -49,7 +50,7 @@ namespace Winix class Functions; -class FunctionParser : public WinixModel +class FunctionParser : public WinixModelDeprecated { public: diff --git a/winixd/functions/imgcrop.cpp b/winixd/functions/imgcrop.cpp index 2bbde6b..26b216d 100644 --- a/winixd/functions/imgcrop.cpp +++ b/winixd/functions/imgcrop.cpp @@ -72,7 +72,7 @@ void ImgCrop::GetDirContent() morm::Finder finder(model_connector); - cur->request->item_tab = finder. + item_tab = finder. select(). where(). eq(L"type", static_cast(Item::file)). @@ -81,7 +81,7 @@ void ImgCrop::GetDirContent() get_vector(); //db->GetItems(cur->request->item_tab, iq); - system->CheckWriteAccessToItems(cur->request->item_tab); + system->CheckWriteAccessToItems(item_tab); } @@ -137,7 +137,10 @@ void ImgCrop::MakePost() void ImgCrop::MakeGet() { if( !cur->request->is_item ) + { GetDirContent(); + cur->request->models.Add(L"item_tab", item_tab); + } } diff --git a/winixd/functions/imgcrop.h b/winixd/functions/imgcrop.h index 9eb2853..6e470e9 100644 --- a/winixd/functions/imgcrop.h +++ b/winixd/functions/imgcrop.h @@ -55,9 +55,11 @@ public: void MakeGet(); void MakePost(); + // IMPROVEME add method Clear() or ClearAfterRequest()? and clear item_tab + private: - //DbItemQuery iq; + std::vector item_tab; void GetDirContent(); diff --git a/winixd/functions/privchanger.h b/winixd/functions/privchanger.h index 3341545..a4461ef 100644 --- a/winixd/functions/privchanger.h +++ b/winixd/functions/privchanger.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2010-2018, Tomasz Sowa + * Copyright (c) 2010-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,17 +35,17 @@ #ifndef headerfile_winix_functions_privchanger #define headerfile_winix_functions_privchanger +#include "core/winixmodeldeprecated.h" #include "core/request.h" #include "core/system.h" #include "db/db.h" -#include "core/winixmodel.h" namespace Winix { -class PrivChanger : public WinixModel +class PrivChanger : public WinixModelDeprecated { public: diff --git a/winixd/html/fun_cat.html b/winixd/html/fun_cat.html index 5b1db4f..bdabd66 100644 --- a/winixd/html/fun_cat.html +++ b/winixd/html/fun_cat.html @@ -1,4 +1,4 @@ -[if item_content_type_is "other"][item_print_content][else] +[if item_content_type_is "other"][item.content.print_content][else] [if false] [if mount_page_arg_is "subject"][if mount_page_arg_is "info"]

[else]

[end][item_subject]

[end] @@ -18,7 +18,7 @@ - [item_print_content] + [item.content.print_content] [else] @@ -30,10 +30,10 @@ - [item_print_content] + [item.content.print_content] [else] - [item_print_content] + [item.content.print_content] [end] [end] diff --git a/winixd/html/fun_imgcrop.html b/winixd/html/fun_imgcrop.html index 7a11211..83363ef 100644 --- a/winixd/html/fun_imgcrop.html +++ b/winixd/html/fun_imgcrop.html @@ -79,22 +79,22 @@ - - [item_tab_subject] + + [item_tab.subject] - [item_tab_url] + [item_tab.url] diff --git a/winixd/models/item.cpp b/winixd/models/item.cpp index ff61d0b..64ad7d4 100644 --- a/winixd/models/item.cpp +++ b/winixd/models/item.cpp @@ -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_helper); @@ -232,6 +236,73 @@ void Item::propagate_connector() } +// IMPROVEME move me to a better place +void Item::print_dir(Ezc::FunInfo & 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 & 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 & env) +{ + Request * req = get_request(); + + if( req ) + { + env.res = req->is_item; + } +} + + +void Item::link(Ezc::FunInfo & 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 diff --git a/winixd/models/item.h b/winixd/models/item.h index 0c001ff..fbf0e86 100644 --- a/winixd/models/item.h +++ b/winixd/models/item.h @@ -36,8 +36,8 @@ #define headerfile_winix_models_item #include -#include "model.h" -#include "models/itemcontent.h" +#include "winixmodel.h" +#include "itemcontent.h" // temporary @@ -89,7 +89,7 @@ public: }; -class Item : public morm::Model +class Item : public WinixModel { public: @@ -184,11 +184,11 @@ public: void propagate_connector(); - // for tests - static void my_test_function(Ezc::FunInfo & env) - { - env.out << L"hello from function"; - } + void print_dir(Ezc::FunInfo & env); + void print_dir_without_slash(Ezc::FunInfo & env); + + void is(Ezc::FunInfo & env); + void link(Ezc::FunInfo & env); protected: @@ -200,6 +200,7 @@ protected: bool do_migration_to_3(); bool do_migration_to_4(); + MORM_MEMBER_FIELD(Item) }; diff --git a/winixd/models/itemcontent.cpp b/winixd/models/itemcontent.cpp index 532b764..5a5e6a4 100644 --- a/winixd/models/itemcontent.cpp +++ b/winixd/models/itemcontent.cpp @@ -35,7 +35,8 @@ #include "models/itemcontent.h" #include "core/crypt.h" #include "core/misc.h" - +#include "templates/misc.h" +#include "core/bbcodeparser.h" namespace Winix @@ -81,6 +82,8 @@ void ItemContent::fields() field(L"meta", meta); field(L"meta_admin", meta_admin); + field(L"print_content", &ItemContent::print_content); + content_raw_type = static_cast(content_raw_type_helper); content_parsed_type = static_cast(content_parsed_type_helper); } @@ -166,6 +169,51 @@ bool ItemContent::CanContentBeHtmlFiltered() + +void ItemContent::print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on) +{ + using TemplatesFunctions::R; + + if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) ) + out << R(""); + + if( content_type == ItemContent::ct_text ) + { + out << content; + } + else + if( content_type == ItemContent::ct_formatted_text ) + { + TemplatesFunctions::HtmlEscapeFormTxt(out, content); + } + else + if( content_type == ItemContent::ct_bbcode ) + { + static std::wstring out_temp; + out_temp.clear(); + out_temp.reserve(content.size()*2); + + BBCODEParser bbcode_parser; // IMPROVE ME move me to a better place + bbcode_parser.Filter(content.c_str(), out_temp); + out << R(out_temp); + } + else + { + // ct_html, ct_other + out << R(content); + } + + if( is_html_filter_on && !ItemContent::CanContentBeHtmlFiltered(content_type) ) + out << R(""); +} + + +void ItemContent::print_content(Ezc::FunInfo & env) +{ + print_content(env.out, content_raw, content_raw_type, true); // IMPROVE ME get the 'true' from the config (config->html_filter) +} + + bool ItemContent::do_migration(int & current_table_version) { bool ok = true; diff --git a/winixd/models/itemcontent.h b/winixd/models/itemcontent.h index 15ac948..b05f6ec 100644 --- a/winixd/models/itemcontent.h +++ b/winixd/models/itemcontent.h @@ -39,6 +39,7 @@ #include "space/space.h" #include "date/date.h" #include "model.h" +#include "templates/htmltextstream.h" namespace Winix @@ -230,6 +231,9 @@ public: bool CanContentBeHtmlFiltered(); + static void print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type, bool is_html_filter_on); + void print_content(Ezc::FunInfo & env); + bool do_migration(int & current_table_version); @@ -240,6 +244,8 @@ protected: bool do_migration_to_2(); bool do_migration_to_3(); + MORM_MEMBER_FIELD(ItemContent) + }; diff --git a/winixd/models/winixmodel.cpp b/winixd/models/winixmodel.cpp new file mode 100644 index 0000000..e6edcfa --- /dev/null +++ b/winixd/models/winixmodel.cpp @@ -0,0 +1,96 @@ +/* + * This file is a part of Winix + * and is distributed under the 2-Clause BSD licence. + * Author: Tomasz Sowa + */ + +/* + * 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 "winixmodel.h" + +namespace Winix +{ + +Config * WinixModel::get_config() +{ + WinixModelConnector * connector = get_winix_model_connector(); + + if( connector ) + { + return connector->get_winix_config(); + } + + return nullptr; +} + + +Request * WinixModel::get_request() +{ + WinixModelConnector * connector = get_winix_model_connector(); + + if( connector ) + { + return connector->get_winix_request(); + } + + return nullptr; +} + + +Log * WinixModel::get_logger() +{ + WinixModelConnector * connector = get_winix_model_connector(); + + if( connector ) + { + return connector->get_winix_logger(); + } + + return nullptr; +} + + +WinixModelConnector * WinixModel::get_winix_model_connector() +{ + if( model_connector ) + { + return dynamic_cast(model_connector); + } + + return nullptr; +} + + + + + + + +} + diff --git a/winixd/models/winixmodel.h b/winixd/models/winixmodel.h new file mode 100644 index 0000000..4fdc1af --- /dev/null +++ b/winixd/models/winixmodel.h @@ -0,0 +1,68 @@ +/* + * This file is a part of Winix + * and is distributed under the 2-Clause BSD licence. + * Author: Tomasz Sowa + */ + +/* + * 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_winixmodel +#define headerfile_winix_models_winixmodel + +#include "model.h" +#include "core/log.h" +#include "winixmodelconnector.h" + + +namespace Winix +{ +class Config; +class Request; +class Log; + + +class WinixModel : public morm::Model +{ +public: + + Config * get_config(); + Request * get_request(); + Log * get_logger(); + + +protected: + + WinixModelConnector * get_winix_model_connector(); + + +}; + +} + +#endif diff --git a/winixd/models/winixmodelconnector.cpp b/winixd/models/winixmodelconnector.cpp new file mode 100644 index 0000000..3ca8733 --- /dev/null +++ b/winixd/models/winixmodelconnector.cpp @@ -0,0 +1,88 @@ +/* + * This file is a part of Winix + * and is distributed under the 2-Clause BSD licence. + * Author: Tomasz Sowa + */ + +/* + * 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 "winixmodelconnector.h" + + +namespace Winix +{ + + +WinixModelConnector::WinixModelConnector() +{ + config = nullptr; + request = nullptr; + log = nullptr; +} + + +Config * WinixModelConnector::get_winix_config() +{ + return config; +} + + +Request * WinixModelConnector::get_winix_request() +{ + return request; +} + + +Log * WinixModelConnector::get_winix_logger() +{ + return log; +} + + +void WinixModelConnector::set_winix_config(Config * config) +{ + this->config = config; +} + + +void WinixModelConnector::set_winix_request(Request * request) +{ + this->request = request; +} + + +void WinixModelConnector::set_winix_logger(Log * log) +{ + this->log = log; +} + + + +} + diff --git a/winixd/models/winixmodelconnector.h b/winixd/models/winixmodelconnector.h new file mode 100644 index 0000000..03f3dc5 --- /dev/null +++ b/winixd/models/winixmodelconnector.h @@ -0,0 +1,72 @@ +/* + * This file is a part of Winix + * and is distributed under the 2-Clause BSD licence. + * Author: Tomasz Sowa + */ + +/* + * 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_winixmodelconnector +#define headerfile_winix_models_winixmodelconnector + +#include "modelconnector.h" + + +namespace Winix +{ +class Config; +class Request; +class Log; + +class WinixModelConnector : public morm::ModelConnector +{ +public: + + WinixModelConnector(); + + Config * get_winix_config(); + Request * get_winix_request(); + Log * get_winix_logger(); + + void set_winix_config(Config * config); + void set_winix_request(Request * request); + void set_winix_logger(Log * log); + + +protected: + + Config * config; // one global config + Request * request; // each thread worker has its own request (not implemented yet) + Log * log; // each thread has its own logger + +}; + +} + +#endif diff --git a/winixd/notify/notify.h b/winixd/notify/notify.h index 38aff18..7600461 100644 --- a/winixd/notify/notify.h +++ b/winixd/notify/notify.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2010-2014, Tomasz Sowa + * Copyright (c) 2010-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,10 +37,11 @@ #include #include + +#include "core/winixmodeldeprecated.h" #include "notifypool.h" #include "templates/patterns.h" #include "notifythread.h" -#include "core/winixmodel.h" @@ -56,7 +57,7 @@ class ThreadManager; class FileLog; -class Notify : public WinixModel +class Notify : public WinixModelDeprecated { public: diff --git a/winixd/plugins/export/exportinfo.h b/winixd/plugins/export/exportinfo.h index f4d5cfe..bba701e 100644 --- a/winixd/plugins/export/exportinfo.h +++ b/winixd/plugins/export/exportinfo.h @@ -41,7 +41,7 @@ #include "edb.h" #include "message.h" #include "exportthread.h" -#include "core/winixmodel.h" +#include "core/winixmodeldeprecated.h" @@ -52,7 +52,7 @@ namespace Export { -class ExportInfo : public WinixModel +class ExportInfo : public WinixModelDeprecated { public: diff --git a/winixd/plugins/stats/stats.h b/winixd/plugins/stats/stats.h index 4cb823a..5dae716 100644 --- a/winixd/plugins/stats/stats.h +++ b/winixd/plugins/stats/stats.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2010-2018, Tomasz Sowa + * Copyright (c) 2010-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ #include #include #include "core/config.h" -#include "core/winixmodel.h" +#include "core/winixmodeldeprecated.h" namespace Winix @@ -50,7 +50,7 @@ namespace Stats -struct Stats : public WinixModel +struct Stats : public WinixModelDeprecated { Stats(); diff --git a/winixd/plugins/thread/templates.cpp b/winixd/plugins/thread/templates.cpp index fa646f4..3e597ae 100644 --- a/winixd/plugins/thread/templates.cpp +++ b/winixd/plugins/thread/templates.cpp @@ -183,7 +183,7 @@ void thread_sort_tab_print_content(Info & i) std::wstring & content = thread_info.item_sort_tab[item_sort_index]->item_content.content_raw; ItemContent::ContentType type = thread_info.item_sort_tab[item_sort_index]->item_content.content_raw_type; - item_print_content(i.out, content, type); + ItemContent::print_content(i.out, content, type, config->html_filter); } @@ -354,11 +354,11 @@ void thread_sort_tab_run(Info & i) Ezc::Pattern * p = pattern_cacher.GetPattern(*thread_info.item_sort_tab[item_sort_index]); item_run_content.Clear(); - InitGenerator(ezc_generator); + InitGenerator(ezc_generator, cur->request->models); ezc_generator.SetPattern(*p); ezc_generator.Generate(item_run_content); - item_print_content(i.out, item_run_content.Str(), thread_info.item_sort_tab[item_sort_index]->item_content.content_raw_type); + ItemContent::print_content(i.out, item_run_content.Str(), thread_info.item_sort_tab[item_sort_index]->item_content.content_raw_type, config->html_filter); } else { diff --git a/winixd/plugins/thread/threadinfo.h b/winixd/plugins/thread/threadinfo.h index edbd404..d91edf0 100644 --- a/winixd/plugins/thread/threadinfo.h +++ b/winixd/plugins/thread/threadinfo.h @@ -40,7 +40,7 @@ #include "db/db.h" #include "thread.h" #include "tdb.h" -#include "core/winixmodel.h" +#include "core/winixmodeldeprecated.h" #include "models/item.h" @@ -52,7 +52,7 @@ namespace Winix namespace Thread { -class ThreadInfo : public WinixModel +class ThreadInfo : public WinixModelDeprecated { public: diff --git a/winixd/plugins/ticket/ticketinfo.h b/winixd/plugins/ticket/ticketinfo.h index 96fc645..5af7cae 100644 --- a/winixd/plugins/ticket/ticketinfo.h +++ b/winixd/plugins/ticket/ticketinfo.h @@ -42,7 +42,7 @@ #include "db/db.h" #include "tdb.h" #include "space/spaceparser.h" -#include "core/winixmodel.h" +#include "core/winixmodeldeprecated.h" #include "models/item.h" @@ -67,7 +67,7 @@ struct TicketConfWrap }; -class TicketInfo : public WinixModel +class TicketInfo : public WinixModelDeprecated { public: diff --git a/winixd/templates/htmltextstream.cpp b/winixd/templates/htmltextstream.cpp index 741a9ef..5b2d13f 100644 --- a/winixd/templates/htmltextstream.cpp +++ b/winixd/templates/htmltextstream.cpp @@ -52,6 +52,12 @@ void HtmlTextStream::Clear() } +void HtmlTextStream::clear() +{ + Clear(); +} + + /* without escaping diff --git a/winixd/templates/htmltextstream.h b/winixd/templates/htmltextstream.h index 89ecf3b..1e79730 100644 --- a/winixd/templates/htmltextstream.h +++ b/winixd/templates/htmltextstream.h @@ -85,6 +85,7 @@ public: * clearing the buffer and setting 'escape' flag to true */ void Clear(); + void clear(); // utf8 methods call clear(), in the future Clear() will be renamed to clear() /* diff --git a/winixd/templates/insert.cpp b/winixd/templates/insert.cpp index 690df7d..9e047ca 100644 --- a/winixd/templates/insert.cpp +++ b/winixd/templates/insert.cpp @@ -74,10 +74,10 @@ void insert_page_run(Info & i) info.run_content.Clear(); - InitGenerator(info.ezc_gen); + InitGenerator(info.ezc_gen, cur->request->models); info.ezc_gen.SetPattern(*pat); info.ezc_gen.Generate(info.run_content); - item_print_content(i.out, info.run_content.Str(), info.item.item_content.content_raw_type); + ItemContent::print_content(i.out, info.run_content.Str(), info.item.item_content.content_raw_type, config->html_filter); insert_page_cur -= 1; } @@ -119,7 +119,7 @@ void insert_page(Info & i) insert_page_run(i); else if( system->HasReadAccess(info.item) ) - item_print_content(i.out, info.item.item_content.content_raw, info.item.item_content.content_raw_type); + ItemContent::print_content(i.out, info.item.item_content.content_raw, info.item.item_content.content_raw_type, config->html_filter); } } diff --git a/winixd/templates/item.cpp b/winixd/templates/item.cpp index 95f5484..c8a07bc 100644 --- a/winixd/templates/item.cpp +++ b/winixd/templates/item.cpp @@ -46,7 +46,6 @@ namespace Winix namespace TemplatesFunctions { -static BBCODEParser bbcode_parser; static HtmlTextStream item_run_content; static EzcGen ezc_generator; @@ -126,52 +125,11 @@ void item_content_type_is(Info & i) } -void item_print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type) -{ - if( config->html_filter && !ItemContent::CanContentBeHtmlFiltered(content_type) ) - out << R(""); - - if( content_type == ItemContent::ct_text ) - { - out << content; - } - else - if( content_type == ItemContent::ct_formatted_text ) - { - HtmlEscapeFormTxt(out, content); - } - else - if( content_type == ItemContent::ct_bbcode ) - { - static std::wstring out_temp; - out_temp.clear(); - out_temp.reserve(content.size()*2); - - bbcode_parser.Filter(content.c_str(), out_temp); - out << R(out_temp); - } - else - { - // ct_html, ct_other - out << R(content); - } - - if( config->html_filter && !ItemContent::CanContentBeHtmlFiltered(content_type) ) - out << R(""); -} - - void item_content_is_empty(Info & i) { i.res = cur->request->last_item->item_content.content_raw.empty(); } -void item_print_content(Info & i) -{ - item_print_content(i.out, cur->request->last_item->item_content.content_raw, cur->request->last_item->item_content.content_raw_type); -} - - void item_privileges(Info & i) { @@ -332,7 +290,7 @@ void item_run(Info & i) Ezc::Pattern * p = pattern_cacher.GetPattern(*cur->request->last_item); item_run_content.Clear(); - InitGenerator(ezc_generator); + InitGenerator(ezc_generator, cur->request->models); ezc_generator.SetPattern(*p); if( config->allow_ezc_frames_in_executable_items ) @@ -340,7 +298,7 @@ void item_run(Info & i) else ezc_generator.Generate(item_run_content); - item_print_content(i.out, item_run_content.Str(), cur->request->last_item->item_content.content_raw_type); + ItemContent::print_content(i.out, item_run_content.Str(), cur->request->last_item->item_content.content_raw_type, config->html_filter); } else { @@ -490,7 +448,7 @@ void item_can_content_be_html_filtered(Info & i) } - +/* static size_t item_index; @@ -739,7 +697,7 @@ void item_tab_run(Info & i) { Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item_tab[item_index]); item_run_content.Clear(); - InitGenerator(ezc_generator); + InitGenerator(ezc_generator, cur->request->models); ezc_generator.SetPattern(*p); if( config->allow_ezc_frames_in_executable_items ) @@ -884,7 +842,7 @@ void item_tab_meta_tab_has_next(Info & i) if( item_index < cur->request->item_tab.size() ) space_list_tab_has_next(i, cur->request->item_tab[item_index].item_content.meta, L"item_tab_meta_tab"); } - +*/ diff --git a/winixd/templates/misc.cpp b/winixd/templates/misc.cpp index 7422fa5..806d188 100644 --- a/winixd/templates/misc.cpp +++ b/winixd/templates/misc.cpp @@ -48,7 +48,6 @@ namespace TemplatesFunctions extern EzcFun ezc_functions; extern Ezc::Blocks ezc_blocks; extern Ezc::Vars ezc_vars; -extern Ezc::Models ezc_models; void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in) @@ -93,7 +92,7 @@ int was_enter = 0; // how many enteres there were before -void InitGenerator(EzcGen & gen) +void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models) { gen.TrimWhite(gen_trim_white); gen.SkipNewLine(gen_skip_new_line); diff --git a/winixd/templates/misc.h b/winixd/templates/misc.h index 20503a0..a62a757 100644 --- a/winixd/templates/misc.h +++ b/winixd/templates/misc.h @@ -63,7 +63,7 @@ HtmlTextStream::RawText R(const RawType & par) } -void InitGenerator(EzcGen & gen); +void InitGenerator(EzcGen & gen, Ezc::Models & ezc_models); void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in); diff --git a/winixd/templates/templates.cpp b/winixd/templates/templates.cpp index 9205125..cde76d6 100644 --- a/winixd/templates/templates.cpp +++ b/winixd/templates/templates.cpp @@ -63,7 +63,6 @@ EzcFun ezc_functions; Ezc::Blocks ezc_blocks; Ezc::Objects ezc_objects; Ezc::Vars ezc_vars; -Ezc::Models ezc_models; LocaleFilter locale_filter; HTMLFilter html_filter; @@ -186,7 +185,7 @@ Ezc::Pattern * p = 0; if( p ) { - InitGenerator(content_gen); + InitGenerator(content_gen, cur->request->models); content_gen.SetPattern(*p); content_gen.Generate(i.out, cur->request->out_streams); } @@ -438,7 +437,6 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_content", item_content); ezc_functions.Insert("item_content_noescape", item_content_noescape); ezc_functions.Insert("item_content_type_is", item_content_type_is); - ezc_functions.Insert("item_print_content", item_print_content); ezc_functions.Insert("item_privileges", item_privileges); ezc_functions.Insert("item_dir", item_dir); ezc_functions.Insert("item_url", item_url); @@ -486,6 +484,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_admin_meta_tab_has_next", item_admin_meta_tab_has_next); ezc_functions.Insert("item_can_content_be_html_filtered", item_can_content_be_html_filtered); + /* ezc_functions.Insert("item_tab", item_tab); ezc_functions.Insert("item_tab_index", item_tab_index); ezc_functions.Insert("item_tab_id", item_tab_id); @@ -530,7 +529,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_tab_meta_tab", item_tab_meta_tab); ezc_functions.Insert("item_tab_meta_tab_value", item_tab_meta_tab_value); ezc_functions.Insert("item_tab_meta_tab_has_next", item_tab_meta_tab_has_next); - + */ /* last @@ -1024,8 +1023,6 @@ using namespace TemplatesFunctions; log << log4 << "Templates: patterns cache size: " << pattern_cacher.Size() << logend; pattern_cacher.DeleteOldPatterns(); - - ezc_models.Clear(); } @@ -1128,7 +1125,7 @@ using namespace TemplatesFunctions; if( index ) { - InitGenerator(generator); + InitGenerator(generator, cur->request->models); generator.SetPattern(*index); generator.Generate(cur->request->out_main_stream, cur->request->out_streams); } @@ -1147,7 +1144,7 @@ void Templates::Generate(Ezc::Pattern & pattern) using namespace TemplatesFunctions; ezc_vars.clear(); - InitGenerator(generator); + InitGenerator(generator, cur->request->models); generator.SetPattern(pattern); generator.Generate(cur->request->out_main_stream, cur->request->out_streams); } diff --git a/winixd/templates/templates.h b/winixd/templates/templates.h index ad5448a..e84480e 100644 --- a/winixd/templates/templates.h +++ b/winixd/templates/templates.h @@ -96,9 +96,6 @@ namespace TemplatesFunctions extern bool gen_skip_new_line; extern bool gen_use_special_chars; - extern Ezc::Models ezc_models; - - /* adduser @@ -331,8 +328,6 @@ namespace TemplatesFunctions void item_content_type_is(Item & item, Info & i); void item_content_type_is(Info & i); void item_content_is_empty(Info & i); - void item_print_content(HtmlTextStream & out, const std::wstring & content, ItemContent::ContentType content_type); - void item_print_content(Info & i); void item_privileges(Info & i); void item_dir(Info & i); void item_url(Info & i); @@ -379,6 +374,7 @@ namespace TemplatesFunctions void item_admin_meta_tab_has_next(Info & i); void item_can_content_be_html_filtered(Info & i); + /* void item_tab(Info & i); void item_tab_index(Info & i); void item_tab_id(Info & i); @@ -423,7 +419,7 @@ namespace TemplatesFunctions void item_tab_meta_tab(Info & i); void item_tab_meta_tab_value(Info & i); void item_tab_meta_tab_has_next(Info & i); - + */ /* last