本文整理汇总了PHP中FORMAT::parse_markdown方法的典型用法代码示例。如果您正苦于以下问题:PHP FORMAT::parse_markdown方法的具体用法?PHP FORMAT::parse_markdown怎么用?PHP FORMAT::parse_markdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FORMAT
的用法示例。
在下文中一共展示了FORMAT::parse_markdown方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: questions_list_action
public function questions_list_action()
{
if ($_GET['feature_id']) {
$topic_ids = $this->model('feature')->get_topics_by_feature_id($_GET['feature_id']);
if ($topic_ids) {
$answers = $this->model('reader')->fetch_answers_list_by_topic_ids($topic_ids, $_GET['page'], 20);
}
} else {
$answers = $this->model('reader')->fetch_answers_list($_GET['page'], 20);
}
$output = array();
if ($answers) {
foreach ($answers as $key => $val) {
$question_ids[$val['question_id']] = $val['question_id'];
$uids[$val['uid']] = $val['uid'];
}
$questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
$question_topics = $this->model('topic')->get_topics_by_item_ids($question_ids, 'question');
$users_info = $this->model('account')->get_user_info_by_uids($uids, TRUE);
foreach ($answers as $key => $val) {
$output['answers'][$val['answer_id']] = array('answer_id' => $val['answer_id'], 'question_id' => $val['question_id'], 'avatar' => get_avatar_url($val['uid'], 'mid'), 'user_name' => $users_info[$val['uid']]['user_name'], 'signature' => $users_info[$val['uid']]['signature'], 'agree_count' => $val['agree_count'], 'agree_users' => $this->model('answer')->get_vote_user_by_answer_id($val['answer_id']), 'answer_content' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['answer_content']))), 'add_time' => date_friendly($val['add_time']), 'uid' => $val['uid']);
}
foreach ($questions_info as $key => $val) {
$output['questions'][$val['question_id']] = array('question_id' => $val['question_id'], 'question_content' => $val['question_content'], 'question_detail' => FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['question_detail']))), 'answer_users' => $val['answer_users'], 'focus_count' => $val['focus_count'], 'view_count' => $val['view_count'], 'topics' => $question_topics[$val['question_id']]);
}
}
echo json_encode($output);
}
示例2: article_action
public function article_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('文章不存在或已被删除'), '/home/explore/');
}
$this->crumb($article_info['title'], '/article/' . $article_info['id']);
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'], null, 10);
TPL::assign('article_info', $article_info);
TPL::assign('article_topics', $this->model('topic')->get_topics_by_item_id($article_info['id'], 'article'));
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);
}
}
$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('/m/article/id-' . $article_info['id']), 'total_rows' => $article_info['comments'], 'per_page' => 100))->create_links());
TPL::output('m/article');
}
示例3: add_questions_to_mpnews
public function add_questions_to_mpnews($question_ids)
{
$questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
if (!$questions_info) {
return false;
}
foreach ($questions_info as $question_info) {
$published_uids[] = $question_info['published_uid'];
}
$users_info = $this->model('account')->get_user_info_by_uids($published_uids);
foreach ($questions_info as $question_info) {
$user_info = $users_info[$question_info['published_uid']];
$img = get_setting('upload_dir') . '/avatar/' . $this->model('account')->get_avatar($user_info['uid'], 'max');
if (!is_file($img)) {
$img = ROOT_PATH . 'static/common/avatar-max-img.jpg';
}
$result = $this->model('openid_weixin_weixin')->upload_file($img, 'image');
if (!$result) {
return AWS_APP::lang()->_t('远程服务器忙');
}
if ($result['errmsg']) {
return $result['errmsg'];
}
$this->mpnews['articles'][] = array('thumb_media_id' => $result['media_id'], 'author' => $user_info['user_name'], 'title' => $question_info['question_content'], 'content_source_url' => get_js_url('/m/question/' . $question_info['question_id']), 'content' => FORMAT::parse_markdown($question_info['question_detail']), 'show_cover_pic' => '0');
$this->to_save_questions[$question_info['question_id']] = array('id' => $question_info['question_id'], 'title' => $question_info['question_content']);
}
}
示例4: preview_action
public function preview_action()
{
if (!$_GET['action'] or $_GET['action'] != 'edit') {
$_GET['action'] = 'preview';
} else {
$this->crumb(AWS_APP::lang()->_t('待审项修改'), 'admin/approval/edit/');
TPL::assign('menu_list', $this->model('admin')->fetch_menu_list(300));
}
switch ($_GET['type']) {
case 'weibo_msg':
$approval_item = $this->model('openid_weibo_weibo')->get_msg_info_by_id($_GET['id']);
if ($approval_item['question_id']) {
exit;
}
$approval_item['type'] = 'weibo_msg';
break;
case 'received_email':
$approval_item = $this->model('edm')->get_received_email_by_id($_GET['id']);
if ($approval_item['question_id']) {
exit;
}
$approval_item['type'] = 'received_email';
break;
default:
$approval_item = $this->model('publish')->get_approval_item($_GET['id']);
break;
}
if (!$approval_item) {
exit;
}
switch ($approval_item['type']) {
case 'question':
$approval_item['title'] = htmlspecialchars($approval_item['data']['question_content']);
$approval_item['content'] = htmlspecialchars($approval_item['data']['question_detail']);
$approval_item['topics'] = htmlspecialchars(implode(',', $approval_item['data']['topics']));
break;
case 'answer':
$approval_item['content'] = htmlspecialchars($approval_item['data']['answer_content']);
break;
case 'article':
$approval_item['title'] = htmlspecialchars($approval_item['data']['title']);
$approval_item['content'] = htmlspecialchars($approval_item['data']['message']);
break;
case 'article_comment':
$approval_item['content'] = htmlspecialchars($approval_item['data']['message']);
break;
case 'weibo_msg':
$approval_item['content'] = htmlspecialchars($approval_item['text']);
if ($approval_item['has_attach']) {
$approval_item['attachs'] = $this->model('publish')->get_attach('weibo_msg', $_GET['id']);
}
break;
case 'received_email':
$approval_item['title'] = htmlspecialchars($approval_item['subject']);
$approval_item['content'] = htmlspecialchars($approval_item['content']);
break;
}
if ($approval_item['data']['attach_access_key']) {
$approval_item['attachs'] = $this->model('publish')->get_attach_by_access_key($approval_item['type'], $approval_item['data']['attach_access_key']);
}
if ($_GET['action'] != 'edit') {
$approval_item['content'] = nl2br(FORMAT::parse_markdown($approval_item['content']));
}
TPL::assign('approval_item', $approval_item);
TPL::output('admin/approval/' . $_GET['action']);
}
示例5: index_action
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');
}
示例6: topic_action
public function topic_action()
{
if (is_numeric($_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::ajax_json_output(AWS_APP::RSM(null, -1, 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'])) {
$topic_info = $this->model('topic')->get_topic_by_id($_GET['merged_id']);
$topic_info['merged_tip'] = "您查看的话题已被合并到当前话题";
} else {
$this->model('topic')->remove_merge_topic($topic_info['topic_id'], $topic_info['merged_id']);
}
}
//此话题的最佳回答者
//TPL::assign('best_answer_users', $this->model('topic')->get_best_answer_users_by_topic_id($topic_info['topic_id'], 5));
if ($this->user_id) {
$topic_info['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
}
$topic_info['topic_description'] = nl2br(FORMAT::parse_markdown($topic_info['topic_description']));
H::ajax_json_output(AWS_APP::RSM(array('topic_info' => $topic_info), 1, null));
}
示例7: index_action
public function index_action()
{
$this->pre_page = 100;
if ($_GET['notification_id']) {
$this->model('notify')->read_notification($_GET['notification_id'], $this->user_id);
}
$ticket_info = $this->model('ticket')->get_ticket_info_by_id($_GET['id']);
if (!$ticket_info) {
H::redirect_msg(AWS_APP::lang()->_t('工单不存在或已被删除'), '/');
}
if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_service'] and $ticket_info['uid'] != $this->user_id and !$this->model('ticket')->has_invited($this->user_id)) {
H::redirect_msg(AWS_APP::lang()->_t('你没有权限查看该工单'));
}
$this->crumb($ticket_info['title'], '/ticket/' . $ticket_info['id']);
$uids[] = $ticket_info['uid'];
if ($ticket_info['service']) {
$uids[] = $ticket_info['service'];
}
if ($_GET['column']) {
if ($_GET['column'] == 'log') {
$ticket_log = $this->model('ticket')->parse_ticket_log($ticket_info['id']);
if ($ticket_log) {
foreach ($ticket_log as $log_info) {
$uids[] = $log_info['uid'];
}
}
}
} else {
if (!$_GET['page']) {
$_GET['page'] = 1;
}
if ($_GET['reply_id']) {
$replies_list = array($this->model('ticket')->get_ticket_reply_by_id($_GET['reply_id']));
} else {
$replies_list = $this->model('ticket')->get_replies_list_by_ticket_id($ticket_info['id'], $_GET['page'], $this->pre_page);
}
if ($replies_list) {
foreach ($replies_list as $reply_info) {
$uids[] = $reply_info['uid'];
}
}
$replies_count = $this->model('ticket')->found_rows();
TPL::assign('replies_count', $replies_count);
TPL::assign('draft_content', $this->model('draft')->get_data(1, 'ticket_reply', $this->user_id));
TPL::assign('attach_access_key', md5($this->user_id . time()));
TPL::assign('human_valid', human_valid('answer_valid_hour'));
if (get_setting('advanced_editor_enable') == 'Y') {
import_editor_static_files();
}
if (get_setting('upload_enable') == 'Y') {
// fileupload
TPL::import_js('js/fileupload.js');
}
}
$ticket_topics = $this->model('topic')->get_topics_by_item_id($ticket_info['id'], 'ticket');
if ($ticket_topics) {
TPL::assign('ticket_topics', $ticket_topics);
}
$invite_users = $this->model('ticket')->get_invite_users($ticket_info['id']);
if ($invite_users) {
foreach ($invite_users as $invite_info) {
$uids[] = $invite_info['recipient_uid'];
}
}
$users_list = $this->model('account')->get_user_info_by_uids($uids);
$ticket_info['user_info'] = $users_list[$ticket_info['uid']];
$ticket_info['service_info'] = $users_list[$ticket_info['service']];
$ticket_info['message'] = nl2br(FORMAT::parse_markdown($ticket_info['message']));
if ($ticket_info['has_attach']) {
$ticket_info['attachs'] = $this->model('publish')->get_attach('ticket', $ticket_info['id'], 'min');
$ticket_info['insert_attach_ids'] = FORMAT::parse_attachs($ticket_info['message'], true);
$ticket_info['message'] = FORMAT::parse_attachs($ticket_info['message']);
}
if ($ticket_log) {
foreach ($ticket_log as $key => $log_info) {
$ticket_log[$key]['user_info'] = $users_list[$log_info['uid']];
}
TPL::assign('ticket_log', $ticket_log);
}
if ($replies_list) {
foreach ($replies_list as $key => $reply_info) {
$replies_list[$key]['user_info'] = $users_list[$reply_info['uid']];
$replies_list[$key]['message'] = nl2br(FORMAT::parse_markdown($reply_info['message']));
if ($reply_info['has_attach']) {
$has_attach_reply_ids[] = $reply_info['id'];
}
}
if ($has_attach_reply_ids) {
$reply_attachs = $this->model('publish')->get_attachs('ticket_reply', $has_attach_reply_ids, 'min');
foreach ($replies_list as $key => $reply_info) {
if ($reply_info['has_attach']) {
$replies_list[$key]['attachs'] = $reply_attachs[$reply_info['id']];
$replies_list[$key]['insert_attach_ids'] = FORMAT::parse_attachs($reply_info['message'], true);
$replies_list[$key]['message'] = FORMAT::parse_attachs($reply_info['message']);
}
}
}
TPL::assign('replies_list', $replies_list);
TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/ticket/id-' . $ticket_info['id']), 'total_rows' => $replies_count, 'per_page' => $this->pre_page))->create_links());
}
//.........这里部分代码省略.........
示例8: reply_action
public function reply_action()
{
$_POST['message'] = trim($_POST['message']);
if (!$_POST['message']) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入回复内容')));
}
if (!$_POST['id']) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要回复的工单')));
}
$ticket_info = $this->model('ticket')->get_ticket_info_by_id($_POST['id']);
if (!$ticket_info) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('工单不存在')));
}
if ($ticket_info['status'] == 'closed') {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('工单已关闭')));
}
if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_service'] and $ticket_info['uid'] != $this->user_id and !$this->model('ticket')->has_invited($this->user_id)) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限回复该工单')));
}
$reply_id = $this->model('ticket')->reply_ticket($ticket_info['id'], $_POST['message'], $this->user_id, $_POST['attach_access_key']);
if (!$reply_id) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('回复失败')));
}
$this->model('draft')->delete_draft(1, 'ticket_reply', $this->user_id);
$reply_info = $this->model('ticket')->get_ticket_reply_by_id($reply_id);
if ($ticket_info['uid'] != $this->user_id) {
$this->model('notify')->send($reply_info['uid'], $ticket_info['uid'], notify_class::TYPE_TICKET_REPLIED, notify_class::CATEGORY_TICKET, 0, array('from_uid' => $reply_info['uid'], 'ticket_id' => $ticket_info['id'], 'reply_id' => $reply_info['id']));
}
$reply_info['user_info'] = $this->user_info;
$reply_info['message'] = nl2br(FORMAT::parse_markdown($reply_info['message']));
if ($reply_info['has_attach']) {
$reply_info['attachs'] = $this->model('publish')->get_attach('ticket', $reply_info['id'], 'min');
$reply_info['insert_attach_ids'] = FORMAT::parse_attachs($reply_info['message'], true);
$reply_info['message'] = FORMAT::parse_attachs($reply_info['message']);
}
if (!$ticket_info['service'] and $ticket_info['uid'] != $this->user_id and ($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_service'])) {
$this->model('ticket')->assign_service($ticket_info['id'], $this->user_id);
}
TPL::assign('reply_info', $reply_info);
H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('ticket/ajax/reply', false)), 1, null));
}
示例9: publish_answer
public function publish_answer($question_id, $answer_content, $uid, $anonymous = null, $attach_access_key = null, $auto_focus = 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, htmlspecialchars($answer_content), $question_id);
ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ANSWER_QUESTION, htmlspecialchars($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 ($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_markdown($answer_content)));
}
return $answer_id;
}
示例10: save_answer_action
public function save_answer_action()
{
if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y') {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作')));
}
if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['question_id']))) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('主题不存在')));
}
if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('已经锁定的主题不能回复')));
}
$answer_content = trim($_POST['answer_content'], "\r\n\t");
if (!$answer_content) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入回复内容')));
}
// 判断是否是主题发表者
if (get_setting('answer_self_question') == 'N' and $question_info['published_uid'] == $this->user_id) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('不能回复自己发布的主题,你可以修改主题内容')));
}
// 判断是否已回复过主题
if (get_setting('answer_unique') == 'Y' and $this->model('answer')->has_answer_by_uid($question_info['question_id'], $this->user_id)) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个主题只能回复一次,你可以编辑回复过的回复')));
}
if (strlen($answer_content) < get_setting('answer_length_lower')) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('回复内容字数不得少于 %s 字节', get_setting('answer_length_lower'))));
}
if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($answer_content)) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
}
if (!$this->model('publish')->insert_attach_is_self_upload($answer_content, $_POST['attach_ids'])) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
}
if (human_valid('answer_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
}
// !注: 来路检测后面不能再放报错提示
if (!valid_post_hash($_POST['post_hash'])) {
H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
}
$this->model('draft')->delete_draft($question_info['question_id'], 'answer', $this->user_id);
if ($this->publish_approval_valid()) {
$this->model('publish')->publish_approval('answer', array('question_id' => $question_info['question_id'], 'answer_content' => $answer_content, 'anonymous' => $_POST['anonymous'], 'attach_access_key' => $_POST['attach_access_key'], 'auto_focus' => $_POST['auto_focus']), $this->user_id, $_POST['attach_access_key']);
H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/publish/wait_approval/question_id-' . $question_info['question_id'] . '__is_mobile-' . $_POST['_is_mobile'])), 1, null));
} else {
$answer_id = $this->model('publish')->publish_answer($question_info['question_id'], $answer_content, $this->user_id, $_POST['anonymous'], $_POST['attach_access_key'], $_POST['auto_focus']);
if ($_POST['_is_mobile']) {
//$url = get_js_url('/m/question/id-' . $question_info['question_id'] . '__item_id-' . $answer_id . '__rf-false');
$this->model('answer')->set_answer_publish_source($answer_id, 'mobile');
} else {
//$url = get_js_url('/question/' . $question_info['question_id'] . '?item_id=' . $answer_id . '&rf=false');
}
$answer_info = $this->model('answer')->get_answer_by_id($answer_id);
if ($answer_info['has_attach']) {
$answer_info['attachs'] = $this->model('publish')->get_attach('answer', $answer_id, 'min');
$answer_info['insert_attach_ids'] = FORMAT::parse_attachs($answer_info['answer_content'], true);
}
$answer_info['user_info'] = $this->user_info;
$answer_info['answer_content'] = $this->model('question')->parse_at_user(FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($answer_info['answer_content']))));
TPL::assign('answer_info', $answer_info);
if (is_mobile()) {
H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('m/ajax/question_answer', false)), 1, null));
} else {
H::ajax_json_output(AWS_APP::RSM(array('ajax_html' => TPL::output('question/ajax/answer', false)), 1, null));
}
}
}
示例11: topics_action
public function topics_action()
{
if (!is_array($_POST['topics'])) {
$_POST['topics'] = explode(',', $_POST['topics']);
//英文逗号隔开
}
if (!$_POST['topics']) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('参数错误')));
}
if (!($topic_info = $this->model('topic')->get_topics_by_ids($_POST['topics']))) {
H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('话题不存在')));
}
foreach ($topic_info as $key => $val) {
if ($val['topic_pic']) {
$topic_info[$key]['topic_pic'] = get_setting('upload_url') . '/topic/' . $val['topic_pic'];
}
$topic_info[$key]['has_focus'] = 0;
if ($this->user_id and $this->model('topic')->has_focus_topic($this->user_id, $val['topic_id'])) {
$topic_info[$key]['has_focus'] = 1;
}
$topic_info[$key]['topic_description'] = nl2br(FORMAT::parse_markdown($val['topic_description']));
}
H::ajax_json_output(AWS_APP::RSM(array('total_rows' => count($topic_info), 'rows' => array_values($topic_info)), 1, null));
}