/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010, Tomasz Sowa * All rights reserved. * */ #include "templates.h" #include "misc.h" #include "core/misc.h" #include "core/request.h" namespace TemplatesFunctions { /* bool HtmlTryChar(TextStream & out, wchar_t c) { if( c == '<' ) { out << L"<"; return true; } else if( c == '>' ) { out << L">"; return true; } else if( c == '&' ) { out << L"&"; return true; } return false; } void HtmlEscape(TextStream & out, const std::wstring & in) { std::wstring::const_iterator i; for(i = in.begin() ; i != in.end() ; ++i) { if( !HtmlTryChar(out, *i) ) out << *i; } } std::wstring HtmlEscape(const std::wstring & in) { TextStream out; HtmlEscape(out, in); return out.Str(); } */ 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("

\n

"); was_enter = 0; } out << *i; } out << R("

\n"); } /* std::wstring HtmlEscapeFormTxt(const std::wstring & in) { TextStream out; HtmlEscapeFormTxt(out, in); return out.Str(); } */ void print_date_nice(Info & i, const tm & rtm) { time_t t = Time(rtm); time_t now = std::time(0); time_t one_day = 60 * 60 * 24; tm ltm = system->LocalTime(rtm); if( t + one_day > now ) i.out << DateToStr(ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec); else i.out << DateToStr(ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday); } 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 } } int ParseCKeditorFun() { ckeditor_getparser.fun_num = 2; // default if there is a problem with parsing info if( !request->get_tab.empty() ) { size_t last = request->get_tab.size()-1; if( !request->get_tab[last].empty() ) { static std::string get; AssignString(request->get_tab[last], get); ckeditor_getparser.Parse(get.c_str() + 1); // the first char is '?' } } return ckeditor_getparser.fun_num; } // those functions from here are used in the second thread too void ClearPatterns(Patterns & patterns, size_t len) { size_t loc, pat; patterns.resize(Locale::lang_unknown); for(loc=0 ; loc < static_cast(Locale::lang_unknown) ; ++loc) { patterns[loc].resize(len); for(pat=0 ; pat