the first part of reimplementing has been done
now we have app object and singletons are only: log logn plugin and app git-svn-id: svn://ttmath.org/publicrep/winix/trunk@628 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -8,12 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "templates.h"
|
||||
#include "../core/request.h"
|
||||
#include "../core/data.h"
|
||||
#include "../core/db.h"
|
||||
#include "../core/log.h"
|
||||
#include "../core/misc.h"
|
||||
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
namespace TemplatesFunctions
|
||||
@@ -23,9 +19,9 @@ namespace TemplatesFunctions
|
||||
|
||||
void dir(Info & i)
|
||||
{
|
||||
for(size_t a=0 ; a<request.dir_table.size() ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size() ; ++a)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table[a]->url);
|
||||
HtmlEscape(i.out, request->dir_table[a]->url);
|
||||
i.out << '/';
|
||||
}
|
||||
}
|
||||
@@ -33,11 +29,11 @@ void dir(Info & i)
|
||||
|
||||
void dir_without_slash(Info & i)
|
||||
{
|
||||
for(size_t a=0 ; a<request.dir_table.size() ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size() ; ++a)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table[a]->url);
|
||||
HtmlEscape(i.out, request->dir_table[a]->url);
|
||||
|
||||
if( a < request.dir_table.size()-1 )
|
||||
if( a < request->dir_table.size()-1 )
|
||||
i.out << '/';
|
||||
}
|
||||
}
|
||||
@@ -45,12 +41,12 @@ void dir_without_slash(Info & i)
|
||||
|
||||
void dir_parent(Info & i)
|
||||
{
|
||||
if( request.dir_table.empty() )
|
||||
if( request->dir_table.empty() )
|
||||
return;
|
||||
|
||||
for(size_t a=0 ; a<request.dir_table.size()-1 ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size()-1 ; ++a)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table[a]->url);
|
||||
HtmlEscape(i.out, request->dir_table[a]->url);
|
||||
i.out << '/';
|
||||
}
|
||||
}
|
||||
@@ -58,14 +54,14 @@ void dir_parent(Info & i)
|
||||
|
||||
void dir_parent_without_slash(Info & i)
|
||||
{
|
||||
if( request.dir_table.empty() )
|
||||
if( request->dir_table.empty() )
|
||||
return;
|
||||
|
||||
for(size_t a=0 ; a<request.dir_table.size()-1 ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size()-1 ; ++a)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table[a]->url);
|
||||
HtmlEscape(i.out, request->dir_table[a]->url);
|
||||
|
||||
if( request.dir_table.size()>=2 && a<request.dir_table.size()-2 )
|
||||
if( request->dir_table.size()>=2 && a<request->dir_table.size()-2 )
|
||||
i.out << '/';
|
||||
}
|
||||
}
|
||||
@@ -77,9 +73,9 @@ void dir_can_read_exec(Info & i)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
for(size_t a=0 ; a<request.dir_table.size() ; ++a)
|
||||
for(size_t a=0 ; a<request->dir_table.size() ; ++a)
|
||||
{
|
||||
if( !request.HasReadExecAccess(*request.dir_table[a]) )
|
||||
if( !system->HasReadExecAccess(*request->dir_table[a]) )
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
@@ -92,7 +88,7 @@ bool result = true;
|
||||
|
||||
void dir_can_write(Info & i)
|
||||
{
|
||||
i.res = request.HasWriteAccess(*request.dir_table.back());
|
||||
i.res = system->HasWriteAccess(*request->dir_table.back());
|
||||
}
|
||||
|
||||
|
||||
@@ -101,18 +97,18 @@ void dir_can_remove(Info & i)
|
||||
bool result = true;
|
||||
|
||||
|
||||
if( request.dir_table.size() == 1 )
|
||||
if( request->dir_table.size() == 1 )
|
||||
{
|
||||
// rm for the root dir
|
||||
// only the superuser can do it
|
||||
if( !request.session->puser || !request.session->puser->super_user )
|
||||
if( !request->session->puser || !request->session->puser->super_user )
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item * last_but_one_dir = *(--(--request.dir_table.end()));
|
||||
Item * last_but_one_dir = *(--(--request->dir_table.end()));
|
||||
|
||||
if( !request.HasWriteAccess(*last_but_one_dir) )
|
||||
if( !system->HasWriteAccess(*last_but_one_dir) )
|
||||
result = false;
|
||||
}
|
||||
|
||||
@@ -122,26 +118,20 @@ bool result = true;
|
||||
|
||||
void dir_can_use_emacs(Info & i)
|
||||
{
|
||||
if( !request.dir_table.empty() )
|
||||
i.res = request.CanUseEmacs(*request.dir_table.back(), true);
|
||||
else
|
||||
i.res = false;
|
||||
i.res = functions->fun_emacs.HasAccess();
|
||||
}
|
||||
|
||||
|
||||
void dir_can_use_mkdir(Info & i)
|
||||
{
|
||||
if( !request.dir_table.empty() )
|
||||
i.res = request.CanUseMkdir(*request.dir_table.back(), true);
|
||||
else
|
||||
i.res = false;
|
||||
i.res = functions->fun_mkdir.HasAccess();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static std::vector<Item*> dir_childs_table;
|
||||
static size_t dir_childs_index;
|
||||
// request.id is never 0 and we can start dir_childs_reqid from 0
|
||||
// request->id is never 0 and we can start dir_childs_reqid from 0
|
||||
static size_t dir_childs_reqid = 0;
|
||||
|
||||
// is the first directory the parent ('..')
|
||||
@@ -150,22 +140,22 @@ static bool dir_childs_has_parent;
|
||||
|
||||
void dir_childs_tab(Info & i)
|
||||
{
|
||||
if( dir_childs_reqid != request.id )
|
||||
if( dir_childs_reqid != request->id )
|
||||
{
|
||||
dir_childs_reqid = request.id;
|
||||
dir_childs_reqid = request->id;
|
||||
dir_childs_table.clear();
|
||||
dir_childs_has_parent = false;
|
||||
|
||||
if( !request.dir_table.empty() )
|
||||
if( !request->dir_table.empty() )
|
||||
{
|
||||
if( request.dir_table.size() >= 2 && i.par == "with_parent")
|
||||
if( request->dir_table.size() >= 2 && i.par == "with_parent")
|
||||
{
|
||||
Item * dir_up = request.dir_table[request.dir_table.size()-2];
|
||||
Item * dir_up = request->dir_table[request->dir_table.size()-2];
|
||||
dir_childs_table.push_back(dir_up);
|
||||
dir_childs_has_parent = true;
|
||||
}
|
||||
|
||||
data.dirs.GetDirChilds(request.dir_table.back()->id, dir_childs_table);
|
||||
system->dirs.GetDirChilds(request->dir_table.back()->id, dir_childs_table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +191,7 @@ void dir_childs_tab_user(Info & i)
|
||||
if( dir_childs_index < dir_childs_table.size() )
|
||||
{
|
||||
long user_id = dir_childs_table[dir_childs_index]->user_id;
|
||||
User * puser = data.users.GetUser(user_id);
|
||||
User * puser = system->users.GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
@@ -224,7 +214,7 @@ void dir_childs_tab_group(Info & i)
|
||||
if( dir_childs_index < dir_childs_table.size() )
|
||||
{
|
||||
long group_id = dir_childs_table[dir_childs_index]->group_id;
|
||||
Group * pgroup = data.groups.GetGroup(group_id);
|
||||
Group * pgroup = system->groups.GetGroup(group_id);
|
||||
|
||||
if( pgroup )
|
||||
HtmlEscape(i.out, pgroup->name);
|
||||
@@ -244,24 +234,24 @@ static size_t dir_index;
|
||||
void dir_tab(Info & i)
|
||||
{
|
||||
dir_index = i.iter;
|
||||
i.res = dir_index < request.dir_table.size();
|
||||
i.res = dir_index < request->dir_table.size();
|
||||
}
|
||||
|
||||
|
||||
void dir_tab_url(Info & i)
|
||||
{
|
||||
if( dir_index < request.dir_table.size() )
|
||||
HtmlEscape(i.out, request.dir_table[dir_index]->url);
|
||||
if( dir_index < request->dir_table.size() )
|
||||
HtmlEscape(i.out, request->dir_table[dir_index]->url);
|
||||
}
|
||||
|
||||
|
||||
void dir_tab_link(Info & i)
|
||||
{
|
||||
i.out << data.base_url;
|
||||
i.out << config->base_url;
|
||||
|
||||
for(size_t a = 0 ; a <= dir_index && a < request.dir_table.size() ; ++a)
|
||||
for(size_t a = 0 ; a <= dir_index && a < request->dir_table.size() ; ++a)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table[a]->url);
|
||||
HtmlEscape(i.out, request->dir_table[a]->url);
|
||||
i.out << '/';
|
||||
}
|
||||
}
|
||||
@@ -274,23 +264,23 @@ static size_t dir_last_default_item_reqid = 0;
|
||||
|
||||
void dir_last_default_item_init()
|
||||
{
|
||||
if( dir_last_default_item_reqid == request.id )
|
||||
if( dir_last_default_item_reqid == request->id )
|
||||
return;
|
||||
|
||||
dir_last_default_item_reqid = request.id;
|
||||
dir_last_default_item_reqid = request->id;
|
||||
|
||||
dir_last_default_item.Clear();
|
||||
|
||||
if( request.dir_table.empty() )
|
||||
if( request->dir_table.empty() )
|
||||
return;
|
||||
|
||||
long default_item = request.dir_table.back()->default_item;
|
||||
long default_item = request->dir_table.back()->default_item;
|
||||
|
||||
if( default_item == -1 )
|
||||
return;
|
||||
|
||||
std::vector<Item> item_table; // !! tymczasowo, nie bedzie tego po zmianie interfejsu dla Db
|
||||
db.GetItem(item_table, default_item);
|
||||
db->GetItem(item_table, default_item);
|
||||
|
||||
if( item_table.empty() )
|
||||
return;
|
||||
@@ -307,7 +297,7 @@ void dir_last_default_item_dir(Info & i)
|
||||
std::string path;
|
||||
|
||||
if( dir_last_default_item.parent_id != -1 )
|
||||
if( data.dirs.MakePath(dir_last_default_item.parent_id, path) )
|
||||
if( system->dirs.MakePath(dir_last_default_item.parent_id, path) )
|
||||
HtmlEscape(i.out, path);
|
||||
}
|
||||
|
||||
@@ -322,7 +312,7 @@ void dir_last_default_item_url(Info & i)
|
||||
|
||||
void dir_last_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table.back()->subject);
|
||||
HtmlEscape(i.out, request->dir_table.back()->subject);
|
||||
}
|
||||
|
||||
|
||||
@@ -331,14 +321,14 @@ void dir_last_info(Info & i)
|
||||
if( static_cast<size_t>(locale.GetLang()) >= patterns.size() )
|
||||
return;
|
||||
|
||||
Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_dir_last_info], functions);
|
||||
Ezc::Generator gen(i.out, patterns[locale.GetLang()][pat_dir_last_info], ezc_functions);
|
||||
gen.Generate();
|
||||
}
|
||||
|
||||
|
||||
void dir_last_user(Info & i)
|
||||
{
|
||||
User * puser = data.users.GetUser(request.dir_table.back()->user_id);
|
||||
User * puser = system->users.GetUser(request->dir_table.back()->user_id);
|
||||
|
||||
if( puser )
|
||||
HtmlEscape(i.out, puser->name);
|
||||
@@ -346,8 +336,8 @@ void dir_last_user(Info & i)
|
||||
{
|
||||
i.out << "~";
|
||||
|
||||
if( !request.dir_table.back()->guest_name.empty() )
|
||||
HtmlEscape(i.out, request.dir_table.back()->guest_name);
|
||||
if( !request->dir_table.back()->guest_name.empty() )
|
||||
HtmlEscape(i.out, request->dir_table.back()->guest_name);
|
||||
else
|
||||
i.out << "guest"; // !! dodac do konfiga
|
||||
}
|
||||
@@ -356,19 +346,19 @@ void dir_last_user(Info & i)
|
||||
|
||||
void dir_last_url(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.dir_table.back()->url);
|
||||
HtmlEscape(i.out, request->dir_table.back()->url);
|
||||
}
|
||||
|
||||
|
||||
void dir_last_url_is(Info & i)
|
||||
{
|
||||
i.res = request.dir_table.back()->url == i.par;
|
||||
i.res = request->dir_table.back()->url == i.par;
|
||||
}
|
||||
|
||||
|
||||
void dir_last_date_creation(Info & i)
|
||||
{
|
||||
tm * ptm = &request.dir_table.back()->date_creation;
|
||||
tm * ptm = &request->dir_table.back()->date_creation;
|
||||
|
||||
i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
}
|
||||
@@ -376,7 +366,7 @@ void dir_last_date_creation(Info & i)
|
||||
|
||||
void dir_last_date_modification(Info & i)
|
||||
{
|
||||
tm * ptm = &request.dir_table.back()->date_modification;
|
||||
tm * ptm = &request->dir_table.back()->date_modification;
|
||||
|
||||
i.out << DateToStr(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
}
|
||||
@@ -384,8 +374,8 @@ void dir_last_date_modification(Info & i)
|
||||
|
||||
void dir_last_dates_equal(Info & i)
|
||||
{
|
||||
tm * ptm1 = &request.dir_table.back()->date_creation;
|
||||
tm * ptm2 = &request.dir_table.back()->date_modification;
|
||||
tm * ptm1 = &request->dir_table.back()->date_creation;
|
||||
tm * ptm2 = &request->dir_table.back()->date_modification;
|
||||
|
||||
i.res = ptm1->tm_year == ptm2->tm_year &&
|
||||
ptm1->tm_mon == ptm2->tm_mon &&
|
||||
|
||||
Reference in New Issue
Block a user