added: created directory 'content' which has Content:: files
added: created directory 'templates' which has Templates:: and TemplatesFunctions:: files changed: content.cpp split into many files (directory 'content') changed: templates.cpp split into many files (directory 'templates') added: full permissions changed: building of the program (GNU make is used now) Makefile and Makefile.dep added into directories added: a parser 'FunctionParser' is used to parse the GET string it recognizes directories, items, functions, functions parameters added: other classes: Function, Functions added: function: ls, privileges changed: function 'id' to 'node' changed: version: to 0.2.0 added/changed: a lot of work have been done git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@469 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
248
templates/item.cpp
Executable file
248
templates/item.cpp
Executable file
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void item_is(Info & i)
|
||||
{
|
||||
i.result = request.is_item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_id(Info & i)
|
||||
{
|
||||
i.out << request.item.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.item.subject);
|
||||
}
|
||||
|
||||
|
||||
void item_subject_noescape(Info & i)
|
||||
{
|
||||
i.out << request.item.subject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_content(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.item.content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_content_noescape(Info & i)
|
||||
{
|
||||
i.out << request.item.content;
|
||||
}
|
||||
|
||||
|
||||
void item_privileges(Info & i)
|
||||
{
|
||||
i.out << std::setbase(8) << request.item.privileges << std::setbase(10);
|
||||
}
|
||||
|
||||
|
||||
void item_dir(Info & i)
|
||||
{
|
||||
dir(i);
|
||||
}
|
||||
|
||||
|
||||
void item_url(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.item.url);
|
||||
}
|
||||
|
||||
|
||||
void item_link(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, data.base_url);
|
||||
item_dir(i);
|
||||
item_url(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void item_old_id(Info & i)
|
||||
{
|
||||
i.out << request.session->item.id;
|
||||
}
|
||||
|
||||
|
||||
void item_old_subject(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.session->item.subject);
|
||||
}
|
||||
|
||||
|
||||
void item_old_subject_noescape(Info & i)
|
||||
{
|
||||
i.out << request.session->item.subject;
|
||||
}
|
||||
|
||||
|
||||
void item_old_content(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.session->item.content);
|
||||
}
|
||||
|
||||
|
||||
void item_old_content_noescape(Info & i)
|
||||
{
|
||||
i.out << request.session->item.content;
|
||||
}
|
||||
|
||||
|
||||
void item_old_privileges(Info & i)
|
||||
{
|
||||
i.out << std::setbase(8) << request.session->item.privileges << std::setbase(10);
|
||||
}
|
||||
|
||||
|
||||
void item_old_dir(Info & i)
|
||||
{
|
||||
std::string path;
|
||||
|
||||
if( data.dirs.MakePath(request.session->item.parent_id, path) )
|
||||
HtmlEscape(i.out, path);
|
||||
else
|
||||
i.out << "/the path does not exist/";
|
||||
}
|
||||
|
||||
|
||||
void item_old_url(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, request.session->item.url);
|
||||
}
|
||||
|
||||
|
||||
void item_old_link(Info & i)
|
||||
{
|
||||
HtmlEscape(i.out, data.base_url);
|
||||
item_old_dir(i);
|
||||
item_old_url(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static size_t item_index;
|
||||
|
||||
|
||||
void item_tab(Info & i)
|
||||
{
|
||||
item_index = i.iter;
|
||||
i.result = item_index < request.item_table.size();
|
||||
}
|
||||
|
||||
|
||||
void item_tab_id(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
i.out << request.item_table[item_index].id;
|
||||
}
|
||||
|
||||
|
||||
void item_tab_subject(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
HtmlEscape(i.out, request.item_table[item_index].subject);
|
||||
}
|
||||
|
||||
void item_tab_subject_noescape(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
i.out << request.item_table[item_index].subject;
|
||||
}
|
||||
|
||||
|
||||
void item_tab_content(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
HtmlEscape(i.out, request.item_table[item_index].content);
|
||||
}
|
||||
|
||||
|
||||
void item_tab_content_noescape(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
i.out << request.item_table[item_index].content;
|
||||
}
|
||||
|
||||
|
||||
void item_tab_privileges(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
i.out << std::setbase(8) << request.item_table[item_index].privileges << std::setbase(10);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void item_tab_dir(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
std::string path;
|
||||
|
||||
if( data.dirs.MakePath(request.item_table[item_index].parent_id, path) )
|
||||
HtmlEscape(i.out, path);
|
||||
else
|
||||
i.out << "/the path does not exist/";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void item_tab_url(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
HtmlEscape(i.out, request.item_table[item_index].url);
|
||||
}
|
||||
|
||||
|
||||
void item_tab_link(Info & i)
|
||||
{
|
||||
if( item_index < request.item_table.size() )
|
||||
{
|
||||
HtmlEscape(i.out, data.base_url);
|
||||
item_tab_dir(i);
|
||||
item_tab_url(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace TemplatesFunctions
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user