From f3cd3b88b9811b4f1a541b866650867ea37b0133 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Fri, 13 Aug 2010 20:04:57 +0000 Subject: [PATCH] some improvement in templates (now we have O(1) time for selecting the right html template) added: winix function: template for selecting a template for an item (file or dir) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@636 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/Makefile.dep | 62 ++++++----- core/app.cpp | 2 +- core/config.cpp | 5 + core/config.h | 15 +++ core/db.cpp | 45 +++++++- core/db.h | 8 +- core/db_itemcolumns.cpp | 2 + core/item.h | 4 + core/mount.cpp | 4 +- core/mount.h | 2 +- core/request.h | 4 +- functions/Makefile.dep | 60 ++++++---- functions/Makefile.o.dep | 2 +- functions/functionbase.cpp | 2 + functions/functionbase.h | 5 + functions/functions.cpp | 30 ++++- functions/functions.h | 10 +- functions/template.cpp | 70 ++++++++++++ functions/template.h | 38 +++++++ html/fun_cat.html | 3 +- html/fun_chmod.html | 2 + html/fun_chown.html | 1 + html/fun_run.html | 2 +- html/fun_template.html | 65 +++++++++++ html/fun_thread.html | 4 +- html/fun_ticket.html | 4 +- html/item_modify_info.html | 0 locale/en | 8 ++ locale/pl | 9 ++ main/Makefile.dep | 15 +-- plugins/stats/Makefile.dep | 27 ++--- static/layout1/winix.css | 7 +- templates/Makefile.dep | 42 ++++--- templates/Makefile.o.dep | 2 +- templates/dir.cpp | 16 ++- templates/item.cpp | 20 +++- templates/mount.cpp | 14 ++- templates/template.cpp | 113 +++++++++++++++++++ templates/templates.cpp | 222 ++++++++++++++++++++----------------- templates/templates.h | 38 +++++-- 40 files changed, 756 insertions(+), 228 deletions(-) create mode 100755 functions/template.cpp create mode 100755 functions/template.h create mode 100755 html/fun_template.html delete mode 100755 html/item_modify_info.html create mode 100755 templates/template.cpp diff --git a/core/Makefile.dep b/core/Makefile.dep index cbd39a6..3d65e4f 100755 --- a/core/Makefile.dep +++ b/core/Makefile.dep @@ -22,10 +22,10 @@ app.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h app.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h app.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h app.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -app.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -app.o: ../functions/uptime.h ../functions/who.h ../templates/templates.h -app.o: ../templates/patterncacher.h ../core/item.h misc.h -app.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h +app.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +app.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +app.o: ../templates/templates.h ../templates/patterncacher.h ../core/item.h +app.o: misc.h ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h app.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h app.o: compress.h getparser.h httpsimpleparser.h postparser.h cookieparser.h app.o: postmultiparser.h acceptencodingparser.h acceptbaseparser.h plugin.h @@ -51,13 +51,13 @@ config.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h config.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h config.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h config.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -config.o: ../functions/uptime.h ../functions/who.h ../templates/templates.h -config.o: ../templates/patterncacher.h ../core/item.h misc.h -config.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -config.o: ../core/log.h ../templates/indexpatterns.h -config.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h -config.o: ../core/sessionmanager.h +config.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +config.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +config.o: ../templates/templates.h ../templates/patterncacher.h +config.o: ../core/item.h misc.h ../templates/ckeditorgetparser.h +config.o: ../core/httpsimpleparser.h ../core/log.h +config.o: ../templates/indexpatterns.h ../templates/localefilter.h +config.o: ../core/locale.h ../core/locale.h ../core/sessionmanager.h confparser.o: confparser.h misc.h item.h db.o: db.h item.h user.h group.h thread.h error.h log.h dircontainer.h db.o: ugcontainer.h ticket.h misc.h @@ -111,13 +111,13 @@ plugin.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h plugin.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h plugin.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h plugin.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -plugin.o: ../functions/uptime.h ../functions/who.h ../templates/templates.h -plugin.o: ../templates/patterncacher.h ../core/item.h misc.h -plugin.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -plugin.o: ../core/log.h ../templates/indexpatterns.h -plugin.o: ../templates/localefilter.h ../core/locale.h ../core/locale.h -plugin.o: ../core/sessionmanager.h +plugin.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +plugin.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +plugin.o: ../templates/templates.h ../templates/patterncacher.h +plugin.o: ../core/item.h misc.h ../templates/ckeditorgetparser.h +plugin.o: ../core/httpsimpleparser.h ../core/log.h +plugin.o: ../templates/indexpatterns.h ../templates/localefilter.h +plugin.o: ../core/locale.h ../core/locale.h ../core/sessionmanager.h plugindata.o: plugindata.h plugin.h pluginmsg.h log.h config.h confparser.h plugindata.o: htmlfilter.h request.h requesttypes.h session.h item.h error.h plugindata.o: user.h rebus.h system.h dirs.h dircontainer.h db.h group.h @@ -140,8 +140,9 @@ plugindata.o: ../functions/node.h ../functions/priv.h ../functions/reload.h plugindata.o: ../functions/rm.h ../functions/run.h ../functions/subject.h plugindata.o: ../functions/funthread.h ../core/thread.h plugindata.o: ../functions/funticket.h ../core/ticket.h -plugindata.o: ../functions/tinymce.h ../functions/uname.h -plugindata.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +plugindata.o: ../functions/template.h ../functions/tinymce.h +plugindata.o: ../functions/uname.h ../functions/upload.h +plugindata.o: ../functions/uptime.h ../functions/who.h plugindata.o: ../templates/templates.h ../templates/patterncacher.h plugindata.o: ../core/item.h misc.h ../templates/ckeditorgetparser.h plugindata.o: ../core/httpsimpleparser.h ../core/log.h @@ -170,8 +171,9 @@ request.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h request.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h request.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h request.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -request.o: ../functions/uptime.h ../functions/who.h ../templates/templates.h +request.o: ../functions/template.h ../functions/tinymce.h +request.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h +request.o: ../functions/who.h ../templates/templates.h request.o: ../templates/patterncacher.h ../core/item.h misc.h request.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h request.o: ../core/log.h ../templates/indexpatterns.h @@ -203,14 +205,14 @@ sessionmanager.o: ../functions/node.h ../functions/priv.h sessionmanager.o: ../functions/reload.h ../functions/rm.h ../functions/run.h sessionmanager.o: ../functions/subject.h ../functions/funthread.h sessionmanager.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -sessionmanager.o: ../functions/tinymce.h ../functions/uname.h -sessionmanager.o: ../functions/upload.h ../functions/uptime.h -sessionmanager.o: ../functions/who.h ../templates/templates.h -sessionmanager.o: ../templates/patterncacher.h ../core/item.h misc.h -sessionmanager.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -sessionmanager.o: ../core/log.h ../templates/indexpatterns.h -sessionmanager.o: ../templates/localefilter.h ../core/locale.h -sessionmanager.o: ../core/locale.h ../core/sessionmanager.h +sessionmanager.o: ../functions/template.h ../functions/tinymce.h +sessionmanager.o: ../functions/uname.h ../functions/upload.h +sessionmanager.o: ../functions/uptime.h ../functions/who.h +sessionmanager.o: ../templates/templates.h ../templates/patterncacher.h +sessionmanager.o: ../core/item.h misc.h ../templates/ckeditorgetparser.h +sessionmanager.o: ../core/httpsimpleparser.h ../core/log.h +sessionmanager.o: ../templates/indexpatterns.h ../templates/localefilter.h +sessionmanager.o: ../core/locale.h ../core/locale.h ../core/sessionmanager.h sessionparser.o: sessionparser.h session.h item.h error.h log.h user.h sessionparser.o: plugindata.h rebus.h sessioncontainer.h lastcontainer.h sessionparser.o: users.h ugcontainer.h request.h requesttypes.h config.h diff --git a/core/app.cpp b/core/app.cpp index c7cff80..17ad63e 100755 --- a/core/app.cpp +++ b/core/app.cpp @@ -144,7 +144,7 @@ bool App::Init() if( !notify.Init() ) return false; - + // init templates after functions are created templates.ReadIndexFileNames(); templates.ReadTemplates(); templates.CreateFunctions(); diff --git a/core/config.cpp b/core/config.cpp index 8799cc5..fa2ed90 100755 --- a/core/config.cpp +++ b/core/config.cpp @@ -107,6 +107,11 @@ void Config::AssignValues(bool stdout_is_closed) templates_dir = Text("templates_dir"); templates_dir_default = Text("templates_dir_default"); + templates_fun_prefix = Text("templates_fun_prefix", "fun_"); + templates_fun_postfix = Text("templates_fun_postfix", ".html"); + templates_index = Text("templates_index", "index.html"); + template_only_root_use_template_fun = Bool("template_only_root_use_template_fun", false); + http_session_id_name = Text("http_session_id_name"); db_database = Text("db_database"); db_user = Text("db_user"); diff --git a/core/config.h b/core/config.h index 3a2fc8e..d1868e7 100755 --- a/core/config.h +++ b/core/config.h @@ -57,6 +57,21 @@ public: std::string templates_dir; std::string templates_dir_default; // templates from winix + // prefix and postfix for functions templates + // default: + // prefix: "fun_" + // postfix: ".html" + std::string templates_fun_prefix; + std::string templates_fun_postfix; + + // main html template + // default: index.html + std::string templates_index; + + // if true then only root can use 'template' function + // default: false + bool template_only_root_use_template_fun; + std::string db_database; std::string db_user; std::string db_pass; diff --git a/core/db.cpp b/core/db.cpp index 31638d1..c1c6409 100755 --- a/core/db.cpp +++ b/core/db.cpp @@ -456,7 +456,7 @@ Error Db::AddItemIntoItem(Item & item) AssertConnection(); std::ostringstream query; query << "insert into core.item (user_id, modification_user_id, group_id, privileges, date_creation, date_modification, type, " - "parent_id, content_id, auth, auth_path, default_item, subject, guest_name, url) values ("; + "parent_id, content_id, auth, auth_path, default_item, subject, guest_name, template, url) values ("; query << '\'' << item.user_id << "', "; query << '\'' << item.modification_user_id << "', "; query << '\'' << item.group_id << "', "; @@ -471,6 +471,7 @@ Error Db::AddItemIntoItem(Item & item) query << '\'' << item.default_item << "', "; query << '\'' << Escape(item.subject) << "', "; query << '\'' << Escape(item.guest_name) << "', "; + query << '\'' << Escape(item.html_template) << "', "; url_without_id = AddItemCreateUrlSubject(item); @@ -564,7 +565,7 @@ Error Db::EditItemInItem(Item & item, bool with_url) AssertConnection(); std::ostringstream query; query << "update core.item set (user_id, modification_user_id, group_id, privileges, date_creation, date_modification, type, " - "default_item, parent_id, subject, guest_name, auth, auth_path"; + "default_item, parent_id, subject, guest_name, auth, auth_path, template"; if( with_url ) query << ", url"; @@ -582,7 +583,8 @@ Error Db::EditItemInItem(Item & item, bool with_url) query << '\'' << Escape(item.subject) << "', "; query << '\'' << Escape(item.guest_name) << "', "; query << '\'' << static_cast(item.auth) << "', "; - query << '\'' << Escape(item.auth_path) << "' "; + query << '\'' << Escape(item.auth_path) << "', "; + query << '\'' << Escape(item.html_template) << "' "; if( with_url ) { @@ -789,6 +791,42 @@ return result; } +Error Db::EditTemplateItemById(long id, const std::string & new_html_template) +{ + PGresult * r = 0; + Error result = WINIX_ERR_OK; + + try + { + AssertConnection(); + std::ostringstream query; + query << "update core.item set (template) = ('" << Escape(new_html_template) << "') where id='" << id << "';"; + + r = AssertQuery(query.str()); + AssertResultStatus(r, PGRES_COMMAND_OK); + + char * rows_str = PQcmdTuples(r); + long rows = 0; + + if( rows_str ) + rows = atol(rows_str); + + if( rows == 0 ) + { + result = WINIX_ERR_NO_ITEM; + log << log1 << "Db: EditTemplateItemById: no such item, id: " << id << logend; + } + } + catch(const Error & e) + { + result = e; + } + + ClearResult(r); + +return result; +} + PGresult * Db::GetItemsQuery(const ItemQuery & iq, bool skip_other_sel) @@ -810,6 +848,7 @@ PGresult * Db::GetItemsQuery(const ItemQuery & iq, bool skip_other_sel) if( iq.sel_type ) query << " ,type"; if( iq.sel_default_item ) query << " ,default_item"; if( iq.sel_auth ) query << " ,auth, auth_path"; + if( iq.sel_html_template ) query << " ,template"; } query << " from core.item"; diff --git a/core/db.h b/core/db.h index dd3c498..738d910 100755 --- a/core/db.h +++ b/core/db.h @@ -67,6 +67,7 @@ public: bool sel_type; // type (dir, file, none) bool sel_default_item; // default_item bool sel_auth; // auth, auth_path + bool sel_html_template; // template bool where_id; // bool where_parent_id; // @@ -96,6 +97,7 @@ public: sel_type = sel; sel_default_item= sel; sel_auth = sel; + sel_html_template= sel; } void SetAllWhere(bool where_) @@ -161,7 +163,8 @@ public: Error GetItemById(long item_id, Item & item); Error GetItem(long parent_id, const std::string & url, Item & item); Error EditDefaultItem(long id, long new_default_item); - + Error EditTemplateItemById(long id, const std::string & new_html_template); + long GetItemId(long parent_id, const std::string & url, Item::Type type); long GetFileId(long parent_id, const std::string & url); long GetDirId(long parent_id, const std::string & url); @@ -231,7 +234,8 @@ protected: struct ItemColumns { int id, user_id, group_id, privileges, date_creation, date_modification, url, type, parent_id, - content_id, default_item, subject, content, content_type, guest_name, auth, auth_path, modification_user_id; + content_id, default_item, subject, content, content_type, guest_name, auth, auth_path, + modification_user_id, html_template; void SetColumns(PGresult * r); void SetItem(PGresult * r, long row, Item & item); diff --git a/core/db_itemcolumns.cpp b/core/db_itemcolumns.cpp index 22ad2e7..a370183 100755 --- a/core/db_itemcolumns.cpp +++ b/core/db_itemcolumns.cpp @@ -31,6 +31,7 @@ void Db::ItemColumns::SetColumns(PGresult * r) guest_name = PQfnumber(r, "guest_name"); auth = PQfnumber(r, "auth"); auth_path = PQfnumber(r, "auth_path"); + html_template = PQfnumber(r, "template"); modification_user_id = PQfnumber(r, "modification_user_id"); } @@ -55,6 +56,7 @@ void Db::ItemColumns::SetItem(PGresult * r, long row, Item & item) if( guest_name != -1 ) item.guest_name = Db::AssertValue(r, row, guest_name); if( auth != -1 ) item.auth = static_cast( atoi(Db::AssertValue(r, row, auth)) ); if( auth_path != -1 ) item.auth_path = Db::AssertValue(r, row, auth_path); + if( html_template != -1 ) item.html_template = Db::AssertValue(r, row, html_template); if( modification_user_id != -1 ) item.modification_user_id = atol( Db::AssertValue(r, row, modification_user_id) ); } diff --git a/core/item.h b/core/item.h index 7941b8b..7bca23f 100755 --- a/core/item.h +++ b/core/item.h @@ -81,6 +81,8 @@ Auth auth; std::string auth_path; // path to a file (if auth!=auth_none) +std::string html_template; + // methods Item() @@ -130,6 +132,8 @@ void Clear() auth = auth_none; auth_path.clear(); + html_template.clear(); + SetDateToNow(); } diff --git a/core/mount.cpp b/core/mount.cpp index ca33504..4e79432 100755 --- a/core/mount.cpp +++ b/core/mount.cpp @@ -178,12 +178,12 @@ return false; -const std::string * Mount::HtmlTemplate() const +const std::string * Mount::FirstHtmlTemplate() const { if( !param[par_html_template].defined ) return 0; - if( param[par_html_template].arg.size() != 1 ) + if( param[par_html_template].arg.empty() ) return 0; return & param[par_html_template].arg[0]; diff --git a/core/mount.h b/core/mount.h index 85c177b..34a8b10 100755 --- a/core/mount.h +++ b/core/mount.h @@ -101,7 +101,7 @@ public: bool IsArg(Mount::ParamCode code, int arg); // returning a name to html template (can be null if not defined) - const std::string * HtmlTemplate() const; + const std::string * FirstHtmlTemplate() const; }; diff --git a/core/request.h b/core/request.h index a84e7d7..82cbd36 100755 --- a/core/request.h +++ b/core/request.h @@ -107,7 +107,9 @@ struct Request // send as attachment (causing header: content-disposition: attachment) bool send_as_attachment; - + // !! moze dolozyc pole Item * last_item + // i ono bedzie wskazywalo na albo item (jesli jest) albo na ostatni katalog + // ? Request(); diff --git a/functions/Makefile.dep b/functions/Makefile.dep index 9ce516b..91d074f 100755 --- a/functions/Makefile.dep +++ b/functions/Makefile.dep @@ -70,7 +70,7 @@ ckeditor.o: privchanger.h chown.h cp.h createthread.h createticket.h ckeditor.o: default.h download.h editticket.h emacs.h last.h login.h logout.h ckeditor.o: ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h ckeditor.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h -ckeditor.o: tinymce.h uname.h upload.h uptime.h who.h +ckeditor.o: template.h tinymce.h uname.h upload.h uptime.h who.h cp.o: cp.h functionbase.h ../core/item.h ../core/db.h ../core/item.h cp.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h cp.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h @@ -87,8 +87,8 @@ cp.o: ../core/system.h ../core/misc.h functions.h functionparser.h adduser.h cp.o: cat.h chmod.h privchanger.h chown.h ckeditor.h createthread.h cp.o: createticket.h default.h download.h editticket.h emacs.h last.h login.h cp.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h -cp.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h tinymce.h -cp.o: uname.h upload.h uptime.h who.h +cp.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h template.h +cp.o: tinymce.h uname.h upload.h uptime.h who.h createthread.o: createthread.h functionbase.h ../core/item.h ../core/db.h createthread.o: ../core/item.h ../core/user.h ../core/group.h createthread.o: ../core/thread.h ../core/error.h ../core/log.h @@ -108,7 +108,8 @@ createthread.o: privchanger.h chown.h ckeditor.h cp.h createticket.h createthread.o: default.h download.h editticket.h emacs.h last.h login.h createthread.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h createthread.o: subject.h funthread.h ../core/thread.h funticket.h -createthread.o: ../core/ticket.h tinymce.h uname.h upload.h uptime.h who.h +createthread.o: ../core/ticket.h template.h tinymce.h uname.h upload.h +createthread.o: uptime.h who.h createticket.o: createticket.h functionbase.h ../core/item.h ../core/db.h createticket.o: ../core/item.h ../core/user.h ../core/group.h createticket.o: ../core/thread.h ../core/error.h ../core/log.h @@ -128,7 +129,8 @@ createticket.o: adduser.h cat.h chmod.h privchanger.h chown.h ckeditor.h cp.h createticket.o: createthread.h default.h download.h editticket.h emacs.h createticket.o: last.h login.h logout.h ls.h mkdir.h mv.h node.h priv.h createticket.o: reload.h rm.h run.h subject.h funthread.h ../core/thread.h -createticket.o: funticket.h tinymce.h uname.h upload.h uptime.h who.h +createticket.o: funticket.h template.h tinymce.h uname.h upload.h uptime.h +createticket.o: who.h default.o: default.h functionbase.h ../core/item.h ../core/db.h default.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h default.o: ../core/error.h ../core/log.h ../core/dircontainer.h @@ -173,8 +175,8 @@ editticket.o: privchanger.h chown.h ckeditor.h cp.h createthread.h editticket.o: createticket.h default.h download.h emacs.h last.h login.h editticket.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h editticket.o: subject.h funthread.h ../core/thread.h funticket.h -editticket.o: ../core/ticket.h tinymce.h uname.h upload.h uptime.h who.h -editticket.o: readticket.h +editticket.o: ../core/ticket.h template.h tinymce.h uname.h upload.h uptime.h +editticket.o: who.h readticket.h emacs.o: emacs.h functionbase.h ../core/item.h ../core/db.h ../core/item.h emacs.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h emacs.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h @@ -196,7 +198,7 @@ emacs.o: cat.h chmod.h privchanger.h chown.h ckeditor.h cp.h createthread.h emacs.o: createticket.h default.h download.h editticket.h last.h login.h emacs.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h emacs.o: subject.h funthread.h ../core/thread.h funticket.h ../core/ticket.h -emacs.o: tinymce.h uname.h upload.h uptime.h who.h +emacs.o: template.h tinymce.h uname.h upload.h uptime.h who.h functionbase.o: functionbase.h ../core/item.h ../core/db.h ../core/item.h functionbase.o: ../core/user.h ../core/group.h ../core/thread.h functionbase.o: ../core/error.h ../core/log.h ../core/dircontainer.h @@ -216,7 +218,8 @@ functionbase.o: chown.h ckeditor.h cp.h createthread.h createticket.h functionbase.o: default.h download.h editticket.h emacs.h last.h login.h functionbase.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h run.h functionbase.o: subject.h funthread.h ../core/thread.h funticket.h -functionbase.o: ../core/ticket.h tinymce.h uname.h upload.h uptime.h who.h +functionbase.o: ../core/ticket.h template.h tinymce.h uname.h upload.h +functionbase.o: uptime.h who.h functionparser.o: functionparser.h ../core/request.h ../core/requesttypes.h functionparser.o: ../core/session.h ../core/item.h ../core/error.h functionparser.o: ../core/log.h ../core/user.h ../core/plugindata.h @@ -237,7 +240,8 @@ functionparser.o: chown.h ckeditor.h cp.h createthread.h createticket.h functionparser.o: default.h download.h editticket.h emacs.h last.h login.h functionparser.o: logout.h ls.h mkdir.h mv.h node.h priv.h reload.h rm.h functionparser.o: run.h subject.h funthread.h ../core/thread.h funticket.h -functionparser.o: ../core/ticket.h tinymce.h uname.h upload.h uptime.h who.h +functionparser.o: ../core/ticket.h template.h tinymce.h uname.h upload.h +functionparser.o: uptime.h who.h functions.o: functions.h functionbase.h ../core/item.h ../core/db.h functions.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h functions.o: ../core/error.h ../core/log.h ../core/dircontainer.h @@ -256,8 +260,8 @@ functions.o: ckeditor.h cp.h createthread.h createticket.h default.h functions.o: download.h editticket.h emacs.h last.h login.h logout.h ls.h functions.o: mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h functions.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h -functions.o: tinymce.h uname.h upload.h uptime.h who.h ../core/log.h -functions.o: ../core/misc.h ../templates/templates.h +functions.o: template.h tinymce.h uname.h upload.h uptime.h who.h +functions.o: ../core/log.h ../core/misc.h ../templates/templates.h functions.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h functions.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h functions.o: ../core/log.h ../templates/indexpatterns.h @@ -359,7 +363,7 @@ mkdir.o: chmod.h privchanger.h chown.h ckeditor.h cp.h createthread.h mkdir.o: createticket.h default.h download.h editticket.h emacs.h last.h mkdir.o: login.h logout.h ls.h mv.h node.h priv.h reload.h rm.h run.h mkdir.o: subject.h funthread.h ../core/thread.h funticket.h ../core/ticket.h -mkdir.o: tinymce.h uname.h upload.h uptime.h who.h +mkdir.o: template.h tinymce.h uname.h upload.h uptime.h who.h mv.o: mv.h functionbase.h ../core/item.h ../core/db.h ../core/item.h mv.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h mv.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h @@ -376,8 +380,8 @@ mv.o: ../core/system.h functions.h functionparser.h adduser.h cat.h chmod.h mv.o: privchanger.h chown.h ckeditor.h cp.h createthread.h createticket.h mv.o: default.h download.h editticket.h emacs.h last.h login.h logout.h ls.h mv.o: mkdir.h node.h priv.h reload.h rm.h run.h subject.h funthread.h -mv.o: ../core/thread.h funticket.h ../core/ticket.h tinymce.h uname.h -mv.o: upload.h uptime.h who.h +mv.o: ../core/thread.h funticket.h ../core/ticket.h template.h tinymce.h +mv.o: uname.h upload.h uptime.h who.h node.o: node.h functionbase.h ../core/item.h ../core/db.h ../core/item.h node.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h node.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h @@ -458,8 +462,8 @@ rm.o: ../functions/functions.h functionparser.h adduser.h cat.h chmod.h rm.o: privchanger.h chown.h ckeditor.h cp.h createthread.h createticket.h rm.o: default.h download.h editticket.h emacs.h last.h login.h logout.h ls.h rm.o: mkdir.h mv.h node.h priv.h reload.h run.h subject.h funthread.h -rm.o: ../core/thread.h funticket.h ../core/ticket.h tinymce.h uname.h -rm.o: upload.h uptime.h who.h ../templates/templates.h +rm.o: ../core/thread.h funticket.h ../core/ticket.h template.h tinymce.h +rm.o: uname.h upload.h uptime.h who.h ../templates/templates.h rm.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h rm.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h rm.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h @@ -489,6 +493,20 @@ subject.o: ../core/groups.h ../core/loadavg.h ../core/notify.h subject.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h subject.o: ../core/mount.h ../core/locale.h ../templates/misc.h subject.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +template.o: template.h functionbase.h ../core/item.h ../core/db.h +template.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h +template.o: ../core/error.h ../core/log.h ../core/dircontainer.h +template.o: ../core/ugcontainer.h ../core/ticket.h ../core/request.h +template.o: ../core/requesttypes.h ../core/session.h ../core/plugindata.h +template.o: ../core/rebus.h ../core/config.h ../core/confparser.h +template.o: ../core/htmlfilter.h ../core/config.h ../core/system.h +template.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h +template.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h +template.o: ../core/groups.h ../core/loadavg.h ../core/notify.h +template.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h +template.o: ../core/mount.h ../core/locale.h ../templates/misc.h +template.o: ../templates/localefilter.h ../core/locale.h ../core/system.h +template.o: ../core/misc.h tinymce.o: tinymce.h functionbase.h ../core/item.h ../core/db.h tinymce.o: ../core/item.h ../core/user.h ../core/group.h ../core/thread.h tinymce.o: ../core/error.h ../core/log.h ../core/dircontainer.h @@ -506,8 +524,8 @@ tinymce.o: functions.h functionparser.h adduser.h cat.h chmod.h privchanger.h tinymce.o: chown.h ckeditor.h cp.h createthread.h createticket.h default.h tinymce.o: download.h editticket.h emacs.h last.h login.h logout.h ls.h tinymce.o: mkdir.h mv.h node.h priv.h reload.h rm.h run.h subject.h -tinymce.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h uname.h -tinymce.o: upload.h uptime.h who.h +tinymce.o: funthread.h ../core/thread.h funticket.h ../core/ticket.h +tinymce.o: template.h uname.h upload.h uptime.h who.h uname.o: uname.h functionbase.h ../core/item.h ../core/db.h ../core/item.h uname.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h uname.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h @@ -538,8 +556,8 @@ upload.o: functionparser.h adduser.h cat.h chmod.h privchanger.h chown.h upload.o: ckeditor.h cp.h createthread.h createticket.h default.h download.h upload.o: editticket.h emacs.h last.h login.h logout.h ls.h mkdir.h mv.h upload.o: node.h priv.h reload.h rm.h run.h subject.h funthread.h -upload.o: ../core/thread.h funticket.h ../core/ticket.h tinymce.h uname.h -upload.o: uptime.h who.h +upload.o: ../core/thread.h funticket.h ../core/ticket.h template.h tinymce.h +upload.o: uname.h uptime.h who.h uptime.o: uptime.h functionbase.h ../core/item.h ../core/db.h ../core/item.h uptime.o: ../core/user.h ../core/group.h ../core/thread.h ../core/error.h uptime.o: ../core/log.h ../core/dircontainer.h ../core/ugcontainer.h diff --git a/functions/Makefile.o.dep b/functions/Makefile.o.dep index f5bf292..daa6dcf 100755 --- a/functions/Makefile.o.dep +++ b/functions/Makefile.o.dep @@ -1 +1 @@ -o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o createthread.o createticket.o default.o download.o editticket.o emacs.o functionbase.o functionparser.o functions.o funthread.o funticket.o last.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o readticket.o reload.o rm.o run.o subject.o tinymce.o uname.o upload.o uptime.o who.o +o = adduser.o cat.o chmod.o chown.o ckeditor.o cp.o createthread.o createticket.o default.o download.o editticket.o emacs.o functionbase.o functionparser.o functions.o funthread.o funticket.o last.o login.o logout.o ls.o mkdir.o mv.o node.o priv.o privchanger.o readticket.o reload.o rm.o run.o subject.o template.o tinymce.o uname.o upload.o uptime.o who.o diff --git a/functions/functionbase.cpp b/functions/functionbase.cpp index fcd2943..26c5565 100755 --- a/functions/functionbase.cpp +++ b/functions/functionbase.cpp @@ -14,6 +14,8 @@ FunctionBase::FunctionBase() { + id = -1; + fun.user_id = -1; fun.group_id = -1; fun.privileges = 0755; diff --git a/functions/functionbase.h b/functions/functionbase.h index 642747a..c40479b 100755 --- a/functions/functionbase.h +++ b/functions/functionbase.h @@ -30,6 +30,11 @@ class FunctionBase { public: + // function id + // it is set automatically when you add the function to functions list + // is used to load a template (in templates) + long id; + FunctionBase(); // user, group, permissions, url (function name) diff --git a/functions/functions.cpp b/functions/functions.cpp index 7b9c65c..607a9d1 100755 --- a/functions/functions.cpp +++ b/functions/functions.cpp @@ -37,16 +37,37 @@ void Functions::SetSystem(System * psystem) system = psystem; } + void Functions::SetTemplates(Templates * ptemplates) { templates = ptemplates; } + void Functions::SetNotify(Notify * pnotify) { notify = pnotify; } + +size_t Functions::FunctionsSize() +{ + return table.size(); +} + + +Functions::Iterator Functions::Begin() +{ + return table.begin(); +} + + +Functions::Iterator Functions::End() +{ + return table.end(); +} + + FunctionBase * Functions::Find(const std::string & function_name) { Table::iterator i = table.find(function_name); @@ -129,8 +150,9 @@ void Functions::Add(FunctionBase * fun) return; } - table[fun->fun.url] = fun; + fun->id = table.size(); SetObjects(fun); + table[fun->fun.url] = fun; } @@ -145,6 +167,8 @@ void Functions::Add(FunctionBase & fun) void Functions::Create() { + Add(fun_template); + Add(fun_adduser); Add(fun_cat); Add(fun_chmod); @@ -281,7 +305,7 @@ void Functions::MakeGet() return; } - if( !request->function->HasAccess() ) + if( !system->HasReadExecAccess(request->function->fun) || !request->function->HasAccess() ) { request->status = WINIX_ERR_PERMISSION_DENIED; return; @@ -310,7 +334,7 @@ void Functions::MakePost() return; } - if( !request->function->HasAccess() ) + if( !system->HasReadExecAccess(request->function->fun) || !request->function->HasAccess() ) { request->status = WINIX_ERR_PERMISSION_DENIED; return; diff --git a/functions/functions.h b/functions/functions.h index 653fadf..6c3fa7a 100755 --- a/functions/functions.h +++ b/functions/functions.h @@ -39,6 +39,7 @@ #include "subject.h" #include "funthread.h" #include "funticket.h" +#include "template.h" #include "tinymce.h" #include "uname.h" #include "upload.h" @@ -80,16 +81,22 @@ public: Fun::Subject fun_subject; Fun::FunThread fun_thread; Fun::FunTicket fun_ticket; + Fun::Template fun_template; Fun::Tinymce fun_tinymce; Fun::Uname fun_uname; Fun::Upload fun_upload; Fun::Uptime fun_uptime; Fun::Who fun_who; - + typedef std::map Table; + typedef Table::iterator Iterator; void Create(); void Parse(); + size_t FunctionsSize(); + + Iterator Begin(); + Iterator End(); void MakeGet(); void MakePost(); @@ -133,7 +140,6 @@ private: bool ReadItemUrlSubject(Item & item, Item::Type item_type); - typedef std::map Table; Table table; FunctionParser function_parser; diff --git a/functions/template.cpp b/functions/template.cpp new file mode 100755 index 0000000..567085c --- /dev/null +++ b/functions/template.cpp @@ -0,0 +1,70 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include "template.h" +#include "core/misc.h" + + + +namespace Fun +{ + +Template::Template() +{ + fun.url = "template"; +} + + + + + +bool Template::HasAccess() +{ + if( config->template_only_root_use_template_fun ) + { + // only root is allowed to change the template + return (request->session->puser && request->session->puser->super_user); + } + + + if( request->is_item ) + return system->HasWriteAccess(request->item); + else + return system->HasWriteAccess(*request->dir_tab.back()); +} + + +void Template::EditTemplate(Item & item) +{ + html_file = request->PostVar("template"); + TrimWhite(html_file); + request->status = db->EditTemplateItemById(item.id, html_file); + + if( request->status == WINIX_ERR_OK ) + item.html_template = html_file; +} + + +void Template::MakePost() +{ + if( request->is_item ) + { + EditTemplate(request->item); + } + else + { + EditTemplate(*request->dir_tab.back()); + } + + system->RedirectToLastItem(); +} + + + +} // namespace diff --git a/functions/template.h b/functions/template.h new file mode 100755 index 0000000..ace9f19 --- /dev/null +++ b/functions/template.h @@ -0,0 +1,38 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2010, Tomasz Sowa + * All rights reserved. + * + */ + +#ifndef headerfilecmslucontenttemplate +#define headerfilecmslucontenttemplate + +#include "functionbase.h" + + + +namespace Fun +{ + + +class Template : public FunctionBase +{ +public: + + Template(); + bool HasAccess(); + void MakePost(); + +private: + + std::string html_file; + void EditTemplate(Item & item); +}; + + +} // namespace + +#endif diff --git a/html/fun_cat.html b/html/fun_cat.html index 3441de4..8a606be 100755 --- a/html/fun_cat.html +++ b/html/fun_cat.html @@ -1,5 +1,5 @@ [if mount_page_is "subject"][if mount_page_is "info"]

