function onadd() { $qid = intval($this->get[2]); $cid = intval($this->get[3]); $viewurl = urlmap('question/view/' . $qid, 2); $message = "该问题已经收藏,不能重复收藏!"; $this->load("favorite"); if (!$_ENV['favorite']->get_by_qid($qid)) { $_ENV['favorite']->add($qid); $message = '问题收藏成功!'; } $this->message($message, $viewurl); }
function onajaxviewcomment() { $answerid = intval($this->get[2]); $commentlist = $_ENV['answer_comment']->get_by_aid($answerid, 0, 50); $commentstr = '<li class="loading">暂无评论 :)</li>'; if ($commentlist) { $commentstr = ""; $admin_control = $this->user['grouptype'] == 1 ? '<span class="span-line">|</span><a href="javascript:void(0)" onclick="deletecomment({commentid},{answerid});">删除</a>' : ''; foreach ($commentlist as $comment) { $viewurl = urlmap('user/space/' . $comment['authorid'], 2); $reply_control = $this->user['uid'] != $comment['authorid'] ? '<span class="span-line">|</span><a href="javascript:void(0)" onclick="replycomment(' . $comment['authorid'] . ',' . $comment['aid'] . ');">回复</a>' : ''; if ($admin_control) { $admin_control = str_replace("{commentid}", $comment['id'], $admin_control); $admin_control = str_replace("{answerid}", $comment['aid'], $admin_control); } $commentstr .= '<li><div class="other-comment"><a id="comment_author_' . $comment['authorid'] . '" href="' . $viewurl . '" title="' . $comment['author'] . '" target="_blank" class="pic"><img width="30" height="30" src="' . $comment['avatar'] . '" onmouseover="pop_user_on(this, \'' . $comment['authorid'] . '\', \'\');" onmouseout="pop_user_out();"></a><p><a href="' . $viewurl . '" title="' . $comment['author'] . '" target="_blank">' . $comment['author'] . '</a>:' . $comment['content'] . '</p></div><div class="replybtn"><span class="times">' . $comment['format_time'] . '</span>' . $reply_control . '' . $admin_control . '</div></li>'; } } exit($commentstr); }
function onverifyanswer() { $qid = intval($this->get[3]); $aid = intval($this->get[2]); $viewurl = urlmap('question/view/' . $qid, 2); $_ENV['answer']->change_to_verify($aid); $this->message("回答审核完成!", $viewurl); }
function page($num, $perpage, $curpage, $operation, $ajax = 0) { global $setting; $multipage = ''; $operation = urlmap($operation, 2); $mpurl = SITE_URL . $setting['seo_prefix'] . $operation . '/'; 'admin' == substr($operation, 0, 5) && ($mpurl = 'index.php?' . $operation . '/'); if ($num > $perpage) { $page = 8; $offset = 2; $pages = @ceil($num / $perpage); if ($page > $pages) { $from = 1; $to = $pages; } else { $from = $curpage - $offset; $to = $from + $page - 1; if ($from < 1) { $to = $curpage + 1 - $from; $from = 1; if ($to - $from < $page) { $to = $page; } } elseif ($to > $pages) { $from = $pages - $page + 1; $to = $pages; } } if (!$ajax) { $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a class="n" href="' . $mpurl . '1' . $setting['seo_suffix'] . '" >首页</a>' . "\n" : '') . ($curpage > 1 ? '<a href="' . $mpurl . ($curpage - 1) . $setting['seo_suffix'] . '" class="n">上一页</a>' . "\n" : ''); for ($i = $from; $i <= $to; $i++) { $multipage .= $i == $curpage ? "<strong>{$i}</strong>\n" : '<a href="' . $mpurl . $i . $setting['seo_suffix'] . '">' . $i . '</a>' . "\n"; } $multipage .= ($curpage < $pages ? '<a class="n" href="' . $mpurl . ($curpage + 1) . $setting['seo_suffix'] . '">下一页</a>' . "\n" : '') . ($to < $pages ? '<a class="n" href="' . $mpurl . $pages . $setting['seo_suffix'] . '" >最后一页</a>' . "\n" : ''); } else { $multipage = ''; if ($curpage < $pages) { $multipage = '<a href="' . $mpurl . ($curpage + 1) . $setting['seo_suffix'] . '">查看更多</a>'; } } } return $multipage; }