2008-12-10 05:42:49 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
Pattern pat_index;
|
|
|
|
Pattern pat_item;
|
|
|
|
Pattern pat_dir;
|
|
|
|
Pattern pat_item_add_edit;
|
|
|
|
Pattern pat_item_del_confirm;
|
|
|
|
Pattern pat_err_404;
|
2008-12-21 22:17:09 +01:00
|
|
|
Pattern pat_err_per_denied;
|
2008-12-10 05:42:49 +01:00
|
|
|
Pattern pat_err_internal;
|
|
|
|
|
|
|
|
Functions functions;
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
void is_group_tv(Info & i)
|
|
|
|
{
|
|
|
|
long gid = data.groups.GetGroupId("tv");
|
|
|
|
|
|
|
|
if( request.session->puser && request.session->puser->IsMemberOf(gid) )
|
|
|
|
i.result = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
void language(Info & i)
|
|
|
|
{
|
|
|
|
// at the moment only Polish language
|
|
|
|
i.out << "pl";
|
|
|
|
}
|
|
|
|
|
|
|
|
void title(Info & i)
|
|
|
|
{
|
|
|
|
i.out << "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void charset(Info & i)
|
|
|
|
{
|
|
|
|
i.out << "iso-8859-2";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void version_major(Info & i)
|
|
|
|
{
|
|
|
|
i.out << MAJOR_VER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void version_minor(Info & i)
|
|
|
|
{
|
|
|
|
i.out << MINOR_VER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void version_revision(Info & i)
|
|
|
|
{
|
|
|
|
i.out << REVISION_VER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
void user_name(Info & i)
|
|
|
|
{
|
|
|
|
User * puser = data.users.GetUser(request.session->user_id);
|
|
|
|
|
|
|
|
if( puser )
|
|
|
|
i.out << puser->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
void content(Info & i)
|
|
|
|
{
|
|
|
|
Pattern * p;
|
|
|
|
|
|
|
|
switch( request.result )
|
|
|
|
{
|
|
|
|
case Request::add_item:
|
|
|
|
case Request::edit_item:
|
|
|
|
p = &pat_item_add_edit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Request::show_dir:
|
|
|
|
p = &pat_dir;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Request::show_item:
|
|
|
|
p = &pat_item;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Request::del_item_confirm:
|
|
|
|
p = &pat_item_del_confirm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Request::err_internal:
|
|
|
|
p = &pat_err_internal;
|
|
|
|
break;
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
case Request::err_per_denied:
|
|
|
|
p = &pat_err_per_denied;
|
|
|
|
break;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
case Request::err404:
|
|
|
|
default:
|
|
|
|
p = &pat_err_404;
|
|
|
|
}
|
|
|
|
|
|
|
|
Generator gen(i.out, *p, functions);
|
|
|
|
|
|
|
|
gen.Generate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void base_url(Info & i)
|
|
|
|
{
|
|
|
|
i.out << data.base_url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void current_url(Info & i)
|
|
|
|
{
|
2008-12-12 04:11:29 +01:00
|
|
|
i.out << request.env_request_uri;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void user_logged(Info & i)
|
|
|
|
{
|
|
|
|
i.result = request.session->is_logged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
void user_super_user(Info & i)
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
2008-12-21 22:17:09 +01:00
|
|
|
if( request.session->puser && request.session->puser->super_user )
|
|
|
|
i.result = true;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void item_id(Info & i)
|
|
|
|
{
|
|
|
|
i.out << request.item.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void item_subject(Info & i)
|
|
|
|
{
|
2008-12-21 22:17:09 +01:00
|
|
|
i.out << request.item.subject;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_content(Info & i)
|
|
|
|
{
|
|
|
|
i.out << request.item.content;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
void item_subject_escape(Info & i)
|
|
|
|
{
|
|
|
|
i.out << HtmlSpecial(request.item.subject);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_content_escape(Info & i)
|
|
|
|
{
|
|
|
|
i.out << HtmlSpecial(request.item.content);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_privileges(Info & i)
|
|
|
|
{
|
|
|
|
i.out << std::setbase(8) << request.item.privileges << std::setbase(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void item_url_subject(Info & i) // !! zmienic nazwe
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
2008-12-14 06:28:28 +01:00
|
|
|
i.out << request.item.url;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_dir(Info & i)
|
|
|
|
{
|
|
|
|
std::string path;
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
if( data.dirs.MakePath(request.item.parent_id, path) )
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
i.out << path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "problem with generating a path";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ---------
|
|
|
|
|
|
|
|
|
|
|
|
void old_item_id(Info & i)
|
|
|
|
{
|
|
|
|
i.out << request.session->item.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void old_item_subject(Info & i)
|
|
|
|
{
|
|
|
|
i.out << HtmlSpecial(request.session->item.subject);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void old_item_content(Info & i)
|
|
|
|
{
|
|
|
|
//i.out << HtmlSpecial(request.session->item.content);
|
|
|
|
i.out << request.session->item.content;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void old_item_url_subject(Info & i) // zmienic nazwe !!
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
2008-12-14 06:28:28 +01:00
|
|
|
i.out << request.session->item.url;
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void old_item_dir(Info & i)
|
|
|
|
{
|
|
|
|
std::string path;
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
if( data.dirs.MakePath(request.session->item.parent_id, path) )
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
i.out << path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "problem with generating a path";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----
|
|
|
|
|
|
|
|
void full_dir(Info & i)
|
|
|
|
{
|
|
|
|
std::vector<Item>::size_type a;
|
|
|
|
|
|
|
|
for(a=0 ; a<request.cur_dir_table.size() ; ++a)
|
|
|
|
{
|
2008-12-14 06:28:28 +01:00
|
|
|
i.out << request.cur_dir_table[a].url << '/';
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<Item>::size_type item_index, dir_index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void dir_items(Info & i)
|
|
|
|
{
|
|
|
|
if( i.iter >= (int)request.dir_table.size() )
|
|
|
|
{
|
|
|
|
i.result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.result = true;
|
|
|
|
dir_index = i.iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void dir_subject2(Info & i)
|
|
|
|
{
|
|
|
|
if( dir_index < request.dir_table.size() )
|
|
|
|
{
|
|
|
|
if( request.dir_table[dir_index].subject.empty() )
|
|
|
|
i.out << "bez nazwy";
|
|
|
|
else
|
|
|
|
HtmlSpecial(i.out, request.dir_table[dir_index].subject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void dir_url_subject2(Info & i) // zmienic nazwe
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
if( dir_index < request.dir_table.size() )
|
|
|
|
{
|
2008-12-14 06:28:28 +01:00
|
|
|
HtmlSpecial(i.out, request.dir_table[dir_index].url);
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void items(Info & i) // zamienic na fitems !!
|
|
|
|
{
|
|
|
|
if( i.iter >= (int)request.item_table.size() )
|
|
|
|
{
|
|
|
|
i.result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.result = true;
|
|
|
|
item_index = i.iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void item_subject2(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < request.item_table.size() )
|
|
|
|
{
|
|
|
|
if( request.item_table[item_index].subject.empty() )
|
|
|
|
i.out << "bez nazwy";
|
|
|
|
else
|
|
|
|
HtmlSpecial(i.out, request.item_table[item_index].subject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void item_url_subject2(Info & i) // !! zmienic nazwe
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
if( item_index < request.item_table.size() )
|
2008-12-14 06:28:28 +01:00
|
|
|
HtmlSpecial(i.out, request.item_table[item_index].url);
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void item_content2(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < request.item_table.size() )
|
|
|
|
//HtmlSpecial(i.out, request.item_table[item_index].content);
|
|
|
|
i.out << request.item_table[item_index].content;
|
|
|
|
}
|
|
|
|
|
|
|
|
void item_id2(Info & i)
|
|
|
|
{
|
|
|
|
if( item_index < request.item_table.size() )
|
|
|
|
i.out << request.item_table[item_index].id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void incorrect_dir(Info & i)
|
|
|
|
{
|
|
|
|
if( request.session->done_status == Error::incorrect_dir )
|
|
|
|
i.result = true;
|
|
|
|
else
|
|
|
|
i.result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<Item>::size_type current_dir_index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fcurrent_dir(Info & i)
|
|
|
|
{
|
|
|
|
if( i.iter < (int)request.cur_dir_table.size() )
|
|
|
|
{
|
|
|
|
current_dir_index = i.iter;
|
|
|
|
i.result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i.result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void current_dir_part_link(Info & i)
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
|
|
|
std::vector<Item>::size_type a;
|
|
|
|
|
|
|
|
i.out << data.base_url;
|
|
|
|
|
|
|
|
for(a = 0 ; a <= current_dir_index && a < request.cur_dir_table.size() ; ++a)
|
|
|
|
{
|
2008-12-14 06:28:28 +01:00
|
|
|
i.out << request.cur_dir_table[a].url << '/';
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-14 06:28:28 +01:00
|
|
|
void current_dir_part_url(Info & i)
|
|
|
|
{
|
|
|
|
if( current_dir_index < request.cur_dir_table.size() )
|
|
|
|
i.out << request.cur_dir_table[current_dir_index].url;
|
|
|
|
}
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
void edit_item(Info & i)
|
|
|
|
{
|
|
|
|
i.result = request.result == Request::edit_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void added_item(Info &i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done == Done::added_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void edited_item(Info &i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done == Done::edited_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
void deleted_item(Info &i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done == Done::deleted_item;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// zostawic tylko jedna funkcje done_with_errors (bedzie uzywana do roznych celow) !!
|
|
|
|
void deleted_item_errors(Info & i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done_status != Error::ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void done_with_errors(Info & i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done_status != Error::ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void done_status(Info & i)
|
|
|
|
{
|
|
|
|
i.out << static_cast<int>( request.session->done_status );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitems_in_dir(Info & i)
|
|
|
|
{
|
|
|
|
// i.out << "abc: " << variables["fitems_directory"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loggedout(Info & i)
|
|
|
|
{
|
|
|
|
i.result = request.session->done == Done::loggedout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
std::vector<long> fgroup_table;
|
|
|
|
size_t fgroup_index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_group_initializing()
|
|
|
|
{
|
|
|
|
fgroup_table.clear();
|
|
|
|
|
|
|
|
if( !request.session->puser )
|
|
|
|
{
|
|
|
|
// not logged
|
|
|
|
fgroup_table.push_back(request.item.group_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( request.session->puser->super_user )
|
|
|
|
{
|
|
|
|
// super user is allowed to change to any group
|
|
|
|
for(size_t i=0 ; i<data.groups.Size() ; ++i)
|
|
|
|
fgroup_table.push_back( data.groups[i].id );
|
|
|
|
|
|
|
|
// as well to -1
|
|
|
|
fgroup_table.push_back(-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( request.session->puser->id == request.item.user_id )
|
|
|
|
{
|
|
|
|
bool was_current_group = false;
|
|
|
|
// owner of the item -- is allowed to change only to a group in which he belongs to
|
|
|
|
for(size_t i=0 ; i<request.session->puser->groups.size() ; ++i)
|
|
|
|
{
|
|
|
|
fgroup_table.push_back( request.session->puser->groups[i] );
|
|
|
|
|
|
|
|
if( request.item.group_id == request.session->puser->groups[i] )
|
|
|
|
was_current_group = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we're showing the item.group_id if it's different
|
|
|
|
if( !was_current_group )
|
|
|
|
fgroup_table.push_back(request.item.group_id);
|
|
|
|
|
|
|
|
// switching to -1 is allowed too
|
|
|
|
fgroup_table.push_back(-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// not the owner and not a super user -- the same as not logged
|
|
|
|
fgroup_table.push_back(request.item.group_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_group(Info & i)
|
|
|
|
{
|
|
|
|
if( i.iter == 0 )
|
|
|
|
fitem_group_initializing();
|
|
|
|
|
|
|
|
fgroup_index = i.iter;
|
|
|
|
i.result = fgroup_index < fgroup_table.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_group_name(Info & i)
|
|
|
|
{
|
|
|
|
if( fgroup_index < fgroup_table.size() )
|
|
|
|
{
|
|
|
|
long gid = fgroup_table[fgroup_index];
|
|
|
|
|
|
|
|
if( gid != -1 )
|
|
|
|
{
|
|
|
|
Group * pgroup = data.groups.GetGroup( gid );
|
|
|
|
|
|
|
|
if( pgroup )
|
|
|
|
i.out << pgroup->name;
|
|
|
|
else
|
|
|
|
i.out << "group_id: " << gid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << data.priv_no_group;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_group_default(Info & i)
|
|
|
|
{
|
|
|
|
if( fgroup_index < fgroup_table.size() )
|
|
|
|
{
|
|
|
|
long gid = fgroup_table[fgroup_index];
|
|
|
|
|
|
|
|
if( gid == request.item.group_id )
|
|
|
|
i.result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<long> fuser_table;
|
|
|
|
size_t fuser_index;
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_user_initializing()
|
|
|
|
{
|
|
|
|
fuser_table.clear();
|
|
|
|
|
|
|
|
if( !request.session->puser )
|
|
|
|
{
|
|
|
|
// not logged
|
|
|
|
fuser_table.push_back(request.item.user_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if( request.session->puser->super_user )
|
|
|
|
{
|
|
|
|
// super user is allowed to change to any user
|
|
|
|
for(size_t i=0 ; i<data.users.Size() ; ++i)
|
|
|
|
fuser_table.push_back( data.users[i].id );
|
|
|
|
|
|
|
|
// as well to -1
|
|
|
|
fuser_table.push_back(-1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// others
|
|
|
|
fuser_table.push_back(request.item.user_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_user(Info & i)
|
|
|
|
{
|
|
|
|
if( i.iter == 0 )
|
|
|
|
fitem_user_initializing();
|
|
|
|
|
|
|
|
fuser_index = i.iter;
|
|
|
|
i.result = fuser_index < fuser_table.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_user_name(Info & i)
|
|
|
|
{
|
|
|
|
if( fuser_index < fuser_table.size() )
|
|
|
|
{
|
|
|
|
long uid = fuser_table[fuser_index];
|
|
|
|
|
|
|
|
if( uid != -1 )
|
|
|
|
{
|
|
|
|
User * puser = data.users.GetUser( uid );
|
|
|
|
|
|
|
|
if( puser )
|
|
|
|
i.out << puser->name;
|
|
|
|
else
|
|
|
|
i.out << "user_id: " << uid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << data.priv_no_user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void fitem_user_default(Info & i)
|
|
|
|
{
|
|
|
|
if( fuser_index < fuser_table.size() )
|
|
|
|
{
|
|
|
|
long uid = fuser_table[fuser_index];
|
|
|
|
|
|
|
|
if( uid == request.item.user_id )
|
|
|
|
i.result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::CreateFunctions()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
functions.Clear();
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
functions.Insert("is_group_tv", is_group_tv);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
functions.Insert("language", language);
|
|
|
|
functions.Insert("title", title);
|
|
|
|
functions.Insert("charset", charset);
|
|
|
|
functions.Insert("content", content);
|
|
|
|
functions.Insert("version_major", version_major);
|
|
|
|
functions.Insert("version_minor", version_minor);
|
|
|
|
functions.Insert("version_revision", version_revision);
|
|
|
|
functions.Insert("base_url", base_url);
|
|
|
|
functions.Insert("current_url", current_url);
|
|
|
|
functions.Insert("user_logged", user_logged);
|
2008-12-21 22:17:09 +01:00
|
|
|
functions.Insert("user_super_user", user_super_user);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
functions.Insert("item_id", item_id);
|
|
|
|
functions.Insert("item_subject", item_subject);
|
|
|
|
functions.Insert("item_content", item_content);
|
2008-12-21 22:17:09 +01:00
|
|
|
functions.Insert("item_subject_escape", item_subject_escape);
|
|
|
|
functions.Insert("item_content_escape", item_content_escape);
|
2008-12-10 05:42:49 +01:00
|
|
|
functions.Insert("item_url_subject", item_url_subject);
|
|
|
|
functions.Insert("item_dir", item_dir);
|
2008-12-21 22:17:09 +01:00
|
|
|
functions.Insert("item_privileges", item_privileges);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
functions.Insert("old_item_id", old_item_id);
|
|
|
|
functions.Insert("old_item_subject", old_item_subject);
|
|
|
|
functions.Insert("old_item_content", old_item_content);
|
|
|
|
functions.Insert("old_item_url_subject", old_item_url_subject);
|
|
|
|
functions.Insert("old_item_dir", old_item_dir);
|
|
|
|
|
|
|
|
functions.Insert("dir_items", dir_items);
|
|
|
|
functions.Insert("items", items);
|
|
|
|
functions.Insert("item_subject2", item_subject2);
|
|
|
|
functions.Insert("dir_subject2", dir_subject2);
|
|
|
|
functions.Insert("full_dir", full_dir);
|
|
|
|
functions.Insert("dir_url_subject2", dir_url_subject2);
|
|
|
|
functions.Insert("item_url_subject2", item_url_subject2);
|
|
|
|
functions.Insert("item_content2", item_content2);
|
|
|
|
functions.Insert("item_id2", item_id2);
|
|
|
|
|
|
|
|
|
|
|
|
functions.Insert("edit_item", edit_item);
|
|
|
|
|
|
|
|
|
|
|
|
functions.Insert("incorrect_dir", incorrect_dir);
|
|
|
|
|
|
|
|
functions.Insert("fcurrent_dir", fcurrent_dir);
|
2008-12-14 06:28:28 +01:00
|
|
|
functions.Insert("current_dir_part_link", current_dir_part_link);
|
2008-12-10 05:42:49 +01:00
|
|
|
functions.Insert("current_dir_part_url", current_dir_part_url);
|
|
|
|
|
|
|
|
functions.Insert("added_item", added_item);
|
|
|
|
functions.Insert("edited_item", edited_item);
|
|
|
|
functions.Insert("deleted_item", deleted_item);
|
|
|
|
functions.Insert("loggedout", loggedout);
|
|
|
|
functions.Insert("deleted_item_errors", deleted_item_errors);
|
|
|
|
|
|
|
|
|
|
|
|
functions.Insert("done_with_errors", done_with_errors);
|
|
|
|
functions.Insert("done_status", done_status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
functions.Insert("fitems_in_dir", fitems_in_dir);
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
|
|
|
|
functions.Insert("user_name", user_name);
|
|
|
|
|
|
|
|
functions.Insert("fitem_group", fitem_group);
|
|
|
|
functions.Insert("fitem_group_name", fitem_group_name);
|
|
|
|
functions.Insert("fitem_group_default", fitem_group_default);
|
|
|
|
|
|
|
|
functions.Insert("fitem_user", fitem_user);
|
|
|
|
functions.Insert("fitem_user_name", fitem_user_name);
|
|
|
|
functions.Insert("fitem_user_default", fitem_user_default);
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::Read()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
pat_index.Directory(data.templates);
|
|
|
|
pat_index.ParseFile(data.default_index);
|
|
|
|
|
|
|
|
pat_item.Directory(data.templates);
|
|
|
|
pat_item.ParseFile("item.html");
|
|
|
|
|
|
|
|
pat_dir.Directory(data.templates);
|
|
|
|
pat_dir.ParseFile("dir.html");
|
|
|
|
|
|
|
|
pat_item_add_edit.Directory(data.templates);
|
|
|
|
pat_item_add_edit.ParseFile("item_add_edit.html");
|
|
|
|
|
|
|
|
pat_err_404.Directory(data.templates);
|
|
|
|
pat_err_404.ParseFile("err_404.html");
|
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
pat_err_per_denied.Directory(data.templates);
|
|
|
|
pat_err_per_denied.ParseFile("err_per_denied.html");
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
pat_item_del_confirm.Directory(data.templates);
|
|
|
|
pat_item_del_confirm.ParseFile("item_del_confirm.html");
|
|
|
|
|
|
|
|
pat_err_internal.Directory(data.templates);
|
|
|
|
pat_err_internal.ParseFile("err_internal.html");
|
|
|
|
|
|
|
|
CreateFunctions();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Templates::Generate()
|
|
|
|
{
|
|
|
|
using namespace TemplatesFunctions;
|
|
|
|
|
|
|
|
// clear some variables (indexes for example)
|
|
|
|
item_index = 0;
|
|
|
|
current_dir_index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
Generator generator(request.page, pat_index, functions);
|
|
|
|
|
|
|
|
generator.Generate();
|
|
|
|
}
|
|
|
|
|