本文整理汇总了PHP中qa_q_request函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_q_request函数的具体用法?PHP qa_q_request怎么用?PHP qa_q_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_q_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
global $qa_login_userid, $questionid, $relatedcount, $question, $relatedquestions, $qa_cookieid, $usershtml;
list($question, $relatedquestions) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid));
if ($relatedcount > 1 && !$question['hidden']) {
$minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
foreach ($relatedquestions as $key => $related) {
if ($related['postid'] == $questionid || $related['score'] < $minscore) {
unset($relatedquestions[$key]);
}
}
if (count($relatedquestions)) {
$themeobject->output('<h2>' . qa_lang('main/related_qs_title') . '</h2>');
} else {
$themeobject->output('<h2>' . qa_lang('main/no_related_qs_title') . '</h2>');
}
$upper = qa_opt('related_qs_num') < count($relatedquestions) ? qa_opt('related_qs_num') : count($relatedquestions);
foreach ($relatedquestions as $related) {
if ($upper <= 0) {
break;
}
$themeobject->output('<p style="margin:0 0 10px 0; font-weight:bold;"><a href="' . qa_path_html(qa_q_request($related['postid'], $related['title'])) . '">' . $related['title'] . '</a></p>');
$upper--;
}
}
}
示例2: q2apro_save_most_viewed_questions
function q2apro_save_most_viewed_questions()
{
// save checktime of cache
qa_opt('q2apro_popularqu_checktime', time());
$maxquestions = qa_opt('q2apro_popularqu_maxqu');
$lastdays = qa_opt('q2apro_popularqu_lastdays');
$ourTopQuestions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, acount FROM `^posts`
WHERE `created` > NOW() - INTERVAL # DAY
AND `type` = "Q"
AND `closedbyid` IS NULL
ORDER BY views DESC
LIMIT #;', $lastdays, $maxquestions));
$saveoutput = '';
foreach ($ourTopQuestions as $qu) {
$activity_url = qa_path_html(qa_q_request($qu['postid'], $qu['title']), null, qa_opt('site_url'), null, null);
$questionlink = '<a href="' . $activity_url . '">' . htmlspecialchars($qu['title']) . '</a>';
$answercnt = '';
if (qa_opt('q2apro_popularqu_answercount')) {
$acnttitle = $qu['acount'] == 1 ? qa_lang('q2apro_popularqu_lang/answer_one') : $qu['acount'] . ' ' . qa_lang('q2apro_popularqu_lang/answers');
$answercnt = ' <span title="' . $acnttitle . '">(' . $qu['acount'] . ')</span>';
}
$saveoutput .= '<li>
' . $questionlink . $answercnt . '
</li>
';
}
// save into cache
qa_opt('q2apro_popularqu_cached', $saveoutput);
}
示例3: qa_priv_notification
function qa_priv_notification($uid, $oid, $badge_slug)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
if (QA_FINAL_EXTERNAL_USERS) {
$publictohandle = qa_get_public_from_userids(array($uid));
$handle = @$publictohandle[$uid];
} else {
$user = qa_db_single_select(qa_db_user_account_selectspec($uid, true));
$handle = @$user['handle'];
}
$subject = qa_opt('badge_email_subject');
$body = qa_opt('badge_email_body');
$body = preg_replace('/\\^if_post_text="([^"]*)"/', $oid ? '$1' : '', $body);
// if post text
$site_url = qa_opt('site_url');
$profile_url = qa_path_html('user/' . $handle, null, $site_url);
if ($oid) {
$post = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $oid), true);
if ($post['parentid']) {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $post['parentid']), true);
}
if (isset($parent)) {
$anchor = urlencode(qa_anchor($post['basetype'], $oid));
$post_title = $parent['title'];
$post_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
} else {
$post_title = $post['title'];
$post_url = qa_path_html(qa_q_request($post['postid'], $post['title']), null, qa_opt('site_url'));
}
}
$subs = array('^badge_name' => qa_opt('badge_' . $badge_slug . '_name'), '^post_title' => @$post_title, '^post_url' => @$post_url, '^profile_url' => $profile_url, '^site_url' => $site_url);
qa_send_notification($uid, '@', $handle, $subject, $body, $subs);
}
示例4: qa_share_buttons
function qa_share_buttons($q_view)
{
if (qa_opt('expert_question_enable')) {
$qid = $q_view['raw']['postid'];
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true);
if ($expert) {
return;
}
}
$url = qa_path_html(qa_q_request($q_view['raw']['postid'], $q_view['raw']['title']), null, qa_opt('site_url'));
$code = array('facebook' => '<iframe src="//www.facebook.com/plugins/like.php?href=' . qa_path_html(qa_q_request($this->content['q_view']['raw']['postid'], $this->content['q_view']['raw']['title']), null, qa_opt('site_url')) . '&send=false&layout=standard&width=53&layout=button_count&show_faces=false&action=like&colorscheme=light&font&height=20&appId=170382616390886" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:53px; height:20px;" allowTransparency="true"></iframe>', 'twitter' => '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>', 'google' => '<g:plusone size="medium" count="false"></g:plusone>', 'linkedin' => '<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script>', 'email' => '<a title="Share this question via email" id="share-button-email" href="mailto:?subject=' . rawurlencode('[' . qa_opt('site_title') . '] ' . $q_view['raw']['title']) . '&body=' . rawurlencode($url) . '"><img height="24" src="' . QA_HTML_THEME_LAYER_URLTOROOT . 'qa-share-mail.png' . '"/></a>');
// sort by weight
$weight = array('facebook' => qa_opt('share_plugin_facebook_weight'), 'twitter' => qa_opt('share_plugin_twitter_weight'), 'google' => qa_opt('share_plugin_google_weight'), 'linkedin' => qa_opt('share_plugin_linkedin_weight'), 'email' => qa_opt('share_plugin_email_weight'));
asort($weight);
// output
foreach ($weight as $key => $val) {
if (qa_opt('share_plugin_' . $key)) {
$shares[] = $code[$key];
}
}
if (empty($shares)) {
return null;
}
$output = implode(' ', $shares);
return $output;
}
示例5: 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));
}
}
示例6: process_event
public function process_event($event, $userid, $handle, $cookieid, $params)
{
switch ($event) {
case 'q_post':
$this->send_hipchat_notification($this->build_new_question_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $params['title'], qa_q_path($params['postid'], $params['title'], true)));
break;
case 'a_post':
$parentpost = qa_post_get_full($params['parentid']);
$this->send_hipchat_notification($this->build_new_answer_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $parentpost['title'], qa_path(qa_q_request($params['parentid'], $parentpost['title']), null, qa_opt('site_url'), null, qa_anchor('A', $params['postid']))));
break;
}
}
示例7: html
function html()
{
if (qa_post_text('ajax_merge_get_from')) {
$posts = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid,title FROM ^posts WHERE postid IN (#,#)", qa_post_text('ajax_merge_get_from'), qa_post_text('ajax_merge_get_to')));
if ($posts[0]['postid'] == (int) qa_post_text('ajax_merge_get_from')) {
echo '{"from":"' . $posts[0]['title'] . '","to":"' . $posts[1]['title'] . '","from_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_from'), $posts[0]['title']), null, qa_opt('site_url')) . '","to_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_to'), $posts[1]['title']), null, qa_opt('site_url')) . '"}';
} else {
echo '{"from":"' . $posts[1]['title'] . '","to":"' . $posts[0]['title'] . '","from_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_from'), $posts[1]['title']), null, qa_opt('site_url')) . '","to_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_to'), $posts[0]['title']), null, qa_opt('site_url')) . '"}';
}
return;
}
qa_html_theme_base::html();
}
示例8: doctype
function doctype()
{
if (qa_post_text('merge_from') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$merged = qa_merge_do_merge();
if ($merged === true) {
qa_redirect(qa_q_request(qa_post_text('merge_to'), null), array('merged' => qa_post_text('merge_from')));
} else {
$error1 = $merged[0];
$error2 = $merged[1];
$this->content['error'] = "Error merging posts.";
}
}
qa_html_theme_base::doctype();
}
示例9: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
$temp = qa_db_query_sub('SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$', 'Q');
$max = mysqli_num_rows($temp);
if (!$max) {
return;
}
$themeobject->output('<h2>' . qa_opt('random_question_title') . '</h2>');
for ($i = 0; $i < qa_opt('random_question_number'); $i++) {
$rand = rand() / getrandmax() * $max;
$check = mysqli_data_seek($temp, $rand);
if (!$check) {
$i--;
} else {
$random_question = qa_db_read_one_assoc($temp, true);
}
if (is_array($random_question)) {
$votes = (int) $random_question['netvotes'];
if ($votes > 0) {
if ($votes > 1) {
$votes = str_replace('^', '+' . $votes, qa_lang('main/x_votes'));
} else {
$votes = str_replace('1', '+1', qa_lang('main/1_vote'));
}
} else {
if ($votes < 0) {
if ($votes < -1) {
$votes = str_replace('^', $votes, qa_lang('main/x_votes'));
} else {
$votes = str_replace('1', '-1', qa_lang('main/1_vote'));
}
} else {
$votes = '';
}
}
$answers = (int) $random_question['acount'];
if ($answers > 0) {
if ($answers > 1) {
$answers = str_replace('^', '+' . $answers, qa_lang('main/x_answers'));
} else {
$answers = qa_lang('main/1_answer');
}
} else {
$answers = '';
}
$themeobject->output('<div class="random-question" style="padding-bottom:4px;"><a href="' . qa_path_html(qa_q_request($random_question['postid'], $random_question['title'])) . '">' . $random_question['title'] . '</a></div><div class="random-question-meta" style="padding-bottom:4px; border-bottom:1px solid; margin-bottom:2px;">' . $votes . ($votes && $answers ? ', ' : '') . $answers . '</div>');
}
}
}
示例10: qa_merge_do_merge
function qa_merge_do_merge()
{
qa_opt('merge_question_merged', qa_post_text('merge_question_merged'));
$from = (int) qa_post_text('merge_from');
$to = (int) qa_post_text('merge_to');
$titles = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid,title,acount FROM ^posts WHERE postid IN (#,#)", qa_post_text('merge_from'), qa_post_text('merge_to')));
if (count($titles) != 2) {
$error1 = null;
$error2 = null;
if (empty($titles)) {
$error1 = 'Post not found.';
$error2 = $error1;
} else {
if ($titles[0]['postid'] == $from) {
$error2 = 'Post not found.';
} else {
if ($titles[0]['postid'] == $to) {
$error1 = 'Post not found.';
} else {
$error1 = 'unknown error.';
}
}
}
return array($error1, $error2);
} else {
$acount = (int) $titles[0]['acount'] + (int) $titles[1]['acount'];
$text = '<div class="qa-content-merged"> ' . str_replace('^post', qa_path(qa_q_request((int) qa_post_text('merge_to'), $titles[0]['postid'] == $to ? $titles[0]['title'] : $titles[1]['title']), null, qa_opt('site_url')), qa_opt('merge_question_merged')) . ' </div>';
qa_db_query_sub("UPDATE ^posts SET parentid=# WHERE parentid=#", $to, $from);
qa_db_query_sub("UPDATE ^posts SET acount=# WHERE postid=#", $acount, $to);
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT \'\',
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
qa_db_query_sub("INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,'merged_with',#)", $from, $to);
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
qa_post_delete($from);
return true;
}
}
示例11: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
if (qa_opt('expert_question_enable')) {
switch ($event) {
case 'q_post':
if (qa_post_text('is_expert_question') == 'yes' || in_array(qa_opt('expert_question_type'), array(1, 2)) && !qa_get_logged_in_userid() || qa_opt('expert_question_type') == 3) {
require_once QA_INCLUDE_DIR . 'qa-app-post-update.php';
qa_question_set_hidden($params, true, $userid, $handle, $cookieid, array(), array());
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT \'\',
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
qa_db_query_sub("INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,'is_expert_question','1')", $params['postid']);
if (qa_opt('expert_question_email_experts')) {
$subs = array('^post_title' => $params['title'], '^post_url' => qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url')), '^questions_list' => qa_path_html(qa_opt('expert_question_page_url'), null, qa_opt('site_url')), '^site_url' => qa_opt('site_url'));
$experts = explode("\n", qa_opt('expert_question_users'));
foreach ($experts as $expert) {
if (strpos($expert, '=')) {
$expert = explode('=', $expert);
$catnames = explode(',', $expert[1]);
$cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames));
if (in_array($params['categoryid'], $cats)) {
qa_send_notification($this->getuserfromhandle($expert[0]), '@', $expert[0], qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs);
}
} else {
qa_send_notification($this->getuserfromhandle($expert), '@', $expert, qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs);
}
}
}
}
break;
default:
break;
}
}
}
示例12: qa_badge_plugin_user_form
function qa_badge_plugin_user_form($userid)
{
$handles = qa_userids_to_handles(array($userid));
$handle = $handles[$userid];
// displays badge list in user profile
$result = qa_db_read_all_assoc(qa_db_query_sub('SELECT badge_slug as slug, object_id AS oid FROM ^userbadges WHERE user_id=#', $userid));
$fields = array();
if (count($result) > 0) {
// count badges
$bin = qa_get_badge_list();
$badges = array();
foreach ($result as $info) {
$slug = $info['slug'];
$type = $bin[$slug]['type'];
if (isset($badges[$type][$slug])) {
$badges[$type][$slug]['count']++;
} else {
$badges[$type][$slug]['count'] = 1;
}
if ($info['oid']) {
$badges[$type][$slug]['oid'][] = $info['oid'];
}
}
foreach ($badges as $type => $badge) {
$typea = qa_get_badge_type($type);
$types = $typea['slug'];
$typed = $typea['name'];
$output = '
<table>
<tr>
<td class="qa-form-wide-label">
<h3 class="badge-title" title="' . qa_lang('badges/' . $types . '_desc') . '">' . $typed . '</h3>
</td>
</tr>';
foreach ($badge as $slug => $info) {
$badge_name = qa_lang('badges/' . $slug);
if (!qa_opt('badge_' . $slug . '_name')) {
qa_opt('badge_' . $slug . '_name', $badge_name);
}
$name = qa_opt('badge_' . $slug . '_name');
$count = $info['count'];
if (qa_opt('badge_show_source_posts')) {
$oids = @$info['oid'];
} else {
$oids = null;
}
$var = qa_opt('badge_' . $slug . '_var');
$desc = qa_badge_desc_replace($slug, $var, $name);
// badge row
$output .= '
<tr>
<td class="badge-container">
<div class="badge-container-badge">
<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '</span> <span onclick="jQuery(\'.badge-container-sources-' . $slug . '\').slideToggle()" class="badge-count' . (is_array($oids) ? ' badge-count-link" title="' . qa_lang('badges/badge_count_click') : '') . '">x ' . $count . '</span>
</div>';
// source row(s) if any
if (is_array($oids)) {
$output .= '
<div class="badge-container-sources-' . $slug . '" style="display:none">';
foreach ($oids as $oid) {
$post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $oid));
$title = $post['title'];
$anchor = '';
if ($post['parentid']) {
$anchor = urlencode(qa_anchor($post['type'], $oid));
$oid = $post['parentid'];
$title = qa_db_read_one_value(qa_db_query_sub('SELECT BINARY title as title FROM ^posts WHERE postid=#', $oid), true);
}
$length = 30;
$text = qa_strlen($title) > $length ? qa_substr($title, 0, $length) . '...' : $title;
$output .= '
<div class="badge-source"><a href="' . qa_path_html(qa_q_request($oid, $title), NULL, qa_opt('site_url')) . ($anchor ? '#' . $anchor : '') . '">' . qa_html($text) . '</a></div>';
}
}
$output .= '
</td>
</tr>';
}
$output .= '
</table>';
$outa[] = $output;
}
$fields[] = array('value' => '<table class="badge-user-tables"><tr><td class="badge-user-table">' . implode('</td><td class="badge-user-table">', $outa) . '</td></tr></table>', 'type' => 'static');
}
$ok = null;
$tags = null;
$buttons = array();
if ((bool) qa_opt('badge_email_notify') && qa_get_logged_in_handle() == $handle) {
// add badge notify checkbox
if (qa_clicked('badge_email_notify_save')) {
qa_opt('badge_email_notify_id_' . $userid, (bool) qa_post_text('badge_notify_email_me'));
$ok = qa_lang('badges/badge_notified_email_me');
}
$select = (bool) qa_opt('badge_email_notify_id_' . $userid);
$tags = 'id="badge-form" action="' . qa_self_html() . '#signature_text" method="POST"';
$fields[] = array('type' => 'blank');
$fields[] = array('label' => qa_lang('badges/badge_notify_email_me'), 'type' => 'checkbox', 'tags' => 'NAME="badge_notify_email_me"', 'value' => $select);
$buttons[] = array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="badge_email_notify_save"');
}
return array('ok' => $ok && !isset($error) ? $ok : null, 'style' => 'tall', 'tags' => $tags, 'title' => qa_lang('badges/badges'), 'fields' => $fields, 'buttons' => $buttons);
//.........这里部分代码省略.........
示例13: post
function post($event, $userid, $handle, $params, $type)
{
// remove mentions
if (!qa_opt('buddypress_mentions')) {
remove_filter('bp_activity_after_save', 'bp_activity_at_name_filter_updates');
}
switch ($type) {
case 'Q':
$suffix = ' question ';
break;
case 'A':
$suffix = 'n %answer% to the question ';
break;
case 'C':
$suffix = ' %comment% on the question ';
break;
}
// poll integration
if (qa_post_text('is_poll')) {
if ($type == 'A') {
return;
}
if ($type == 'Q') {
$suffix = str_replace('question', 'poll', $suffix);
} else {
$suffix = str_replace('question', 'poll', $suffix);
}
}
$content = $params['content'];
// activity post
if ($event != 'q_post') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $params['parentid']), true);
if ($parent['type'] == 'A') {
$parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $parent['parentid']), true);
}
$anchor = qa_anchor($event == 'a_post' ? 'A' : 'C', $params['postid']);
$suffix = preg_replace('/%([^%]+)%/', '<a href="' . qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor) . '">$1</a>', $suffix);
$activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'));
$context = $suffix . '"<a href="' . $activity_url . '">' . $parent['title'] . '</a>"';
} else {
$activity_url = qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url'));
$context = $suffix . '"<a href="' . $activity_url . '">' . $params['title'] . '</a>"';
}
if (qa_opt('buddypress_display_names')) {
$name = bp_core_get_user_displayname($handle) ? bp_core_get_user_displayname($handle) : $handle;
} else {
$name = $handle;
}
$action = '<a href="' . bp_core_get_user_domain($userid) . '" rel="nofollow">' . $name . '</a> posted a' . $context . ' at <a href="' . qa_opt('site_url') . '">' . qa_opt('site_title') . '</a>';
if (qa_opt('buddypress_integration_include_content')) {
$informat = $params['format'];
$viewer = qa_load_viewer($content, $informat);
if (qa_opt('buddypress_integration_max_post_length') && strlen($content) > (int) qa_opt('buddypress_integration_max_post_length')) {
$content = substr($content, 0, (int) qa_opt('buddypress_integration_max_post_length'));
$content = $content . ' ...';
}
$content = $viewer->get_html($content, $informat, array());
} else {
$content = null;
}
global $phpmailer;
if (class_exists('PHPMailer') && !is_object($phpmailer)) {
$phpmailer = new PHPMailer(true);
}
$act_id = qa_buddypress_activity_post(array('action' => $action, 'content' => $content, 'primary_link' => $activity_url, 'component' => 'bp-qa', 'type' => 'activity_qa_' . $type, 'user_id' => $userid, 'item_id' => null));
}
示例14: array_keys
// extract IDs and prepare for pagination
$answerids = array_keys($answerposition);
$countforpages = count($answerids);
$pagesize = qa_opt('page_size_q_as');
// see if we need to display a particular answer
if (isset($showid)) {
if (isset($commentsfollows[$showid])) {
$showid = $commentsfollows[$showid]['parentid'];
}
$position = array_search($showid, $answerids);
if (is_numeric($position)) {
$pagestart = floor($position / $pagesize) * $pagesize;
}
}
// set the canonical url based on possible pagination
$qa_content['canonical'] = qa_path_html(qa_q_request($question['postid'], $question['title']), $pagestart > 0 ? array('start' => $pagestart) : null, qa_opt('site_url'));
// build the actual answer list
$answerids = array_slice($answerids, $pagestart, $pagesize);
foreach ($answerids as $answerid) {
$answer = $answers[$answerid];
if (!($formtype == 'a_edit' && $formpostid == $answerid)) {
$a_view = qa_page_q_answer_view($question, $answer, $answer['isselected'], $usershtml, $formrequested);
// Prepare content for comments on this answer, plus add or edit comment forms
if ($formtype == 'c_add' && $formpostid == $answerid || $answer['commentbutton'] && !$formrequested) {
// ...to be added
$a_view['c_form'] = qa_page_q_add_c_form($qa_content, $question, $answer, 'c' . $answerid, $captchareason, @$cnewin[$answerid], @$cnewerrors[$answerid], $formtype == 'c_add');
if ($formtype == 'c_add' && $formpostid == $answerid) {
$jumptoanchor = 'c' . $answerid;
$commentsall = $answerid;
}
} elseif ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $answerid) {
示例15: ra_user_badges_list
function ra_user_badges_list($userid)
{
if (!qa_opt('badge_active')) {
return;
}
$handles = qa_userids_to_handles(array($userid));
$handle = $handles[$userid];
// displays badge list in user profile
$result = qa_db_read_all_assoc(qa_db_query_sub('SELECT badge_slug as slug, object_id AS oid FROM ^userbadges WHERE user_id=#', $userid));
if (count($result) > 0) {
// count badges
$bin = qa_get_badge_list();
$badges = array();
foreach ($result as $info) {
$slug = $info['slug'];
$type = $bin[$slug]['type'];
if (isset($badges[$type][$slug])) {
$badges[$type][$slug]['count']++;
} else {
$badges[$type][$slug]['count'] = 1;
}
if ($info['oid']) {
$badges[$type][$slug]['oid'][] = $info['oid'];
}
}
foreach ($badges as $type => $badge) {
$typea = qa_get_badge_type($type);
$types = $typea['slug'];
$typed = $typea['name'];
$output = '';
//$output = '<h3 class="badge-title" title="'.qa_lang('badges/'.$types.'_desc').'">'.$typed.'</h3>';
foreach ($badge as $slug => $info) {
$badge_name = qa_badge_name($slug);
if (!qa_opt('badge_' . $slug . '_name')) {
qa_opt('badge_' . $slug . '_name', $badge_name);
}
$name = qa_opt('badge_' . $slug . '_name');
$count = $info['count'];
if (qa_opt('badge_show_source_posts')) {
$oids = @$info['oid'];
} else {
$oids = null;
}
$var = qa_opt('badge_' . $slug . '_var');
$desc = qa_badge_desc_replace($slug, $var, false);
// badge row
$output .= '<div class="badge-container-badge">
<span class="user-badge ' . $types . ' icon-badge" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '</span> <span class="badge-count">x ' . $count . '</span>' . (is_array($oids) ? '<i class="icon-chevron-down"></i>' : '');
// source row(s) if any
if (is_array($oids)) {
$output .= '
<div class="badge-sources ' . $slug . '"><ul>';
foreach ($oids as $oid) {
$post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $oid));
$title = $post['title'];
$anchor = '';
if ($post['parentid']) {
$anchor = urlencode(qa_anchor($post['type'], $oid));
$oid = $post['parentid'];
$title = qa_db_read_one_value(qa_db_query_sub('SELECT BINARY title as title FROM ^posts WHERE postid=#', $oid), true);
}
//$length = 30;
$text = $title;
$output .= '<li><a href="' . qa_path_html(qa_q_request($oid, $title), NULL, qa_opt('site_url')) . ($anchor ? '#' . $anchor : '') . '">' . qa_html($text) . '</a></li>';
}
$output .= '</ul></div>';
}
$output .= '</div>';
}
$outa[] = $output;
}
$fields = '<div class="badge-user-block widget"><h3 class="widget-title">' . _ra_lang('Badges') . '</h3><div class="widget-inner">' . implode('', $outa) . '</div></div>';
}
return $fields;
}