forked from siseboy/junichi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxomments.php
executable file
·247 lines (234 loc) · 10.6 KB
/
xomments.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
$GLOBALS['z'] = $this->options->CDNURL;
function threadedComments($comments, $options) {
$commentClass = '';
if ($comments->authorId) {
if ($comments->authorId == $comments->ownerId) {
$commentClass .= ' comment-by-author';
} else {
$commentClass .= ' comment-by-user';
}
}
$commentLevelClass = $comments->levels > 0 ? ' comment-child' : ' comment-parent';
if ($comments->url) {
$author = '<a href="' . $comments->url . '" target="_blank"' . ' rel="external nofollow">' . $comments->author . '</a>';
} else {
$author = $comments->author;
}
?>
<li data-no-instant id="li-<?php $comments->theId(); ?>" class="comment-body<?php
if ($comments->levels > 0) {
echo ' comment-child';
$comments->levelsAlt(' comment-level-odd', ' comment-level-even');
} else {
echo ' comment-parent';
}
$comments->alt(' comment-odd', ' comment-even');
echo $commentClass;
?>">
<div id="<?php $comments->theId(); ?>">
<?php
$host = '//cdn.v2ex.com';
$url = '/gravatar/';
$size = '80';
$rating = Helper::options()->commentsAvatarRating;
$hash = md5(strtolower($comments->mail));
$avatar = $host . $url . $hash . '?s=' . $size . '&r=' . $rating . '&d=';
?>
<img class="avatar" src="<?php echo $avatar ?>" alt="<?php echo $comments->author; ?>" width="<?php echo $size ?>" height="<?php echo $size ?>" />
<div class="comment-main">
<p class="comment-at"><?php get_comment_at($comments->coid)?></p>
<?php $comments->content(); ?>
<div class="comment-meta">
<span class="comment-author"><?php echo $author; ?></span>
<time class="comment-time"><?php $comments->date(); ?></time>
<span class="comment-reply"><?php $comments->reply(); ?></span>
</div>
</div>
</div>
<?php if ($comments->children) { ?>
<div class="comment-children">
<?php $comments->threadedComments($options); ?>
</div>
<?php } ?>
</li>
<?php } ?>
<div id="comments" class="cf">
<?php $this->comments()->to($comments); ?>
<?php if ($comments->have()): ?>
<span class="comment-num"><?php $this->commentsNum(_t('暂无评论'), _t('仅有 1 条评论'), _t('已有 %d 条评论')); ?></span>
<?php $comments->listComments(); ?>
<?php $comments->pageNav('«', '»'); ?>
<?php endif; ?>
<?php if($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<div class="cancel-comment-reply"><span class="response"><?php _e('发表新评论'); ?></span><span class="cancel-reply"><?php $comments->cancelReply(); ?></span></div>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<?php if($this->user->hasLogin()): ?>
<p style="padding-top:10px;"><?php _e('已登入: '); ?><a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> »</a></p>
<?php else: ?>
<?php if($this->remember('author',true) != "" && $this->remember('mail',true) != "") : ?>
<p style="padding-top:10px;color:#aaa;">
<span onClick='showhidediv("author_info")'; style="cursor:pointer;color:#2479cc;"><?php $this->remember('author'); ?></span>,<?php _e('欢迎回来'); ?>
<span id="cancel-comment-reply"><?php $comments->cancelReply(); ?></span>
</p>
<div id="author_info" style="display:none;">
<?php else : ?>
<div id="author_info">
<?php endif ; ?>
<input type="text" name="author" maxlength="12" id="author" class="form-control" placeholder="<?php _e('称呼 *'); ?>" value="<?php $this->remember('author'); ?>">
<input type="email" name="mail" id="mail" class="form-control" placeholder="<?php _e('电子邮箱 *'); ?>" value="<?php $this->remember('mail'); ?>">
<input type="url" name="url" id="url" class="form-control" placeholder="<?php _e('网址(http://)'); ?>" value="<?php $this->remember('url'); ?>">
</div>
<?php endif; ?>
<textarea name="text" id="textarea" class="form-control" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};" placeholder="<?php _e('在这里输入你的评论(Ctrl/Cmd+Enter也可以提交)...'); ?>" required ><?php $this->remember('text',false); ?></textarea>
<button type="submit" class="submit" id="misubmit"><?php _e('提交评论'); ?></button>
<?php $security = $this->widget('Widget_Security'); ?>
<input type="hidden" name="_" value="<?php echo $security->getToken($this->request->getReferer())?>">
</form>
</div>
</div>
<?php else: ?>
<h4 class="comment-close">此处评论已关闭</h4>
<?php endif; ?>
<script>
function showhidediv(id){
var sbtitle=document.getElementById(id);
if(sbtitle){
if(sbtitle.style.display=='block'){
sbtitle.style.display='none';
}else{
sbtitle.style.display='block';
}
}
}
(function () {
window.TypechoComment = {
dom : function (id) {
return document.getElementById(id);
},
create : function (tag, attr) {
var el = document.createElement(tag);
for (var key in attr) {
el.setAttribute(key, attr[key]);
}
return el;
},
reply : function (cid, coid) {
var comment = this.dom(cid), parent = comment.parentNode,
response = this.dom('<?php echo $this->respondId(); ?>'),
input = this.dom('comment-parent'),
form = 'form' == response.tagName ? response : response.getElementsByTagName('form')[0],
textarea = response.getElementsByTagName('textarea')[0];
if (null == input) {
input = this.create('input', {
'type' : 'hidden',
'name' : 'parent',
'id' : 'comment-parent'
});
form.appendChild(input);
}
input.setAttribute('value', coid);
if (null == this.dom('comment-form-place-holder')) {
var holder = this.create('div', {
'id' : 'comment-form-place-holder'
});
response.parentNode.insertBefore(holder, response);
}
comment.appendChild(response);
this.dom('cancel-comment-reply-link').style.display = '';
if (null != textarea && 'text' == textarea.name) {
textarea.focus();
}
return false;
},
cancelReply : function () {
var response = this.dom('<?php echo $this->respondId(); ?>'),
holder = this.dom('comment-form-place-holder'),
input = this.dom('comment-parent');
if (null != input) {
input.parentNode.removeChild(input);
}
if (null == holder) {
return true;
}
this.dom('cancel-comment-reply-link').style.display = 'none';
holder.parentNode.insertBefore(response, holder);
return false;
}
};
})();
</script>
<?php if(!empty($this->options->search_form) && in_array('Pjax', $this->options->search_form)): ?>
<script type = "text/javascript" data-no-instant>
(function() {
var event = document.addEventListener ? {
add: 'addEventListener',
focus: 'focus',
load: 'DOMContentLoaded'
} : {
add: 'attachEvent',
focus: 'onfocus',
load: 'onload'
};
document[event.add](event.load, function() {
var r = document.getElementById('<?php echo $this->respondId(); ?>');
if (null != r) {
var forms = r.getElementsByTagName('form');
if (forms.length > 0) {
var f = forms[0],
textarea = f.getElementsByTagName('textarea')[0],
added = false;
if (null != textarea && 'text' == textarea.name) {
textarea[event.add](event.focus, function() {
if (!added) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = '_';
input.value = (function() {
var _a8C5A = //'xr'
'8d0' + //'vI'
'vI' + /* 'mj'//'mj' */ '' + //'P'
'06' + 'd' //'chS'
+ //'wo'
'0ef' + '41' //'9G'
+ '8c8' //'R'
+ //'p1'
'd0' + //'mi'
'mi' + 'baf' //'lu'
+ 'c' //'dm'
+ //'ED'
'1a9' + //'Lh'
'd9' + '6' //'luM'
+ //'xH'
'f1' + //'W'
'2c7' + 'f' //'f'
+ //'9'
'9' + //'Nd'
'Nd' + /* '8ys'//'8ys' */ '' + '' ///*'6Yc'*/'6Yc'
+ //'H'
'0',
_LceE8M = [
[3, 5],
[16, 18],
[31, 32],
[31, 32],
[31, 33]
];
for (var i = 0; i < _LceE8M.length; i++) {
_a8C5A = _a8C5A.substring(0, _LceE8M[i][0]) + _a8C5A.substring(_LceE8M[i][1]);
}
return _a8C5A;
})();
f.appendChild(input);
added = true;
}
});
}
}
}
});
})();
</script>
<?php else : ?>
<?php endif; ?>