Пример #1
0
 public function index_action()
 {
     $_GET['per_page'] = $_GET['per_page'] ? intval($_GET['per_page']) : get_setting('contents_per_page');
     $result = $this->model('search')->search(cjk_substr($_GET['q'], 0, 64), $_GET['type'], $_GET['page'], $_GET['per_page'], $_GET['topic_ids'], $_GET['is_recommend']);
     if (!$result) {
         $result = array();
     }
     if ($_GET['is_question_id'] and is_digits($_GET['q'])) {
         $question_info = $this->model('question')->get_question_info_by_id($_GET['q']);
         if ($question_info) {
             $result[] = $this->model('search')->prase_result_info($question_info);
         }
     }
     if ($result) {
         $key_arr = array('type', 'search_id', 'name', 'detail');
         foreach ($result as $key => $val) {
             foreach ($val as $k => $v) {
                 if (!in_array($k, $key_arr)) {
                     unset($result[$key][$k]);
                 }
             }
         }
     }
     H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($result), 'rows' => $result), 1, null));
 }
Пример #2
0
 public function topic_info_action()
 {
     $topic_info = $this->model('topic')->get_topic_by_id($_GET['topic_id']);
     $topic_info['type'] = 'topic';
     $topic_info['topic_description'] = cjk_substr(strip_tags($topic_info['topic_description']), 0, 80, 'UTF-8', '...');
     $topic_info['focus_count'] = $topic_info['focus_count'];
     if ($this->user_id) {
         $topic_info['focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
     }
     $topic_info['topic_pic'] = get_topic_pic_url('mid', $topic_info['topic_pic']);
     $topic_info['url'] = get_js_url('/topic/' . $topic_info['url_token']);
     H::ajax_json_output($topic_info);
 }
Пример #3
0
 public function search_action()
 {
     $result = $this->model('search')->search(cjk_substr($_GET['q'], 0, 64), $_GET['type'], 1, $_GET['limit'], $_GET['topic_ids'], $_GET['is_recommend']);
     if (!$result) {
         $result = array();
     }
     if ($_GET['is_question_id'] and is_digits($_GET['q'])) {
         $question_info = $this->model('question')->get_question_info_by_id($_GET['q']);
         if ($question_info) {
             $result[] = $this->model('search')->prase_result_info($question_info);
         }
     }
     H::ajax_json_output($result);
 }
Пример #4
0
 public function get_favorite_article_action()
 {
     if (empty($_GET['page'])) {
         $_GET['page'] = 1;
     }
     if (empty($_GET['per_page'])) {
         $_GET['per_page'] = 10;
     }
     $uid = $this->user_id;
     if (!empty($_GET['uid'])) {
         $uid = intval($_GET['uid']);
     }
     $data = $this->model('api')->get_favorite_article($uid, $_GET['page'], $_GET['per_page']);
     if (!empty($data['rows'])) {
         foreach ($data['rows'] as $k => $v) {
             $data['rows'][$k]['message'] = cjk_substr(strip_ubb($v['message']), 0, 80, 'utf-8');
         }
     }
     if (empty($data['rows'])) {
         $data['rows'] = null;
         $data['total_rows'] = 0;
     }
     H::ajax_json_output(AWS_APP::RSM($data, 1, null));
 }
Пример #5
0
 public function get_last_messages($dialog_ids)
 {
     if (!is_array($dialog_ids)) {
         return false;
     }
     foreach ($dialog_ids as $dialog_id) {
         $dialog_message = $this->fetch_row('inbox', 'dialog_id = ' . intval($dialog_id), 'id DESC');
         $last_message[$dialog_id] = cjk_substr($dialog_message['message'], 0, 60, 'UTF-8', '...');
     }
     return $last_message;
 }
Пример #6
0
 public function fetch_share_data_action()
 {
     switch ($_GET['type']) {
         case 'question':
             $question_info = $this->model('question')->get_question_info_by_id($_GET['item_id']);
             $question_info['question_content'] = trim(cjk_substr($question_info['question_content'], 0, 100, 'UTF-8', '...'), "\r\n\t");
             $url = get_js_url('/question/' . $question_info['question_id'] . '?fromuid=' . $this->user_id);
             $message = AWS_APP::lang()->_t('我看到一个不错的问题, 想和你分享:') . ' ' . $question_info['question_content'] . ' ' . $url;
             break;
         case 'answer':
             $answer_info = $this->model('answer')->get_answer_by_id($_GET['item_id']);
             $user_info = $this->model('account')->get_user_info_by_uid($answer_info['uid']);
             $question_info = $this->model('question')->get_question_info_by_id($answer_info['question_id']);
             $answer_info['answer_content'] = trim(cjk_substr($answer_info['answer_content'], 0, 100, 'UTF-8', '...'), "\r\n\t");
             $answer_info['answer_content'] = str_replace(array("\r", "\n", "\t"), ' ', $answer_info['answer_content']);
             $url = get_js_url('/question/' . $answer_info['question_id'] . '?fromuid=' . $this->user_id . '&answer_id=' . $answer_info['answer_id'] . '&single=true');
             if ($answer_info['anonymous']) {
                 $user_info['user_name'] = AWS_APP::lang()->_t('匿名用户');
             }
             $message = AWS_APP::lang()->_t('我看到一个不错的问题, 想和你分享:') . ' ' . $question_info['question_content'] . ' - ' . $user_info['user_name'] . ": " . $answer_info['answer_content'] . ' ' . $url;
             break;
         case 'article':
             $article_info = $this->model('article')->get_article_info_by_id($_GET['item_id']);
             $article_info['message'] = trim(cjk_substr($article_info['message'], 0, 100, 'UTF-8', '...'), "\r\n\t");
             $article_info['message'] = str_replace(array("\r", "\n", "\t"), ' ', $article_info['message']);
             $url = get_js_url('/article/' . $article_info['id'] . '?fromuid=' . $this->user_id);
             $message = AWS_APP::lang()->_t('我看到一个不错的文章, 想和你分享:') . ' ' . $article_info['title'] . ": " . $article_info['message'] . ' ' . $url;
             break;
     }
     $data = array('message' => $message, 'url' => $url, 'sina_akey' => get_setting('sina_akey') ? get_setting('sina_akey') : '3643094708', 'qq_app_key' => get_setting('qq_app_key') ? get_setting('qq_app_key') : '801158211');
     H::ajax_json_output(AWS_APP::RSM(array('share_txt' => $data), 1, null));
 }
Пример #7
0
 public function index_action()
 {
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题不存在或已被删除')));
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($_GET['column'] != 'log') {
         $this->model('question')->calc_popular_value($question_info['question_id']);
         $this->model('question')->update_views($question_info['question_id']);
         if (is_digits($_GET['uid'])) {
             $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
             $answer_count_where = 'uid = ' . intval($_GET['uid']);
         } else {
             if ($_GET['uid'] == 'focus' and $this->user_id) {
                 if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                     foreach ($friends as $key => $val) {
                         $follow_uids[] = $val['uid'];
                     }
                 } else {
                     $follow_uids[] = 0;
                 }
                 $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_order_by = 'add_time ASC';
             } else {
                 if ($_GET['sort_key'] == 'add_time') {
                     $answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
                 } else {
                     $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
                 }
             }
         }
         if ($answer_count_where) {
             $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
         } else {
             $answer_count = $question_info['answer_count'];
         }
         if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
         } else {
             if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
                 if ($question_info['best_answer']) {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
                 } else {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
                 }
             } else {
                 if ($answer_list_where) {
                     $answer_list_where = implode(' AND ', $answer_list_where);
                 }
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
             }
         }
         // 最佳回复预留
         $answers[0] = '';
         if (!is_array($answer_list)) {
             $answer_list = array();
         }
         $answer_ids = array();
         $answer_uids = array();
         foreach ($answer_list as $answer) {
             $answer_ids[] = $answer['answer_id'];
             $answer_uids[] = $answer['uid'];
             if ($answer['has_attach']) {
                 $has_attach_answer_ids[] = $answer['answer_id'];
             }
         }
         if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
             $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
         }
         if ($answer_ids) {
             $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
             $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
             $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
         }
         foreach ($answer_list as $answer) {
             $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
             $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
             $answer['answer_content'] = cjk_substr(strip_ubb($answer['answer_content']), 0, 100);
             //$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
             $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
             $answer['user_info']['avatar_file'] = get_avatar_url($answer['uid']);
             if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
                 $answers[0] = $answer;
             } else {
                 $answers[] = $answer;
             }
         }
         if (!$answers[0]) {
             unset($answers[0]);
         }
         $question_info['user_answered'] = 0;
         //如果系统设置了用户只能回答一次
         if (get_setting('answer_unique') == 'Y') {
             if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
                 $question_info['user_answered'] = 1;
             } else {
                 $question_info['user_answered'] = 0;
             }
         }
     }
     $question_info['user_follow_check'] = 0;
     $question_info['user_question_focus'] = 0;
     $question_info['user_thanks'] = 0;
     if ($this->user_id) {
         if ($this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id)) {
             $question_info['user_thanks'] = 1;
         }
         //当前用户是否已关注该问题作者
         if ($this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid'])) {
             $question_info['user_follow_check'] = 1;
         }
         if ($this->model('question')->has_focus_question($question_info['question_id'], $this->user_id)) {
             $question_info['user_question_focus'] = 1;
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     $question_info['answer_count'] = $answer_count;
     //clean
     $question_key = array('question_id', 'question_content', 'question_detail', 'add_time', 'update_time', 'answer_count', 'view_count', 'agree_count', 'focus_count', 'against_count', 'thanks_count', 'comment_count', 'user_info', 'user_answered', 'user_thanks', 'user_follow_check', 'user_question_focus');
     $user_key = array('uid', 'user_name', 'namecard_pic', 'signature');
     $topics_key = array('topic_id', 'topic_title');
     foreach ($question_info as $k => $v) {
         if (!in_array($k, $question_key)) {
             unset($question_info[$k]);
         }
     }
     //作者信息
     if (!empty($question_info['user_info'])) {
         foreach ($question_info['user_info'] as $k => $v) {
             if (!in_array($k, $user_key)) {
                 unset($question_info['user_info'][$k]);
             }
         }
         $question_info['user_info']['avatar_file'] = get_avatar_url($question_info['user_info']['uid'], 'mid');
     }
     if (!empty($answers)) {
         foreach ($answers as $key => $value) {
             if (!empty($value['user_info'])) {
                 foreach ($value['user_info'] as $k => $v) {
                     if (!in_array($k, $user_key)) {
                         unset($answers[$key]['user_info'][$k]);
                     }
                 }
                 $answers[$key]['user_info']['avatar_file'] = get_avatar_url($answers[$key]['user_info']['uid'], 'mid');
             }
             $answers[$key]['answer_content'] = strip_tags($value['answer_content']);
         }
     }
     if (!empty($question_topics)) {
         foreach ($question_topics as $key => $val) {
             foreach ($val as $k => $v) {
                 if (!in_array($k, $topics_key)) {
                     unset($question_topics[$key][$k]);
                 }
             }
         }
     }
     //$question_info['answers'] = $answers;
     H::ajax_json_output(AWS_APP::RSM(array('question_info' => $question_info, 'question_topics' => $question_topics, 'answers' => array_values($answers)), 1, null));
 }
