当前位置: 首页>>代码示例>>PHP>>正文


PHP qa_anchor函数代码示例

本文整理汇总了PHP中qa_anchor函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_anchor函数的具体用法?PHP qa_anchor怎么用?PHP qa_anchor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qa_anchor函数的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));
    }
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:27,代码来源:qa-app-post-update.php

示例2: 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);
}
开发者ID:NoahY,项目名称:q2a-privileges,代码行数:34,代码来源:qa-plugin.php

示例3: 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;
     }
 }
开发者ID:jereze,项目名称:qa-hipchat-notifications,代码行数:12,代码来源:qa-hipchat-notifications-event.php

示例4: qa_user_use_captcha

    require_once QA_INCLUDE_DIR . 'pages/question-view.php';
    require_once QA_INCLUDE_DIR . 'pages/question-submit.php';
    require_once QA_INCLUDE_DIR . 'util/sort.php';
    //	Try to create the new comment
    $usecaptcha = qa_user_use_captcha(qa_user_level_for_post($question));
    $commentid = qa_page_q_add_c_submit($question, $parent, $children, $usecaptcha, $in, $errors);
    //	If successful, page content will be updated via Ajax
    if (isset($commentid)) {
        $children = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $parentid));
        $parent = $parent + qa_page_q_post_rules($parent, $questionid == $parentid ? null : $question, null, $children);
        // in theory we should retrieve the parent's siblings for the above, but they're not going to be relevant
        foreach ($children as $key => $child) {
            $children[$key] = $child + qa_page_q_post_rules($child, $parent, $children, null);
        }
        $usershtml = qa_userids_handles_html($children, true);
        qa_sort_by($children, 'created');
        $c_list = qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null);
        $themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);
        echo "QA_AJAX_RESPONSE\n1\n";
        //	Send back the ID of the new comment
        echo qa_anchor('C', $commentid) . "\n";
        //	Send back the HTML
        $themeclass->c_list_items($c_list['cs']);
        return;
    }
}
echo "QA_AJAX_RESPONSE\n0\n";
// fall back to non-Ajax submission if there were any problems
/*
	Omit PHP closing tag to help avoid accidental output
*/
开发者ID:Trideon,项目名称:gigolo,代码行数:31,代码来源:comment.php

示例5: process_request


