165 lines
2.4 KiB
C++
Executable File
165 lines
2.4 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "templates.h"
|
|
#include "core/request.h"
|
|
#include "core/misc.h"
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
{
|
|
|
|
|
|
static std::wstring doc_proto_str;
|
|
|
|
|
|
|
|
void doc_title(Info & i)
|
|
{
|
|
size_t a;
|
|
bool was_dir = false;
|
|
|
|
// from 1 means skipping the root directory
|
|
for(a = 1 ; a<cur->request->dir_tab.size() ; ++a)
|
|
{
|
|
i.out << cur->request->dir_tab[a]->subject;
|
|
was_dir = true;
|
|
|
|
if( a < cur->request->dir_tab.size()-1 )
|
|
i.out << config->title_separator;
|
|
}
|
|
|
|
if( cur->request->is_item )
|
|
{
|
|
if( was_dir )
|
|
i.out << config->title_separator;
|
|
|
|
i.out << cur->request->item.subject;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void doc_proto(Info & i)
|
|
{
|
|
system->PutUrlProto(config->use_ssl, doc_proto_str);
|
|
i.out << doc_proto_str;
|
|
}
|
|
|
|
|
|
void doc_proto_static(Info & i)
|
|
{
|
|
system->PutUrlProto(config->use_ssl_static, doc_proto_str);
|
|
i.out << doc_proto_str;
|
|
}
|
|
|
|
|
|
void doc_proto_common(Info & i)
|
|
{
|
|
system->PutUrlProto(config->use_ssl_common, doc_proto_str);
|
|
i.out << doc_proto_str;
|
|
}
|
|
|
|
|
|
void doc_base_url(Info & i)
|
|
{
|
|
doc_proto(i);
|
|
i.out << config->base_url;
|
|
}
|
|
|
|
|
|
void doc_base_url_static(Info & i)
|
|
{
|
|
doc_proto_static(i);
|
|
i.out << config->base_url_static;
|
|
}
|
|
|
|
|
|
void doc_base_url_common(Info & i)
|
|
{
|
|
doc_proto_common(i);
|
|
i.out << config->base_url_common;
|
|
}
|
|
|
|
|
|
|
|
void doc_current_url(Info & i)
|
|
{
|
|
i.out << cur->request->env_request_uri;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static size_t doc_css_index = 0;
|
|
|
|
|
|
/*
|
|
cur->session->last_css is set by some javascript wysiwyg editors (ckeditor, tinymce)
|
|
*/
|
|
void doc_css_tab(Info & i)
|
|
{
|
|
doc_css_index = i.iter;
|
|
i.res = doc_css_index < cur->session->last_css.size();
|
|
}
|
|
|
|
|
|
void doc_css_tab_file(Info & i)
|
|
{
|
|
if( doc_css_index < cur->session->last_css.size() )
|
|
i.out << cur->session->last_css[doc_css_index];
|
|
}
|
|
|
|
|
|
void doc_css_tab_file_is_global(Info & i)
|
|
{
|
|
if( doc_css_index < cur->session->last_css.size() )
|
|
i.res = IsSubString(L"http://", cur->session->last_css[doc_css_index].c_str()) ||
|
|
IsSubString(L"https://", cur->session->last_css[doc_css_index].c_str());
|
|
}
|
|
|
|
|
|
void doc_css_tab_has_next(Info & i)
|
|
{
|
|
i.res = (doc_css_index + 1 < cur->session->last_css.size());
|
|
}
|
|
|
|
|
|
void doc_css_is_empty(Info & i)
|
|
{
|
|
i.res = cur->session->last_css.empty();
|
|
}
|
|
|
|
|
|
void doc_css_is_one(Info & i)
|
|
{
|
|
i.res = cur->session->last_css.size() == 1;
|
|
}
|
|
|
|
|
|
void doc_css_more_than_one(Info & i)
|
|
{
|
|
i.res = cur->session->last_css.size() > 1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|