-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAction.php
More file actions
51 lines (49 loc) · 2.05 KB
/
Action.php
File metadata and controls
51 lines (49 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
* 发送邮件操作
* @author 绛木子 <master@lixianhua.com>
*/
class TeComment_Action extends Typecho_Widget implements Widget_Interface_Do{
public function comment($cid){
$setting = Helper::options()->plugin('TeComment');
$this->request->setParam('cid',$cid);
$archive = $this->widget('Widget_Archive', array('type'=>'single'));
if(!$archive->have() || !$archive->is('single')){
$this->response->throwJson(array('status'=>0,'msg'=>_t('内容不存在!')));
}
$functionsFile = $archive->getThemeDir() . 'functions.php';
if (file_exists($functionsFile)) {
require_once $functionsFile;
if (function_exists('themeInit')) {
themeInit($this);
}
}
$parameter = array(
'parentId' => $archive->hidden ? 0 : $archive->cid,
'parentContent' => $archive->row,
'respondId' => $archive->respondId,
'commentPage' => $this->request->filter('int')->commentPage,
'allowComment' => $archive->allow('comment'),
);
$commentArchive = $this->widget('Widget_Comments_Archive', $parameter);
$data = array();
ob_start();
$commentArchive->listComments();
$data['comments'] = ob_get_clean();
ob_start();
$commentArchive->pageNav($setting->commentPrev, $setting->commentNext);
$data['pageNav'] = ob_get_clean();
$data['status'] = 1;
$commentToken = Typecho_Common::shuffleScriptVar(
Helper::security()->getToken($this->request->getReferer()));
$data['token'] = '<script id="tecmt-token">$(document).ready(function(){
window.token = '.$commentToken.'
});</script>';
$this->response->throwJson($data);
}
public function action(){
$this->on($this->request->is('comment'))->comment($this->request->filter('int')->get('comment'));
$this->response->redirect(Helper::options()->index);
}
}