Пример #8
0
 public function create_comment($access_token, $id, $comment)
 {
     $client = new Services_Weibo_WeiboClient(get_setting('sina_akey'), get_setting('sina_skey'), $access_token);
     return $client->send_comment($id, cjk_substr($comment, 0, 140, 'UTF-8', '...'));
 }
Пример #9
0
function excerpt($html, $start, $length, $dot = '...')
{
    return cjk_substr(trim(preg_replace('/(\\s|\\&nbsp\\;| |\\xc2\\xa0|[[attach].*[\\/attach]]|[[\\/\\!]*?[^\\[\\]]*?]|si)/', '', strip_tags($html))), intval($start), intval($start) + intval($length), 'UTF-8', $dot);
}
Пример #10
0
 public function user_actions_by_where_action()
 {
     if (isset($_GET['perpage']) and intval($_GET['perpage']) > 0) {
         $this->per_page = intval($_GET['perpage']);
     }
     $associate_type = $_GET['type'];
     if (!in_array($associate_type, array(ACTION_LOG::CATEGORY_ARTICLE, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::CATEGORY_ANSWER, ACTION_LOG::CATEGORY_NEWS))) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('参数有误')));
     }
     $associate_action = $_GET['actions'];
     if (empty($_GET['page'])) {
         $_GET['page'] = 0;
     }
     if ($data = $this->model('actions')->get_user_action_by_where($associate_type, $associate_action, $_GET['uid'], intval($_GET['page']) * $this->per_page . ", {$this->per_page}")) {
         foreach ($data as $k => $v) {
             if (!empty($v['info']['message']) and strlen($v['info']['message']) > 80) {
                 $data[$k]['info']['message'] = cjk_substr(strip_tags($v['info']['message']), 0, 80, 'utf-8') . '...';
             }
         }
     } else {
         $data = null;
     }
     H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($data), 'rows' => $data), 1, null));
 }
