本文整理汇总了PHP中qa_get_block_words_preg函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_get_block_words_preg函数的具体用法?PHP qa_get_block_words_preg怎么用?PHP qa_get_block_words_preg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_get_block_words_preg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_question_set_selchildid
function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers)
{
$oldselchildid = $oldquestion['selchildid'];
qa_db_post_set_selchildid($oldquestion['postid'], isset($selchildid) ? $selchildid : null);
qa_db_points_update_ifuser($oldquestion['userid'], 'aselects');
if (isset($oldselchildid)) {
if (isset($answers[$oldselchildid])) {
qa_db_points_update_ifuser($answers[$oldselchildid]['userid'], 'aselecteds');
qa_report_event('a_unselect', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $oldselchildid));
}
}
if (isset($selchildid)) {
$answer = $answers[$selchildid];
qa_db_points_update_ifuser($answer['userid'], 'aselecteds');
if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) {
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
$blockwordspreg = qa_get_block_words_preg();
$sendtitle = qa_block_words_replace($oldquestion['title'], $blockwordspreg);
$sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg));
qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendcontent, '^url' => qa_path(qa_q_request($oldquestion['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $selchildid))));
}
qa_report_event('a_select', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $selchildid));
}
}
示例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: output_widget
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'db/selects.php';
$populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags')));
$maxcount = reset($populartags);
// $themeobject->output(sprintf('<h2 style="margin-top: 0; padding-top: 0;">%s</h2>', qa_lang_html('main/popular_tags')));
// $themeobject->output('<div style="font-size: 10px;">');
$themeobject->output(sprintf('<div class="panel panel-primary" style="padding: 0;"><div class="panel-heading"><h3 class="panel-title">%s</h3></div>', qa_lang_html('main/popular_tags')));
$themeobject->output('<div class="panel-body">');
$maxsize = qa_opt('tag_cloud_font_size');
$minsize = qa_opt('tag_cloud_minimal_font_size');
$scale = qa_opt('tag_cloud_size_popular');
$blockwordspreg = qa_get_block_words_preg();
foreach ($populartags as $tag => $count) {
$matches = qa_block_words_match_all($tag, $blockwordspreg);
if (empty($matches)) {
if ($scale) {
$size = number_format($maxsize * $count / $maxcount, 1);
if ($size < $minsize) {
$size = $minsize;
}
} else {
$size = $maxsize;
}
$themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag)));
}
}
// $themeobject->output('</div>');
$themeobject->output('</div></div>');
}
示例4: 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
}
示例5: 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
}
示例6: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
$widget_opt = @$themeobject->current_widget['param']['options'];
if (@$themeobject->current_widget['param']['locations']['show_title']) {
$themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/tags') . '<a href="' . qa_path_html('tags') . '">' . qa_lang('cleanstrap/view_all') . '</a></h3>');
}
$to_show = (int) $widget_opt['cs_tags_count'];
$populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, !empty($to_show) ? $to_show : 20));
reset($populartags);
$themeobject->output('<div class="ra-tags-widget clearfix">');
$blockwordspreg = qa_get_block_words_preg();
foreach ($populartags as $tag => $count) {
if (count(qa_block_words_match_all($tag, $blockwordspreg))) {
continue;
}
// skip censored tags
$themeobject->output('<a href="' . qa_path_html('tag/' . $tag) . '" class="widget-tag">' . qa_html($tag) . '<span>' . $count . '</span></a>');
}
$themeobject->output('</div>');
}
示例7: qa_q_request
function qa_q_request($questionid, $title)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
$title = qa_block_words_replace($title, qa_get_block_words_preg());
$words = qa_string_to_words($title, true, false, false);
$wordlength = array();
foreach ($words as $index => $word) {
$wordlength[$index] = qa_strlen($word);
}
$remaining = qa_opt('q_urls_title_length');
if (array_sum($wordlength) > $remaining) {
arsort($wordlength, SORT_NUMERIC);
// sort with longest words first
foreach ($wordlength as $index => $length) {
if ($remaining > 0) {
$remaining -= $length;
} else {
unset($words[$index]);
}
}
}
$title = implode('-', $words);
if (qa_opt('q_urls_remove_accents')) {
$title = qa_string_remove_accents($title);
}
return (int) $questionid . '/' . $title;
}
示例8: qa_page_q_question_view
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested)
{
$questionid = $question['postid'];
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
$htmloptions = qa_post_html_defaults('Q', true);
$htmloptions['answersview'] = false;
// answer count is displayed separately so don't show it here
$htmloptions['avatarsize'] = qa_opt('avatar_q_page_q_size');
$q_view = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $htmloptions);
$q_view['main_form_tags'] = 'METHOD="POST" ACTION="' . qa_self_html() . '"';
// Buttons for operating on the question
if (!$formrequested) {
// don't show if another form is currently being shown on page
$clicksuffix = ' onClick="qa_show_waiting_after(this, false);"';
// add to operations that write to database
$buttons = array();
if ($question['editbutton']) {
$buttons['edit'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_q_popup'));
}
$hascategories = qa_using_categories();
if ($question['retagcatbutton']) {
$buttons['retagcat'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html($hascategories ? 'question/recat_button' : 'question/retag_button'), 'popup' => qa_lang_html($hascategories ? qa_using_tags() ? 'question/retag_cat_popup' : 'question/recat_popup' : 'question/retag_popup'));
}
if ($question['flagbutton']) {
$buttons['flag'] = array('tags' => 'NAME="q_doflag"' . $clicksuffix, 'label' => qa_lang_html($question['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_q_popup'));
}
if ($question['unflaggable']) {
$buttons['unflag'] = array('tags' => 'NAME="q_dounflag"' . $clicksuffix, 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup'));
}
if ($question['clearflaggable']) {
$buttons['clearflags'] = array('tags' => 'NAME="q_doclearflags"' . $clicksuffix, 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup'));
}
if ($question['closeable']) {
$buttons['close'] = array('tags' => 'NAME="q_doclose"', 'label' => qa_lang_html('question/close_button'), 'popup' => qa_lang_html('question/close_q_popup'));
}
if ($question['reopenable']) {
$buttons['reopen'] = array('tags' => 'NAME="q_doreopen"' . $clicksuffix, 'label' => qa_lang_html('question/reopen_button'));
}
if ($question['moderatable']) {
$buttons['approve'] = array('tags' => 'NAME="q_doapprove"' . $clicksuffix, 'label' => qa_lang_html('question/approve_button'));
$buttons['reject'] = array('tags' => 'NAME="q_doreject"' . $clicksuffix, 'label' => qa_lang_html('question/reject_button'));
}
if ($question['hideable']) {
$buttons['hide'] = array('tags' => 'NAME="q_dohide"' . $clicksuffix, 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_q_popup'));
}
if ($question['reshowable']) {
$buttons['reshow'] = array('tags' => 'NAME="q_doreshow"' . $clicksuffix, 'label' => qa_lang_html('question/reshow_button'));
}
if ($question['deleteable']) {
$buttons['delete'] = array('tags' => 'NAME="q_dodelete"' . $clicksuffix, 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_q_popup'));
}
if ($question['claimable']) {
$buttons['claim'] = array('tags' => 'NAME="q_doclaim"' . $clicksuffix, 'label' => qa_lang_html('question/claim_button'));
}
if ($question['answerbutton']) {
// don't show if shown by default
$buttons['answer'] = array('tags' => 'NAME="q_doanswer" ID="q_doanswer" onClick="return qa_toggle_element(\'anew\')"', 'label' => qa_lang_html('question/answer_button'), 'popup' => qa_lang_html('question/answer_q_popup'));
}
if ($question['commentbutton']) {
$buttons['comment'] = array('tags' => 'NAME="q_docomment" onClick="return qa_toggle_element(\'c' . $questionid . '\')"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_q_popup'));
}
$q_view['form'] = array('style' => 'light', 'buttons' => $buttons, 'hidden' => array('qa_click' => ''));
}
// Information about the question of the answer that this question follows on from (or a question directly)
if (isset($parentquestion)) {
$q_view['follows'] = array('label' => qa_lang_html($question['parentid'] == $parentquestion['postid'] ? 'question/follows_q' : 'question/follows_a'), 'title' => qa_html(qa_block_words_replace($parentquestion['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($parentquestion['postid'], $parentquestion['title'], false, $question['parentid'] == $parentquestion['postid'] ? 'Q' : 'A', $question['parentid']));
}
// Information about the question that this question is a duplicate of (if appropriate)
if (isset($closepost)) {
if ($closepost['basetype'] == 'Q') {
$q_view['closed'] = array('label' => qa_lang_html('question/closed_as_duplicate'), 'content' => qa_html(qa_block_words_replace($closepost['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($closepost['postid'], $closepost['title']));
} elseif ($closepost['type'] == 'NOTE') {
$viewer = qa_load_viewer($closepost['content'], $closepost['format']);
$q_view['closed'] = array('label' => qa_lang_html('question/closed_with_note'), 'content' => $viewer->get_html($closepost['content'], $closepost['format'], array('blockwordspreg' => qa_get_block_words_preg())));
}
}
// Extra value display
if (strlen(@$question['extra']) && qa_opt('extra_field_active') && qa_opt('extra_field_display')) {
$q_view['extra'] = array('label' => qa_html(qa_opt('extra_field_label')), 'content' => qa_html(qa_block_words_replace($question['extra'], qa_get_block_words_preg())));
}
return $q_view;
}
示例9: qa_html
$field['error'] = qa_html(@$errors['content']);
$custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : '';
$qa_content['form'] = array('tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('ask' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('ask'), 'doask' => '1'));
if (!strlen($custom)) {
unset($qa_content['form']['fields']['custom']);
}
if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) {
$qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
$qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"';
if (strlen(@$in['title'])) {
$qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');';
}
}
if (isset($followanswer)) {
$viewer = qa_load_viewer($followanswer['content'], $followanswer['format']);
$field = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg())));
qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field));
}
if (qa_using_categories() && count($categories)) {
$field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid']));
qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category'));
if (!qa_opt('allow_no_category')) {
// don't auto-select a category even though one is required
$field['options'][''] = '';
}
qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field));
}
if (qa_opt('extra_field_active')) {
$field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra']));
qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field));
}
示例10: qa_message_html_defaults
function qa_message_html_defaults()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
return array('whenview' => qa_opt('show_when_created'), 'whoview' => true, 'avatarsize' => qa_opt('avatar_message_list_size'), 'blockwordspreg' => qa_get_block_words_preg(), 'showurllinks' => qa_opt('show_url_links'), 'linksnewwindow' => qa_opt('links_in_new_window'), 'fulldatedays' => qa_opt('show_full_date_days'));
}
示例11: 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>');
}
}
示例12: 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;
}
示例13: ra_post_list
function ra_post_list($type, $limit)
{
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$post = qa_db_query_sub('SELECT * FROM ^posts WHERE ^posts.type=$ ORDER BY ^posts.created DESC LIMIT #', $type, $limit);
$output = '<ul class="question-list">';
while ($p = mysql_fetch_array($post)) {
$p['title'] = qa_block_words_replace($p['title'], qa_get_block_words_preg(), '*');
$p['content'] = qa_block_words_replace($p['content'], qa_get_block_words_preg(), '*');
if ($type == 'Q') {
$what = _ra_lang('asked');
} elseif ($type == 'A') {
$what = _ra_lang('answered');
} elseif ('C') {
$what = _ra_lang('commented');
}
$handle = qa_post_userid_to_handle($p['userid']);
$output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
$output .= '<div class="pull-left avatar" data-handle="' . $handle . '" data-id="' . qa_handle_to_userid($handle) . '">' . ra_get_avatar($handle, 40) . '</div>';
$output .= '<div class="list-right">';
$output .= '<h5><a href="' . qa_path_html('user/' . $handle) . '">' . ra_name($handle) . '</a> ' . $what . '</h5>';
if ($type == 'Q') {
$output .= '<p><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></p>';
} elseif ($type == 'A') {
$output .= '<p><a href="' . ra_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . substr(strip_tags($p['content']), 0, 50) . '</a></p>';
} else {
$output .= '<p><a href="' . ra_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . substr(strip_tags($p['content']), 0, 50) . '</a></p>';
}
if ($type == 'Q') {
$output .= '<div class="counts"><div class="vote-count icon-chevron-up"><span>' . $p['netvotes'] . '</span></div>';
$output .= '<div class="ans-count icon-chat-4"><span>' . $p['acount'] . '</span></div></div>';
} elseif ($type == 'A') {
$output .= '<div class="counts"><div class="vote-count icon-chevron-up"><span>' . $p['netvotes'] . '</span></div>';
}
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
echo $output;
}
示例14: qw_notify_users_by_email
function qw_notify_users_by_email($event, $postid, $userid, $effecteduserid, $params)
{
if (!!$effecteduserid) {
//get the working user data
$logged_in_handle = qa_get_logged_in_handle();
$logged_in_user_name = qw_get_name_from_userid($userid);
$logged_in_user_name = !!$logged_in_user_name ? $logged_in_user_name : $logged_in_handle;
$name = qw_get_name_from_userid($effecteduserid);
switch ($event) {
case 'a_post':
case 'related':
$parent = isset($params['parent']) ? $params['parent'] : "";
if (!!$parent) {
$name = !!$name ? $name : $parent['handle'];
$email = $parent['email'];
$handle = $parent['handle'];
} else {
//seems proper values are not available
return;
}
break;
case 'c_post':
case 'q_reshow':
case 'a_reshow':
case 'c_reshow':
case 'a_select':
case 'q_vote_up':
case 'q_vote_down':
case 'a_vote_up':
case 'a_vote_down':
case 'q_favorite':
case 'u_favorite':
case 'u_message':
case 'u_wall_post':
case 'u_level':
case 'q_post_user_fl':
case 'q_post_tag_fl':
case 'q_post_cat_fl':
//this is because we wont have the $parent['email'] for each effected userids when a these selected events occurs
$user_details = qw_get_user_details_from_userid($effecteduserid);
$handle = $user_details['handle'];
$name = !!$name ? $name : $user_details['handle'];
$email = $user_details['email'];
break;
case 'q_approve':
case 'q_reject':
$oldquestion = $params['oldquestion'];
$handle = $oldquestion['handle'];
$name = !!$name ? $name : $oldquestion['handle'];
$email = $oldquestion['email'];
break;
case 'a_approve':
case 'a_reject':
$oldanswer = $params['oldanswer'];
$handle = $oldquestion['handle'];
$name = !!$name ? $name : $oldanswer['handle'];
$email = $oldanswer['email'];
break;
case 'c_approve':
case 'c_reject':
$oldcomment = $params['oldcomment'];
$handle = $oldcomment['handle'];
$name = !!$name ? $name : $oldcomment['handle'];
$email = $oldcomment['email'];
break;
default:
break;
}
include_once QA_INCLUDE_DIR . 'qa-util-string.php';
$notifying_user['userid'] = $effecteduserid;
$notifying_user['name'] = $name;
$notifying_user['email'] = $email;
$notifying_user['handle'] = isset($handle) ? $handle : qa_lang('main/anonymous');
//consider only first 50 characters for saving notification
if ($event === 'u_message') {
$content = isset($params['message']) && !empty($params['message']) ? $params['message'] : "";
$title = "";
$canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES);
$url = qa_path_absolute($canreply ? 'message/' . $logged_in_handle : 'user/' . $logged_in_handle);
} else {
if ($event === 'u_wall_post') {
$content = isset($params['text']) && !empty($params['text']) ? $params['text'] : "";
if (!!$content) {
$blockwordspreg = qa_get_block_words_preg();
$content = qa_block_words_replace($content, $blockwordspreg);
}
$title = "";
$url = qa_path_absolute('user/' . $params['handle'] . '/wall', null, null);
} else {
if ($event === 'u_level') {
$title = "";
$url = qa_path_absolute('user/' . $params['handle']);
$old_level = $params['oldlevel'];
$new_level = $params['level'];
if ($new_level < $old_level) {
return;
}
$approved_only = "";
if ($new_level == QA_USER_LEVEL_APPROVED && $old_level < QA_USER_LEVEL_APPROVED) {
$approved_only = true;
//.........这里部分代码省略.........
示例15: elseif
} elseif (isset($result['url'])) {
$questions[] = $setarray;
}
}
break;
}
// Remove duplicate questions (perhaps referenced in an answer and a comment) and cut down to size
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
if ($feedtype != 'search' && $feedtype != 'hot') {
// leave search results and hot questions sorted by relevance
$questions = qa_any_sort_and_dedupe($questions);
}
$questions = array_slice($questions, 0, $count);
$blockwordspreg = qa_get_block_words_preg();
// Prepare the XML output
$lines = array();
$lines[] = '<?xml version="1.0" encoding="utf-8"?>';
$lines[] = '<rss version="2.0">';
$lines[] = '<channel>';
$lines[] = '<title>' . qa_xml($sitetitle . ' - ' . $title) . '</title>';
$lines[] = '<link>' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . '</link>';
$lines[] = '<description>Powered by Question2Answer</description>';
foreach ($questions as $question) {
// Determine whether this is a question, answer or comment, and act accordingly
$options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks);
$time = null;
$htmlcontent = null;
if (isset($question['opostid'])) {
$time = $question['otime'];