来源于:http://trac.seagullproject.org/wiki/Modules/Comment

Comment Module(评论模块)

你可以将Comment模块添加到Seagull中的任何模块当中。FAQ和Publisher模块就是实例。

在Publisher中调用Comment模块

Comment本来是是为article设计的,要使用Comment模块只需在模块配置文件夹中设置 [commentsEnabled] = true。

对Comment模块的引用代码可以在_cmd_list行为方法中,如下:

//  display comments?
if (SGL::moduleIsEnabled('comment') && !empty($this->conf['ArticleViewMgr']['commentsEnabled'])) {
    $output->aComments = $this->da->getCommentsByEntityId('articleview',
        $input->articleID);
}

数据存取对象($this→da)在ArticleViewMgr类的构造函数中设置:

//  enable comments if configured
if (SGL::moduleIsEnabled('comment')) {
    require_once SGL_MOD_DIR  . '/comment/classes/CommentDAO.php';
    require_once SGL_CORE_DIR . '/Delegator.php';
    $dao = &CommentDAO::singleton();
    $this->da = new SGL_Delegator();
    $this->da->add($dao);
}

这个方法可以用在你的任何一个模块里。

如何从数据存取层调用getCommentsByEntityId()函数

注意数据存取调用的第一个参数:

$this→da→getCommentsByEntityId($entityName, $entityId)

实体名称是控制类名称去掉mgr部分,并全部小写,就和URI中一样。第二个参数是可选的,是当前实体的ID。

也就是说任何数量的Comment可以被联合到管理一个实体的控制类,在articlek中Comment可以和实体的一个实例进行联合。

在FAQ模块中使用Comment

假设你想让用户添加评论到你的FAQ版块,比如说如何对现存的FAQ进行改进。你只需在配置文件中启用Comment模块即可。

即将支持

除了可以将Comment和系统中的实体联合在一起,其它的实现是很简单的。要发展成一个羽翼丰满的Comment模块它还需要

  • 评论管理 (I'd like to see something similar to what the latest s9y has)
  • 使评论是可审核的 - 数据库中已存在相应字段
  • 集成CAPTCHA - 通过我们现存的 CAPTCHA 应该是很容易实现的
  • 为作者集成 http://www.gravatar.com/ 图标
  • 有能力提供反垃圾广告的Web服务 http://akismet.com/
 
modules/comment.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2