2008-12-30 02:05:03 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2021-05-11 22:20:46 +02:00
|
|
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
2008-12-30 02:05:03 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-30 02:05:03 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "templates.h"
|
2011-06-24 22:53:21 +02:00
|
|
|
#include "core/request.h"
|
|
|
|
#include "core/misc.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2011-08-18 01:09:47 +02:00
|
|
|
static std::wstring doc_proto_str;
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void doc_title(Info & i)
|
|
|
|
{
|
2012-07-15 17:49:48 +02:00
|
|
|
bool was_dir = false;
|
2010-02-15 01:31:14 +01:00
|
|
|
|
2012-07-15 17:49:48 +02:00
|
|
|
for(size_t a=0 ; a<cur->request->dir_tab.size() ; ++a)
|
2009-06-07 04:40:27 +02:00
|
|
|
{
|
2011-11-25 05:51:55 +01:00
|
|
|
if( !cur->request->dir_tab[a]->subject.empty() )
|
|
|
|
{
|
2012-07-15 17:49:48 +02:00
|
|
|
if( was_dir )
|
|
|
|
i.out << config->title_separator;
|
|
|
|
|
2011-11-25 05:51:55 +01:00
|
|
|
i.out << cur->request->dir_tab[a]->subject;
|
|
|
|
was_dir = true;
|
|
|
|
}
|
2009-06-07 04:40:27 +02:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
2012-07-15 17:49:48 +02:00
|
|
|
if( cur->request->is_item &&
|
|
|
|
!cur->request->item.subject.empty() &&
|
|
|
|
cur->request->item.subject != cur->request->dir_tab.back()->subject
|
|
|
|
)
|
2009-06-07 04:40:27 +02:00
|
|
|
{
|
2010-02-15 19:22:16 +01:00
|
|
|
if( was_dir )
|
2010-08-10 18:12:50 +02:00
|
|
|
i.out << config->title_separator;
|
2010-02-15 19:22:16 +01:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->item.subject;
|
2012-07-15 17:49:48 +02:00
|
|
|
was_dir = true;
|
2009-06-07 04:40:27 +02:00
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-18 01:09:47 +02:00
|
|
|
void doc_proto(Info & i)
|
|
|
|
{
|
|
|
|
system->PutUrlProto(config->use_ssl, doc_proto_str);
|
|
|
|
i.out << doc_proto_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_proto_static(Info & i)
|
|
|
|
{
|
|
|
|
system->PutUrlProto(config->use_ssl_static, doc_proto_str);
|
|
|
|
i.out << doc_proto_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_proto_common(Info & i)
|
|
|
|
{
|
|
|
|
system->PutUrlProto(config->use_ssl_common, doc_proto_str);
|
|
|
|
i.out << doc_proto_str;
|
|
|
|
}
|
2008-12-30 02:05:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
void doc_base_url(Info & i)
|
|
|
|
{
|
2011-08-18 01:09:47 +02:00
|
|
|
doc_proto(i);
|
2012-04-22 20:23:44 +02:00
|
|
|
|
|
|
|
if( !cur->request->subdomain.empty() )
|
|
|
|
i.out << cur->request->subdomain << '.';
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
i.out << config->base_url;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
void doc_base_url_static(Info & i)
|
2010-02-11 21:56:52 +01:00
|
|
|
{
|
2011-08-18 01:09:47 +02:00
|
|
|
doc_proto_static(i);
|
2010-08-10 18:12:50 +02:00
|
|
|
i.out << config->base_url_static;
|
2010-02-11 21:56:52 +01:00
|
|
|
}
|
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
void doc_base_url_common(Info & i)
|
2009-12-30 21:46:12 +01:00
|
|
|
{
|
2011-08-18 01:09:47 +02:00
|
|
|
doc_proto_common(i);
|
2010-08-10 18:12:50 +02:00
|
|
|
i.out << config->base_url_common;
|
2009-12-30 21:46:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-22 23:52:09 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
void doc_current_url(Info & i)
|
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
i.out << cur->request->env_request_uri;
|
2008-12-30 02:05:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
static size_t doc_css_index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
cur->session->last_css is set by some javascript wysiwyg editors (ckeditor, tinymce)
|
|
|
|
*/
|
|
|
|
void doc_css_tab(Info & i)
|
|
|
|
{
|
|
|
|
doc_css_index = i.iter;
|
|
|
|
i.res = doc_css_index < cur->session->last_css.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_tab_file(Info & i)
|
|
|
|
{
|
|
|
|
if( doc_css_index < cur->session->last_css.size() )
|
|
|
|
i.out << cur->session->last_css[doc_css_index];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_tab_file_is_global(Info & i)
|
|
|
|
{
|
2011-09-13 08:08:34 +02:00
|
|
|
// !! z konfiga wziasc przedrostki
|
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
if( doc_css_index < cur->session->last_css.size() )
|
2021-05-20 20:59:12 +02:00
|
|
|
i.res = pt::is_substr(L"http://", cur->session->last_css[doc_css_index].c_str()) ||
|
|
|
|
pt::is_substr(L"https://", cur->session->last_css[doc_css_index].c_str());
|
2011-06-24 22:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_tab_has_next(Info & i)
|
|
|
|
{
|
|
|
|
i.res = (doc_css_index + 1 < cur->session->last_css.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_is_empty(Info & i)
|
|
|
|
{
|
|
|
|
i.res = cur->session->last_css.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_is_one(Info & i)
|
|
|
|
{
|
|
|
|
i.res = cur->session->last_css.size() == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void doc_css_more_than_one(Info & i)
|
|
|
|
{
|
|
|
|
i.res = cur->session->last_css.size() > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
} // namespace TemplatesFunctions
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
|