2009-04-20 00:13:21 +02:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2009-04-20 00:13:21 +02:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2009-04-20 00:13:21 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2010-02-15 01:31:14 +01:00
|
|
|
#include "misc.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "../core/data.h"
|
|
|
|
#include "../core/request.h"
|
|
|
|
#include "../core/misc.h"
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
void thread_is(Info & i)
|
|
|
|
{
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = request.is_thread;
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static size_t thread_tab_index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab(Info & i)
|
|
|
|
{
|
|
|
|
thread_tab_index = i.iter;
|
|
|
|
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = thread_tab_index < request.thread_tab.size();
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab_url(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
{
|
|
|
|
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
|
|
|
|
|
|
|
if( dir )
|
|
|
|
{
|
|
|
|
HtmlEscape(i.out, dir->url);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "<!-- unknown directory -->";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab_subject(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
{
|
|
|
|
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
|
|
|
|
|
|
|
if( dir )
|
|
|
|
{
|
2009-11-17 00:36:38 +01:00
|
|
|
if( !dir->subject.empty() )
|
|
|
|
HtmlEscape(i.out, dir->subject);
|
|
|
|
else
|
|
|
|
HtmlEscape(i.out, dir->url);
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << "<!-- unknown subject -->";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab_answers(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
{
|
|
|
|
long a = request.thread_tab[thread_tab_index].items;
|
|
|
|
|
|
|
|
// the first is created by the author
|
|
|
|
// we count only the rest
|
|
|
|
if( a > 0 )
|
|
|
|
--a;
|
|
|
|
|
|
|
|
i.out << a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab_author(Info & i)
|
|
|
|
{
|
|
|
|
bool unknown = true;
|
|
|
|
|
|
|
|
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
{
|
|
|
|
Item * dir = data.dirs.GetDir( request.thread_tab[thread_tab_index].dir_id );
|
|
|
|
|
|
|
|
if( dir )
|
|
|
|
{
|
|
|
|
User * puser = data.users.GetUser(dir->user_id);
|
|
|
|
unknown = false;
|
|
|
|
|
|
|
|
if( puser )
|
|
|
|
HtmlEscape(i.out, puser->name);
|
|
|
|
else
|
2009-06-07 04:40:27 +02:00
|
|
|
{
|
|
|
|
i.out << "~";
|
|
|
|
|
|
|
|
if( !dir->guest_name.empty() )
|
|
|
|
HtmlEscape(i.out, dir->guest_name);
|
|
|
|
else
|
|
|
|
i.out << "guest"; // !! dodac do konfiga
|
|
|
|
}
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( unknown )
|
|
|
|
{
|
|
|
|
i.out << "<!-- unknown user -->";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_tab_last_item_date_modification(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
|
|
|
i.out << DateToStr( &request.thread_tab[thread_tab_index].last_item.date_modification );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
void thread_tab_last_item_date_modification_nice(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
|
|
|
TemplatesMisc::print_date_nice(i, &request.thread_tab[thread_tab_index].last_item.date_modification);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
void thread_tab_last_item_user(Info & i)
|
|
|
|
{
|
|
|
|
if( thread_tab_index < request.thread_tab.size() )
|
|
|
|
{
|
|
|
|
if( request.thread_tab[thread_tab_index].last_item.id != -1 )
|
|
|
|
{
|
|
|
|
User * puser = data.users.GetUser( request.thread_tab[thread_tab_index].last_item.user_id );
|
|
|
|
|
|
|
|
if( puser )
|
|
|
|
HtmlEscape(i.out, puser->name);
|
|
|
|
else
|
2009-06-07 04:40:27 +02:00
|
|
|
{
|
|
|
|
i.out << "~";
|
|
|
|
|
|
|
|
if( !request.thread_tab[thread_tab_index].last_item.guest_name.empty() )
|
|
|
|
HtmlEscape(i.out, request.thread_tab[thread_tab_index].last_item.guest_name);
|
|
|
|
else
|
|
|
|
i.out << "guest"; // !! dodac do konfiga
|
|
|
|
}
|
2009-06-05 22:29:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void thread_can_create(Info & i)
|
|
|
|
{
|
2010-05-30 23:07:46 +02:00
|
|
|
i.res = request.CanCreateThread(true);
|
2009-04-20 00:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
|
|
|
|
|
|
|
|