changed: the way how raw template is set
option for setting raw template from 'emacs' function has been removed now we have index_raw.html template and it can be set from 'template' function removed: template index_fullscreen.html changed: some work in miscspace (changed: space_list_tab, space_list_tab_value and space_list_tab_has_next) fixed: main index template could not be set through 'template' function git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1039 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
abd1500f07
commit
240bf4dc5d
|
@ -601,8 +601,6 @@ void App::CreateJSONAnswer()
|
||||||
// !! IMPROVE ME change to a better name
|
// !! IMPROVE ME change to a better name
|
||||||
void App::MakePage()
|
void App::MakePage()
|
||||||
{
|
{
|
||||||
bool sent = false;
|
|
||||||
|
|
||||||
if( cur.request->page_generated || !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
|
if( cur.request->page_generated || !cur.request->redirect_to.empty() || !cur.request->x_sendfile.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -610,27 +608,7 @@ bool sent = false;
|
||||||
cur.request->gen_skip_new_line,
|
cur.request->gen_skip_new_line,
|
||||||
cur.request->gen_use_special_chars);
|
cur.request->gen_use_special_chars);
|
||||||
|
|
||||||
if( cur.request->is_item && cur.request->item.file_type == WINIX_ITEM_FILETYPE_NONE &&
|
templates.Generate();
|
||||||
cur.request->item.content_type == Item::ct_raw && cur.request->status == WINIX_ERR_OK && cur.request->function )
|
|
||||||
{
|
|
||||||
if( cur.request->function == &functions.fun_cat )
|
|
||||||
{
|
|
||||||
TemplatesFunctions::item_print_content(cur.request->out_main_stream,
|
|
||||||
cur.request->item.content, cur.request->item.content_type);
|
|
||||||
sent = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if( cur.request->function == &functions.fun_run )
|
|
||||||
{
|
|
||||||
templates.GenerateRunRaw();
|
|
||||||
sent = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !sent )
|
|
||||||
{
|
|
||||||
templates.Generate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1182,13 +1160,6 @@ void App::SendHeaders()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class RawType>
|
|
||||||
DbTextStream::RawText<RawType> R(const RawType & par)
|
|
||||||
{
|
|
||||||
return DbTextStream::RawText<RawType>(par);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void App::SendCookies()
|
void App::SendCookies()
|
||||||
{
|
{
|
||||||
PT::Space::TableSingle::iterator i;
|
PT::Space::TableSingle::iterator i;
|
||||||
|
@ -1248,14 +1219,11 @@ void App::PrepareHeaders(bool compressing, int compress_encoding, Header header,
|
||||||
void App::FilterContent()
|
void App::FilterContent()
|
||||||
{
|
{
|
||||||
Request & req = *cur.request;
|
Request & req = *cur.request;
|
||||||
bool raw = req.is_item && req.item.content_type == Item::ct_raw &&
|
|
||||||
req.status == WINIX_ERR_OK && req.function &&
|
|
||||||
(req.function == &functions.fun_cat || req.function == &functions.fun_run);
|
|
||||||
|
|
||||||
bool filter_main_stream = false;
|
bool filter_main_stream = false;
|
||||||
bool filter_json = false;
|
bool filter_json = false;
|
||||||
|
|
||||||
if( config.html_filter && !req.send_bin_stream && !raw )
|
if( config.html_filter && !req.send_bin_stream )
|
||||||
{
|
{
|
||||||
if( req.return_json )
|
if( req.return_json )
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2015, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -182,6 +182,7 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||||
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
|
||||||
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
|
||||||
templates_index = Text(L"templates_index", L"index.html");
|
templates_index = Text(L"templates_index", L"index.html");
|
||||||
|
templates_index_raw = Text(L"templates_index_raw", L"index_raw.html");
|
||||||
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
|
||||||
|
|
||||||
http_session_id_name = Text(L"http_session_id_name", L"session_id");
|
http_session_id_name = Text(L"http_session_id_name", L"session_id");
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2015, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -175,6 +175,10 @@ public:
|
||||||
// default: index.html
|
// default: index.html
|
||||||
std::wstring templates_index;
|
std::wstring templates_index;
|
||||||
|
|
||||||
|
// html template used to send raw content
|
||||||
|
// default: index_raw.html
|
||||||
|
std::wstring templates_index_raw;
|
||||||
|
|
||||||
// if true then only root can use 'template' winix function
|
// if true then only root can use 'template' winix function
|
||||||
// default: false
|
// default: false
|
||||||
bool template_only_root_use_template_fun;
|
bool template_only_root_use_template_fun;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -82,7 +82,6 @@ struct Item
|
||||||
ct_formatted_text,
|
ct_formatted_text,
|
||||||
ct_html,
|
ct_html,
|
||||||
ct_bbcode,
|
ct_bbcode,
|
||||||
ct_raw
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentType content_type;
|
ContentType content_type;
|
||||||
|
@ -116,7 +115,6 @@ struct Item
|
||||||
int hash_type; // hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
int hash_type; // hash type WINIX_CRYPT_HASH_* (see crypt.h)
|
||||||
size_t file_size; // size of the file
|
size_t file_size; // size of the file
|
||||||
|
|
||||||
|
|
||||||
std::wstring html_template;
|
std::wstring html_template;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -753,11 +753,6 @@ bool System::CanUseBBCode(long user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool System::CanUseRaw(long user_id)
|
|
||||||
{
|
|
||||||
return IsSuperUser(user_id) || IsMemberOfGroup(user_id, L"allow_raw");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool System::IsSuperUser(long user_id)
|
bool System::IsSuperUser(long user_id)
|
||||||
|
@ -1395,15 +1390,15 @@ bool System::AddCommonFileToVar(const wchar_t * file_path, const wchar_t * url,
|
||||||
}
|
}
|
||||||
|
|
||||||
file_content_item.Clear();
|
file_content_item.Clear();
|
||||||
file_content_item.parent_id = var->id;
|
file_content_item.parent_id = var->id;
|
||||||
file_content_item.user_id = var->user_id;
|
file_content_item.user_id = var->user_id;
|
||||||
file_content_item.group_id = var->group_id;
|
file_content_item.group_id = var->group_id;
|
||||||
file_content_item.privileges = 07555; // !! IMPROVE ME: may it should be added as a parameter to this function?
|
file_content_item.privileges = 07555; // !! IMPROVE ME: may it should be added as a parameter to this function?
|
||||||
file_content_item.subject = url;
|
file_content_item.subject = url;
|
||||||
file_content_item.url = url;
|
file_content_item.url = url;
|
||||||
file_content_item.type = Item::file;
|
file_content_item.type = Item::file;
|
||||||
file_content_item.content_type = Item::ct_raw;
|
file_content_item.html_template = config->templates_index_raw;
|
||||||
file_content_item.content = file_content;
|
file_content_item.content = file_content;
|
||||||
|
|
||||||
return AddFile(file_content_item, false) == WINIX_ERR_OK;
|
return AddFile(file_content_item, false) == WINIX_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -158,7 +158,6 @@ public:
|
||||||
|
|
||||||
bool CanUseHtml(long user_id);
|
bool CanUseHtml(long user_id);
|
||||||
bool CanUseBBCode(long user_id);
|
bool CanUseBBCode(long user_id);
|
||||||
bool CanUseRaw(long user_id);
|
|
||||||
|
|
||||||
bool IsSuperUser(long user_id);
|
bool IsSuperUser(long user_id);
|
||||||
bool IsMemberOfGroup(long user_id, const wchar_t * group_name);
|
bool IsMemberOfGroup(long user_id, const wchar_t * group_name);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -590,12 +590,6 @@ void Functions::ReadItemContentWithType(Item & item)
|
||||||
if( system->CanUseBBCode(user_id) )
|
if( system->CanUseBBCode(user_id) )
|
||||||
item.content_type = Item::ct_bbcode;
|
item.content_type = Item::ct_bbcode;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if( temp == L"4" )
|
|
||||||
{
|
|
||||||
if( system->CanUseRaw(user_id) )
|
|
||||||
item.content_type = Item::ct_raw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -96,8 +96,13 @@ void Template::CreateTemplateFileName(const std::wstring & index_str)
|
||||||
html_template = config->templates_index;
|
html_template = config->templates_index;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if( index == 1 )
|
||||||
{
|
{
|
||||||
index -= 1;
|
html_template = config->templates_index_raw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index -= 2;
|
||||||
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
||||||
|
|
||||||
if( !par.defined || (size_t)index >= par.arg.size() )
|
if( !par.defined || (size_t)index >= par.arg.size() )
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
[# minimalistic template]
|
|
||||||
|
|
||||||
<html lang="{language}">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>[doc_title]</title>
|
|
||||||
[include "index_head_functions_add.html"]
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
[include "slog.html"]
|
|
||||||
|
|
||||||
[# each winix function has div.winix in its template defined -- only functions: cat and run don't have div.winix]
|
|
||||||
[# so you can easly use 'content' with your own template]
|
|
||||||
[# and when using other winix functions you automatically get proper styling]
|
|
||||||
[content]
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -0,0 +1 @@
|
||||||
|
[content]
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
* Copyright (c) 2011-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -151,7 +151,7 @@ void gallery_tab_meta_tab_value(Info & i)
|
||||||
if( gallery_index < gallery_info.item_sort_tab.size() )
|
if( gallery_index < gallery_info.item_sort_tab.size() )
|
||||||
{
|
{
|
||||||
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
||||||
space_list_tab_value(i, item.meta);
|
space_list_tab_value(i, item.meta, L"gallery_tab_meta_tab");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ void gallery_tab_meta_tab_has_next(Info & i)
|
||||||
if( gallery_index < gallery_info.item_sort_tab.size() )
|
if( gallery_index < gallery_info.item_sort_tab.size() )
|
||||||
{
|
{
|
||||||
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
||||||
space_list_tab_has_next(i, item.meta);
|
space_list_tab_has_next(i, item.meta, L"gallery_tab_meta_tab");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2015, Tomasz Sowa
|
* Copyright (c) 2011-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -405,7 +405,7 @@ void menu_dir_tab_meta_tab_value(Info & i)
|
||||||
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
|
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
|
||||||
|
|
||||||
if( stack->iter < sitem->citem->menu_items.size() )
|
if( stack->iter < sitem->citem->menu_items.size() )
|
||||||
space_list_tab_value(i, sitem->citem->menu_items[stack->iter].meta);
|
space_list_tab_value(i, sitem->citem->menu_items[stack->iter].meta, L"menu_dir_tab_meta_tab");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ void menu_dir_tab_meta_tab_has_next(Info & i)
|
||||||
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
|
StackItem * sitem = reinterpret_cast<StackItem*>(stack->fun_data);
|
||||||
|
|
||||||
if( stack->iter < sitem->citem->menu_items.size() )
|
if( stack->iter < sitem->citem->menu_items.size() )
|
||||||
space_list_tab_has_next(i, sitem->citem->menu_items[stack->iter].meta);
|
space_list_tab_has_next(i, sitem->citem->menu_items[stack->iter].meta, L"menu_dir_tab_meta_tab");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -482,14 +482,14 @@ void dir_last_meta_tab(Info & i)
|
||||||
|
|
||||||
void dir_last_meta_tab_value(Info & i)
|
void dir_last_meta_tab_value(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_value(i, cur->request->dir_tab.back()->meta);
|
space_list_tab_value(i, cur->request->dir_tab.back()->meta, L"dir_last_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void dir_last_meta_tab_has_next(Info & i)
|
void dir_last_meta_tab_has_next(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_has_next(i, cur->request->dir_tab.back()->meta);
|
space_list_tab_has_next(i, cur->request->dir_tab.back()->meta, L"dir_last_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -515,13 +515,13 @@ void dir_last_admin_meta_tab(Info & i)
|
||||||
|
|
||||||
void dir_last_admin_meta_tab_value(Info & i)
|
void dir_last_admin_meta_tab_value(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_value(i, cur->request->dir_tab.back()->ameta);
|
space_list_tab_value(i, cur->request->dir_tab.back()->ameta, L"dir_last_admin_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void dir_last_admin_meta_tab_has_next(Info & i)
|
void dir_last_admin_meta_tab_has_next(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_has_next(i, cur->request->dir_tab.back()->ameta);
|
space_list_tab_has_next(i, cur->request->dir_tab.back()->ameta, L"dir_last_admin_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ void env_tab_value(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
space_list_tab_value(i, puser->env);
|
space_list_tab_value(i, puser->env, L"env_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void env_tab_has_next(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
space_list_tab_has_next(i, puser->env);
|
space_list_tab_has_next(i, puser->env, L"env_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void env_admin_tab_value(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
space_list_tab_value(i, puser->aenv);
|
space_list_tab_value(i, puser->aenv, L"env_admin_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ void env_admin_tab_has_next(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
space_list_tab_has_next(i, puser->aenv);
|
space_list_tab_has_next(i, puser->aenv, L"env_admin_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -114,9 +114,6 @@ void item_content_type_is(Item & item, Info & i)
|
||||||
else
|
else
|
||||||
if( item.content_type == Item::ct_bbcode && i.par == L"bbcode" )
|
if( item.content_type == Item::ct_bbcode && i.par == L"bbcode" )
|
||||||
i.res = true;
|
i.res = true;
|
||||||
else
|
|
||||||
if( item.content_type == Item::ct_raw && i.par == L"raw" )
|
|
||||||
i.res = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +135,7 @@ void item_print_content(HtmlTextStream & out, const std::wstring & content, Item
|
||||||
HtmlEscapeFormTxt(out, content);
|
HtmlEscapeFormTxt(out, content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( content_type == Item::ct_html || content_type == Item::ct_raw )
|
if( content_type == Item::ct_html )
|
||||||
{
|
{
|
||||||
out << R(content);
|
out << R(content);
|
||||||
}
|
}
|
||||||
|
@ -436,14 +433,14 @@ void item_meta_tab(Info & i)
|
||||||
|
|
||||||
void item_meta_tab_value(Info & i)
|
void item_meta_tab_value(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_value(i, cur->request->last_item->meta);
|
space_list_tab_value(i, cur->request->last_item->meta, L"item_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void item_meta_tab_has_next(Info & i)
|
void item_meta_tab_has_next(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_has_next(i, cur->request->last_item->meta);
|
space_list_tab_has_next(i, cur->request->last_item->meta, L"item_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,13 +466,13 @@ void item_admin_meta_tab(Info & i)
|
||||||
|
|
||||||
void item_admin_meta_tab_value(Info & i)
|
void item_admin_meta_tab_value(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_value(i, cur->request->last_item->ameta);
|
space_list_tab_value(i, cur->request->last_item->ameta, L"item_admin_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void item_admin_meta_tab_has_next(Info & i)
|
void item_admin_meta_tab_has_next(Info & i)
|
||||||
{
|
{
|
||||||
space_list_tab_has_next(i, cur->request->last_item->ameta);
|
space_list_tab_has_next(i, cur->request->last_item->ameta, L"item_admin_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -861,7 +858,7 @@ void item_tab_meta_tab(Info & i)
|
||||||
void item_tab_meta_tab_value(Info & i)
|
void item_tab_meta_tab_value(Info & i)
|
||||||
{
|
{
|
||||||
if( item_index < cur->request->item_tab.size() )
|
if( item_index < cur->request->item_tab.size() )
|
||||||
space_list_tab_value(i, cur->request->item_tab[item_index].meta);
|
space_list_tab_value(i, cur->request->item_tab[item_index].meta, L"item_tab_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -869,7 +866,7 @@ void item_tab_meta_tab_value(Info & i)
|
||||||
void item_tab_meta_tab_has_next(Info & i)
|
void item_tab_meta_tab_has_next(Info & i)
|
||||||
{
|
{
|
||||||
if( item_index < cur->request->item_tab.size() )
|
if( item_index < cur->request->item_tab.size() )
|
||||||
space_list_tab_has_next(i, cur->request->item_tab[item_index].meta);
|
space_list_tab_has_next(i, cur->request->item_tab[item_index].meta, L"item_tab_meta_tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,44 +120,6 @@ static size_t space_reqid = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
struct SpaceKey
|
|
||||||
{
|
|
||||||
PT::Space * global_space;
|
|
||||||
std::vector<std::wstring> spaces_names;
|
|
||||||
|
|
||||||
|
|
||||||
bool operator<(const SpaceKey & k)
|
|
||||||
{
|
|
||||||
if( global_space != k.global_space )
|
|
||||||
return global_space < k.global_space;
|
|
||||||
|
|
||||||
if( spaces_names.size() != k.spaces_names.size() )
|
|
||||||
return spaces_names.size() < k.spaces_names.size();
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<spaces_names.size() ; ++i)
|
|
||||||
{
|
|
||||||
if( spaces_names[i] != k.spaces_names[i] )
|
|
||||||
return spaces_names[i] < k.spaces_names[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
* this is the same space
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mapping a global space with spaces names (strings) to a last space address
|
|
||||||
*/
|
|
||||||
//static std::map<SpaceKey, PT::Space *> space_map;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void space_init(const std::vector<Ezc::Var> & params, PT::Space & space, SpaceInfo & space_info)
|
void space_init(const std::vector<Ezc::Var> & params, PT::Space & space, SpaceInfo & space_info)
|
||||||
|
@ -212,233 +174,20 @@ void space_value(Info & i, PT::Space & space, bool escape)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct SpaceTabStackItem : public Ezc::FunData
|
||||||
/*
|
|
||||||
stack item for [for] statement
|
|
||||||
*/
|
|
||||||
struct SpaceStackItem
|
|
||||||
{
|
{
|
||||||
// names of the spaces
|
|
||||||
std::vector<std::wstring> spaces;
|
|
||||||
|
|
||||||
// table of values
|
|
||||||
std::vector<std::wstring> values;
|
std::vector<std::wstring> values;
|
||||||
|
|
||||||
// an index to 'values' which is incremented every each [for]
|
|
||||||
size_t value_index;
|
|
||||||
|
|
||||||
|
|
||||||
SpaceStackItem()
|
|
||||||
{
|
|
||||||
value_index = 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
each Space has its own SpacesTabInfo struct
|
|
||||||
*/
|
|
||||||
struct SpacesTabInfo
|
|
||||||
{
|
|
||||||
// a stack for [for] statements
|
|
||||||
std::vector<SpaceStackItem> stack_tab;
|
|
||||||
|
|
||||||
// current item from 'stack_tab'
|
|
||||||
size_t cur_stack;
|
|
||||||
|
|
||||||
SpacesTabInfo()
|
|
||||||
{
|
|
||||||
cur_stack = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::map<PT::Space*, SpacesTabInfo> spaces_tab_info_map;
|
|
||||||
static size_t spaces_tab_reqid = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool spaces_tab_find_stack_item(std::vector<Ezc::Var> & params, SpacesTabInfo & spaces_tab_info)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size();
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<spaces_tab_info.stack_tab.size() ; ++i)
|
|
||||||
{
|
|
||||||
if( are_spaces_the_same(params, spaces_tab_info.stack_tab[i].spaces) )
|
|
||||||
{
|
|
||||||
spaces_tab_info.cur_stack = i;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void spaces_tab_add_to_stack(std::vector<Ezc::Var> & params, PT::Space & space, SpacesTabInfo & spaces_tab_info)
|
|
||||||
{
|
|
||||||
if( !params.empty() )
|
|
||||||
{
|
|
||||||
// adding a new item at the end (with the default constructor)
|
|
||||||
spaces_tab_info.stack_tab.resize(spaces_tab_info.stack_tab.size() + 1);
|
|
||||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size() - 1;
|
|
||||||
|
|
||||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab.back();
|
|
||||||
|
|
||||||
copy_space(params, stack_item.spaces);
|
|
||||||
space.ListText(params.back().str, stack_item.values);
|
|
||||||
stack_item.value_index = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void spaces_tab_check_reqid()
|
|
||||||
{
|
|
||||||
if( spaces_tab_reqid != cur->request->id )
|
|
||||||
{
|
|
||||||
spaces_tab_reqid = cur->request->id;
|
|
||||||
spaces_tab_info_map.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void spaces_tab_init(std::vector<Ezc::Var> & params, PT::Space & space, SpacesTabInfo & spaces_tab_info)
|
|
||||||
{
|
|
||||||
PT::Space * child_space = find_space(params, space);
|
|
||||||
|
|
||||||
if( child_space )
|
|
||||||
{
|
|
||||||
if( !spaces_tab_find_stack_item(params, spaces_tab_info) )
|
|
||||||
{
|
|
||||||
// add a new value to the stack
|
|
||||||
spaces_tab_add_to_stack(params, *child_space, spaces_tab_info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// there is not such a space
|
|
||||||
// space_list_tab() will return false immediately
|
|
||||||
spaces_tab_info.cur_stack = spaces_tab_info.stack_tab.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void space_list_tab(Info & i, PT::Space & space)
|
void space_list_tab(Info & i, PT::Space & space)
|
||||||
{
|
|
||||||
spaces_tab_check_reqid();
|
|
||||||
|
|
||||||
if( !i.params.empty() )
|
|
||||||
{
|
|
||||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
|
||||||
spaces_tab_init(i.params, space, spaces_tab_info);
|
|
||||||
|
|
||||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
|
||||||
{
|
|
||||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
|
||||||
|
|
||||||
// i.iter is different for each [for] statement (implemented in EZC)
|
|
||||||
// so we don't have to remember it in our stack
|
|
||||||
// for each the same space we have only one item in the stack, e.g.
|
|
||||||
// [for item_meta "space1" "space2" "value"]
|
|
||||||
// [for item_meta "space1" "space2" "value"]
|
|
||||||
// [end]
|
|
||||||
// [end]
|
|
||||||
// above two [for]s use the same item on our stack
|
|
||||||
stack_item.value_index = i.iter;
|
|
||||||
|
|
||||||
i.res = stack_item.value_index < stack_item.values.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void spaces_tab_value_print(HtmlTextStream & out, SpacesTabInfo & spaces_tab_info)
|
|
||||||
{
|
|
||||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
|
||||||
{
|
|
||||||
SpaceStackItem & stack_item = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
|
||||||
|
|
||||||
if( stack_item.value_index < stack_item.values.size() )
|
|
||||||
out << stack_item.values[stack_item.value_index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void space_list_tab_value(Info & i, PT::Space & space)
|
|
||||||
{
|
|
||||||
spaces_tab_check_reqid();
|
|
||||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
|
||||||
|
|
||||||
if( i.params.empty() )
|
|
||||||
{
|
|
||||||
// value from last [for ...] statement
|
|
||||||
spaces_tab_value_print(i.out, spaces_tab_info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size_t cur_stack_old = spaces_tab_info.cur_stack;
|
|
||||||
|
|
||||||
if( spaces_tab_find_stack_item(i.params, spaces_tab_info) )
|
|
||||||
spaces_tab_value_print(i.out, spaces_tab_info);
|
|
||||||
|
|
||||||
spaces_tab_info.cur_stack = cur_stack_old;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool spaces_tab_has_next(SpacesTabInfo & spaces_tab_info)
|
|
||||||
{
|
|
||||||
if( spaces_tab_info.cur_stack < spaces_tab_info.stack_tab.size() )
|
|
||||||
{
|
|
||||||
SpaceStackItem & val = spaces_tab_info.stack_tab[spaces_tab_info.cur_stack];
|
|
||||||
return val.value_index + 1 < val.values.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void space_list_tab_has_next(Info & i, PT::Space & space)
|
|
||||||
{
|
|
||||||
spaces_tab_check_reqid();
|
|
||||||
SpacesTabInfo & spaces_tab_info = spaces_tab_info_map[&space];
|
|
||||||
|
|
||||||
if( i.params.empty() )
|
|
||||||
{
|
|
||||||
// value from last [for ...] statement
|
|
||||||
i.res = spaces_tab_has_next(spaces_tab_info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size_t cur_stack_old = spaces_tab_info.cur_stack;
|
|
||||||
|
|
||||||
if( spaces_tab_find_stack_item(i.params, spaces_tab_info) )
|
|
||||||
i.res = spaces_tab_has_next(spaces_tab_info);
|
|
||||||
|
|
||||||
spaces_tab_info.cur_stack = cur_stack_old;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Space2StackItem : public Ezc::FunData
|
|
||||||
{
|
|
||||||
std::vector<std::wstring> values;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void space2_list_tab(Info & i, PT::Space & space)
|
|
||||||
{
|
{
|
||||||
if( !i.stack.fun_data )
|
if( !i.stack.fun_data )
|
||||||
{
|
{
|
||||||
if( !i.params.empty() )
|
if( !i.params.empty() )
|
||||||
{
|
{
|
||||||
i.stack.for_name = new std::wstring(L"space_list_tab");
|
SpaceTabStackItem * stack_item = new SpaceTabStackItem();
|
||||||
|
|
||||||
Space2StackItem * stack_item = new Space2StackItem();
|
|
||||||
i.stack.fun_data = stack_item;
|
i.stack.fun_data = stack_item;
|
||||||
|
|
||||||
PT::Space * dst_space = find_space(i.params, space);
|
PT::Space * dst_space = find_space(i.params, space);
|
||||||
|
@ -451,27 +200,32 @@ void space2_list_tab(Info & i, PT::Space & space)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto stack_item = reinterpret_cast<Space2StackItem*>(i.stack.fun_data);
|
auto stack_item = reinterpret_cast<SpaceTabStackItem*>(i.stack.fun_data);
|
||||||
i.res = i.iter < stack_item->values.size();
|
i.res = i.iter < stack_item->values.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void space2_list_tab_value(Info & i, PT::Space & space)
|
void space_list_tab_value(Info & i, PT::Space & space, const std::wstring & function_name)
|
||||||
{
|
{
|
||||||
Ezc::Stack * stack = i.FindLastFor(i.par, L"space_list_tab");
|
Ezc::Stack * stack;
|
||||||
|
auto user_object = i.FindUserObject<SpaceTabStackItem>(function_name, &stack);
|
||||||
|
|
||||||
if( stack && stack->fun_data )
|
if( user_object && stack->iter < user_object->values.size() )
|
||||||
{
|
i.out << user_object->values[stack->iter];
|
||||||
auto stack_item = dynamic_cast<Space2StackItem*>(stack->fun_data);
|
|
||||||
|
|
||||||
if( stack_item && stack->iter < stack_item->values.size() )
|
|
||||||
i.out << stack_item->values[stack->iter];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void space_list_tab_has_next(Info & i, PT::Space & space, const std::wstring & function_name)
|
||||||
|
{
|
||||||
|
Ezc::Stack * stack;
|
||||||
|
auto user_object = i.FindUserObject<SpaceTabStackItem>(function_name, &stack);
|
||||||
|
|
||||||
|
if( user_object && stack->iter + 1 < user_object->values.size() )
|
||||||
|
i.res = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,13 +72,13 @@ void space_value(Info & i, PT::Space & space, bool escape = true);
|
||||||
// add
|
// add
|
||||||
// void space_list_tab_size(Info & i, PT::Space & space);
|
// void space_list_tab_size(Info & i, PT::Space & space);
|
||||||
|
|
||||||
void space_list_tab(Info & i, PT::Space & space);
|
|
||||||
void space_list_tab_value(Info & i, PT::Space & space);
|
|
||||||
void space_list_tab_has_next(Info & i, PT::Space & space);
|
|
||||||
|
|
||||||
|
|
||||||
void space2_list_tab(Info & i, PT::Space & space);
|
void space_list_tab(Info & i, PT::Space & space);
|
||||||
void space2_list_tab_value(Info & i, PT::Space & space);
|
void space_list_tab_value(Info & i, PT::Space & space, const std::wstring & function_name);
|
||||||
|
void space_list_tab_has_next(Info & i, PT::Space & space, const std::wstring & function_name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// !! IMPROVE ME
|
// !! IMPROVE ME
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -91,7 +91,8 @@ void template_init()
|
||||||
// the first item in the html template is an empty string
|
// the first item in the html template is an empty string
|
||||||
// added in the html template
|
// added in the html template
|
||||||
temp_tab.clear();
|
temp_tab.clear();
|
||||||
temp_tab.push_back(config->templates_index);
|
temp_tab.push_back(config->templates_index); // index: 0
|
||||||
|
temp_tab.push_back(config->templates_index_raw); // index: 1
|
||||||
|
|
||||||
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
Mount::ParamRow & par = system->mounts.pmount->param[system->mounts.MountParHtmlTemplate()];
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t pat_index; // main index pattern
|
size_t pat_index; // main index pattern
|
||||||
size_t pat_index_fullscreen; // an empty pattern (without menus etc. but with all rest html tags, used for ckeditor images browser)
|
size_t pat_index_raw; // pattern for a raw content
|
||||||
size_t pat_err_404; // 404 error
|
size_t pat_err_404; // 404 error
|
||||||
size_t pat_err_per_denied; // permission denied error
|
size_t pat_err_per_denied; // permission denied error
|
||||||
|
|
||||||
|
@ -678,7 +678,6 @@ void Templates::CreateFunctions()
|
||||||
ezc_functions.Insert("user_is_in_all_groups", user_is_in_all_groups);
|
ezc_functions.Insert("user_is_in_all_groups", user_is_in_all_groups);
|
||||||
ezc_functions.Insert("user_can_use_html", user_can_use_html);
|
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_bbcode", user_can_use_bbcode);
|
||||||
ezc_functions.Insert("user_can_use_raw", user_can_use_raw);
|
|
||||||
ezc_functions.Insert("user_has_correct_time_zone",user_has_correct_time_zone);
|
ezc_functions.Insert("user_has_correct_time_zone",user_has_correct_time_zone);
|
||||||
ezc_functions.Insert("user_time_zone_name", user_time_zone_name);
|
ezc_functions.Insert("user_time_zone_name", user_time_zone_name);
|
||||||
ezc_functions.Insert("user_time_zone_id", user_time_zone_id);
|
ezc_functions.Insert("user_time_zone_id", user_time_zone_id);
|
||||||
|
@ -949,7 +948,7 @@ using namespace TemplatesFunctions;
|
||||||
ezc_blocks.Clear();
|
ezc_blocks.Clear();
|
||||||
|
|
||||||
pat_index = patterns.Add(config->templates_index);
|
pat_index = patterns.Add(config->templates_index);
|
||||||
pat_index_fullscreen = patterns.Add(L"index_fullscreen.html"); // !! IMPROVE ME name to the config
|
pat_index_raw = patterns.Add(config->templates_index_raw);
|
||||||
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
|
pat_err_404 = patterns.Add(L"err_404.html"); // !! IMPROVE ME name to the config
|
||||||
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
|
pat_err_per_denied = patterns.Add(L"err_per_denied.html"); // !! IMPROVE ME name to the config
|
||||||
|
|
||||||
|
@ -1005,36 +1004,29 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
|
|
||||||
// can return a null pointer
|
// can return a null pointer
|
||||||
Ezc::Pattern * Templates::SelectIndexPatternFromItemAndMountPoint()
|
Ezc::Pattern * Templates::SelectIndexPattern(const std::wstring & template_name)
|
||||||
{
|
{
|
||||||
using namespace TemplatesFunctions;
|
using namespace TemplatesFunctions;
|
||||||
|
|
||||||
Ezc::Pattern * index = 0;
|
Ezc::Pattern * index = 0;
|
||||||
|
|
||||||
// first we try to get an index template from 'template' item parameter (template winix function)
|
if( template_name == config->templates_index )
|
||||||
// if such a parameter is not defined then we try to get an index from the mount point
|
|
||||||
if( !cur->request->last_item->html_template.empty() && cur->request->last_item->html_template != config->templates_index )
|
|
||||||
{
|
{
|
||||||
index = index_patterns.Get(cur->request->last_item->html_template, locale.GetCurLang());
|
index = patterns.Get(pat_index, locale.GetCurLang());
|
||||||
|
}
|
||||||
if( index )
|
else
|
||||||
{
|
if( template_name == config->templates_index_raw )
|
||||||
log << log4 << "Templates: index template taken from the last item, template file name: "
|
{
|
||||||
<< cur->request->last_item->html_template << logend;
|
index = patterns.Get(pat_index_raw, locale.GetCurLang());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Mounts & mounts = TemplatesFunctions::system->mounts;
|
index = index_patterns.Get(template_name, locale.GetCurLang());
|
||||||
const std::wstring & mount_file_name = cur->mount->FirstArg(mounts.MountParHtmlTemplate());
|
}
|
||||||
|
|
||||||
if( !mount_file_name.empty() && mount_file_name != config->templates_index )
|
if( index )
|
||||||
{
|
{
|
||||||
index = index_patterns.Get(mount_file_name, locale.GetCurLang());
|
log << log3 << "Templates: index template taken from: " << template_name << logend;
|
||||||
|
|
||||||
if( index )
|
|
||||||
log << log4 << "Templates: index template taken from the mount point, template file name: " << mount_file_name << logend;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
@ -1050,18 +1042,19 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
Ezc::Pattern * index = 0;
|
Ezc::Pattern * index = 0;
|
||||||
|
|
||||||
if( cur->request->IsParam(L"fullscreen") )
|
if( !cur->request->last_item->html_template.empty() )
|
||||||
{
|
{
|
||||||
index = patterns.Get(pat_index_fullscreen, locale.GetCurLang());
|
index = SelectIndexPattern(cur->request->last_item->html_template);
|
||||||
|
|
||||||
if( index )
|
|
||||||
log << log3 << "Templates: index template taken from index_fullscreen.html" << logend;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index = SelectIndexPatternFromItemAndMountPoint();
|
Mounts & mounts = TemplatesFunctions::system->mounts;
|
||||||
|
const std::wstring & mount_file_name = cur->mount->FirstArg(mounts.MountParHtmlTemplate());
|
||||||
|
|
||||||
|
if( !mount_file_name.empty() )
|
||||||
|
index = SelectIndexPattern(mount_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !index )
|
if( !index )
|
||||||
{
|
{
|
||||||
index = change_patterns.Get(cur->mount->dir_id, config->templates_index, locale.GetCurLang());
|
index = change_patterns.Get(cur->mount->dir_id, config->templates_index, locale.GetCurLang());
|
||||||
|
@ -1072,7 +1065,7 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
if( !index )
|
if( !index )
|
||||||
{
|
{
|
||||||
index = patterns.Get(pat_index, locale.GetCurLang());;
|
index = patterns.Get(pat_index, locale.GetCurLang());
|
||||||
|
|
||||||
if( index )
|
if( index )
|
||||||
log << log3 << "Templates: index template taken from: " << config->templates_index << logend;
|
log << log3 << "Templates: index template taken from: " << config->templates_index << logend;
|
||||||
|
@ -1114,21 +1107,6 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Templates::GenerateRunRaw()
|
|
||||||
{
|
|
||||||
using namespace TemplatesFunctions;
|
|
||||||
|
|
||||||
if( !empty_pars.empty() )
|
|
||||||
empty_pars.clear();
|
|
||||||
|
|
||||||
Ezc::Stack s;
|
|
||||||
Info info(cur->request->out_main_stream, empty_pars, empty_string, empty_stream, s);
|
|
||||||
|
|
||||||
info.iter = s.iter;
|
|
||||||
info.res = false;
|
|
||||||
|
|
||||||
item_run(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Templates::Generate(Ezc::Pattern & pattern)
|
void Templates::Generate(Ezc::Pattern & pattern)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2015, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -573,7 +573,6 @@ namespace TemplatesFunctions
|
||||||
void user_is_in_all_groups(Info & i);
|
void user_is_in_all_groups(Info & i);
|
||||||
void user_can_use_html(Info & i);
|
void user_can_use_html(Info & i);
|
||||||
void user_can_use_bbcode(Info & i);
|
void user_can_use_bbcode(Info & i);
|
||||||
void user_can_use_raw(Info & i);
|
|
||||||
void user_has_correct_time_zone(Info & i);
|
void user_has_correct_time_zone(Info & i);
|
||||||
void user_time_zone_name(Info & i);
|
void user_time_zone_name(Info & i);
|
||||||
void user_time_zone_id(Info & i);
|
void user_time_zone_id(Info & i);
|
||||||
|
@ -686,7 +685,6 @@ public:
|
||||||
void SetEzcParameters(bool trim_white, bool skip_new_line, bool use_special_chars);
|
void SetEzcParameters(bool trim_white, bool skip_new_line, bool use_special_chars);
|
||||||
|
|
||||||
void Generate();
|
void Generate();
|
||||||
void GenerateRunRaw();
|
|
||||||
void Generate(Ezc::Pattern & pattern);
|
void Generate(Ezc::Pattern & pattern);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -697,7 +695,7 @@ private:
|
||||||
void ReadLocale();
|
void ReadLocale();
|
||||||
void SetHtmlFilter();
|
void SetHtmlFilter();
|
||||||
void CreateFunctions(); // should be called before reading patterns (patterns will cache ezc functions)
|
void CreateFunctions(); // should be called before reading patterns (patterns will cache ezc functions)
|
||||||
Ezc::Pattern * SelectIndexPatternFromItemAndMountPoint();
|
Ezc::Pattern * SelectIndexPattern(const std::wstring & template_name);
|
||||||
Ezc::Pattern * SelectIndexPattern();
|
Ezc::Pattern * SelectIndexPattern();
|
||||||
|
|
||||||
TemplatesFunctions::EzcGen generator;
|
TemplatesFunctions::EzcGen generator;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
* Copyright (c) 2008-2016, Tomasz Sowa
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -128,15 +128,6 @@ void user_can_use_bbcode(Info & i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void user_can_use_raw(Info & i)
|
|
||||||
{
|
|
||||||
if( !cur->session->puser )
|
|
||||||
i.res = false;
|
|
||||||
else
|
|
||||||
i.res = system->CanUseRaw(cur->session->puser->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void user_has_correct_time_zone(Info & i)
|
void user_has_correct_time_zone(Info & i)
|
||||||
{
|
{
|
||||||
if( cur->session->puser )
|
if( cur->session->puser )
|
||||||
|
|
Loading…
Reference in New Issue