moved some ezc functions from templates/item.cpp to Item and ItemContent

removed: templates/item.cpp
updated: some html templates which use [item] or [item_tab]
removed some old html templates: item_info.html and itam_tab_info.html
master
Tomasz Sowa 2 years ago
parent 746aa41111
commit 9d65d931d0

File diff suppressed because one or more lines are too long

@ -359,7 +359,7 @@ void CorrectUrlOnlyAllowedChar(std::wstring & url)
// DEPRECATED now pt::Date can print a month in Roman numerals
const wchar_t * DateToStr(int year, int month, int day)
{
static const wchar_t * month_letter[] = { L"I", L"II", L"III", L"IV", L"V", L"VI", L"VII", L"VIII", L"IX", L"X", L"XI", L"XII" };
@ -383,6 +383,7 @@ static wchar_t buffer[100];
}
// DEPRECATED now pt::Date can print a month in Roman numerals
const wchar_t * DateToStr(int year, int month, int day, int hour, int min, int sec)
{
static const wchar_t * month_letter[] = { L"I", L"II", L"III", L"IV", L"V", L"VI", L"VII", L"VIII", L"IX", L"X", L"XI", L"XII" };

@ -29,7 +29,7 @@
[# template fun_ls.html uses the name: itemcontent to refer to this textarea item]
<div class="uk-form-controls">
<div style="border-top: 1px solid #dadada; border-bottom: 1px solid #dadada; padding: 0.2em 0 0.2em 0; margin: 1em 0 1em 0;" id="winix-editor-content" data-winix-post-name="itemcontent">[item_print_content]</div>
<div style="border-top: 1px solid #dadada; border-bottom: 1px solid #dadada; padding: 0.2em 0 0.2em 0; margin: 1em 0 1em 0;" id="winix-editor-content" data-winix-post-name="itemcontent">[item.content.print_content]</div>
</div>
</div>
@ -42,7 +42,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -5,7 +5,7 @@
[if request.is_item]
[if any request.is_item item_filetype_is_image]
[if any request.is_item item.content.filetype_is_image]
[if winix_function_param_is "thumb"]
<p>{imgcrop_crop_only_thumb_info}</p>
@ -80,7 +80,7 @@
<td data-uk-lightbox="animation: slide">
<a href="[item_tab.link]">
<img src="[item_tab.link][if item_tab.has_thumb]/-/thumb[end]" alt="[item_tab.subject]">
<img src="[item_tab.link][if item_tab.content.has_thumb]/-/thumb[end]" alt="[item_tab.subject]">
</a>
</td>

@ -9,7 +9,7 @@
</p>
<div class="uk-margin-top">
<a href="[doc_base_url][if dir_can_read_exec][dir][if any request.is_item item_can_read][item.url]/[end][else]/[end]logout" class="uk-button uk-button-primary uk-width-small">{login_logout_button}</a>
<a href="[doc_base_url][if dir_can_read_exec][dir][if any request.is_item item.has_read_access][item.url]/[end][else]/[end]logout" class="uk-button uk-button-primary uk-width-small">{login_logout_button}</a>
</div>
</div>
[else]

@ -44,7 +44,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -5,7 +5,7 @@
<p>
[if request.is_item]
[if item_type_is_symlink]
[if item.type_is_symlink]
{rm_symlink}: [dir][item.url]
[else]
{rm_file}: [dir][item.url]

@ -1,19 +1,7 @@
[if item.content.type_is "other"][item.run][else]
<div>
[if false]
[if mount_page_arg_is "subject"]
<h1>[item.subject]</h1>
[end]
[if mount_page_arg_is "info"]
[include "item_info.html"]
[end]
[end]
[item.execute]
</div>
[end]

@ -9,8 +9,8 @@
{template_info_file}:
[if item_has_html_template]
[item_html_template]
[if item.has_html_template]
[item.html_template]
[else]
{template_from_mount_point}

@ -1,15 +1,9 @@
<div class="winix winix-thread">
[if mount_page_arg_is "subject"]<h1[if mount_page_arg_is "info"] class="winix_withinfo"[end]>[item.subject]</h1>[end]
[if false]
[if mount_page_arg_is "info"][include "item_info.html"][end]
[end]
[if not [thread_mount_arg_is "sort_desc"]]
<div class="uk-margin">
[if item.has_write_access]<a class="uk-button uk-button-default uk-button-small" href="[item.link]/emacs" rel="nofollow">{edit}</a>[end]
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item.subject]</h2>[end]
[if thread_mount_arg_is "info"][include "item_info.html"][end]
<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item.subject]</h2>
[item.content.print_content]
</div>
[end]
@ -38,8 +32,7 @@
[if thread_mount_arg_is "sort_desc"]
<div class="uk-margin">
[if item.has_write_access]<a class="uk-button uk-button-default uk-button-small" href="[item.link]/emacs" rel="nofollow">{edit}</a>[end]
[if thread_mount_arg_is "subject"]<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item.subject]</h2>[end]
[if thread_mount_arg_is "info"][include "item_info.html"][end]
<h2[if thread_mount_arg_is "info"] class="winix_withinfo"[end]>[item.subject]</h2>
[item.content.print_content]
</div>
[end]

