halasz/trynx-support-form

为网络应用程序提供支持表单。

安装: 42

依赖: 0

建议者: 0

安全: 0

星标: 1

观察者: 2

分支: 0

开放问题: 0

语言:JavaScript

v1.0.6 2021-10-30 11:48 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:57 UTC


README

此扩展将反馈表单添加到您的应用程序中。

安装

下载

安装 Halasz/TrynxSupportForm 的最佳方式是使用 Composer

$ composer require halasz/trynx-support-form

注册

您可以使用 neon 配置启用此扩展

extensions:
	TrynxSupportForm: Halasz\Support\SupportExtension

注入

您可以直接在 Presenters/Services 中注入工厂

public function __construct(Halasz\Support\Support\ISupportFormFactory $SupportFormFactory)
{
    parent::__construct();
    ....
}

演示者

当您需要在演示者中创建组件并在模板中使用时,可以像下面这样做。不要忘记使用命名空间 Halasz

    protected function createComponentSupportForm()
    {
        return $this->supportForm->create();
    }
	

模板

创建一个接口 ISupportFormFactory 的方法返回一个组件,因此您可以在 .latte 中直接调用

{control SupportForm}

默认的 .latte 文件用于绘制组件,您可以在 samples 文件夹中找到。您可以复制此模板并进行自定义。您可以通过配置文件指定模板的路径。

需求

重要!!!您必须将 samples 文件夹中的 css 和 js 文件链接到您的模板中。之后,您需要在 js 代码中调用 halasz.SupportForm.init(); - 在 jQuery 之后!!! 此扩展需要 jQuery v3.4.1Bootstrap v3.3.7netteForms.js v3html2canvas 1.0.0-rc.5。所有这些都在 samples 文件夹中。

配置

所有配置都是 可选的

必须在配置文件中指定配置

TrynxSupportForm:
	template: 'path/to/customized/template.latte'
	maxFiles: 3                                             # max files in multiselect 
	maxFileSize: 3145728                                    # max size of one file in musltiselect (in bytes)
	title: 'Feedback form'                                  # title of modal (top right text)
	invokeButtonText: 'online support'                      # text in button (bottom right on page)
	sendButtonText: 'Send feedback'                         # text in send button
	screenshotButtonText: 'Add Screenshot'                  # text in button which is used to make screenshot
	postUrl: 'http://halasz.ajaximple.cz/www/test/test'     # URL address where may be send data from formular
	syncToken: 'nothing'                                    # sync token, which is send to url with data from formular
	idEmail: 'email_identity_column_name'                   # email column name in $this->user->getIdentity();
	idEmail2: 'alternate email_identity_column_name'        # column name with alternate email in $this->user->getIdentity(); if it's value is not empty, it's used instead idEmail 
	idName: 'username_identity_column_name'                 # username column name in $this->user->getIdentity();
	defaultEmail: 'your@email.com'				# default email address for use when email in getIdentity() is empty    
	flashMessage:
		success: 'Your feedback has been sent. We will send E-Mail to you as soon as possible.'
		error: 'We have encountered an error. Please try it again later.'
	labels:                                                 # labels to form inputs
		message: 'Your message'
		image: 'Add screenshot'
		files: 'Add files'
		name: 'Name'
		email: 'E-Mail'
		subject: 'Subject'
	errors:                                                 # Theese texts are shown under inputs when there is an error.
		message: 'Required'
		name: 'Required'
		email: 'Required'
		subject: 'Required'
		image: 'Uploaded file must be an image'
		files_max: 'You can upload maximum %d files'
		files_size: 'Maximum file size is 3MB'
		files_mimes: 'Is allowed to upload only files with this types: GIF, JPG, PNG, txt, xls, doc, zip or rar'

在指定 URL 上接收数据

在 PHP 中

数据通过 POST 方法发送。 在 $_POST 中包括以下格式的数据

如果用户已登录
[
	'sync_token' => 'token',
	'dataxml' => '<xml>
<cl_users_id>123</cl_users_id>
<email>email</email>
<user_name>name</user_name>
<subject>subject</subject>
<message>message</message>
<screenshot>screenshot in BASE64</screenshot>
<file1>fileName1.ext</file1>
<file2>fileName2.ext</file2>
<file3>fileName3.ext</file3>
</xml>'
]
如果用户未登录
[
	'sync_token' => 'tokem',
	'dataxml' => '<xml>
<email>email</email>
<user_name>name</user_name>
<subject>subject</subject>
<message>message</message>
<screenshot>screenshot in BASE64</screenshot>
<file1>fileName1.ext</file1>
<file2>fileName2.ext</file2>
<file3>fileName3.ext</file3>
</xml>'
]

在这两种情况下都可以通过 $_FILES 访问文件1-3。$_FILES 内容的示例

[
	'fileName1_ext' => [
		name => 'randomTMPname',
		type => 'mime/type',
		tmp_name => 'path/to/tmp/folder/and/tmp/name/of/file'
		error => value,
		size => sizeOfFileInBytes
	],
	'fileName2_ext' => [...],
	'fileName3_ext' => [...]
]

屏幕截图提示

屏幕截图是从页面 body 元素生成的。屏幕截图的大小根据 body 元素的大小。在某些布局情况下,body 可能没有正确的高度,所以如果这个问题发生在您身上,请检查 body 元素的高度。

从指定 URL 返回的数据

此组件期望具有特定结构的 XML。

<xml>
<status></status>
<error_message></error_message>
</xml>
如果一切处理正确
<xml>
<status>OK</status>
<error_message></error_message>
</xml>
在出现某些错误的情况下
<xml>
<status>ERROR</status>
<error_message>Described error. Remember, it's shown to user.</error_message>
</xml>

翻译

组件具有自动装配的翻译器,该翻译器在配置文件中注册并实现 Nette\Localization\ITranslator,请参阅 Nette Localization

结论

此扩展需要 Nette3,并归 Tomas Halász 所有 © 2019