/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010-2012, Tomasz Sowa * All rights reserved. * */ #include "templates.h" #include "misc.h" #include "core/misc.h" #include "core/request.h" #include "core/user.h" namespace TemplatesFunctions { void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in) { std::wstring::const_iterator i; int was_enter = 0; // how many enteres there were before if( in.empty() ) return; out << R("
"); // !! pozbyc sie wstawianie tego html tutaj (wrzucic w jakis sposob do szablonow)
// skipping first new line characters
for(i = in.begin() ; i != in.end() && (*i==13 || *i==10) ; ++i);
for( ; i != in.end() ; ++i )
{
if( *i == 13 ) // skipping stupid characters (\r\n\ in dos mode)
continue;
if( *i == 10 )
{
++was_enter;
}
else
{
if( was_enter == 1 )
out << R("
\n");
else
if( was_enter > 1 )
out << R("
"); was_enter = 0; } out << *i; } out << R("
\n"); } void print_hour_min(Info & i, time_t time) { char buffer[100]; int hours = time / 60 / 60; int mins = (time / 60 - hours * 60); sprintf(buffer, "%02d:%02d", hours, mins); i.out << buffer; } void print_date_nice(Info & i, const PT::Date & date) { time_t one_day = 60 * 60 * 24; PT::Date ltm = system->ToLocal(date); if( date + one_day > cur->request->start_time ) i.out << DateToStr(ltm.year, ltm.month, ltm.day, ltm.hour, ltm.min, ltm.sec); else i.out << DateToStr(ltm.year, ltm.month, ltm.day); } void print_user_name(Info & i, const User * puser, const std::wstring & guest_name) { if( puser ) { i.out << puser->name; } else { i.out << "~"; if( !guest_name.empty() ) i.out << guest_name; else i.out << "guest"; // !! dodac do konfiga } } } // namespace TemplatesFunctions