@ -1,10 +1,5 @@
<div class="winix">
[if mount_page_arg_is "subject"]<h1[if mount_page_arg_is "info"] class="withinfo"[end]>[item.subject]</h1>[end]
[if mount_page_arg_is "info"][include "item_info.html"][end]
<div class="uk-section uk-section-muted uk-padding">
[if ticket_can_edit]<p class="winix_ticket_edit"><a href="[doc_base_url][dir][item.url]/editticket" rel="nofollow">\[{edit}\]</a></p>[end]
<table class="uk-table uk-table-small">

@ -26,7 +26,7 @@
[if mount_type_is "ticket"]<label class="uk-form-label" for="winix_content_id">{form_emacs_content_ticket}</label>[end]
<div class="uk-form-controls">
<div style="border-top: 1px solid #dadada; border-bottom: 1px solid #dadada; padding: 0.2em 0 0.2em 0; margin: 1em 0 1em 0;" id="winix-editor-content" data-winix-post-name="itemcontent">[item_print_content]</div>
<div style="border-top: 1px solid #dadada; border-bottom: 1px solid #dadada; padding: 0.2em 0 0.2em 0; margin: 1em 0 1em 0;" id="winix-editor-content" data-winix-post-name="itemcontent">[item.content.print_content]</div>
</div>
</div>
@ -38,7 +38,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -42,7 +42,7 @@
<div class="uk-margin">
<label class="uk-form-label" for="winix_nick_id">{nick}</label>
<div class="uk-form-controls">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item_guest_name]">
<input class="uk-input" id="winix_nick_id" type="text" name="guestname" value="[item.content.guest_name]">
</div>
</div>

@ -1,5 +0,0 @@
<p class="uk-text-meta">
{added_by}: [item.content.display_user_name], [item_date_creation_nice][if not item_dates_equal],
{last_modified}[if item_users_different] {by}: [item_modification_user],[else]:[end]
[item_date_modification_nice][end]
</p>

@ -1,8 +0,0 @@
<p class="uk-text-meta">
{added_by}: [item_tab_user], [item_tab_date_creation_nice][if not item_tab_dates_equal],
{last_modified}[if item_tab_users_different] {by}: [item_tab_modification_user],[else]:[end]
[item_tab_date_modification_nice]
[end]
</p>

@ -92,6 +92,7 @@ void Item::fields()
field(L"execute", &Item::execute);
field(L"has_html_template", &Item::has_html_template);
// may we should add a method setTypeFromInt(int t)?
type = static_cast<Type>(type_helper);
@ -648,6 +649,11 @@ void Item::execute(EzcEnv & env)
}
bool Item::has_html_template()
{
return !html_template.empty();
}
} // namespace Winix

@ -197,6 +197,7 @@ public:
bool is_parent_for_current_dir() const;
bool is_current_dir() const;
bool has_html_template();
protected:

@ -90,6 +90,7 @@ void ItemContent::fields()
field(L"privileges_octal", &ItemContent::privileges_octal);
field(L"has_user", &ItemContent::has_user);
field(L"has_group", &ItemContent::has_group);
field(L"item_users_different", &ItemContent::item_users_different);
field(L"user", &ItemContent::user);
field(L"group", &ItemContent::group);
field(L"type_is", &ItemContent::type_is);
@ -106,6 +107,12 @@ void ItemContent::fields()
field(L"is_meta_object", &ItemContent::is_meta_object);
field(L"is_admin_meta_object", &ItemContent::is_admin_meta_object);
field(L"are_dates_equal", &ItemContent::are_dates_equal);
field(L"can_content_be_html_filtered", &ItemContent::CanContentBeHtmlFiltered);
field(L"is_link_to", &ItemContent::is_link_to);
field(L"is_link_redirect", &ItemContent::is_link_redirect);
// IMPROVEME prepare a setter functions which tests whether content_raw_type_helper and content_parsed_type_helper are correct values
content_raw_type = static_cast<ContentType>(content_raw_type_helper);
content_parsed_type = static_cast<ContentType>(content_parsed_type_helper);
@ -450,6 +457,13 @@ bool ItemContent::has_group() const
return group_id != -1;
}
bool ItemContent::item_users_different()
{
return user_id != modification_user_id;
}
void ItemContent::user(morm::Wrapper & wrapper)
{
Users * users = get_users();
@ -600,17 +614,36 @@ void ItemContent::display_user_name(EzcEnv & env)
}
bool ItemContent::is_meta_object()
bool ItemContent::is_meta_object() const
{
return meta.is_object();
}
bool ItemContent::is_admin_meta_object()
bool ItemContent::is_admin_meta_object() const
{
return admin_meta.is_object();
}
bool ItemContent::are_dates_equal() const
{
return date_creation == date_modification;
}
bool ItemContent::is_link_to() const
{
return !link_to.empty();
}
bool ItemContent::is_link_redirect() const
{
return link_redirect == 1;
}
} // namespace Winix

