模块化发表主题功能发表主题的方法只实现最简单的普通主题的发表功能,其它主题功能如特殊主题、抢楼帖、分类信息等均以扩展方式实现3 D9 具体实现方法是:给model_forum_thread->newthread()方法的执行前后绑定相应的扩展方法,部分代码如下:
- $modthread = C::m('forum_thread');
- $bfmethods = $afmethods = array();//note 抢楼贴
- }
- if($_GET['rushreply']) { $bfmethods[] = array('class' => 'extend_thread_rushreply', 'method' => 'before_newthread');
- $afmethods[] = array('class' => 'extend_thread_rushreply', 'method' => 'after_newthread');
- }
- { //noteX 回帖送积分(不使用标志位)
- $bfmethods[] = array('class' => 'extend_thread_replycredit', 'method' => 'before_newthread');
- $afmethods[] = array('class' => 'extend_thread_replycredit', 'method' => 'after_newthread');
- if($sortid) {
- $bfmethods[] = array('class' => 'extend_thread_sort', 'method' => 'before_newthread');
- } $afmethods[] = array('class' => 'extend_thread_sort', 'method' => 'after_newthread');
- }
- $bfmethods[] = array('class' => 'extend_thread_allowat', 'method' => 'before_newthread');
- $afmethods[] = array('class' => 'extend_thread_allowat', 'method' => 'after_newthread');
- $afmethods[] = array('class' => 'extend_thread_image', 'method' => 'after_newthread');
- if(!empty($_GET['adddynamic'])) {
- $afmethods[] = array('class' => 'extend_thread_follow', 'method' => 'after_newthread');
- }
- $modthread->attach_before_methods('newthread', $bfmethods);
- $modthread->attach_after_methods('newthread', $afmethods);
复制代码
|