robertboloc / rbcomment
为Zend Framework 2应用程序的评论
Requires
- php: ^5.6 || ^7.0
- zendframework/zend-console: ^2.6
- zendframework/zend-db: ^2.8.1
- zendframework/zend-form: ^2.9
- zendframework/zend-http: ^2.5.4
- zendframework/zend-i18n: ^2.7.3
- zendframework/zend-inputfilter: ^2.7.2
- zendframework/zend-loader: ^2.5.1
- zendframework/zend-mail: ^2.7.1
- zendframework/zend-math: ^3.0
- zendframework/zend-mime: ^2.6
- zendframework/zend-modulemanager: ^2.7.2
- zendframework/zend-mvc: ^3.0.1
- zendframework/zend-mvc-plugin-flashmessenger: ^1.0
- zendframework/zend-serializer: ^2.8
- zendframework/zend-servicemanager: ^3.1
- zendframework/zend-stdlib: ^3.0.1
- zendframework/zend-view: ^2.8
- zendframework/zendservice-akismet: 2.0.2
Requires (Dev)
- phpunit/phpunit: ^5.7
- robertboloc/zf2-components-list-generator: dev-master
- squizlabs/php_codesniffer: ^2.7
This package is not auto-updated.
Last update: 2024-09-14 15:40:11 UTC
README
为Zend Framework 2提供的模块,用于集成自托管评论功能,支持电子邮件通知、Akismet、ZfcUser和Gravatar集成。
目录
安装
- 将模块密钥添加到您的
composer.json
文件中
{ "require": { "robertboloc/rbcomment": "^2.0" } }
-
运行
composer update
-
将schema从
data/schema.sql
导入到您的数据库中。 -
将新模块添加到您的应用模块列表中的
config/application.config.php
'modules' => array( 'Application', 'RbComment', // Add this ),
用法
在您的视图中,使用rbComment
助手显示计数、列表和添加新评论的表单。在您希望评论框出现的地方调用它。简单吧?此助手可用于任何视图。
<?php echo $this->rbComment($theme) ?>
$theme
参数用于指定评论框的主题(如果未指定,则使用default
)。
目前,该模块设计为每个页面只能有一个评论框,因为它使用页面uri来识别一个线程。
主题
目前,该模块提供了2个主题。要实现新的主题,请创建一个新的部分,以现有的部分为基础。
通过调用$this->rbComment('yourpartial')
使用您的新主题
当前主题(以及如果不使用自定义部分,则$theme
参数的可能值)为
default
没有外部依赖的基本主题。包含最少的设计风格,使其看起来不错。
<?php echo $this->rbComment() ?>
uikit
此主题需要UIkit CSS框架。如果您的项目基于UIkit框架,请使用此主题。
<?php echo $this->rbComment('uikit') ?>
bootstrap3
此主题需要Bootstrap v3.x.x CSS框架。如果您的项目基于Bootstrap框架(版本3),请使用此主题。
<?php echo $this->rbComment('bootstrap3') ?>
配置
模块的默认配置可以在文件config/module.config.php
中找到。要覆盖默认值,请在您的应用config/autoload/local.php
文件的rb_comment
键下添加您的值,使用与默认值相同的结构。
目前可配置的参数包括
default_visibility
此参数控制新发布评论的可见性。如果设置为1,所有新发布的评论都将可见。如果为0,则不会显示。这对于审核很有用。
strings
此数组包含在评论框中使用的字符串的翻译。要更改或翻译成其他语言,请使用您自己的值覆盖这些值。
此数组包含电子邮件通知参数
'email' => array( /** * Send email notifications. */ 'notify' => false, /** * Email addresses where to send the notification. */ 'to' => array(), /** * From header. Usually something like noreply@myserver.com */ 'from' => '', /** * Subject of the notification email. */ 'subject' => 'New Comment', /** * Text of the comment link. */ 'context_link_text' => 'See this comment in context', ),
为了发送电子邮件,模块使用名为RbComment\Mailer
的服务工厂。默认情况下,它配置了一个sendmail传输。在生产环境中,这应该被改变并定制以满足您的需求(可能使用smtp)。为此,重写服务工厂RbComment\Mailer
。
akismet
该模块提供与Akismet服务的集成。标记为垃圾邮件的评论将被隐藏(不会删除)且不会发送通知。要使用此功能,必须配置以下参数
'akismet' => array( /** * If this is true, the comment will be checked for spam. */ 'enabled' => false, /** * Your Akismet api key. */ 'api_key' => '', /** * Akismet uses IP addresses. If you are behind a proxy this SHOULD * be configured to avoid false positives. * Uses the class \Zend\Http\PhpEnvironment\RemoteAddress */ 'proxy' => array( /** * Use proxy addresses or not. */ 'use' => false, /** * List of trusted proxy IP addresses. */ 'trusted' => array( ), /** * HTTP header to introspect for proxies. */ 'header' => 'X-Forwarded-For', ), ),
zfc_user
默认情况下,ZfcUser集成是禁用的。要使用它,您必须在配置文件中更新此标志。
'zfc_user' => array( /** * This enables the ZfcUser integration. */ 'enabled' => false, ),
gravatar
默认情况下,Gravatar集成是禁用的。要使用它,您必须在配置文件中更新此标志。
'gravatar' => array( /** * This enables the Gravatar integration. */ 'enabled' => false, ),
命令行界面
以下命令行命令可用
delete spam
从数据库中删除所有标记为垃圾邮件的评论
可以将此内容添加到cron中,定期从数据库中删除垃圾邮件,以保持您的表整洁轻量。
路线图
如果您想为这个模块的开发做出贡献,但不知道从哪里开始,您可以挑选以下任务之一
- 允许在同一页面上有多个评论框实例
- 使用AJAX来存储/检索评论
- 表情符号集成
- 根据IP地址屏蔽垃圾邮件发送者
- 更多主题
备注
-
如果您正在使用BjyAuthorize模块(或任何其他路由限制模块),请确保路由
rbcomment
是公开可访问的。 -
本模块假定您已配置数据库适配器。