@ -272,10 +272,15 @@ public:
bool has_user() const;
bool has_group() const;
bool item_users_different();
bool is_meta_object();
bool is_admin_meta_object();
bool is_meta_object() const;
bool is_admin_meta_object() const;
bool are_dates_equal() const;
bool is_link_to() const;
bool is_link_redirect() const;
protected:

@ -1590,131 +1590,6 @@ ipban.o: ../../../winix/winixd/functions/upload.h
ipban.o: ../../../winix/winixd/functions/uptime.h
ipban.o: ../../../winix/winixd/functions/who.h
ipban.o: ../../../winix/winixd/functions/vim.h
item.o: templates.h ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
item.o: ../../../ezc/src/blocks.h ../../../ezc/src/item.h
item.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h
item.o: ../../../pikotools/src/utf8/utf8.h
item.o: ../../../pikotools/src/textstream/stream.h
item.o: ../../../pikotools/src/utf8/utf8_templates.h
item.o: ../../../pikotools/src/utf8/utf8_private.h ../../../ezc/src/funinfo.h
item.o: ../../../ezc/src/objects.h ../../../ezc/src/pattern.h
item.o: ../../../ezc/src/outstreams.h ../../../ezc/src/expressionparser.h
item.o: ../../../ezc/src/models.h ../../../pikotools/src/log/log.h
item.o: ../../../pikotools/src/textstream/textstream.h
item.o: ../../../pikotools/src/textstream/stream.h
item.o: ../../../pikotools/src/space/space.h
item.o: ../../../pikotools/src/textstream/types.h
item.o: ../../../pikotools/src/convert/inttostr.h
item.o: ../../../pikotools/src/date/date.h
item.o: ../../../pikotools/src/membuffer/membuffer.h
item.o: ../../../pikotools/src/textstream/types.h
item.o: ../../../pikotools/src/log/filelog.h ../../../ezc/src/patternparser.h
item.o: misc.h localefilter.h locale.h
item.o: ../../../pikotools/src/space/spaceparser.h
item.o: ../../../pikotools/src/space/space.h
item.o: ../../../winix/winixd/core/winixbase.h
item.o: ../../../winix/winixd/core/config.h ../../../winix/winixd/core/log.h
item.o: ../../../winix/winixd/core/logmanipulators.h ../../../morm/src/morm.h
item.o: ../../../morm/src/morm_types.h ../../../morm/src/model.h
item.o: ../../../morm/src/modelconnector.h ../../../morm/src/clearer.h
item.o: ../../../morm/src/dbconnector.h ../../../morm/src/queryresult.h
item.o: ../../../morm/src/ft.h ../../../morm/src/flatconnector.h
item.o: ../../../morm/src/dbexpression.h ../../../morm/src/baseexpression.h
item.o: ../../../morm/src/modelenv.h ../../../morm/src/modeldata.h
item.o: ../../../morm/src/cursorhelper.h ../../../morm/src/finderhelper.h
item.o: ../../../morm/src/fieldvaluehelper.h ../../../morm/src/wrapper.h
item.o: ../../../morm/src/spacewrapper.h
item.o: ../../../morm/src/baseobjectwrapper.h
item.o: ../../../morm/src/modelcontainerwrapper.h
item.o: ../../../pikotools/src/convert/text.h
item.o: ../../../morm/src/flatexpression.h ../../../morm/src/finder.h
item.o: ../../../morm/src/cursor.h ../../../morm/src/jsonexpression.h
item.o: ../../../morm/src/postgresqlexpression.h
item.o: ../../../morm/src/jsonconnector.h
item.o: ../../../morm/src/postgresqlconnector.h
item.o: ../../../morm/src/postgresqlqueryresult.h
item.o: ../../../winix/winixd/core/log.h ../../../winix/winixd/core/synchro.h
item.o: ../../../winix/winixd/core/filelog.h
item.o: ../../../winix/winixd/core/lock.h
item.o: ../../../winix/winixd/core/synchro.h
item.o: ../../../pikotools/src/convert/patternreplacer.h
item.o: ../../../pikotools/src/convert/strtoint.h
item.o: ../../../pikotools/src/convert/text.h htmltextstream.h
item.o: ../../../winix/winixd/core/textstream.h patterncacher.h
item.o: ../../../winix/winixd/models/item.h
item.o: ../../../winix/winixd/models/winixmodel.h
item.o: ../../../winix/winixd/models/winixmodelconnector.h
item.o: ../../../winix/winixd/models/itemcontent.h
item.o: ../../../winix/winixd/templates/htmltextstream.h
item.o: ../../../winix/winixd/templates/misc.h indexpatterns.h patterns.h
item.o: changepatterns.h ../../../winix/winixd/core/cur.h
item.o: ../../../winix/winixd/core/request.h
item.o: ../../../winix/winixd/core/requesttypes.h
item.o: ../../../winix/winixd/core/error.h
item.o: ../../../winix/winixd/core/config.h
item.o: ../../../winix/winixd/core/textstream.h
item.o: ../../../winix/winixd/models/winixmodel.h
item.o: ../../../winix/winixd/core/session.h
item.o: ../../../winix/winixd/models/user.h
item.o: ../../../winix/winixd/core/plugindata.h
item.o: ../../../winix/winixd/core/rebus.h
item.o: ../../../winix/winixd/core/winixbase.h
item.o: ../../../winix/winixd/core/ipban.h ../../../winix/winixd/core/mount.h
item.o: ../../../winix/winixd/core/system.h ../../../winix/winixd/core/job.h
item.o: ../../../winix/winixd/core/basethread.h
item.o: ../../../winix/winixd/core/winixmodeldeprecated.h
item.o: ../../../winix/winixd/core/plugin.h
item.o: ../../../winix/winixd/core/pluginmsg.h
item.o: ../../../winix/winixd/core/dirs.h
item.o: ../../../winix/winixd/core/dircontainer.h
item.o: ../../../winix/winixd/db/db.h ../../../winix/winixd/db/dbbase.h
item.o: ../../../winix/winixd/db/dbconn.h
item.o: ../../../winix/winixd/db/dbtextstream.h
item.o: ../../../winix/winixd/core/error.h
item.o: ../../../winix/winixd/models/group.h
item.o: ../../../winix/winixd/core/dircontainer.h
item.o: ../../../winix/winixd/core/ugcontainer.h
item.o: ../../../winix/winixd/core/mounts.h
item.o: ../../../winix/winixd/core/mountparser.h
item.o: ../../../winix/winixd/core/crypt.h ../../../winix/winixd/core/run.h
item.o: ../../../winix/winixd/core/users.h
item.o: ../../../winix/winixd/core/ugcontainer.h
item.o: ../../../winix/winixd/core/lastcontainer.h
item.o: ../../../winix/winixd/core/cur.h ../../../winix/winixd/core/groups.h
item.o: ../../../winix/winixd/core/loadavg.h
item.o: ../../../winix/winixd/core/image.h
item.o: ../../../winix/winixd/core/threadmanager.h
item.o: ../../../winix/winixd/models/winixmodelconnector.h
item.o: ../../../winix/winixd/notify/notify.h
item.o: ../../../winix/winixd/core/winixmodeldeprecated.h
item.o: ../../../winix/winixd/notify/notifypool.h
item.o: ../../../winix/winixd/templates/locale.h
item.o: ../../../winix/winixd/templates/patterns.h
item.o: ../../../winix/winixd/notify/notifythread.h
item.o: ../../../winix/winixd/core/basethread.h
item.o: ../../../winix/winixd/notify/templatesnotify.h
item.o: ../../../winix/winixd/core/users.h
item.o: ../../../winix/winixd/core/timezones.h
item.o: ../../../winix/winixd/core/timezone.h
item.o: ../../../winix/winixd/core/sessionmanager.h
item.o: ../../../winix/winixd/core/sessioncontainer.h
item.o: ../../../winix/winixd/core/ipbancontainer.h
item.o: ../../../winix/winixd/core/system.h
item.o: ../../../winix/winixd/core/sessionidmanager.h
item.o: ../../../tito/src/base64.h ../../../tito/src/aes.h
item.o: ../../../winix/winixd/core/htmlfilter.h
item.o: ../../../winix/winixd/core/winixrequest.h
item.o: ../../../winix/winixd/core/winixsystem.h
item.o: ../../../winix/winixd/core/slog.h
item.o: ../../../winix/winixd/core/request.h
item.o: ../../../winix/winixd/core/misc.h
item.o: ../../../winix/winixd/core/winix_const.h
item.o: ../../../pikotools/src/convert/convert.h
item.o: ../../../pikotools/src/convert/inttostr.h
item.o: ../../../pikotools/src/convert/patternreplacer.h
item.o: ../../../pikotools/src/convert/double.h
item.o: ../../../winix/winixd/core/bbcodeparser.h
item.o: ../../../winix/winixd/core/htmlfilter.h
last.o: templates.h ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
last.o: ../../../ezc/src/blocks.h ../../../ezc/src/item.h
last.o: ../../../ezc/src/cache.h ../../../ezc/src/functions.h

