398 lines
9.3 KiB
C++
Executable File
398 lines
9.3 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfilecmslutemplatestemplates
|
|
#define headerfilecmslutemplatestemplates
|
|
|
|
#include <iomanip>
|
|
#include <set>
|
|
#include "ezc.h"
|
|
#include "misc.h"
|
|
#include "patterncacher.h"
|
|
#include "ckeditorgetparser.h"
|
|
#include "indexpatterns.h"
|
|
#include "locale.h"
|
|
#include "db/db.h"
|
|
#include "htmltextstream.h"
|
|
#include "core/config.h"
|
|
#include "core/request.h"
|
|
#include "core/system.h"
|
|
#include "core/sessionmanager.h"
|
|
#include "localefilter.h"
|
|
|
|
|
|
|
|
class Functions;
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
{
|
|
|
|
enum Pat
|
|
{
|
|
pat_index = 0, // first should be zero
|
|
pat_err_404,
|
|
pat_err_per_denied,
|
|
pat_last // should be last
|
|
};
|
|
|
|
extern IndexPatterns index_patterns; // patterns for main index template
|
|
extern Patterns patterns; // those patterns from enum Pat
|
|
extern Patterns patterns_fun; // patterns for winix functions
|
|
extern PatternCacher pattern_cacher; // patterns for user items (files with an executable bit set)
|
|
extern Locale locale;
|
|
extern EzcFun ezc_functions;
|
|
extern LocaleFilter locale_filter;
|
|
extern CKEditorGetParser ckeditor_getparser;
|
|
|
|
extern Config * config;
|
|
extern Request * request;
|
|
extern Db * db;
|
|
extern System * system;
|
|
extern Functions * functions;
|
|
extern SessionManager * session_manager;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
adduser
|
|
*/
|
|
void adduser_last_login(Info & i);
|
|
void adduser_last_email(Info & i);
|
|
|
|
|
|
/*
|
|
dir
|
|
*/
|
|
void dir(Info & i);
|
|
void dir_without_slash(Info & i);
|
|
void dir_parent(Info & i);
|
|
void dir_parent_without_slash(Info & i);
|
|
void dir_can_read_exec(Info & i);
|
|
void dir_can_write(Info & i);
|
|
void dir_can_remove(Info & i);
|
|
void dir_can_use_emacs(Info & i);
|
|
void dir_can_use_mkdir(Info & i);
|
|
|
|
void dir_childs_tab(Info & i);
|
|
void dir_childs_is_parent(Info & i);
|
|
void dir_childs_tab_url(Info & i);
|
|
void dir_childs_tab_privileges(Info & i);
|
|
void dir_childs_tab_user(Info & i);
|
|
void dir_childs_tab_group(Info & i);
|
|
|
|
void dir_tab(Info & i);
|
|
void dir_tab_url(Info & i);
|
|
void dir_tab_link(Info & i);
|
|
|
|
void dir_last_default_item_dir(Info &);
|
|
void dir_last_default_item_url(Info & i);
|
|
void dir_last_subject(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_date_creation_nice(Info & i);
|
|
void dir_last_date_modification_nice(Info & i);
|
|
void dir_last_dates_equal(Info & i);
|
|
void dir_last_users_different(Info & i);
|
|
void dir_last_modification_user(Info & i);
|
|
void dir_last_html_template(Info & i);
|
|
void dir_last_has_html_template(Info & i);
|
|
|
|
|
|
/*
|
|
doc
|
|
*/
|
|
void doc_title(Info & i);
|
|
void doc_base_url(Info & i);
|
|
void doc_base_url_auth(Info & i);
|
|
void doc_base_url_static(Info & i);
|
|
void doc_base_url_common(Info & i);
|
|
void doc_current_url(Info & i);
|
|
|
|
|
|
/*
|
|
item
|
|
*/
|
|
void item_is(Info & i); // !! change to is_item lub na item_defined
|
|
void item_id(Info & i);
|
|
void item_subject(Info & i);
|
|
void item_subject_noescape(Info & i);
|
|
void item_content(Info & i);
|
|
void item_content_noescape(Info & i);
|
|
void item_content_type_is(Item & item, Info & i);
|
|
void item_content_type_is(Info & i);
|
|
void item_content_is_empty(Info & i);
|
|
void item_print_content(HtmlTextStream & out, const std::wstring & content, Item::ContentType content_type);
|
|
void item_print_content(Info & i);
|
|
void item_privileges(Info & i);
|
|
void item_dir(Info & i);
|
|
void item_url(Info & i);
|
|
void item_url_is(Info & i);
|
|
void item_link(Info & i);
|
|
void item_auth_is_none(Info & i);
|
|
void item_auth_is_image(Info & i);
|
|
void item_can_read(Info & i);
|
|
void item_can_write(Info & i);
|
|
void item_can_remove(Info & i);
|
|
void item_user(Info & i);
|
|
void item_modification_user(Info & i);
|
|
void item_users_different(Info & i);
|
|
void item_date_creation(Info & i);
|
|
void item_date_modification(Info & i);
|
|
void item_date_creation_nice(Info & i);
|
|
void item_date_modification_nice(Info & i);
|
|
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);
|
|
void item_tab_subject(Info & i);
|
|
void item_tab_subject_noescape(Info & i);
|
|
void item_tab_content(Info & i);
|
|
void item_tab_content_noescape(Info & i);
|
|
void item_tab_print_content(Info & i);
|
|
void item_tab_privileges(Info & i);
|
|
void item_tab_dir(Info & i);
|
|
void item_tab_url(Info & i);
|
|
void item_tab_link(Info & i);
|
|
void item_tab_link_auth(Info & i);
|
|
void item_tab_can_read(Info & i);
|
|
void item_tab_can_write(Info & i);
|
|
void item_tab_user(Info & i);
|
|
void item_tab_modification_user(Info & i);
|
|
void item_tab_users_different(Info & i);
|
|
void item_tab_group(Info & i);
|
|
void item_tab_date_creation(Info & i);
|
|
void item_tab_date_modification(Info & i);
|
|
void item_tab_date_creation_nice(Info & i);
|
|
void item_tab_date_modification_nice(Info & i);
|
|
void item_tab_dates_equal(Info & i);
|
|
void item_tab_run(Info & i);
|
|
void item_tab_can_use_emacs(Info & i);
|
|
|
|
|
|
/*
|
|
last
|
|
*/
|
|
void last_tab(Info & i);
|
|
void last_tab_name(Info & i);
|
|
void last_tab_ip(Info & i);
|
|
void last_tab_start(Info & i);
|
|
void last_tab_end(Info & i);
|
|
|
|
|
|
/*
|
|
mount
|
|
*/
|
|
void mount_type_is(Info & i);
|
|
void mount_page_arg_is(Info & i);
|
|
void mount_thread_arg_is(Info & i);
|
|
void mount_has_html_template(Info & i);
|
|
void mount_first_html_template(Info & i);
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
void ls_ckeditor_funnum_browse(Info & i);
|
|
|
|
|
|
/*
|
|
privileges
|
|
*/
|
|
void priv_user_tab(Info & i);
|
|
void priv_user_tab_name(Info & i);
|
|
void priv_user_tab_isdefault(Info & i);
|
|
|
|
void priv_group_tab(Info & i);
|
|
void priv_group_tab_name(Info & i);
|
|
void priv_group_tab_isdefault(Info & i);
|
|
|
|
void priv_privileges(Info & i);
|
|
void priv_privileges_for_files(Info & i);
|
|
void priv_privileges_for_dirs(Info & i);
|
|
|
|
void priv_show_form_chown(Info & i);
|
|
void priv_show_form_chmod(Info & i);
|
|
|
|
|
|
/*
|
|
rebus
|
|
*/
|
|
void rebus_question(Info & i);
|
|
|
|
|
|
/*
|
|
stat
|
|
*/
|
|
void stat_item_type_is_file(Info & i);
|
|
void stat_item_type_is_static_file(Info & i);
|
|
void stat_item_type_is_dir(Info & i);
|
|
void stat_item_inode(Info & i);
|
|
void stat_item_user(Info & i);
|
|
void stat_item_group(Info & i);
|
|
void stat_item_privileges(Info & i);
|
|
void stat_item_date_creation(Info & i);
|
|
void stat_item_date_modification(Info & i);
|
|
void stat_item_template(Info & i);
|
|
void stat_item_is_template_from_mount_point(Info & i);
|
|
|
|
|
|
/*
|
|
sys
|
|
*/
|
|
void sys_ver_major(Info & i);
|
|
void sys_ver_minor(Info & i);
|
|
void sys_ver_revision(Info & i);
|
|
|
|
|
|
/*
|
|
upload
|
|
*/
|
|
void upload_ckeditor_funnum(Info & i);
|
|
|
|
|
|
/*
|
|
uptime
|
|
*/
|
|
void uptime_more_than_one_day(Info & i);
|
|
void uptime_days(Info & i);
|
|
void uptime_hours(Info & i);
|
|
|
|
|
|
/*
|
|
user
|
|
*/
|
|
void user_name(Info & i);
|
|
void user_logged(Info & i);
|
|
void user_super_user(Info & i);
|
|
void user_is_in_group(Info & i);
|
|
void user_can_use_html(Info & i);
|
|
void user_can_use_bbcode(Info & i);
|
|
void user_can_use_raw(Info & i);
|
|
|
|
|
|
/*
|
|
template (html templates)
|
|
*/
|
|
void template_index(Info & i);
|
|
void template_tab(Info & i);
|
|
void template_tab_index(Info & i);
|
|
void template_tab_isdefault(Info & i);
|
|
void template_tab_file_name(Info & i);
|
|
|
|
|
|
/*
|
|
thread
|
|
*/
|
|
void thread_is(Info & i); // !! change to is_thread lub na thread_defined
|
|
void thread_tab(Info & i);
|
|
void thread_tab_url(Info & i);
|
|
void thread_tab_subject(Info & i);
|
|
void thread_tab_author(Info & i);
|
|
void thread_tab_answers(Info & i);
|
|
void thread_tab_last_item_date_modification(Info & i);
|
|
void thread_tab_last_item_date_modification_nice(Info & i);
|
|
void thread_tab_last_item_user(Info & i);
|
|
void thread_can_create(Info & i);
|
|
|
|
|
|
/*
|
|
winix
|
|
*/
|
|
void winix_cur_time(Info & i);
|
|
void winix_how_many_sessions(Info & i);
|
|
void winix_users_logged(Info & i);
|
|
void winix_function(Info & i);
|
|
void winix_function_is(Info & i);
|
|
void winix_function_param_is(Info & i);
|
|
void winix_has_plugin(Info & i);
|
|
void winix_loadavg_now(Info & i);
|
|
void winix_loadavg_1(Info & i);
|
|
void winix_loadavg_5(Info & i);
|
|
void winix_loadavg_15(Info & i);
|
|
void winix_req_per_sec_now(Info & i);
|
|
void winix_req_per_sec_1(Info & i);
|
|
void winix_req_per_sec_5(Info & i);
|
|
void winix_req_per_sec_15(Info & i);
|
|
void winix_err_is(Info & i);
|
|
void winix_err_code(Info & i);
|
|
void winix_is_err_in_locales(Info & i);
|
|
void winix_err_msg_from_locales(Info & i);
|
|
void winix_show_content_in_full_window(Info & i);
|
|
void winix_false(Info & i);
|
|
void winix_true(Info & i);
|
|
|
|
|
|
/*
|
|
who
|
|
*/
|
|
void who_tab(Info & i);
|
|
void who_tab_lp(Info & i);
|
|
void who_tab_user(Info & i);
|
|
void who_tab_time(Info & i);
|
|
void who_tab_last_time(Info & i);
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Templates
|
|
{
|
|
public:
|
|
|
|
Templates();
|
|
|
|
void SetConfig(Config * pconfig);
|
|
void SetRequest(Request * prequest);
|
|
void SetDb(Db * pdb);
|
|
void SetSystem(System * psystem);
|
|
void SetFunctions(Functions * pfunctions);
|
|
void SetSessionManager(SessionManager * psession_manager);
|
|
|
|
void ClearPatterns();
|
|
void ReadTemplates();
|
|
void ReadNewIndexTemplates();
|
|
void ReadIndexFileNames(bool add_pattern = false);
|
|
void CreateFunctions(); // should be called before reading patterns (patterns will cache ezc functions)
|
|
void Generate();
|
|
void GenerateRunRaw();
|
|
|
|
private:
|
|
|
|
void ReadFile(TemplatesFunctions::Pat pat, const wchar_t * file);
|
|
void ReadFileFun(size_t index, const wchar_t * file);
|
|
void ReadFunctionsTemplates();
|
|
void SetLocale();
|
|
|
|
std::wstring temp;
|
|
std::wstring fun_file;
|
|
};
|
|
|
|
|
|
|
|
#endif
|