[else]

[end][item_subject]

[end] -[if mount_page_is "info"][item_info][end] +[if mount_page_is "info"][include "item_info.html"][end] [if-one item_auth_is_image] [item_subject] @@ -14,6 +14,7 @@ [end] + [include "item_options.html"] diff --git a/html/fun_chmod.html b/html/fun_chmod.html index e69de29..e609eb5 100755 --- a/html/fun_chmod.html +++ b/html/fun_chmod.html @@ -0,0 +1,2 @@ +[include "fun_priv.html"] + diff --git a/html/fun_chown.html b/html/fun_chown.html index e69de29..2e6bb56 100755 --- a/html/fun_chown.html +++ b/html/fun_chown.html @@ -0,0 +1 @@ +[include "fun_priv.html"] diff --git a/html/fun_run.html b/html/fun_run.html index fa6f9af..d9b447e 100755 --- a/html/fun_run.html +++ b/html/fun_run.html @@ -12,7 +12,7 @@ [end] [if mount_page_is "info"] - [item_info] + [include "item_info.html"] [end] [item_run] diff --git a/html/fun_template.html b/html/fun_template.html new file mode 100755 index 0000000..a46da64 --- /dev/null +++ b/html/fun_template.html @@ -0,0 +1,65 @@ +

{template_header}

