2009-06-05 22:29:06 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-06-05 22:29:06 +02:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2011-06-21 23:24:49 +02:00
|
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
2009-06-05 22:29:06 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-08-13 22:04:57 +02:00
|
|
|
#include "core/misc.h"
|
2011-06-21 23:24:49 +02:00
|
|
|
#include "core/mounts.h"
|
2009-06-05 22:29:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
void mount_type_is(Info & i)
|
2009-06-05 22:29:06 +02:00
|
|
|
{
|
2010-09-29 23:24:34 +02:00
|
|
|
int mount_type_id = system->mounts.FindMountType(i.par);
|
2009-06-05 22:29:06 +02:00
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
if( mount_type_id == -1 )
|
|
|
|
return;
|
2010-05-30 23:07:46 +02:00
|
|
|
|
2011-10-16 23:33:45 +02:00
|
|
|
i.res = (cur->mount->type == mount_type_id);
|
2009-06-07 04:40:27 +02:00
|
|
|
}
|
2009-06-05 22:29:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
void mount_page_arg_is(Info & i)
|
2009-10-01 00:31:20 +02:00
|
|
|
{
|
2011-10-16 23:33:45 +02:00
|
|
|
i.res = cur->mount->IsArg(system->mounts.MountParPage(), i.par);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_lang_arg(Info & i)
|
|
|
|
{
|
|
|
|
i.out << cur->mount->FirstArg(system->mounts.MountParLang());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_lang_arg_is(Info & i)
|
|
|
|
{
|
|
|
|
i.res = cur->mount->IsArg(system->mounts.MountParLang(), i.par);
|
2009-10-01 00:31:20 +02:00
|
|
|
}
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2010-09-29 23:24:34 +02:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
void mount_has_html_template(Info & i)
|
|
|
|
{
|
2011-10-16 23:33:45 +02:00
|
|
|
i.res = cur->mount->param[system->mounts.MountParHtmlTemplate()].defined;
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
|
2010-08-13 22:04:57 +02:00
|
|
|
void mount_first_html_template(Info & i)
|
|
|
|
{
|
2011-10-16 23:33:45 +02:00
|
|
|
Mount::ParamRow & par = cur->mount->param[system->mounts.MountParHtmlTemplate()];
|
2010-08-13 22:04:57 +02:00
|
|
|
|
|
|
|
if( par.defined && !par.arg.empty() )
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
i.out << par.arg[0];
|
2010-08-13 22:04:57 +02:00
|
|
|
}
|
2010-01-25 05:52:17 +01:00
|
|
|
|
|
|
|
|
2011-06-21 23:24:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
static size_t mount_css_index = 0;
|
|
|
|
|
|
|
|
void mount_css_tab(Info & i)
|
|
|
|
{
|
|
|
|
int parcss = system->mounts.MountParCss();
|
|
|
|
|
|
|
|
|
|
|
|
if( !cur->mount->param[parcss].defined )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mount_css_index = i.iter;
|
|
|
|
i.res = mount_css_index < cur->mount->param[parcss].arg.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_tab_file(Info & i)
|
|
|
|
{
|
|
|
|
int parcss = system->mounts.MountParCss();
|
|
|
|
|
|
|
|
if( mount_css_index < cur->mount->param[parcss].arg.size() )
|
|
|
|
i.out << cur->mount->param[parcss].arg[mount_css_index];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_tab_file_is_global(Info & i)
|
|
|
|
{
|
|
|
|
int parcss = system->mounts.MountParCss();
|
|
|
|
|
|
|
|
if( mount_css_index < cur->mount->param[parcss].arg.size() )
|
|
|
|
i.res = IsSubString(L"http://", cur->mount->param[parcss].arg[mount_css_index].c_str()) ||
|
|
|
|
IsSubString(L"https://", cur->mount->param[parcss].arg[mount_css_index].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
int parcss = system->mounts.MountParCss();
|
|
|
|
|
|
|
|
if( !cur->mount->param[parcss].defined )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i.res = (mount_css_index + 1 < cur->mount->param[parcss].arg.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t mount_css_size()
|
|
|
|
{
|
|
|
|
int parcss = system->mounts.MountParCss();
|
|
|
|
|
|
|
|
if( !cur->mount->param[parcss].defined )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return cur->mount->param[parcss].arg.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_is_empty(Info & i)
|
|
|
|
{
|
|
|
|
i.res = mount_css_size() == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_is_one(Info & i)
|
|
|
|
{
|
|
|
|
i.res = mount_css_size() == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_css_more_than_one(Info & i)
|
|
|
|
{
|
|
|
|
i.res = mount_css_size() > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-21 23:24:49 +02:00
|
|
|
static bool mount_tab_inited = false;
|
|
|
|
static Mounts::MountTab::const_iterator mount_iter;
|
|
|
|
static std::wstring dir_str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_cur_type(Info & i)
|
|
|
|
{
|
|
|
|
i.out << system->mounts.GetMountType(cur->mount->type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_cur_dir(Info & i)
|
|
|
|
{
|
|
|
|
Item * pdir = system->dirs.GetDir(cur->mount->dir_id);
|
|
|
|
|
|
|
|
if( pdir && system->dirs.MakePath(pdir->id, dir_str) )
|
|
|
|
i.out << dir_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_cur_fs(Info & i)
|
|
|
|
{
|
|
|
|
i.out << system->mounts.GetMountFs(cur->mount->fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_print_parlist(Info & i, const Mount::Param & param)
|
|
|
|
{
|
|
|
|
bool was_printed = false;
|
|
|
|
|
|
|
|
for(size_t p=0 ; p < param.size() ; ++p)
|
|
|
|
{
|
|
|
|
if( param[p].defined )
|
|
|
|
{
|
|
|
|
if( was_printed )
|
|
|
|
i.out << ", ";
|
|
|
|
|
|
|
|
i.out << system->mounts.GetMountPar(p);
|
|
|
|
was_printed = true;
|
|
|
|
|
|
|
|
if( !param[p].arg.empty() )
|
|
|
|
{
|
|
|
|
i.out << "(";
|
|
|
|
|
|
|
|
for(size_t a=0 ; a < param[p].arg.size() ; ++a)
|
|
|
|
{
|
|
|
|
i.out << param[p].arg[a];
|
|
|
|
|
|
|
|
if( a + 1 < param[p].arg.size() )
|
|
|
|
i.out << ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
i.out << ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_cur_parlist(Info & i)
|
|
|
|
{
|
|
|
|
mount_print_parlist(i, cur->mount->param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_tab(Info & i)
|
|
|
|
{
|
|
|
|
const Mounts::MountTab * pmount_tab = system->mounts.GetMountTab();
|
|
|
|
|
|
|
|
if( i.iter == 0 )
|
|
|
|
{
|
|
|
|
mount_iter = pmount_tab->begin();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( mount_iter != pmount_tab->end() )
|
|
|
|
++mount_iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
mount_tab_inited = (mount_iter != pmount_tab->end());
|
|
|
|
i.res = mount_tab_inited;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_tab_type(Info & i)
|
|
|
|
{
|
|
|
|
if( mount_tab_inited )
|
|
|
|
{
|
|
|
|
i.out << system->mounts.GetMountType(mount_iter->second.type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mount_tab_dir(Info & i)
|
|
|
|
{
|
|
|
|
if( mount_tab_inited )
|
|
|
|
{
|
|
|
|
Item * pdir = system->dirs.GetDir(mount_iter->second.dir_id);
|
|
|
|
|
|
|
|
if( pdir && system->dirs.MakePath(pdir->id, dir_str) )
|
|
|
|
i.out << dir_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_tab_fs(Info & i)
|
|
|
|
{
|
|
|
|
if( mount_tab_inited )
|
|
|
|
{
|
|
|
|
i.out << system->mounts.GetMountFs(mount_iter->second.fs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mount_tab_parlist(Info & i)
|
|
|
|
{
|
|
|
|
if( !mount_tab_inited )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mount_print_parlist(i, mount_iter->second.param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|