定制 halasz/trynx-support-form 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

halasz/trynx-support-form

Composer 安装命令:

composer require halasz/trynx-support-form

包简介

Support form for web applications.

README 文档

README

This extension add feedback form to your application.

Instalation

Download

The best way to install Halasz/TrynxSupportForm is using Composer:

$ composer require halasz/trynx-support-form

Registering

You can enable the extension using your neon config:

extensions:
	TrynxSupportForm: Halasz\Support\SupportExtension

Injecting

You can simply inject factory in Your Presenters/Services:

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

Presenter

When you need to create component in your presenter for use in template you can do it as shown bellow. Don't forget use namespace Halasz:

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

Templates

Create method of interface ISupportFormFactory returns an component, so in your .latte you can simply call:

{control SupportForm}

Default .latte file used to draw the component you can find in samples folder. You can copy this template and customize it. Path to the template you can specify via your config file.

Reqirements

IMPORTANT!!! you must link the css and js files from samples folder into your template. After that you need to call halasz.SupportForm.init(); in your js code - AFTER jQuery!!!. This extension requires jQuery v3.4.1, Bootstrap v3.3.7, netteForms.js v3 and html2canvas 1.0.0-rc.5. All of theese are included in samples folder.

Configuration

All config is optional.

Configuration must be specified in config file:

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'

Receive data on specified URL

In PHP:

Data are sent by POST method. In $_POST are included data in format:

If user is logged in:
[
	'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>'
]
If user is not logged in:
[
	'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>'
]

in both cases can be files1-3 accessed via $_FILES Example of $_FILES content

[
	'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' => [...]
]

Screenshot tips

Screenshot is generated from body element of page. Screenshot is taken according to size of body element. In some layout cases is possible that body doesn't have correct height, so if this issue hapen's to you, check height of body element.

Returned data from specified URL

This component is expecting XML with specified structure.

<xml>
<status></status>
<error_message></error_message>
</xml>
If everything is correctly processed:
<xml>
<status>OK</status>
<error_message></error_message>
</xml>
In case of some errors:
<xml>
<status>ERROR</status>
<error_message>Described error. Remember, it's shown to user.</error_message>
</xml>

Translation

Component has autowired translator, which is registered in config file and implements Nette\Localization\ITranslator see Nette Localization

Conclusion

This extension requires Nette3 and it is property of Tomas Halász © 2019

halasz/trynx-support-form 适用场景与选型建议

halasz/trynx-support-form 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 halasz/trynx-support-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 halasz/trynx-support-form 我们能提供哪些服务?
定制开发 / 二次开发

基于 halasz/trynx-support-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-12-23