本文整理汇总了PHP中qa_viewer_text函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_viewer_text函数的具体用法?PHP qa_viewer_text怎么用?PHP qa_viewer_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_viewer_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = preg_replace('/\\s+/', ' ', $text);
// Remove duplicated blanks, new line characters, tabs, etc
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title);
}
}
}
}
parent::q_list($q_list);
// call back through to the default function
}
示例2: q_list
function q_list($q_list)
{
if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (count($postids)) {
// Retrieve the content for these questions from the database and put into an array
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
$maxlength = qa_opt('mouseover_content_max_len');
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>';
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例3: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例4: qa_wall_add_post
function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-db-messages.php';
$messageid = qa_db_message_create($userid, $touserid, $content, $format, true);
qa_db_user_recount_posts($touserid);
qa_report_event('u_wall_post', $userid, $handle, $cookieid, array('userid' => $touserid, 'handle' => $tohandle, 'messageid' => $messageid, 'content' => $content, 'format' => $format, 'text' => qa_viewer_text($content, $format)));
return $messageid;
}
示例5: send_default_emails
function send_default_emails($event, $userid, $handle, $cookieid, $params)
{
switch ($event) {
case 'q_queue':
case 'q_requeue':
if (qa_opt('moderate_notify_admin')) {
qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'q_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'q_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldquestion['name']) ? $oldquestion['name'] : qa_lang('main/anonymous'))), '^p_context' => trim(@$params['title'] . "\n\n" . $params['text']), '^url' => qa_q_path($params['postid'], $params['title'], true), '^a_url' => qa_path_absolute('admin/moderate')));
}
break;
case 'a_queue':
case 'a_requeue':
if (qa_opt('moderate_notify_admin')) {
qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'a_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'a_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous'))), '^p_context' => $params['text'], '^url' => qa_q_path($params['parentid'], $params['parent']['title'], true, 'A', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate')));
}
break;
case 'c_queue':
case 'c_requeue':
if (qa_opt('moderate_notify_admin')) {
qw_send_notification(null, qa_opt('feedback_email'), null, $event == 'c_requeue' ? qa_lang('emails/remoderate_subject') : qa_lang('emails/moderate_subject'), $event == 'c_requeue' ? nl2br(qa_lang('emails/remoderate_body')) : nl2br(qa_lang('emails/moderate_body')), array('^p_handle' => isset($handle) ? $handle : (strlen($params['name']) ? $params['name'] : (strlen(@$oldcomment['name']) ? $oldcomment['name'] : (strlen(@$oldanswer['name']) ? $oldanswer['name'] : qa_lang('main/anonymous')))), '^p_context' => $params['text'], '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, 'C', $params['postid']), '^a_url' => qa_path_absolute('admin/moderate')));
}
break;
case 'q_flag':
case 'a_flag':
case 'c_flag':
$flagcount = $params['flagcount'];
$oldpost = $params['oldpost'];
$notifycount = $flagcount - qa_opt('flagging_notify_first');
if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) {
qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), nl2br(qa_lang('emails/flagged_body')), array('^p_handle' => isset($oldpost['handle']) ? $oldpost['handle'] : (strlen($oldpost['name']) ? $oldpost['name'] : qa_lang('main/anonymous')), '^flags' => $flagcount == 1 ? qa_lang_html_sub('main/1_flag', '1', '1') : qa_lang_html_sub('main/x_flags', $flagcount), '^p_context' => trim(@$oldpost['title'] . "\n\n" . qa_viewer_text($oldpost['content'], $oldpost['format'])), '^url' => qa_q_path($params['questionid'], $params['question']['title'], true, $oldpost['basetype'], $oldpost['postid']), '^a_url' => qa_path_absolute('admin/flagged')));
}
break;
case 'u_register':
if (qa_opt('register_notify_admin')) {
qw_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/u_registered_subject'), qa_opt('moderate_users') ? nl2br(qa_lang('emails/u_to_approve_body')) : nl2br(qa_lang('emails/u_registered_body')), array('^u_handle' => $handle, '^url' => qa_path_absolute('user/' . $handle), '^a_url' => qa_path_absolute('admin/approve')));
}
break;
}
}
示例6: qa_comment_set_status
function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid, $question, $parent)
{
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
if (!isset($parent)) {
$parent = $question;
}
// for backwards compatibility with old answer parameter
$washidden = $oldcomment['type'] == 'C_HIDDEN';
$wasqueued = $oldcomment['type'] == 'C_QUEUED';
$wasrequeued = $wasqueued && isset($oldcomment['updated']);
qa_post_unindex($oldcomment['postid']);
$setupdated = false;
$event = null;
if ($status == QA_POST_STATUS_QUEUED) {
$newtype = 'C_QUEUED';
if (!$wasqueued) {
$event = 'c_requeue';
}
// same event whether it was hidden or shown before
} elseif ($status == QA_POST_STATUS_HIDDEN) {
$newtype = 'C_HIDDEN';
if (!$washidden) {
$event = $wasqueued ? 'c_reject' : 'c_hide';
if (!$wasqueued) {
$setupdated = true;
}
}
} elseif ($status == QA_POST_STATUS_NORMAL) {
$newtype = 'C';
if ($wasqueued) {
$event = 'c_approve';
} elseif ($washidden) {
$event = 'c_reshow';
$setupdated = true;
}
} else {
qa_fatal_error('Unknown status in qa_comment_set_status(): ' . $status);
}
qa_db_post_set_type($oldcomment['postid'], $newtype, $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_VISIBLE);
if ($wasqueued && $status == QA_POST_STATUS_NORMAL && qa_opt('moderate_update_time')) {
// ... for approval of a post, can set time to now instead
if ($wasrequeued) {
qa_db_post_set_updated($oldcomment['postid'], null);
} else {
qa_db_post_set_created($oldcomment['postid'], null);
}
}
qa_db_ccount_update();
qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
if ($wasqueued || $status == QA_POST_STATUS_QUEUED) {
qa_db_queuedcount_update();
}
if ($oldcomment['flagcount']) {
qa_db_flaggedcount_update();
}
if ($question['type'] == 'Q' && ($parent['type'] == 'Q' || $parent['type'] == 'A') && $status == QA_POST_STATUS_NORMAL) {
// only index if none of the things it depends on are hidden or queued
qa_post_index($oldcomment['postid'], 'C', $question['postid'], $oldcomment['parentid'], null, $oldcomment['content'], $oldcomment['format'], qa_viewer_text($oldcomment['content'], $oldcomment['format']), null, $oldcomment['categoryid']);
}
$eventparams = array('postid' => $oldcomment['postid'], 'parentid' => $oldcomment['parentid'], 'parenttype' => $parent['basetype'], 'parent' => $parent, 'questionid' => $question['postid'], 'question' => $question, 'content' => $oldcomment['content'], 'format' => $oldcomment['format'], 'text' => qa_viewer_text($oldcomment['content'], $oldcomment['format']), 'categoryid' => $oldcomment['categoryid'], 'name' => $oldcomment['name']);
if (isset($event)) {
qa_report_event($event, $userid, $handle, $cookieid, $eventparams + array('oldcomment' => $oldcomment));
}
if ($wasqueued && $status == QA_POST_STATUS_NORMAL && !$wasrequeued) {
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$commentsfollows = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $oldcomment['parentid']));
$thread = array();
foreach ($commentsfollows as $comment) {
if ($comment['type'] == 'C' && $comment['parentid'] == $parent['postid']) {
$thread[] = $comment;
}
}
qa_report_event('c_post', $oldcomment['userid'], $oldcomment['handle'], $oldcomment['cookieid'], $eventparams + array('thread' => $thread, 'notify' => isset($oldcomment['notify']), 'email' => qa_email_validate($oldcomment['notify']) ? $oldcomment['notify'] : null, 'delayed' => $oldcomment['created']));
}
}
示例7: qa_update_post_text
function qa_update_post_text(&$fields, $oldfields)
{
if (strcmp($oldfields['content'], $fields['content']) || strcmp($oldfields['format'], $fields['format']) || strcmp($oldfields['text'], $fields['text'])) {
$fields['text'] = qa_viewer_text($fields['content'], $fields['format']);
}
}
示例8: qa_comment_set_hidden
function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $parent)
{
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
if (!isset($parent)) {
$parent = $question;
}
// for backwards compatibility with old answer parameter
$wasqueued = $oldcomment['type'] == 'C_QUEUED';
qa_post_unindex($oldcomment['postid']);
$setupdated = $hidden || !$wasqueued;
// don't record approval of a post as an update action...
qa_db_post_set_type($oldcomment['postid'], $hidden ? 'C_HIDDEN' : 'C', $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, QA_UPDATE_VISIBLE);
if (!$setupdated) {
// ... for approval of a post, set created time to now instead
qa_db_post_set_created($oldcomment['postid'], null);
}
qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
qa_db_ccount_update();
if ($question['type'] == 'Q' && ($parent['type'] == 'Q' || $parent['type'] == 'A') && !$hidden) {
// only index if none of the things it depends on are hidden or queued
qa_post_index($oldcomment['postid'], 'C', $question['postid'], $oldcomment['parentid'], null, $oldcomment['content'], $oldcomment['format'], qa_viewer_text($oldcomment['content'], $oldcomment['format']), null, $oldcomment['categoryid']);
}
qa_report_event($wasqueued ? $hidden ? 'c_reject' : 'c_approve' : ($hidden ? 'c_hide' : 'c_reshow'), $userid, $handle, $cookieid, array('postid' => $oldcomment['postid'], 'parentid' => $oldcomment['parentid'], 'oldcomment' => $oldcomment, 'parenttype' => $parent['basetype'], 'questionid' => $question['postid']));
if ($wasqueued && !$hidden) {
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$commentsfollows = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $oldcomment['parentid']));
$thread = array();
foreach ($commentsfollows as $comment) {
if ($comment['type'] == 'C' && $comment['parentid'] == $parent['postid']) {
$thread[] = $comment;
}
}
qa_report_event('c_post', $oldcomment['userid'], $oldcomment['handle'], $oldcomment['cookieid'], array('postid' => $oldcomment['postid'], 'parentid' => $oldcomment['parentid'], 'parenttype' => $parent['basetype'], 'parent' => $parent, 'questionid' => $question['postid'], 'question' => $question, 'thread' => $thread, 'content' => $oldcomment['content'], 'format' => $oldcomment['format'], 'text' => qa_viewer_text($oldcomment['content'], $oldcomment['format']), 'categoryid' => $oldcomment['categoryid'], 'notify' => isset($oldcomment['notify']), 'email' => qa_email_validate($oldcomment['notify']) ? $oldcomment['notify'] : null, 'delayed' => $oldcomment['created']));
}
}
示例9: qa_recalc_perform_step
function qa_recalc_perform_step(&$state)
{
$continue = false;
@(list($operation, $length, $next, $done) = explode("\t", $state));
switch ($operation) {
case 'doreindexcontent':
qa_recalc_transition($state, 'doreindexcontent_pagereindex');
break;
case 'doreindexcontent_pagereindex':
$pages = qa_db_pages_get_for_reindexing($next, 10);
if (count($pages)) {
require_once QA_INCLUDE_DIR . 'app/format.php';
$lastpageid = max(array_keys($pages));
foreach ($pages as $pageid => $page) {
if (!($page['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
$searchmodules = qa_load_modules_with('search', 'unindex_page');
foreach ($searchmodules as $searchmodule) {
$searchmodule->unindex_page($pageid);
}
$searchmodules = qa_load_modules_with('search', 'index_page');
if (count($searchmodules)) {
$indextext = qa_viewer_text($page['content'], 'html');
foreach ($searchmodules as $searchmodule) {
$searchmodule->index_page($pageid, $page['tags'], $page['heading'], $page['content'], 'html', $indextext);
}
}
}
}
$next = 1 + $lastpageid;
$done += count($pages);
$continue = true;
} else {
qa_recalc_transition($state, 'doreindexcontent_postcount');
}
break;
case 'doreindexcontent_postcount':
qa_db_qcount_update();
qa_db_acount_update();
qa_db_ccount_update();
qa_recalc_transition($state, 'doreindexcontent_postreindex');
break;
case 'doreindexcontent_postreindex':
$posts = qa_db_posts_get_for_reindexing($next, 10);
if (count($posts)) {
require_once QA_INCLUDE_DIR . 'app/format.php';
$lastpostid = max(array_keys($posts));
qa_db_prepare_for_reindexing($next, $lastpostid);
qa_suspend_update_counts();
foreach ($posts as $postid => $post) {
qa_post_unindex($postid);
qa_post_index($postid, $post['type'], $post['questionid'], $post['parentid'], $post['title'], $post['content'], $post['format'], qa_viewer_text($post['content'], $post['format']), $post['tags'], $post['categoryid']);
}
$next = 1 + $lastpostid;
$done += count($posts);
$continue = true;
} else {
qa_db_truncate_indexes($next);
qa_recalc_transition($state, 'doreindexposts_wordcount');
}
break;
case 'doreindexposts_wordcount':
$wordids = qa_db_words_prepare_for_recounting($next, 1000);
if (count($wordids)) {
$lastwordid = max($wordids);
qa_db_words_recount($next, $lastwordid);
$next = 1 + $lastwordid;
$done += count($wordids);
$continue = true;
} else {
qa_db_tagcount_update();
// this is quick so just do it here
qa_recalc_transition($state, 'doreindexposts_complete');
}
break;
case 'dorecountposts':
qa_recalc_transition($state, 'dorecountposts_postcount');
break;
case 'dorecountposts_postcount':
qa_db_qcount_update();
qa_db_acount_update();
qa_db_ccount_update();
qa_db_unaqcount_update();
qa_db_unselqcount_update();
qa_recalc_transition($state, 'dorecountposts_votecount');
break;
case 'dorecountposts_votecount':
$postids = qa_db_posts_get_for_recounting($next, 1000);
if (count($postids)) {
$lastpostid = max($postids);
qa_db_posts_votes_recount($next, $lastpostid);
$next = 1 + $lastpostid;
$done += count($postids);
$continue = true;
} else {
qa_recalc_transition($state, 'dorecountposts_acount');
}
break;
case 'dorecountposts_acount':
$postids = qa_db_posts_get_for_recounting($next, 1000);
if (count($postids)) {
//.........这里部分代码省略.........
示例10: qa_flag_set_tohide
function qa_flag_set_tohide($post, $userid, $handle, $cookieid, $question)
{
require_once QA_INCLUDE_DIR . 'qa-db-votes.php';
require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
qa_db_userflag_set($post['postid'], $userid, true);
qa_db_post_recount_flags($post['postid']);
switch ($post['basetype']) {
case 'Q':
$action = 'q_flag';
break;
case 'A':
$action = 'a_flag';
break;
case 'C':
$action = 'c_flag';
break;
}
qa_report_write_action($userid, null, $action, $post['basetype'] == 'Q' ? $post['postid'] : null, $post['basetype'] == 'A' ? $post['postid'] : null, $post['basetype'] == 'C' ? $post['postid'] : null);
qa_report_event($action, $userid, $handle, $cookieid, array('postid' => $post['postid']));
$post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $post['postid']));
$flagcount = $post['flagcount'];
$notifycount = $flagcount - qa_opt('flagging_notify_first');
if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) {
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
$anchor = $post['basetype'] == 'Q' ? null : qa_anchor($post['basetype'], $post['postid']);
qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), qa_lang('emails/flagged_body'), array('^p_handle' => isset($post['handle']) ? $post['handle'] : qa_lang('main/anonymous'), '^flags' => $flagcount == 1 ? qa_lang_html_sub('main/1_flag', '1', '1') : qa_lang_html_sub('main/x_flags', $flagcount), '^p_context' => trim(@$post['title'] . "\n\n" . qa_viewer_text($post['content'], $post['format'])), '^url' => qa_path(qa_q_request($question['postid'], $question['title']), null, qa_opt('site_url'), null, $anchor)));
}
if ($flagcount >= qa_opt('flagging_hide_after') && !$post['hidden']) {
return true;
}
return false;
}
示例11: q_list
function q_list($q_list)
{
if (qa_opt('it_layout_lists') == 'qlist') {
qa_html_theme_base::q_list($q_list);
return;
}
if (count(@$q_list['qs'])) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (count($postids)) {
// Retrieve favourite count
$userid = qa_get_logged_in_userid();
$result = qa_db_query_sub('SELECT userid,entityid FROM ^userfavorites WHERE entitytype=$ AND entityid IN (#)', 'Q', $postids);
while ($row = mysqli_fetch_row($result)) {
if ($row[0] == $userid) {
// loged in user favorited this post
$faved_post[$row[1]] = 1;
}
if (isset($favs[$row[1]])) {
$favs[$row[1]] = $favs[$row[1]] + 1;
} else {
$favs[$row[1]] = 1;
}
}
// Retrieve comment count
$result = qa_db_query_sub('SELECT postid,parentid FROM ^posts WHERE type=$ AND parentid IN (#)', 'C', $postids);
$comment_list = qa_db_read_all_assoc($result, 'postid');
foreach ($comment_list as $key => $value) {
if (isset($comments[$value['parentid']])) {
$comments[$value['parentid']] = $comments[$value['parentid']] + 1;
} else {
$comments[$value['parentid']] = 1;
}
}
if (qa_opt('it_excerpt_field_enable') or qa_opt('it_enable_except')) {
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
if (qa_opt('it_excerpt_field_enable')) {
$maxlength = qa_opt('it_excerpt_field_length');
// Retrieve Excerpt Text for all questions
$result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_excerpt_text');
$excerpt_text = qa_db_read_all_assoc($result, 'postid');
// set excerpt from field info
foreach ($q_list['qs'] as $index => $question) {
// from field
if (!empty($excerpt_text[$question['raw']['postid']]['content'])) {
$text = qa_viewer_text($excerpt_text[$question['raw']['postid']]['content'], '', array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['excerpt'] = qa_html($text);
// from post content
} elseif (qa_opt('it_enable_except')) {
// Retrieve the content for these questions from the database and put into an array
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['excerpt'] = qa_html($text);
}
}
}
} else {
// qa_opt('it_enable_except') ==> excerpt from question content instead of excerpt field
$maxlength = qa_opt('it_except_len');
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
foreach ($q_list['qs'] as $index => $question) {
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['excerpt'] = qa_html($text);
}
}
}
}
// Retrieve featured images for all list questions
if (qa_opt('it_feature_img_enable')) {
$result = qa_db_query_sub('SELECT postid,content FROM ^postmetas WHERE postid IN (#) AND title=$', $postids, 'et_featured_image');
$featured_images = qa_db_read_all_assoc($result, 'postid');
}
// Now meta information for each question
foreach ($q_list['qs'] as $index => $question) {
if (qa_opt('it_feature_img_enable')) {
$featured_image = @$featured_images[$question['raw']['postid']]['content'];
if (isset($featured_image)) {
$q_list['qs'][$index]['featured'] = qa_opt('it_featured_url_abs') . 'featured/' . $featured_image;
}
}
if (isset($comments[$question['raw']['postid']])) {
$q_list['qs'][$index]['comments'] = $comments[$question['raw']['postid']];
} else {
$q_list['qs'][$index]['comments'] = 0;
//.........这里部分代码省略.........
示例12: qa_comment_set_hidden
function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $answer)
{
qa_post_unindex($oldcomment['postid']);
qa_db_post_set_type($oldcomment['postid'], $hidden ? 'C_HIDDEN' : 'C', $userid, qa_remote_ip_address());
qa_db_points_update_ifuser($oldcomment['userid'], array('cposts'));
qa_db_ccount_update();
if (!($hidden || $question['hidden'] || @$answer['hidden'])) {
// only index if none of the things it depends on are hidden
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
qa_post_index($oldcomment['postid'], 'C', $question['postid'], null, qa_viewer_text($oldcomment['content'], $oldcomment['format']), null);
}
qa_report_event($hidden ? 'c_hide' : 'c_reshow', $userid, $handle, $cookieid, array('postid' => $oldcomment['postid'], 'parentid' => $oldcomment['parentid'], 'parenttype' => isset($answer) ? $answer['basetype'] : $question['basetype'], 'questionid' => $question['postid']));
}
示例13: q_list
function q_list($q_list)
{
if (isset($q_list['qs'])) {
if (qa_opt('cs_enable_except')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (count($postids)) {
// Retrieve the content for these questions from the database and put into an array
//$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
//$postinfo = qa_db_read_all_assoc($result, 'postid');
//cache and apply keys to array now that I can't use array key argument in qa_db_read_all_assoc
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids));
$postinfo = array();
foreach ($posts as $qitem) {
$postinfo[$qitem['postid']] = $qitem;
}
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
$maxlength = qa_opt('cs_except_len');
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['content'] = '<SPAN>' . qa_html($text) . '</SPAN>';
}
}
}
}
$this->output('<div class="qa-q-list' . ($this->list_vote_disabled($q_list['qs']) ? ' qa-q-list-vote-disabled' : '') . ((bool) qa_opt('cs_enable_clean_qlist') ? ' clean' : '') . '">', '');
$this->q_list_items($q_list['qs']);
$this->output('</div> <!-- END qa-q-list -->', '');
} else {
$this->output('
<div class="no-items">
<h3 class="icon-sad">' . qa_lang_html('cleanstrap/no_users') . '</h3>
<p>' . qa_lang_html('cleanstrap/no_results_detail') . '.</p>
</div>');
}
}
示例14: qa_comment_create
function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $answer, $commentsfollows)
{
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$parent = isset($answer) ? $answer : $question;
$postid = qa_db_post_create('C', $parent['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), null, $content, $format, null, qa_combine_notify_email($userid, $notify, $email), $question['categoryid']);
qa_db_posts_calc_category_path($postid);
if (!($question['hidden'] || @$answer['hidden'])) {
// don't index comment if parent or parent of parent is hidden
qa_post_index($postid, 'C', $question['postid'], null, $text, null);
}
qa_db_points_update_ifuser($userid, 'cposts');
qa_db_ccount_update();
// $senttoemail and $senttouserid ensure each user or email gets only one notification about an added comment,
// even if they have several previous comments in the same thread and asked for notifications for the parent.
// Still, if a person posted some comments as a registered user and some others anonymously,
// they could get two emails about a subsequent comment. Shouldn't be much of a problem in practice.
$senttoemail = array();
$senttouserid = array();
switch ($parent['basetype']) {
case 'Q':
$subject = qa_lang('emails/q_commented_subject');
$body = qa_lang('emails/q_commented_body');
$context = $parent['title'];
break;
case 'A':
$subject = qa_lang('emails/a_commented_subject');
$body = qa_lang('emails/a_commented_body');
$context = qa_viewer_text($parent['content'], $parent['format']);
break;
}
$blockwordspreg = qa_get_block_words_preg();
$sendhandle = isset($handle) ? $handle : qa_lang('main/anonymous');
$sendcontext = qa_block_words_replace($context, $blockwordspreg);
$sendtext = qa_block_words_replace($text, $blockwordspreg);
$sendtitle = qa_block_words_replace($question['title'], $blockwordspreg);
$sendurl = qa_path(qa_q_request($question['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor($parent['basetype'], $parent['postid']));
if (isset($parent['notify']) && !qa_post_is_by_user($parent, $userid, $cookieid)) {
$senduserid = $parent['userid'];
$sendemail = @$parent['notify'];
if (qa_email_validate($sendemail)) {
$senttoemail[$sendemail] = true;
} elseif (isset($senduserid)) {
$senttouserid[$senduserid] = true;
}
qa_send_notification($senduserid, $sendemail, @$parent['handle'], $subject, $body, array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl));
}
foreach ($commentsfollows as $comment) {
if ($comment['basetype'] == 'C' && $comment['parentid'] == $parent['postid'] && !$comment['hidden']) {
// find just those for this parent
if (isset($comment['notify']) && !qa_post_is_by_user($comment, $userid, $cookieid)) {
$senduserid = $comment['userid'];
$sendemail = @$comment['notify'];
if (qa_email_validate($sendemail)) {
if (@$senttoemail[$sendemail]) {
continue;
}
$senttoemail[$sendemail] = true;
} elseif (isset($senduserid)) {
if (@$senttouserid[$senduserid]) {
continue;
}
$senttouserid[$senduserid] = true;
}
qa_send_notification($senduserid, $sendemail, @$comment['handle'], qa_lang('emails/c_commented_subject'), qa_lang('emails/c_commented_body'), array('^c_handle' => $sendhandle, '^c_context' => $sendcontext, '^c_content' => $sendtext, '^url' => $sendurl));
}
}
}
qa_report_event('c_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => $parent['postid'], 'parenttype' => $parent['basetype'], 'questionid' => $question['postid'], 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $question['categoryid'], 'notify' => $notify, 'email' => $email));
return $postid;
}
示例15: qa_recalc_perform_step
function qa_recalc_perform_step(&$state)
{
$continue = false;
@(list($operation, $length, $next, $done) = explode(',', $state));
switch ($operation) {
case 'doreindexcontent':
qa_recalc_transition($state, 'doreindexcontent_pagereindex');
break;
case 'doreindexcontent_pagereindex':
$pages = qa_db_pages_get_for_reindexing($next, 10);
if (count($pages)) {
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
$lastpageid = max(array_keys($pages));
foreach ($pages as $pageid => $page) {
if (!($page['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
$searchmodules = qa_load_modules_with('search', 'unindex_page');
foreach ($searchmodules as $searchmodule) {
$searchmodule->unindex_page($pageid);
}
$searchmodules = qa_load_modules_with('search', 'index_page');
if (count($searchmodules)) {
$indextext = qa_viewer_text($page['content'], 'html');
foreach ($searchmodules as $searchmodule) {
$searchmodule->index_page($pageid, $page['tags'], $page['heading'], $page['content'], 'html', $indextext);
}
}
}
}
$next = 1 + $lastpageid;
$done += count($pages);
$continue = true;
} else {
qa_recalc_transition($state, 'doreindexcontent_postcount');
}
break;
case 'doreindexcontent_postcount':
qa_db_qcount_update();
qa_db_acount_update();
qa_db_ccount_update();
qa_recalc_transition($state, 'doreindexcontent_postreindex');
break;
case 'doreindexcontent_postreindex':
$posts = qa_db_posts_get_for_reindexing($next, 10);
if (count($posts)) {
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
$lastpostid = max(array_keys($posts));
qa_db_prepare_for_reindexing($next, $lastpostid);
qa_suspend_update_counts();
foreach ($posts as $postid => $post) {
qa_post_unindex($postid);
qa_post_index($postid, $post['type'], $post['questionid'], $post['parentid'], $post['title'], $post['content'], $post['format'], qa_viewer_text($post['content'], $post['format']), $post['tags'], $post['categoryid']);
}
$next = 1 + $lastpostid;
$done += count($posts);
$continue = true;
} else {
qa_db_truncate_indexes($next);
qa_recalc_transition($state, 'doreindexposts_wordcount');
}
break;
case 'doreindexposts_wordcount':
$wordids = qa_db_words_prepare_for_recounting($next, 1000);
if (count($wordids)) {
$lastwordid = max($wordids);
qa_db_words_recount($next, $lastwordid);
$next = 1 + $lastwordid;
$done += count($wordids);
$continue = true;
} else {
qa_db_tagcount_update();
// this is quick so just do it here
qa_recalc_transition($state, 'doreindexposts_complete');
}
break;
case 'dorecountposts':
qa_recalc_transition($state, 'dorecountposts_postcount');
break;
case 'dorecountposts_postcount':
qa_db_qcount_update();
qa_db_acount_update();
qa_db_ccount_update();
qa_db_unaqcount_update();
qa_db_unselqcount_update();
qa_recalc_transition($state, 'dorecountposts_votecount');
break;
case 'dorecountposts_votecount':
$postids = qa_db_posts_get_for_recounting($next, 1000);
if (count($postids)) {
$lastpostid = max($postids);
qa_db_posts_votes_recount($next, $lastpostid);
$next = 1 + $lastpostid;
$done += count($postids);
$continue = true;
} else {
qa_recalc_transition($state, 'dorecountposts_acount');
}
break;
case 'dorecountposts_acount':
$postids = qa_db_posts_get_for_recounting($next, 1000);
if (count($postids)) {
//.........这里部分代码省略.........