//.........这里部分代码省略.........
                            $userhandle = qa_post_userid_to_handle($userid);
                            // from v1.7 require_once QA_INCLUDE_DIR.'qa-app-users.php'; and qa_userid_to_handle($userid);
                            $activity_url = qa_path_absolute('user') . '/' . $userhandle . '/wall';
                            $linkTitle = qa_lang('q2apro_onsitenotifications_lang/wallpost_from') . ' ' . $event['handle'];
                        } else {
                            // a_post, c_post, q_vote_up, a_vote_up, q_vote_down, a_vote_down
                            $postid = preg_replace('/_.*/', '', $postid_string);
                            $post = null;
                            // assign post content (postid,type,parentid,title) if available
                            $post = @$posts[$postid];
                            $params = array();
                            // explode string to array with values (memo: leave "\t", '\t' will cause errors)
                            $paramsa = explode("\t", $event['params']);
                            foreach ($paramsa as $param) {
                                $parama = explode('=', $param);
                                if (isset($parama[1])) {
                                    $params[$parama[0]] = $parama[1];
                                } else {
                                    $params[$param] = $param;
                                }
                            }
                            $link = '';
                            $linkTitle = '';
                            $activity_url = '';
                            // comment or answer
                            if (isset($post) && strpos($event['event'], 'q_') !== 0 && strpos($event['event'], 'in_q_') !== 0) {
                                if (!isset($params['parentid'])) {
                                    $params['parentid'] = $post['parentid'];
                                }
                                $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $params['parentid']));
                                if ($parent['type'] == 'A') {
                                    $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $parent['parentid']));
                                }
                                $anchor = qa_anchor(strpos($event['event'], 'a_') === 0 || strpos($event['event'], 'in_a_') === 0 ? 'A' : 'C', $params['postid']);
                                $activity_url = qa_path_absolute(qa_q_request($parent['postid'], $parent['title']), null, $anchor);
                                $linkTitle = $parent['title'];
                                $link = '<a target="_blank" href="' . $activity_url . '">' . $parent['title'] . '</a>';
                            } else {
                                if (isset($post)) {
                                    // question
                                    if (!isset($params['title'])) {
                                        $params['title'] = $posts[$params['postid']]['title'];
                                    }
                                    if ($params['title'] !== null) {
                                        $qTitle = qa_db_read_one_value(qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = " . $params['postid'] . " LIMIT 1"), true);
                                        if (!isset($qTitle)) {
                                            $qTitle = '';
                                        }
                                        $activity_url = qa_path_absolute(qa_q_request($params['postid'], $qTitle), null, null);
                                        $linkTitle = $qTitle;
                                        $link = '<a target="_blank" href="' . $activity_url . '">' . $qTitle . '</a>';
                                    }
                                }
                            }
                            // event name
                            $eventName = '';
                            $itemIcon = '';
                            if ($type == 'in_c_question' || $type == 'in_c_answer' || $type == 'in_c_comment') {
                                // added in_c_comment
                                $eventName = qa_lang('q2apro_onsitenotifications_lang/in_comment');
                                $itemIcon = '<div class="nicon ncomment"></div>';
                            } else {
                                if ($type == 'in_q_vote_up' || $type == 'in_a_vote_up') {
                                    $eventName = qa_lang('q2apro_onsitenotifications_lang/in_upvote');
                                    $itemIcon = '<div class="nicon nvoteup"></div>';
                                } else {
开发者ID:Kasparohub,项目名称:q2apro-on-site-notifications,代码行数:67,代码来源:q2apro-onsitenotifications-page.php

示例6: 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;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:33,代码来源:qa-app-votes.php

示例7: qa_q_path

function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    if (($showtype == 'Q' || $showtype == 'A' || $showtype == 'C') && isset($showid)) {
        $params = array('show' => $showid);
        // due to pagination
        $anchor = qa_anchor($showtype, $showid);
    } else {
        $params = null;
        $anchor = null;
    }
    return qa_path(qa_q_request($questionid, $title), $params, $absolute ? qa_opt('site_url') : null, null, $anchor);
}
开发者ID:netham91,项目名称:question2answer,代码行数:16,代码来源:qa-base.php

示例8: qa_post_html_fields

function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $options = array())
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/updates.php';
    if (isset($options['blockwordspreg'])) {
        require_once QA_INCLUDE_DIR . 'util/string.php';
    }
    $fields = array('raw' => $post);
    //	Useful stuff used throughout function
    $postid = $post['postid'];
    $isquestion = $post['basetype'] == 'Q';
    $isanswer = $post['basetype'] == 'A';
    $isbyuser = qa_post_is_by_user($post, $userid, $cookieid);
    $anchor = urlencode(qa_anchor($post['basetype'], $postid));
    $elementid = isset($options['elementid']) ? $options['elementid'] : $anchor;
    $microformats = @$options['microformats'];
    $isselected = @$options['isselected'];
    $favoritedview = @$options['favoritedview'];
    $favoritemap = $favoritedview ? qa_get_favorite_non_qs_map() : array();
    //	High level information
    $fields['hidden'] = @$post['hidden'];
    $fields['tags'] = 'id="' . qa_html($elementid) . '"';
    $fields['classes'] = $isquestion && $favoritedview && @$post['userfavoriteq'] ? 'qa-q-favorited' : '';
    if ($isquestion && isset($post['closedbyid'])) {
        $fields['classes'] = ltrim($fields['classes'] . ' qa-q-closed');
    }
    if ($microformats) {
        $fields['classes'] .= ' hentry ' . ($isquestion ? 'question' : ($isanswer ? $isselected ? 'answer answer-selected' : 'answer' : 'comment'));
    }
    //	Question-specific stuff (title, URL, tags, answer count, category)
    if ($isquestion) {
        if (isset($post['title'])) {
            $fields['url'] = qa_q_path_html($postid, $post['title']);
            if (isset($options['blockwordspreg'])) {
                $post['title'] = qa_block_words_replace($post['title'], $options['blockwordspreg']);
            }
            $fields['title'] = qa_html($post['title']);
            if ($microformats) {
                $fields['title'] = '<span class="entry-title">' . $fields['title'] . '</span>';
            }
            /*if (isset($post['score'])) // useful for setting match thresholds
            		$fields['title'].=' <small>('.$post['score'].')</small>';*/
        }
        if (@$options['tagsview'] && isset($post['tags'])) {
            $fields['q_tags'] = array();
            $tags = qa_tagstring_to_tags($post['tags']);
            foreach ($tags as $tag) {
                if (isset($options['blockwordspreg']) && count(qa_block_words_match_all($tag, $options['blockwordspreg']))) {
                    // skip censored tags
                    continue;
                }
                $fields['q_tags'][] = qa_tag_html($tag, $microformats, @$favoritemap['tag'][qa_strtolower($tag)]);
            }
        }
        if (@$options['answersview'] && isset($post['acount'])) {
            $fields['answers_raw'] = $post['acount'];
            $fields['answers'] = $post['acount'] == 1 ? qa_lang_html_sub_split('main/1_answer', '1', '1') : qa_lang_html_sub_split('main/x_answers', number_format($post['acount']));
            $fields['answer_selected'] = isset($post['selchildid']);
        }
        if (@$options['viewsview'] && isset($post['views'])) {
            $fields['views_raw'] = $post['views'];
            $fields['views'] = $post['views'] == 1 ? qa_lang_html_sub_split('main/1_view', '1', '1') : qa_lang_html_sub_split('main/x_views', number_format($post['views']));
        }
        if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath'])) {
            $favoriteclass = '';
            if (count(@$favoritemap['category'])) {
                if (@$favoritemap['category'][$post['categorybackpath']]) {
                    $favoriteclass = ' qa-cat-favorited';
                } else {
                    foreach ($favoritemap['category'] as $categorybackpath => $dummy) {
                        if (substr('/' . $post['categorybackpath'], -strlen($categorybackpath)) == $categorybackpath) {
                            $favoriteclass = ' qa-cat-parent-favorited';
                        }
                    }
                }
            }
            $fields['where'] = qa_lang_html_sub_split('main/in_category_x', '<a href="' . qa_path_html(@$options['categorypathprefix'] . implode('/', array_reverse(explode('/', $post['categorybackpath'])))) . '" class="qa-category-link' . $favoriteclass . '">' . qa_html($post['categoryname']) . '</a>');
        }
    }
    //	Answer-specific stuff (selection)
    if ($isanswer) {
        $fields['selected'] = $isselected;
        if ($isselected) {
            $fields['select_text'] = qa_lang_html('question/select_text');
        }
    }
    //	Post content
    if (@$options['contentview'] && isset($post['content'])) {
        $viewer = qa_load_viewer($post['content'], $post['format']);
        $fields['content'] = $viewer->get_html($post['content'], $post['format'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow']));
        if ($microformats) {
            $fields['content'] = '<div class="entry-content">' . $fields['content'] . '</div>';
        }
        $fields['content'] = '<a name="' . qa_html($postid) . '"></a>' . $fields['content'];
        // this is for backwards compatibility with any existing links using the old style of anchor
        // that contained the post id only (changed to be valid under W3C specifications)
    }
//.........这里部分代码省略.........
开发者ID:amiyasahu,项目名称:question2answer,代码行数:101,代码来源:format.php

示例9: 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>&nbsp;<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&nbsp;' . $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);
//.........这里部分代码省略.........
开发者ID:roine,项目名称:q2a-badges,代码行数:101,代码来源:qa-plugin.php

示例10: list_vote_buttons

 function list_vote_buttons($post)
 {
     $onclick = 'onclick="return qa_vote_click(this);"';
     $anchor = urlencode(qa_anchor($post['raw']['type'], $post['raw']['postid']));
     //v($post['vote_up_tags']);
     //v($post['vote_down_tags']);
     if ($post['vote_up_tags'] == ' ') {
         $post['vote_up_tags'] = 'title="' . qa_lang_html('main/voted_up_popup') . '" name="' . qa_html('vote_' . $post['raw']['postid'] . '_0_' . $anchor) . '" ' . $onclick;
     }
     if ($post['vote_down_tags'] == ' ') {
         $post['vote_down_tags'] = 'title="' . qa_lang_html('main/voted_down_popup') . '" name="' . qa_html('vote_' . $post['raw']['postid'] . '_0_' . $anchor) . '" ' . $onclick;
     }
     switch (@$post['vote_state']) {
         case 'voted_up':
             $this->post_hover_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-one-button qa-voted-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_hover_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-one-button qa-vote-down');
             break;
         case 'voted_up_disabled':
             $this->post_disabled_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-one-button qa-vote-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_hover_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-one-button qa-voted-down');
             break;
         case 'voted_down':
             $this->post_hover_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-one-button qa-vote-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_hover_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-one-button qa-voted-down');
             break;
         case 'voted_down_disabled':
             $this->post_hover_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-one-button qa-voted-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_disabled_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-one-button qa-vote-down');
             break;
         case 'up_only':
             $this->post_hover_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-first-button qa-vote-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_disabled_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-second-button qa-vote-down');
             break;
         case 'enabled':
             $this->post_hover_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-first-button qa-vote-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_hover_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-second-button qa-vote-down');
             break;
         default:
             $this->post_disabled_button($post, 'vote_up_tags', '&#xf087;', 'fa btn btn-success qa-item-vote-first-button qa-vote-up');
             $this->output('<div class="qa-list-vote-count">' . $post['netvotes_view']['data'] . '</div>');
             $this->post_disabled_button($post, 'vote_down_tags', '&#xf088;', 'fa btn btn-danger qa-item-vote-second-button qa-vote-down');
             break;
     }
 }
开发者ID:swuit,项目名称:swuit-q2a,代码行数:50,代码来源:qa-layer-base.php

示例11: activitylist

    function activitylist()
    {
        // get points for each activity
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $event_point['in_a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $event_point['q_post'] = (int) $options['points_post_q'] * $multi;
        $event_point['a_post'] = (int) $options['points_post_a'] * $multi;
        $event_point['a_select'] = (int) $options['points_select_a'] * $multi;
        $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        /*
        // Exclude Activities
        $exclude = array(
        	'u_login',
        	'u_logout',
        	'u_password',
        	'u_reset',
        	'u_save',
        	'u_edit',
        	'u_block',
        	'u_unblock',
        	'feedback',
        	'search',
        	'badge_awarded',
        );
        $excludes = "'".implode("','",$exclude)."'";
        $eventslist = qa_db_read_all_assoc(
        	qa_db_query_sub( 
        		'SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE userid=# AND 
        		DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
        		AND event NOT IN (' . $excludes .') ORDER BY datetime DESC'.(qa_opt('qat_activity_number')?' LIMIT '.(int)qa_opt('qat_activity_number'):''),
        		$userid, qa_opt('qat_activity_age')
        	)
        );
        */
        // Get Events
        $userid = qa_get_logged_in_userid();
        $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE effecteduserid=# AND 
				DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
				ORDER BY datetime DESC' . (qa_opt('qat_activity_number') ? ' LIMIT ' . (int) qa_opt('qat_activity_number') : ''), $userid, qa_opt('qat_activity_age')));
        $event = array();
        $output = '';
        $i = 0;
        //
        $userids = array();
        foreach ($eventslist as $event) {
            $userids[$event['userid']] = $event['userid'];
            $userids[$event['effecteduserid']] = $event['effecteduserid'];
        }
        $handles = qa_db_user_get_userid_handles($userids);
        // get event's: time, type, parameters
        // get post id of questions
        foreach ($eventslist as $event) {
            $title = '';
            $link = '';
            $vote_status = '';
            $handle = $handles[$event['userid']];
            $user_link = qa_path('user/' . $handle);
            $datetime = $event['datetime'];
            $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
            $event['params'] = json_decode($event['params'], true);
            $output .= '<li>';
            switch ($event['event']) {
                case 'related':
                    // related question to an answer
                    $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), null, qa_opt('site_url'), null, null);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">Asked a question related to your answer</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['title'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_post':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
//.........这里部分代码省略.........
开发者ID:swuit,项目名称:swuit-q2a,代码行数:101,代码来源:qa-layer-ajax.php

示例12: qa_news_plugin_createNewsletter

function qa_news_plugin_createNewsletter($send)
{
    $news = qa_opt('news_plugin_template');
    // static replacements
    $news = str_replace('[css]', qa_opt('news_plugin_css'), $news);
    $lastdate = time() - qa_opt('news_plugin_send_days') * 24 * 60 * 60;
    if (qa_opt('news_plugin_max_q') > 0) {
        $selectspec = "SELECT postid, BINARY title AS title, BINARY content AS content, format, netvotes, userid FROM ^posts WHERE type='Q' AND FROM_UNIXTIME(#) <= created AND netvotes > 0 ORDER BY netvotes DESC, created ASC LIMIT " . (int) qa_opt('news_plugin_max_q');
        $sub = qa_db_query_sub($selectspec, $lastdate);
        while (($post = qa_db_read_one_assoc($sub, true)) !== null) {
            $qcontent = '';
            if (!empty($post['content'])) {
                $viewer = qa_load_viewer($post['content'], $post['format']);
                $content = $viewer->get_html($post['content'], $post['format'], array());
            }
            $one = str_replace('[question-title]', $post['title'], qa_opt('news_plugin_template_question'));
            $one = str_replace('[anchor]', 'question' . $post['postid'], $one);
            $one = str_replace('[url]', qa_html(qa_q_request($post['postid'], $post['title'])), $one);
            $one = str_replace('[question]', $content, $one);
            $votes = str_replace('[number]', ($post['netvotes'] > 0 ? '+' : ($post['netvotes'] < 0 ? '-' : '')) . $post['netvotes'], qa_opt('news_plugin_template_votes'));
            $one = str_replace('[voting]', $votes, $one);
            $uid = $post['userid'];
            $handles = qa_userids_to_handles(array($uid));
            $handle = $handles[$uid];
            $one = str_replace('[meta]', qa_lang_sub('newsletter/meta', '<a href="' . qa_opt('site_url') . 'user/' . $handle . '">' . $handle . '</a>'), $one);
            $qhtml[] = $one;
        }
    }
    if (qa_opt('news_plugin_max_a') > 0) {
        $selectspec = "SELECT a.postid AS postid, a.parentid AS parentid, BINARY a.content AS content, a.format AS format, a.netvotes AS netvotes, a.userid as userid, q.title AS qtitle FROM ^posts AS q, ^posts AS a WHERE a.type='A' AND q.postid=a.parentid AND FROM_UNIXTIME(#) <= a.created AND a.netvotes > 0 ORDER BY a.netvotes DESC, a.created ASC LIMIT " . (int) qa_opt('news_plugin_max_a');
        $sub = qa_db_query_sub($selectspec, $lastdate);
        while (($post = qa_db_read_one_assoc($sub, true)) !== null) {
            $content = '';
            if (!empty($post['content'])) {
                $viewer = qa_load_viewer($post['content'], $post['format']);
                $content = $viewer->get_html($post['content'], $post['format'], array());
            }
            $anchor = qa_anchor('C', $post['postid']);
            $purl = qa_path_html(qa_q_request($post['parentid'], $post['qtitle']), null, qa_opt('site_url'));
            $url = qa_path_html(qa_q_request($post['parentid'], $post['qtitle']), null, qa_opt('site_url'), null, $anchor);
            $response = qa_lang_sub('newsletter/response_to_question', '<a href="' . $purl . '">' . $post['qtitle'] . '</a>');
            $response = str_replace('[url]', $url, $response);
            $one = str_replace('[parent-ref]', $response, qa_opt('news_plugin_template_answer'));
            $one = str_replace('[anchor]', 'answer' . $post['postid'], $one);
            $one = str_replace('[answer]', $content, $one);
            $votes = str_replace('[number]', ($post['netvotes'] > 0 ? '+' : ($post['netvotes'] < 0 ? '-' : '')) . $post['netvotes'], qa_opt('news_plugin_template_votes'));
            $one = str_replace('[voting]', $votes, $one);
            $uid = $post['userid'];
            $handles = qa_userids_to_handles(array($uid));
            $handle = $handles[$uid];
            $one = str_replace('[meta]', qa_lang_sub('newsletter/meta', '<a href="' . qa_opt('site_url') . 'user/' . $handle . '">' . $handle . '</a>'), $one);
            $ahtml[] = $one;
        }
    }
    if (qa_opt('news_plugin_max_c') > 0) {
        $selectspec = "SELECT c.postid AS postid, c.parentid AS parentid, BINARY c.content AS content, c.format AS format, c.netvotes AS netvotes, c.userid as userid, p.title AS ptitle, p.parentid AS gpostid, g.title AS gtitle FROM ^posts AS c INNER JOIN ^posts AS p ON c.type='C' AND p.postid=c.parentid AND FROM_UNIXTIME(#) <= c.created LEFT JOIN ^posts AS g ON g.postid=p.parentid AND g.type='Q' AND c.netvotes > 0 ORDER BY c.netvotes DESC, c.created ASC LIMIT " . (int) qa_opt('news_plugin_max_a');
        $sub = qa_db_query_sub($selectspec, $lastdate);
        while (($post = qa_db_read_one_assoc($sub, true)) !== null) {
            $content = '';
            if (!empty($post['content'])) {
                $viewer = qa_load_viewer($post['content'], $post['format']);
                $content = $viewer->get_html($post['content'], $post['format'], array());
            }
            if (isset($post['gtitle'])) {
                $parent = 'answer';
                $title = $post['gtitle'];
                $parentid = $post['gpostid'];
                $aurl = qa_path_html(qa_q_request($post['parentid'], $title), null, qa_opt('site_url'), null, qa_anchor('A', $post['parentid']));
            } else {
                $parent = 'question';
                $title = $post['ptitle'];
                $parentid = $post['parentid'];
            }
            $anchor = qa_anchor('C', $post['postid']);
            $purl = qa_path_html(qa_q_request($parentid, $title), null, qa_opt('site_url'));
            $url = qa_path_html(qa_q_request($parentid, $title), null, qa_opt('site_url'), null, $anchor);
            $response = qa_lang_sub('newsletter/response_to_' . $parent, '<a href="' . $purl . '">' . $title . '</a>');
            $response = str_replace('[url]', $url, $response);
            if (isset($aurl)) {
                $response = str_replace('[aurl]', $aurl, $response);
            }
            $one = str_replace('[parent-ref]', $response, qa_opt('news_plugin_template_comment'));
            $one = str_replace('[anchor]', 'comment' . $post['postid'], $one);
            $one = str_replace('[comment]', $content, $one);
            $votes = str_replace('[number]', ($post['netvotes'] > 0 ? '+' : ($post['netvotes'] < 0 ? '-' : '')) . $post['netvotes'], qa_opt('news_plugin_template_votes'));
            $one = str_replace('[voting]', $votes, $one);
            $uid = $post['userid'];
            $handles = qa_userids_to_handles(array($uid));
            $handle = $handles[$uid];
            $one = str_replace('[meta]', qa_lang_sub('newsletter/meta', '<a href="' . qa_opt('site_url') . 'user/' . $handle . '">' . $handle . '</a>'), $one);
            $chtml[] = $one;
        }
    }
    $news = str_replace('[questions]', implode('<hr class="inner">', $qhtml), $news);
    $news = str_replace('[answers]', implode('<hr class="inner">', $ahtml), $news);
    $news = str_replace('[comments]', implode('<hr class="inner">', $chtml), $news);
    // misc subs
    $news = str_replace('[intro]', qa_lang('newsletter/intro'), $news);
    $news = str_replace('[footer]', qa_lang('newsletter/footer'), $news);
    $news = str_replace('[site-title]', qa_opt('site_title'), $news);
//.........这里部分代码省略.........
开发者ID:ruuttt,项目名称:question2answer_sandbox,代码行数:101,代码来源:qa-plugin.php

示例13: qa_search_max_match_anchor

function qa_search_max_match_anchor($question)
{
    $anchorscore = array();
    $matchparts = explode(',', $question['matchparts']);
    foreach ($matchparts as $matchpart) {
        if (sscanf($matchpart, '%1s:%f:%f', $matchposttype, $matchpostid, $matchscore) == 3) {
            @($anchorscore[qa_anchor($matchposttype, $matchpostid)] += $matchscore);
        }
    }
    if (count($anchorscore)) {
        $anchor = array_search(max($anchorscore), $anchorscore);
        if ($anchor != qa_anchor('Q', $question['postid'])) {
            return $anchor;
        }
    }
    return null;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:17,代码来源:qa-db-selects.php

示例14: qa_base_db_disconnect

qa_base_db_disconnect();
//	Prepare the XML output
$lines = array();
$lines[] = '<?xml version="1.0" encoding="UTF-8"?>';
$lines[] = '<rss version="2.0">';
$lines[] = '<channel>';
$lines[] = '<title>' . qa_html($sitetitle . ' - ' . $title) . '</title>';
$lines[] = '<link>' . qa_path_html($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);
    $anchor = null;
    if (isset($question['opostid'])) {
        if ($question['obasetype'] != 'Q') {
            $anchor = qa_anchor($question['obasetype'], $question['opostid']);
        }
        $time = $question['otime'];
        if ($full) {
            $htmlcontent = qa_viewer_html($question['ocontent'], $question['oformat'], $options);
        }
    } else {
        $time = $question['created'];
        if ($full) {
            $htmlcontent = qa_viewer_html($question['content'], $question['format'], $options);
        }
    }
    switch (@$question['obasetype']) {
        case 'A':
            $titleprefix = @$question['oedited'] ? qa_lang('misc/feed_a_edited_prefix') : qa_lang('misc/feed_a_prefix');
            break;
开发者ID:TheProjecter,项目名称:microprobe,代码行数:31,代码来源:qa-feed.php

示例15: user_activity_form


//.........这里部分代码省略.........
            }
            $params = array();
            $paramsa = explode("\t", $event['params']);
            foreach ($paramsa as $param) {
                $parama = explode('=', $param);
                if (isset($parama[1])) {
                    $params[$parama[0]] = $parama[1];
                } else {
                    $params[$param] = $param;
                }
            }
            $link = '';
            if (in_array($type, $nopost)) {
                if ($type == 'search') {
                    if ((int) $params['start'] != 0) {
                        continue;
                    }
                    $link = '<a href="' . qa_path_html('search', array('q' => $params['query'])) . '">' . qa_html($params['query']) . '</a>';
                } else {
                    if (in_array($type, array('u_edit', 'u_level', 'u_block', 'u_unblock'))) {
                        $ohandle = $this->getHandleFromID($params['userid']);
                        $link = '<a href="' . qa_path_html('user/' . $ohandle, null, qa_opt('site_url')) . '">' . $ohandle . '</a>';
                    } else {
                        $link = '';
                    }
                }
            } else {
                if ($type == 'badge_awarded') {
                    if (!qa_opt('badge_active') || !function_exists('qa_get_badge_type')) {
                        continue;
                    }
                    if ($post != null) {
                        if (strpos($post['type'], 'Q') !== 0) {
                            $anchor = qa_anchor(strpos($post['type'], 'A') === 0 ? 'A' : 'C', $params['postid']);
                            $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT parentid,type,BINARY title as title,postid FROM ^posts WHERE postid=#', $post['parentid']), true);
                            if ($parent['type'] == 'A') {
                                $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY title as title,postid FROM ^posts WHERE postid=#', $parent['parentid']), true);
                            }
                            $activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
                            $link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
                        } else {
                            $activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'), null, null);
                            $link = '<a href="' . $activity_url . '">' . $post['title'] . '</a>';
                        }
                    }
                } else {
                    if ($post != null && strpos($event['event'], 'q_') !== 0 && strpos($event['event'], 'in_q_') !== 0) {
                        // comment or answer
                        if (!isset($params['parentid'])) {
                            $params['parentid'] = $post['parentid'];
                        }
                        $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $params['parentid']));
                        if ($parent['type'] == 'A') {
                            $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $parent['parentid']));
                        }
                        $anchor = qa_anchor(strpos($event['event'], 'a_') === 0 || strpos($event['event'], 'in_a_') === 0 ? 'A' : 'C', $params['postid']);
                        $activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
                        $link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
                    } else {
                        if ($post != null) {
                            // question
                            if (!isset($params['title'])) {
                                $params['title'] = $posts[$params['postid']]['title'];
                            }
                            if ($params['title'] !== null) {
                                $activity_url = qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url'));
开发者ID:ruuttt,项目名称:question2answer_sandbox,代码行数:67,代码来源:qa-history-layer.php


注:本文中的qa_anchor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。