2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-01-28 16:39:01 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-01-28 16:39:01 +01:00
|
|
|
#include "localefilter.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "../core/data.h"
|
|
|
|
#include "../core/request.h"
|
|
|
|
#include "../core/misc.h"
|
2009-11-13 21:40:11 +01:00
|
|
|
#include "../core/plugin.h"
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
TemplatesMisc::Patterns patterns;
|
|
|
|
Ezc::Functions functions;
|
|
|
|
PatternCacher pattern_cacher;
|
2010-02-15 01:31:14 +01:00
|
|
|
Locale locale;
|
2010-02-11 21:56:52 +01:00
|
|
|
LocaleFilter locale_filter;
|
|
|
|
CKEditorGetParser ckeditor_getparser;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ezc::Pattern * content_for_function()
|
|
|
|
{
|
|
|
|
Ezc::Pattern * p = 0;
|
|
|
|
|
|
|
|
if( !request.pfunction )
|
|
|
|
{
|
|
|
|
log << log1 << "Templates: no function" << logend;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
static PatName pat_name_tab[] = {
|
|
|
|
{FUN_CAT, pat_fun_cat},
|
|
|
|
{FUN_LS, pat_fun_ls},
|
|
|
|
{FUN_RM, pat_fun_rm},
|
|
|
|
{FUN_EMACS, pat_fun_emacs},
|
|
|
|
{FUN_MKDIR, pat_fun_mkdir},
|
|
|
|
{FUN_DEFAULT, pat_fun_default},
|
|
|
|
{FUN_PRIV, pat_fun_priv},
|
|
|
|
{FUN_RUN, pat_fun_run},
|
|
|
|
{FUN_WHO, pat_fun_who},
|
|
|
|
{FUN_LAST, pat_fun_last},
|
|
|
|
{FUN_THREAD, pat_fun_thread},
|
|
|
|
{FUN_RELOAD, pat_fun_reload},
|
|
|
|
{FUN_CREATETHREAD, pat_fun_createthread},
|
|
|
|
{FUN_TICKET, pat_fun_ticket},
|
|
|
|
{FUN_CREATETICKET, pat_fun_createticket},
|
|
|
|
{FUN_EDITTICKET, pat_fun_createticket},
|
2010-02-11 21:56:52 +01:00
|
|
|
{FUN_UPLOAD, pat_fun_upload},
|
|
|
|
{FUN_UPTIME, pat_fun_uptime},
|
|
|
|
{FUN_LOGIN, pat_fun_login},
|
|
|
|
/* {FUN_MV, pat_fun_mv},
|
|
|
|
{FUN_UNAME, pat_fun_uname},
|
|
|
|
{FUN_CHMOD, pat_fun_chmod},
|
|
|
|
{FUN_CHOWN, pat_fun_chown}, */
|
|
|
|
{FUN_CKEDITOR, pat_fun_ckeditor}
|
2010-01-28 16:39:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
size_t i, len = sizeof(pat_name_tab)/sizeof(PatName);
|
|
|
|
|
|
|
|
for(i=0 ; i<len ; ++i)
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-01-28 16:39:01 +01:00
|
|
|
if( pat_name_tab[i].fun_code == request.pfunction->code )
|
|
|
|
{
|
2010-02-15 01:31:14 +01:00
|
|
|
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
|
|
|
|
p = &patterns[locale.GetLang()][pat_name_tab[i].pat];
|
2010-01-28 16:39:01 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void content(Info & i)
|
|
|
|
{
|
|
|
|
Ezc::Pattern * p = 0;
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
if( static_cast<size_t>(locale.GetLang()) >= patterns.size() )
|
2010-01-28 16:39:01 +01:00
|
|
|
{
|
|
|
|
log << log1 << "Templates: there is no such a language in patterns" << logend;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
switch( request.status )
|
|
|
|
{
|
|
|
|
case Error::ok:
|
2009-12-09 01:42:40 +01:00
|
|
|
case Error::spam:
|
|
|
|
case Error::incorrect_rebus:
|
2008-12-30 02:05:03 +01:00
|
|
|
p = content_for_function();
|
|
|
|
break;
|
|
|
|
|
2010-01-11 17:41:23 +01:00
|
|
|
//case Error::no_item: !! we need something like 'error::item_required'
|
|
|
|
//p = &pat_err_item_required;
|
|
|
|
//break;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
case Error::permission_denied:
|
2009-06-05 22:29:06 +02:00
|
|
|
case Error::cant_change_user:
|
|
|
|
case Error::cant_change_group:
|
|
|
|
case Error::cant_change_privileges:
|
2010-02-15 01:31:14 +01:00
|
|
|
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
|
|
|
|
p = &patterns[locale.GetLang()][pat_err_per_denied];
|
2008-12-30 02:05:03 +01:00
|
|
|
break;
|
|
|
|
|
2010-01-11 17:41:23 +01:00
|
|
|
case Error::no_item:
|
2008-12-30 02:05:03 +01:00
|
|
|
case Error::no_function:
|
2009-02-06 14:12:03 +01:00
|
|
|
case Error::unknown_param:
|
2010-02-15 01:31:14 +01:00
|
|
|
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
|
|
|
|
p = &patterns[locale.GetLang()][pat_err_404];
|
2008-12-30 02:05:03 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-02-15 01:31:14 +01:00
|
|
|
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
|
|
|
|
p = &patterns[locale.GetLang()][pat_err_others];
|
2008-12-30 02:05:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( p )
|
|
|
|
{
|
|
|
|
Ezc::Generator gen(i.out, *p, functions);
|
|
|
|
gen.Generate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "<!-- there are not any patterns -->";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::CreateFunctions()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
functions.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
sys
|
|
|
|
*/
|
|
|
|
functions.Insert("sys_ver_major", sys_ver_major);
|
|
|
|
functions.Insert("sys_ver_minor", sys_ver_minor);
|
|
|
|
functions.Insert("sys_ver_revision", sys_ver_revision);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
doc
|
|
|
|
*/
|
2009-12-30 21:46:12 +01:00
|
|
|
functions.Insert("doc_title", doc_title);
|
|
|
|
functions.Insert("doc_base_url", doc_base_url);
|
|
|
|
functions.Insert("doc_base_url_static", doc_base_url_static);
|
2010-02-11 21:56:52 +01:00
|
|
|
functions.Insert("doc_base_url_static_ext", doc_base_url_static_ext);
|
2009-12-30 21:46:12 +01:00
|
|
|
functions.Insert("doc_base_url_static_auth", doc_base_url_static_auth);
|
|
|
|
functions.Insert("doc_current_url", doc_current_url);
|
|
|
|
functions.Insert("doc_is_error", doc_is_error);
|
|
|
|
functions.Insert("doc_status", doc_status);
|
2009-12-09 01:42:40 +01:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
item
|
|
|
|
*/
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_is", item_is);
|
|
|
|
functions.Insert("item_id", item_id);
|
|
|
|
functions.Insert("item_subject", item_subject);
|
|
|
|
functions.Insert("item_subject_noescape", item_subject_noescape);
|
2010-02-13 00:16:13 +01:00
|
|
|
functions.Insert("item_content_is_empty", item_content_is_empty);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_content", item_content);
|
|
|
|
functions.Insert("item_content_noescape", item_content_noescape);
|
2010-01-11 15:47:52 +01:00
|
|
|
functions.Insert("item_content_type_is", item_content_type_is);
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("item_print_content", item_print_content);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_privileges", item_privileges);
|
|
|
|
functions.Insert("item_dir", item_dir);
|
|
|
|
functions.Insert("item_url", item_url);
|
2010-02-08 21:02:16 +01:00
|
|
|
functions.Insert("item_url_is", item_url_is);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_link", item_link);
|
2009-12-30 21:46:12 +01:00
|
|
|
functions.Insert("item_link_static_auth", item_link_static_auth);
|
|
|
|
functions.Insert("item_static_auth_is_none", item_static_auth_is_none);
|
|
|
|
functions.Insert("item_static_auth_is_image", item_static_auth_is_image);
|
|
|
|
functions.Insert("item_static_auth_is_other", item_static_auth_is_other);
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_can_read", item_can_read);
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("item_can_write", item_can_write);
|
2010-02-11 21:56:52 +01:00
|
|
|
functions.Insert("item_can_remove", item_can_remove);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_info", item_info);
|
|
|
|
functions.Insert("item_user", item_user);
|
|
|
|
functions.Insert("item_date_creation", item_date_creation);
|
|
|
|
functions.Insert("item_date_modification", item_date_modification);
|
2010-02-15 01:31:14 +01:00
|
|
|
functions.Insert("item_date_creation_nice", item_date_creation_nice);
|
|
|
|
functions.Insert("item_date_modification_nice",item_date_modification_nice);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_dates_equal", item_dates_equal);
|
|
|
|
functions.Insert("item_run", item_run);
|
2009-11-17 00:36:38 +01:00
|
|
|
functions.Insert("item_guest_name", item_guest_name);
|
2009-04-21 01:49:28 +02:00
|
|
|
|
|
|
|
functions.Insert("item_old_id", item_old_id);
|
|
|
|
functions.Insert("item_old_subject", item_old_subject);
|
|
|
|
functions.Insert("item_old_subject_noescape", item_old_subject_noescape);
|
|
|
|
functions.Insert("item_old_content", item_old_content);
|
|
|
|
functions.Insert("item_old_content_noescape", item_old_content_noescape);
|
|
|
|
functions.Insert("item_old_privileges", item_old_privileges);
|
|
|
|
functions.Insert("item_old_dir", item_old_dir);
|
|
|
|
functions.Insert("item_old_url", item_old_url);
|
|
|
|
functions.Insert("item_old_link", item_old_link);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_tab", item_tab);
|
|
|
|
functions.Insert("item_tab_id", item_tab_id);
|
|
|
|
functions.Insert("item_tab_subject", item_tab_subject);
|
|
|
|
functions.Insert("item_tab_subject_noescape", item_tab_subject_noescape);
|
|
|
|
functions.Insert("item_tab_content", item_tab_content);
|
|
|
|
functions.Insert("item_tab_content_noescape", item_tab_content_noescape);
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("item_tab_print_content", item_tab_print_content);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_tab_privileges", item_tab_privileges);
|
|
|
|
functions.Insert("item_tab_dir", item_tab_dir);
|
|
|
|
functions.Insert("item_tab_url", item_tab_url);
|
|
|
|
functions.Insert("item_tab_link", item_tab_link);
|
2010-02-11 21:56:52 +01:00
|
|
|
functions.Insert("item_tab_link_static_auth", item_tab_link_static_auth);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_tab_can_read", item_tab_can_read);
|
|
|
|
functions.Insert("item_tab_info", item_tab_info);
|
|
|
|
functions.Insert("item_tab_user", item_tab_user);
|
|
|
|
functions.Insert("item_tab_date_creation", item_tab_date_creation);
|
|
|
|
functions.Insert("item_tab_date_modification", item_tab_date_modification);
|
2010-02-15 01:31:14 +01:00
|
|
|
functions.Insert("item_tab_date_creation_nice", item_tab_date_creation_nice);
|
|
|
|
functions.Insert("item_tab_date_modification_nice", item_tab_date_modification_nice);
|
2009-04-21 01:49:28 +02:00
|
|
|
functions.Insert("item_tab_dates_equal", item_tab_dates_equal);
|
|
|
|
functions.Insert("item_tab_run", item_tab_run);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
dir
|
|
|
|
*/
|
2008-12-31 19:28:12 +01:00
|
|
|
functions.Insert("dir", dir);
|
2009-01-14 21:11:12 +01:00
|
|
|
functions.Insert("dir_can_read_exec", dir_can_read_exec);
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("dir_can_write", dir_can_write);
|
|
|
|
functions.Insert("dir_can_remove", dir_can_remove);
|
|
|
|
functions.Insert("dir_can_use_emacs", dir_can_use_emacs);
|
|
|
|
functions.Insert("dir_can_use_mkdir", dir_can_use_mkdir);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2008-12-31 19:28:12 +01:00
|
|
|
functions.Insert("dir_childs_tab", dir_childs_tab);
|
|
|
|
functions.Insert("dir_childs_tab_url", dir_childs_tab_url);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2008-12-31 19:28:12 +01:00
|
|
|
functions.Insert("dir_tab", dir_tab);
|
|
|
|
functions.Insert("dir_tab_url", dir_tab_url);
|
|
|
|
functions.Insert("dir_tab_link", dir_tab_link);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2009-06-07 04:40:27 +02:00
|
|
|
functions.Insert("dir_last_default_item_dir", dir_last_default_item_dir);
|
|
|
|
functions.Insert("dir_last_default_item_url", dir_last_default_item_url);
|
|
|
|
functions.Insert("dir_last_subject", dir_last_subject);
|
|
|
|
functions.Insert("dir_last_info", dir_last_info);
|
|
|
|
functions.Insert("dir_last_user", dir_last_user);
|
2010-02-08 21:02:16 +01:00
|
|
|
functions.Insert("dir_last_url", dir_last_url);
|
2009-06-07 04:40:27 +02:00
|
|
|
functions.Insert("dir_last_date_creation", dir_last_date_creation);
|
|
|
|
functions.Insert("dir_last_date_modification", dir_last_date_modification);
|
|
|
|
functions.Insert("dir_last_dates_equal", dir_last_dates_equal);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-02-06 15:08:44 +01:00
|
|
|
|
2009-02-06 14:12:03 +01:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
/*
|
|
|
|
user
|
|
|
|
*/
|
|
|
|
functions.Insert("ls_ckeditor_funnum_browse", ls_ckeditor_funnum_browse);
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
user
|
|
|
|
*/
|
2010-01-11 15:47:52 +01:00
|
|
|
functions.Insert("user_name", user_name);
|
|
|
|
functions.Insert("user_logged", user_logged);
|
|
|
|
functions.Insert("user_super_user", user_super_user);
|
|
|
|
functions.Insert("user_can_use_html", user_can_use_html);
|
|
|
|
functions.Insert("user_can_use_bbcode", user_can_use_bbcode);
|
|
|
|
functions.Insert("user_can_use_raw", user_can_use_raw);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
privileges
|
|
|
|
*/
|
|
|
|
functions.Insert("priv_user_tab", priv_user_tab);
|
|
|
|
functions.Insert("priv_user_tab_name", priv_user_tab_name);
|
|
|
|
functions.Insert("priv_user_tab_isdefault", priv_user_tab_isdefault);
|
|
|
|
|
|
|
|
functions.Insert("priv_group_tab", priv_group_tab);
|
|
|
|
functions.Insert("priv_group_tab_name", priv_group_tab_name);
|
|
|
|
functions.Insert("priv_group_tab_isdefault", priv_group_tab_isdefault);
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("priv_privileges", priv_privileges);
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
done
|
|
|
|
*/
|
2009-12-09 01:42:40 +01:00
|
|
|
functions.Insert("done_is_error", done_is_error);
|
|
|
|
functions.Insert("done_status", done_status);
|
|
|
|
functions.Insert("done_status_no_item", done_status_no_item);
|
|
|
|
functions.Insert("done_status_incorrect_dir", done_status_incorrect_dir);
|
|
|
|
functions.Insert("done_status_incorrect_rebus", done_status_incorrect_rebus);
|
|
|
|
functions.Insert("done_status_spam", done_status_spam);
|
|
|
|
functions.Insert("done_added_item", done_added_item);
|
|
|
|
functions.Insert("done_edited_item", done_edited_item);
|
|
|
|
functions.Insert("done_deleted_item", done_deleted_item);
|
|
|
|
functions.Insert("done_privileged_item", done_privileged_item);
|
|
|
|
functions.Insert("done_loggedout", done_loggedout);
|
|
|
|
functions.Insert("done_added_dir", done_added_dir);
|
|
|
|
functions.Insert("done_deleted_dir", done_deleted_dir);
|
|
|
|
functions.Insert("done_defaulted_dir", done_defaulted_dir);
|
|
|
|
functions.Insert("done_reloaded_templates", done_reloaded_templates);
|
2008-12-31 14:36:46 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
others
|
|
|
|
*/
|
|
|
|
functions.Insert("content", content);
|
|
|
|
|
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
/*
|
|
|
|
who
|
|
|
|
*/
|
2009-04-16 03:59:42 +02:00
|
|
|
functions.Insert("who_tab", who_tab);
|
|
|
|
functions.Insert("who_tab_lp", who_tab_lp);
|
|
|
|
functions.Insert("who_tab_user", who_tab_user);
|
|
|
|
functions.Insert("who_tab_time", who_tab_time);
|
|
|
|
functions.Insert("who_tab_last_time", who_tab_last_time);
|
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2009-04-16 03:59:42 +02:00
|
|
|
/*
|
|
|
|
last
|
|
|
|
*/
|
|
|
|
functions.Insert("last_tab", last_tab);
|
|
|
|
functions.Insert("last_tab_name", last_tab_name);
|
|
|
|
functions.Insert("last_tab_ip", last_tab_ip);
|
|
|
|
functions.Insert("last_tab_start", last_tab_start);
|
|
|
|
functions.Insert("last_tab_end", last_tab_end);
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
thread
|
|
|
|
*/
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("thread_is", thread_is);
|
|
|
|
functions.Insert("thread_tab", thread_tab);
|
|
|
|
functions.Insert("thread_tab_url", thread_tab_url);
|
|
|
|
functions.Insert("thread_tab_subject", thread_tab_subject);
|
|
|
|
functions.Insert("thread_tab_author", thread_tab_author);
|
|
|
|
functions.Insert("thread_tab_answers", thread_tab_answers);
|
|
|
|
functions.Insert("thread_tab_last_item_date_modification", thread_tab_last_item_date_modification);
|
2010-02-15 01:31:14 +01:00
|
|
|
functions.Insert("thread_tab_last_item_date_modification_nice", thread_tab_last_item_date_modification_nice);
|
2009-06-05 22:29:06 +02:00
|
|
|
functions.Insert("thread_tab_last_item_user", thread_tab_last_item_user);
|
|
|
|
functions.Insert("thread_can_create", thread_can_create);
|
|
|
|
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
/*
|
|
|
|
ticket
|
|
|
|
*/
|
|
|
|
functions.Insert("ticket_is", ticket_is);
|
|
|
|
functions.Insert("ticket_can_create", ticket_can_create);
|
2010-02-06 15:08:44 +01:00
|
|
|
functions.Insert("ticket_can_edit", ticket_can_edit);
|
2010-01-25 05:52:17 +01:00
|
|
|
functions.Insert("ticket_type", ticket_type);
|
|
|
|
functions.Insert("ticket_status", ticket_status);
|
|
|
|
functions.Insert("ticket_priority", ticket_priority);
|
|
|
|
functions.Insert("ticket_category", ticket_category);
|
|
|
|
functions.Insert("ticket_expected", ticket_expected);
|
|
|
|
functions.Insert("ticket_progress", ticket_progress);
|
|
|
|
|
|
|
|
functions.Insert("ticket_tab", ticket_tab);
|
|
|
|
functions.Insert("ticket_tab_url", ticket_tab_url);
|
|
|
|
functions.Insert("ticket_tab_subject", ticket_tab_subject);
|
|
|
|
functions.Insert("ticket_tab_subject_empty", ticket_tab_subject_empty);
|
|
|
|
functions.Insert("ticket_tab_author", ticket_tab_author);
|
|
|
|
functions.Insert("ticket_tab_type", ticket_tab_type);
|
|
|
|
functions.Insert("ticket_tab_status", ticket_tab_status);
|
|
|
|
functions.Insert("ticket_tab_priority", ticket_tab_priority);
|
|
|
|
functions.Insert("ticket_tab_category", ticket_tab_category);
|
|
|
|
functions.Insert("ticket_tab_expected", ticket_tab_expected);
|
|
|
|
functions.Insert("ticket_tab_progress", ticket_tab_progress);
|
|
|
|
|
|
|
|
functions.Insert("ticket_type_tab", ticket_type_tab);
|
|
|
|
functions.Insert("ticket_type_tab_defined", ticket_type_tab_defined);
|
|
|
|
functions.Insert("ticket_type_tab_isdefault", ticket_type_tab_isdefault);
|
|
|
|
functions.Insert("ticket_type_tab_index", ticket_type_tab_index);
|
|
|
|
functions.Insert("ticket_type_tab_name", ticket_type_tab_name);
|
|
|
|
|
|
|
|
functions.Insert("ticket_status_tab", ticket_status_tab);
|
|
|
|
functions.Insert("ticket_status_tab_defined", ticket_status_tab_defined);
|
|
|
|
functions.Insert("ticket_status_tab_isdefault", ticket_status_tab_isdefault);
|
|
|
|
functions.Insert("ticket_status_tab_index", ticket_status_tab_index);
|
|
|
|
functions.Insert("ticket_status_tab_name", ticket_status_tab_name);
|
|
|
|
|
|
|
|
functions.Insert("ticket_priority_tab", ticket_priority_tab);
|
|
|
|
functions.Insert("ticket_priority_tab_defined", ticket_priority_tab_defined);
|
|
|
|
functions.Insert("ticket_priority_tab_isdefault", ticket_priority_tab_isdefault);
|
|
|
|
functions.Insert("ticket_priority_tab_index", ticket_priority_tab_index);
|
|
|
|
functions.Insert("ticket_priority_tab_name", ticket_priority_tab_name);
|
|
|
|
|
|
|
|
functions.Insert("ticket_category_tab", ticket_category_tab);
|
|
|
|
functions.Insert("ticket_category_tab_defined", ticket_category_tab_defined);
|
|
|
|
functions.Insert("ticket_category_tab_isdefault", ticket_category_tab_isdefault);
|
|
|
|
functions.Insert("ticket_category_tab_index", ticket_category_tab_index);
|
|
|
|
functions.Insert("ticket_category_tab_name", ticket_category_tab_name);
|
|
|
|
|
|
|
|
functions.Insert("ticket_expected_tab", ticket_expected_tab);
|
|
|
|
functions.Insert("ticket_expected_tab_defined", ticket_expected_tab_defined);
|
|
|
|
functions.Insert("ticket_expected_tab_isdefault", ticket_expected_tab_isdefault);
|
|
|
|
functions.Insert("ticket_expected_tab_index", ticket_expected_tab_index);
|
|
|
|
functions.Insert("ticket_expected_tab_name", ticket_expected_tab_name);
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
/*
|
|
|
|
mount
|
|
|
|
*/
|
2010-01-25 05:52:17 +01:00
|
|
|
functions.Insert("mount_page_is", mount_page_is);
|
|
|
|
functions.Insert("mount_thread_is", mount_thread_is);
|
|
|
|
functions.Insert("mount_type_is_thread", mount_type_is_thread);
|
|
|
|
functions.Insert("mount_type_is_ticket", mount_type_is_ticket);
|
|
|
|
functions.Insert("mount_type_is_cms", mount_type_is_cms);
|
2009-04-16 03:59:42 +02:00
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2009-11-17 00:36:38 +01:00
|
|
|
/*
|
|
|
|
rebus
|
|
|
|
*/
|
2010-02-11 21:56:52 +01:00
|
|
|
functions.Insert("rebus_question", rebus_question);
|
2009-11-17 00:36:38 +01:00
|
|
|
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
/*
|
|
|
|
uptime
|
|
|
|
*/
|
|
|
|
functions.Insert("uptime_more_than_one_day", uptime_more_than_one_day);
|
|
|
|
functions.Insert("uptime_days", uptime_days);
|
|
|
|
functions.Insert("uptime_hours", uptime_hours);
|
|
|
|
|
2009-11-17 00:36:38 +01:00
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
/*
|
|
|
|
winix
|
|
|
|
*/
|
|
|
|
functions.Insert("winix_cur_time", winix_cur_time);
|
|
|
|
functions.Insert("winix_users_logged", winix_users_logged);
|
|
|
|
functions.Insert("winix_function_is", winix_function_is);
|
|
|
|
functions.Insert("winix_function_param_is", winix_function_param_is);
|
2010-02-13 21:12:15 +01:00
|
|
|
functions.Insert("winix_loadavg_now", winix_loadavg_now);
|
|
|
|
functions.Insert("winix_loadavg_1", winix_loadavg_1);
|
|
|
|
functions.Insert("winix_loadavg_5", winix_loadavg_5);
|
|
|
|
functions.Insert("winix_loadavg_15", winix_loadavg_15);
|
|
|
|
functions.Insert("winix_req_per_sec_now", winix_req_per_sec_now);
|
|
|
|
functions.Insert("winix_req_per_sec_1", winix_req_per_sec_1);
|
|
|
|
functions.Insert("winix_req_per_sec_5", winix_req_per_sec_5);
|
|
|
|
functions.Insert("winix_req_per_sec_15", winix_req_per_sec_15);
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &functions);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
void Templates::ReadFile(TemplatesFunctions::Pat pat, const char * file)
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
TemplatesMisc::Read(patterns, static_cast<size_t>(pat), locale, locale_filter, file);
|
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2009-11-16 18:43:23 +01:00
|
|
|
void Templates::ReadTemplates()
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-01-28 16:39:01 +01:00
|
|
|
using namespace TemplatesFunctions;
|
2010-02-15 01:31:14 +01:00
|
|
|
|
|
|
|
Locale::Lang lang = Locale::StrToLang(data.locale_str);
|
|
|
|
|
|
|
|
if( lang != Locale::lang_unknown )
|
|
|
|
locale.SetLang(lang);
|
|
|
|
else
|
|
|
|
locale.SetLang(Locale::lang_en);
|
|
|
|
|
|
|
|
locale.Read(data.locale_dir, data.locale_dir_default);
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
ClearPatterns();
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
ReadFile(pat_index, "index.html");
|
|
|
|
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_err_others, "err_others.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_chmod, "fun_chmod.html");
|
|
|
|
ReadFile(pat_fun_chown, "fun_chown.html"); */
|
|
|
|
ReadFile(pat_fun_ckeditor, "fun_ckeditor.html");
|
2010-01-28 16:39:01 +01:00
|
|
|
}
|
2009-06-07 04:40:27 +02:00
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
void Templates::ClearPatterns()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
TemplatesMisc::ClearPatterns(patterns, pat_last);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::Generate()
|
|
|
|
{
|
2010-01-11 15:47:52 +01:00
|
|
|
using namespace TemplatesFunctions;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
// !! locale beda w zaleznosci od uzytkownika
|
2010-02-15 01:31:14 +01:00
|
|
|
if( static_cast<size_t>(locale.GetLang()) >= patterns.size() )
|
2010-01-28 16:39:01 +01:00
|
|
|
return;
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
Ezc::Generator generator(request.page, patterns[locale.GetLang()][pat_index], functions);
|
2008-12-30 02:05:03 +01:00
|
|
|
generator.Generate();
|
|
|
|
}
|
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
void Templates::GenerateRunRaw()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
Ezc::Info info(request.page);
|
|
|
|
info.iter = 0;
|
|
|
|
info.result = false;
|
|
|
|
|
|
|
|
item_run(info);
|
|
|
|
}
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
Templates::Templates()
|
|
|
|
{
|
|
|
|
ClearPatterns();
|
|
|
|
}
|
|
|
|
|
|
|
|
|