added a new plugin: "gallery"
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@716 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
138
plugins/gallery/templates.cpp
Executable file
138
plugins/gallery/templates.cpp
Executable file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2011, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gallery.h"
|
||||
#include "core/request.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
#include "templates/templates.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Gallery
|
||||
{
|
||||
using namespace TemplatesFunctions;
|
||||
using TemplatesFunctions::system;
|
||||
|
||||
|
||||
extern GalleryInfo gallery_info;
|
||||
extern Gallery fun_gallery;
|
||||
|
||||
|
||||
static size_t gallery_index;
|
||||
static std::wstring item_dir;
|
||||
|
||||
|
||||
void gallery_tab(Info & i)
|
||||
{
|
||||
gallery_index = i.iter;
|
||||
i.res = gallery_index < gallery_info.item_sort_tab.size();
|
||||
}
|
||||
|
||||
|
||||
void gallery_tab_dir(Info & i)
|
||||
{
|
||||
if( gallery_index < gallery_info.item_sort_tab.size() )
|
||||
{
|
||||
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
||||
system->dirs.MakePath(item.parent_id, item_dir);
|
||||
i.out << item_dir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gallery_tab_url(Info & i)
|
||||
{
|
||||
if( gallery_index < gallery_info.item_sort_tab.size() )
|
||||
{
|
||||
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
||||
i.out << item.url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gallery_tab_subject(Info & i)
|
||||
{
|
||||
if( gallery_index < gallery_info.item_sort_tab.size() )
|
||||
{
|
||||
Item & item = *gallery_info.item_sort_tab[gallery_index];
|
||||
i.out << item.subject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void gallery_tab_link(Info & i)
|
||||
{
|
||||
i.out << config->base_url;
|
||||
gallery_tab_dir(i);
|
||||
gallery_tab_url(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void gallery_width(Info & i)
|
||||
{
|
||||
if( !system->mounts.pmount )
|
||||
return;
|
||||
|
||||
Mount & m = *system->mounts.pmount;
|
||||
|
||||
if( !m.param[gallery_info.mount_par_gallery_size].defined || m.param[gallery_info.mount_par_gallery_size].arg.size() != 2 )
|
||||
{
|
||||
i.out << "800px";
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << m.param[gallery_info.mount_par_gallery_size].arg[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void gallery_height(Info & i)
|
||||
{
|
||||
if( !system->mounts.pmount )
|
||||
return;
|
||||
|
||||
Mount & m = *system->mounts.pmount;
|
||||
|
||||
if( !m.param[gallery_info.mount_par_gallery_size].defined || m.param[gallery_info.mount_par_gallery_size].arg.size() != 2 )
|
||||
{
|
||||
i.out << "500px";
|
||||
}
|
||||
else
|
||||
{
|
||||
i.out << m.param[gallery_info.mount_par_gallery_size].arg[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddEzcFunctions(PluginInfo & info)
|
||||
{
|
||||
using TemplatesFunctions::EzcFun;
|
||||
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
|
||||
|
||||
fun->Insert("gallery_tab", gallery_tab);
|
||||
fun->Insert("gallery_tab_dir", gallery_tab_dir);
|
||||
fun->Insert("gallery_tab_url", gallery_tab_url);
|
||||
fun->Insert("gallery_tab_subject", gallery_tab_subject);
|
||||
fun->Insert("gallery_tab_link", gallery_tab_link);
|
||||
fun->Insert("gallery_width", gallery_width);
|
||||
fun->Insert("gallery_height", gallery_height);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user