Пример #11
0
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/article/' . $_GET['id']);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     TPL::assign('article_info', $article_info);
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     if ($article_topics) {
         TPL::assign('article_topics', $article_topics);
         foreach ($article_topics as $topic_info) {
             $article_topic_ids[] = $topic_info['topic_id'];
         }
     }
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($article_info['user_info']['uid'], $user['reputation'], 5));
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 100);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
         }
     }
     if ($this->user_id) {
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $article_info['uid']));
     }
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list(null, $article_info['title']));
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 100))->create_links());
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($article_info['title'])));
     TPL::set_meta('description', $article_info['title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($article_info['message'])), 0, 128, 'UTF-8', '...'));
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($article_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['id'] and $value['id'] == $article_info['id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     if (get_setting('advanced_editor_enable') == 'Y') {
         TPL::import_js('js/editor/prettify.js');
     }
     TPL::output('article/index');
 }
Пример #12
0
 public function index_action()
 {
     if (is_mobile()) {
         HTTP::redirect('/m/topic/' . $_GET['id']);
     }
     if (is_digits($_GET['id'])) {
         if (!($topic_info = $this->model('topic')->get_topic_by_id($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_title($_GET['id']);
         }
     } else {
         if (!($topic_info = $this->model('topic')->get_topic_by_title($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_url_token($_GET['id']);
         }
     }
     if (!$topic_info) {
         header('HTTP/1.1 404 Not Found');
         H::redirect_msg(AWS_APP::lang()->_t('话题不存在'), '/');
     }
     if ($topic_info['merged_id'] and $topic_info['merged_id'] != $topic_info['topic_id']) {
         if ($this->model('topic')->get_topic_by_id($topic_info['merged_id'])) {
             HTTP::redirect('/topic/' . $topic_info['merged_id'] . '?rf=' . $topic_info['topic_id']);
         } else {
             $this->model('topic')->remove_merge_topic($topic_info['topic_id'], $topic_info['merged_id']);
         }
     }
     if (urldecode($topic_info['url_token']) != $_GET['id']) {
         HTTP::redirect('/topic/' . $topic_info['url_token'] . '?rf=' . $_GET['rf']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_topic = $this->model('topic')->get_topic_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('话题 (%s) 已与当前话题合并', $from_topic['topic_title']);
         }
     }
     if ($topic_info['seo_title']) {
         TPL::assign('page_title', $topic_info['seo_title']);
     } else {
         $this->crumb($topic_info['topic_title'], '/topic/' . $topic_info['url_token']);
     }
     if ($this->user_id) {
         $topic_info['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
     }
     if ($topic_info['topic_description']) {
         TPL::set_meta('description', $topic_info['topic_title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...'));
     }
     $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description']));
     TPL::assign('topic_info', $topic_info);
     TPL::assign('best_answer_users', $this->model('topic')->get_best_answer_users_by_topic_id($topic_info['topic_id'], 5));
     switch ($topic_info['model_type']) {
         default:
             $related_topics_ids = array();
             $page_keywords[] = $topic_info['topic_title'];
             if ($related_topics = $this->model('topic')->related_topics($topic_info['topic_id'])) {
                 foreach ($related_topics as $key => $val) {
                     $related_topics_ids[$val['topic_id']] = $val['topic_id'];
                     $page_keywords[] = $val['topic_title'];
                 }
             }
             TPL::set_meta('keywords', implode(',', $page_keywords));
             TPL::set_meta('description', cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...'));
             if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($topic_info['topic_id'])) {
                 foreach ($child_topic_ids as $key => $topic_id) {
                     $related_topics_ids[$topic_id] = $topic_id;
                 }
             }
             TPL::assign('related_topics', $related_topics);
             $log_list = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 10, ACTION_LOG::CATEGORY_TOPIC, implode(',', array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_RELATED_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC)), -1);
             $log_list = $this->model('topic')->analysis_log($log_list);
             $contents_topic_id = $topic_info['topic_id'];
             $contents_topic_title = $topic_info['topic_title'];
             if ($merged_topics = $this->model('topic')->get_merged_topic_ids($topic_info['topic_id'])) {
                 foreach ($merged_topics as $key => $val) {
                     $merged_topic_ids[] = $val['source_id'];
                 }
                 $contents_topic_id .= ',' . implode(',', $merged_topic_ids);
                 if ($merged_topics_info = $this->model('topic')->get_topics_by_ids($merged_topic_ids)) {
                     foreach ($merged_topics_info as $key => $val) {
                         $merged_topic_title[] = $val['topic_title'];
                     }
                 }
                 if ($merged_topic_title) {
                     $contents_topic_title .= ',' . implode(',', $merged_topic_title);
                 }
             }
             $contents_related_topic_ids = array_merge($related_topics_ids, explode(',', $contents_topic_id));
             TPL::assign('contents_related_topic_ids', implode(',', $contents_related_topic_ids));
             if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), 'new', $contents_related_topic_ids)) {
                 foreach ($posts_list as $key => $val) {
                     if ($val['answer_count']) {
                         $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
                     }
                 }
             }
             TPL::assign('posts_list', $posts_list);
             TPL::assign('all_list_bit', TPL::output('explore/ajax/list', false));
             if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), null, $contents_related_topic_ids, null, null, 30, true)) {
                 foreach ($posts_list as $key => $val) {
                     if ($val['answer_count']) {
                         $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
                     }
                 }
             }
             TPL::assign('topic_recommend_list', $posts_list);
             TPL::assign('posts_list', $posts_list);
             TPL::assign('recommend_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('list', $this->model('topic')->get_topic_best_answer_action_list($contents_topic_id, $this->user_id, get_setting('contents_per_page')));
             TPL::assign('best_questions_list_bit', TPL::output('home/ajax/index_actions', false));
             TPL::assign('posts_list', $this->model('posts')->get_posts_list('question', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             TPL::assign('all_questions_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('posts_list', $this->model('posts')->get_posts_list('article', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             TPL::assign('articles_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('contents_topic_id', $contents_topic_id);
             TPL::assign('contents_topic_title', $contents_topic_title);
             TPL::assign('log_list', $log_list);
             TPL::assign('redirect_message', $redirect_message);
             if ($topic_info['parent_id']) {
                 TPL::assign('parent_topic_info', $this->model('topic')->get_topic_by_id($topic_info['parent_id']));
             }
             TPL::output('topic/index');
             break;
     }
 }
Пример #13
0
 public function topic_best_answer_list_action()
 {
     if (!$_GET['topic_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('参数错误')));
     }
     $_GET['page'] = $_GET['page'] ? $_GET['page'] - 1 : 0;
     $per_page = get_setting('contents_per_page');
     if ($_GET['per_page']) {
         $per_page = intval($_GET['per_page']);
     }
     //$action_list = $this->model('topic')->get_topic_best_answer_action_list(intval($_GET['topic_id']), $this->user_id, intval($_GET['page']) * get_setting('contents_per_page') . ', ' . get_setting('contents_per_page'));
     $action_list = $this->model('topic')->get_topic_best_answer_action_list(intval($_GET['topic_id']), $this->user_id, intval($_GET['page']) * $per_page . ', ' . $per_page);
     $question_info_key = array('question_id', 'question_content');
     $answer_info_key = array('answer_id', 'answer_content', 'add_time', 'against_count', 'agree_count', 'comment_count', 'thanks_count', 'agree_status');
     if ($action_list) {
         foreach ($action_list as $key => $val) {
             foreach ($val as $kk => $vv) {
                 if (!in_array($kk, array('question_info', 'user_info', 'answer_info'))) {
                     unset($action_list[$key][$kk]);
                 }
                 if ($kk == 'question_info') {
                     foreach ($vv as $k => $v) {
                         if (!in_array($k, $question_info_key)) {
                             unset($action_list[$key][$kk][$k]);
                         }
                     }
                 }
                 if ($kk == 'user_info') {
                     $action_list[$key][$kk] = $this->model('myapi')->get_clean_user_info($vv);
                 }
                 if ($kk == 'answer_info') {
                     foreach ($vv as $k => $v) {
                         if (!in_array($k, $answer_info_key)) {
                             unset($action_list[$key][$kk][$k]);
                         }
                     }
                     $vv['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($vv['answer_content']))));
                     $action_list[$key][$kk]['answer_content'] = cjk_substr(trim(strip_tags($vv['answer_content'])), 0, 100);
                 }
             }
         }
     } else {
         $action_list = null;
     }
     H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($action_list), 'rows' => array_values($action_list)), 1, null));
 }
Пример #14
0
 public function reply_ticket($ticket_id, $message, $uid, $attach_access_key = null)
 {
     $ticket_info = $this->get_ticket_info_by_id($ticket_id);
     if (!$ticket_info or $ticket_info['status'] == 'closed') {
         return false;
     }
     $now = time();
     $reply_id = $this->insert('ticket_reply', array('ticket_id' => $ticket_info['id'], 'message' => htmlspecialchars($message), 'uid' => intval($uid), 'time' => $now, 'uid' => intval($uid), 'ip' => ip2long(fetch_ip())));
     if (!$reply_id) {
         return false;
     }
     set_human_valid('answer_valid_hour');
     if ($attach_access_key) {
         $this->model('publish')->update_attach('ticket_reply', $reply_id, $attach_access_key);
     }
     if (!$ticket_info['reply_time']) {
         $this->shutdown_update('ticket', array('reply_time' => $now), 'id = ' . $ticket_info['id']);
     }
     if ($ticket_info['weibo_msg_id']) {
         $this->model('openid_weibo_weibo')->reply_answer_to_sina($question_info['question_id'], cjk_substr($answer_content, 0, 110, 'UTF-8', '...'));
     }
     if ($ticket_info['received_email_id']) {
         $this->model('edm')->reply_answer_by_email($question_info['question_id'], nl2br(FORMAT::parse_bbcode($answer_content)));
     }
     return $reply_id;
 }
Пример #15
0
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (!($article_info = $this->model('article')->get_article_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('文章不存在或已被删除'), '/');
     }
     if ($article_info['has_attach']) {
         $article_info['attachs'] = $this->model('publish')->get_attach('article', $article_info['id'], 'min');
         $article_info['attachs_ids'] = FORMAT::parse_attachs($article_info['message'], true);
     }
     $article_info['user_info'] = $this->model('account')->get_user_info_by_uid($article_info['uid'], true);
     $article_info['message'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($article_info['message'])));
     if ($this->user_id) {
         $article_info['vote_info'] = $this->model('article')->get_article_vote_by_id('article', $article_info['id'], null, $this->user_id);
     }
     $article_info['vote_users'] = $this->model('article')->get_article_vote_users_by_id('article', $article_info['id'], 1, 10);
     // 是否为推荐到首页
     $article_info['is_recommend_homepage'] = $this->model('recommend')->recommend_homepage_check('article', $article_info['id']);
     TPL::assign('article_info', $article_info);
     $article_topics = $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article');
     if ($article_topics) {
         TPL::assign('article_topics', $article_topics);
         foreach ($article_topics as $topic_info) {
             $article_topic_ids[] = $topic_info['topic_id'];
         }
     }
     TPL::assign('reputation_topics', $this->model('people')->get_user_reputation_topic($article_info['user_info']['uid'], $user['reputation'], 5));
     $this->crumb($article_info['title'], '/article/' . $article_info['id']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     if ($_GET['item_id']) {
         $comments[] = $this->model('article')->get_comment_by_id($_GET['item_id']);
     } else {
         $comments = $this->model('article')->get_comments($article_info['id'], $_GET['page'], 50);
     }
     if ($comments and $this->user_id) {
         foreach ($comments as $key => $val) {
             $comments[$key]['vote_info'] = $this->model('article')->get_article_vote_by_id('comment', $val['id'], 1, $this->user_id);
             $comments[$key]['message'] = $this->model('question')->parse_at_user($val['message']);
         }
     }
     if ($this->user_id) {
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $article_info['uid']));
     }
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list(null, $article_info['title']));
     // 最新推荐文章
     $hot_articles = $this->model('article')->get_articles_list(null, 1, 5, 'votes DESC', null);
     foreach ($hot_articles as $key => $val) {
         $article_ids[] = $val['id'];
     }
     $article_attachs = $this->model('publish')->get_attachs('article', $article_ids, 'min');
     foreach ($hot_articles as $key => $val) {
         $hot_articles[$key]['attachs'] = $article_attachs[$val['id']];
     }
     TPL::assign('hot_articles', $hot_articles);
     // 推荐专题
     if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) {
         TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'], 4));
     }
     $this->model('article')->update_views($article_info['id']);
     TPL::assign('comments', $comments);
     TPL::assign('comments_count', $article_info['comments']);
     TPL::assign('human_valid', human_valid('answer_valid_hour'));
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 50))->create_links());
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($article_info['title'])));
     TPL::set_meta('description', $article_info['title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($article_info['message'])), 0, 128, 'UTF-8', '...'));
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($article_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['id'] and $value['id'] == $article_info['id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 收藏数量
     $bookmark_count = $this->model('favorite')->get_favorite_counts('article', $article_info['id']);
     TPL::assign('bookmark_count', $bookmark_count);
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('article/index');
 }
Пример #16
0
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if (is_mobile()) {
         HTTP::redirect('/m/question/' . $_GET['id']);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     if ($question_info['category_id'] and get_setting('category_enable') == 'Y') {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     if ($_GET['column'] != 'log') {
         $this->model('question')->calc_popular_value($question_info['question_id']);
         $this->model('question')->update_views($question_info['question_id']);
         if (is_digits($_GET['uid'])) {
             $answer_list_where[] = 'uid = ' . intval($_GET['uid']);
             $answer_count_where = 'uid = ' . intval($_GET['uid']);
         } else {
             if ($_GET['uid'] == 'focus' and $this->user_id) {
                 if ($friends = $this->model('follow')->get_user_friends($this->user_id, false)) {
                     foreach ($friends as $key => $val) {
                         $follow_uids[] = $val['uid'];
                     }
                 } else {
                     $follow_uids[] = 0;
                 }
                 $answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
                 $answer_order_by = 'add_time ASC';
             } else {
                 if ($_GET['sort_key'] == 'add_time') {
                     $answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
                 } else {
                     $answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
                 }
             }
         }
         if ($answer_count_where) {
             $answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
         } else {
             $answer_count = $question_info['answer_count'];
         }
         if (isset($_GET['answer_id']) and (!$this->user_id or $_GET['single'])) {
             $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
         } else {
             if (!$this->user_id and !$this->user_info['permission']['answer_show']) {
                 if ($question_info['best_answer']) {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
                 } else {
                     $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
                 }
             } else {
                 if ($answer_list_where) {
                     $answer_list_where = implode(' AND ', $answer_list_where);
                 }
                 $answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
             }
         }
         // 最佳回复预留
         $answers[0] = '';
         if (!is_array($answer_list)) {
             $answer_list = array();
         }
         $answer_ids = array();
         $answer_uids = array();
         foreach ($answer_list as $answer) {
             $answer_ids[] = $answer['answer_id'];
             $answer_uids[] = $answer['uid'];
             if ($answer['has_attach']) {
                 $has_attach_answer_ids[] = $answer['answer_id'];
             }
         }
         if (!in_array($question_info['best_answer'], $answer_ids) and intval($_GET['page']) < 2) {
             $answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
         }
         if ($answer_ids) {
             $answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
             $answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
             $answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
             $answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
             $answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
         }
         foreach ($answer_list as $answer) {
             if ($answer['has_attach']) {
                 $answer['attachs'] = $answer_attachs[$answer['answer_id']];
                 $answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
             }
             $answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
             $answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
             $answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
             $answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
             $answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
             if ($question_info['best_answer'] == $answer['answer_id'] and intval($_GET['page']) < 2) {
                 $answers[0] = $answer;
             } else {
                 $answers[] = $answer;
             }
         }
         if (!$answers[0]) {
             unset($answers[0]);
         }
         if (get_setting('answer_unique') == 'Y') {
             if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
                 TPL::assign('user_answered', 1);
             } else {
                 TPL::assign('user_answered', 0);
             }
         }
         TPL::assign('answers', $answers);
         TPL::assign('answer_count', $answer_count);
     }
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     TPL::assign('question_related_list', $this->model('question')->get_related_question_list($question_info['question_id'], $question_info['question_content']));
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     if ($this->user_id) {
         if ($question_topics) {
             foreach ($question_topics as $key => $val) {
                 $question_topic_ids[] = $val['topic_id'];
             }
         }
         if ($helpful_users = $this->model('topic')->get_helpful_users_by_topic_ids($question_topic_ids, 17)) {
             foreach ($helpful_users as $key => $val) {
                 if ($val['user_info']['uid'] == $this->user_id) {
                     unset($helpful_users[$key]);
                 } else {
                     $helpful_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
                     $helpful_users[$key]['experience'] = end($helpful_users[$key]['experience']);
                 }
             }
             TPL::assign('helpful_users', $helpful_users);
         }
     }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('attach_access_key', md5($this->user_id . time()));
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 答题选项
     if (intval($question_info['quiz_id']) > 0) {
         $question_quiz = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
         TPL::import_js('js/quiz.js');
         TPL::import_css('css/quiz.css');
         TPL::import_js('js/app/question.js');
         TPL::assign('question_quiz', $question_quiz);
     }
     TPL::output('question/index');
 }
Пример #17
0
 public function index_action()
 {
     if (is_digits($_GET['id'])) {
         if (!($topic_info = $this->model('topic')->get_topic_by_id($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_title($_GET['id']);
         }
     } else {
         if (!($topic_info = $this->model('topic')->get_topic_by_title($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_url_token($_GET['id']);
         }
     }
     if (!$topic_info) {
         H::redirect_msg(AWS_APP::lang()->_t('专题不存在'), '/');
     }
     // if ($topic_info['merged_id'] AND $topic_info['merged_id'] != $topic_info['topic_id'])
     // {
     // 	if ($this->model('topic')->get_topic_by_id($topic_info['merged_id']))
     // 	{
     // 		HTTP::redirect('/topic/' . $topic_info['merged_id'] . '?rf=' . $topic_info['topic_id']);
     // 	}
     // 	else
     // 	{
     // 		$this->model('topic')->remove_merge_topic($topic_info['topic_id'], $topic_info['merged_id']);
     // 	}
     // }
     // if (urldecode($topic_info['url_token']) != $_GET['id'])
     // {
     // 	HTTP::redirect('/topic/' . $topic_info['url_token'] . '?rf=' . $_GET['rf']);
     // }
     // if (is_digits($_GET['rf']) and $_GET['rf'])
     // {
     // 	if ($from_topic = $this->model('topic')->get_topic_by_id($_GET['rf']))
     // 	{
     // 		$redirect_message[] = AWS_APP::lang()->_t('话题 (%s) 已与当前话题合并', $from_topic['topic_title']);
     // 	}
     // }
     if ($topic_info['seo_title']) {
         TPL::assign('page_title', $topic_info['seo_title']);
     } else {
         $this->crumb($topic_info['topic_title'], '/topic/' . $topic_info['url_token']);
     }
     if ($this->user_id) {
         $topic_info['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
     }
     if ($topic_info['topic_description']) {
         TPL::set_meta('description', $topic_info['topic_title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...'));
     }
     $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description']));
     //是否首页精选
     $topic_info['is_recommend_homepage'] = $this->model('recommend')->recommend_homepage_check('topic', $topic_info['topic_id']);
     TPL::assign('topic_info', $topic_info);
     // TPL::assign('best_answer_users', $this->model('topic')->get_best_answer_users_by_topic_id($topic_info['topic_id'], 5));
     switch ($topic_info['model_type']) {
         default:
             // $related_topics_ids = array();
             // if ($related_topics = $this->model('topic')->related_topics($topic_info['topic_id']))
             // {
             // 	foreach ($related_topics AS $key => $val)
             // 	{
             // 		$related_topics_ids[$val['topic_id']] = $val['topic_id'];
             // 	}
             // }
             // if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($topic_info['topic_id']))
             // {
             // 	foreach ($child_topic_ids AS $key => $topic_id)
             // 	{
             // 		$related_topics_ids[$topic_id] = $topic_id;
             // 	}
             // }
             // TPL::assign('related_topics', $related_topics);
             // $log_list = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 10, ACTION_LOG::CATEGORY_TOPIC, implode(',', array(
             // 	ACTION_LOG::ADD_TOPIC,
             // 	ACTION_LOG::MOD_TOPIC,
             // 	ACTION_LOG::MOD_TOPIC_DESCRI,
             // 	ACTION_LOG::MOD_TOPIC_PIC,
             // 	ACTION_LOG::DELETE_TOPIC,
             // 	ACTION_LOG::ADD_RELATED_TOPIC,
             // 	ACTION_LOG::DELETE_RELATED_TOPIC
             // )), -1);
             // $log_list = $this->model('topic')->analysis_log($log_list);
             // $contents_topic_id = $topic_info['topic_id'];
             // $contents_topic_title = $topic_info['topic_title'];
             // if ($merged_topics = $this->model('topic')->get_merged_topic_ids($topic_info['topic_id']))
             // {
             // 	foreach ($merged_topics AS $key => $val)
             // 	{
             // 		$merged_topic_ids[] = $val['source_id'];
             // 	}
             // 	$contents_topic_id .= ',' . implode(',', $merged_topic_ids);
             // 	if ($merged_topics_info = $this->model('topic')->get_topics_by_ids($merged_topic_ids))
             // 	{
             // 		foreach($merged_topics_info AS $key => $val)
             // 		{
             // 			$merged_topic_title[] = $val['topic_title'];
             // 		}
             // 	}
             // 	if ($merged_topic_title)
             // 	{
             // 		$contents_topic_title .= ',' . implode(',', $merged_topic_title);
             // 	}
             // }
             // // $contents_related_topic_ids = array_merge($related_topics_ids, explode(',', $contents_topic_id));
             // // TPL::assign('contents_related_topic_ids', implode(',', $contents_related_topic_ids));
             // // if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), 'new', $contents_related_topic_ids))
             // // {
             // // 	foreach ($posts_list AS $key => $val)
             // // 	{
             // // 		if ($val['answer_count'])
             // // 		{
             // // 			$posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
             // // 		}
             // // 	}
             // // }
             // // TPL::assign('posts_list', $posts_list);
             // // TPL::assign('all_list_bit', TPL::output('explore/ajax/list', false));
             // // if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), null, $contents_related_topic_ids, null, null, 30, true))
             // // {
             // // 	foreach ($posts_list AS $key => $val)
             // // 	{
             // // 		if ($val['answer_count'])
             // // 		{
             // // 			$posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
             // // 		}
             // // 	}
             // // }
             // 问题列表
             $question_list = $this->model('topic')->get_question_list_by_topic($topic_info['topic_id'], $_GET['page'], get_setting('contents_per_page'));
             if ($question_list) {
                 foreach ($question_list as $key => $val) {
                     $this->model('question')->load_list_question_info($question_list[$key], $val, $this->user_id);
                 }
             }
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/topic/id-' . $topic_info['topic_id'] . '__page-', $_GET['page']), 'total_rows' => $this->model('topic')->get_question_list_total(), 'per_page' => get_setting('contents_per_page'), 'num_links' => 2))->create_links());
             TPL::assign('question_list', $question_list);
             //边栏热门话题
             if (TPL::is_output('block/sidebar_hot_topics.tpl.htm', 'question/square')) {
                 TPL::assign('sidebar_hot_topics', $this->model('module')->sidebar_hot_topics($_GET['category'], 4));
             }
             // TPL::assign('topic_recommend_list', $posts_list);
             // TPL::assign('posts_list', $posts_list);
             // TPL::assign('recommend_list_bit', TPL::output('explore/ajax/list', false));
             // TPL::assign('list', $this->model('topic')->get_topic_best_answer_action_list($contents_topic_id, $this->user_id, get_setting('contents_per_page')));
             // TPL::assign('best_questions_list_bit', TPL::output('home/ajax/index_actions', false));
             // TPL::assign('posts_list', $this->model('posts')->get_posts_list('question', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             // TPL::assign('all_questions_list_bit', TPL::output('explore/ajax/list', false));
             // TPL::assign('posts_list', $this->model('posts')->get_posts_list('article', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             // TPL::assign('articles_list_bit', TPL::output('explore/ajax/list', false));
             // TPL::assign('contents_topic_id', $contents_topic_id);
             // TPL::assign('contents_topic_title', $contents_topic_title);
             // TPL::assign('log_list', $log_list);
             // TPL::assign('redirect_message', $redirect_message);
             if ($topic_info['parent_id']) {
                 TPL::assign('parent_topic_info', $this->model('topic')->get_topic_by_id($topic_info['parent_id']));
             }
             TPL::output('topic/index');
             break;
     }
 }
Пример #18
0
 public function publish_answer($question_id, $answer_content, $uid, $anonymous = null, $attach_access_key = null, $auto_focus = true, $reply_to_openid = true)
 {
     if (!($question_info = $this->model('question')->get_question_info_by_id($question_id))) {
         return false;
     }
     if (!($answer_id = $this->model('answer')->save_answer($question_id, $answer_content, $uid, $anonymous))) {
         return false;
     }
     if ($at_users = $this->model('question')->parse_at_user($answer_content, false, true)) {
         foreach ($at_users as $user_id) {
             if ($user_id != $uid) {
                 $this->model('notify')->send($uid, $user_id, notify_class::TYPE_ANSWER_AT_ME, notify_class::CATEGORY_QUESTION, $question_info['question_id'], array('from_uid' => $uid, 'question_id' => $question_info['question_id'], 'item_id' => $answer_id, 'anonymous' => intval($anonymous)));
             }
         }
     }
     set_human_valid('answer_valid_hour');
     if ($auto_focus) {
         if (!$this->model('question')->has_focus_question($question_id, $uid)) {
             $this->model('question')->add_focus_question($question_id, $uid, $anonymous, false);
         }
     }
     ACTION_LOG::save_action($uid, $answer_id, ACTION_LOG::CATEGORY_ANSWER, ACTION_LOG::ANSWER_QUESTION, $answer_content, $question_id);
     ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ANSWER_QUESTION, $answer_content, $answer_id, 0, intval($anonymous));
     if ($question_info['published_uid'] != $uid) {
         $this->model('integral')->process($uid, 'ANSWER_QUESTION', get_setting('integral_system_config_new_answer'), '回答问题 #' . $question_id, $question_id);
         if (get_setting('integral_system_config_answer_change_source') == 'Y' and get_setting('integral_system_config_new_answer') <= 0) {
             $this->model('integral')->process($question_info['published_uid'], 'QUESTION_ANSWER', -get_setting('integral_system_config_new_answer'), '问题被回答 #' . $question_id, $question_id);
         }
     }
     $this->model('question')->save_last_answer($question_id, $answer_id);
     if ($focus_uids = $this->model('question')->get_focus_uid_by_question_id($question_id)) {
         foreach ($focus_uids as $focus_user) {
             if ($focus_user['uid'] != $uid) {
                 $this->model('email')->action_email('NEW_ANSWER', $focus_user['uid'], get_js_url('/question/' . $question_id), array('question_title' => $question_info['question_content']));
                 $this->model('notify')->send($uid, $focus_user['uid'], notify_class::TYPE_NEW_ANSWER, notify_class::CATEGORY_QUESTION, $question_id, array('question_id' => $question_id, 'from_uid' => $uid, 'item_id' => $answer_id, 'anonymous' => intval($anonymous)));
             }
         }
     }
     // 删除回复邀请
     $this->model('question')->answer_question_invite($question_id, $uid);
     if ($attach_access_key) {
         $this->model('publish')->update_attach('answer', $answer_id, $attach_access_key);
     }
     $this->model('question')->delete_question_uninterested($uid, $question_id);
     if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_uid($question_info['published_uid']) and $question_info['published_uid'] != $uid) {
         $weixin_user_info = $this->model('account')->get_user_info_by_uid($weixin_user['uid']);
         if ($weixin_user_info['weixin_settings']['NEW_ANSWER'] != 'N') {
             $this->model('weixin')->send_text_message($weixin_user['openid'], "您的问题 [" . $question_info['question_content'] . "] 收到了新的回答:\n\n" . strip_tags($answer_content), $this->model('openid_weixin_weixin')->redirect_url('/m/question/' . $question_id));
         }
     }
     $this->model('posts')->set_posts_index($question_id, 'question');
     if ($reply_to_openid) {
         if ($question_info['weibo_msg_id']) {
             $this->model('openid_weibo_weibo')->reply_answer_to_sina($question_info['question_id'], cjk_substr($answer_content, 0, 110, 'UTF-8', '...'));
         }
         if ($question_info['received_email_id']) {
             $this->model('edm')->reply_answer_by_email($question_info['question_id'], nl2br(FORMAT::parse_bbcode($answer_content)));
         }
     }
     return $answer_id;
 }
Пример #19
0
 public function parse_log_item($parse_items)
 {
     if (!is_array($parse_items)) {
         return false;
     }
     foreach ($parse_items as $log_id => $item) {
         if (strstr($item['action'], 'ANSWER_FOLD_')) {
             $item['action'] = 'ANSWER_FOLD';
         }
         switch ($item['action']) {
             case 'NEWS_QUESTION':
             case 'ANSWER_QUESTION':
             case 'QUESTION_ANSWER':
             case 'INVITE_ANSWER':
             case 'ANSWER_INVITE':
             case 'THANKS_QUESTION':
             case 'QUESTION_THANKS':
             case 'QUESTION_QUIZ_RETRY':
             case 'QUESTION_VIEW_SOLUTION':
             case 'QUESTION_QUIZ_TIMEOUT':
             case 'QUESTION_QUIZ_CORRECT':
             case 'QUESTION_QUIZ_INCORRECT':
             case 'QUESTION_QUIZ_INVALID':
                 $question_ids[] = $item['item_id'];
                 break;
             case 'ANSWER_THANKS':
             case 'THANKS_ANSWER':
             case 'ANSWER_FOLD':
             case 'BEST_ANSWER':
                 $answer_ids[] = $item['item_id'];
                 break;
             case 'INVITE':
                 $user_ids[] = $item['item_id'];
                 break;
             case 'SIGN_IN':
                 break;
         }
     }
     if ($question_ids) {
         $questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
     }
     if ($answer_ids) {
         $answers_info = $this->model('answer')->get_answers_by_ids($answer_ids);
     }
     if ($user_ids) {
         $users_info = $this->model('account')->get_user_info_by_uids($user_ids);
     }
     foreach ($parse_items as $log_id => $item) {
         if (!$item['item_id']) {
             continue;
         }
         if (strstr($item['action'], 'ANSWER_FOLD_')) {
             $item['action'] = 'ANSWER_FOLD';
         }
         switch ($item['action']) {
             case 'NEWS_QUESTION':
             case 'ANSWER_INVITE':
             case 'ANSWER_QUESTION':
             case 'QUESTION_ANSWER':
             case 'INVITE_ANSWER':
             case 'THANKS_QUESTION':
             case 'QUESTION_THANKS':
             case 'QUESTION_QUIZ_RETRY':
             case 'QUESTION_VIEW_SOLUTION':
             case 'QUESTION_QUIZ_TIMEOUT':
             case 'QUESTION_QUIZ_CORRECT':
             case 'QUESTION_QUIZ_INCORRECT':
             case 'QUESTION_QUIZ_INVALID':
                 if ($questions_info[$item['item_id']]) {
                     $result[$log_id] = array('title' => '问题: ' . $questions_info[$item['item_id']]['question_content'], 'url' => get_js_url('/question/' . $item['item_id']));
                 }
                 break;
             case 'ANSWER_THANKS':
             case 'THANKS_ANSWER':
             case 'ANSWER_FOLD':
             case 'BEST_ANSWER':
                 if ($answers_info[$item['item_id']]) {
                     $result[$log_id] = array('title' => '答案: ' . cjk_substr($answers_info[$item['item_id']]['answer_content'], 0, 24, 'UTF-8', '...'), 'url' => get_js_url('/question/id-' . $answers_info[$item['item_id']]['question_id'] . '__answer_id-' . $item['item_id'] . '__single-TRUE'));
                 }
                 break;
             case 'INVITE':
                 if ($users_info[$item['item_id']]) {
                     $result[$log_id] = array('title' => '用户: ' . $users_info[$item['item_id']]['user_name'], 'url' => get_js_url('/people/' . $users_info[$item['item_id']]['uid']));
                 }
                 break;
             case 'SIGN_IN':
                 break;
         }
     }
     return $result;
 }
Пример #20
0
 public function index_action()
 {
     if ($_GET['notification_id']) {
         $this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
     }
     if ($_GET['column'] == 'log' and !$this->user_id) {
         HTTP::redirect('/question/' . $_GET['id']);
     }
     if (!($question_info = $this->model('question')->get_question_info_by_id($_GET['id']))) {
         H::redirect_msg(AWS_APP::lang()->_t('问题不存在或已被删除'), '/question/');
     }
     if (!$_GET['sort'] or $_GET['sort'] != 'ASC') {
         $_GET['sort'] = 'DESC';
     } else {
         $_GET['sort'] = 'ASC';
     }
     if (get_setting('unfold_question_comments') == 'Y') {
         $_GET['comment_unfold'] = 'all';
     }
     $question_info['redirect'] = $this->model('question')->get_redirect($question_info['question_id']);
     if ($question_info['redirect']['target_id']) {
         $target_question = $this->model('question')->get_question_info_by_id($question_info['redirect']['target_id']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_question = $this->model('question')->get_question_info_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('从问题 %s 跳转而来', '<a href="' . get_js_url('/question/' . $_GET['rf'] . '?rf=false') . '">' . $from_question['question_content'] . '</a>');
         }
     }
     if ($question_info['redirect'] and !$_GET['rf']) {
         if ($target_question) {
             HTTP::redirect('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']);
         } else {
             $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
         }
     } else {
         if ($question_info['redirect']) {
             if ($target_question) {
                 $message = AWS_APP::lang()->_t('此问题将跳转至') . ' <a href="' . get_js_url('/question/' . $question_info['redirect']['target_id'] . '?rf=' . $question_info['question_id']) . '">' . $target_question['question_content'] . '</a>';
                 if ($this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or !$this->question_info['lock'] and $this->user_info['permission']['redirect_question'])) {
                     $message .= '&nbsp; (<a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL + \'/question/ajax/redirect/\', \'item_id=' . $question_info['question_id'] . '\');">' . AWS_APP::lang()->_t('撤消重定向') . '</a>)';
                 }
                 $redirect_message[] = $message;
             } else {
                 $redirect_message[] = AWS_APP::lang()->_t('重定向目标问题已被删除, 将不再重定向问题');
             }
         }
     }
     if ($question_info['has_attach']) {
         $question_info['attachs'] = $this->model('publish')->get_attach('question', $question_info['question_id'], 'min');
         $question_info['attachs_ids'] = FORMAT::parse_attachs($question_info['question_detail'], true);
     }
     $question_info['user_info'] = $this->model('account')->get_user_info_by_uid($question_info['published_uid'], true);
     // 分类信息
     if ($question_info['category_id']) {
         $question_info['category_info'] = $this->model('system')->get_category_info($question_info['category_id']);
     }
     if (intval($question_info['quiz_id']) > 0) {
         $question_info['question_quiz'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     $this->model('question')->calc_popular_value($question_info['question_id']);
     $this->model('question')->update_views($question_info['question_id']);
     // if ($_GET['column'] != 'log')
     // {
     // $this->model('question')->calc_popular_value($question_info['question_id']);
     // $this->model('question')->update_views($question_info['question_id']);
     // if (is_digits($_GET['uid']))
     // {
     // 	$answer_list_where[] = 'uid = ' . intval($_GET['uid']);
     // 	$answer_count_where = 'uid = ' . intval($_GET['uid']);
     // }
     // else if ($_GET['uid'] == 'focus' and $this->user_id)
     // {
     // 	if ($friends = $this->model('follow')->get_user_friends($this->user_id, false))
     // 	{
     // 		foreach ($friends as $key => $val)
     // 		{
     // 			$follow_uids[] = $val['uid'];
     // 		}
     // 	}
     // 	else
     // 	{
     // 		$follow_uids[] = 0;
     // 	}
     // 	$answer_list_where[] = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_count_where = 'uid IN(' . implode($follow_uids, ',') . ')';
     // 	$answer_order_by = 'add_time ASC';
     // }
     // else if ($_GET['sort_key'] == 'add_time')
     // {
     // 	$answer_order_by = $_GET['sort_key'] . " " . $_GET['sort'];
     // }
     // else
     // {
     // 	$answer_order_by = "agree_count " . $_GET['sort'] . ", against_count ASC, add_time ASC";
     // }
     // if ($answer_count_where)
     // {
     // 	$answer_count = $this->model('answer')->get_answer_count_by_question_id($question_info['question_id'], $answer_count_where);
     // }
     // else
     // {
     // 	$answer_count = $question_info['answer_count'];
     // }
     // if (isset($_GET['answer_id']) and (! $this->user_id OR $_GET['single']))
     // {
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($_GET['answer_id']));
     // }
     // else if (! $this->user_id AND !$this->user_info['permission']['answer_show'])
     // {
     // 	if ($question_info['best_answer'])
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . intval($question_info['best_answer']));
     // 	}
     // 	else
     // 	{
     // 		$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, null, 'agree_count DESC');
     // 	}
     // }
     // else
     // {
     // 	if ($answer_list_where)
     // 	{
     // 		$answer_list_where = implode(' AND ', $answer_list_where);
     // 	}
     // 	$answer_list = $this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], calc_page_limit($_GET['page'], 100), $answer_list_where, $answer_order_by);
     // }
     // // 最佳回复预留
     // $answers[0] = '';
     // if (! is_array($answer_list))
     // {
     // 	$answer_list = array();
     // }
     // $answer_ids = array();
     // $answer_uids = array();
     // foreach ($answer_list as $answer)
     // {
     // 	$answer_ids[] = $answer['answer_id'];
     // 	$answer_uids[] = $answer['uid'];
     // 	if ($answer['has_attach'])
     // 	{
     // 		$has_attach_answer_ids[] = $answer['answer_id'];
     // 	}
     // }
     // if (!in_array($question_info['best_answer'], $answer_ids) AND intval($_GET['page']) < 2)
     // {
     // 	$answer_list = array_merge($this->model('answer')->get_answer_list_by_question_id($question_info['question_id'], 1, 'answer_id = ' . $question_info['best_answer']), $answer_list);
     // }
     // if ($answer_ids)
     // {
     // 	$answer_agree_users = $this->model('answer')->get_vote_user_by_answer_ids($answer_ids);
     // 	$answer_vote_status = $this->model('answer')->get_answer_vote_status($answer_ids, $this->user_id);
     // 	$answer_users_rated_thanks = $this->model('answer')->users_rated('thanks', $answer_ids, $this->user_id);
     // 	$answer_users_rated_uninterested = $this->model('answer')->users_rated('uninterested', $answer_ids, $this->user_id);
     // 	$answer_attachs = $this->model('publish')->get_attachs('answer', $has_attach_answer_ids, 'min');
     // }
     // foreach ($answer_list as $answer)
     // {
     // 	if ($answer['has_attach'])
     // 	{
     // 		$answer['attachs'] = $answer_attachs[$answer['answer_id']];
     // 		$answer['insert_attach_ids'] = FORMAT::parse_attachs($answer['answer_content'], true);
     // 	}
     // 	$answer['user_rated_thanks'] = $answer_users_rated_thanks[$answer['answer_id']];
     // 	$answer['user_rated_uninterested'] = $answer_users_rated_uninterested[$answer['answer_id']];
     // 	$answer['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($answer['answer_content']))));
     // 	$answer['agree_users'] = $answer_agree_users[$answer['answer_id']];
     // 	$answer['agree_status'] = $answer_vote_status[$answer['answer_id']];
     // 	if ($question_info['best_answer'] == $answer['answer_id'] AND intval($_GET['page']) < 2)
     // 	{
     // 		$answers[0] = $answer;
     // 	}
     // 	else
     // 	{
     // 		$answers[] = $answer;
     // 	}
     // 	// 获取回答评论列表
     // 	$comments = $this->model('answer')->get_answer_comments($answer['answer_id']);
     // 	$user_infos = $this->model('account')->get_user_info_by_uids(fetch_array_value($comments, 'uid'));
     // 	foreach ($comments as $key => $val)
     // 	{
     // 		$comments[$key]['message'] = FORMAT::parse_links($this->model('question')->parse_at_user($comments[$key]['message']));
     // 		$comments[$key]['user_name'] = $user_infos[$val['uid']]['user_name'];
     // 		$comments[$key]['url_token'] = $user_infos[$val['uid']]['url_token'];
     // 	}
     // 	$answer_comments[$answer['answer_id']] = $comments;
     // }
     // if (! $answers[0])
     // {
     // 	unset($answers[0]);
     // }
     // if (get_setting('answer_unique') == 'Y')
     // {
     // if ($this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id))
     // {
     // 	TPL::assign('user_answered', 1);
     // }
     // else
     // {
     // 	TPL::assign('user_answered', 0);
     // }
     // }
     $user_answered = $this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id);
     $answer_count = $question_info['answer_count'];
     TPL::assign('user_answered', $user_answered);
     // TPL::assign('answers', $answers);
     // TPL::assign('comments', $answer_comments);
     TPL::assign('answer_count', $answer_count);
     // }
     // 用户是否通过答题
     $passed_quiz = $this->model('quiz')->user_question_quiz_passed($question_info['question_id'], $this->user_id);
     $show_answers = ($question_info['published_uid'] == $this->user_id or $this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'] or $user_answered or $passed_quiz);
     TPL::assign('show_answers', $show_answers);
     if ($this->user_id) {
         TPL::assign('question_thanks', $this->model('question')->get_question_thanks($question_info['question_id'], $this->user_id));
         // TPL::assign('invite_users', $this->model('question')->get_invite_users($question_info['question_id']));
         TPL::assign('user_follow_check', $this->model('follow')->user_follow_check($this->user_id, $question_info['published_uid']));
         if ($this->user_info['draft_count'] > 0) {
             TPL::assign('draft_content', $this->model('draft')->get_data($question_info['question_id'], 'answer', $this->user_id));
         }
     }
     $question_info['question_detail'] = FORMAT::parse_attachs(nl2br(FORMAT::parse_bbcode($question_info['question_detail'])));
     // 获取答题选项类型
     if ($question_info['quiz_id']) {
         $question_info['quiz_info'] = $this->model('quiz')->get_question_quiz_info_by_id($question_info['quiz_id']);
     }
     TPL::assign('question_info', $question_info);
     TPL::assign('question_focus', $this->model('question')->has_focus_question($question_info['question_id'], $this->user_id));
     $question_topics = $this->model('topic')->get_topics_by_item_id($question_info['question_id'], 'question');
     if (sizeof($question_topics) == 0 and $this->user_id) {
         $related_topics = $this->model('question')->get_related_topics($question_info['question_content']);
         TPL::assign('related_topics', $related_topics);
     }
     TPL::assign('question_topics', $question_topics);
     // 可能喜欢的问题
     $exclude_qids[] = $question_info['question_id'];
     $recommend_questions = $this->model('question')->get_recommend_question_list_by_category($question_info['question_id'], $exclude_qids, $this->user_id, 8);
     if ($recommend_questions) {
         foreach ($recommend_questions as $key => $value) {
             // 获取相关问题的附加图片
             if ($value['has_attach']) {
                 $recommend_questions[$key]['attachs'] = $this->model('publish')->get_attach('question', $value['question_id'], 'min');
             }
             // 获取是否为限时答题信息
             $is_countdown = false;
             if ($value['quiz_id']) {
                 $quiz_info = $this->model('quiz')->get_question_quiz_info_by_id($value['quiz_id']);
                 $is_countdown = $quiz_info['countdown'] > 0;
             }
             $recommend_questions[$key]['is_countdown'] = $is_countdown;
         }
         TPL::assign('recommend_question_list', $recommend_questions);
     }
     TPL::assign('question_related_links', $this->model('related')->get_related_links('question', $question_info['question_id']));
     // 推荐用户答题功能
     $exclude_uids[] = $question_info['published_uid'];
     if ($this->user_id) {
         $exclude_uids[] = $this->user_id;
     }
     $invited_uids = $this->model('question')->get_invited_user_ids($question_info['question_id']);
     if ($invited_uids) {
         foreach ($invited_uids as $key => $val) {
             $exclude_uids[] = $val['uid'];
         }
     }
     if ($question_info['quiz_id']) {
         $answered_uids = $this->model('question')->get_quized_uids($question_info['question_id']);
     } else {
         $answered_uids = $this->model('question')->get_commented_uids($question_info['question_id']);
     }
     if ($answered_uids) {
         foreach ($answered_uids as $val) {
             if (!in_array($val, $exclude_uids)) {
                 $exclude_uids[] = $val['uid'];
             }
         }
     }
     TPL::assign('exclude_uids', $exclude_uids);
     $recommend_users = $this->model('question')->get_recommend_users_by_category_id($question_info['category_id'], $exclude_uids, get_setting('user_question_invite_recommend'));
     if ($recommend_users) {
         $uids = null;
         foreach ($recommend_users as $key => $val) {
             $uids[] = $val['uid'];
         }
         $users_info = $this->model('account')->get_user_info_by_uids($uids, true);
         foreach ($recommend_users as $key => $val) {
             $recommend_users[$key]['user_info'] = $users_info[$val['uid']];
         }
     }
     TPL::assign('recommend_users', $recommend_users);
     TPL::assign('invited_user_count', $this->model('question')->get_invited_user_count($question_info['question_id']));
     // if ($this->user_id)
     // {
     // 	if ($question_topics)
     // 	{
     // 		foreach ($question_topics AS $key => $val)
     // 		{
     // 			$question_topic_ids[] = $val['topic_id'];
     // 		}
     // 	}
     // 	if ($recommend_users = $this->model('topic')->get_recommend_users_by_topic_ids($question_topic_ids, 17))
     // 	{
     // 		foreach ($recommend_users AS $key => $val)
     // 		{
     // 			if ($val['user_info']['uid'] == $this->user_id)
     // 			{
     // 				unset($recommend_users[$key]);
     // 			}
     // 			else
     // 			{
     // 				$recommend_users[$key]['has_invite'] = $this->model('question')->has_question_invite($question_info['question_id'], $val['user_info']['uid'], $this->user_id);
     // 				$recommend_users[$key]['experience'] = end($recommend_users[$key]['experience']);
     // 			}
     // 		}
     // 		TPL::assign('recommend_users', $recommend_users);
     // 	}
     // }
     $this->crumb($question_info['question_content'], '/question/' . $question_info['question_id']);
     if ($_GET['column'] == 'log') {
         // $this->crumb(AWS_APP::lang()->_t('日志'), '/question/id-' . $question_info['question_id'] . '__column-log');
     } else {
         TPL::assign('human_valid', human_valid('answer_valid_hour'));
         if ($this->user_id) {
             TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/question/id-' . $question_info['question_id'] . '__sort_key-' . $_GET['sort_key'] . '__sort-' . $_GET['sort'] . '__uid-' . $_GET['uid']), 'total_rows' => $answer_count, 'per_page' => 100))->create_links());
         }
     }
     TPL::set_meta('keywords', implode(',', $this->model('system')->analysis_keyword($question_info['question_content'])));
     TPL::set_meta('description', $question_info['question_content'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($question_info['question_detail'])), 0, 128, 'UTF-8', '...'));
     if (get_setting('advanced_editor_enable') == 'Y') {
         import_editor_static_files();
     }
     if (get_setting('upload_enable') == 'Y') {
         // fileupload
         TPL::import_js('js/fileupload.js');
     }
     TPL::assign('redirect_message', $redirect_message);
     $recommend_posts = $this->model('posts')->get_recommend_posts_by_topic_ids($question_topic_ids);
     if ($recommend_posts) {
         foreach ($recommend_posts as $key => $value) {
             if ($value['question_id'] and $value['question_id'] == $question_info['question_id']) {
                 unset($recommend_posts[$key]);
                 break;
             }
         }
         TPL::assign('recommend_posts', $recommend_posts);
     }
     // 是否进行出题成功提示
     if ($this->user_id == $question_info['published_uid'] and $question_info['is_first']) {
         TPL::assign('is_first_visited', true);
         TPL::assign('publish_integral', get_setting('integral_system_config_new_question'));
         TPL::assign('user_integral', $this->user_info['integral']);
         $this->model('question')->set_is_first_visited($question_info['question_id'], 0);
     }
     // 答题动态信息
     $question_quiz_record = $this->model('quiz')->get_question_quiz_record_list_page($question_info['question_id'], 1, 5);
     TPL::assign('question_quiz_record', $question_quiz_record);
     // // 添加题目解析提示提示
     // if($this->user_id == $question_info['published_uid'] AND !$question_info['solution_id'])
     // {
     // 	TPL::assign('show_add_solution_hint', true);
     // }
     // 获取上一道题目和下一道题目的信息
     // $question_info_next = $this->model('question')->get_next_question_info($question_info['question_id']);
     // $question_info_previous = $this->model('question')->get_previous_question_info($question_info['question_id']);
     // TPL::assign('question_info_next', $question_info_next);
     // TPL::assign('question_info_previous', $question_info_previous);
     TPL::import_js('js/app/question.js');
     TPL::import_js('js/bootstrap-growl.min.js');
     TPL::import_js('js/quiz.js');
     TPL::import_css('css/quiz.css');
     TPL::import_js('js/sweetalert.min.js');
     TPL::import_css('css/sweetalert.css');
     TPL::import_js('js/jquery-qrcode.min.js');
     TPL::import_js('js/share.js');
     TPL::output('question/index');
 }