updated to the new Pikotools api (new Space struct)
This commit is contained in:
parent
00b980e74b
commit
35e10ed469
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2019, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -504,6 +504,14 @@ void App::ProcessRequestThrow()
|
||||||
{
|
{
|
||||||
functions.Parse(); // parsing directories, files, functions and parameters
|
functions.Parse(); // parsing directories, files, functions and parameters
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set global connector for now
|
||||||
|
* in the future each thread will have its own model_connector
|
||||||
|
*
|
||||||
|
* don't set connector for item_tab - it will be moved out from request
|
||||||
|
*/
|
||||||
|
cur.request->item.set_connector(model_connector);
|
||||||
|
|
||||||
if( !cur.request->dir_tab.empty() )
|
if( !cur.request->dir_tab.empty() )
|
||||||
{
|
{
|
||||||
cur.mount = system.mounts.CalcCurMount();
|
cur.mount = system.mounts.CalcCurMount();
|
||||||
|
@ -625,6 +633,8 @@ void App::ClearAfterRequest()
|
||||||
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
system.mounts.pmount = cur.mount; // IMPROVE ME system.mounts.pmount will be removed
|
||||||
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
// send_data_buf doesn't have to be cleared and it is better to not clear it (optimizing)
|
||||||
|
|
||||||
|
cur.request->item.set_connector(nullptr);
|
||||||
|
|
||||||
log << logendrequest;
|
log << logendrequest;
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
|
@ -700,16 +710,7 @@ void App::CreateJSONAnswer()
|
||||||
json_out_stream << L"}\n,\n\"info\": ";
|
json_out_stream << L"}\n,\n\"info\": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if( req.info_serializer )
|
req.info.serialize_to_json_stream(json_out_stream, false);
|
||||||
{
|
|
||||||
req.info_serializer->Serialize(req.info, json_out_stream, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
json_out_stream << L"{}";
|
|
||||||
log << log1 << "App: Request::info_serializer not defined" << logend;
|
|
||||||
}
|
|
||||||
|
|
||||||
log << log3 << "App: sending JSON answer";
|
log << log3 << "App: sending JSON answer";
|
||||||
|
|
||||||
if( !req.return_info_only )
|
if( !req.return_info_only )
|
||||||
|
@ -831,16 +832,19 @@ void App::LogEnvironmentVariables()
|
||||||
|
|
||||||
void App::LogEnvironmentHTTPVariables()
|
void App::LogEnvironmentHTTPVariables()
|
||||||
{
|
{
|
||||||
PT::Space::Table::iterator i = cur.request->headers_in.table.begin();
|
if( cur.request->headers_in.is_object() )
|
||||||
|
|
||||||
for( ; i != cur.request->headers_in.table.end() ; ++i)
|
|
||||||
{
|
{
|
||||||
log << log1 << "HTTP Env: " << i->first << "=";
|
PT::Space::ObjectType::iterator i = cur.request->headers_in.value.value_object.begin();
|
||||||
|
|
||||||
if( i->second.size() == 1 )
|
for( ; i != cur.request->headers_in.value.value_object.end() ; ++i)
|
||||||
log << i->second[0] << logend;
|
{
|
||||||
else
|
log << log1 << "HTTP Env: " << i->first << "=";
|
||||||
log << "(incorrect value table size, should be one but is " << i->second.size() << ")" << logend;
|
|
||||||
|
if( i->second->is_wstr() )
|
||||||
|
log << *i->second->get_wstr() << logend;
|
||||||
|
else
|
||||||
|
log << "(incorrect value type, expected wstr)" << logend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -983,11 +987,12 @@ bool App::SaveEnvHTTPVariable(const char * env)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PT::UTF8ToWide(header_name, http_header);
|
PT::UTF8ToWide(header_name, http_header_name);
|
||||||
|
PT::UTF8ToWide(header_value, http_header_value);
|
||||||
|
|
||||||
std::wstring & inserted_header = cur.request->headers_in.Add(http_header, L"", true);
|
cur.request->headers_in.add(http_header_name, http_header_value);
|
||||||
PT::UTF8ToWide(header_value, inserted_header);
|
http_header_name.clear();
|
||||||
http_header.clear();
|
http_header_value.clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -999,11 +1004,11 @@ void App::ReadEnvRemoteIP()
|
||||||
|
|
||||||
if( config.check_proxy_ip_header )
|
if( config.check_proxy_ip_header )
|
||||||
{
|
{
|
||||||
http_header = L"HTTP_";
|
http_header_name = L"HTTP_";
|
||||||
http_header += config.proxy_ip_header;
|
http_header_name += config.proxy_ip_header;
|
||||||
PT::ToUpper(http_header);
|
PT::ToUpper(http_header_name);
|
||||||
|
|
||||||
PT::WideToUTF8(http_header, http_header_8bit);
|
PT::WideToUTF8(http_header_name, http_header_8bit);
|
||||||
v = FCGX_GetParam(http_header_8bit.c_str(), fcgi_request.envp);
|
v = FCGX_GetParam(http_header_8bit.c_str(), fcgi_request.envp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1087,7 +1092,7 @@ void App::ReadPostJson()
|
||||||
const int buffer_len = sizeof(buffer) / sizeof(char) - 1;
|
const int buffer_len = sizeof(buffer) / sizeof(char) - 1;
|
||||||
int read_len;
|
int read_len;
|
||||||
|
|
||||||
post_json_parser.SetSpace(cur.request->post_in);
|
space_parser.SetSpace(cur.request->post_in);
|
||||||
post_buffer.clear();
|
post_buffer.clear();
|
||||||
post_buffer.reserve(1024 * 1024 * 5); // IMPROVEME add to config?
|
post_buffer.reserve(1024 * 1024 * 5); // IMPROVEME add to config?
|
||||||
|
|
||||||
|
@ -1106,13 +1111,17 @@ void App::ReadPostJson()
|
||||||
|
|
||||||
if( !post_buffer.empty() )
|
if( !post_buffer.empty() )
|
||||||
{
|
{
|
||||||
PT::JSONToSpaceParser::Status status = post_json_parser.ParseString(post_buffer.c_str());
|
PT::SpaceParser::Status status = space_parser.ParseJSON(post_buffer.c_str());
|
||||||
post_buffer.clear();
|
post_buffer.clear();
|
||||||
|
|
||||||
if( status != PT::JSONToSpaceParser::ok )
|
if( status != PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
log << log1 << "App: cannot parse the input stream as a JSON object, status: " << (int)status << logend;
|
log << log1 << "App: cannot parse the input stream as an JSON object";
|
||||||
cur.request->post_in.Clear();
|
|
||||||
|
if( status == PT::SpaceParser::syntax_error )
|
||||||
|
log << ", syntax error in line: " << space_parser.get_last_parsed_line() << logend;
|
||||||
|
|
||||||
|
cur.request->post_in.clear();
|
||||||
// return an error (http error of some kind?)
|
// return an error (http error of some kind?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1202,9 +1211,9 @@ void App::PrepareSessionCookie()
|
||||||
|
|
||||||
bool App::AddHeader(const wchar_t * name, const wchar_t * value)
|
bool App::AddHeader(const wchar_t * name, const wchar_t * value)
|
||||||
{
|
{
|
||||||
if( !cur.request->out_headers.GetValue(name) )
|
if( !cur.request->out_headers.has_key(name) )
|
||||||
{
|
{
|
||||||
cur.request->out_headers.Add(name, value);
|
cur.request->out_headers.add(name, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1214,9 +1223,9 @@ return false;
|
||||||
|
|
||||||
bool App::AddHeader(const std::wstring & name, const std::wstring & value)
|
bool App::AddHeader(const std::wstring & name, const std::wstring & value)
|
||||||
{
|
{
|
||||||
if( !cur.request->out_headers.GetValue(name) )
|
if( !cur.request->out_headers.has_key(name) )
|
||||||
{
|
{
|
||||||
cur.request->out_headers.Add(name, value);
|
cur.request->out_headers.add(name, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,9 +1235,9 @@ return false;
|
||||||
|
|
||||||
bool App::AddHeader(const wchar_t * name, const PT::WTextStream & value)
|
bool App::AddHeader(const wchar_t * name, const PT::WTextStream & value)
|
||||||
{
|
{
|
||||||
if( !cur.request->out_headers.GetValue(name) )
|
if( !cur.request->out_headers.has_key(name) )
|
||||||
{
|
{
|
||||||
cur.request->out_headers.Add(name, value);
|
cur.request->out_headers.add_stream(name, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,9 +1247,9 @@ return false;
|
||||||
|
|
||||||
bool App::AddHeader(const std::wstring & name, const PT::WTextStream & value)
|
bool App::AddHeader(const std::wstring & name, const PT::WTextStream & value)
|
||||||
{
|
{
|
||||||
if( !cur.request->out_headers.GetValue(name) )
|
if( !cur.request->out_headers.has_key(name) )
|
||||||
{
|
{
|
||||||
cur.request->out_headers.Add(name, value);
|
cur.request->out_headers.add_stream(name, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,34 +1322,29 @@ void App::PrepareHeadersStatic()
|
||||||
|
|
||||||
void App::PrepareHeaderContentType()
|
void App::PrepareHeaderContentType()
|
||||||
{
|
{
|
||||||
std::wstring * value = 0;
|
if( !cur.request->out_headers.has_key(L"Content-Type") )
|
||||||
|
|
||||||
if( !cur.request->out_headers.GetValue(L"Content-Type") )
|
|
||||||
{
|
{
|
||||||
if( cur.request->return_json )
|
if( cur.request->return_json )
|
||||||
{
|
{
|
||||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/json");
|
cur.request->out_headers.add(L"Content-Type", L"application/json; charset=UTF-8");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch( config.content_type_header )
|
switch( config.content_type_header )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/xhtml+xml");
|
cur.request->out_headers.add(L"Content-Type", L"application/xhtml+xml; charset=UTF-8");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
value = &cur.request->out_headers.Add(L"Content-Type", L"application/xml");
|
cur.request->out_headers.add(L"Content-Type", L"application/xml; charset=UTF-8");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
value = &cur.request->out_headers.Add(L"Content-Type", L"text/html");
|
cur.request->out_headers.add(L"Content-Type", L"text/html; charset=UTF-8");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( value )
|
|
||||||
*value += L"; charset=UTF-8";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1435,25 +1439,32 @@ void App::PrepareHeadersNormal(Header header, size_t output_size)
|
||||||
// and if compression is enabled the client's browser will not be able to decompress the stream
|
// and if compression is enabled the client's browser will not be able to decompress the stream
|
||||||
void App::SendHeaders()
|
void App::SendHeaders()
|
||||||
{
|
{
|
||||||
PT::Space::Table::iterator i;
|
PT::Space::ObjectType::iterator i;
|
||||||
PT::Space & headers = cur.request->out_headers;
|
PT::Space & headers = cur.request->out_headers;
|
||||||
|
|
||||||
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_HEADERS, &headers);
|
if( headers.is_object() )
|
||||||
|
|
||||||
for(i=headers.table.begin() ; i != headers.table.end() ; ++i)
|
|
||||||
{
|
{
|
||||||
if( i->second.size() == 1 )
|
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_HEADERS, &headers);
|
||||||
|
|
||||||
|
for(i=headers.value.value_object.begin() ; i != headers.value.value_object.end() ; ++i)
|
||||||
{
|
{
|
||||||
PT::WideToUTF8(i->first, aheader_name);
|
if( i->second->is_wstr() )
|
||||||
PT::WideToUTF8(i->second[0], aheader_value);
|
{
|
||||||
|
PT::WideToUTF8(i->first, aheader_name);
|
||||||
|
PT::WideToUTF8(*i->second->get_wstr(), aheader_value);
|
||||||
|
|
||||||
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
||||||
FCGX_PutS(": ", fcgi_request.out);
|
FCGX_PutS(": ", fcgi_request.out);
|
||||||
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
||||||
FCGX_PutS("\r\n", fcgi_request.out);
|
FCGX_PutS("\r\n", fcgi_request.out);
|
||||||
|
|
||||||
if( config.log_http_answer_headers )
|
if( config.log_http_answer_headers )
|
||||||
log << log1 << "HTTP Header: " << aheader_name << ": " << aheader_value << logend;
|
log << log1 << "HTTP Header: " << aheader_name << ": " << aheader_value << logend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log2 << "Skipping HTTP Header: " << i->first << " - it's not a wstr" << logend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1462,26 +1473,33 @@ void App::SendHeaders()
|
||||||
|
|
||||||
void App::SendCookies()
|
void App::SendCookies()
|
||||||
{
|
{
|
||||||
PT::Space::Table::iterator i;
|
PT::Space::ObjectType::iterator i;
|
||||||
PT::Space & cookies = cur.request->out_cookies;
|
PT::Space & cookies = cur.request->out_cookies;
|
||||||
|
|
||||||
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_COOKIES, &cookies);
|
if( cookies.is_object() )
|
||||||
|
|
||||||
for(i=cookies.table.begin() ; i != cookies.table.end() ; ++i)
|
|
||||||
{
|
{
|
||||||
if( i->second.size() == 1 )
|
plugin.Call(WINIX_PREPARE_TO_SEND_HTTP_COOKIES, &cookies);
|
||||||
|
|
||||||
|
for(i=cookies.value.value_object.begin() ; i != cookies.value.value_object.end() ; ++i)
|
||||||
{
|
{
|
||||||
PT::WideToUTF8(i->first, aheader_name);
|
if( i->second->is_wstr() )
|
||||||
PT::WideToUTF8(i->second[0], aheader_value);
|
{
|
||||||
|
PT::WideToUTF8(i->first, aheader_name);
|
||||||
|
PT::WideToUTF8(*i->second->get_wstr(), aheader_value);
|
||||||
|
|
||||||
FCGX_PutS("Set-Cookie: ", fcgi_request.out);
|
FCGX_PutS("Set-Cookie: ", fcgi_request.out);
|
||||||
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
|
||||||
FCGX_PutS("=", fcgi_request.out);
|
FCGX_PutS("=", fcgi_request.out);
|
||||||
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
FCGX_PutS(aheader_value.c_str(), fcgi_request.out);
|
||||||
FCGX_PutS("\r\n", fcgi_request.out);
|
FCGX_PutS("\r\n", fcgi_request.out);
|
||||||
|
|
||||||
if( config.log_http_answer_headers )
|
if( config.log_http_answer_headers )
|
||||||
log << log1 << "HTTP Header: Set-Cookie: " << aheader_name << "=" << aheader_value << logend;
|
log << log1 << "HTTP Header: Set-Cookie: " << aheader_name << "=" << aheader_value << logend;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log2 << "Skipping Cookie: " << i->first << " - it's not a wstr" << logend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1522,14 +1540,14 @@ void App::PrepareStandardJSONFields()
|
||||||
{
|
{
|
||||||
PT::Space & info = cur.request->info;
|
PT::Space & info = cur.request->info;
|
||||||
|
|
||||||
if( !info.GetFirstValue(L"status") )
|
if( !info.has_key(L"status") )
|
||||||
{
|
{
|
||||||
info.Add(L"status", cur.request->status);
|
info.add(L"status", cur.request->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !cur.request->redirect_to.empty() && !info.GetFirstValue(L"redirect_to") )
|
if( !cur.request->redirect_to.empty() && !info.has_key(L"redirect_to") )
|
||||||
{
|
{
|
||||||
info.Add(L"redirect_to", cur.request->redirect_to);
|
info.add(L"redirect_to", cur.request->redirect_to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1824,12 +1842,6 @@ int compress_encoding;
|
||||||
|
|
||||||
void App::SendAnswer()
|
void App::SendAnswer()
|
||||||
{
|
{
|
||||||
if( !cur.request->info_serializer )
|
|
||||||
{
|
|
||||||
json_generic_serializer.Clear(); // !! IMPROVE ME add to the end of a request
|
|
||||||
cur.request->info_serializer = &json_generic_serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cur.request->return_json )
|
if( cur.request->return_json )
|
||||||
PrepareStandardJSONFields();
|
PrepareStandardJSONFields();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -54,7 +54,6 @@
|
||||||
#include "cookieparser.h"
|
#include "cookieparser.h"
|
||||||
#include "postmultiparser.h"
|
#include "postmultiparser.h"
|
||||||
#include "acceptencodingparser.h"
|
#include "acceptencodingparser.h"
|
||||||
#include "space/jsontospaceparser.h"
|
|
||||||
|
|
||||||
#include "winixrequest.h"
|
#include "winixrequest.h"
|
||||||
#include "log/log.h"
|
#include "log/log.h"
|
||||||
|
@ -144,7 +143,7 @@ private:
|
||||||
|
|
||||||
PostParser post_parser;
|
PostParser post_parser;
|
||||||
PostMultiParser post_multi_parser;
|
PostMultiParser post_multi_parser;
|
||||||
PT::JSONToSpaceParser post_json_parser;
|
PT::SpaceParser space_parser;
|
||||||
std::string post_buffer;
|
std::string post_buffer;
|
||||||
|
|
||||||
CookieParser cookie_parser;
|
CookieParser cookie_parser;
|
||||||
|
@ -156,14 +155,14 @@ private:
|
||||||
pthread_t signal_thread;
|
pthread_t signal_thread;
|
||||||
std::string socket_to_send_on_exit;
|
std::string socket_to_send_on_exit;
|
||||||
std::string send_data_buf;
|
std::string send_data_buf;
|
||||||
PT::SpaceToJSON json_generic_serializer;
|
|
||||||
TextStream<std::wstring> json_out_stream;
|
TextStream<std::wstring> json_out_stream;
|
||||||
std::string aheader_name, aheader_value;
|
std::string aheader_name, aheader_value;
|
||||||
std::wstring html_filtered;
|
std::wstring html_filtered;
|
||||||
std::string output_8bit;
|
std::string output_8bit;
|
||||||
BinaryPage compressed_output;
|
BinaryPage compressed_output;
|
||||||
std::wstring cookie_id_string;
|
std::wstring cookie_id_string;
|
||||||
std::wstring http_header;
|
std::wstring http_header_name;
|
||||||
|
std::wstring http_header_value;
|
||||||
std::string http_header_8bit;
|
std::string http_header_8bit;
|
||||||
|
|
||||||
morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector
|
morm::ModelConnector model_connector; // main thread model connector, each thread has its own connector
|
||||||
|
|
|
@ -83,9 +83,9 @@ void Config::ShowError()
|
||||||
|
|
||||||
case PT::SpaceParser::syntax_error:
|
case PT::SpaceParser::syntax_error:
|
||||||
if( errors_to_stdout )
|
if( errors_to_stdout )
|
||||||
std::wcout << "Config: syntax error, line: " << parser.line << std::endl;
|
std::wcout << "Config: syntax error, line: " << parser.get_last_parsed_line() << std::endl;
|
||||||
|
|
||||||
log << log1 << "Config: syntax error, line: " << parser.line << logend;
|
log << log1 << "Config: syntax error, line: " << parser.get_last_parsed_line() << logend;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ bool Config::ReadConfig(bool errors_to_stdout_, bool stdout_is_closed)
|
||||||
log << log2 << "Config: reading a config file" << logend;
|
log << log2 << "Config: reading a config file" << logend;
|
||||||
|
|
||||||
parser.SetSpace(space);
|
parser.SetSpace(space);
|
||||||
PT::SpaceParser::Status status = parser.Parse(config_file);
|
PT::SpaceParser::Status status = parser.ParseSpaceFile(config_file);
|
||||||
|
|
||||||
if( status == PT::SpaceParser::ok )
|
if( status == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
|
@ -382,150 +382,112 @@ void Config::CheckPasswd()
|
||||||
|
|
||||||
std::wstring Config::Text(const wchar_t * name)
|
std::wstring Config::Text(const wchar_t * name)
|
||||||
{
|
{
|
||||||
return space.Text(name);
|
return space.to_wstr(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::wstring Config::Text(const wchar_t * name, const wchar_t * def)
|
std::wstring Config::Text(const wchar_t * name, const wchar_t * def)
|
||||||
{
|
{
|
||||||
return space.Text(name, def);
|
return space.to_wstr(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::wstring Config::Text(const std::wstring & name, const wchar_t * def)
|
std::wstring Config::Text(const std::wstring & name, const wchar_t * def)
|
||||||
{
|
{
|
||||||
return space.Text(name, def);
|
return space.to_wstr(name, def);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::wstring & Config::TextRef(const wchar_t * name)
|
|
||||||
{
|
|
||||||
return space.TextRef(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::wstring & Config::TextRef(const wchar_t * name, const wchar_t * def)
|
|
||||||
{
|
|
||||||
return space.TextRef(name, def);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::wstring & Config::TextRef(const std::wstring & name, const wchar_t * def)
|
|
||||||
{
|
|
||||||
return space.TextRef(name, def);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const wchar_t * name)
|
int Config::Int(const wchar_t * name)
|
||||||
{
|
{
|
||||||
return space.Int(name);
|
return space.to_int(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const wchar_t * name, int def)
|
int Config::Int(const wchar_t * name, int def)
|
||||||
{
|
{
|
||||||
return space.Int(name, def);
|
return space.to_int(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Config::Int(const std::wstring & name, int def)
|
int Config::Int(const std::wstring & name, int def)
|
||||||
{
|
{
|
||||||
return space.Int(name, def);
|
return space.to_int(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long Config::Long(const wchar_t * name)
|
long Config::Long(const wchar_t * name)
|
||||||
{
|
{
|
||||||
return space.Long(name);
|
return space.to_long(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
long Config::Long(const wchar_t * name, long def)
|
long Config::Long(const wchar_t * name, long def)
|
||||||
{
|
{
|
||||||
return space.Long(name, def);
|
return space.to_long(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
long Config::Long(const std::wstring & name, long def)
|
long Config::Long(const std::wstring & name, long def)
|
||||||
{
|
{
|
||||||
return space.Long(name, def);
|
return space.to_long(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t Config::Size(const wchar_t * name)
|
size_t Config::Size(const wchar_t * name)
|
||||||
{
|
{
|
||||||
return space.Size(name);
|
return space.to_ulong(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t Config::Size(const wchar_t * name, size_t def)
|
size_t Config::Size(const wchar_t * name, size_t def)
|
||||||
{
|
{
|
||||||
return space.Size(name, def);
|
return space.to_ulong(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t Config::Size(const std::wstring & name, size_t def)
|
size_t Config::Size(const std::wstring & name, size_t def)
|
||||||
{
|
{
|
||||||
return space.Size(name, def);
|
return space.to_ulong(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const wchar_t * name)
|
bool Config::Bool(const wchar_t * name)
|
||||||
{
|
{
|
||||||
return space.Bool(name);
|
return space.to_bool(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const wchar_t * name, bool def)
|
bool Config::Bool(const wchar_t * name, bool def)
|
||||||
{
|
{
|
||||||
return space.Bool(name, def);
|
return space.to_bool(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Config::Bool(const std::wstring & name, bool def)
|
bool Config::Bool(const std::wstring & name, bool def)
|
||||||
{
|
{
|
||||||
return space.Bool(name, def);
|
return space.to_bool(name, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
bool Config::ListText(const wchar_t * name, std::vector<std::wstring> & list)
|
||||||
{
|
{
|
||||||
return space.ListText(name, list);
|
return space.to_list(name, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
bool Config::ListText(const std::wstring & name, std::vector<std::wstring> & list)
|
||||||
{
|
{
|
||||||
return space.ListText(name, list);
|
return space.to_list(name, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Config::HasValue(const wchar_t * name, const wchar_t * value)
|
|
||||||
{
|
|
||||||
return space.HasValue(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Config::HasValue(const wchar_t * name, const std::wstring & value)
|
//void Config::Print(std::wostream & out)
|
||||||
{
|
//{
|
||||||
return space.HasValue(name, value);
|
// space.serialize_to_space_stream(out);
|
||||||
}
|
//}
|
||||||
|
|
||||||
bool Config::HasValue(const std::wstring & name, const wchar_t * value)
|
|
||||||
{
|
|
||||||
return space.HasValue(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Config::HasValue(const std::wstring & name, const std::wstring & value)
|
|
||||||
{
|
|
||||||
return space.HasValue(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Config::Print(std::wostream & out)
|
|
||||||
{
|
|
||||||
space.Serialize(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -619,6 +619,7 @@ public:
|
||||||
// 2 - application/xml - for XHTML 1.0 or for XHTML 1.1
|
// 2 - application/xml - for XHTML 1.0 or for XHTML 1.1
|
||||||
// default: 0
|
// default: 0
|
||||||
// if utf8 is true then "; charset=UTF-8" will also be appended
|
// if utf8 is true then "; charset=UTF-8" will also be appended
|
||||||
|
// may it would be better to set just the string here instead of integers?
|
||||||
int content_type_header;
|
int content_type_header;
|
||||||
|
|
||||||
// global umask
|
// global umask
|
||||||
|
@ -793,10 +794,6 @@ public:
|
||||||
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
std::wstring Text(const wchar_t * name, const wchar_t * def);
|
||||||
std::wstring Text(const std::wstring & name, const wchar_t * def);
|
std::wstring Text(const std::wstring & name, const wchar_t * def);
|
||||||
|
|
||||||
std::wstring & TextRef(const wchar_t * name);
|
|
||||||
std::wstring & TextRef(const wchar_t * name, const wchar_t * def);
|
|
||||||
std::wstring & TextRef(const std::wstring & name, const wchar_t * def);
|
|
||||||
|
|
||||||
int Int(const wchar_t *);
|
int Int(const wchar_t *);
|
||||||
int Int(const wchar_t * name, int def);
|
int Int(const wchar_t * name, int def);
|
||||||
int Int(const std::wstring & name, int def);
|
int Int(const std::wstring & name, int def);
|
||||||
|
@ -812,13 +809,8 @@ public:
|
||||||
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
bool ListText(const wchar_t * name, std::vector<std::wstring> & list);
|
||||||
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
bool ListText(const std::wstring & name, std::vector<std::wstring> & list);
|
||||||
|
|
||||||
bool HasValue(const wchar_t * name, const wchar_t * value);
|
|
||||||
bool HasValue(const wchar_t * name, const std::wstring & value);
|
|
||||||
bool HasValue(const std::wstring & name, const wchar_t * value);
|
|
||||||
bool HasValue(const std::wstring & name, const std::wstring & value);
|
|
||||||
|
|
||||||
// for debug
|
// for debug
|
||||||
void Print(std::wostream & out);
|
//void Print(std::wostream & out);
|
||||||
|
|
||||||
// raw access to the config
|
// raw access to the config
|
||||||
PT::Space space;
|
PT::Space space;
|
||||||
|
|
|
@ -214,6 +214,14 @@ bool Plugin::SetDependency(PluginInfo & info)
|
||||||
info.session_manager = session_manager;
|
info.session_manager = session_manager;
|
||||||
info.plugin = this;
|
info.plugin = this;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME
|
||||||
|
* if we call a message from a different thread then a different model connector is needed
|
||||||
|
* (each thread should have its own model connector)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
info.model_connector = system->get_model_connector();
|
||||||
|
|
||||||
info.log.SetDependency(&log);
|
info.log.SetDependency(&log);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -93,15 +93,15 @@ void Request::Clear()
|
||||||
post_tab.clear();
|
post_tab.clear();
|
||||||
post_file_tab.clear();
|
post_file_tab.clear();
|
||||||
cookie_tab.clear();
|
cookie_tab.clear();
|
||||||
post_in.Clear();
|
post_in.clear();
|
||||||
is_postin_used = false;
|
is_postin_used = false;
|
||||||
|
|
||||||
method = unknown_method;
|
method = unknown_method;
|
||||||
|
|
||||||
headers_in.Clear();
|
headers_in.clear();
|
||||||
|
|
||||||
out_headers.Clear();
|
out_headers.clear();
|
||||||
out_cookies.Clear();
|
out_cookies.clear();
|
||||||
|
|
||||||
page_generated = false;
|
page_generated = false;
|
||||||
|
|
||||||
|
@ -117,6 +117,7 @@ void Request::Clear()
|
||||||
|
|
||||||
item_tab.clear();
|
item_tab.clear();
|
||||||
item.Clear();
|
item.Clear();
|
||||||
|
item.set_connector(nullptr);
|
||||||
dir_tab.clear();
|
dir_tab.clear();
|
||||||
last_item = &item;
|
last_item = &item;
|
||||||
is_item = false;
|
is_item = false;
|
||||||
|
@ -139,8 +140,7 @@ void Request::Clear()
|
||||||
|
|
||||||
subdomain.clear();
|
subdomain.clear();
|
||||||
return_info_only = false;
|
return_info_only = false;
|
||||||
info.Clear();
|
info.clear();
|
||||||
info_serializer = 0;
|
|
||||||
return_json = false;
|
return_json = false;
|
||||||
|
|
||||||
out_bin_stream.clear();
|
out_bin_stream.clear();
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include "templates/htmltextstream.h"
|
#include "templates/htmltextstream.h"
|
||||||
#include "date/date.h"
|
#include "date/date.h"
|
||||||
#include "space/space.h"
|
#include "space/space.h"
|
||||||
#include "space/spacetojson.h"
|
|
||||||
#include "textstream/textstream.h"
|
#include "textstream/textstream.h"
|
||||||
#include "outstreams.h"
|
#include "outstreams.h"
|
||||||
|
|
||||||
|
@ -308,11 +307,6 @@ struct Request
|
||||||
// additional info added when sending the JSON answer
|
// additional info added when sending the JSON answer
|
||||||
PT::Space info;
|
PT::Space info;
|
||||||
|
|
||||||
// info serializer
|
|
||||||
// if not set then the json_generic_serializer from App will be used
|
|
||||||
// default: null (json_generic_serializer used)
|
|
||||||
PT::SpaceToJSON * info_serializer;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,10 +386,10 @@ struct Request
|
||||||
// value - cookie value (can be everything which can be put to PT::WTextStream stream)
|
// value - cookie value (can be everything which can be put to PT::WTextStream stream)
|
||||||
// the return std::wstring reference is a reference to the cookie inserted value (in out_cookies structure)
|
// the return std::wstring reference is a reference to the cookie inserted value (in out_cookies structure)
|
||||||
template<typename NameType, typename ValueType>
|
template<typename NameType, typename ValueType>
|
||||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date * expires = 0);
|
void AddCookie(const NameType & name, const ValueType & value, PT::Date * expires = 0);
|
||||||
|
|
||||||
template<typename NameType, typename ValueType>
|
template<typename NameType, typename ValueType>
|
||||||
std::wstring & AddCookie(const NameType & name, const ValueType & value, PT::Date & expires);
|
void AddCookie(const NameType & name, const ValueType & value, PT::Date & expires);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,9 +409,9 @@ private:
|
||||||
|
|
||||||
|
|
||||||
template<typename NameType, typename ValueType>
|
template<typename NameType, typename ValueType>
|
||||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date * expires)
|
void Request::AddCookie(const NameType & name, const ValueType & value, PT::Date * expires)
|
||||||
{
|
{
|
||||||
PT::WTextStream cookie;
|
PT::WTextStream cookie;
|
||||||
|
|
||||||
cookie << value;
|
cookie << value;
|
||||||
|
|
||||||
|
@ -439,14 +433,14 @@ PT::WTextStream cookie;
|
||||||
will be lost (the session cookie will be overwritten in the client's browser)
|
will be lost (the session cookie will be overwritten in the client's browser)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return out_cookies.Add(name, cookie);
|
out_cookies.add_stream(name, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename NameType, typename ValueType>
|
template<typename NameType, typename ValueType>
|
||||||
std::wstring & Request::AddCookie(const NameType & name, const ValueType & value, PT::Date & expires)
|
void Request::AddCookie(const NameType & name, const ValueType & value, PT::Date & expires)
|
||||||
{
|
{
|
||||||
return AddCookie(name, value, &expires);
|
AddCookie(name, value, &expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-2018, Tomasz Sowa
|
* Copyright (c) 2014-2021, 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,7 @@ void SessionIdManager::ReadKey(const wchar_t * name, PT::Space & space, std::vec
|
||||||
std::vector<std::wstring> keys;
|
std::vector<std::wstring> keys;
|
||||||
std::string key_ascii, key_base64_decoded;
|
std::string key_ascii, key_base64_decoded;
|
||||||
|
|
||||||
space.ListText(name, keys);
|
space.to_list(name, keys);
|
||||||
|
|
||||||
for(size_t i=0 ; i<key_tab_size ; ++i)
|
for(size_t i=0 ; i<key_tab_size ; ++i)
|
||||||
dest_key[i].clear();
|
dest_key[i].clear();
|
||||||
|
@ -145,16 +145,16 @@ PT::SpaceParser parser;
|
||||||
PT::Date date;
|
PT::Date date;
|
||||||
|
|
||||||
parser.SetSpace(space);
|
parser.SetSpace(space);
|
||||||
PT::SpaceParser::Status status = parser.Parse(file);
|
PT::SpaceParser::Status status = parser.ParseSpaceFile(file);
|
||||||
|
|
||||||
if( status == PT::SpaceParser::ok )
|
if( status == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
key_index = space.Size(L"key_index");
|
key_index = space.to_ulong(L"key_index");
|
||||||
|
|
||||||
if( key_index >= 256 )
|
if( key_index >= 256 )
|
||||||
key_index = 0;
|
key_index = 0;
|
||||||
|
|
||||||
if( date.Parse(space.Text(L"last_key_generated", L"0")) )
|
if( date.Parse(space.to_wstr(L"last_key_generated", L"0")) )
|
||||||
last_key_generated = date.ToTime();
|
last_key_generated = date.ToTime();
|
||||||
|
|
||||||
ReadKey(L"key_tab1", space, key_tab1);
|
ReadKey(L"key_tab1", space, key_tab1);
|
||||||
|
|
|
@ -755,7 +755,7 @@ int System::NewPrivileges(int creation_mask)
|
||||||
{
|
{
|
||||||
if( cur && cur->session && cur->session->puser )
|
if( cur && cur->session && cur->session->puser )
|
||||||
{
|
{
|
||||||
int umask = cur->session->puser->env.Int(L"umask", config->umask);
|
int umask = cur->session->puser->env.to_int(L"umask", config->umask);
|
||||||
return (~umask) & creation_mask;
|
return (~umask) & creation_mask;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -109,6 +109,8 @@ public:
|
||||||
TimeZones time_zones;
|
TimeZones time_zones;
|
||||||
|
|
||||||
|
|
||||||
|
using WinixModel::get_model_connector;
|
||||||
|
|
||||||
void SetCur(Cur * pcur);
|
void SetCur(Cur * pcur);
|
||||||
//void SetConfig(Config * pconfig);
|
//void SetConfig(Config * pconfig);
|
||||||
void SetDb(Db * pdb);
|
void SetDb(Db * pdb);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -398,7 +398,7 @@ TextStream<StringType> & TextStream<StringType>::write(const wchar_t * buf, size
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
TextStream<StringType> & TextStream<StringType>::operator<<(const PT::Space & space)
|
TextStream<StringType> & TextStream<StringType>::operator<<(const PT::Space & space)
|
||||||
{
|
{
|
||||||
space.Serialize(*this, true, false);
|
space.serialize_to_space_stream(*this, true);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,16 +181,17 @@ void ThreadManager::StopAll()
|
||||||
for(ThreadItem & item : thread_tab)
|
for(ThreadItem & item : thread_tab)
|
||||||
{
|
{
|
||||||
log << log4 << "TM: waiting for thread " << id << " (" << item.object->ThreadId()
|
log << log4 << "TM: waiting for thread " << id << " (" << item.object->ThreadId()
|
||||||
<< ", name: " << item.name << ")" << logend;
|
<< ", name: " << item.name << ")" << logend << logsave;
|
||||||
|
|
||||||
item.object->WaitForThread();
|
item.object->WaitForThread();
|
||||||
log << log4 << "TM: thread " << id << " terminated" << logend;
|
log << log4 << "TM: thread " << id << " terminated" << logend << logsave;
|
||||||
|
|
||||||
// the thread is stopped and we can set the thread log buffer pointing to
|
// the thread is stopped and we can set the thread log buffer pointing to
|
||||||
// the main log buffer (from the main thread)
|
// the main log buffer (from the main thread)
|
||||||
item.object->set_log_buffer(log.GetLogBuffer());
|
item.object->set_log_buffer(log.GetLogBuffer());
|
||||||
|
|
||||||
delete item.thread_item_data;
|
delete item.thread_item_data;
|
||||||
|
item.thread_item_data = nullptr;
|
||||||
id += 1;
|
id += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -242,12 +242,12 @@ return offset;
|
||||||
|
|
||||||
time_t TimeZone::GetOffset(PT::Space & space)
|
time_t TimeZone::GetOffset(PT::Space & space)
|
||||||
{
|
{
|
||||||
std::wstring * offset_str = space.GetFirstValue(L"offset_str");
|
std::wstring * offset_str = space.get_wstr(L"offset_str");
|
||||||
|
|
||||||
if( offset_str )
|
if( offset_str )
|
||||||
return ParseStrOffset(offset_str->c_str());
|
return ParseStrOffset(offset_str->c_str());
|
||||||
|
|
||||||
return space.Long(L"offset");
|
return space.to_long(L"offset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,22 +257,25 @@ bool TimeZone::SetTzDst(PT::Space & year)
|
||||||
bool result = true;
|
bool result = true;
|
||||||
Dst dst;
|
Dst dst;
|
||||||
|
|
||||||
int year_int = Toi(year.name);
|
int year_int = 0;
|
||||||
|
|
||||||
|
if( year.name )
|
||||||
|
year_int = Toi(*year.name);
|
||||||
|
|
||||||
if( year_int < 1970 || year_int > 10000 )
|
if( year_int < 1970 || year_int > 10000 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dst.has_dst = year.Bool(L"has_dst", false);
|
dst.has_dst = year.to_bool(L"has_dst", false);
|
||||||
|
|
||||||
if( dst.has_dst )
|
if( dst.has_dst )
|
||||||
{
|
{
|
||||||
dst.start.year = year_int;
|
dst.start.year = year_int;
|
||||||
dst.end.year = year_int;
|
dst.end.year = year_int;
|
||||||
|
|
||||||
if( !dst.start.ParseMonthDayTime(year.Text(L"start")) )
|
if( !dst.start.ParseMonthDayTime(year.to_wstr(L"start")) )
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
if( !dst.end.ParseMonthDayTime(year.Text(L"end")) )
|
if( !dst.end.ParseMonthDayTime(year.to_wstr(L"end")) )
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
dst.offset = GetOffset(year);
|
dst.offset = GetOffset(year);
|
||||||
|
@ -291,24 +294,31 @@ return result;
|
||||||
bool TimeZone::SetTz(PT::Space & space)
|
bool TimeZone::SetTz(PT::Space & space)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
name = space.name;
|
name.clear();
|
||||||
id = space.Int(L"id", -1);
|
|
||||||
|
if( space.name )
|
||||||
|
name = *space.name;
|
||||||
|
|
||||||
|
id = space.to_int(L"id", -1);
|
||||||
offset = GetOffset(space);
|
offset = GetOffset(space);
|
||||||
time_t h24 = 60 * 60 * 24; // 24 hours
|
time_t h24 = 60 * 60 * 24; // 24 hours
|
||||||
|
|
||||||
if( offset < -h24 || offset > h24 )
|
if( offset < -h24 || offset > h24 )
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
PT::Space & dst = space.FindAddSpace(L"dst");
|
PT::Space * dst = space.find_child_space(L"dst");
|
||||||
|
|
||||||
for(size_t i=0 ; i<dst.spaces.size() ; ++i)
|
if( dst && dst->child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & year = *dst.spaces[i];
|
for(size_t i=0 ; i<dst->child_spaces->size() ; ++i)
|
||||||
|
|
||||||
if( !SetTzDst(year) )
|
|
||||||
{
|
{
|
||||||
result = false;
|
PT::Space & year = *(*dst->child_spaces)[i];
|
||||||
break;
|
|
||||||
|
if( !SetTzDst(year) )
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -123,37 +123,40 @@ bool TimeZones::Empty() const
|
||||||
|
|
||||||
void TimeZones::ParseZones()
|
void TimeZones::ParseZones()
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<temp_space.spaces.size() ; ++i)
|
if( temp_space.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & zone = *temp_space.spaces[i];
|
for(size_t i=0 ; i<temp_space.child_spaces->size() ; ++i)
|
||||||
temp_zone.Clear();
|
|
||||||
|
|
||||||
if( temp_zone.SetTz(zone) )
|
|
||||||
{
|
{
|
||||||
if( !HasZone(temp_zone.id) )
|
PT::Space & zone = *((*temp_space.child_spaces)[i]);
|
||||||
|
temp_zone.Clear();
|
||||||
|
|
||||||
|
if( temp_zone.SetTz(zone) )
|
||||||
{
|
{
|
||||||
if( temp_zone.id < zone_indices.size() )
|
if( !HasZone(temp_zone.id) )
|
||||||
{
|
{
|
||||||
zone_tab.push_back(temp_zone);
|
if( temp_zone.id < zone_indices.size() )
|
||||||
zone_indices[temp_zone.id] = zone_tab.size() - 1;
|
{
|
||||||
|
zone_tab.push_back(temp_zone);
|
||||||
|
zone_indices[temp_zone.id] = zone_tab.size() - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log1 << "Tz: zone: " << temp_zone.name << " has too big id: "
|
||||||
|
<< temp_zone.id << " (skipping)" << logend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log1 << "Tz: zone: " << temp_zone.name << " has too big id: "
|
log << log1 << "Tz: zone with id: " << temp_zone.id
|
||||||
<< temp_zone.id << " (skipping)" << logend;
|
<< " already exists (skipping)" << logend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log1 << "Tz: zone with id: " << temp_zone.id
|
log << log1 << "System: problem with reading time zone info from time zone: "
|
||||||
<< " already exists (skipping)" << logend;
|
<< zone.name << " (skipping) " << logend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "System: problem with reading time zone info from time zone: "
|
|
||||||
<< zone.name << " (skipping) " << logend;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +169,9 @@ bool TimeZones::ReadTimeZones(const wchar_t * path)
|
||||||
{
|
{
|
||||||
parser.SetSpace(temp_space);
|
parser.SetSpace(temp_space);
|
||||||
zone_tab.clear();
|
zone_tab.clear();
|
||||||
temp_space.Clear();
|
temp_space.clear();
|
||||||
|
|
||||||
PT::SpaceParser::Status status = parser.Parse(path);
|
PT::SpaceParser::Status status = parser.ParseSpaceFile(path);
|
||||||
|
|
||||||
if( status == PT::SpaceParser::ok )
|
if( status == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
|
@ -178,7 +181,7 @@ bool TimeZones::ReadTimeZones(const wchar_t * path)
|
||||||
else
|
else
|
||||||
if( status == PT::SpaceParser::syntax_error )
|
if( status == PT::SpaceParser::syntax_error )
|
||||||
{
|
{
|
||||||
log << log1 << "TZ: error in time zone file, line: " << parser.line << logend;
|
log << log1 << "TZ: error in time zone file, line: " << parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( status == PT::SpaceParser::cant_open_file )
|
if( status == PT::SpaceParser::cant_open_file )
|
||||||
|
@ -186,7 +189,7 @@ bool TimeZones::ReadTimeZones(const wchar_t * path)
|
||||||
log << log1 << "TZ: I cannot open the time zone file: " << path << logend;
|
log << log1 << "TZ: I cannot open the time zone file: " << path << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_space.Clear();
|
temp_space.clear();
|
||||||
|
|
||||||
return status == PT::SpaceParser::ok;
|
return status == PT::SpaceParser::ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -54,8 +54,8 @@ void User::Clear()
|
||||||
groups.clear();
|
groups.clear();
|
||||||
email.clear();
|
email.clear();
|
||||||
notify = 0;
|
notify = 0;
|
||||||
env.Clear();
|
env.clear();
|
||||||
aenv.Clear();
|
aenv.clear();
|
||||||
status = WINIX_ACCOUNT_BLOCKED;
|
status = WINIX_ACCOUNT_BLOCKED;
|
||||||
locale_id = 0;
|
locale_id = 0;
|
||||||
time_zone_id = 0;
|
time_zone_id = 0;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -260,20 +260,20 @@ bool DbBase::AssertValueSpace(PGresult * r, int row, int col, PT::Space & space)
|
||||||
const char * res = AssertValue(r, row, col);
|
const char * res = AssertValue(r, row, col);
|
||||||
|
|
||||||
conf_parser.SetSpace(space);
|
conf_parser.SetSpace(space);
|
||||||
space.Clear();
|
space.clear();
|
||||||
|
|
||||||
PT::SpaceParser::Status status = conf_parser.ParseString(res);
|
PT::SpaceParser::Status status = conf_parser.ParseSpace(res);
|
||||||
|
|
||||||
if( status != PT::SpaceParser::ok )
|
if( status != PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
log << log1 << "Db: a problem with parsing a PT::Space";
|
log << log1 << "Db: a problem with parsing a PT::Space";
|
||||||
|
|
||||||
if( status == PT::SpaceParser::syntax_error )
|
if( status == PT::SpaceParser::syntax_error )
|
||||||
log << ", syntax error at line: " << conf_parser.line;
|
log << ", syntax error at line: " << conf_parser.get_last_parsed_line();
|
||||||
|
|
||||||
log << logend;
|
log << logend;
|
||||||
|
|
||||||
space.Clear();
|
space.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2014, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -589,7 +589,7 @@ DbTextStream & DbTextStream::operator<<(const PT::Space & space)
|
||||||
tmp_stream.Clear();
|
tmp_stream.Clear();
|
||||||
// !! IMPROVE ME
|
// !! IMPROVE ME
|
||||||
// we can calculate how much memory is needed before serializing
|
// we can calculate how much memory is needed before serializing
|
||||||
space.Serialize(tmp_stream, true, false);
|
space.serialize_to_space_stream(tmp_stream, true);
|
||||||
operator<<(tmp_stream.Str());
|
operator<<(tmp_stream.Str());
|
||||||
tmp_stream.Clear();
|
tmp_stream.Clear();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2018, Tomasz Sowa
|
* Copyright (c) 2013-2021, 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
|
||||||
|
@ -55,7 +55,7 @@ Account::Account()
|
||||||
|
|
||||||
bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||||
{
|
{
|
||||||
std::wstring * user_code_str = puser->aenv.GetFirstValue(L"activation_code");
|
std::wstring * user_code_str = puser->aenv.get_wstr(L"activation_code");
|
||||||
|
|
||||||
if( user_code_str )
|
if( user_code_str )
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ bool Account::ActivateAccount(User * puser, long code, bool use_ses_log)
|
||||||
{
|
{
|
||||||
if( db->ChangeUserStatus(puser->id, WINIX_ACCOUNT_READY) == WINIX_ERR_OK )
|
if( db->ChangeUserStatus(puser->id, WINIX_ACCOUNT_READY) == WINIX_ERR_OK )
|
||||||
{
|
{
|
||||||
puser->aenv.Remove(L"activation_code");
|
puser->aenv.remove(L"activation_code");
|
||||||
db->ChangeUserAdminEnv(puser->id, puser->aenv);
|
db->ChangeUserAdminEnv(puser->id, puser->aenv);
|
||||||
puser->status = WINIX_ACCOUNT_READY;
|
puser->status = WINIX_ACCOUNT_READY;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
* Copyright (c) 2008-2021, 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
|
||||||
|
@ -229,7 +229,7 @@ bool AddUser::AddNewUser(const std::wstring & login,
|
||||||
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
if( user.status == WINIX_ACCOUNT_NOT_ACTIVATED )
|
||||||
{
|
{
|
||||||
code = std::rand();
|
code = std::rand();
|
||||||
user.aenv.Add(L"activation_code", code);
|
user.aenv.add(L"activation_code", code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( AddNewUser(user, pass) )
|
if( AddNewUser(user, pass) )
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -74,10 +74,10 @@ return true;
|
||||||
|
|
||||||
bool Env::Parse(const std::wstring & env_str)
|
bool Env::Parse(const std::wstring & env_str)
|
||||||
{
|
{
|
||||||
space.Clear();
|
space.clear();
|
||||||
conf_parser.SetSpace(space);
|
conf_parser.SetSpace(space);
|
||||||
|
|
||||||
return (conf_parser.ParseString(env_str) == PT::SpaceParser::ok);
|
return (conf_parser.ParseSpace(env_str) == PT::SpaceParser::ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,10 +102,10 @@ bool Env::EditAdminEnv(long user_id, const std::wstring & env_str, bool use_ses_
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
log << log2 << "Env: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
|
|
||||||
if( use_ses_log )
|
if( use_ses_log )
|
||||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,10 +133,10 @@ bool Env::EditEnv(long user_id, const std::wstring & env_str, bool use_ses_log)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log2 << "Env: Syntax error in line: " << conf_parser.line << logend;
|
log << log2 << "Env: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
|
|
||||||
if( use_ses_log )
|
if( use_ses_log )
|
||||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -62,10 +62,10 @@ bool Meta::HasAccess()
|
||||||
|
|
||||||
bool Meta::Parse(const std::wstring & meta_str)
|
bool Meta::Parse(const std::wstring & meta_str)
|
||||||
{
|
{
|
||||||
space.Clear();
|
space.clear();
|
||||||
conf_parser.SetSpace(space);
|
conf_parser.SetSpace(space);
|
||||||
|
|
||||||
return (conf_parser.ParseString(meta_str) == PT::SpaceParser::ok);
|
return (conf_parser.ParseSpace(meta_str) == PT::SpaceParser::ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,10 +91,10 @@ bool Meta::EditAdminMeta(Item & item, const std::wstring & meta_str, bool use_se
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
|
log << log2 << "Meta: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
|
|
||||||
if( use_ses_log )
|
if( use_ses_log )
|
||||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -122,10 +122,10 @@ bool Meta::EditMeta(Item & item, const std::wstring & meta_str, bool use_ses_log
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log << log2 << "Meta: Syntax error in line: " << conf_parser.line << logend;
|
log << log2 << "Meta: Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
|
|
||||||
if( use_ses_log )
|
if( use_ses_log )
|
||||||
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.line << logend;
|
slog << logerror << T("syntax_error_in_line") << ' ' << conf_parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
* Copyright (c) 2011-2021, 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
|
||||||
|
@ -189,7 +189,7 @@ return result;
|
||||||
|
|
||||||
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
|
bool Passwd::ResetPassword(User * puser, long code, bool use_ses_log, bool only_check_access)
|
||||||
{
|
{
|
||||||
std::wstring * user_code_str = puser->aenv.GetFirstValue(L"password_change_code");
|
std::wstring * user_code_str = puser->aenv.get_wstr(L"password_change_code");
|
||||||
|
|
||||||
if( user_code_str )
|
if( user_code_str )
|
||||||
{
|
{
|
||||||
|
@ -229,7 +229,7 @@ bool Passwd::ResetPassword(const std::wstring & login, long code, bool use_ses_l
|
||||||
{
|
{
|
||||||
long t = static_cast<long>(cur->request->start_time);
|
long t = static_cast<long>(cur->request->start_time);
|
||||||
|
|
||||||
if( puser->aenv.Long(L"password_change_time") + config->reset_password_code_expiration_time > t )
|
if( puser->aenv.to_long(L"password_change_time") + config->reset_password_code_expiration_time > t )
|
||||||
{
|
{
|
||||||
result = ResetPassword(puser, code, use_ses_log, only_check_access);
|
result = ResetPassword(puser, code, use_ses_log, only_check_access);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,6 @@ Upload::Upload()
|
||||||
|
|
||||||
void Upload::Init()
|
void Upload::Init()
|
||||||
{
|
{
|
||||||
json_serializer.TreatAsTable(L"files");
|
|
||||||
json_serializer.TreatAsNumeric(L"size");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,9 +144,10 @@ void Upload::CreateThumb(Item & item)
|
||||||
void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||||
{
|
{
|
||||||
// we should add the file beforehand to get the proper item.id
|
// we should add the file beforehand to get the proper item.id
|
||||||
cur->request->status = system->AddFile(item, 0, false);
|
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||||
|
bool status = system->AddFile(item, 0, false);
|
||||||
|
|
||||||
if( cur->request->status == WINIX_ERR_OK )
|
if( status )
|
||||||
{
|
{
|
||||||
if( system->CreateNewFile(item) )
|
if( system->CreateNewFile(item) )
|
||||||
{
|
{
|
||||||
|
@ -160,6 +159,7 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||||
//cur->request->status = db->EditFileById(item, item.id);
|
//cur->request->status = db->EditFileById(item, item.id);
|
||||||
if( item.update(item_model_data) )
|
if( item.update(item_model_data) )
|
||||||
{
|
{
|
||||||
|
cur->request->status = WINIX_ERR_OK;
|
||||||
plugin->Call(WINIX_FILE_ADDED, &item);
|
plugin->Call(WINIX_FILE_ADDED, &item);
|
||||||
|
|
||||||
if( item.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
if( item.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||||
|
@ -174,10 +174,6 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||||
if( is_jquery_upload )
|
if( is_jquery_upload )
|
||||||
cur->request->item_tab.push_back(item);
|
cur->request->item_tab.push_back(item);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -246,6 +242,8 @@ void Upload::UploadMulti()
|
||||||
|
|
||||||
void Upload::UploadSingle()
|
void Upload::UploadSingle()
|
||||||
{
|
{
|
||||||
|
cur->request->item.Clear(); // clearing and setting date
|
||||||
|
|
||||||
const std::wstring & new_subject = cur->request->PostVar(L"subject");
|
const std::wstring & new_subject = cur->request->PostVar(L"subject");
|
||||||
const std::wstring & new_url = cur->request->PostVar(L"url");
|
const std::wstring & new_url = cur->request->PostVar(L"url");
|
||||||
bool has_subject = !new_subject.empty();
|
bool has_subject = !new_subject.empty();
|
||||||
|
@ -308,29 +306,33 @@ void Upload::MakePost()
|
||||||
void Upload::CreateAnswer()
|
void Upload::CreateAnswer()
|
||||||
{
|
{
|
||||||
Request & req = *cur->request;
|
Request & req = *cur->request;
|
||||||
PT::Space & files = req.info.AddSpace(L"files"); // 'files' will be serialized to an array
|
PT::Space & files = req.info.add_empty_space(L"files");
|
||||||
|
|
||||||
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
|
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
|
||||||
{
|
{
|
||||||
PT::Space & file = files.AddSpace(L"");
|
PT::Space & file = files.add_empty_space();
|
||||||
|
|
||||||
file.Add(L"name", req.item_tab[i].url);
|
file.add(L"name", req.item_tab[i].url);
|
||||||
file.Add(L"size", req.item_tab[i].item_content.file_size);
|
file.add(L"size", req.item_tab[i].item_content.file_size);
|
||||||
|
|
||||||
std::wstring & link = file.Add(L"url", L"");
|
std::wstring link;
|
||||||
system->CreateItemLink(req.item_tab[i], link);
|
system->CreateItemLink(req.item_tab[i], link);
|
||||||
|
file.add(L"url", link);
|
||||||
|
|
||||||
std::wstring & del_url = file.Add(L"deleteUrl", link);
|
std::wstring delete_url = link;
|
||||||
del_url += L"/rm/jquery_upload";
|
delete_url += L"/rm/jquery_upload";
|
||||||
|
file.add(L"deleteUrl", delete_url);
|
||||||
|
|
||||||
file.Add(L"deleteType", L"POST");
|
file.add(L"deleteType", L"POST");
|
||||||
|
|
||||||
if( req.item_tab[i].item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
if( req.item_tab[i].item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||||
{
|
{
|
||||||
std::wstring & thumb = file.Add(L"thumbnailUrl", link);
|
std::wstring thumb = link;
|
||||||
|
|
||||||
if( req.item_tab[i].item_content.file_has_thumb )
|
if( req.item_tab[i].item_content.file_has_thumb )
|
||||||
thumb += L"/-/thumb";
|
thumb += L"/-/thumb";
|
||||||
|
|
||||||
|
file.add(L"thumbnailUrl", thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -341,10 +343,6 @@ void Upload::CreateAnswer()
|
||||||
|
|
||||||
cur->request->return_json = true;
|
cur->request->return_json = true;
|
||||||
cur->request->return_info_only = true;
|
cur->request->return_info_only = true;
|
||||||
cur->request->info_serializer = &json_serializer;
|
|
||||||
|
|
||||||
|
|
||||||
//cur->request->out_headers.Add(L"Content-Type", L"text/html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define headerfile_winix_functions_upload
|
#define headerfile_winix_functions_upload
|
||||||
|
|
||||||
#include "functionbase.h"
|
#include "functionbase.h"
|
||||||
#include "space/spacetojson.h"
|
|
||||||
|
|
||||||
namespace Winix
|
namespace Winix
|
||||||
{
|
{
|
||||||
|
@ -62,11 +62,6 @@ private:
|
||||||
//DbItemQuery query;
|
//DbItemQuery query;
|
||||||
bool is_jquery_upload;
|
bool is_jquery_upload;
|
||||||
|
|
||||||
// this object is used in App at the end of a request
|
|
||||||
// for serializing Request::info to JSON
|
|
||||||
// this will make a problem if in the future we'll use multithread requests
|
|
||||||
PT::SpaceToJSON json_serializer;
|
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
bool HasAccess(const Item & item);
|
bool HasAccess(const Item & item);
|
||||||
|
|
|
@ -229,7 +229,6 @@ meta_admin_for_page = Additional administrative information for page
|
||||||
|
|
||||||
mkdir_header = Make directory
|
mkdir_header = Make directory
|
||||||
|
|
||||||
html_lang_attr_value = "en"
|
|
||||||
language_orphans = ()
|
language_orphans = ()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -232,8 +232,6 @@ man_ezc_functions = Funkcje szablonów EZC
|
||||||
|
|
||||||
mkdir_header = Stwórz katalog
|
mkdir_header = Stwórz katalog
|
||||||
|
|
||||||
html_lang_attr_value = "pl"
|
|
||||||
|
|
||||||
# current limitation: winix is not allowed to convert polish capital letters to lower case
|
# current limitation: winix is not allowed to convert polish capital letters to lower case
|
||||||
# so we need to give both versions (small and capital letters)
|
# so we need to give both versions (small and capital letters)
|
||||||
language_orphans = ( "(np.", "a", "al.", "ale", "aż", "aŻ", "bo", "bp", "by", "co", "cz.", "czy", "dn.",
|
language_orphans = ( "(np.", "a", "al.", "ale", "aż", "aŻ", "bo", "bp", "by", "co", "cz.", "czy", "dn.",
|
||||||
|
|
|
@ -58,6 +58,11 @@ public:
|
||||||
field(L"item_id", item_id);
|
field(L"item_id", item_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepare_table()
|
||||||
|
{
|
||||||
|
table(L"core", L"item");
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,8 +143,8 @@ void ItemContent::Clear()
|
||||||
content_parsed.clear();
|
content_parsed.clear();
|
||||||
content_parsed_type = ct_formatted_text;
|
content_parsed_type = ct_formatted_text;
|
||||||
|
|
||||||
meta.Clear();
|
meta.clear();
|
||||||
meta_admin.Clear();
|
meta_admin.clear();
|
||||||
|
|
||||||
SetDateToNow();
|
SetDateToNow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,23 +330,27 @@ void ExportInfo::SendAllFilesFromDir(long dir_id)
|
||||||
|
|
||||||
void ExportInfo::AdditionalExport(const Item & item)
|
void ExportInfo::AdditionalExport(const Item & item)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<item.item_content.meta.spaces.size() ; ++i)
|
if( item.item_content.meta.child_spaces )
|
||||||
{
|
{
|
||||||
if( item.item_content.meta.spaces[i]->name == L"export" )
|
for(size_t i=0 ; i<item.item_content.meta.child_spaces->size() ; ++i)
|
||||||
AdditionalExport(item, *item.item_content.meta.spaces[i]);
|
{
|
||||||
|
PT::Space & child = *(*item.item_content.meta.child_spaces)[i];
|
||||||
|
|
||||||
|
if( child.name && *child.name == L"export" )
|
||||||
|
AdditionalExport(item, child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExportInfo::AdditionalExport(const Item & item, PT::Space & meta)
|
void ExportInfo::AdditionalExport(const Item & item, PT::Space & meta)
|
||||||
{
|
{
|
||||||
if( meta.ListText(L"additional_export", additional_export) )
|
meta.to_list(L"additional_export", additional_export);
|
||||||
|
|
||||||
|
for(size_t i=0 ; i<additional_export.size() ; ++i)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<additional_export.size() ; ++i)
|
log << log1 << "additional export: " << additional_export[i] << logend;
|
||||||
{
|
AdditionalExport(additional_export[i]);
|
||||||
log << log1 << "exportuje dodatkowo takiego swiniaka: " << additional_export[i] << logend;
|
|
||||||
AdditionalExport(additional_export[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ void gallery_tab_meta_str(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];
|
||||||
item.item_content.meta.Serialize(i.out, true, false);
|
item.item_content.meta.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,14 @@ bool GroupInfo::ParseGroups(const std::wstring & str, Groups & groups)
|
||||||
PT::Space & space = *groups.GetSpace();
|
PT::Space & space = *groups.GetSpace();
|
||||||
conf_parser.SetSpace(space);
|
conf_parser.SetSpace(space);
|
||||||
|
|
||||||
if( conf_parser.ParseString(str) == PT::SpaceParser::ok )
|
if( conf_parser.ParseSpace(str) == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
groups.Reindex();
|
groups.Reindex();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
slog << logerror << "Syntax error in line: " << conf_parser.line << logend;
|
slog << logerror << "Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
log << log1 << "Syntax error in line: " << conf_parser.line << logend;
|
log << log1 << "Syntax error in line: " << conf_parser.get_last_parsed_line() << logend;
|
||||||
groups.Clear();
|
groups.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2018, Tomasz Sowa
|
* Copyright (c) 2011-2021, 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
|
||||||
|
@ -59,21 +59,27 @@ void Groups::Reindex()
|
||||||
group_index_tab.clear();
|
group_index_tab.clear();
|
||||||
size_t seti = 0;
|
size_t seti = 0;
|
||||||
|
|
||||||
while( seti < space.spaces.size() )
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
const std::wstring & name = space.spaces[seti]->name;
|
while( seti < space.child_spaces->size() )
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*space.child_spaces)[seti];
|
||||||
|
|
||||||
if( set_index.find(name) == set_index.end() )
|
if( sp.name )
|
||||||
{
|
{
|
||||||
set_index[name] = seti;
|
if( set_index.find(*sp.name) == set_index.end() )
|
||||||
group_index_tab.push_back(GroupIndex());
|
{
|
||||||
ReindexGroups(group_index_tab.back(), *space.spaces[seti]);
|
set_index[*sp.name] = seti;
|
||||||
seti += 1;
|
group_index_tab.push_back(GroupIndex());
|
||||||
}
|
ReindexGroups(group_index_tab.back(), sp);
|
||||||
else
|
seti += 1;
|
||||||
{
|
}
|
||||||
slog << logerror << "set: " << name << " already defined (skipping)" << logend;
|
else
|
||||||
space.spaces.erase(space.spaces.begin() + seti);
|
{
|
||||||
|
slog << logerror << "set: " << sp.name << " already defined (skipping)" << logend;
|
||||||
|
space.remove_child_space(seti);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,74 +89,83 @@ void Groups::ReindexGroups(GroupIndex & group_index, PT::Space & set)
|
||||||
{
|
{
|
||||||
size_t i, v;
|
size_t i, v;
|
||||||
|
|
||||||
// loop through all groups in the set
|
if( set.child_spaces )
|
||||||
for( i=0 ; i < set.spaces.size() ; ++i )
|
|
||||||
{
|
{
|
||||||
PT::Space & group = *set.spaces[i];
|
// loop through all groups in the set
|
||||||
// !! IMPROVE ME will be safer to copy the value out
|
for( i=0 ; i < set.child_spaces->size() ; ++i )
|
||||||
// if we used accidently the group.Text later the key
|
|
||||||
// would be overwritten
|
|
||||||
const std::wstring & key = group.Text(L"key", L"value");
|
|
||||||
|
|
||||||
// loop through all values in the group
|
|
||||||
for(v=0 ; v<group.spaces.size() ; )
|
|
||||||
{
|
{
|
||||||
std::wstring * vali = group.spaces[v]->GetFirstValue(key);
|
PT::Space & group = *(*set.child_spaces)[i];
|
||||||
|
// !! IMPROVE ME will be safer to copy the value out
|
||||||
|
// if we used accidently the group.Text later the key
|
||||||
|
// would be overwritten
|
||||||
|
std::wstring key = group.to_wstr(L"key", L"value");
|
||||||
|
|
||||||
if( vali )
|
if( group.child_spaces )
|
||||||
{
|
{
|
||||||
GroupIndex::iterator g = group_index.find(*vali);
|
// loop through all values in the group
|
||||||
|
for(v=0 ; v<group.child_spaces->size() ; )
|
||||||
if( g == group_index.end() )
|
|
||||||
{
|
{
|
||||||
group_index[*vali] = i;
|
std::wstring * vali = (*group.child_spaces)[v]->get_wstr(key.c_str());
|
||||||
v += 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slog << logwarning << "set: " << set.name << " has a group with a duplicated value: "
|
|
||||||
<< *vali << " (skipping)" << logend;
|
|
||||||
|
|
||||||
group.spaces.erase(group.spaces.begin() + v);
|
if( vali )
|
||||||
|
{
|
||||||
|
GroupIndex::iterator g = group_index.find(*vali);
|
||||||
|
|
||||||
|
if( g == group_index.end() )
|
||||||
|
{
|
||||||
|
group_index[*vali] = i;
|
||||||
|
v += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slog << logwarning << "set: " << set.name << " has a group with a duplicated value: "
|
||||||
|
<< *vali << " (skipping)" << logend;
|
||||||
|
|
||||||
|
group.remove_child_space(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log1 << "key: " << key << " was not found" << logend;
|
||||||
|
slog << logwarning << "set: " << set.name
|
||||||
|
<< " has a group without a value (skipping)" << logend;
|
||||||
|
|
||||||
|
group.remove_child_space(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "key: " << key << " was not found" << logend;
|
|
||||||
slog << logwarning << "set: " << set.name
|
|
||||||
<< " has a group without a value (skipping)" << logend;
|
|
||||||
|
|
||||||
group.spaces.erase(group.spaces.begin() + v);
|
SortValues(group);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SortValues(group);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Groups::SortValues(PT::Space & group)
|
void Groups::SortValues(PT::Space & group)
|
||||||
{
|
{
|
||||||
sort_by = group.Text(L"sort_by");
|
sort_by = group.to_wstr(L"sort_by");
|
||||||
sort_asc = (group.Text(L"sort_asc", L"true") == L"true");
|
sort_asc = group.is_equal(L"sort_asc", L"true");
|
||||||
|
|
||||||
if( !sort_by.empty() )
|
if( !sort_by.empty() && group.child_spaces )
|
||||||
{
|
{
|
||||||
group.ListText(L"sort", sort_value);
|
group.to_list(L"sort", sort_value, true);
|
||||||
std::sort(group.spaces.begin(), group.spaces.end(), SortFunHelper(this));
|
std::sort(group.child_spaces->begin(), group.child_spaces->end(), SortFunHelper(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Groups::SortFunHelper::operator()(PT::Space * sp1, PT::Space * sp2)
|
bool Groups::SortFunHelper::operator()(PT::Space * sp1, PT::Space * sp2)
|
||||||
{
|
{
|
||||||
const std::wstring & val1 = sp1->Text(groups->sort_by, L"");
|
const std::wstring * val1 = sp1->get_wstr(groups->sort_by.c_str());
|
||||||
const std::wstring & val2 = sp2->Text(groups->sort_by, L"");
|
const std::wstring * val2 = sp2->get_wstr(groups->sort_by.c_str());
|
||||||
|
|
||||||
|
if( !val1 || !val2 )
|
||||||
|
return false;
|
||||||
|
|
||||||
if( groups->sort_asc )
|
if( groups->sort_asc )
|
||||||
return SortValue(val1) < SortValue(val2);
|
return SortValue(*val1) < SortValue(*val2);
|
||||||
else
|
else
|
||||||
return SortValue(val1) > SortValue(val2);
|
return SortValue(*val1) > SortValue(*val2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,16 +206,21 @@ return false;
|
||||||
|
|
||||||
const std::wstring & Groups::GetOption(size_t seti, size_t groupi, size_t valuei, const wchar_t * option)
|
const std::wstring & Groups::GetOption(size_t seti, size_t groupi, size_t valuei, const wchar_t * option)
|
||||||
{
|
{
|
||||||
if( seti < space.spaces.size() )
|
if( space.child_spaces && seti < space.child_spaces->size() )
|
||||||
{
|
{
|
||||||
PT::Space & groups = *space.spaces[seti];
|
PT::Space & groups = *(*space.child_spaces)[seti];
|
||||||
|
|
||||||
if( groupi < groups.spaces.size() )
|
if( groups.child_spaces && groupi < groups.child_spaces->size() )
|
||||||
{
|
{
|
||||||
PT::Space & value = *groups.spaces[groupi];
|
PT::Space & value = *(*groups.child_spaces)[groupi];
|
||||||
|
|
||||||
if( valuei < value.spaces.size() )
|
if( value.child_spaces && valuei < value.child_spaces->size() )
|
||||||
return value.spaces[valuei]->TextRef(option);
|
{
|
||||||
|
const std::wstring * res = (*value.child_spaces)[valuei]->get_wstr(option);
|
||||||
|
|
||||||
|
if( res )
|
||||||
|
return *res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,12 +237,12 @@ const std::wstring & Groups::GetOption(size_t seti, size_t groupi, size_t valuei
|
||||||
|
|
||||||
size_t Groups::Size(size_t seti, size_t groupi)
|
size_t Groups::Size(size_t seti, size_t groupi)
|
||||||
{
|
{
|
||||||
if( seti < space.spaces.size() )
|
if( space.child_spaces && seti < space.child_spaces->size() )
|
||||||
{
|
{
|
||||||
PT::Space & groups = *space.spaces[seti];
|
PT::Space & groups = *(*space.child_spaces)[seti];
|
||||||
|
|
||||||
if( groupi < groups.spaces.size() )
|
if( groups.child_spaces && groupi < groups.child_spaces->size() )
|
||||||
return groups.spaces[groupi]->spaces.size();
|
return (*groups.child_spaces)[groupi]->child_spaces->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -236,7 +256,7 @@ return 0;
|
||||||
|
|
||||||
void Groups::Clear()
|
void Groups::Clear()
|
||||||
{
|
{
|
||||||
space.Clear();
|
space.clear();
|
||||||
set_index.clear();
|
set_index.clear();
|
||||||
group_index_tab.clear();
|
group_index_tab.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2014, Tomasz Sowa
|
* Copyright (c) 2011-2021, 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
|
||||||
|
@ -136,7 +136,7 @@ private:
|
||||||
|
|
||||||
std::wstring sort_by;
|
std::wstring sort_by;
|
||||||
bool sort_asc;
|
bool sort_asc;
|
||||||
PT::Space::Value sort_value;
|
std::vector<std::wstring> sort_value;
|
||||||
|
|
||||||
struct SortFunHelper
|
struct SortFunHelper
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,16 +77,16 @@ void ReloadConfigFile(PluginInfo & info, Item & file)
|
||||||
PT::SpaceParser parser;
|
PT::SpaceParser parser;
|
||||||
|
|
||||||
parser.SetSpace(space);
|
parser.SetSpace(space);
|
||||||
PT::SpaceParser::Status status = parser.ParseString(file.item_content.content_raw);
|
PT::SpaceParser::Status status = parser.ParseSpace(file.item_content.content_raw);
|
||||||
|
|
||||||
if( status == PT::SpaceParser::syntax_error )
|
if( status == PT::SpaceParser::syntax_error )
|
||||||
{
|
{
|
||||||
info.log << log1 << "MR: syntax error in file: " << file.url << ", line: " << parser.line << " (skipping this file)" << logend;
|
info.log << log1 << "MR: syntax error in file: " << file.url << ", line: " << parser.get_last_parsed_line() << " (skipping this file)" << logend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( status == PT::SpaceParser::ok )
|
if( status == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
std::wstring * list_id_str = space.GetFirstValue(L"list_id");
|
std::wstring * list_id_str = space.get_wstr(L"list_id");
|
||||||
|
|
||||||
if( list_id_str )
|
if( list_id_str )
|
||||||
{
|
{
|
||||||
|
|
|
@ -390,7 +390,7 @@ void menu_dir_tab_meta_str(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() )
|
||||||
sitem->citem->menu_items[stack->iter].meta.Serialize(i.out, true, false);
|
sitem->citem->menu_items[stack->iter].meta.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,9 @@ void Seo::MakePost()
|
||||||
|
|
||||||
item.subject = subject;
|
item.subject = subject;
|
||||||
|
|
||||||
PT::Space & seo = item.item_content.meta.FindAddSpace(L"seo");
|
PT::Space & seo = item.item_content.meta.find_add_child_space(L"seo");
|
||||||
seo.Add(L"description", description);
|
seo.add(L"description", description);
|
||||||
seo.Add(L"keywords", keywords);
|
seo.add(L"keywords", keywords);
|
||||||
|
|
||||||
ItemModelData item_model_data;
|
ItemModelData item_model_data;
|
||||||
item_model_data.prepare_unique_url = false;
|
item_model_data.prepare_unique_url = false;
|
||||||
|
|
|
@ -80,11 +80,11 @@ bool Reply::HasAccess()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
PT::Space * thread_space = cur->request->item.item_content.meta_admin.FindSpace(L"thread");
|
PT::Space * thread_space = cur->request->item.item_content.meta_admin.find_child_space(L"thread");
|
||||||
|
|
||||||
if( thread_space )
|
if( thread_space )
|
||||||
{
|
{
|
||||||
if( thread_space->Bool(L"closed", false) )
|
if( thread_space->to_bool(L"closed", false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ return DoCommand(query);
|
||||||
long TDb::FindLastAnswer(long file_id)
|
long TDb::FindLastAnswer(long file_id)
|
||||||
{
|
{
|
||||||
PGresult * r = 0;
|
PGresult * r = 0;
|
||||||
Error status = WINIX_ERR_OK;
|
//Error status = WINIX_ERR_OK;
|
||||||
long last_item_id = -1;
|
long last_item_id = -1;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -249,7 +249,7 @@ long TDb::FindLastAnswer(long file_id)
|
||||||
}
|
}
|
||||||
catch(const Error & e)
|
catch(const Error & e)
|
||||||
{
|
{
|
||||||
status = e;
|
//status = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearResult(r);
|
ClearResult(r);
|
||||||
|
|
|
@ -185,7 +185,7 @@ PT::Space & EditTicket::PrepareSpace()
|
||||||
|
|
||||||
if( is_new )
|
if( is_new )
|
||||||
{
|
{
|
||||||
PT::Space * ticket_space = cur->request->item.item_content.meta.FindSpace(L"ticket");
|
PT::Space * ticket_space = cur->request->item.item_content.meta.find_child_space(L"ticket");
|
||||||
|
|
||||||
if( ticket_space )
|
if( ticket_space )
|
||||||
{
|
{
|
||||||
|
@ -203,11 +203,11 @@ bool EditTicket::CloseTicket()
|
||||||
{
|
{
|
||||||
cur->request->item.propagate_connector();
|
cur->request->item.propagate_connector();
|
||||||
|
|
||||||
PT::Space & ticket_space = cur->request->item.item_content.meta_admin.FindAddSpace(L"ticket");
|
PT::Space & ticket_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"ticket");
|
||||||
ticket_space.Add(L"closed", true);
|
ticket_space.add(L"closed", true);
|
||||||
|
|
||||||
PT::Space & thread_space = cur->request->item.item_content.meta_admin.FindAddSpace(L"thread");
|
PT::Space & thread_space = cur->request->item.item_content.meta_admin.find_add_child_space(L"thread");
|
||||||
thread_space.Add(L"closed", true);
|
thread_space.add(L"closed", true);
|
||||||
|
|
||||||
//if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK )
|
//if( db->EditAdminMetaById(cur->request->item.ameta, cur->request->item.id) == WINIX_ERR_OK )
|
||||||
if( cur->request->item.item_content.update() )
|
if( cur->request->item.item_content.update() )
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -144,30 +144,36 @@ void SessionData::BuildFileList(std::vector<long> & file_tab, PT::Space & space)
|
||||||
{
|
{
|
||||||
file_tab.clear();
|
file_tab.clear();
|
||||||
|
|
||||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & sp = *space.spaces[i];
|
for(size_t i=0 ; i<space.child_spaces->size() ; ++i)
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*space.child_spaces)[i];
|
||||||
|
|
||||||
if( sp.name == L"param" )
|
if( sp.name && (*sp.name) == L"param" )
|
||||||
CheckFile(file_tab, sp);
|
CheckFile(file_tab, sp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionData::CheckFile(std::vector<long> & file_tab, PT::Space & space)
|
void SessionData::CheckFile(std::vector<long> & file_tab, PT::Space & space)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & subsp = *space.spaces[i];
|
for(size_t i=0 ; i<space.child_spaces->size() ; ++i)
|
||||||
|
|
||||||
if( subsp.name == L"file" )
|
|
||||||
{
|
{
|
||||||
std::wstring * file_id_str = subsp.GetFirstValue(L"itemid");
|
PT::Space & subsp = *(*space.child_spaces)[i];
|
||||||
|
|
||||||
if( file_id_str )
|
if( subsp.name && *subsp.name == L"file" )
|
||||||
{
|
{
|
||||||
long file_id = Tol(*file_id_str);
|
std::wstring * file_id_str = subsp.get_wstr(L"itemid");
|
||||||
file_tab.push_back(file_id);
|
|
||||||
|
if( file_id_str )
|
||||||
|
{
|
||||||
|
long file_id = Tol(*file_id_str);
|
||||||
|
file_tab.push_back(file_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,16 +173,19 @@ PT::Space * find_ticket_param(long param_id, PT::Space & meta)
|
||||||
{
|
{
|
||||||
wchar_t param_id_str[50];
|
wchar_t param_id_str[50];
|
||||||
|
|
||||||
// for performane
|
if( meta.child_spaces )
|
||||||
// should be a little faster in each loop comparing only just text
|
|
||||||
Toa(param_id, param_id_str, sizeof(param_id_str)/sizeof(wchar_t));
|
|
||||||
|
|
||||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
|
||||||
{
|
{
|
||||||
PT::Space & sp = *meta.spaces[i];
|
// for performane
|
||||||
|
// should be a little faster in each loop comparing only just text
|
||||||
|
Toa(param_id, param_id_str, sizeof(param_id_str)/sizeof(wchar_t));
|
||||||
|
|
||||||
if( sp.name == L"param" && sp.Text(L"id") == param_id_str )
|
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||||
return &sp;
|
{
|
||||||
|
PT::Space & sp = *(*meta.child_spaces)[i];
|
||||||
|
|
||||||
|
if( sp.name && *sp.name == L"param" && sp.is_equal(L"id", param_id_str) )
|
||||||
|
return &sp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -226,7 +229,7 @@ size_t par_index;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PT::Space * meta = item_meta.FindSpace(L"ticket");
|
PT::Space * meta = item_meta.find_child_space(L"ticket");
|
||||||
|
|
||||||
if( meta )
|
if( meta )
|
||||||
{
|
{
|
||||||
|
@ -246,15 +249,19 @@ size_t par_index;
|
||||||
|
|
||||||
void ticket_print_value_select(Info & i, TicketValue & value)
|
void ticket_print_value_select(Info & i, TicketValue & value)
|
||||||
{
|
{
|
||||||
if( value.is_param && value.is_value )
|
if( value.is_param && value.is_value && value.config_par->child_spaces )
|
||||||
{
|
{
|
||||||
for(size_t a=0 ; a<value.config_par->spaces.size() ; ++a)
|
for(size_t a=0 ; a<value.config_par->child_spaces->size() ; ++a)
|
||||||
{
|
{
|
||||||
PT::Space & sp = *value.config_par->spaces[a];
|
PT::Space & sp = *(*value.config_par->child_spaces)[a];
|
||||||
|
|
||||||
if( sp.name == L"option" && sp.Long(L"id") == value.ticket_par->intv )
|
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == value.ticket_par->intv )
|
||||||
{
|
{
|
||||||
i.out << sp.Text(L"value");
|
std::wstring * val = sp.get_wstr(L"value");
|
||||||
|
|
||||||
|
if( val )
|
||||||
|
i.out << *val;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +274,7 @@ void ticket_print_value(Info & i, TicketValue & value)
|
||||||
if( !value.is_param || !value.is_value )
|
if( !value.is_param || !value.is_value )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::wstring * type = value.config_par->GetFirstValue(L"type");
|
std::wstring * type = value.config_par->get_wstr(L"type");
|
||||||
|
|
||||||
if( value.is_in_ticket_par )
|
if( value.is_in_ticket_par )
|
||||||
{
|
{
|
||||||
|
@ -281,7 +288,10 @@ void ticket_print_value(Info & i, TicketValue & value)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i.out << value.value_meta->Text(L"value");
|
std::wstring * val = value.value_meta->get_wstr(L"value");
|
||||||
|
|
||||||
|
if( val )
|
||||||
|
i.out << *val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,10 +322,10 @@ void ticket_meta_value(Info & i)
|
||||||
|
|
||||||
void ticket_is_closed(Info & i)
|
void ticket_is_closed(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space * ticket_space = ticket_info.item->item_content.meta_admin.FindSpace(L"ticket");
|
PT::Space * ticket_space = ticket_info.item->item_content.meta_admin.find_child_space(L"ticket");
|
||||||
|
|
||||||
if( ticket_space )
|
if( ticket_space )
|
||||||
i.res = ticket_space->Bool(L"closed", false);
|
i.res = ticket_space->to_bool(L"closed", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,24 +340,27 @@ void ticket_param_value_for_param_id(Info & i)
|
||||||
PT::Space & space = *ticket_info.cur_conf;
|
PT::Space & space = *ticket_info.cur_conf;
|
||||||
int id = Toi(i.par);
|
int id = Toi(i.par);
|
||||||
|
|
||||||
|
if( space.child_spaces )
|
||||||
for( ; conf_index < space.spaces.size() ; ++conf_index)
|
|
||||||
{
|
{
|
||||||
if( space.spaces[conf_index]->name == L"param" &&
|
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
|
||||||
space.spaces[conf_index]->Int(L"id") == id )
|
|
||||||
{
|
{
|
||||||
value_for_param_id.Clear();
|
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||||
value_for_param_id.is_param = true;
|
|
||||||
value_for_param_id.config_par = space.spaces[conf_index];
|
|
||||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
|
||||||
|
|
||||||
if( ticket_info.ticket && ticket_info.item )
|
if( sp.name && *sp.name == L"param" && sp.to_int(L"id") == id )
|
||||||
{
|
{
|
||||||
find_ticket_value(value_for_param_id, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
value_for_param_id.Clear();
|
||||||
ticket_print_value(i, value_for_param_id);
|
value_for_param_id.is_param = true;
|
||||||
}
|
value_for_param_id.config_par = &sp;
|
||||||
|
value_for_param_id.param_id = sp.to_long(L"id");
|
||||||
|
|
||||||
break;
|
if( ticket_info.ticket && ticket_info.item )
|
||||||
|
{
|
||||||
|
find_ticket_value(value_for_param_id, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||||
|
ticket_print_value(i, value_for_param_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,20 +374,21 @@ void ticket_does_param_id_have_value(Info & i)
|
||||||
size_t conf_index = 0;
|
size_t conf_index = 0;
|
||||||
PT::Space & space = *ticket_info.cur_conf;
|
PT::Space & space = *ticket_info.cur_conf;
|
||||||
|
|
||||||
if( i.params.size() == 2 )
|
if( i.params.size() == 2 && space.child_spaces )
|
||||||
{
|
{
|
||||||
long id = Tol(i.params[0].str);
|
long id = Tol(i.params[0].str);
|
||||||
long id2 = Tol(i.params[1].str);
|
long id2 = Tol(i.params[1].str);
|
||||||
|
|
||||||
for( ; conf_index < space.spaces.size() ; ++conf_index)
|
for( ; conf_index < space.child_spaces->size() ; ++conf_index)
|
||||||
{
|
{
|
||||||
if( space.spaces[conf_index]->name == L"param" &&
|
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||||
space.spaces[conf_index]->Int(L"id") == id )
|
|
||||||
|
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
|
||||||
{
|
{
|
||||||
value_for_param_id.Clear();
|
value_for_param_id.Clear();
|
||||||
value_for_param_id.is_param = true;
|
value_for_param_id.is_param = true;
|
||||||
value_for_param_id.config_par = space.spaces[conf_index];
|
value_for_param_id.config_par = &sp;
|
||||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
value_for_param_id.param_id = sp.to_long(L"id");
|
||||||
|
|
||||||
if( ticket_info.ticket && ticket_info.item )
|
if( ticket_info.ticket && ticket_info.item )
|
||||||
{
|
{
|
||||||
|
@ -545,10 +559,10 @@ void tickets_tab_is_closed(Info & i)
|
||||||
|
|
||||||
if( tickets_value.is_item )
|
if( tickets_value.is_item )
|
||||||
{
|
{
|
||||||
PT::Space * ticket_space = tickets_value.item->item_content.meta_admin.FindSpace(L"ticket");
|
PT::Space * ticket_space = tickets_value.item->item_content.meta_admin.find_child_space(L"ticket");
|
||||||
|
|
||||||
if( ticket_space )
|
if( ticket_space )
|
||||||
i.res = ticket_space->Bool(L"closed", false);
|
i.res = ticket_space->to_bool(L"closed", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,22 +639,27 @@ void tickets_tab_param_value_for_param_id(Info & i)
|
||||||
{
|
{
|
||||||
size_t param_index = 0;
|
size_t param_index = 0;
|
||||||
PT::Space & space = *ticket_info.cur_conf;
|
PT::Space & space = *ticket_info.cur_conf;
|
||||||
int id = Toi(i.par);
|
long id = Tol(i.par);
|
||||||
|
|
||||||
for( ; param_index < space.spaces.size() ; ++param_index)
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
if( space.spaces[param_index]->name == L"param" &&
|
for( ; param_index < space.child_spaces->size() ; ++param_index)
|
||||||
space.spaces[param_index]->Int(L"id") == id )
|
|
||||||
{
|
{
|
||||||
value_for_param_id.Clear();
|
PT::Space & sp = *(*space.child_spaces)[param_index];
|
||||||
value_for_param_id.is_param = true;
|
|
||||||
value_for_param_id.config_par = space.spaces[param_index];
|
|
||||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
|
||||||
|
|
||||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
if( sp.name && *sp.name == L"param" &&
|
||||||
ticket_print_value(i, value_for_param_id);
|
sp.to_long(L"id") == id )
|
||||||
|
{
|
||||||
|
value_for_param_id.Clear();
|
||||||
|
value_for_param_id.is_param = true;
|
||||||
|
value_for_param_id.config_par = &sp;
|
||||||
|
value_for_param_id.param_id = sp.to_long(L"id");
|
||||||
|
|
||||||
break;
|
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||||
|
ticket_print_value(i, value_for_param_id);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,32 +679,36 @@ void tickets_tab_does_param_id_have_value(Info & i)
|
||||||
long id = Toi(i.params[0].str);
|
long id = Toi(i.params[0].str);
|
||||||
long id2 = Toi(i.params[1].str);
|
long id2 = Toi(i.params[1].str);
|
||||||
|
|
||||||
for( ; param_index < space.spaces.size() ; ++param_index)
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
if( space.spaces[param_index]->name == L"param" &&
|
for( ; param_index < space.child_spaces->size() ; ++param_index)
|
||||||
space.spaces[param_index]->Int(L"id") == id )
|
|
||||||
{
|
{
|
||||||
value_for_param_id.Clear();
|
PT::Space & sp = *(*space.child_spaces)[param_index];
|
||||||
value_for_param_id.is_param = true;
|
|
||||||
value_for_param_id.config_par = space.spaces[param_index];
|
|
||||||
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
|
|
||||||
|
|
||||||
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == id )
|
||||||
|
|
||||||
if( value_for_param_id.is_value )
|
|
||||||
{
|
{
|
||||||
if( value_for_param_id.is_in_ticket_par )
|
value_for_param_id.Clear();
|
||||||
{
|
value_for_param_id.is_param = true;
|
||||||
i.res = value_for_param_id.ticket_par->intv == id2;
|
value_for_param_id.config_par = &sp;
|
||||||
}
|
value_for_param_id.param_id = sp.to_long(L"id");
|
||||||
else
|
|
||||||
{
|
|
||||||
log << log1 << "Ticket: tickets_tab_does_param_id_have_value cannot be used with meta values"
|
|
||||||
<< logend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||||
|
|
||||||
|
if( value_for_param_id.is_value )
|
||||||
|
{
|
||||||
|
if( value_for_param_id.is_in_ticket_par )
|
||||||
|
{
|
||||||
|
i.res = value_for_param_id.ticket_par->intv == id2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << log1 << "Ticket: tickets_tab_does_param_id_have_value cannot be used with meta values"
|
||||||
|
<< logend;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,17 +725,27 @@ void tickets_tab_conf_tab(Info & i)
|
||||||
conf_index = i.iter;
|
conf_index = i.iter;
|
||||||
PT::Space & space = *ticket_info.cur_conf;
|
PT::Space & space = *ticket_info.cur_conf;
|
||||||
|
|
||||||
while( conf_index < space.spaces.size() && space.spaces[conf_index]->name != L"param" )
|
if( space.child_spaces )
|
||||||
conf_index += 1;
|
|
||||||
|
|
||||||
i.res = conf_index < space.spaces.size();
|
|
||||||
|
|
||||||
if( i.res )
|
|
||||||
{
|
{
|
||||||
value.is_param = true;
|
while( conf_index < space.child_spaces->size() )
|
||||||
value.config_par = space.spaces[conf_index];
|
{
|
||||||
value.param_id = value.config_par->Long(L"id");
|
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||||
find_ticket_value(value, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
|
||||||
|
if( sp.name && *sp.name == L"param" )
|
||||||
|
break;
|
||||||
|
|
||||||
|
conf_index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.res = conf_index < space.child_spaces->size();
|
||||||
|
|
||||||
|
if( i.res )
|
||||||
|
{
|
||||||
|
value.is_param = true;
|
||||||
|
value.config_par = (*space.child_spaces)[conf_index];
|
||||||
|
value.param_id = value.config_par->to_long(L"id");
|
||||||
|
find_ticket_value(value, tickets_value.ticket->par_tab, tickets_value.item->item_content.meta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -751,7 +784,7 @@ void tickets_tab_conf_tab_param_name(Info & i)
|
||||||
|
|
||||||
if( value.is_param )
|
if( value.is_param )
|
||||||
{
|
{
|
||||||
std::wstring * name = value.config_par->GetFirstValue(L"name");
|
std::wstring * name = value.config_par->get_wstr(L"name");
|
||||||
|
|
||||||
if( name )
|
if( name )
|
||||||
i.out << *name;
|
i.out << *name;
|
||||||
|
@ -773,7 +806,7 @@ void tickets_tab_conf_tab_type_is(Info & i)
|
||||||
tickets_tab_check_reqid();
|
tickets_tab_check_reqid();
|
||||||
|
|
||||||
if( value.is_param )
|
if( value.is_param )
|
||||||
i.res = (value.config_par->Text(L"type") == i.par);
|
i.res = value.config_par->is_equal(L"type", i.par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -809,13 +842,23 @@ void tickets_tab_conf_tab_file_tab(Info & i)
|
||||||
|
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
while( tickets_file_index < mt.spaces.size() && mt.spaces[tickets_file_index]->name != L"file" )
|
if( mt.child_spaces )
|
||||||
tickets_file_index += 1;
|
{
|
||||||
|
while( tickets_file_index < mt.child_spaces->size() )
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*mt.child_spaces)[tickets_file_index];
|
||||||
|
|
||||||
i.res = (tickets_file_index < mt.spaces.size());
|
if( sp.name && *sp.name == L"file" )
|
||||||
|
break;
|
||||||
|
|
||||||
if( i.res && i.iter > 0 )
|
tickets_file_index += 1;
|
||||||
tickets_file_number += 1;
|
}
|
||||||
|
|
||||||
|
i.res = (tickets_file_index < mt.child_spaces->size());
|
||||||
|
|
||||||
|
if( i.res && i.iter > 0 )
|
||||||
|
tickets_file_number += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +871,7 @@ void tickets_tab_conf_tab_file_tab_index(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( tickets_file_index < mt.spaces.size() )
|
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||||
i.out << tickets_file_number;
|
i.out << tickets_file_number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,8 +886,8 @@ void tickets_tab_conf_tab_file_tab_path(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( tickets_file_index < mt.spaces.size() )
|
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||||
i.out << mt.spaces[tickets_file_index]->Text(L"path");
|
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,8 +900,8 @@ void tickets_tab_conf_tab_file_tab_itemid(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( tickets_file_index < mt.spaces.size() )
|
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||||
i.out << mt.spaces[tickets_file_index]->Text(L"itemid");
|
i.out << (*mt.child_spaces)[tickets_file_index]->to_wstr(L"itemid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,8 +914,8 @@ void tickets_tab_conf_tab_file_tab_meta(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( tickets_file_index < mt.spaces.size() )
|
if( mt.child_spaces && tickets_file_index < mt.child_spaces->size() )
|
||||||
space_value(i, *mt.spaces[tickets_file_index]);
|
space_value(i, *(*mt.child_spaces)[tickets_file_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,19 +956,29 @@ void ticket_tab(Info & i)
|
||||||
conf_index = i.iter;
|
conf_index = i.iter;
|
||||||
PT::Space & space = *ticket_info.cur_conf;
|
PT::Space & space = *ticket_info.cur_conf;
|
||||||
|
|
||||||
while( conf_index < space.spaces.size() && space.spaces[conf_index]->name != L"param" )
|
if( space.child_spaces )
|
||||||
conf_index += 1;
|
|
||||||
|
|
||||||
i.res = conf_index < space.spaces.size();
|
|
||||||
|
|
||||||
if( i.res )
|
|
||||||
{
|
{
|
||||||
value.is_param = true;
|
while( conf_index < space.child_spaces->size() )
|
||||||
value.config_par = space.spaces[conf_index];
|
{
|
||||||
value.param_id = value.config_par->Long(L"id");
|
PT::Space & sp = *(*space.child_spaces)[conf_index];
|
||||||
|
|
||||||
if( ticket_info.ticket && ticket_info.item )
|
if( sp.name && *sp.name == L"param" )
|
||||||
find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
break;
|
||||||
|
|
||||||
|
conf_index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.res = conf_index < space.child_spaces->size();
|
||||||
|
|
||||||
|
if( i.res )
|
||||||
|
{
|
||||||
|
value.is_param = true;
|
||||||
|
value.config_par = (*space.child_spaces)[conf_index];
|
||||||
|
value.param_id = value.config_par->to_long(L"id");
|
||||||
|
|
||||||
|
if( ticket_info.ticket && ticket_info.item )
|
||||||
|
find_ticket_value(value, ticket_info.ticket->par_tab, ticket_info.item->item_content.meta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,7 +1008,7 @@ void ticket_tab_param_name(Info & i)
|
||||||
ticket_tab_check_reqid();
|
ticket_tab_check_reqid();
|
||||||
|
|
||||||
if( value.is_param )
|
if( value.is_param )
|
||||||
i.out << value.config_par->Text(L"name");
|
i.out << value.config_par->to_wstr(L"name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1008,7 +1061,7 @@ void ticket_tab_type_is(Info & i)
|
||||||
ticket_tab_check_reqid();
|
ticket_tab_check_reqid();
|
||||||
|
|
||||||
if( value.is_param )
|
if( value.is_param )
|
||||||
i.res = (value.config_par->Text(L"type") == i.par);
|
i.res = value.config_par->is_equal(L"type", i.par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1021,10 +1074,20 @@ void ticket_tab_select_tab(Info & i)
|
||||||
select_index = i.iter;
|
select_index = i.iter;
|
||||||
PT::Space & sp = *value.config_par;
|
PT::Space & sp = *value.config_par;
|
||||||
|
|
||||||
while( select_index < sp.spaces.size() && sp.spaces[select_index]->name != L"option" )
|
if( sp.child_spaces )
|
||||||
select_index += 1;
|
{
|
||||||
|
while( select_index < sp.child_spaces->size() )
|
||||||
|
{
|
||||||
|
PT::Space & sp_child = *(*sp.child_spaces)[select_index];
|
||||||
|
|
||||||
i.res = (select_index < sp.spaces.size());
|
if( sp_child.name && *sp_child.name == L"option" )
|
||||||
|
break;
|
||||||
|
|
||||||
|
select_index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.res = (select_index < sp.child_spaces->size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,9 +1100,11 @@ void ticket_tab_select_tab_is_selected(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & sp = *value.config_par;
|
PT::Space & sp = *value.config_par;
|
||||||
|
|
||||||
if( select_index < sp.spaces.size() )
|
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||||
{
|
{
|
||||||
long id = sp.spaces[select_index]->Long(L"id");
|
PT::Space & sp_child = *(*sp.child_spaces)[select_index];
|
||||||
|
|
||||||
|
long id = sp_child.to_long(L"id");
|
||||||
|
|
||||||
if( value.is_value )
|
if( value.is_value )
|
||||||
{
|
{
|
||||||
|
@ -1048,7 +1113,7 @@ void ticket_tab_select_tab_is_selected(Info & i)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i.res = (id == sp.Long(L"default"));
|
i.res = (id == sp.to_long(L"default"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1063,8 +1128,8 @@ void ticket_tab_select_tab_name(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & sp = *value.config_par;
|
PT::Space & sp = *value.config_par;
|
||||||
|
|
||||||
if( select_index < sp.spaces.size() )
|
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||||
i.out << sp.spaces[select_index]->Text(L"value");
|
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,8 +1142,8 @@ void ticket_tab_select_tab_id(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & sp = *value.config_par;
|
PT::Space & sp = *value.config_par;
|
||||||
|
|
||||||
if( select_index < sp.spaces.size() )
|
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||||
i.out << sp.spaces[select_index]->Text(L"id");
|
i.out << (*sp.child_spaces)[select_index]->to_wstr(L"id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,8 +1155,8 @@ void ticket_tab_select_tab_meta(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & sp = *value.config_par;
|
PT::Space & sp = *value.config_par;
|
||||||
|
|
||||||
if( select_index < sp.spaces.size() )
|
if( sp.child_spaces && select_index < sp.child_spaces->size() )
|
||||||
space_value(i, *sp.spaces[select_index]);
|
space_value(i, *(*sp.child_spaces)[select_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1110,13 +1175,23 @@ void ticket_tab_file_tab(Info & i)
|
||||||
|
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
while( ticket_file_index < mt.spaces.size() && mt.spaces[ticket_file_index]->name != L"file" )
|
if( mt.child_spaces )
|
||||||
ticket_file_index += 1;
|
{
|
||||||
|
while( ticket_file_index < mt.child_spaces->size() )
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*mt.child_spaces)[ticket_file_index];
|
||||||
|
|
||||||
i.res = (ticket_file_index < mt.spaces.size());
|
if( sp.name && *sp.name == L"file" )
|
||||||
|
break;
|
||||||
|
|
||||||
if( i.res && i.iter > 0 )
|
ticket_file_index += 1;
|
||||||
ticket_file_number += 1;
|
}
|
||||||
|
|
||||||
|
i.res = (ticket_file_index < mt.child_spaces->size());
|
||||||
|
|
||||||
|
if( i.res && i.iter > 0 )
|
||||||
|
ticket_file_number += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1204,7 @@ void ticket_tab_file_tab_index(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( ticket_file_index < mt.spaces.size() )
|
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||||
i.out << ticket_file_number;
|
i.out << ticket_file_number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1143,8 +1218,8 @@ void ticket_tab_file_tab_path(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( ticket_file_index < mt.spaces.size() )
|
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||||
i.out << mt.spaces[ticket_file_index]->Text(L"path");
|
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"path");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,8 +1231,8 @@ void ticket_tab_file_tab_itemid(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( ticket_file_index < mt.spaces.size() )
|
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||||
i.out << mt.spaces[ticket_file_index]->Text(L"itemid");
|
i.out << (*mt.child_spaces)[ticket_file_index]->to_wstr(L"itemid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,8 +1244,8 @@ void ticket_tab_file_tab_meta(Info & i)
|
||||||
{
|
{
|
||||||
PT::Space & mt = *value.value_meta;
|
PT::Space & mt = *value.value_meta;
|
||||||
|
|
||||||
if( ticket_file_index < mt.spaces.size() )
|
if( mt.child_spaces && ticket_file_index < mt.child_spaces->size() )
|
||||||
space_value(i, *mt.spaces[ticket_file_index]);
|
space_value(i, *(*mt.child_spaces)[ticket_file_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ void TicketInfo::Clear()
|
||||||
|
|
||||||
cur_conf_wrap = &cur_conf_wrap_empty;
|
cur_conf_wrap = &cur_conf_wrap_empty;
|
||||||
cur_conf = &cur_conf_empty;
|
cur_conf = &cur_conf_empty;
|
||||||
cur_conf->Clear();
|
cur_conf->clear();
|
||||||
|
|
||||||
item_tab.clear();
|
item_tab.clear();
|
||||||
ticket_tab.clear();
|
ticket_tab.clear();
|
||||||
|
@ -167,9 +167,9 @@ bool TicketInfo::ParseTicketConf(long mount_dir_id, const std::wstring & path)
|
||||||
|
|
||||||
conf_tab[mount_dir_id].file_name = path;
|
conf_tab[mount_dir_id].file_name = path;
|
||||||
conf_parser.SetSpace(conf_tab[mount_dir_id].conf);
|
conf_parser.SetSpace(conf_tab[mount_dir_id].conf);
|
||||||
conf_tab[mount_dir_id].conf.Clear();
|
conf_tab[mount_dir_id].conf.clear();
|
||||||
|
|
||||||
return (conf_parser.ParseString(config_file.item_content.content_raw) == PT::SpaceParser::ok);
|
return (conf_parser.ParseSpace(config_file.item_content.content_raw) == PT::SpaceParser::ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,15 +264,15 @@ void TicketInfo::FindCurrentConf()
|
||||||
|
|
||||||
void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||||
{
|
{
|
||||||
std::wstring * type = space.GetFirstValue(L"type");
|
std::wstring * type = space.get_wstr(L"type");
|
||||||
|
|
||||||
if( !type )
|
if( !type )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( *type == L"integer" )
|
if( *type == L"integer" )
|
||||||
{
|
{
|
||||||
std::wstring * min_str = space.GetFirstValue(L"min");
|
std::wstring * min_str = space.get_wstr(L"min");
|
||||||
std::wstring * max_str = space.GetFirstValue(L"min");
|
std::wstring * max_str = space.get_wstr(L"min");
|
||||||
|
|
||||||
if( min_str )
|
if( min_str )
|
||||||
{
|
{
|
||||||
|
@ -303,16 +303,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||||
else
|
else
|
||||||
if( *type == L"select" )
|
if( *type == L"select" )
|
||||||
{
|
{
|
||||||
for(size_t a=0 ; a<space.spaces.size() ; ++a)
|
if( space.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & sp = *space.spaces[a];
|
for(size_t a=0 ; a<space.child_spaces->size() ; ++a)
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*space.child_spaces)[a];
|
||||||
|
|
||||||
if( sp.name == L"option" && sp.Long(L"id") == par.intv )
|
if( sp.name && *sp.name == L"option" && sp.to_long(L"id") == par.intv )
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
par.intv = 0;
|
par.intv = 0;
|
||||||
std::wstring * def = space.GetFirstValue(L"default");
|
std::wstring * def = space.get_wstr(L"default");
|
||||||
|
|
||||||
if( def )
|
if( def )
|
||||||
par.intv = Tol(*def);
|
par.intv = Tol(*def);
|
||||||
|
@ -322,16 +325,19 @@ void TicketInfo::CheckMinMaxValue(PT::Space & space, Ticket::TicketParam & par)
|
||||||
|
|
||||||
PT::Space & TicketInfo::FindAddMetaByParam(PT::Space & meta, long param)
|
PT::Space & TicketInfo::FindAddMetaByParam(PT::Space & meta, long param)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
if( meta.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & sp = *meta.spaces[i];
|
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||||
|
{
|
||||||
|
PT::Space & sp = *(*meta.child_spaces)[i];
|
||||||
|
|
||||||
if( sp.name == L"param" && sp.Long(L"id") == param )
|
if( sp.name && *sp.name == L"param" && sp.to_long(L"id") == param )
|
||||||
return sp;
|
return sp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PT::Space & sp = meta.AddSpace(L"param");
|
PT::Space & sp = meta.add_child_space(L"param");
|
||||||
sp.Add(L"id", param);
|
sp.add(L"id", param);
|
||||||
|
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
@ -340,9 +346,9 @@ return sp;
|
||||||
|
|
||||||
bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta)
|
bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::TicketParam & par, const std::wstring & value, PT::Space & meta)
|
||||||
{
|
{
|
||||||
if( space.Text(L"type") == L"integer" ||
|
if( space.is_equal(L"type", L"integer") ||
|
||||||
space.Text(L"type") == L"progress" ||
|
space.is_equal(L"type", L"progress") ||
|
||||||
space.Text(L"type") == L"select" )
|
space.is_equal(L"type", L"select") )
|
||||||
{
|
{
|
||||||
par.intv = Tol(value);
|
par.intv = Tol(value);
|
||||||
par.decv.clear();
|
par.decv.clear();
|
||||||
|
@ -350,16 +356,16 @@ bool TicketInfo::ReadTicketValue(PT::Space & space, long param_id, Ticket::Ticke
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( space.Text(L"type") == L"string" ||
|
if( space.is_equal(L"type", L"string") ||
|
||||||
space.Text(L"type") == L"multistring" )
|
space.is_equal(L"type", L"multistring") )
|
||||||
{
|
{
|
||||||
// !! dodac cos co sprawdzi czy string nie zawiera znakow konca linii
|
// !! dodac cos co sprawdzi czy string nie zawiera znakow konca linii
|
||||||
PT::Space & sp = FindAddMetaByParam(meta, param_id);
|
PT::Space & sp = FindAddMetaByParam(meta, param_id);
|
||||||
sp.Add(L"value", value);
|
sp.add(L"value", value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( space.Text(L"type") == L"images" ||
|
if( space.is_equal(L"type", L"images") ||
|
||||||
space.Text(L"type") == L"files" )
|
space.is_equal(L"type", L"files") )
|
||||||
{
|
{
|
||||||
if( !value.empty() )
|
if( !value.empty() )
|
||||||
{
|
{
|
||||||
|
@ -404,16 +410,16 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||||
if( cur->request->status == WINIX_ERR_OK )
|
if( cur->request->status == WINIX_ERR_OK )
|
||||||
{
|
{
|
||||||
PT::Space & space = FindAddMetaByParam(meta, param_id);
|
PT::Space & space = FindAddMetaByParam(meta, param_id);
|
||||||
PT::Space & file_space = space.AddSpace(L"file");
|
PT::Space & file_space = space.add_child_space(L"file");
|
||||||
|
|
||||||
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
if( file.item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||||
file_space.Add(L"type", L"image");
|
file_space.add(L"type", L"image");
|
||||||
else
|
else
|
||||||
file_space.Add(L"type", L"file");
|
file_space.add(L"type", L"file");
|
||||||
|
|
||||||
file_space.Add(L"itemid", file.id);
|
file_space.add(L"itemid", file.id);
|
||||||
system->MakePath(file, file_path);
|
system->MakePath(file, file_path);
|
||||||
file_space.Add(L"path", file_path);
|
file_space.add(L"path", file_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -425,11 +431,11 @@ void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||||
void TicketInfo::ReadTicketValue(PT::Space & space,
|
void TicketInfo::ReadTicketValue(PT::Space & space,
|
||||||
long param_id, const PostFile & value, PT::Space & meta)
|
long param_id, const PostFile & value, PT::Space & meta)
|
||||||
{
|
{
|
||||||
std::wstring * type = space.GetFirstValue(L"type");
|
std::wstring * type = space.get_wstr(L"type");
|
||||||
|
|
||||||
if( type && (*type == L"images" || *type == L"files") )
|
if( type && (*type == L"images" || *type == L"files") )
|
||||||
{
|
{
|
||||||
std::wstring * upload_path = space.GetFirstValue(L"upload_dir");
|
std::wstring * upload_path = space.get_wstr(L"upload_dir");
|
||||||
|
|
||||||
if( upload_path && !upload_path->empty() )
|
if( upload_path && !upload_path->empty() )
|
||||||
{
|
{
|
||||||
|
@ -479,14 +485,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
||||||
{
|
{
|
||||||
ticket_param.Clear();
|
ticket_param.Clear();
|
||||||
|
|
||||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
if( cur_conf->child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & space = *cur_conf->spaces[i];
|
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
|
||||||
|
|
||||||
if( space.name == L"param" && Tol(space.Text(L"id")) == param_id )
|
|
||||||
{
|
{
|
||||||
ReadTicketParam(space, ticket, param_id, value, meta);
|
PT::Space & space = *(*cur_conf->child_spaces)[i];
|
||||||
return;
|
|
||||||
|
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
|
||||||
|
{
|
||||||
|
ReadTicketParam(space, ticket, param_id, value, meta);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,14 +506,17 @@ void TicketInfo::ReadTicketParam(Ticket & ticket, long param_id, const std::wstr
|
||||||
// always adds a new parameter
|
// always adds a new parameter
|
||||||
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
|
void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Space & meta)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<cur_conf->spaces.size() ; ++i)
|
if( cur_conf->child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & space = *cur_conf->spaces[i];
|
for(size_t i=0 ; i<cur_conf->child_spaces->size() ; ++i)
|
||||||
|
|
||||||
if( space.name == L"param" && space.Long(L"id") == param_id )
|
|
||||||
{
|
{
|
||||||
ReadTicketValue(space, param_id, value, meta);
|
PT::Space & space = *(*cur_conf->child_spaces)[i];
|
||||||
return;
|
|
||||||
|
if( space.name && *space.name == L"param" && space.to_long(L"id") == param_id )
|
||||||
|
{
|
||||||
|
ReadTicketValue(space, param_id, value, meta);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,29 +529,32 @@ void TicketInfo::ReadTicketParam(long param_id, const PostFile & value, PT::Spac
|
||||||
|
|
||||||
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta)
|
bool TicketInfo::DeleteTicketFile(Ticket & ticket, long file_id, PT::Space & meta)
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<meta.spaces.size() ; ++i)
|
if( meta.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & param = *meta.spaces[i];
|
for(size_t i=0 ; i<meta.child_spaces->size() ; ++i)
|
||||||
|
|
||||||
if( param.name == L"param" )
|
|
||||||
{
|
{
|
||||||
for(size_t z=0 ; z<param.spaces.size() ; ++z)
|
PT::Space & param = *(*meta.child_spaces)[i];
|
||||||
|
|
||||||
|
if( param.name && *param.name == L"param" && param.child_spaces )
|
||||||
{
|
{
|
||||||
PT::Space & file = *param.spaces[z];
|
for(size_t z=0 ; z<param.child_spaces->size() ; ++z)
|
||||||
|
|
||||||
if( file.name == L"file" )
|
|
||||||
{
|
{
|
||||||
if( file.Long(L"itemid") == file_id )
|
PT::Space & file = *(*param.child_spaces)[z];
|
||||||
|
|
||||||
|
if( file.name && *file.name == L"file" )
|
||||||
{
|
{
|
||||||
param.RemoveSpace(z);
|
if( file.to_long(L"itemid") == file_id )
|
||||||
|
{
|
||||||
|
param.remove_child_space(z);
|
||||||
|
|
||||||
// !! IMPROVE ME
|
// !! IMPROVE ME
|
||||||
// temporarily we delete the file here
|
// temporarily we delete the file here
|
||||||
// but it should be really deleted when the user will press
|
// but it should be really deleted when the user will press
|
||||||
// the submit button
|
// the submit button
|
||||||
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
|
//functions->fun_rm.RemoveFileOrSymlink(file_id, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,9 +631,8 @@ void TicketInfo::RemoveTicket(long file_id)
|
||||||
|
|
||||||
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
|
void TicketInfo::CopyTicketSpace(PT::Space & ticket_space, Item & item)
|
||||||
{
|
{
|
||||||
PT::Space & ticket_meta = item.item_content.meta.FindAddSpace(L"ticket");
|
PT::Space & ticket_meta = item.item_content.meta.find_add_child_space(L"ticket");
|
||||||
ticket_meta = ticket_space;
|
ticket_meta = ticket_space;
|
||||||
ticket_meta.name = L"ticket";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ void dir_last_has_html_template(Info & i)
|
||||||
|
|
||||||
void dir_last_meta_str(Info & i)
|
void dir_last_meta_str(Info & i)
|
||||||
{
|
{
|
||||||
cur->request->dir_tab.back()->item_content.meta.Serialize(i.out, true, false);
|
cur->request->dir_tab.back()->item_content.meta.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ void dir_last_meta_tab_has_next(Info & i)
|
||||||
|
|
||||||
void dir_last_admin_meta_str(Info & i)
|
void dir_last_admin_meta_str(Info & i)
|
||||||
{
|
{
|
||||||
cur->request->dir_tab.back()->item_content.meta_admin.Serialize(i.out, true, false);
|
cur->request->dir_tab.back()->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2015, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -52,7 +52,7 @@ void env_str(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
puser->env.Serialize(i.out, true, false);
|
puser->env.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void env_admin_str(Info & i)
|
||||||
User * puser = cur->session->puser;
|
User * puser = cur->session->puser;
|
||||||
|
|
||||||
if( puser )
|
if( puser )
|
||||||
puser->aenv.Serialize(i.out, true, false);
|
puser->aenv.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2015, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -555,7 +555,7 @@ HtmlTextStream & HtmlTextStream::operator<<(const PT::Space & space)
|
||||||
{
|
{
|
||||||
if( escape )
|
if( escape )
|
||||||
{
|
{
|
||||||
space.Serialize(*this, true, false);
|
space.serialize_to_space_stream(*this, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
tmp_stream.Clear();
|
tmp_stream.Clear();
|
||||||
|
|
|
@ -416,7 +416,7 @@ void item_sort(Info & i)
|
||||||
|
|
||||||
void item_meta_str(Info & i)
|
void item_meta_str(Info & i)
|
||||||
{
|
{
|
||||||
cur->request->last_item->item_content.meta.Serialize(i.out, true, false);
|
cur->request->last_item->item_content.meta.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ void item_meta_tab_has_next(Info & i)
|
||||||
|
|
||||||
void item_admin_meta_str(Info & i)
|
void item_admin_meta_str(Info & i)
|
||||||
{
|
{
|
||||||
cur->request->last_item->item_content.meta_admin.Serialize(i.out, true, false);
|
cur->request->last_item->item_content.meta_admin.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ void item_tab_has_next(Info & i)
|
||||||
void item_tab_meta_str(Info & i)
|
void item_tab_meta_str(Info & i)
|
||||||
{
|
{
|
||||||
if( item_index < cur->request->item_tab.size() )
|
if( item_index < cur->request->item_tab.size() )
|
||||||
cur->request->item_tab[item_index].item_content.meta.Serialize(i.out, true, false);
|
cur->request->item_tab[item_index].item_content.meta.serialize_to_space_stream(i.out, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -88,7 +88,7 @@ return false;
|
||||||
void Locale::ReadFile(const char * dir, const char * dir_def, const char * file)
|
void Locale::ReadFile(const char * dir, const char * dir_def, const char * file)
|
||||||
{
|
{
|
||||||
bool read = false;
|
bool read = false;
|
||||||
temp_space.Clear();
|
temp_space.clear();
|
||||||
|
|
||||||
if( dir_def && ReadFile(dir_def, file) )
|
if( dir_def && ReadFile(dir_def, file) )
|
||||||
read = true;
|
read = true;
|
||||||
|
@ -113,7 +113,7 @@ bool read = false;
|
||||||
file_name += file;
|
file_name += file;
|
||||||
|
|
||||||
loc_parser.SetSpace(temp_space);
|
loc_parser.SetSpace(temp_space);
|
||||||
PT::SpaceParser::Status status = loc_parser.Parse(file_name);
|
PT::SpaceParser::Status status = loc_parser.ParseSpaceFile(file_name);
|
||||||
|
|
||||||
if( status == PT::SpaceParser::ok )
|
if( status == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ bool read = false;
|
||||||
else
|
else
|
||||||
if( status == PT::SpaceParser::syntax_error )
|
if( status == PT::SpaceParser::syntax_error )
|
||||||
{
|
{
|
||||||
log << log1 << "Locale: syntax error in: " << file_name << " in line: " << loc_parser.line << logend;
|
log << log1 << "Locale: syntax error in: " << file_name << " in line: " << loc_parser.get_last_parsed_line() << logend;
|
||||||
}
|
}
|
||||||
|
|
||||||
return read;
|
return read;
|
||||||
|
@ -133,7 +133,7 @@ return read;
|
||||||
|
|
||||||
void Locale::AddLocale(const char * file)
|
void Locale::AddLocale(const char * file)
|
||||||
{
|
{
|
||||||
std::wstring * id_str = temp_space.GetFirstValue(L"winix_locale_id");
|
std::wstring * id_str = temp_space.get_wstr(L"winix_locale_id");
|
||||||
|
|
||||||
if( !id_str )
|
if( !id_str )
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,7 @@ void Locale::ReadSubstTable(const char * dir, const char * dir_def)
|
||||||
{
|
{
|
||||||
bool read = false;
|
bool read = false;
|
||||||
|
|
||||||
|
temp_space.clear();
|
||||||
subst_url.clear();
|
subst_url.clear();
|
||||||
subst_smalllet.clear();
|
subst_smalllet.clear();
|
||||||
subst_capitallet.clear();
|
subst_capitallet.clear();
|
||||||
|
@ -186,17 +187,17 @@ bool read = false;
|
||||||
|
|
||||||
loc_parser.SetSpace(temp_space);
|
loc_parser.SetSpace(temp_space);
|
||||||
|
|
||||||
if( loc_parser.Parse(file_name) == PT::SpaceParser::ok )
|
if( loc_parser.ParseSpaceFile(file_name) == PT::SpaceParser::ok )
|
||||||
{
|
{
|
||||||
read = true;
|
read = true;
|
||||||
CreateSubstVector(subst_url, temp_space.Text(L"url_original"), temp_space.Text(L"url_changeto"));
|
CreateSubstVector(subst_url, temp_space.to_wstr(L"url_original"), temp_space.to_wstr(L"url_changeto"));
|
||||||
CreateSubstVector(subst_smalllet, temp_space.Text(L"smallleters"), temp_space.Text(L"capitalics"));
|
CreateSubstVector(subst_smalllet, temp_space.to_wstr(L"smallleters"), temp_space.to_wstr(L"capitalics"));
|
||||||
CreateSubstVector(subst_capitallet, temp_space.Text(L"capitalics"), temp_space.Text(L"smallleters"));
|
CreateSubstVector(subst_capitallet, temp_space.to_wstr(L"capitalics"), temp_space.to_wstr(L"smallleters"));
|
||||||
|
|
||||||
std::vector<std::wstring> * sort_vec = temp_space.GetValue(L"sort");
|
std::vector<std::wstring> sort_vec;
|
||||||
|
|
||||||
if( sort_vec )
|
if( temp_space.to_list(L"sort", sort_vec) )
|
||||||
CreateSubstSortVector(subst_sort, *sort_vec);
|
CreateSubstSortVector(subst_sort, sort_vec);
|
||||||
|
|
||||||
log << log3 << "Locale: read characters substitution tables from: " << file_name << logend;
|
log << log3 << "Locale: read characters substitution tables from: " << file_name << logend;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +362,7 @@ const std::wstring * Locale::GetKeyInLanguage(const std::wstring & key, size_t l
|
||||||
size_t index = locale_indices[lang_id];
|
size_t index = locale_indices[lang_id];
|
||||||
|
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
return locale_tab[index].GetFirstValue(key);
|
return locale_tab[index].get_wstr(key.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -425,64 +426,29 @@ return empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Locale::IsList(const wchar_t * key, bool try_default_too)
|
|
||||||
|
bool Locale::GetList(const wchar_t * key, std::vector<std::wstring> & list, bool try_default_too)
|
||||||
{
|
{
|
||||||
key_str = key;
|
key_str = key;
|
||||||
return IsList(key_str, try_default_too);
|
return GetList(key_str, list, try_default_too);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Locale::IsList(const std::wstring & key, bool try_default_too) const
|
bool Locale::GetList(const std::wstring & key, std::vector<std::wstring> & list, bool try_default_too) const
|
||||||
{
|
{
|
||||||
return IsList(key, current_lang, try_default_too);
|
return GetList(key, current_lang, list, try_default_too);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Locale::GetList(const wchar_t * key, size_t lang_id, std::vector<std::wstring> & list, bool try_default_too)
|
||||||
bool Locale::IsList(const wchar_t * key, size_t lang_id, bool try_default_too)
|
|
||||||
{
|
{
|
||||||
key_str = key;
|
key_str = key;
|
||||||
return IsList(key_str, lang_id, try_default_too);
|
return GetList(key_str, lang_id, list, try_default_too);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Locale::IsList(const std::wstring & key, size_t lang_id, bool try_default_too) const
|
bool Locale::GetListInLanguage(const std::wstring & key, size_t lang_id, std::vector<std::wstring> & list) const
|
||||||
{
|
|
||||||
if( GetListInLanguage(key, lang_id) != 0 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( !try_default_too || lang_id == default_lang )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return GetListInLanguage(key, default_lang) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetList(const wchar_t * key, bool try_default_too)
|
|
||||||
{
|
|
||||||
key_str = key;
|
|
||||||
return GetList(key_str, try_default_too);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetList(const std::wstring & key, bool try_default_too) const
|
|
||||||
{
|
|
||||||
return GetList(key, current_lang, try_default_too);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetList(const wchar_t * key, size_t lang_id, bool try_default_too)
|
|
||||||
{
|
|
||||||
key_str = key;
|
|
||||||
return GetList(key_str, lang_id, try_default_too);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> * Locale::GetListInLanguage(const std::wstring & key, size_t lang_id) const
|
|
||||||
{
|
{
|
||||||
if( lang_id < locale_indices.size() )
|
if( lang_id < locale_indices.size() )
|
||||||
{
|
{
|
||||||
|
@ -490,34 +456,26 @@ const std::vector<std::wstring> * Locale::GetListInLanguage(const std::wstring &
|
||||||
|
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
{
|
{
|
||||||
PT::Space::Table::const_iterator i = locale_tab[index].table.find(key);
|
return locale_tab[index].to_list(key, list);
|
||||||
|
|
||||||
if( i != locale_tab[index].table.end() )
|
|
||||||
return &i->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetList(const std::wstring & key,
|
bool Locale::GetList(const std::wstring & key, size_t lang_id, std::vector<std::wstring> & list, bool try_default_too) const
|
||||||
size_t lang_id, bool try_default_too) const
|
|
||||||
{
|
{
|
||||||
const std::vector<std::wstring> * list = GetListInLanguage(key, lang_id);
|
if( GetListInLanguage(key, lang_id, list) )
|
||||||
|
return true;
|
||||||
if( list )
|
|
||||||
return *list;
|
|
||||||
|
|
||||||
if( !try_default_too || lang_id == default_lang )
|
if( !try_default_too || lang_id == default_lang )
|
||||||
return empty_list;
|
return false;
|
||||||
|
|
||||||
list = GetListInLanguage(key, default_lang);
|
|
||||||
|
|
||||||
if( list )
|
if( GetListInLanguage(key, default_lang, list) )
|
||||||
return *list;
|
return true;
|
||||||
|
|
||||||
return empty_list;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -553,7 +511,7 @@ bool Locale::IsKeyByIndex(const std::wstring & key, size_t index, bool try_defau
|
||||||
{
|
{
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
{
|
{
|
||||||
if( locale_tab[index].GetValue(key) != 0 )
|
if( locale_tab[index].get_object_field(key) != 0 )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +540,7 @@ const std::wstring & Locale::GetByIndex(const std::wstring & key, size_t index,
|
||||||
{
|
{
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
{
|
{
|
||||||
const std::wstring * value = locale_tab[index].GetFirstValue(key);
|
const std::wstring * value = locale_tab[index].get_wstr(key.c_str());
|
||||||
|
|
||||||
if( value )
|
if( value )
|
||||||
return *value;
|
return *value;
|
||||||
|
@ -613,47 +571,54 @@ bool Locale::IsListByIndex(const std::wstring & key, size_t index, bool try_defa
|
||||||
{
|
{
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
{
|
{
|
||||||
PT::Space::Table::const_iterator i = locale_tab[index].table.find(key);
|
if( locale_tab[index].has_key(key) )
|
||||||
|
|
||||||
if( i != locale_tab[index].table.end() )
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( try_default_too )
|
if( try_default_too )
|
||||||
return GetListInLanguage(key, default_lang) != 0;
|
return IsListInLanguage(key, default_lang);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetListByIndex(const wchar_t * key,
|
bool Locale::IsListInLanguage(const std::wstring & key, size_t lang_id) const
|
||||||
size_t index, bool try_default_too)
|
|
||||||
{
|
{
|
||||||
key_str = key;
|
if( lang_id < locale_indices.size() )
|
||||||
return GetListByIndex(key_str, index, try_default_too);
|
{
|
||||||
|
size_t index = locale_indices[lang_id];
|
||||||
|
|
||||||
|
if( index < locale_tab.size() )
|
||||||
|
{
|
||||||
|
if( locale_tab[index].has_key(key) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & Locale::GetListByIndex(const std::wstring & key,
|
bool Locale::GetListByIndex(const wchar_t * key, size_t index, std::vector<std::wstring> & list, bool try_default_too)
|
||||||
size_t index, bool try_default_too) const
|
{
|
||||||
|
key_str = key;
|
||||||
|
return GetListByIndex(key_str, index, list, try_default_too);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Locale::GetListByIndex(const std::wstring & key, size_t index, std::vector<std::wstring> & list, bool try_default_too) const
|
||||||
{
|
{
|
||||||
if( index < locale_tab.size() )
|
if( index < locale_tab.size() )
|
||||||
{
|
{
|
||||||
PT::Space::Table::const_iterator i = locale_tab[index].table.find(key);
|
return locale_tab[index].to_list(key, list);
|
||||||
|
|
||||||
if( i != locale_tab[index].table.end() )
|
|
||||||
return i->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( try_default_too )
|
if( try_default_too )
|
||||||
{
|
{
|
||||||
const std::vector<std::wstring> * value = GetListInLanguage(key, default_lang);
|
return GetListInLanguage(key, default_lang, list);
|
||||||
|
|
||||||
if( value )
|
|
||||||
return *value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty_list;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -145,18 +145,10 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// lists
|
// lists
|
||||||
// current limitation:
|
bool GetList(const wchar_t * key, std::vector<std::wstring> & list, bool try_default_too = true);
|
||||||
// we are looking only in 'space.table' so lists with only one item are not found
|
bool GetList(const std::wstring & key, std::vector<std::wstring> & list, bool try_default_too = true) const;
|
||||||
// (SplitSingle(true) was called to the space struct)
|
bool GetList(const wchar_t * key, size_t lang_id, std::vector<std::wstring> & list, bool try_default_too = true);
|
||||||
bool IsList(const wchar_t * key, bool try_default_too = true);
|
bool GetList(const std::wstring & key, size_t lang_id, std::vector<std::wstring> & list, bool try_default_too = true) const;
|
||||||
bool IsList(const std::wstring & key, bool try_default_too = true) const;
|
|
||||||
bool IsList(const wchar_t * key, size_t lang_id, bool try_default_too = true);
|
|
||||||
bool IsList(const std::wstring & key, size_t lang_id, bool try_default_too = true) const;
|
|
||||||
|
|
||||||
const std::vector<std::wstring> & GetList(const wchar_t * key, bool try_default_too = true);
|
|
||||||
const std::vector<std::wstring> & GetList(const std::wstring & key, bool try_default_too = true) const;
|
|
||||||
const std::vector<std::wstring> & GetList(const wchar_t * key, size_t lang_id, bool try_default_too = true);
|
|
||||||
const std::vector<std::wstring> & GetList(const std::wstring & key, size_t lang_id, bool try_default_too = true) const;
|
|
||||||
|
|
||||||
// converting lang_id to an internal index
|
// converting lang_id to an internal index
|
||||||
// returns an index from <0, Size()-1> or size_t(-1) if lang_id is incorrect
|
// returns an index from <0, Size()-1> or size_t(-1) if lang_id is incorrect
|
||||||
|
@ -181,10 +173,9 @@ public:
|
||||||
// (SplitSingle(true) was called to the space struct)
|
// (SplitSingle(true) was called to the space struct)
|
||||||
bool IsListByIndex(const wchar_t * key, size_t index, bool try_default_too = true);
|
bool IsListByIndex(const wchar_t * key, size_t index, bool try_default_too = true);
|
||||||
bool IsListByIndex(const std::wstring & key, size_t index, bool try_default_too = true) const;
|
bool IsListByIndex(const std::wstring & key, size_t index, bool try_default_too = true) const;
|
||||||
const std::vector<std::wstring> & GetListByIndex(const wchar_t * key, size_t index,
|
|
||||||
bool try_default_too = true);
|
bool GetListByIndex(const wchar_t * key, size_t index, std::vector<std::wstring> & list, bool try_default_too = true);
|
||||||
const std::vector<std::wstring> & GetListByIndex(const std::wstring & key, size_t index,
|
bool GetListByIndex(const std::wstring & key, size_t index, std::vector<std::wstring> & list, bool try_default_too = true) const;
|
||||||
bool try_default_too = true) const;
|
|
||||||
|
|
||||||
|
|
||||||
// url substitution characters
|
// url substitution characters
|
||||||
|
@ -227,7 +218,8 @@ private:
|
||||||
size_t SubstFindIndex(const std::vector<SubstItem> & vect, wchar_t val);
|
size_t SubstFindIndex(const std::vector<SubstItem> & vect, wchar_t val);
|
||||||
wchar_t SubstFind(const std::vector<SubstItem> & vect, wchar_t val);
|
wchar_t SubstFind(const std::vector<SubstItem> & vect, wchar_t val);
|
||||||
const std::wstring * GetKeyInLanguage(const std::wstring & key, size_t lang_id) const;
|
const std::wstring * GetKeyInLanguage(const std::wstring & key, size_t lang_id) const;
|
||||||
const std::vector<std::wstring> * GetListInLanguage(const std::wstring & key, size_t lang_id) const;
|
bool GetListInLanguage(const std::wstring & key, size_t lang_id, std::vector<std::wstring> & list) const;
|
||||||
|
bool IsListInLanguage(const std::wstring & key, size_t lang_id) const;
|
||||||
|
|
||||||
|
|
||||||
// locale files
|
// locale files
|
||||||
|
@ -264,7 +256,6 @@ private:
|
||||||
std::string file_name;
|
std::string file_name;
|
||||||
std::wstring key_str;
|
std::wstring key_str;
|
||||||
const std::wstring empty; // used when returning a non existing key from loc_tab (or in LangToFileName)
|
const std::wstring empty; // used when returning a non existing key from loc_tab (or in LangToFileName)
|
||||||
const std::vector<std::wstring> empty_list; // the same as above
|
|
||||||
std::string adir1, adir2;
|
std::string adir1, adir2;
|
||||||
std::wstring pattern_value;
|
std::wstring pattern_value;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010-2018, Tomasz Sowa
|
* Copyright (c) 2010-2021, 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
|
||||||
|
@ -143,7 +143,7 @@ void print_date_nice(Info & i, const PT::Date & date)
|
||||||
// cannot be a const reference at the moment (PT::Space is used)
|
// cannot be a const reference at the moment (PT::Space is used)
|
||||||
void print_user_name(Info & i, User & user)
|
void print_user_name(Info & i, User & user)
|
||||||
{
|
{
|
||||||
std::wstring * dname = user.aenv.GetFirstValue(L"display_name");
|
std::wstring * dname = user.aenv.get_wstr(L"display_name");
|
||||||
|
|
||||||
if( dname && !IsWhite(*dname, true) )
|
if( dname && !IsWhite(*dname, true) )
|
||||||
i.out << *dname;
|
i.out << *dname;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -75,12 +75,14 @@ void copy_space(const std::vector<Ezc::Var> & params, std::vector<std::wstring>
|
||||||
|
|
||||||
PT::Space * find_space(const std::vector<Ezc::Var> & params, PT::Space & space, size_t level = 0)
|
PT::Space * find_space(const std::vector<Ezc::Var> & params, PT::Space & space, size_t level = 0)
|
||||||
{
|
{
|
||||||
if( level + 1 < params.size() )
|
if( level + 1 < params.size() && space.child_spaces )
|
||||||
{
|
{
|
||||||
for(size_t i=0 ; i<space.spaces.size() ; ++i)
|
for(size_t i=0 ; i<space.child_spaces->size() ; ++i)
|
||||||
{
|
{
|
||||||
if( space.spaces[i]->name == params[level].str )
|
PT::Space & child = *(*space.child_spaces)[i];
|
||||||
return find_space(params, *space.spaces[i], level+1);
|
|
||||||
|
if( child.name && *child.name == params[level].str )
|
||||||
|
return find_space(params, child, level+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is no such a space
|
// there is no such a space
|
||||||
|
@ -155,7 +157,7 @@ void space_value(Info & i, PT::Space & space, bool escape)
|
||||||
if( space_info.last_space )
|
if( space_info.last_space )
|
||||||
{
|
{
|
||||||
const std::wstring & param = i.params.back().str;
|
const std::wstring & param = i.params.back().str;
|
||||||
const std::wstring * value = space_info.last_space->GetFirstValue(param);
|
const std::wstring * value = space_info.last_space->get_wstr(param.c_str());
|
||||||
|
|
||||||
if( value )
|
if( value )
|
||||||
{
|
{
|
||||||
|
@ -193,7 +195,7 @@ void space_list_tab(Info & i, PT::Space & space)
|
||||||
PT::Space * dst_space = find_space(i.params, space);
|
PT::Space * dst_space = find_space(i.params, space);
|
||||||
|
|
||||||
if( dst_space )
|
if( dst_space )
|
||||||
dst_space->ListText(i.params.back().str, stack_item->values);
|
dst_space->to_list(i.params.back().str, stack_item->values);
|
||||||
|
|
||||||
i.res = i.iter < stack_item->values.size();
|
i.res = i.iter < stack_item->values.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,11 +899,15 @@ using namespace TemplatesFunctions;
|
||||||
|
|
||||||
for(size_t i=0 ; i<TemplatesFunctions::locale.Size() ; ++i)
|
for(size_t i=0 ; i<TemplatesFunctions::locale.Size() ; ++i)
|
||||||
{
|
{
|
||||||
if( TemplatesFunctions::locale.IsKeyByIndex(L"html_lang_attr_value", i, false) &&
|
if( TemplatesFunctions::locale.IsKeyByIndex(L"winix_html_lang_attr", i, false) &&
|
||||||
TemplatesFunctions::locale.IsListByIndex(L"language_orphans", i, false) )
|
TemplatesFunctions::locale.IsListByIndex(L"language_orphans", i, false) )
|
||||||
{
|
{
|
||||||
html_filter.AssignOrphans(TemplatesFunctions::locale.GetByIndex(L"html_lang_attr_value", i, false),
|
const std::wstring & html_lang_attr = TemplatesFunctions::locale.GetByIndex(L"winix_html_lang_attr", i, false);
|
||||||
TemplatesFunctions::locale.GetListByIndex(L"language_orphans", i, false));
|
|
||||||
|
std::vector<std::wstring> orphans;
|
||||||
|
TemplatesFunctions::locale.GetListByIndex(L"language_orphans", i, orphans, false);
|
||||||
|
|
||||||
|
html_filter.AssignOrphans(html_lang_attr, orphans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
* Copyright (c) 2012-2021, 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
|
||||||
|
@ -477,7 +477,7 @@ TexTextStream & TexTextStream::operator<<(const PT::Space & space)
|
||||||
tmp_stream.Clear();
|
tmp_stream.Clear();
|
||||||
// !! IMPROVE ME
|
// !! IMPROVE ME
|
||||||
// we can calculate how many memory is needed beforehand
|
// we can calculate how many memory is needed beforehand
|
||||||
space.Serialize(tmp_stream, true, false);
|
space.serialize_to_space_stream(tmp_stream, true);
|
||||||
operator<<(tmp_stream.Str());
|
operator<<(tmp_stream.Str());
|
||||||
tmp_stream.Clear();
|
tmp_stream.Clear();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue