winix/plugins/groupitem/templates.cpp

88 lines
1.4 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "templates/templates.h"
#include "core/plugin.h"
#include "groupinfo.h"
namespace GroupItem
{
using namespace TemplatesFunctions;
using TemplatesFunctions::system;
extern GroupInfo group_info;
static size_t group_tab_reqid = 0;
static bool group_tab_found = false;
static Groups * pgroups;
static size_t group_index;
static size_t group_tab_index;
static std::wstring group_last_path;
void group_tab_init(const std::wstring & path)
{
if( group_tab_reqid != cur->request->id || group_last_path != path)
{
group_tab_found = false;
group_tab_reqid = cur->request->id;
group_last_path = path;
pgroups = group_info.FindGroups(cur->request->dir_tab.back()->id);
if( pgroups )
{
group_tab_found = true;
group_index = pgroups->Find(path);
}
}
}
void group_tab(Info & i)
{
group_tab_init(i.par);
group_tab_index = i.iter;
if( group_tab_found )
i.res = group_tab_index < pgroups->GroupSize(group_index);
}
void group_tab_link(Info & i)
{
if( group_tab_found )
i.out << pgroups->GroupPath(group_index, group_tab_index);
}
void AddEzcFunctions(PluginInfo & info)
{
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
fun->Insert("group_tab", group_tab);
fun->Insert("group_tab_link", group_tab_link);
}
} // namespace