+ +[include "error.html"] + +

+ +[if item_is] + + {template_info_file}: + + [if item_has_html_template] + [item_html_template] + [else] + {template_from_mount_point} + + [if mount_has_html_template] + ([mount_first_html_template]) + [else] + ([template_index]) + [end] + [end] + +[else] + + {template_info_dir}: + + [if dir_last_has_html_template] + [dir_last_html_template] + [else] + {template_from_mount_point} + + [if mount_has_html_template] + ([mount_first_html_template]) + [else] + ([template_index]) + [end] + [end] + +[end] + +

+ + + + +
+
+ {template_form_legend} + + {template_form_info}: + + + + +
+
+ diff --git a/html/fun_thread.html b/html/fun_thread.html index a18a143..3114752 100755 --- a/html/fun_thread.html +++ b/html/fun_thread.html @@ -1,5 +1,5 @@ [if mount_page_is "subject"][dir_last_subject][end] -[if mount_page_is "info"][dir_last_info][end] +[if mount_page_is "info"][include "dir_last_info.html"][end] [if-one thread_can_create]
    @@ -34,7 +34,7 @@
    [if-one item_tab_can_use_emacs]\[{edit}\][end] [if mount_thread_is "subject"][item_tab_subject][end] - [if mount_thread_is "info"][item_tab_info][end] + [if mount_thread_is "info"][include "item_tab_info.html"][end] [item_tab_print_content]
    [end] diff --git a/html/fun_ticket.html b/html/fun_ticket.html index 6eb13d2..7374604 100755 --- a/html/fun_ticket.html +++ b/html/fun_ticket.html @@ -1,5 +1,5 @@ [if mount_page_is "subject"][dir_last_subject][end] -[if mount_page_is "info"][dir_last_info][end] +[if mount_page_is "info"][include "dir_last_info.html"][end] [if-one ticket_can_create] @@ -56,7 +56,7 @@ [for item_tab]
    [if mount_thread_is "subject"][item_tab_subject][end] - [if mount_thread_is "info"][item_tab_info][end] + [if mount_thread_is "info"][include "item_tab_info.html"][end] [item_tab_print_content]
    [end] diff --git a/html/item_modify_info.html b/html/item_modify_info.html deleted file mode 100755 index e69de29..0000000 diff --git a/locale/en b/locale/en index 6c1a32b..c04083d 100755 --- a/locale/en +++ b/locale/en @@ -149,6 +149,14 @@ ticket_info_expected = Expected in ticket_info_progress = Progress ticket_reply_in_this_thread = Replay in this thread +template_header = Template +template_info_file = Current html template for this file +template_info_dir = Current html template for this directory +template_from_mount_point = is taken from the mount point +template_form_legend = Template form +template_form_info = Select a new template +template_form_from_mount_point = from the mount point + upload_header = Upload a file upload_form_file = Browse for a file upload_form_file_multi = Browse for files diff --git a/locale/pl b/locale/pl index 2f463ad..d32b448 100755 --- a/locale/pl +++ b/locale/pl @@ -152,6 +152,15 @@ ticket_info_expected = Oczekiwany w ticket_info_progress = Postęp prac ticket_reply_in_this_thread = Odpowiedz w tym wątku +template_header = Szablon +template_info_file = Bieżący szablon dla tego pliku +template_info_dir = Bieżący szablon dla tego katalogu +template_from_mount_point = jest brany z punktu montowania +template_form_legend = Formularz zmiany szablonu +template_form_info = Wybierz nowy szablon +template_form_from_mount_point = z punktu montowania + + upload_header = Prześlij plik upload_form_file = Wybierz plik upload_form_file_multi = Wybierz pliki diff --git a/main/Makefile.dep b/main/Makefile.dep index 3ce7435..f342cff 100755 --- a/main/Makefile.dep +++ b/main/Makefile.dep @@ -25,12 +25,13 @@ main.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h main.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h main.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h main.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -main.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -main.o: ../functions/uptime.h ../functions/who.h ../templates/templates.h -main.o: ../templates/patterncacher.h ../core/item.h ../templates/misc.h -main.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h -main.o: ../core/log.h ../templates/indexpatterns.h ../core/sessionmanager.h -main.o: ../core/compress.h ../core/getparser.h ../core/httpsimpleparser.h -main.o: ../core/postparser.h ../core/cookieparser.h ../core/postmultiparser.h +main.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +main.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +main.o: ../templates/templates.h ../templates/patterncacher.h ../core/item.h +main.o: ../templates/misc.h ../templates/ckeditorgetparser.h +main.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h +main.o: ../core/sessionmanager.h ../core/compress.h ../core/getparser.h +main.o: ../core/httpsimpleparser.h ../core/postparser.h +main.o: ../core/cookieparser.h ../core/postmultiparser.h main.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h main.o: ../core/plugin.h ../core/pluginmsg.h diff --git a/plugins/stats/Makefile.dep b/plugins/stats/Makefile.dep index 41e7a98..d86bd1f 100755 --- a/plugins/stats/Makefile.dep +++ b/plugins/stats/Makefile.dep @@ -32,14 +32,14 @@ init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h init.o: ../../functions/run.h ../../functions/subject.h init.o: ../../functions/funthread.h ../../core/thread.h init.o: ../../functions/funticket.h ../../core/ticket.h -init.o: ../../functions/tinymce.h ../../functions/uname.h -init.o: ../../functions/upload.h ../../functions/uptime.h -init.o: ../../functions/who.h ../../templates/templates.h -init.o: ../../templates/patterncacher.h ../../core/item.h -init.o: ../../templates/misc.h ../../templates/ckeditorgetparser.h -init.o: ../../core/httpsimpleparser.h ../../core/log.h -init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h -init.o: statssession.h ../../core/plugindata.h +init.o: ../../functions/template.h ../../functions/tinymce.h +init.o: ../../functions/uname.h ../../functions/upload.h +init.o: ../../functions/uptime.h ../../functions/who.h +init.o: ../../templates/templates.h ../../templates/patterncacher.h +init.o: ../../core/item.h ../../templates/misc.h +init.o: ../../templates/ckeditorgetparser.h ../../core/httpsimpleparser.h +init.o: ../../core/log.h ../../templates/indexpatterns.h +init.o: ../../core/sessionmanager.h statssession.h ../../core/plugindata.h stats.o: stats.h ../../core/config.h ../../core/log.h templates.o: templates.h ../../core/plugin.h ../../core/pluginmsg.h templates.o: ../../core/log.h ../../core/plugindata.h ../../core/config.h @@ -74,11 +74,12 @@ templates.o: ../../functions/reload.h ../../functions/rm.h templates.o: ../../functions/run.h ../../functions/subject.h templates.o: ../../functions/funthread.h ../../core/thread.h templates.o: ../../functions/funticket.h ../../core/ticket.h -templates.o: ../../functions/tinymce.h ../../functions/uname.h -templates.o: ../../functions/upload.h ../../functions/uptime.h -templates.o: ../../functions/who.h ../../templates/templates.h -templates.o: ../../templates/patterncacher.h ../../core/item.h -templates.o: ../../templates/misc.h ../../templates/ckeditorgetparser.h +templates.o: ../../functions/template.h ../../functions/tinymce.h +templates.o: ../../functions/uname.h ../../functions/upload.h +templates.o: ../../functions/uptime.h ../../functions/who.h +templates.o: ../../templates/templates.h ../../templates/patterncacher.h +templates.o: ../../core/item.h ../../templates/misc.h +templates.o: ../../templates/ckeditorgetparser.h templates.o: ../../core/httpsimpleparser.h ../../core/log.h templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h templates.o: ../../core/misc.h stats.h diff --git a/static/layout1/winix.css b/static/layout1/winix.css index cfde951..c26c16e 100755 --- a/static/layout1/winix.css +++ b/static/layout1/winix.css @@ -455,9 +455,12 @@ margin: 0.3em 0 0.3em 0; #additem select.contenttype { -border: 1px solid #dedede; width: 150px; -margin: 0.3em 0 0.3em 0; +} + + +#additem select.template { +width: 200px; } diff --git a/templates/Makefile.dep b/templates/Makefile.dep index 0a8c767..62e10aa 100755 --- a/templates/Makefile.dep +++ b/templates/Makefile.dep @@ -40,8 +40,9 @@ dir.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h dir.o: ../functions/node.h ../functions/priv.h ../functions/reload.h dir.o: ../functions/rm.h ../functions/run.h ../functions/subject.h dir.o: ../functions/funthread.h ../core/thread.h ../functions/funticket.h -dir.o: ../core/ticket.h ../functions/tinymce.h ../functions/uname.h -dir.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h +dir.o: ../core/ticket.h ../functions/template.h ../functions/tinymce.h +dir.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h +dir.o: ../functions/who.h doc.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h doc.o: localefilter.h ../core/locale.h ../core/confparser.h doc.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h @@ -127,7 +128,7 @@ mount.o: ../core/ugcontainer.h ../core/ticket.h ../core/system.h mount.o: ../core/dirs.h ../core/db.h ../core/request.h ../core/mounts.h mount.o: ../core/mount.h ../core/users.h ../core/lastcontainer.h mount.o: ../core/groups.h ../core/loadavg.h ../core/sessionmanager.h -mount.o: ../core/sessioncontainer.h ../core/system.h +mount.o: ../core/sessioncontainer.h ../core/system.h ../core/misc.h patterncacher.o: patterncacher.h ../core/item.h ../../ezc/src/ezc.h patterncacher.o: ../core/log.h priv.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h misc.h @@ -156,9 +157,9 @@ priv.o: ../functions/logout.h ../functions/ls.h ../functions/mkdir.h priv.o: ../functions/mv.h ../functions/node.h ../functions/priv.h priv.o: ../functions/reload.h ../functions/rm.h ../functions/run.h priv.o: ../functions/subject.h ../functions/funthread.h ../core/thread.h -priv.o: ../functions/funticket.h ../core/ticket.h ../functions/tinymce.h -priv.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h -priv.o: ../functions/who.h +priv.o: ../functions/funticket.h ../core/ticket.h ../functions/template.h +priv.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h +priv.o: ../functions/uptime.h ../functions/who.h rebus.o: ../core/request.h templates.h ../../ezc/src/ezc.h patterncacher.h rebus.o: ../core/item.h misc.h localefilter.h ../core/locale.h rebus.o: ../core/confparser.h ckeditorgetparser.h ../core/httpsimpleparser.h @@ -185,6 +186,20 @@ sys.o: ../core/db.h ../core/request.h ../core/mounts.h ../core/mount.h sys.o: ../core/users.h ../core/lastcontainer.h ../core/groups.h sys.o: ../core/loadavg.h ../core/sessionmanager.h ../core/sessioncontainer.h sys.o: ../core/system.h ../core/request.h ../core/version.h +template.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h +template.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h +template.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h +template.o: indexpatterns.h ../core/locale.h ../core/config.h +template.o: ../core/htmlfilter.h ../core/request.h ../core/requesttypes.h +template.o: ../core/session.h ../core/item.h ../core/error.h ../core/log.h +template.o: ../core/user.h ../core/plugindata.h ../core/rebus.h +template.o: ../core/config.h ../core/db.h ../core/group.h ../core/thread.h +template.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/ticket.h +template.o: ../core/system.h ../core/dirs.h ../core/db.h ../core/request.h +template.o: ../core/mounts.h ../core/mount.h ../core/users.h +template.o: ../core/lastcontainer.h ../core/groups.h ../core/loadavg.h +template.o: ../core/sessionmanager.h ../core/sessioncontainer.h +template.o: ../core/system.h ../core/misc.h templates.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h templates.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h templates.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h @@ -215,7 +230,8 @@ templates.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h templates.o: ../functions/node.h ../functions/priv.h ../functions/reload.h templates.o: ../functions/rm.h ../functions/run.h ../functions/subject.h templates.o: ../functions/funthread.h ../core/thread.h -templates.o: ../functions/funticket.h ../core/ticket.h ../functions/tinymce.h +templates.o: ../functions/funticket.h ../core/ticket.h +templates.o: ../functions/template.h ../functions/tinymce.h templates.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h templates.o: ../functions/who.h ../templates/templates.h thread.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h @@ -246,8 +262,8 @@ thread.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h thread.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h thread.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h thread.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -thread.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -thread.o: ../functions/uptime.h ../functions/who.h +thread.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +thread.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h ticket.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h ticket.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h ticket.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h @@ -276,8 +292,8 @@ ticket.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h ticket.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h ticket.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h ticket.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -ticket.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -ticket.o: ../functions/uptime.h ../functions/who.h +ticket.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +ticket.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h upload.o: templates.h ../../ezc/src/ezc.h patterncacher.h ../core/item.h upload.o: misc.h localefilter.h ../core/locale.h ../core/confparser.h upload.o: ckeditorgetparser.h ../core/httpsimpleparser.h ../core/log.h @@ -360,5 +376,5 @@ winix.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h winix.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h winix.o: ../functions/run.h ../functions/subject.h ../functions/funthread.h winix.o: ../core/thread.h ../functions/funticket.h ../core/ticket.h -winix.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h -winix.o: ../functions/uptime.h ../functions/who.h +winix.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h +winix.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h diff --git a/templates/Makefile.o.dep b/templates/Makefile.o.dep index 2a643c7..7787a61 100755 --- a/templates/Makefile.o.dep +++ b/templates/Makefile.o.dep @@ -1 +1 @@ -o = adduser.o dir.o doc.o indexpatterns.o item.o last.o localefilter.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o sys.o templates.o thread.o ticket.o upload.o uptime.o user.o who.o winix.o +o = adduser.o dir.o doc.o indexpatterns.o item.o last.o localefilter.o ls.o misc.o mount.o patterncacher.o priv.o rebus.o sys.o template.o templates.o thread.o ticket.o upload.o uptime.o user.o who.o winix.o diff --git a/templates/dir.cpp b/templates/dir.cpp index d3e08d1..e98dff5 100755 --- a/templates/dir.cpp +++ b/templates/dir.cpp @@ -317,7 +317,7 @@ void dir_last_subject(Info & i) HtmlEscape(i.out, request->dir_tab.back()->subject); } - +/* void dir_last_info(Info & i) { if( static_cast(locale.GetLang()) >= patterns.size() ) @@ -326,7 +326,7 @@ void dir_last_info(Info & i) Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_dir_last_info], ezc_functions); gen.Generate(); } - +*/ void dir_last_user(Info & i) { @@ -388,6 +388,18 @@ void dir_last_dates_equal(Info & i) } +void dir_last_html_template(Info & i) +{ + HtmlEscape(i.out, request->dir_tab.back()->html_template); +} + + +void dir_last_has_html_template(Info & i) +{ + i.res = !request->dir_tab.back()->html_template.empty(); +} + + diff --git a/templates/item.cpp b/templates/item.cpp index 8447948..9546a9f 100755 --- a/templates/item.cpp +++ b/templates/item.cpp @@ -218,7 +218,7 @@ void item_can_remove(Info & i) i.res = system->HasWriteAccess(*request->dir_tab.back()); } - +/* void item_info(Info & i) { if( static_cast(locale.GetLang()) >= patterns.size() ) @@ -227,7 +227,7 @@ void item_info(Info & i) Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_info], ezc_functions); gen.Generate(); } - +*/ void item_user(Info & i) { @@ -325,6 +325,18 @@ void item_guest_name(Info & i) } +void item_html_template(Info & i) +{ + HtmlEscape(i.out, request->item.html_template); +} + + +void item_has_html_template(Info & i) +{ + i.res = !request->item.html_template.empty(); +} + + @@ -456,7 +468,7 @@ void item_tab_can_write(Info & i) } } - +/* void item_tab_info(Info & i) { if( static_cast(locale.GetLang()) >= patterns.size() ) @@ -465,7 +477,7 @@ void item_tab_info(Info & i) Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_item_tab_info], ezc_functions); gen.Generate(); } - +*/ void item_tab_user(Info & i) { diff --git a/templates/mount.cpp b/templates/mount.cpp index 41122d6..212c1f3 100755 --- a/templates/mount.cpp +++ b/templates/mount.cpp @@ -8,7 +8,7 @@ */ #include "templates.h" - +#include "core/misc.h" @@ -47,8 +47,20 @@ void mount_type_is_cms(Info & i) i.res = system->mounts.pmount->type == Mount::cms; } +void mount_has_html_template(Info & i) +{ + i.res = system->mounts.pmount->param[Mount::par_html_template].defined; +} +void mount_first_html_template(Info & i) +{ + Mount::ParamRow & par = system->mounts.pmount->param[Mount::par_html_template]; + + if( par.defined && !par.arg.empty() ) + HtmlEscape(i.out, par.arg[0]); +} + } // namespace TemplatesFunctions diff --git a/templates/template.cpp b/templates/template.cpp new file mode 100755 index 0000000..d7ae5d3 --- /dev/null +++ b/templates/template.cpp @@ -0,0 +1,113 @@ +/* + * This file is a part of Winix + * and is not publicly distributed + * + * Copyright (c) 2008-2010, Tomasz Sowa + * All rights reserved. + * + */ + +#include +#include +#include "templates.h" +#include "core/misc.h" + + + +namespace TemplatesFunctions +{ + + +void template_index(Info & i) +{ + HtmlEscape(i.out, config->templates_index); +} + + +static std::vector temp_tab; +static size_t temp_req_id = 0; +static size_t temp_def; +static size_t temp_index; + + + +void template_set_def() +{ + temp_def = (size_t)-1; // none + const std::string * html_file; + + if( request->is_item ) + html_file = &request->item.html_template; + else + html_file = &request->dir_tab.back()->html_template; + + + if( html_file->empty() ) + { + // the first default item should be selected (that first in html source with value="") + return; + } + + + for(size_t i=0 ; itemplates_index); + + Mount::ParamRow & par = system->mounts.pmount->param[Mount::par_html_template]; + + if( par.defined ) + { + size_t len = par.arg.size(); + + for(size_t i=0 ; iid != temp_req_id ) + { + temp_req_id = request->id; + template_init(); + } + + temp_index = i.iter; + i.res = temp_index < temp_tab.size(); +} + + + +void template_tab_isdefault(Info & i) +{ + if( temp_index < temp_tab.size() ) + i.res = (temp_index == temp_def); +} + + + +void template_tab_file_name(Info & i) +{ + if( temp_index < temp_tab.size() ) + HtmlEscape(i.out, temp_tab[temp_index]); +} + + + +} // namespace diff --git a/templates/templates.cpp b/templates/templates.cpp index 93862a4..7f4beee 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -20,6 +20,7 @@ namespace TemplatesFunctions IndexPatterns index_patterns; Patterns patterns; +Patterns patterns_fun; Ezc::Functions ezc_functions; PatternCacher pattern_cacher; Locale locale; @@ -41,58 +42,22 @@ SessionManager * session_manager; Ezc::Pattern * content_for_function() { -Ezc::Pattern * p = 0; - if( !request->function ) { log << log1 << "Templates: no function" << logend; - return p; + return 0; } - static PatName pat_name_tab[] = { - {"cat", pat_fun_cat}, - {"ls", pat_fun_ls}, - {"rm", pat_fun_rm}, - {"emacs", pat_fun_emacs}, - {"mkdir", pat_fun_mkdir}, - {"default", pat_fun_default}, - {"priv", pat_fun_priv}, - {"chmod", pat_fun_priv}, - {"chown", pat_fun_priv}, - {"run", pat_fun_run}, - {"who", pat_fun_who}, - {"last", pat_fun_last}, - {"thread", pat_fun_thread}, - {"reload", pat_fun_reload}, - {"createthread",pat_fun_createthread}, - {"ticket", pat_fun_ticket}, - {"createticket",pat_fun_createticket}, - {"editticket", pat_fun_createticket}, - {"upload", pat_fun_upload}, - {"uptime", pat_fun_uptime}, - {"login", pat_fun_login}, - {"mv", pat_fun_mv}, - {"uname", pat_fun_uname}, - {"ckeditor", pat_fun_ckeditor}, - {"subject", pat_fun_subject}, - {"adduser", pat_fun_adduser}, - {"cp", pat_fun_cp}, - {"tinymce", pat_fun_tinymce}, - }; + const size_t loc_index = static_cast(locale.GetLang()); + const size_t fun_id = static_cast(request->function->id); - size_t i, len = sizeof(pat_name_tab)/sizeof(PatName); - - for(i=0 ; i= patterns_fun.size() || fun_id >= patterns_fun[loc_index].size() ) { - if( strcmp(pat_name_tab[i].fun_name, request->function->fun.url.c_str()) == 0 ) - { - // !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika - p = &patterns[locale.GetLang()][pat_name_tab[i].pat]; - break; - } + log << log1 << "Templates: incorrect function index" << logend; + return 0; } - -return p; + +return &patterns_fun[loc_index][fun_id]; } @@ -152,12 +117,9 @@ Ezc::Pattern * p = 0; { i.out << ""; } - } - - } // namespace TemplatesFunctions @@ -219,7 +181,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_can_read", item_can_read); ezc_functions.Insert("item_can_write", item_can_write); ezc_functions.Insert("item_can_remove", item_can_remove); - ezc_functions.Insert("item_info", item_info); + //ezc_functions.Insert("item_info", item_info); ezc_functions.Insert("item_user", item_user); ezc_functions.Insert("item_modification_user", item_modification_user); ezc_functions.Insert("item_users_different", item_users_different); @@ -230,6 +192,9 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_dates_equal", item_dates_equal); ezc_functions.Insert("item_run", item_run); ezc_functions.Insert("item_guest_name", item_guest_name); + ezc_functions.Insert("item_html_template", item_html_template); + ezc_functions.Insert("item_has_html_template", item_has_html_template); + ezc_functions.Insert("item_tab", item_tab); ezc_functions.Insert("item_tab_id", item_tab_id); @@ -245,7 +210,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("item_tab_link_auth", item_tab_link_auth); ezc_functions.Insert("item_tab_can_read", item_tab_can_read); ezc_functions.Insert("item_tab_can_write", item_tab_can_write); - ezc_functions.Insert("item_tab_info", item_tab_info); + //ezc_functions.Insert("item_tab_info", item_tab_info); ezc_functions.Insert("item_tab_user", item_tab_user); ezc_functions.Insert("item_tab_modification_user", item_tab_modification_user); ezc_functions.Insert("item_tab_users_different", item_tab_users_different); @@ -285,13 +250,15 @@ void Templates::CreateFunctions() ezc_functions.Insert("dir_last_default_item_dir", dir_last_default_item_dir); ezc_functions.Insert("dir_last_default_item_url", dir_last_default_item_url); ezc_functions.Insert("dir_last_subject", dir_last_subject); - ezc_functions.Insert("dir_last_info", dir_last_info); + //ezc_functions.Insert("dir_last_info", dir_last_info); ezc_functions.Insert("dir_last_user", dir_last_user); ezc_functions.Insert("dir_last_url", dir_last_url); ezc_functions.Insert("dir_last_url_is", dir_last_url_is); ezc_functions.Insert("dir_last_date_creation", dir_last_date_creation); ezc_functions.Insert("dir_last_date_modification", dir_last_date_modification); ezc_functions.Insert("dir_last_dates_equal", dir_last_dates_equal); + ezc_functions.Insert("dir_last_html_template", dir_last_html_template); + ezc_functions.Insert("dir_last_has_html_template", dir_last_has_html_template); @@ -441,6 +408,8 @@ void Templates::CreateFunctions() ezc_functions.Insert("mount_type_is_thread", mount_type_is_thread); ezc_functions.Insert("mount_type_is_ticket", mount_type_is_ticket); ezc_functions.Insert("mount_type_is_cms", mount_type_is_cms); + ezc_functions.Insert("mount_has_html_template", mount_has_html_template); + ezc_functions.Insert("mount_first_html_template", mount_first_html_template); /* @@ -485,6 +454,16 @@ void Templates::CreateFunctions() ezc_functions.Insert("winix_err_msg_from_locales",winix_err_msg_from_locales); ezc_functions.Insert("winix_show_content_in_full_window", winix_show_content_in_full_window); + + /* + template + */ + ezc_functions.Insert("template_index", template_index); + ezc_functions.Insert("template_tab", template_tab); + ezc_functions.Insert("template_tab_isdefault", template_tab_isdefault); + ezc_functions.Insert("template_tab_file_name", template_tab_file_name); + + plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &ezc_functions); } @@ -499,7 +478,15 @@ using namespace TemplatesFunctions; } -void Templates::ReadTemplates() +void Templates::ReadFileFun(size_t index, const char * file) +{ +using namespace TemplatesFunctions; + + Read(patterns_fun, index, locale, locale_filter, file); +} + + +void Templates::SetLocale() { using namespace TemplatesFunctions; @@ -511,41 +498,48 @@ using namespace TemplatesFunctions; locale.SetLang(Locale::lang_en); locale.Read(config->locale_dir, config->locale_dir_default); +} + +void Templates::ReadFunctionsTemplates() +{ +using namespace TemplatesFunctions; + + Functions::Iterator i = functions->Begin(); + + for(; i != functions->End() ; ++i) + { + const std::string & fun_name = i->first; + const size_t index = i->second->id; + + if( index < functions->FunctionsSize() ) + { + fun_file = config->templates_fun_prefix; + fun_file += fun_name; + fun_file += config->templates_fun_postfix; + ReadFileFun(index, fun_file.c_str()); + } + else + { + log << log1 << "Templates: function index too large, fun: " + << fun_name << ", index: " << index << logend; + } + } +} + + +void Templates::ReadTemplates() +{ +using namespace TemplatesFunctions; + + SetLocale(); ClearPatterns(); - - ReadFile(pat_index, "index.html"); + + ReadFile(pat_index, config->templates_index.c_str()); ReadFile(pat_err_404, "err_404.html"); ReadFile(pat_err_per_denied, "err_per_denied.html"); - ReadFile(pat_fun_cat, "fun_cat.html"); - ReadFile(pat_fun_ls, "fun_ls.html"); - ReadFile(pat_fun_rm, "fun_rm.html"); - ReadFile(pat_fun_emacs, "fun_emacs.html"); - ReadFile(pat_fun_mkdir, "fun_mkdir.html"); - ReadFile(pat_fun_default, "fun_default.html"); - ReadFile(pat_fun_priv, "fun_priv.html"); - ReadFile(pat_fun_who, "fun_who.html"); - ReadFile(pat_fun_run, "fun_run.html"); - ReadFile(pat_fun_last, "fun_last.html"); - ReadFile(pat_item_info, "item_info.html"); - ReadFile(pat_item_tab_info, "item_tab_info.html"); - ReadFile(pat_fun_thread, "fun_thread.html"); - ReadFile(pat_fun_createthread, "fun_createthread.html"); - ReadFile(pat_dir_last_info, "dir_last_info.html"); - ReadFile(pat_fun_reload, "fun_reload.html"); - ReadFile(pat_fun_upload, "fun_upload.html"); - ReadFile(pat_fun_ticket, "fun_ticket.html"); - ReadFile(pat_fun_createticket, "fun_createticket.html"); - ReadFile(pat_fun_uptime, "fun_uptime.html"); - ReadFile(pat_fun_login, "fun_login.html"); - ReadFile(pat_fun_mv, "fun_mv.html"); - ReadFile(pat_fun_uname, "fun_uname.html"); - ReadFile(pat_fun_ckeditor, "fun_ckeditor.html"); - ReadFile(pat_fun_adduser, "fun_adduser.html"); - ReadFile(pat_fun_subject, "fun_subject.html"); - ReadFile(pat_fun_cp, "fun_cp.html"); - ReadFile(pat_fun_tinymce, "fun_tinymce.html"); + ReadFunctionsTemplates(); index_patterns.ReloadPatterns(locale, locale_filter, false); } @@ -556,39 +550,45 @@ using namespace TemplatesFunctions; // the rest are deleted void Templates::ReadNewIndexTemplates() { -Mounts::MountTab::const_iterator i; - - using namespace TemplatesFunctions; +using namespace TemplatesFunctions; index_patterns.MarkAllToDelete(); - const Mounts::MountTab * pmount_tab = TemplatesFunctions::system->mounts.GetMountTab(); - - for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i) - { - const std::string * file = i->second.HtmlTemplate(); - - if( file ) - index_patterns.AddPatternIfNotExists(*file, locale, locale_filter, false); // file pattern will be unmarked - } - + ReadIndexFileNames(true); index_patterns.DeleteMarked(); } -// reading only index file names (without parsing the files) -void Templates::ReadIndexFileNames() +// if add_pattern is true then pattern will be read (parsed) +// if add_pattern is false then only file_name of the pattern will be remembered +// you can next call ReadTemplates() to read those patterns +void Templates::ReadIndexFileNames(bool add_pattern) { using namespace TemplatesFunctions; Mounts::MountTab::const_iterator i; const Mounts::MountTab * pmount_tab = TemplatesFunctions::system->mounts.GetMountTab(); + // loop through all mount points for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i) { - const std::string * file = i->second.HtmlTemplate(); + const Mount & mount = i->second; - if( file ) - index_patterns.AddFileName(*file); + if( mount.param[Mount::par_html_template].defined ) + { + size_t len = mount.param[Mount::par_html_template].arg.size(); + size_t a; + + // loop through all html_templates() values + for(a=0 ; aFunctionsSize()); } @@ -611,11 +612,27 @@ using namespace TemplatesFunctions; return; Ezc::Pattern * index = 0; - const std::string * index_file_local = TemplatesFunctions::system->mounts.pmount->HtmlTemplate(); + const std::string * index_file_local = 0; - if( index_file_local ) + if( request->is_item ) + { + if( !request->item.html_template.empty() ) + index_file_local = &request->item.html_template; + } + else + { + if( !request->dir_tab.back()->html_template.empty() ) + index_file_local = &request->dir_tab.back()->html_template; + } + + + if( !index_file_local ) + index_file_local = TemplatesFunctions::system->mounts.pmount->FirstHtmlTemplate(); + + + if( index_file_local && *index_file_local != config->templates_index ) index = index_patterns.GetPattern(*index_file_local, locale.GetLang()); - + if( !index ) index = &patterns[locale.GetLang()][pat_index]; @@ -680,7 +697,6 @@ void Templates::SetSessionManager(SessionManager * psession_manager) Templates::Templates() { - ClearPatterns(); } diff --git a/templates/templates.h b/templates/templates.h index 972df88..b3611a4 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -60,9 +60,9 @@ namespace TemplatesFunctions pat_fun_adduser, pat_err_404, pat_err_per_denied, - pat_item_info, - pat_item_tab_info, - pat_dir_last_info, + //pat_item_info, + //pat_item_tab_info, + //pat_dir_last_info, pat_fun_subject, pat_fun_cp, pat_fun_tinymce, @@ -79,6 +79,7 @@ namespace TemplatesFunctions extern IndexPatterns index_patterns; extern Patterns patterns; + extern Patterns patterns_fun; extern PatternCacher pattern_cacher; extern Locale locale; extern Ezc::Functions ezc_functions; @@ -144,7 +145,7 @@ namespace TemplatesFunctions void item_can_read(Info & i); void item_can_write(Info & i); void item_can_remove(Info & i); - void item_info(Info & i); + //void item_info(Info & i); void item_user(Info & i); void item_modification_user(Info & i); void item_users_different(Info & i); @@ -155,6 +156,9 @@ namespace TemplatesFunctions void item_dates_equal(Info & i); void item_run(Info & i); void item_guest_name(Info & i); + void item_html_template(Info & i); + void item_has_html_template(Info & i); + void item_tab(Info & i); void item_tab_id(Info & i); @@ -170,7 +174,7 @@ namespace TemplatesFunctions void item_tab_link_auth(Info & i); void item_tab_can_read(Info & i); void item_tab_can_write(Info & i); - void item_tab_info(Info & i); + //void item_tab_info(Info & i); void item_tab_user(Info & i); void item_tab_modification_user(Info & i); void item_tab_users_different(Info & i); @@ -211,14 +215,16 @@ namespace TemplatesFunctions void dir_last_default_item_dir(Info &); void dir_last_default_item_url(Info & i); void dir_last_subject(Info & i); - void dir_last_info(Info & i); + //void dir_last_info(Info & i); void dir_last_user(Info & i); void dir_last_url(Info & i); void dir_last_url_is(Info & i); void dir_last_date_creation(Info & i); void dir_last_date_modification(Info & i); void dir_last_dates_equal(Info & i); - + void dir_last_html_template(Info & i); + void dir_last_has_html_template(Info & i); + /* user @@ -360,6 +366,8 @@ namespace TemplatesFunctions void mount_type_is_thread(Info & i); void mount_type_is_ticket(Info & i); void mount_type_is_cms(Info & i); + void mount_has_html_template(Info & i); + void mount_first_html_template(Info & i); /* @@ -404,6 +412,15 @@ namespace TemplatesFunctions void winix_err_msg_from_locales(Info & i); void winix_show_content_in_full_window(Info & i); + + /* + template (html templates) + */ + void template_index(Info & i); + void template_tab(Info & i); + void template_tab_isdefault(Info & i); + void template_tab_file_name(Info & i); + } // namespace TemplatesFunctions @@ -425,7 +442,7 @@ public: void ClearPatterns(); void ReadTemplates(); void ReadNewIndexTemplates(); - void ReadIndexFileNames(); + void ReadIndexFileNames(bool add_pattern = false); void CreateFunctions(); void Generate(); void GenerateRunRaw(); @@ -433,9 +450,12 @@ public: private: void ReadFile(TemplatesFunctions::Pat pat, const char * file); + void ReadFileFun(size_t index, const char * file); + void ReadFunctionsTemplates(); + void SetLocale(); std::string temp; - + std::string fun_file; };