small changes in template winix function
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@637 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -86,6 +86,7 @@ void Request::Clear()
|
|||||||
item_tab.clear();
|
item_tab.clear();
|
||||||
item.Clear();
|
item.Clear();
|
||||||
dir_tab.clear();
|
dir_tab.clear();
|
||||||
|
last_item = 0;
|
||||||
is_item = false;
|
is_item = false;
|
||||||
function = 0;
|
function = 0;
|
||||||
param_tab.clear();
|
param_tab.clear();
|
||||||
|
|||||||
@@ -107,9 +107,8 @@ struct Request
|
|||||||
// send as attachment (causing header: content-disposition: attachment)
|
// send as attachment (causing header: content-disposition: attachment)
|
||||||
bool send_as_attachment;
|
bool send_as_attachment;
|
||||||
|
|
||||||
// !! moze dolozyc pole Item * last_item
|
// this is a pointer either to the item (if exists) or to the last directory
|
||||||
// i ono bedzie wskazywalo na albo item (jesli jest) albo na ostatni katalog
|
Item * last_item;
|
||||||
// ?
|
|
||||||
|
|
||||||
|
|
||||||
Request();
|
Request();
|
||||||
|
|||||||
@@ -128,17 +128,15 @@ Item * pdir;
|
|||||||
|
|
||||||
void System::RedirectToLastDir()
|
void System::RedirectToLastDir()
|
||||||
{
|
{
|
||||||
// !! dac sprawdzenie czy istnieje
|
if( !request->dir_tab.empty() )
|
||||||
RedirectTo( *request->dir_tab.back() );
|
RedirectTo( *request->dir_tab.back() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void System::RedirectToLastItem()
|
void System::RedirectToLastItem()
|
||||||
{
|
{
|
||||||
if( request->is_item )
|
if( request->last_item )
|
||||||
RedirectTo(request->item);
|
RedirectTo( *request->last_item );
|
||||||
else
|
|
||||||
RedirectTo( *request->dir_tab.back() );// !! dac sprawdzenie czy istnieje
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ void FunctionParser::ParseDirectories()
|
|||||||
|
|
||||||
++get_index;
|
++get_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request->last_item = request->dir_tab.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -77,6 +79,8 @@ void FunctionParser::ParseItem()
|
|||||||
|
|
||||||
if( request->status == WINIX_ERR_OK )
|
if( request->status == WINIX_ERR_OK )
|
||||||
{
|
{
|
||||||
|
request->last_item = &request->item;
|
||||||
|
|
||||||
if( request->role == Request::authorizer && request->item.auth == Item::auth_none )
|
if( request->role == Request::authorizer && request->item.auth == Item::auth_none )
|
||||||
{
|
{
|
||||||
log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend;
|
log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend;
|
||||||
|
|||||||
@@ -40,27 +40,64 @@ bool Template::HasAccess()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Template::EditTemplate(Item & item)
|
void Template::PutLog(Item & item)
|
||||||
{
|
{
|
||||||
html_file = request->PostVar("template");
|
log << log3 << "Template: changed template for item.id: " << item.id << ", new template: ";
|
||||||
TrimWhite(html_file);
|
|
||||||
request->status = db->EditTemplateItemById(item.id, html_file);
|
|
||||||
|
|
||||||
if( request->status == WINIX_ERR_OK )
|
if( item.html_template.empty() )
|
||||||
item.html_template = html_file;
|
log << "(taking from mount point)";
|
||||||
|
else
|
||||||
|
log << item.html_template;
|
||||||
|
|
||||||
|
log << logend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Template::CreateTemplateFileName(const std::string & index_str)
|
||||||
|
{
|
||||||
|
int index = atoi(index_str.c_str());
|
||||||
|
|
||||||
|
if( index < 0 )
|
||||||
|
{
|
||||||
|
html_template.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( index == 0 )
|
||||||
|
{
|
||||||
|
html_template = config->templates_index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index -= 1;
|
||||||
|
Mount::ParamRow & par = system->mounts.pmount->param[Mount::par_html_template];
|
||||||
|
|
||||||
|
if( !par.defined || (size_t)index >= par.arg.size() )
|
||||||
|
html_template.clear();
|
||||||
|
else
|
||||||
|
html_template = par.arg[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Template::ChangeTemplate(Item & item)
|
||||||
|
{
|
||||||
|
if( html_template != item.html_template )
|
||||||
|
{
|
||||||
|
request->status = db->EditTemplateItemById(item.id, html_template);
|
||||||
|
|
||||||
|
if( request->status == WINIX_ERR_OK )
|
||||||
|
{
|
||||||
|
item.html_template = html_template;
|
||||||
|
PutLog(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Template::MakePost()
|
void Template::MakePost()
|
||||||
{
|
{
|
||||||
if( request->is_item )
|
CreateTemplateFileName(request->PostVar("template"));
|
||||||
{
|
ChangeTemplate(*request->last_item);
|
||||||
EditTemplate(request->item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditTemplate(*request->dir_tab.back());
|
|
||||||
}
|
|
||||||
|
|
||||||
system->RedirectToLastItem();
|
system->RedirectToLastItem();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string html_file;
|
std::string html_template;
|
||||||
void EditTemplate(Item & item);
|
void CreateTemplateFileName(const std::string & index_str);
|
||||||
|
void ChangeTemplate(Item & item);
|
||||||
|
void PutLog(Item & item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
[if-no winix_err_is "0"]
|
[if-no winix_err_is "0"]
|
||||||
<p class="error">
|
<p class="error">
|
||||||
[if-one winix_is_err_in_locales]
|
[if-one winix_is_err_in_locales]
|
||||||
[winix_err_msg_from_locales]
|
[winix_err_msg_from_locales]
|
||||||
[else]
|
[else]
|
||||||
{winix_err_default} [winix_err_code]
|
{winix_err_default} [winix_err_code]
|
||||||
[end]
|
[end]
|
||||||
</p>
|
</p>
|
||||||
[end]
|
[end]
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
[include "fun_priv.html"]
|
[include "fun_priv.html"]
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[include "fun_priv.html"]
|
[include "fun_priv.html"]
|
||||||
|
|||||||
@@ -1,61 +1,61 @@
|
|||||||
<h1>{template_header}</h1>
|
<h1>{template_header}</h1>
|
||||||
|
|
||||||
[include "error.html"]
|
[include "error.html"]
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
[if item_is]
|
[if item_is]
|
||||||
|
|
||||||
{template_info_file}:
|
{template_info_file}:
|
||||||
|
|
||||||
[if item_has_html_template]
|
[if item_has_html_template]
|
||||||
[item_html_template]
|
[item_html_template]
|
||||||
[else]
|
[else]
|
||||||
{template_from_mount_point}
|
{template_from_mount_point}
|
||||||
|
|
||||||
[if mount_has_html_template]
|
[if mount_has_html_template]
|
||||||
([mount_first_html_template])
|
([mount_first_html_template])
|
||||||
[else]
|
[else]
|
||||||
([template_index])
|
([template_index])
|
||||||
[end]
|
[end]
|
||||||
[end]
|
[end]
|
||||||
|
|
||||||
[else]
|
[else]
|
||||||
|
|
||||||
{template_info_dir}:
|
{template_info_dir}:
|
||||||
|
|
||||||
[if dir_last_has_html_template]
|
[if dir_last_has_html_template]
|
||||||
[dir_last_html_template]
|
[dir_last_html_template]
|
||||||
[else]
|
[else]
|
||||||
{template_from_mount_point}
|
{template_from_mount_point}
|
||||||
|
|
||||||
[if mount_has_html_template]
|
[if mount_has_html_template]
|
||||||
([mount_first_html_template])
|
([mount_first_html_template])
|
||||||
[else]
|
[else]
|
||||||
([template_index])
|
([template_index])
|
||||||
[end]
|
[end]
|
||||||
[end]
|
[end]
|
||||||
|
|
||||||
[end]
|
[end]
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form id="additem" method="post" action="[doc_base_url][dir][if-one item_is][item_url]/[end]template">
|
<form id="additem" method="post" action="[doc_base_url][dir][if-one item_is][item_url]/[end]template">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{template_form_legend}</legend>
|
<legend>{template_form_legend}</legend>
|
||||||
|
|
||||||
{template_form_info}:
|
{template_form_info}:
|
||||||
|
|
||||||
<select name="template" class="template">
|
<select name="template" class="template">
|
||||||
|
|
||||||
[# the first should be an empty string (value="") which means: a first template from the mount point]
|
[# the first should be an empty string (value="") which means: a first template from the mount point]
|
||||||
<option value="">({template_form_from_mount_point})</option>
|
<option value="-1">({template_form_from_mount_point})</option>
|
||||||
|
|
||||||
[for template_tab]
|
[for template_tab]
|
||||||
<option[if-one template_tab_isdefault] selected[end]>[template_tab_file_name]</option>
|
<option value="[template_tab_index]"[if-one template_tab_isdefault] selected[end]>[template_tab_file_name]</option>
|
||||||
[end]
|
[end]
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
[include "error.html"]
|
[include "error.html"]
|
||||||
|
|
||||||
|
|
||||||
<p>Winix [sys_ver_major].[sys_ver_minor].[sys_ver_revision]</p>
|
<p>Winix [sys_ver_major].[sys_ver_minor].[sys_ver_revision]</p>
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ void template_tab(Info & i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void template_tab_index(Info & i)
|
||||||
|
{
|
||||||
|
i.out << temp_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void template_tab_isdefault(Info & i)
|
void template_tab_isdefault(Info & i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ void Templates::CreateFunctions()
|
|||||||
*/
|
*/
|
||||||
ezc_functions.Insert("template_index", template_index);
|
ezc_functions.Insert("template_index", template_index);
|
||||||
ezc_functions.Insert("template_tab", template_tab);
|
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_isdefault", template_tab_isdefault);
|
||||||
ezc_functions.Insert("template_tab_file_name", template_tab_file_name);
|
ezc_functions.Insert("template_tab_file_name", template_tab_file_name);
|
||||||
|
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ namespace TemplatesFunctions
|
|||||||
*/
|
*/
|
||||||
void template_index(Info & i);
|
void template_index(Info & i);
|
||||||
void template_tab(Info & i);
|
void template_tab(Info & i);
|
||||||
|
void template_tab_index(Info & i);
|
||||||
void template_tab_isdefault(Info & i);
|
void template_tab_isdefault(Info & i);
|
||||||
void template_tab_file_name(Info & i);
|
void template_tab_file_name(Info & i);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user