added: parameters consist of a name and a value now
sample: /dir/dir2/function/paramname:paramvalue removed: TemplatesMisc namespace git-svn-id: svn://ttmath.org/publicrep/winix/trunk@618 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
76e32703ac
commit
50cb88c5ed
|
@ -23,7 +23,7 @@ void Content::FunNode()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long id = atol( request.param_table[0]->c_str() );
|
long id = atol( request.param_table[0].name.c_str() );
|
||||||
|
|
||||||
RedirectTo(id);
|
RedirectTo(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,19 +117,49 @@ void FunctionParser::ParseFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void FunctionParser::ParseParams(const std::string & par)
|
||||||
|
{
|
||||||
|
Param param;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if( par.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// looking for the first colon ':'
|
||||||
|
for(i=0 ; i<par.size() && par[i] != ':' ; ++i);
|
||||||
|
|
||||||
|
if( i == par.size() )
|
||||||
|
{
|
||||||
|
// there is no a colon
|
||||||
|
param.name = par;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( i > 0 )
|
||||||
|
param.name = par.substr(0, i);
|
||||||
|
|
||||||
|
if( i < par.size() - 1 )
|
||||||
|
param.value = par.substr(i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
request.param_table.push_back(param);
|
||||||
|
|
||||||
|
log << log3 << "FP: Param: name=" << param.name << ", value=" << param.value << logend;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FunctionParser::ParseParams()
|
void FunctionParser::ParseParams()
|
||||||
{
|
{
|
||||||
while( true )
|
for( ; true ; ++get_index )
|
||||||
{
|
{
|
||||||
SkipEmptyString("FP: Params: skipped empty string");
|
SkipEmptyString("FP: Params: skipped empty string");
|
||||||
|
|
||||||
if( get_index == get_table_len )
|
if( get_index == get_table_len )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
request.param_table.push_back( &request.get_table[get_index] );
|
ParseParams(request.get_table[get_index]);
|
||||||
log << log3 << "FP: Params: " << request.get_table[get_index] << logend;
|
|
||||||
|
|
||||||
++get_index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ class FunctionParser
|
||||||
void ParseItem();
|
void ParseItem();
|
||||||
bool IsAppFunction();
|
bool IsAppFunction();
|
||||||
void ParseFunction();
|
void ParseFunction();
|
||||||
|
void ParseParams(const std::string & par);
|
||||||
void ParseParams();
|
void ParseParams();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -535,13 +535,15 @@ bool compressing = data.compression && role == responder && redirect_to.empty()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Request::IsParam(const char * s)
|
bool Request::IsParam(const char * param_name)
|
||||||
{
|
{
|
||||||
std::vector<std::string*>::iterator i;
|
ParamTable::iterator i;
|
||||||
|
|
||||||
for(i=param_table.begin() ; i!=param_table.end() ; ++i)
|
for(i=param_table.begin() ; i!=param_table.end() ; ++i)
|
||||||
{
|
{
|
||||||
if( **i == s )
|
// !! make sure that exists std::string::operator==(const char*)
|
||||||
|
// (optimization)
|
||||||
|
if( i->name == param_name )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,6 +551,21 @@ return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string & Request::ParamValue(const char * param_name)
|
||||||
|
{
|
||||||
|
ParamTable::iterator i;
|
||||||
|
|
||||||
|
for(i=param_table.begin() ; i!=param_table.end() ; ++i)
|
||||||
|
{
|
||||||
|
if( i->name == param_name )
|
||||||
|
{
|
||||||
|
return i->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str_empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Request::CanChangeUser(const Item & item, long new_user_id)
|
bool Request::CanChangeUser(const Item & item, long new_user_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct Request
|
||||||
// request id
|
// request id
|
||||||
// is incremented for each request and is never 0
|
// is incremented for each request and is never 0
|
||||||
// (from -1 will be incremented twice)
|
// (from -1 will be incremented twice)
|
||||||
// it's used for some optimalization e.g. in templates
|
// it's used for some optimalizations e.g. in templates
|
||||||
size_t id;
|
size_t id;
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ struct Request
|
||||||
// null if there is no a function
|
// null if there is no a function
|
||||||
Function * pfunction;
|
Function * pfunction;
|
||||||
|
|
||||||
// !! moze nazwac to poprostu param?
|
// parameters (name:value)
|
||||||
std::vector<std::string*> param_table;
|
ParamTable param_table;
|
||||||
|
|
||||||
Error status;
|
Error status;
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ struct Request
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
bool IsParam(const char * s);
|
bool IsParam(const char * param_name);
|
||||||
|
const std::string & ParamValue(const char * param_name); // returns empty string if there is no such a parameter
|
||||||
|
|
||||||
void SetCookie(const char * name, const char * value, tm * expires = 0);
|
void SetCookie(const char * name, const char * value, tm * expires = 0);
|
||||||
void SetCookie(const char * name, long value, tm * expires = 0);
|
void SetCookie(const char * name, long value, tm * expires = 0);
|
||||||
|
@ -200,6 +201,8 @@ private:
|
||||||
// it contains '\0'
|
// it contains '\0'
|
||||||
const char char_empty;
|
const char char_empty;
|
||||||
|
|
||||||
|
// used in ParamValue(const char * param_name) when there is no such a param
|
||||||
|
const std::string str_empty;
|
||||||
|
|
||||||
PostMultiParser post_multi_parser;
|
PostMultiParser post_multi_parser;
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,21 @@ struct PostFile
|
||||||
std::string tmp_filename; // file with content (in /tmp)
|
std::string tmp_filename; // file with content (in /tmp)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// parameters from get name:value
|
||||||
|
struct Param
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// some global types used by Request class
|
// some global types used by Request class
|
||||||
typedef std::vector<std::string> GetTable;
|
typedef std::vector<std::string> GetTable;
|
||||||
typedef std::map<std::string, std::string> PostTable;
|
typedef std::map<std::string, std::string> PostTable;
|
||||||
typedef std::map<std::string, PostFile> PostFileTable;
|
typedef std::map<std::string, PostFile> PostFileTable;
|
||||||
typedef std::map<std::string, std::string> CookieTable;
|
typedef std::map<std::string, std::string> CookieTable;
|
||||||
|
typedef std::vector<Param> ParamTable;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,14 @@ misc.o: ../core/users.h ../core/user.h ../core/ugcontainer.h ../core/log.h
|
||||||
misc.o: ../core/groups.h ../core/group.h ../core/functions.h
|
misc.o: ../core/groups.h ../core/group.h ../core/functions.h
|
||||||
misc.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h
|
misc.o: ../core/function.h ../core/lastcontainer.h ../core/mounts.h
|
||||||
misc.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/loadavg.h
|
misc.o: ../core/mount.h ../core/error.h ../core/rebus.h ../core/loadavg.h
|
||||||
misc.o: ../core/misc.h misc.h localefilter.h ../core/locale.h
|
misc.o: ../core/misc.h ../core/request.h ../core/requesttypes.h
|
||||||
misc.o: ../confparser/confparser.h
|
misc.o: ../core/session.h ../core/plugindata.h ../core/thread.h
|
||||||
|
misc.o: ../core/compress.h ../core/acceptencodingparser.h
|
||||||
|
misc.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
|
||||||
|
misc.o: ../core/postmultiparser.h ../core/ticket.h templates.h
|
||||||
|
misc.o: patterncacher.h ../core/item.h misc.h localefilter.h ../core/locale.h
|
||||||
|
misc.o: ../confparser/confparser.h ckeditorgetparser.h
|
||||||
|
misc.o: ../core/httpsimpleparser.h ../core/log.h indexpatterns.h
|
||||||
mount.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h
|
mount.o: templates.h patterncacher.h ../core/item.h misc.h localefilter.h
|
||||||
mount.o: ../core/locale.h ../confparser/confparser.h ckeditorgetparser.h
|
mount.o: ../core/locale.h ../confparser/confparser.h ckeditorgetparser.h
|
||||||
mount.o: ../core/httpsimpleparser.h ../core/log.h indexpatterns.h
|
mount.o: ../core/httpsimpleparser.h ../core/log.h indexpatterns.h
|
||||||
|
|
|
@ -263,14 +263,14 @@ void item_date_modification(Info & i)
|
||||||
void item_date_creation_nice(Info & i)
|
void item_date_creation_nice(Info & i)
|
||||||
{
|
{
|
||||||
tm * ptm = &request.item.date_creation;
|
tm * ptm = &request.item.date_creation;
|
||||||
TemplatesMisc::print_date_nice(i, ptm);
|
print_date_nice(i, ptm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void item_date_modification_nice(Info & i)
|
void item_date_modification_nice(Info & i)
|
||||||
{
|
{
|
||||||
tm * ptm = &request.item.date_modification;
|
tm * ptm = &request.item.date_modification;
|
||||||
TemplatesMisc::print_date_nice(i, ptm);
|
print_date_nice(i, ptm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ void item_tab_date_creation_nice(Info & i)
|
||||||
if( item_index < request.item_table.size() )
|
if( item_index < request.item_table.size() )
|
||||||
{
|
{
|
||||||
tm * ptm = &request.item_table[item_index].date_creation;
|
tm * ptm = &request.item_table[item_index].date_creation;
|
||||||
TemplatesMisc::print_date_nice(i, ptm);
|
print_date_nice(i, ptm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ void item_tab_date_modification_nice(Info & i)
|
||||||
if( item_index < request.item_table.size() )
|
if( item_index < request.item_table.size() )
|
||||||
{
|
{
|
||||||
tm * ptm = &request.item_table[item_index].date_modification;
|
tm * ptm = &request.item_table[item_index].date_modification;
|
||||||
TemplatesMisc::print_date_nice(i, ptm);
|
print_date_nice(i, ptm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,15 @@ void ls_ckeditor_funnum_browse(Info & i)
|
||||||
ls_ckeditor_reqid = request.id;
|
ls_ckeditor_reqid = request.id;
|
||||||
ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info
|
ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info
|
||||||
|
|
||||||
if( !request.param_table.empty() )
|
if( !request.get_table.empty() )
|
||||||
{
|
{
|
||||||
const char * str = request.param_table[request.param_table.size()-1]->c_str() + 1; // the first char is '?'
|
size_t last = request.get_table.size()-1;
|
||||||
ckeditor_getparser.Parse(str);
|
|
||||||
|
if( !request.get_table[last].empty() )
|
||||||
|
{
|
||||||
|
const char * str = request.get_table[last].c_str() + 1; // the first char is '?'
|
||||||
|
ckeditor_getparser.Parse(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ls_ckeditor_funnum = ckeditor_getparser.fun_num;
|
ls_ckeditor_funnum = ckeditor_getparser.fun_num;
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
|
|
||||||
#include "../core/data.h"
|
#include "../core/data.h"
|
||||||
#include "../core/misc.h"
|
#include "../core/misc.h"
|
||||||
|
#include "../core/request.h"
|
||||||
|
#include "templates.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
namespace TemplatesMisc
|
namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,6 +79,28 @@ size_t loc, pat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace TemplatesMisc
|
|
||||||
|
int ParseCKeditorFun()
|
||||||
|
{
|
||||||
|
ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info
|
||||||
|
|
||||||
|
if( !request.get_table.empty() )
|
||||||
|
{
|
||||||
|
size_t last = request.get_table.size()-1;
|
||||||
|
|
||||||
|
if( !request.get_table[last].empty() )
|
||||||
|
{
|
||||||
|
const char * str = request.get_table[last].c_str() + 1; // the first char is '?'
|
||||||
|
ckeditor_getparser.Parse(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ckeditor_getparser.fun_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace TemplatesFunctions
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace TemplatesMisc
|
namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
// table: [language][file]
|
// table: [language][file]
|
||||||
typedef std::vector<std::vector<Ezc::Pattern> > Patterns;
|
typedef std::vector<std::vector<Ezc::Pattern> > Patterns;
|
||||||
|
@ -36,7 +36,7 @@ void ClearPatterns(Patterns & patterns, size_t len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace TemplatesMisc
|
} // namespace TemplatesFunctions
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
namespace TemplatesFunctions
|
namespace TemplatesFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
IndexPatterns index_patterns;
|
IndexPatterns index_patterns;
|
||||||
TemplatesMisc::Patterns patterns;
|
Patterns patterns;
|
||||||
Ezc::Functions functions;
|
Ezc::Functions functions;
|
||||||
PatternCacher pattern_cacher;
|
PatternCacher pattern_cacher;
|
||||||
Locale locale;
|
Locale locale;
|
||||||
LocaleFilter locale_filter;
|
LocaleFilter locale_filter;
|
||||||
CKEditorGetParser ckeditor_getparser;
|
CKEditorGetParser ckeditor_getparser;
|
||||||
|
|
||||||
|
|
||||||
const std::string empty; // used by GenerateRunRaw()
|
const std::string empty; // used by GenerateRunRaw()
|
||||||
|
@ -485,7 +485,7 @@ void Templates::ReadFile(TemplatesFunctions::Pat pat, const char * file)
|
||||||
{
|
{
|
||||||
using namespace TemplatesFunctions;
|
using namespace TemplatesFunctions;
|
||||||
|
|
||||||
TemplatesMisc::Read(patterns, static_cast<size_t>(pat), locale, locale_filter, file);
|
Read(patterns, static_cast<size_t>(pat), locale, locale_filter, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ void Templates::ClearPatterns()
|
||||||
{
|
{
|
||||||
using namespace TemplatesFunctions;
|
using namespace TemplatesFunctions;
|
||||||
|
|
||||||
TemplatesMisc::ClearPatterns(patterns, pat_last);
|
TemplatesFunctions::ClearPatterns(patterns, pat_last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,11 +69,11 @@ namespace TemplatesFunctions
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern IndexPatterns index_patterns;
|
extern IndexPatterns index_patterns;
|
||||||
extern TemplatesMisc::Patterns patterns;
|
extern Patterns patterns;
|
||||||
extern PatternCacher pattern_cacher;
|
extern PatternCacher pattern_cacher;
|
||||||
extern Locale locale;
|
extern Locale locale;
|
||||||
extern Ezc::Functions functions;
|
extern Ezc::Functions functions;
|
||||||
extern CKEditorGetParser ckeditor_getparser;
|
extern CKEditorGetParser ckeditor_getparser;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ void thread_tab_last_item_date_modification_nice(Info & i)
|
||||||
{
|
{
|
||||||
if( thread_tab_index < request.thread_tab.size() )
|
if( thread_tab_index < request.thread_tab.size() )
|
||||||
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
||||||
TemplatesMisc::print_date_nice(i, &request.thread_tab[thread_tab_index].last_item.date_modification);
|
print_date_nice(i, &request.thread_tab[thread_tab_index].last_item.date_modification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,15 @@ void upload_ckeditor_funnum(Info & i)
|
||||||
upload_ckeditor_reqid = request.id;
|
upload_ckeditor_reqid = request.id;
|
||||||
ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info
|
ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info
|
||||||
|
|
||||||
if( !request.param_table.empty() )
|
if( !request.get_table.empty() )
|
||||||
{
|
{
|
||||||
const char * str = request.param_table[request.param_table.size()-1]->c_str() + 1; // the first char is '?'
|
size_t last = request.get_table.size()-1;
|
||||||
ckeditor_getparser.Parse(str);
|
|
||||||
|
if( !request.get_table[last].empty() )
|
||||||
|
{
|
||||||
|
const char * str = request.get_table[last].c_str() + 1; // the first char is '?'
|
||||||
|
ckeditor_getparser.Parse(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_fun_num = ckeditor_getparser.fun_num;
|
upload_fun_num = ckeditor_getparser.fun_num;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
namespace TemplatesNotifyFunctions
|
namespace TemplatesNotifyFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
TemplatesMisc::Patterns patterns;
|
Patterns patterns;
|
||||||
Ezc::Functions functions;
|
Ezc::Functions functions;
|
||||||
Locale locale;
|
Locale locale;
|
||||||
LocaleFilter locale_filter;
|
LocaleFilter locale_filter;
|
||||||
|
@ -63,7 +63,7 @@ void TemplatesNotify::ClearPatterns()
|
||||||
using namespace TemplatesNotifyFunctions;
|
using namespace TemplatesNotifyFunctions;
|
||||||
|
|
||||||
|
|
||||||
TemplatesMisc::ClearPatterns(patterns, pat_last);
|
TemplatesFunctions::ClearPatterns(patterns, pat_last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ using namespace TemplatesNotifyFunctions;
|
||||||
void TemplatesNotify::Read()
|
void TemplatesNotify::Read()
|
||||||
{
|
{
|
||||||
using namespace TemplatesNotifyFunctions;
|
using namespace TemplatesNotifyFunctions;
|
||||||
using namespace TemplatesMisc;
|
|
||||||
|
|
||||||
Locale::Lang lang = Locale::StrToLang(data.locale_str);
|
Locale::Lang lang = Locale::StrToLang(data.locale_str);
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ using namespace TemplatesMisc;
|
||||||
|
|
||||||
ClearPatterns();
|
ClearPatterns();
|
||||||
locale.Read(data.locale_dir, data.locale_dir_default);
|
locale.Read(data.locale_dir, data.locale_dir_default);
|
||||||
TemplatesMisc::Read(patterns, pat_email_notify, locale, locale_filter, "notify_email.txt", true);
|
TemplatesFunctions::Read(patterns, pat_email_notify, locale, locale_filter, "notify_email.txt", true);
|
||||||
|
|
||||||
notify_msg = 0;
|
notify_msg = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace TemplatesNotifyFunctions
|
||||||
|
|
||||||
typedef std::vector<std::vector<Ezc::Pattern> > Patterns;
|
typedef std::vector<std::vector<Ezc::Pattern> > Patterns;
|
||||||
|
|
||||||
extern TemplatesMisc::Patterns patterns;
|
extern Patterns patterns;
|
||||||
extern NotifyMsg * notify_msg;
|
extern NotifyMsg * notify_msg;
|
||||||
|
|
||||||
void notify_item_added(Info & i);
|
void notify_item_added(Info & i);
|
||||||
|
|
Loading…
Reference in New Issue