2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-30 02:05:03 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2011-02-24 18:06:12 +01:00
|
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "core/misc.h"
|
|
|
|
#include "core/plugin.h"
|
2010-11-21 01:19:17 +01:00
|
|
|
#include "core/textstream.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "functions/functions.h"
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
2009-10-01 00:31:20 +02:00
|
|
|
|
2010-11-25 23:42:24 +01:00
|
|
|
IndexPatterns index_patterns; // patterns for main index template (those from mountpoint)
|
|
|
|
Patterns patterns; // those patterns from enum Pat
|
|
|
|
Patterns patterns_fun; // patterns for winix functions
|
|
|
|
PatternCacher pattern_cacher; // patterns for user items (files with an executable bit set)
|
2010-07-04 22:27:14 +02:00
|
|
|
Locale locale;
|
2010-11-25 23:42:24 +01:00
|
|
|
EzcFun ezc_functions;
|
2010-07-04 22:27:14 +02:00
|
|
|
LocaleFilter locale_filter;
|
2011-04-16 10:42:22 +02:00
|
|
|
HTMLFilter html_filter;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-07-20 01:07:34 +02:00
|
|
|
// used by GenerateRunRaw()
|
2010-11-21 01:19:17 +01:00
|
|
|
std::vector<std::wstring> empty_pars;
|
2011-01-26 13:45:38 +01:00
|
|
|
const std::wstring empty_string;
|
|
|
|
const HtmlTextStream empty_stream;
|
|
|
|
|
2009-03-23 00:54:15 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
Db * db;
|
2011-01-23 15:15:30 +01:00
|
|
|
Cur * cur;
|
|
|
|
Config * config;
|
2010-08-10 18:12:50 +02:00
|
|
|
System * system;
|
|
|
|
Functions * functions;
|
|
|
|
SessionManager * session_manager;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
// generator used by content() function
|
|
|
|
static EzcGen content_gen;
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
Ezc::Pattern * content_for_function()
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->function )
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
|
|
|
log << log1 << "Templates: no function" << logend;
|
2010-08-13 22:04:57 +02:00
|
|
|
return 0;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
2011-02-24 18:06:12 +01:00
|
|
|
const size_t loc_index = locale.GetLang();
|
2011-01-23 15:15:30 +01:00
|
|
|
const size_t fun_id = static_cast<size_t>(cur->request->function->id);
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
if( loc_index >= patterns_fun.size() || fun_id >= patterns_fun[loc_index].size() )
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-08-13 22:04:57 +02:00
|
|
|
log << log1 << "Templates: incorrect function index" << logend;
|
|
|
|
return 0;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
return &patterns_fun[loc_index][fun_id];
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void content(Info & i)
|
|
|
|
{
|
|
|
|
Ezc::Pattern * p = 0;
|
|
|
|
|
2011-02-24 18:06:12 +01:00
|
|
|
if( 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
switch( cur->request->status )
|
2008-12-30 02:05:03 +01:00
|
|
|
{
|
2010-02-28 01:08:10 +01:00
|
|
|
//case WINIX_ERR_NO_ITEM: !! we need something like 'error::item_required'
|
2010-01-11 17:41:23 +01:00
|
|
|
//p = &pat_err_item_required;
|
|
|
|
//break;
|
2011-07-29 00:18:10 +02:00
|
|
|
|
|
|
|
case WINIX_ERR_INCORRECT_URI: // !!temporarily
|
|
|
|
case WINIX_ERR_INTERNAL_ERROR: // !! temprarily
|
2010-02-28 01:08:10 +01:00
|
|
|
case WINIX_ERR_PERMISSION_DENIED:
|
|
|
|
case WINIX_ERR_CANT_CHANGE_USER:
|
|
|
|
case WINIX_ERR_CANT_CHANGE_GROUP:
|
|
|
|
case WINIX_ERR_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-02-28 01:08:10 +01:00
|
|
|
case WINIX_ERR_NO_ITEM:
|
|
|
|
case WINIX_ERR_NO_FUNCTION:
|
|
|
|
case WINIX_ERR_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;
|
|
|
|
|
2010-02-28 01:08:10 +01:00
|
|
|
//default:
|
2010-02-15 01:31:14 +01:00
|
|
|
// !! locale.GetLang() bedzie brane indywidualnie dla kazdego uzytkownika
|
2010-02-28 01:08:10 +01:00
|
|
|
//p = &patterns[locale.GetLang()][pat_err_others];
|
|
|
|
//break;
|
|
|
|
|
|
|
|
//case WINIX_ERR_OK:
|
|
|
|
//case WINIX_ERR_SPAM:
|
|
|
|
//case WINIX_ERR_INCORRECT_REBUS:
|
|
|
|
default:
|
|
|
|
p = content_for_function();
|
|
|
|
break;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( p )
|
2011-01-26 13:45:38 +01:00
|
|
|
content_gen.Generate(i.out, *p);
|
2008-12-30 02:05:03 +01:00
|
|
|
else
|
|
|
|
i.out << "<!-- there are not any patterns -->";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::CreateFunctions()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Clear();
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
2010-02-28 01:08:10 +01:00
|
|
|
/*
|
|
|
|
adduser
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("adduser_last_login", adduser_last_login);
|
|
|
|
ezc_functions.Insert("adduser_last_email", adduser_last_email);
|
2010-02-28 01:08:10 +01:00
|
|
|
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
/*
|
|
|
|
dir
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("dir", dir);
|
|
|
|
ezc_functions.Insert("dir_without_slash", dir_without_slash);
|
2011-01-05 22:24:11 +01:00
|
|
|
ezc_functions.Insert("dir_is_root", dir_is_root);
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("dir_parent", dir_parent);
|
|
|
|
ezc_functions.Insert("dir_parent_without_slash", dir_parent_without_slash);
|
|
|
|
ezc_functions.Insert("dir_can_read_exec", dir_can_read_exec);
|
|
|
|
ezc_functions.Insert("dir_can_write", dir_can_write);
|
|
|
|
ezc_functions.Insert("dir_can_remove", dir_can_remove);
|
|
|
|
ezc_functions.Insert("dir_can_use_emacs", dir_can_use_emacs);
|
|
|
|
ezc_functions.Insert("dir_can_use_mkdir", dir_can_use_mkdir);
|
|
|
|
|
|
|
|
ezc_functions.Insert("dir_childs_tab", dir_childs_tab);
|
|
|
|
ezc_functions.Insert("dir_childs_is_parent", dir_childs_is_parent);
|
|
|
|
ezc_functions.Insert("dir_childs_tab_url", dir_childs_tab_url);
|
|
|
|
ezc_functions.Insert("dir_childs_tab_privileges", dir_childs_tab_privileges);
|
|
|
|
ezc_functions.Insert("dir_childs_tab_user", dir_childs_tab_user);
|
|
|
|
ezc_functions.Insert("dir_childs_tab_group", dir_childs_tab_group);
|
|
|
|
|
|
|
|
ezc_functions.Insert("dir_tab", dir_tab);
|
|
|
|
ezc_functions.Insert("dir_tab_url", dir_tab_url);
|
|
|
|
ezc_functions.Insert("dir_tab_link", dir_tab_link);
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
ezc_functions.Insert("dir_last_link_to", dir_last_link_to);
|
|
|
|
ezc_functions.Insert("dir_last_is_link_redirect", dir_last_is_link_redirect);
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("dir_last_subject", dir_last_subject);
|
|
|
|
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);
|
2010-10-19 02:31:20 +02:00
|
|
|
ezc_functions.Insert("dir_last_date_creation_nice", dir_last_date_creation_nice);
|
|
|
|
ezc_functions.Insert("dir_last_date_modification_nice", dir_last_date_modification_nice);
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("dir_last_dates_equal", dir_last_dates_equal);
|
2010-10-19 02:31:20 +02:00
|
|
|
ezc_functions.Insert("dir_last_users_different", dir_last_users_different);
|
|
|
|
ezc_functions.Insert("dir_last_modification_user", dir_last_modification_user);
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("dir_last_html_template", dir_last_html_template);
|
|
|
|
ezc_functions.Insert("dir_last_has_html_template", dir_last_has_html_template);
|
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
/*
|
|
|
|
filters
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("fil_urlencode", fil_urlencode);
|
|
|
|
ezc_functions.Insert("fil_qencode", fil_qencode);
|
|
|
|
ezc_functions.Insert("fil_capitalize", fil_capitalize);
|
|
|
|
ezc_functions.Insert("fil_tosmall", fil_tosmall);
|
2011-01-27 15:35:25 +01:00
|
|
|
ezc_functions.Insert("fil_firstup", fil_firstup);
|
2011-01-26 13:45:38 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
doc
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("doc_title", doc_title);
|
|
|
|
ezc_functions.Insert("doc_base_url", doc_base_url);
|
|
|
|
ezc_functions.Insert("doc_base_url_static", doc_base_url_static);
|
|
|
|
ezc_functions.Insert("doc_base_url_common", doc_base_url_common);
|
|
|
|
ezc_functions.Insert("doc_current_url", doc_current_url);
|
2011-06-24 22:53:21 +02:00
|
|
|
ezc_functions.Insert("doc_css_tab", doc_css_tab);
|
|
|
|
ezc_functions.Insert("doc_css_tab_file", doc_css_tab_file);
|
|
|
|
ezc_functions.Insert("doc_css_tab_file_is_global", doc_css_tab_file_is_global);
|
|
|
|
ezc_functions.Insert("doc_css_tab_has_next", doc_css_tab_has_next);
|
|
|
|
ezc_functions.Insert("doc_css_is_empty", doc_css_is_empty);
|
|
|
|
ezc_functions.Insert("doc_css_is_one", doc_css_is_one);
|
|
|
|
ezc_functions.Insert("doc_css_more_than_one", doc_css_more_than_one);
|
|
|
|
|
2009-12-09 01:42:40 +01:00
|
|
|
|
2011-07-14 01:14:10 +02:00
|
|
|
/*
|
|
|
|
insert
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("insert_page", insert_page);
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
item
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("item_is", item_is);
|
|
|
|
ezc_functions.Insert("item_id", item_id);
|
|
|
|
ezc_functions.Insert("item_subject", item_subject);
|
|
|
|
ezc_functions.Insert("item_subject_noescape", item_subject_noescape);
|
|
|
|
ezc_functions.Insert("item_content_is_empty", item_content_is_empty);
|
|
|
|
ezc_functions.Insert("item_content", item_content);
|
|
|
|
ezc_functions.Insert("item_content_noescape", item_content_noescape);
|
|
|
|
ezc_functions.Insert("item_content_type_is", item_content_type_is);
|
|
|
|
ezc_functions.Insert("item_print_content", item_print_content);
|
|
|
|
ezc_functions.Insert("item_privileges", item_privileges);
|
|
|
|
ezc_functions.Insert("item_dir", item_dir);
|
|
|
|
ezc_functions.Insert("item_url", item_url);
|
|
|
|
ezc_functions.Insert("item_url_is", item_url_is);
|
|
|
|
ezc_functions.Insert("item_link", item_link);
|
2010-12-11 23:55:48 +01:00
|
|
|
ezc_functions.Insert("item_filetype_is_none", item_filetype_is_none);
|
|
|
|
ezc_functions.Insert("item_filetype_is_image", item_filetype_is_image);
|
2011-01-05 22:24:11 +01:00
|
|
|
ezc_functions.Insert("item_has_static_file", item_has_static_file);
|
2010-12-11 23:55:48 +01:00
|
|
|
ezc_functions.Insert("item_has_thumb", item_has_thumb);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
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_user", item_user);
|
|
|
|
ezc_functions.Insert("item_modification_user", item_modification_user);
|
|
|
|
ezc_functions.Insert("item_users_different", item_users_different);
|
|
|
|
ezc_functions.Insert("item_date_creation", item_date_creation);
|
|
|
|
ezc_functions.Insert("item_date_modification", item_date_modification);
|
|
|
|
ezc_functions.Insert("item_date_creation_nice", item_date_creation_nice);
|
|
|
|
ezc_functions.Insert("item_date_modification_nice",item_date_modification_nice);
|
|
|
|
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);
|
2010-08-13 22:04:57 +02:00
|
|
|
ezc_functions.Insert("item_html_template", item_html_template);
|
|
|
|
ezc_functions.Insert("item_has_html_template", item_has_html_template);
|
2011-01-05 22:24:11 +01:00
|
|
|
ezc_functions.Insert("item_type_is_dir", item_type_is_dir);
|
|
|
|
ezc_functions.Insert("item_type_is_file", item_type_is_file);
|
|
|
|
ezc_functions.Insert("item_type_is_symlink", item_type_is_symlink);
|
|
|
|
ezc_functions.Insert("item_is_link_to", item_is_link_to);
|
|
|
|
ezc_functions.Insert("item_link_to", item_link_to);
|
|
|
|
ezc_functions.Insert("item_is_link_redirect", item_is_link_redirect);
|
2011-06-24 22:53:21 +02:00
|
|
|
ezc_functions.Insert("item_file_size", item_file_size);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
ezc_functions.Insert("item_tab", item_tab);
|
|
|
|
ezc_functions.Insert("item_tab_id", item_tab_id);
|
|
|
|
ezc_functions.Insert("item_tab_subject", item_tab_subject);
|
|
|
|
ezc_functions.Insert("item_tab_subject_noescape", item_tab_subject_noescape);
|
|
|
|
ezc_functions.Insert("item_tab_content", item_tab_content);
|
|
|
|
ezc_functions.Insert("item_tab_content_noescape", item_tab_content_noescape);
|
|
|
|
ezc_functions.Insert("item_tab_print_content", item_tab_print_content);
|
|
|
|
ezc_functions.Insert("item_tab_privileges", item_tab_privileges);
|
|
|
|
ezc_functions.Insert("item_tab_dir", item_tab_dir);
|
|
|
|
ezc_functions.Insert("item_tab_url", item_tab_url);
|
|
|
|
ezc_functions.Insert("item_tab_link", item_tab_link);
|
2011-06-24 22:53:21 +02:00
|
|
|
ezc_functions.Insert("item_tab_filetype_is_none", item_tab_filetype_is_none);
|
|
|
|
ezc_functions.Insert("item_tab_filetype_is_image", item_tab_filetype_is_image);
|
2010-08-10 18:12:50 +02:00
|
|
|
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_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);
|
|
|
|
ezc_functions.Insert("item_tab_group", item_tab_group);
|
|
|
|
ezc_functions.Insert("item_tab_date_creation", item_tab_date_creation);
|
|
|
|
ezc_functions.Insert("item_tab_date_modification", item_tab_date_modification);
|
|
|
|
ezc_functions.Insert("item_tab_date_creation_nice", item_tab_date_creation_nice);
|
|
|
|
ezc_functions.Insert("item_tab_date_modification_nice", item_tab_date_modification_nice);
|
|
|
|
ezc_functions.Insert("item_tab_dates_equal", item_tab_dates_equal);
|
|
|
|
ezc_functions.Insert("item_tab_run", item_tab_run);
|
|
|
|
ezc_functions.Insert("item_tab_can_use_emacs", item_tab_can_use_emacs);
|
2011-01-05 22:24:11 +01:00
|
|
|
ezc_functions.Insert("item_tab_has_static_file", item_tab_has_static_file);
|
|
|
|
ezc_functions.Insert("item_tab_has_thumb", item_tab_has_thumb);
|
|
|
|
ezc_functions.Insert("item_tab_type_is_dir", item_tab_type_is_dir);
|
|
|
|
ezc_functions.Insert("item_tab_type_is_file", item_tab_type_is_file);
|
|
|
|
ezc_functions.Insert("item_tab_type_is_symlink", item_tab_type_is_symlink);
|
|
|
|
ezc_functions.Insert("item_tab_is_link_to", item_tab_is_link_to);
|
|
|
|
ezc_functions.Insert("item_tab_link_to", item_tab_link_to);
|
|
|
|
ezc_functions.Insert("item_tab_is_link_redirect", item_tab_is_link_redirect);
|
2011-06-24 22:53:21 +02:00
|
|
|
ezc_functions.Insert("item_tab_file_size", item_tab_file_size);
|
|
|
|
ezc_functions.Insert("item_tab_has_next", item_tab_has_next);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
last
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("last_tab", last_tab);
|
|
|
|
ezc_functions.Insert("last_tab_name", last_tab_name);
|
|
|
|
ezc_functions.Insert("last_tab_ip", last_tab_ip);
|
|
|
|
ezc_functions.Insert("last_tab_start", last_tab_start);
|
|
|
|
ezc_functions.Insert("last_tab_end", last_tab_end);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
mount
|
2010-02-11 21:56:52 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("mount_type_is", mount_type_is);
|
|
|
|
ezc_functions.Insert("mount_page_arg_is", mount_page_arg_is);
|
|
|
|
ezc_functions.Insert("mount_has_html_template", mount_has_html_template);
|
|
|
|
ezc_functions.Insert("mount_first_html_template", mount_first_html_template);
|
2011-06-24 22:53:21 +02:00
|
|
|
ezc_functions.Insert("mount_css_tab", mount_css_tab);
|
|
|
|
ezc_functions.Insert("mount_css_tab_file", mount_css_tab_file);
|
|
|
|
ezc_functions.Insert("mount_css_tab_file_is_global", mount_css_tab_file_is_global);
|
|
|
|
ezc_functions.Insert("mount_css_tab_has_next", mount_css_tab_has_next);
|
|
|
|
ezc_functions.Insert("mount_css_is_empty", mount_css_is_empty);
|
|
|
|
ezc_functions.Insert("mount_css_is_one", mount_css_is_one);
|
|
|
|
ezc_functions.Insert("mount_css_more_than_one", mount_css_more_than_one);
|
2011-06-21 23:24:49 +02:00
|
|
|
ezc_functions.Insert("mount_cur_type", mount_cur_type);
|
|
|
|
ezc_functions.Insert("mount_cur_dir", mount_cur_dir);
|
|
|
|
ezc_functions.Insert("mount_cur_fs", mount_cur_fs);
|
|
|
|
ezc_functions.Insert("mount_cur_parlist", mount_cur_parlist);
|
|
|
|
ezc_functions.Insert("mount_tab", mount_tab);
|
|
|
|
ezc_functions.Insert("mount_tab_type", mount_tab_type);
|
|
|
|
ezc_functions.Insert("mount_tab_dir", mount_tab_dir);
|
|
|
|
ezc_functions.Insert("mount_tab_fs", mount_tab_fs);
|
|
|
|
ezc_functions.Insert("mount_tab_parlist", mount_tab_parlist);
|
2010-02-11 21:56:52 +01:00
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("ls_ckeditor_funnum_browse", ls_ckeditor_funnum_browse);
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
|
|
|
privileges
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("priv_user_tab", priv_user_tab);
|
|
|
|
ezc_functions.Insert("priv_user_tab_name", priv_user_tab_name);
|
|
|
|
ezc_functions.Insert("priv_user_tab_isdefault", priv_user_tab_isdefault);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("priv_group_tab", priv_group_tab);
|
|
|
|
ezc_functions.Insert("priv_group_tab_name", priv_group_tab_name);
|
|
|
|
ezc_functions.Insert("priv_group_tab_isdefault", priv_group_tab_isdefault);
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("priv_privileges", priv_privileges);
|
|
|
|
ezc_functions.Insert("priv_privileges_for_files", priv_privileges_for_files);
|
|
|
|
ezc_functions.Insert("priv_privileges_for_dirs", priv_privileges_for_dirs);
|
|
|
|
ezc_functions.Insert("priv_show_form_chown", priv_show_form_chown);
|
|
|
|
ezc_functions.Insert("priv_show_form_chmod", priv_show_form_chmod);
|
2010-02-16 19:34:41 +01:00
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
rebus
|
2009-01-31 07:53:36 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("rebus_question", rebus_question);
|
2009-04-16 03:59:42 +02:00
|
|
|
|
|
|
|
|
2011-06-19 22:59:58 +02:00
|
|
|
/*
|
|
|
|
slog
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("slog_tab", slog_tab);
|
|
|
|
ezc_functions.Insert("slog_tab_is_info", slog_tab_is_info);
|
|
|
|
ezc_functions.Insert("slog_tab_is_warning", slog_tab_is_warning);
|
|
|
|
ezc_functions.Insert("slog_tab_is_error", slog_tab_is_error);
|
|
|
|
ezc_functions.Insert("slog_tab_print", slog_tab_print);
|
|
|
|
|
|
|
|
|
2010-10-23 16:54:44 +02:00
|
|
|
/*
|
|
|
|
stat
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("stat_item_type_is_file", stat_item_type_is_file);
|
|
|
|
ezc_functions.Insert("stat_item_type_is_static_file", stat_item_type_is_static_file);
|
|
|
|
ezc_functions.Insert("stat_item_type_is_dir", stat_item_type_is_dir);
|
|
|
|
ezc_functions.Insert("stat_item_inode", stat_item_inode);
|
|
|
|
ezc_functions.Insert("stat_item_user", stat_item_user);
|
|
|
|
ezc_functions.Insert("stat_item_group", stat_item_group);
|
|
|
|
ezc_functions.Insert("stat_item_privileges", stat_item_privileges);
|
|
|
|
ezc_functions.Insert("stat_item_date_creation", stat_item_date_creation);
|
|
|
|
ezc_functions.Insert("stat_item_date_modification", stat_item_date_modification);
|
|
|
|
ezc_functions.Insert("stat_item_template", stat_item_template);
|
|
|
|
ezc_functions.Insert("stat_item_is_template_from_mount_point", stat_item_is_template_from_mount_point);
|
|
|
|
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
sys
|
2009-04-20 00:13:21 +02:00
|
|
|
*/
|
2011-06-27 23:38:19 +02:00
|
|
|
ezc_functions.Insert("sys_ver_major", sys_ver_major);
|
|
|
|
ezc_functions.Insert("sys_ver_minor", sys_ver_minor);
|
|
|
|
ezc_functions.Insert("sys_ver_revision", sys_ver_revision);
|
|
|
|
ezc_functions.Insert("sys_plugin_tab", sys_plugin_tab);
|
|
|
|
ezc_functions.Insert("sys_plugin_tab_has_name", sys_plugin_tab_has_name);
|
|
|
|
ezc_functions.Insert("sys_plugin_tab_name", sys_plugin_tab_name);
|
|
|
|
ezc_functions.Insert("sys_user_tab", sys_user_tab);
|
|
|
|
ezc_functions.Insert("sys_user_tab_is_current", sys_user_tab_is_current);
|
|
|
|
ezc_functions.Insert("sys_user_tab_name", sys_user_tab_name);
|
2009-06-05 22:29:06 +02:00
|
|
|
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
upload
|
2010-01-25 05:52:17 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("upload_ckeditor_funnum", upload_ckeditor_funnum);
|
2010-01-25 05:52:17 +01:00
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
uptime
|
2009-06-05 22:29:06 +02:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("uptime_more_than_one_day", uptime_more_than_one_day);
|
|
|
|
ezc_functions.Insert("uptime_days", uptime_days);
|
|
|
|
ezc_functions.Insert("uptime_hours", uptime_hours);
|
2009-04-16 03:59:42 +02:00
|
|
|
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2009-11-17 00:36:38 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
user
|
2009-11-17 00:36:38 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("user_name", user_name);
|
|
|
|
ezc_functions.Insert("user_logged", user_logged);
|
|
|
|
ezc_functions.Insert("user_super_user", user_super_user);
|
|
|
|
ezc_functions.Insert("user_is_in_group", user_is_in_group);
|
2010-12-06 02:37:30 +01:00
|
|
|
ezc_functions.Insert("user_is_in_all_groups", user_is_in_all_groups);
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("user_can_use_html", user_can_use_html);
|
|
|
|
ezc_functions.Insert("user_can_use_bbcode", user_can_use_bbcode);
|
|
|
|
ezc_functions.Insert("user_can_use_raw", user_can_use_raw);
|
|
|
|
|
|
|
|
|
2010-02-19 00:30:22 +01:00
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
template
|
2010-02-19 00:30:22 +01:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("template_index", template_index);
|
|
|
|
ezc_functions.Insert("template_tab", template_tab);
|
|
|
|
ezc_functions.Insert("template_tab_index", template_tab_index);
|
|
|
|
ezc_functions.Insert("template_tab_isdefault", template_tab_isdefault);
|
|
|
|
ezc_functions.Insert("template_tab_file_name", template_tab_file_name);
|
2010-02-19 00:30:22 +01:00
|
|
|
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
/*
|
|
|
|
winix
|
|
|
|
*/
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("winix_cur_time", winix_cur_time);
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
ezc_functions.Insert("winix_how_many_sessions", winix_how_many_sessions);
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("winix_users_logged", winix_users_logged);
|
|
|
|
ezc_functions.Insert("winix_function", winix_function);
|
|
|
|
ezc_functions.Insert("winix_function_is", winix_function_is);
|
|
|
|
ezc_functions.Insert("winix_function_param_is", winix_function_param_is);
|
2011-02-22 05:14:26 +01:00
|
|
|
ezc_functions.Insert("winix_function_param_is_not",winix_function_param_is_not);
|
2011-02-11 22:37:28 +01:00
|
|
|
ezc_functions.Insert("winix_function_param_value",winix_function_param_value);
|
2010-10-11 22:42:49 +02:00
|
|
|
ezc_functions.Insert("winix_has_plugin", winix_has_plugin);
|
2010-08-10 18:12:50 +02:00
|
|
|
ezc_functions.Insert("winix_loadavg_now", winix_loadavg_now);
|
|
|
|
ezc_functions.Insert("winix_loadavg_1", winix_loadavg_1);
|
|
|
|
ezc_functions.Insert("winix_loadavg_5", winix_loadavg_5);
|
|
|
|
ezc_functions.Insert("winix_loadavg_15", winix_loadavg_15);
|
|
|
|
ezc_functions.Insert("winix_req_per_sec_now", winix_req_per_sec_now);
|
|
|
|
ezc_functions.Insert("winix_req_per_sec_1", winix_req_per_sec_1);
|
|
|
|
ezc_functions.Insert("winix_req_per_sec_5", winix_req_per_sec_5);
|
|
|
|
ezc_functions.Insert("winix_req_per_sec_15", winix_req_per_sec_15);
|
|
|
|
ezc_functions.Insert("winix_err_is", winix_err_is);
|
|
|
|
ezc_functions.Insert("winix_err_code", winix_err_code);
|
|
|
|
ezc_functions.Insert("winix_is_err_in_locales", winix_is_err_in_locales);
|
|
|
|
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);
|
2011-04-26 19:19:08 +02:00
|
|
|
ezc_functions.Insert("false", winix_false);
|
|
|
|
ezc_functions.Insert("true", winix_true);
|
|
|
|
ezc_functions.Insert("str", str);
|
|
|
|
ezc_functions.Insert("strnc", strnc);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
/*
|
2010-09-29 23:24:34 +02:00
|
|
|
who
|
2010-08-13 22:04:57 +02:00
|
|
|
*/
|
2010-09-29 23:24:34 +02:00
|
|
|
ezc_functions.Insert("who_tab", who_tab);
|
|
|
|
ezc_functions.Insert("who_tab_lp", who_tab_lp);
|
|
|
|
ezc_functions.Insert("who_tab_user", who_tab_user);
|
|
|
|
ezc_functions.Insert("who_tab_time", who_tab_time);
|
|
|
|
ezc_functions.Insert("who_tab_last_time", who_tab_last_time);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
others
|
|
|
|
*/
|
|
|
|
ezc_functions.Insert("content", content);
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
plugin.Call(WINIX_TEMPLATES_CREATEFUNCTIONS, &ezc_functions);
|
2010-11-23 22:52:25 +01:00
|
|
|
log << log3 << "Templates: there are " << ezc_functions.Size() << " ezc functions" << logend;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
void Templates::ReadFile(TemplatesFunctions::Pat pat, const wchar_t * file)
|
2010-02-15 01:31:14 +01:00
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
2010-11-25 23:42:24 +01:00
|
|
|
Read(patterns, static_cast<size_t>(pat), locale, locale_filter, ezc_functions, file, config->utf8,
|
|
|
|
config->templates_dir, config->templates_dir_default);
|
2010-02-15 01:31:14 +01:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
void Templates::ReadFileFun(size_t index, const wchar_t * file)
|
2010-08-13 22:04:57 +02:00
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
2010-11-25 23:42:24 +01:00
|
|
|
Read(patterns_fun, index, locale, locale_filter, ezc_functions, file, config->utf8,
|
|
|
|
config->templates_dir, config->templates_dir_default);
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::SetLocale()
|
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
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
locale.UTF8(config->utf8);
|
2011-02-24 18:06:12 +01:00
|
|
|
locale.SetLocaleFiles(config->locale_files);
|
|
|
|
// !! tutaj nie potrzeba ustawiac locali SetLang/SetLangDef (nie odczytujemy kluczy)
|
|
|
|
locale.SetLang(config->locale_default_index); // !! w przyszlosci locale beda ustawiane dla kazdego uzytkownika osobno
|
|
|
|
locale.SetLangDef(config->locale_default_index);
|
2010-08-10 18:12:50 +02:00
|
|
|
locale.Read(config->locale_dir, config->locale_dir_default);
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
2010-01-28 16:39:01 +01:00
|
|
|
|
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
void Templates::ReadFunctionsTemplates()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
Functions::Iterator i = functions->Begin();
|
|
|
|
|
|
|
|
for(; i != functions->End() ; ++i)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring & fun_name = i->first;
|
2010-08-13 22:04:57 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-16 10:42:22 +02:00
|
|
|
void Templates::SetHtmlFilter()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
html_filter.TrimWhite(config->html_filter_trim_white);
|
|
|
|
html_filter.BreakWord(config->html_filter_break_word);
|
|
|
|
html_filter.WrapLine(config->html_filter_wrap_line);
|
|
|
|
html_filter.InsertTabs(config->html_filter_tabs);
|
|
|
|
html_filter.ClearOrphans();
|
|
|
|
|
|
|
|
if( config->html_filter_orphans )
|
|
|
|
{
|
|
|
|
html_filter.OrphansMode(config->html_filter_orphans_mode);
|
|
|
|
|
|
|
|
for(size_t i=0 ; i<locale.Size() ; ++i)
|
|
|
|
{
|
|
|
|
if( locale.IsKeyLang(L"html_lang_attr_value", i) &&
|
|
|
|
locale.IsKeyLangList(L"language_orphans", i) )
|
|
|
|
{
|
|
|
|
html_filter.AssignOrphans(locale.Get(L"html_lang_attr_value", i),
|
|
|
|
locale.GetList(L"language_orphans", i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
void Templates::ReadTemplates()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
SetLocale();
|
|
|
|
ClearPatterns();
|
|
|
|
|
|
|
|
ReadFile(pat_index, config->templates_index.c_str());
|
2010-11-21 01:19:17 +01:00
|
|
|
ReadFile(pat_err_404, L"err_404.html");
|
|
|
|
ReadFile(pat_err_per_denied, L"err_per_denied.html");
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
ReadFunctionsTemplates();
|
2010-06-22 01:53:19 +02:00
|
|
|
index_patterns.ReloadPatterns(locale, locale_filter, false);
|
2011-04-16 10:42:22 +02:00
|
|
|
|
|
|
|
SetHtmlFilter();
|
2010-06-22 01:53:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reading only new index templates (with parsing)
|
|
|
|
// those which are exists are not touched
|
|
|
|
// the rest are deleted
|
|
|
|
void Templates::ReadNewIndexTemplates()
|
|
|
|
{
|
2010-08-13 22:04:57 +02:00
|
|
|
using namespace TemplatesFunctions;
|
2010-06-22 01:53:19 +02:00
|
|
|
|
|
|
|
index_patterns.MarkAllToDelete();
|
2010-08-13 22:04:57 +02:00
|
|
|
ReadIndexFileNames(true);
|
2010-06-22 01:53:19 +02:00
|
|
|
index_patterns.DeleteMarked();
|
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-08-13 22:04:57 +02:00
|
|
|
// 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)
|
2010-06-22 01:53:19 +02:00
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
Mounts::MountTab::const_iterator i;
|
2010-08-10 18:12:50 +02:00
|
|
|
const Mounts::MountTab * pmount_tab = TemplatesFunctions::system->mounts.GetMountTab();
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
// loop through all mount points
|
2010-06-22 01:53:19 +02:00
|
|
|
for(i=pmount_tab->begin() ; i!=pmount_tab->end() ; ++i)
|
|
|
|
{
|
2010-08-13 22:04:57 +02:00
|
|
|
const Mount & mount = i->second;
|
2010-11-21 01:19:17 +01:00
|
|
|
int html_id = TemplatesFunctions::system->mounts.MountParHtmlTemplate();
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
if( size_t(html_id) >= mount.param.size() )
|
|
|
|
{
|
|
|
|
log << log1 << "Templates: something wrong in mount points, there is no"
|
|
|
|
<< " html template parameter" << logend;
|
|
|
|
}
|
|
|
|
else
|
2010-11-21 01:19:17 +01:00
|
|
|
if( mount.param[html_id].defined )
|
2010-08-13 22:04:57 +02:00
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
size_t len = mount.param[html_id].arg.size();
|
2010-08-13 22:04:57 +02:00
|
|
|
size_t a;
|
|
|
|
|
|
|
|
// loop through all html_templates() values
|
|
|
|
for(a=0 ; a<len ; ++a)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring & file_name = mount.param[html_id].arg[a];
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
if( add_pattern )
|
|
|
|
index_patterns.AddPatternIfNotExists(file_name, locale, locale_filter, false); // file pattern will be unmarked
|
|
|
|
else
|
|
|
|
index_patterns.AddFileName(file_name);
|
|
|
|
}
|
|
|
|
}
|
2010-06-22 01:53:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2011-02-24 18:06:12 +01:00
|
|
|
|
|
|
|
void Templates::ClearPatterns(TemplatesFunctions::Patterns & patterns, size_t len)
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
size_t loc, pat;
|
|
|
|
|
|
|
|
patterns.resize(locale.Size());
|
|
|
|
|
|
|
|
for(loc=0 ; loc < patterns.size() ; ++loc)
|
|
|
|
{
|
|
|
|
patterns[loc].resize(len);
|
|
|
|
|
|
|
|
for(pat=0 ; pat<len ; ++pat)
|
|
|
|
patterns[loc][pat].Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 04:09:02 +02:00
|
|
|
void Templates::Init()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
pattern_cacher.SetWhenDelete(config->pattern_cacher_when_delete, config->pattern_cacher_how_many_delete);
|
|
|
|
CreateFunctions(); // create functions first (functions will be cached by patterns)
|
|
|
|
ReadIndexFileNames();
|
|
|
|
ReadTemplates();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-25 23:42:24 +01:00
|
|
|
// index_patterns and patterns for items are not cleared here
|
2010-01-28 16:39:01 +01:00
|
|
|
void Templates::ClearPatterns()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
2010-07-04 22:27:14 +02:00
|
|
|
|
2011-02-24 18:06:12 +01:00
|
|
|
ClearPatterns(patterns, pat_last);
|
|
|
|
ClearPatterns(patterns_fun, functions->FunctionsSize());
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 04:09:02 +02:00
|
|
|
// clearing at the end of a request
|
|
|
|
void Templates::RequestEnd()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
log << log4 << "Templates: patterns cache size: " << pattern_cacher.Size() << logend;
|
|
|
|
pattern_cacher.DeleteOldPatterns();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2011-02-24 18:06:12 +01:00
|
|
|
if( locale.GetLang() >= patterns.size() )
|
2010-01-28 16:39:01 +01:00
|
|
|
return;
|
|
|
|
|
2010-06-22 01:53:19 +02:00
|
|
|
Ezc::Pattern * index = 0;
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring * index_file_local = 0;
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( cur->request->is_item )
|
2010-08-13 22:04:57 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->item.html_template.empty() )
|
|
|
|
index_file_local = &cur->request->item.html_template;
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->dir_tab.back()->html_template.empty() )
|
|
|
|
index_file_local = &cur->request->dir_tab.back()->html_template;
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( !index_file_local )
|
2010-09-13 01:33:27 +02:00
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
const std::wstring & temp = TemplatesFunctions::system->mounts.pmount->FirstArg(
|
2010-09-13 01:33:27 +02:00
|
|
|
TemplatesFunctions::system->mounts.MountParHtmlTemplate() );
|
|
|
|
|
|
|
|
if( !temp.empty() )
|
|
|
|
index_file_local = &temp;
|
|
|
|
|
|
|
|
}
|
2010-06-22 01:53:19 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
if( index_file_local && *index_file_local != config->templates_index )
|
|
|
|
index = index_patterns.GetPattern(*index_file_local, locale.GetLang());
|
|
|
|
|
2010-06-22 01:53:19 +02:00
|
|
|
if( !index )
|
|
|
|
index = &patterns[locale.GetLang()][pat_index];
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
generator.Generate(cur->request->page, *index);
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
void Templates::GenerateRunRaw()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
2010-07-20 01:07:34 +02:00
|
|
|
|
|
|
|
if( !empty_pars.empty() )
|
|
|
|
empty_pars.clear();
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
Info info(cur->request->page, empty_pars, empty_string, empty_stream);
|
2010-05-30 23:07:46 +02:00
|
|
|
|
|
|
|
info.iter = 0;
|
|
|
|
info.res = false;
|
2010-01-11 15:47:52 +01:00
|
|
|
|
|
|
|
item_run(info);
|
|
|
|
}
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
void Templates::Generate(Ezc::Pattern & pattern)
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
generator.Generate(cur->request->page, pattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void Templates::SetConfig(Config * pconfig)
|
|
|
|
{
|
|
|
|
TemplatesFunctions::config = pconfig;
|
|
|
|
TemplatesFunctions::index_patterns.SetConfig(pconfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
void Templates::SetCur(Cur * pcur)
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
TemplatesFunctions::cur = pcur;
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
void Templates::SetDb(Db * pdb)
|
|
|
|
{
|
|
|
|
TemplatesFunctions::db = pdb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::SetSystem(System * psystem)
|
|
|
|
{
|
|
|
|
TemplatesFunctions::system = psystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::SetFunctions(Functions * pfunctions)
|
|
|
|
{
|
|
|
|
TemplatesFunctions::functions = pfunctions;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::SetSessionManager(SessionManager * psession_manager)
|
|
|
|
{
|
|
|
|
TemplatesFunctions::session_manager = psession_manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-28 16:39:01 +01:00
|
|
|
Templates::Templates()
|
|
|
|
{
|
2010-11-25 23:42:24 +01:00
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
index_patterns.SetEzcFunctions(&ezc_functions);
|
|
|
|
pattern_cacher.SetEzcFunctions(&ezc_functions);
|
2010-01-28 16:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|