@ -1 +1 @@
o = adduser.o antispam.o changepatterns.o config.o currentdate.o dir.o doc.o filters.o generic.o htmltextstream.o indexpatterns.o insert.o ipban.o item.o last.o locale.o localefilter.o login.o ls.o man.o misc.o mount.o passwd.o patterncacher.o patterns.o priv.o rebus.o server.o slog.o stat.o sys.o template.o templates.o textextstream.o upload.o uptime.o user.o who.o winix.o
o = adduser.o antispam.o changepatterns.o config.o currentdate.o dir.o doc.o filters.o generic.o htmltextstream.o indexpatterns.o insert.o ipban.o last.o locale.o localefilter.o login.o ls.o man.o misc.o mount.o passwd.o patterncacher.o patterns.o priv.o rebus.o server.o slog.o stat.o sys.o template.o templates.o textextstream.o upload.o uptime.o user.o who.o winix.o

@ -1,858 +0,0 @@
/*
* This file is a part of Winix
* and is distributed under the 2-Clause BSD licence.
* Author: Tomasz Sowa <t.sowa@ttmath.org>
*/
/*
* Copyright (c) 2008-2021, Tomasz Sowa
* All rights reserved.
*
* 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.
*
*/
#include "templates.h"
#include "misc.h"
#include "core/request.h"
#include "core/misc.h"
#include "core/bbcodeparser.h"
#include "core/textstream.h"
namespace Winix
{
namespace TemplatesFunctions
{
static HtmlTextStream item_run_content;
static EzcGen ezc_generator;
//void item_is(Info & i)
//{
// i.res = cur->request->is_item;
//}
//void item_no_is(Info & i)
//{
// i.res = !cur->request->is_item;
//}
//void item_id(Info & i)
//{
// i.out << cur->request->last_item->id;
//}
//void item_subject(Info & i)
//{
// i.out << cur->request->last_item->subject;
//}
//void item_subject_noescape(Info & i)
//{
// i.out << R(cur->request->last_item->subject);
//}
//void item_content(Info & i)
//{
// i.out << cur->request->last_item->item_content.content_raw;
//}
//void item_content_noescape(Info & i)
//{
// i.out << R(cur->request->last_item->item_content.content_raw);
//}
//void item_content_type_is(Item & item, Info & i)
//{
// i.res = false;
//
// if( item.item_content.content_raw_type == ItemContent::ct_text && i.par == L"text" )
// i.res = true;
// else
// if( item.item_content.content_raw_type == ItemContent::ct_formatted_text && i.par == L"formatted text" )
// i.res = true;
// else
// if( item.item_content.content_raw_type == ItemContent::ct_html && i.par == L"html" )
// i.res = true;
// else
// if( item.item_content.content_raw_type == ItemContent::ct_bbcode && i.par == L"bbcode" )
// i.res = true;
// else
// if( item.item_content.content_raw_type == ItemContent::ct_other && i.par == L"other" )
// i.res = true;
//}
//
//
//void item_content_type_is(Info & i)
//{
// item_content_type_is(*cur->request->last_item, i);
//}
//void item_content_is_empty(Info & i)
//{
// i.res = cur->request->last_item->item_content.content_raw.empty();
//}
//void item_privileges(Info & i)
//{
// i.out << Toa(cur->request->last_item->item_content.privileges, 8);
//}
// RENAMED TO item.dir_link
//void item_dir(Info & i)
//{
// dir(i);
//}
//void item_url(Info & i)
//{
// i.out << cur->request->last_item->url;
//}
//void item_url_is(Info & i)
//{
// i.res = (cur->request->last_item->url == i.par);
//}
//void item_url_is_no(Info & i)
//{
// i.res = (cur->request->last_item->url != i.par);
//}
//void item_link(Info & i)
//{
// doc_proto(i);
//
// if( !cur->request->subdomain.empty() )
// i.out << cur->request->subdomain << '.';
//
// i.out << config->base_url;
// item_dir(i);
// item_url(i);
//}
//void item_filetype_is_none(Info & i)
//{
// i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_NONE;
//}
//
//
//void item_filetype_is_image(Info & i)
//{
// i.res = cur->request->last_item->item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE;
//}
//void item_has_static_file(Info & i)
//{
// i.res = cur->request->last_item->item_content.file_type != WINIX_ITEM_FILETYPE_NONE && !cur->request->last_item->item_content.file_path.empty();
//}
//void item_has_thumb(Info & i)
//{
// i.res = cur->request->last_item->item_content.file_has_thumb;
//}
// changed to item.has_read_access
//void item_can_read(Info & i)
//{
// i.res = system->HasReadAccess(*cur->request->last_item);
//}
// changed to item.has_write_access
//void item_can_write(Info & i)
//{
// i.res = system->HasWriteAccess(*cur->request->last_item);
//}
// changed to item.can_be_removed
//void item_can_remove(Info & i)
//{
// // !! tutaj trzeba bedzie cos innego zrobic
// // zwlaszcza jak dojdzie sticky bit
// i.res = system->HasWriteAccess(*cur->request->dir_tab.back());
//}
//void item_user(Info & i)
//{
// User * puser = system->users.GetUser(cur->request->last_item->item_content.user_id);
// print_user_name(i, puser, cur->request->last_item->item_content.guest_name);
//}
void item_modification_user(Info & i)
{
User * puser = system->users.GetUser(cur->request->last_item->item_content.modification_user_id);
print_user_name(i, puser, cur->request->last_item->item_content.guest_name);
}
void item_users_different(Info & i)
{
i.res = (cur->request->last_item->item_content.user_id != cur->request->last_item->item_content.modification_user_id);
}
void item_date_creation(Info & i)
{
pt::Date date = system->ToLocal(cur->request->last_item->item_content.date_creation);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
void item_date_modification(Info & i)
{
pt::Date date = system->ToLocal(cur->request->last_item->item_content.date_modification);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
void item_date_creation_nice(Info & i)
{
print_date_nice(i, cur->request->last_item->item_content.date_creation);
}
void item_date_modification_nice(Info & i)
{
print_date_nice(i, cur->request->last_item->item_content.date_modification);
}
void item_dates_equal(Info & i)
{
pt::Date & date1 = cur->request->last_item->item_content.date_creation;
pt::Date & date2 = cur->request->last_item->item_content.date_modification;
i.res = date1 == date2;
}
//void item_run(Info & i)
//{
// if( !cur->request->is_item )
// {
// i.out << "<!-- there is no an item to run -->";
// return;
// }
//
// if( system->HasReadExecAccess(*cur->request->last_item) )
// {
// Ezc::Pattern * p = pattern_cacher.GetPattern(*cur->request->last_item);
//
// item_run_content.Clear();
// InitGenerator(ezc_generator, cur->request->models);
// ezc_generator.SetPattern(*p);
//
// if( config->allow_ezc_frames_in_executable_items )
// ezc_generator.Generate(item_run_content, cur->request->out_streams);
// else
// ezc_generator.Generate(item_run_content);
//
// ItemContent::print_content(i.out, item_run_content.Str(), cur->request->last_item->item_content.content_raw_type, config->html_filter);
// }
// else
// {
// i.out << "<!-- run: permission denied -->";
// }
//}
//void item_guest_name(Info & i)
//{
// i.out << cur->request->last_item->item_content.guest_name;
//}
//void item_html_template(Info & i)
//{
// i.out << cur->request->last_item->html_template;
//}
void item_has_html_template(Info & i)
{
i.res = !cur->request->last_item->html_template.empty();
}
//void item_type_is_dir(Info & i)
//{
// i.res = cur->request->last_item->type == Item::dir;
//}
//
//
//void item_type_is_file(Info & i)
//{
// i.res = cur->request->last_item->type == Item::file;
//}
//
//
//void item_type_is_symlink(Info & i)
//{
// i.res = cur->request->last_item->type == Item::symlink;
//}
void item_is_link_to(Info & i)
{
i.res = !cur->request->last_item->item_content.link_to.empty();
}
void item_link_to(Info & i)
{
i.out << cur->request->last_item->item_content.link_to;
}
void item_is_link_redirect(Info & i)
{
i.res = cur->request->last_item->item_content.link_redirect == 1;
}
void item_file_size(Info & i)
{
i.res = cur->request->last_item->item_content.file_size;
}
void item_sort(Info & i)
{
i.out << cur->request->last_item->sort_index;
}
//void item_meta_str(Info & i)
//{
// cur->request->last_item->item_content.meta.serialize_to_space_stream(i.out, true);
//}
//
//
//void item_meta(Info & i)
//{
// space_value(i, cur->request->last_item->item_content.meta);
//}
//
//
//void item_meta_noescape(Info & i)
//{
// space_value(i, cur->request->last_item->item_content.meta, false);
//}
//void item_meta_tab(Info & i)
//{
// space_list_tab(i, cur->request->last_item->item_content.meta);
//}
//
//
//void item_meta_tab_value(Info & i)
//{
// space_list_tab_value(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
//}
//
//
//
//void item_meta_tab_has_next(Info & i)
//{
// space_list_tab_has_next(i, cur->request->last_item->item_content.meta, L"item_meta_tab");
//}
//void item_admin_meta_str(Info & i)
//{
// cur->request->last_item->item_content.meta_admin.serialize_to_space_stream(i.out, true);
//}
//
//
//void item_admin_meta(Info & i)
//{
// space_value(i, cur->request->last_item->item_content.meta_admin);
//}
//
//
//void item_admin_meta_tab(Info & i)
//{
// space_list_tab(i, cur->request->last_item->item_content.meta_admin);
//}
//
//
//void item_admin_meta_tab_value(Info & i)
//{
// space_list_tab_value(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
//}
//
//
//void item_admin_meta_tab_has_next(Info & i)
//{
// space_list_tab_has_next(i, cur->request->last_item->item_content.meta_admin, L"item_admin_meta_tab");
//}
//
void item_can_content_be_html_filtered(Info & i)
{
i.res = cur->request->last_item->item_content.CanContentBeHtmlFiltered();
}
/*
static size_t item_index;
void item_tab(Info & i)
{
item_index = i.iter;
i.res = item_index < cur->request->item_tab.size();
}
void item_tab_index(Info & i)
{
i.out << item_index;
}
void item_tab_id(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].id;
}
void item_tab_subject(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].subject;
}
void item_tab_subject_noescape(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << R(cur->request->item_tab[item_index].subject);
}
void item_tab_content(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].item_content.content_raw;
}
void item_tab_content_noescape(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << R(cur->request->item_tab[item_index].item_content.content_raw);
}
void item_tab_print_content(Info & i)
{
if( item_index >= cur->request->item_tab.size() )
return;
std::wstring & content = cur->request->item_tab[item_index].item_content.content_raw;
ItemContent::ContentType type = cur->request->item_tab[item_index].item_content.content_raw_type;
item_print_content(i.out, content, type);
}
void item_tab_privileges(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << "0" << Toa(cur->request->item_tab[item_index].item_content.privileges, 8);
}
void item_tab_dir(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
std::wstring path;
if( system->dirs.MakePath(cur->request->item_tab[item_index].parent_id, path) )
i.out << path;
else
i.out << "/the path does not exist/"; // !! IMPROVEME move me to locales and put some info to log
}
}
void item_tab_url(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].url;
}
void item_tab_link(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
doc_proto(i);
if( !cur->request->subdomain.empty() )
i.out << cur->request->subdomain << '.';
i.out << config->base_url;
item_tab_dir(i);
item_tab_url(i);
}
}
void item_tab_filetype_is_none(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].item_content.file_type == WINIX_ITEM_FILETYPE_NONE;
}
void item_tab_filetype_is_image(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].item_content.file_type == WINIX_ITEM_FILETYPE_IMAGE;
}
void item_tab_can_read(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
if( system->HasReadAccess(cur->request->item_tab[item_index]) )
i.res = true;
}
}
void item_tab_can_write(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
if( system->HasWriteAccess(cur->request->item_tab[item_index]) )
i.res = true;
}
}
void item_tab_user(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
User * puser = system->users.GetUser(cur->request->item_tab[item_index].item_content.user_id);
print_user_name(i, puser, cur->request->item_tab[item_index].item_content.guest_name);
}
}
void item_tab_modification_user(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
User * puser = system->users.GetUser(cur->request->item_tab[item_index].item_content.modification_user_id);
print_user_name(i, puser, cur->request->item_tab[item_index].item_content.guest_name);
}
}
void item_tab_users_different(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
i.res = (cur->request->item_tab[item_index].item_content.user_id != cur->request->item_tab[item_index].item_content.modification_user_id);
}
}
void item_tab_group(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
long group_id = cur->request->item_tab[item_index].item_content.group_id;
Group * pgroup = system->groups.GetGroup(group_id);
if( pgroup )
i.out << pgroup->name;
else
i.out << group_id;
}
}
void item_tab_date_creation(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
pt::Date date = system->ToLocal(cur->request->item_tab[item_index].item_content.date_creation);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
}
void item_tab_date_modification(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
pt::Date date = system->ToLocal(cur->request->item_tab[item_index].item_content.date_modification);
i.out << DateToStr(date.year, date.month, date.day, date.hour, date.min, date.sec);
}
}
void item_tab_date_creation_nice(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
print_date_nice(i, cur->request->item_tab[item_index].item_content.date_creation);
}
}
void item_tab_date_modification_nice(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
print_date_nice(i, cur->request->item_tab[item_index].item_content.date_modification);
}
}
void item_tab_dates_equal(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
pt::Date & date1 = cur->request->item_tab[item_index].item_content.date_creation;
pt::Date & date2 = cur->request->item_tab[item_index].item_content.date_modification;
i.res = date1 == date2;
}
}
void item_tab_run(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
if( system->HasReadExecAccess(cur->request->item_tab[item_index]) )
{
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item_tab[item_index]);
item_run_content.Clear();
InitGenerator(ezc_generator, cur->request->models);
ezc_generator.SetPattern(*p);
if( config->allow_ezc_frames_in_executable_items )
ezc_generator.Generate(item_run_content, cur->request->out_streams);
else
ezc_generator.Generate(item_run_content);
item_print_content(i.out, item_run_content.Str(), cur->request->item_tab[item_index].item_content.content_raw_type);
}
else
{
i.out << "<!-- run: permission denied -->";
}
}
}
void item_tab_can_use_emacs(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
// !!
//i.res = cur->request->CanUseEmacs(cur->request->item_tab[item_index], true);
}
}
void item_tab_has_static_file(Info & i)
{
if( item_index < cur->request->item_tab.size() )
{
i.res = cur->request->item_tab[item_index].item_content.file_type != WINIX_ITEM_FILETYPE_NONE &&
!cur->request->item_tab[item_index].item_content.file_path.empty();
}
}
void item_tab_has_thumb(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].item_content.file_has_thumb;
}
void item_tab_type_is_dir(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].type == Item::dir;
}
void item_tab_type_is_file(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].type == Item::file;
}
void item_tab_type_is_symlink(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].type == Item::symlink;
}
void item_tab_is_link_to(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = !cur->request->item_tab[item_index].item_content.link_to.empty();
}
void item_tab_link_to(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].item_content.link_to;
}
void item_tab_is_link_redirect(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.res = cur->request->item_tab[item_index].item_content.link_redirect == 1;
}
void item_tab_file_size(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].item_content.file_size;
}
void item_tab_sort(Info & i)
{
if( item_index < cur->request->item_tab.size() )
i.out << cur->request->item_tab[item_index].sort_index;
}
void item_tab_has_next(Info & i)
{
i.res = item_index + 1 < cur->request->item_tab.size();
}
void item_tab_meta_str(Info & i)
{
if( item_index < cur->request->item_tab.size() )
cur->request->item_tab[item_index].item_content.meta.serialize_to_space_stream(i.out, true);
}
void item_tab_meta(Info & i)
{
if( item_index < cur->request->item_tab.size() )
space_value(i, cur->request->item_tab[item_index].item_content.meta);
}
void item_tab_meta_noescape(Info & i)
{
if( item_index < cur->request->item_tab.size() )
space_value(i, cur->request->item_tab[item_index].item_content.meta, false);
}
void item_tab_meta_tab(Info & i)
{
if( item_index < cur->request->item_tab.size() )
space_list_tab(i, cur->request->item_tab[item_index].item_content.meta);
}
void item_tab_meta_tab_value(Info & i)
{
if( item_index < cur->request->item_tab.size() )
space_list_tab_value(i, cur->request->item_tab[item_index].item_content.meta, L"item_tab_meta_tab");
}
void item_tab_meta_tab_has_next(Info & i)
{
if( item_index < cur->request->item_tab.size() )
space_list_tab_has_next(i, cur->request->item_tab[item_index].item_content.meta, L"item_tab_meta_tab");
}
*/
} // namespace TemplatesFunctions
} // namespace Winix

@ -339,29 +339,6 @@ void Templates::CreateFunctions()
ezc_functions.Insert("doc_css_more_than_one", doc_css_more_than_one);
/*
env
*/
// ezc_functions.Insert("env_str", env_str);
// ezc_functions.Insert("env", env);
// ezc_functions.Insert("env_tab", env_tab);
// ezc_functions.Insert("env_tab_value", env_tab_value);
// ezc_functions.Insert("env_tab_has_next", env_tab_has_next);
// ezc_functions.Insert("env_admin_str", env_admin_str);
// ezc_functions.Insert("env_admin", env_admin);
// ezc_functions.Insert("env_admin_tab", env_admin_tab);
// ezc_functions.Insert("env_admin_tab_value", env_admin_tab_value);
// ezc_functions.Insert("env_admin_tab_has_next", env_admin_tab_has_next);
// ezc_functions.Insert("env_user_admin_env_str", env_user_admin_env_str);
// ezc_functions.Insert("env_user_env_str", env_user_env_str);
// ezc_functions.Insert("env_user_id", env_user_id);
// ezc_functions.Insert("env_user_name", env_user_name);
// ezc_functions.Insert("env_user_tab", env_user_tab);
// ezc_functions.Insert("env_user_tab_id", env_user_tab_id);
// ezc_functions.Insert("env_user_tab_name", env_user_tab_name);
// ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current);
/*
filters
*/
@ -429,111 +406,6 @@ void Templates::CreateFunctions()
ezc_functions.Insert("ipban_tab_is_logging_allowed", ipban_tab_is_logging_allowed);
/*
item
*/
//ezc_functions.Insert("item_is", item_is);
//ezc_functions.Insert("item_no_is", item_no_is);
// ezc_functions.Insert("item_id", item_id);
// ezc_functions.Insert("item_subject", item_subject);
// ezc_functions.Insert("item_subject_noescape", item_subject_noescape);
// ezc_functions.Insert("item_content_is_empty", item_content_is_empty);
// ezc_functions.Insert("item_content", item_content);
// ezc_functions.Insert("item_content_noescape", item_content_noescape);
// ezc_functions.Insert("item_content_type_is", item_content_type_is);
//ezc_functions.Insert("item_privileges", item_privileges);
// ezc_functions.Insert("item_dir", item_dir);
// ezc_functions.Insert("item_url", item_url);
// ezc_functions.Insert("item_url_is", item_url_is);
// ezc_functions.Insert("item_url_is_no", item_url_is_no);
// ezc_functions.Insert("item_link", item_link);
// ezc_functions.Insert("item_filetype_is_none", item_filetype_is_none);
// ezc_functions.Insert("item_filetype_is_image", item_filetype_is_image);
//ezc_functions.Insert("item_has_static_file", item_has_static_file);
// ezc_functions.Insert("item_has_thumb", item_has_thumb);
// ezc_functions.Insert("item_can_read", item_can_read);
// ezc_functions.Insert("item_can_write", item_can_write);
// ezc_functions.Insert("item_can_remove", item_can_remove);
//ezc_functions.Insert("item_user", item_user);
ezc_functions.Insert("item_modification_user", item_modification_user);
ezc_functions.Insert("item_users_different", item_users_different);
ezc_functions.Insert("item_date_creation", item_date_creation);
ezc_functions.Insert("item_date_modification", item_date_modification);
ezc_functions.Insert("item_date_creation_nice", item_date_creation_nice);
ezc_functions.Insert("item_date_modification_nice",item_date_modification_nice);
ezc_functions.Insert("item_dates_equal", item_dates_equal);
// ezc_functions.Insert("item_run", item_run);
// ezc_functions.Insert("item_guest_name", item_guest_name);
// ezc_functions.Insert("item_html_template", item_html_template);
ezc_functions.Insert("item_has_html_template", item_has_html_template);
// ezc_functions.Insert("item_type_is_dir", item_type_is_di